diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-07-27 10:15:41 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-07-27 10:15:41 -0700 |
commit | 9f62ed218fa656607740b386c0caa03e65dcd283 (patch) | |
tree | 6bde49bc5e4c4241266b108e4277baef4b85535d /libphobos | |
parent | 71e955da39cea0ebffcfee3432effa622d14ca99 (diff) | |
parent | 5eb9f117a361538834b9740d59219911680717d1 (diff) | |
download | gcc-9f62ed218fa656607740b386c0caa03e65dcd283.zip gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.gz gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.bz2 |
Merge from trunk revision 5eb9f117a361538834b9740d59219911680717d1.
Diffstat (limited to 'libphobos')
168 files changed, 8383 insertions, 9980 deletions
diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index 5359674..2d4abbb 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,3 +1,143 @@ +2022-07-06 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 651389b5. + * src/MERGE: Merge upstream phobos 1516ecad9. + +2022-06-29 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add gcc/simd.d. + * libdruntime/Makefile.in: Regenerate. + * libdruntime/gcc/simd.d: New file. + +2022-06-28 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/gcc/attributes.d (simd): Define. + +2022-06-24 Iain Buclaw <ibuclaw@gdcproject.org> + + PR d/105413 + * libdruntime/gcc/attributes.d (register): Define. + +2022-06-24 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 148608b7. + +2022-06-22 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime e150cca1. + * src/MERGE: Merge upstream phobos a4a18d21c. + * testsuite/libphobos.cycles/cycles.exp (cycle_test_list): Update + expected result of deprecate test. + +2022-06-15 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/gcc/attributes.d (no_sanitize): Define. + (noSanitize): Define. + +2022-06-15 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/gcc/attributes.d (visibility): Define. + (hidden): Define. + +2022-06-13 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 454471d8. + * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add + core/sync/package.d. + * libdruntime/Makefile.in: Regenerate. + * src/MERGE: Merge upstream phobos 1206fc94f. + +2022-06-02 David Malcolm <dmalcolm@redhat.com> + + * testsuite/lib/libphobos-dg.exp: Add load_gcc_lib of scansarif.exp. + +2022-05-27 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime f89da313. + * src/MERGE: Merge upstream phobos d46814c86. + +2022-05-16 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 94bd5bcb. + * libdruntime/Makefile.am (ALL_DRUNTIME_INSTALL_DSOURCES): Add + $(DRUNTIME_DSOURCES_ELF). + (ALL_DRUNTIME_SOURCES): Likewise. + (DRUNTIME_DSOURCES_ELF): New variable. + * libdruntime/Makefile.in: Regenerate. + * src/MERGE: Merge upstream phobos 3a1cd9a01. + * testsuite/libphobos.init_fini/custom_gc.d: Update test. + +2022-04-28 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime e361d200. + +2022-04-26 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/gcc/emutls.d (emutlsDestroyThread): Clear the per-thread + TLS array, don't call free(). + +2022-04-21 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 27834edb. + * src/MERGE: Merge upstream phobos ac296f80c. + * src/Makefile.am (PHOBOS_DSOURCES): Add std/int128.d. + * src/Makefile.in: Regenerate. + +2022-04-13 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 9ba9a6ae. + * src/MERGE: Merge upstream phobos c0cc5e917. + +2022-04-02 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime c52e28b7. + * libdruntime/Makefile.am (DRUNTIME_DSOURCES_OPENBSD): Add + core/sys/openbsd/pwd.d. + * libdruntime/Makefile.in: Regenerate. + * src/MERGE: Merge upstream phobos 99e9c1b77. + * testsuite/libphobos.exceptions/message_with_null.d: New test. + +2022-03-21 Iain Buclaw <ibuclaw@gdcproject.org> + + PR d/104911 + * src/MERGE: Merge upstream phobos a74fa63e6. + +2022-03-13 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 26b58167. + * src/MERGE: Merge upstream phobos 16cb085b5. + +2022-03-11 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + PR d/103528 + * configure.ac <x86_64-*-solaris2.* | i?86-*-solaris2.*>: Remove + gas requirement. + * configure: Regenerate. + * configure.tgt (sparc*-*-solaris2.11*): Mark supported. + +2022-03-02 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 100a608c. + * src/MERGE: Merge upstream phobos a1f8c4c07. + +2022-03-01 Iain Buclaw <ibuclaw@gdcproject.org> + + PR d/104659 + * libdruntime/config/mingw/msvc.c (init_msvc): Fix misspelling of + msvcUsesUCRT. + +2022-02-28 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime caf14b0f. + * src/MERGE: Merge upstream phobos 41aaf8c26. + +2022-02-20 Iain Buclaw <ibuclaw@gdcproject.org> + + * libdruntime/MERGE: Merge upstream druntime 55528bd1. + * src/MERGE: Merge upstream phobos 1a3e80ec2. + * testsuite/libphobos.hash/test_hash.d: Update. + * testsuite/libphobos.betterc/test19933.d: New test. + 2022-02-16 Iain Buclaw <ibuclaw@gdcproject.org> * Makefile.in: Regenerate. diff --git a/libphobos/configure b/libphobos/configure index 17b2656..9da06f0 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -15475,18 +15475,6 @@ $as_echo_n "checking for host support for libphobos... " >&6; } . ${srcdir}/configure.tgt case ${host} in x86_64-*-solaris2.* | i?86-*-solaris2.*) - # libphobos doesn't compile with the Solaris/x86 assembler due to a - # relatively low linelength limit. - as_prog=`$CC -print-prog-name=as` - if test -n "$as_prog" && $as_prog -v /dev/null 2>&1 | grep GNU > /dev/null 2>&1; then - druntime_cv_use_gas=yes; - else - druntime_cv_use_gas=no; - fi - rm -f a.out - if test x$druntime_cv_use_gas = xno; then - LIBPHOBOS_SUPPORTED=no - fi # 64-bit D execution fails with Solaris ld without -z relax=transtls support. if test "$druntime_ld_gld" = "no" && test "$druntime_ld_relax_transtls" = "no"; then LIBPHOBOS_SUPPORTED=no diff --git a/libphobos/configure.ac b/libphobos/configure.ac index 47e2fa9..31209ba 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -189,18 +189,6 @@ AC_MSG_CHECKING([for host support for libphobos]) . ${srcdir}/configure.tgt case ${host} in x86_64-*-solaris2.* | i?86-*-solaris2.*) - # libphobos doesn't compile with the Solaris/x86 assembler due to a - # relatively low linelength limit. - as_prog=`$CC -print-prog-name=as` - if test -n "$as_prog" && $as_prog -v /dev/null 2>&1 | grep GNU > /dev/null 2>&1; then - druntime_cv_use_gas=yes; - else - druntime_cv_use_gas=no; - fi - rm -f a.out - if test x$druntime_cv_use_gas = xno; then - LIBPHOBOS_SUPPORTED=no - fi # 64-bit D execution fails with Solaris ld without -z relax=transtls support. if test "$druntime_ld_gld" = "no" && test "$druntime_ld_relax_transtls" = "no"; then LIBPHOBOS_SUPPORTED=no diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt index 6ffca34..0063dd2 100644 --- a/libphobos/configure.tgt +++ b/libphobos/configure.tgt @@ -52,6 +52,9 @@ case "${target}" in s390*-linux*) LIBPHOBOS_SUPPORTED=yes ;; + sparc*-*-solaris2.11*) + LIBPHOBOS_SUPPORTED=yes + ;; x86_64-*-freebsd* | i?86-*-freebsd*) LIBPHOBOS_SUPPORTED=yes ;; diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 251d78d..6e25a9d 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -dbd0c874a345438b8b4379a67525a933436d039a +651389b52243dcadb338dd0c14dd27e7850cda8d The first line of this file holds the git revision number of the last merge done from the dlang/druntime repository. diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am index ba64131..56b332d 100644 --- a/libphobos/libdruntime/Makefile.am +++ b/libphobos/libdruntime/Makefile.am @@ -39,7 +39,7 @@ ALL_DRUNTIME_INSTALL_DSOURCES = $(DRUNTIME_DSOURCES) \ $(DRUNTIME_DSOURCES_OPENBSD) $(DRUNTIME_DSOURCES_POSIX) \ $(DRUNTIME_DSOURCES_SOLARIS) $(DRUNTIME_DSOURCES_WINDOWS) \ $(DRUNTIME_DSOURCES_GENERATED) $(DRUNTIME_DISOURCES) \ - $(DRUNTIME_DSOURCES_STDCXX) + $(DRUNTIME_DSOURCES_ELF) $(DRUNTIME_DSOURCES_STDCXX) # Setup source files depending on configure DRUNTIME_SOURCES_CONFIGURED = @@ -120,7 +120,7 @@ endif DRUNTIME_DSOURCES_GENERATED = gcc/config.d gcc/libbacktrace.d ALL_DRUNTIME_SOURCES = $(DRUNTIME_DSOURCES) $(DRUNTIME_CSOURCES) \ - $(DRUNTIME_DSOURCES_STDCXX) \ + $(DRUNTIME_DSOURCES_ELF) $(DRUNTIME_DSOURCES_STDCXX) \ $(DRUNTIME_SOURCES_CONFIGURED) $(DRUNTIME_DSOURCES_GENERATED) # Need this library to both be part of libgphobos.a, and installed separately. @@ -200,21 +200,21 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \ core/stdc/tgmath.d core/stdc/time.d core/stdc/wchar_.d \ core/stdc/wctype.d core/sync/barrier.d core/sync/condition.d \ core/sync/config.d core/sync/event.d core/sync/exception.d \ - core/sync/mutex.d core/sync/rwmutex.d core/sync/semaphore.d \ - core/thread/context.d core/thread/fiber.d core/thread/osthread.d \ - core/thread/package.d core/thread/threadbase.d \ + core/sync/mutex.d core/sync/package.d core/sync/rwmutex.d \ + core/sync/semaphore.d core/thread/context.d core/thread/fiber.d \ + core/thread/osthread.d core/thread/package.d core/thread/threadbase.d \ core/thread/threadgroup.d core/thread/types.d core/time.d \ core/vararg.d core/volatile.d gcc/attribute.d gcc/attributes.d \ gcc/backtrace.d gcc/builtins.d gcc/deh.d gcc/emutls.d gcc/gthread.d \ gcc/sections/common.d gcc/sections/elf.d gcc/sections/macho.d \ - gcc/sections/package.d gcc/sections/pecoff.d gcc/unwind/arm.d \ - gcc/unwind/arm_common.d gcc/unwind/c6x.d gcc/unwind/generic.d \ - gcc/unwind/package.d gcc/unwind/pe.d object.d rt/aApply.d rt/aApplyR.d \ - rt/aaA.d rt/adi.d rt/arrayassign.d rt/arraycat.d rt/cast_.d \ - rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d rt/ehalloc.d \ - rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \ - rt/profilegc.d rt/sections.d rt/tlsgc.d rt/util/typeinfo.d \ - rt/util/utility.d + gcc/sections/package.d gcc/sections/pecoff.d gcc/simd.d \ + gcc/unwind/arm.d gcc/unwind/arm_common.d gcc/unwind/c6x.d \ + gcc/unwind/generic.d gcc/unwind/package.d gcc/unwind/pe.d object.d \ + rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arrayassign.d \ + rt/arraycat.d rt/cast_.d rt/config.d rt/critical_.d rt/deh.d \ + rt/dmain2.d rt/ehalloc.d rt/invariant.d rt/lifetime.d rt/memory.d \ + rt/minfo.d rt/monitor_.d rt/profilegc.d rt/sections.d rt/tlsgc.d \ + rt/util/typeinfo.d rt/util/utility.d DRUNTIME_DSOURCES_STDCXX = core/stdcpp/allocator.d core/stdcpp/array.d \ core/stdcpp/exception.d core/stdcpp/memory.d core/stdcpp/new_.d \ @@ -253,6 +253,8 @@ DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \ core/sys/dragonflybsd/sys/mman.d core/sys/dragonflybsd/sys/socket.d \ core/sys/dragonflybsd/sys/sysctl.d core/sys/dragonflybsd/time.d +DRUNTIME_DSOURCES_ELF = core/sys/elf/package.d + DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/config.d \ core/sys/freebsd/dlfcn.d core/sys/freebsd/err.d \ core/sys/freebsd/execinfo.d core/sys/freebsd/netinet/in_.d \ @@ -294,13 +296,13 @@ DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \ DRUNTIME_DSOURCES_OPENBSD = core/sys/openbsd/dlfcn.d \ core/sys/openbsd/err.d core/sys/openbsd/execinfo.d \ - core/sys/openbsd/pthread_np.d core/sys/openbsd/stdlib.d \ - core/sys/openbsd/string.d core/sys/openbsd/sys/cdefs.d \ - core/sys/openbsd/sys/elf.d core/sys/openbsd/sys/elf32.d \ - core/sys/openbsd/sys/elf64.d core/sys/openbsd/sys/elf_common.d \ - core/sys/openbsd/sys/link_elf.d core/sys/openbsd/sys/mman.d \ - core/sys/openbsd/sys/sysctl.d core/sys/openbsd/time.d \ - core/sys/openbsd/unistd.d + core/sys/openbsd/pthread_np.d core/sys/openbsd/pwd.d \ + core/sys/openbsd/stdlib.d core/sys/openbsd/string.d \ + core/sys/openbsd/sys/cdefs.d core/sys/openbsd/sys/elf.d \ + core/sys/openbsd/sys/elf32.d core/sys/openbsd/sys/elf64.d \ + core/sys/openbsd/sys/elf_common.d core/sys/openbsd/sys/link_elf.d \ + core/sys/openbsd/sys/mman.d core/sys/openbsd/sys/sysctl.d \ + core/sys/openbsd/time.d core/sys/openbsd/unistd.d DRUNTIME_DSOURCES_POSIX = core/sys/posix/aio.d \ core/sys/posix/arpa/inet.d core/sys/posix/config.d \ diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index 1c64d35..24865fb 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -226,17 +226,18 @@ am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \ core/stdc/tgmath.lo core/stdc/time.lo core/stdc/wchar_.lo \ core/stdc/wctype.lo core/sync/barrier.lo \ core/sync/condition.lo core/sync/config.lo core/sync/event.lo \ - core/sync/exception.lo core/sync/mutex.lo core/sync/rwmutex.lo \ - core/sync/semaphore.lo core/thread/context.lo \ - core/thread/fiber.lo core/thread/osthread.lo \ - core/thread/package.lo core/thread/threadbase.lo \ - core/thread/threadgroup.lo core/thread/types.lo core/time.lo \ - core/vararg.lo core/volatile.lo gcc/attribute.lo \ - gcc/attributes.lo gcc/backtrace.lo gcc/builtins.lo gcc/deh.lo \ - gcc/emutls.lo gcc/gthread.lo gcc/sections/common.lo \ - gcc/sections/elf.lo gcc/sections/macho.lo \ - gcc/sections/package.lo gcc/sections/pecoff.lo \ - gcc/unwind/arm.lo gcc/unwind/arm_common.lo gcc/unwind/c6x.lo \ + core/sync/exception.lo core/sync/mutex.lo core/sync/package.lo \ + core/sync/rwmutex.lo core/sync/semaphore.lo \ + core/thread/context.lo core/thread/fiber.lo \ + core/thread/osthread.lo core/thread/package.lo \ + core/thread/threadbase.lo core/thread/threadgroup.lo \ + core/thread/types.lo core/time.lo core/vararg.lo \ + core/volatile.lo gcc/attribute.lo gcc/attributes.lo \ + gcc/backtrace.lo gcc/builtins.lo gcc/deh.lo gcc/emutls.lo \ + gcc/gthread.lo gcc/sections/common.lo gcc/sections/elf.lo \ + gcc/sections/macho.lo gcc/sections/package.lo \ + gcc/sections/pecoff.lo gcc/simd.lo gcc/unwind/arm.lo \ + gcc/unwind/arm_common.lo gcc/unwind/c6x.lo \ gcc/unwind/generic.lo gcc/unwind/package.lo gcc/unwind/pe.lo \ object.lo rt/aApply.lo rt/aApplyR.lo rt/aaA.lo rt/adi.lo \ rt/arrayassign.lo rt/arraycat.lo rt/cast_.lo rt/config.lo \ @@ -245,13 +246,14 @@ am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \ rt/monitor_.lo rt/profilegc.lo rt/sections.lo rt/tlsgc.lo \ rt/util/typeinfo.lo rt/util/utility.lo am__objects_2 = core/stdc/libgdruntime_la-errno_.lo -am__objects_3 = core/stdcpp/allocator.lo core/stdcpp/array.lo \ +am__objects_3 = core/sys/elf/package.lo +am__objects_4 = core/stdcpp/allocator.lo core/stdcpp/array.lo \ core/stdcpp/exception.lo core/stdcpp/memory.lo \ core/stdcpp/new_.lo core/stdcpp/string.lo \ core/stdcpp/string_view.lo core/stdcpp/type_traits.lo \ core/stdcpp/typeinfo.lo core/stdcpp/utility.lo \ core/stdcpp/vector.lo core/stdcpp/xutility.lo -am__objects_4 = core/sys/posix/aio.lo core/sys/posix/arpa/inet.lo \ +am__objects_5 = core/sys/posix/aio.lo core/sys/posix/arpa/inet.lo \ core/sys/posix/config.lo core/sys/posix/dirent.lo \ core/sys/posix/dlfcn.lo core/sys/posix/fcntl.lo \ core/sys/posix/grp.lo core/sys/posix/iconv.lo \ @@ -278,8 +280,8 @@ am__objects_4 = core/sys/posix/aio.lo core/sys/posix/arpa/inet.lo \ core/sys/posix/syslog.lo core/sys/posix/termios.lo \ core/sys/posix/time.lo core/sys/posix/ucontext.lo \ core/sys/posix/unistd.lo core/sys/posix/utime.lo -@DRUNTIME_OS_POSIX_TRUE@am__objects_5 = $(am__objects_4) -am__objects_6 = core/sys/darwin/config.lo \ +@DRUNTIME_OS_POSIX_TRUE@am__objects_6 = $(am__objects_5) +am__objects_7 = core/sys/darwin/config.lo \ core/sys/darwin/crt_externs.lo core/sys/darwin/dlfcn.lo \ core/sys/darwin/err.lo core/sys/darwin/execinfo.lo \ core/sys/darwin/fcntl.lo core/sys/darwin/ifaddrs.lo \ @@ -294,8 +296,8 @@ am__objects_6 = core/sys/darwin/config.lo \ core/sys/darwin/sys/attr.lo core/sys/darwin/sys/cdefs.lo \ core/sys/darwin/sys/event.lo core/sys/darwin/sys/mman.lo \ core/sys/darwin/sys/sysctl.lo -@DRUNTIME_OS_DARWIN_TRUE@am__objects_7 = $(am__objects_6) -am__objects_8 = core/sys/dragonflybsd/dlfcn.lo \ +@DRUNTIME_OS_DARWIN_TRUE@am__objects_8 = $(am__objects_7) +am__objects_9 = core/sys/dragonflybsd/dlfcn.lo \ core/sys/dragonflybsd/err.lo core/sys/dragonflybsd/execinfo.lo \ core/sys/dragonflybsd/netinet/in_.lo \ core/sys/dragonflybsd/pthread_np.lo \ @@ -314,12 +316,12 @@ am__objects_8 = core/sys/dragonflybsd/dlfcn.lo \ core/sys/dragonflybsd/sys/socket.lo \ core/sys/dragonflybsd/sys/sysctl.lo \ core/sys/dragonflybsd/time.lo -@DRUNTIME_OS_DRAGONFLYBSD_TRUE@am__objects_9 = $(am__objects_8) -am__objects_10 = core/sys/bionic/err.lo core/sys/bionic/fcntl.lo \ +@DRUNTIME_OS_DRAGONFLYBSD_TRUE@am__objects_10 = $(am__objects_9) +am__objects_11 = core/sys/bionic/err.lo core/sys/bionic/fcntl.lo \ core/sys/bionic/stdlib.lo core/sys/bionic/string.lo \ core/sys/bionic/unistd.lo -@DRUNTIME_OS_ANDROID_TRUE@am__objects_11 = $(am__objects_10) -am__objects_12 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \ +@DRUNTIME_OS_ANDROID_TRUE@am__objects_12 = $(am__objects_11) +am__objects_13 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \ core/sys/freebsd/err.lo core/sys/freebsd/execinfo.lo \ core/sys/freebsd/netinet/in_.lo core/sys/freebsd/pthread_np.lo \ core/sys/freebsd/stdlib.lo core/sys/freebsd/string.lo \ @@ -332,8 +334,8 @@ am__objects_12 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \ core/sys/freebsd/sys/mman.lo core/sys/freebsd/sys/mount.lo \ core/sys/freebsd/sys/sysctl.lo core/sys/freebsd/time.lo \ core/sys/freebsd/unistd.lo -@DRUNTIME_OS_FREEBSD_TRUE@am__objects_13 = $(am__objects_12) -am__objects_14 = core/sys/netbsd/dlfcn.lo core/sys/netbsd/err.lo \ +@DRUNTIME_OS_FREEBSD_TRUE@am__objects_14 = $(am__objects_13) +am__objects_15 = core/sys/netbsd/dlfcn.lo core/sys/netbsd/err.lo \ core/sys/netbsd/execinfo.lo core/sys/netbsd/stdlib.lo \ core/sys/netbsd/string.lo core/sys/netbsd/sys/elf.lo \ core/sys/netbsd/sys/elf32.lo core/sys/netbsd/sys/elf64.lo \ @@ -341,18 +343,19 @@ am__objects_14 = core/sys/netbsd/dlfcn.lo core/sys/netbsd/err.lo \ core/sys/netbsd/sys/featuretest.lo \ core/sys/netbsd/sys/link_elf.lo core/sys/netbsd/sys/mman.lo \ core/sys/netbsd/sys/sysctl.lo core/sys/netbsd/time.lo -@DRUNTIME_OS_NETBSD_TRUE@am__objects_15 = $(am__objects_14) -am__objects_16 = core/sys/openbsd/dlfcn.lo core/sys/openbsd/err.lo \ +@DRUNTIME_OS_NETBSD_TRUE@am__objects_16 = $(am__objects_15) +am__objects_17 = core/sys/openbsd/dlfcn.lo core/sys/openbsd/err.lo \ core/sys/openbsd/execinfo.lo core/sys/openbsd/pthread_np.lo \ - core/sys/openbsd/stdlib.lo core/sys/openbsd/string.lo \ - core/sys/openbsd/sys/cdefs.lo core/sys/openbsd/sys/elf.lo \ - core/sys/openbsd/sys/elf32.lo core/sys/openbsd/sys/elf64.lo \ + core/sys/openbsd/pwd.lo core/sys/openbsd/stdlib.lo \ + core/sys/openbsd/string.lo core/sys/openbsd/sys/cdefs.lo \ + core/sys/openbsd/sys/elf.lo core/sys/openbsd/sys/elf32.lo \ + core/sys/openbsd/sys/elf64.lo \ core/sys/openbsd/sys/elf_common.lo \ core/sys/openbsd/sys/link_elf.lo core/sys/openbsd/sys/mman.lo \ core/sys/openbsd/sys/sysctl.lo core/sys/openbsd/time.lo \ core/sys/openbsd/unistd.lo -@DRUNTIME_OS_OPENBSD_TRUE@am__objects_17 = $(am__objects_16) -am__objects_18 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \ +@DRUNTIME_OS_OPENBSD_TRUE@am__objects_18 = $(am__objects_17) +am__objects_19 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \ core/sys/linux/elf.lo core/sys/linux/epoll.lo \ core/sys/linux/err.lo core/sys/linux/errno.lo \ core/sys/linux/execinfo.lo core/sys/linux/fcntl.lo \ @@ -370,8 +373,8 @@ am__objects_18 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \ core/sys/linux/termios.lo core/sys/linux/time.lo \ core/sys/linux/timerfd.lo core/sys/linux/tipc.lo \ core/sys/linux/unistd.lo -@DRUNTIME_OS_LINUX_TRUE@am__objects_19 = $(am__objects_18) -am__objects_20 = core/sys/windows/accctrl.lo \ +@DRUNTIME_OS_LINUX_TRUE@am__objects_20 = $(am__objects_19) +am__objects_21 = core/sys/windows/accctrl.lo \ core/sys/windows/aclapi.lo core/sys/windows/aclui.lo \ core/sys/windows/basetsd.lo core/sys/windows/basetyps.lo \ core/sys/windows/cderr.lo core/sys/windows/cguid.lo \ @@ -456,9 +459,9 @@ am__objects_20 = core/sys/windows/accctrl.lo \ core/sys/windows/winsvc.lo core/sys/windows/winuser.lo \ core/sys/windows/winver.lo core/sys/windows/wtsapi32.lo \ core/sys/windows/wtypes.lo -@DRUNTIME_OS_MINGW_TRUE@am__objects_21 = $(am__objects_20) \ +@DRUNTIME_OS_MINGW_TRUE@am__objects_22 = $(am__objects_21) \ @DRUNTIME_OS_MINGW_TRUE@ config/mingw/libgdruntime_la-msvc.lo -am__objects_22 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \ +am__objects_23 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \ core/sys/solaris/err.lo core/sys/solaris/execinfo.lo \ core/sys/solaris/libelf.lo core/sys/solaris/link.lo \ core/sys/solaris/stdlib.lo core/sys/solaris/sys/elf.lo \ @@ -470,48 +473,48 @@ am__objects_22 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \ core/sys/solaris/sys/priocntl.lo \ core/sys/solaris/sys/procset.lo core/sys/solaris/sys/types.lo \ core/sys/solaris/time.lo -@DRUNTIME_OS_SOLARIS_TRUE@am__objects_23 = $(am__objects_22) -@DRUNTIME_CPU_AARCH64_TRUE@am__objects_24 = config/aarch64/libgdruntime_la-switchcontext.lo -@DRUNTIME_CPU_ARM_TRUE@am__objects_25 = config/arm/libgdruntime_la-switchcontext.lo -@DRUNTIME_CPU_MIPS_TRUE@am__objects_26 = config/mips/libgdruntime_la-switchcontext.lo -@DRUNTIME_CPU_POWERPC_TRUE@am__objects_27 = config/powerpc/libgdruntime_la-switchcontext.lo -@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_28 = config/mingw/libgdruntime_la-switchcontext.lo -@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_29 = config/x86/libgdruntime_la-switchcontext.lo -@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_30 = config/systemz/libgdruntime_la-get_tls_offset.lo -@DRUNTIME_CPU_S390_TRUE@am__objects_31 = config/s390/libgdruntime_la-get_tls_offset.lo -am__objects_32 = $(am__objects_5) $(am__objects_7) $(am__objects_9) \ - $(am__objects_11) $(am__objects_13) $(am__objects_15) \ - $(am__objects_17) $(am__objects_19) $(am__objects_21) \ - $(am__objects_23) $(am__objects_24) $(am__objects_25) \ - $(am__objects_26) $(am__objects_27) $(am__objects_28) \ - $(am__objects_29) $(am__objects_30) $(am__objects_31) -am__objects_33 = gcc/config.lo gcc/libbacktrace.lo -am__objects_34 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \ - $(am__objects_32) $(am__objects_33) -am_libgdruntime_la_OBJECTS = $(am__objects_34) +@DRUNTIME_OS_SOLARIS_TRUE@am__objects_24 = $(am__objects_23) +@DRUNTIME_CPU_AARCH64_TRUE@am__objects_25 = config/aarch64/libgdruntime_la-switchcontext.lo +@DRUNTIME_CPU_ARM_TRUE@am__objects_26 = config/arm/libgdruntime_la-switchcontext.lo +@DRUNTIME_CPU_MIPS_TRUE@am__objects_27 = config/mips/libgdruntime_la-switchcontext.lo +@DRUNTIME_CPU_POWERPC_TRUE@am__objects_28 = config/powerpc/libgdruntime_la-switchcontext.lo +@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_29 = config/mingw/libgdruntime_la-switchcontext.lo +@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_30 = config/x86/libgdruntime_la-switchcontext.lo +@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_31 = config/systemz/libgdruntime_la-get_tls_offset.lo +@DRUNTIME_CPU_S390_TRUE@am__objects_32 = config/s390/libgdruntime_la-get_tls_offset.lo +am__objects_33 = $(am__objects_6) $(am__objects_8) $(am__objects_10) \ + $(am__objects_12) $(am__objects_14) $(am__objects_16) \ + $(am__objects_18) $(am__objects_20) $(am__objects_22) \ + $(am__objects_24) $(am__objects_25) $(am__objects_26) \ + $(am__objects_27) $(am__objects_28) $(am__objects_29) \ + $(am__objects_30) $(am__objects_31) $(am__objects_32) +am__objects_34 = gcc/config.lo gcc/libbacktrace.lo +am__objects_35 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \ + $(am__objects_4) $(am__objects_33) $(am__objects_34) +am_libgdruntime_la_OBJECTS = $(am__objects_35) libgdruntime_la_OBJECTS = $(am_libgdruntime_la_OBJECTS) am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am__objects_35 = core/stdc/libgdruntime_convenience_la-errno_.lo -@DRUNTIME_OS_MINGW_TRUE@am__objects_36 = $(am__objects_20) \ +am__objects_36 = core/stdc/libgdruntime_convenience_la-errno_.lo +@DRUNTIME_OS_MINGW_TRUE@am__objects_37 = $(am__objects_21) \ @DRUNTIME_OS_MINGW_TRUE@ config/mingw/libgdruntime_convenience_la-msvc.lo -@DRUNTIME_CPU_AARCH64_TRUE@am__objects_37 = config/aarch64/libgdruntime_convenience_la-switchcontext.lo -@DRUNTIME_CPU_ARM_TRUE@am__objects_38 = config/arm/libgdruntime_convenience_la-switchcontext.lo -@DRUNTIME_CPU_MIPS_TRUE@am__objects_39 = config/mips/libgdruntime_convenience_la-switchcontext.lo -@DRUNTIME_CPU_POWERPC_TRUE@am__objects_40 = config/powerpc/libgdruntime_convenience_la-switchcontext.lo -@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_41 = config/mingw/libgdruntime_convenience_la-switchcontext.lo -@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_42 = config/x86/libgdruntime_convenience_la-switchcontext.lo -@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_43 = config/systemz/libgdruntime_convenience_la-get_tls_offset.lo -@DRUNTIME_CPU_S390_TRUE@am__objects_44 = config/s390/libgdruntime_convenience_la-get_tls_offset.lo -am__objects_45 = $(am__objects_5) $(am__objects_7) $(am__objects_9) \ - $(am__objects_11) $(am__objects_13) $(am__objects_15) \ - $(am__objects_17) $(am__objects_19) $(am__objects_36) \ - $(am__objects_23) $(am__objects_37) $(am__objects_38) \ - $(am__objects_39) $(am__objects_40) $(am__objects_41) \ - $(am__objects_42) $(am__objects_43) $(am__objects_44) -am__objects_46 = $(am__objects_1) $(am__objects_35) $(am__objects_3) \ - $(am__objects_45) $(am__objects_33) -am__objects_47 = $(am__objects_46) -am_libgdruntime_convenience_la_OBJECTS = $(am__objects_47) +@DRUNTIME_CPU_AARCH64_TRUE@am__objects_38 = config/aarch64/libgdruntime_convenience_la-switchcontext.lo +@DRUNTIME_CPU_ARM_TRUE@am__objects_39 = config/arm/libgdruntime_convenience_la-switchcontext.lo +@DRUNTIME_CPU_MIPS_TRUE@am__objects_40 = config/mips/libgdruntime_convenience_la-switchcontext.lo +@DRUNTIME_CPU_POWERPC_TRUE@am__objects_41 = config/powerpc/libgdruntime_convenience_la-switchcontext.lo +@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_TRUE@am__objects_42 = config/mingw/libgdruntime_convenience_la-switchcontext.lo +@DRUNTIME_CPU_X86_TRUE@@DRUNTIME_OS_MINGW_FALSE@am__objects_43 = config/x86/libgdruntime_convenience_la-switchcontext.lo +@DRUNTIME_CPU_SYSTEMZ_TRUE@am__objects_44 = config/systemz/libgdruntime_convenience_la-get_tls_offset.lo +@DRUNTIME_CPU_S390_TRUE@am__objects_45 = config/s390/libgdruntime_convenience_la-get_tls_offset.lo +am__objects_46 = $(am__objects_6) $(am__objects_8) $(am__objects_10) \ + $(am__objects_12) $(am__objects_14) $(am__objects_16) \ + $(am__objects_18) $(am__objects_20) $(am__objects_37) \ + $(am__objects_24) $(am__objects_38) $(am__objects_39) \ + $(am__objects_40) $(am__objects_41) $(am__objects_42) \ + $(am__objects_43) $(am__objects_44) $(am__objects_45) +am__objects_47 = $(am__objects_1) $(am__objects_36) $(am__objects_3) \ + $(am__objects_4) $(am__objects_46) $(am__objects_34) +am__objects_48 = $(am__objects_47) +am_libgdruntime_convenience_la_OBJECTS = $(am__objects_48) libgdruntime_convenience_la_OBJECTS = \ $(am_libgdruntime_convenience_la_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) @@ -776,7 +779,7 @@ ALL_DRUNTIME_INSTALL_DSOURCES = $(DRUNTIME_DSOURCES) \ $(DRUNTIME_DSOURCES_OPENBSD) $(DRUNTIME_DSOURCES_POSIX) \ $(DRUNTIME_DSOURCES_SOLARIS) $(DRUNTIME_DSOURCES_WINDOWS) \ $(DRUNTIME_DSOURCES_GENERATED) $(DRUNTIME_DISOURCES) \ - $(DRUNTIME_DSOURCES_STDCXX) + $(DRUNTIME_DSOURCES_ELF) $(DRUNTIME_DSOURCES_STDCXX) # Setup source files depending on configure @@ -795,7 +798,7 @@ DRUNTIME_SOURCES_CONFIGURED = $(am__append_1) $(am__append_2) \ # Generated by configure DRUNTIME_DSOURCES_GENERATED = gcc/config.d gcc/libbacktrace.d ALL_DRUNTIME_SOURCES = $(DRUNTIME_DSOURCES) $(DRUNTIME_CSOURCES) \ - $(DRUNTIME_DSOURCES_STDCXX) \ + $(DRUNTIME_DSOURCES_ELF) $(DRUNTIME_DSOURCES_STDCXX) \ $(DRUNTIME_SOURCES_CONFIGURED) $(DRUNTIME_DSOURCES_GENERATED) @@ -864,21 +867,21 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \ core/stdc/tgmath.d core/stdc/time.d core/stdc/wchar_.d \ core/stdc/wctype.d core/sync/barrier.d core/sync/condition.d \ core/sync/config.d core/sync/event.d core/sync/exception.d \ - core/sync/mutex.d core/sync/rwmutex.d core/sync/semaphore.d \ - core/thread/context.d core/thread/fiber.d core/thread/osthread.d \ - core/thread/package.d core/thread/threadbase.d \ + core/sync/mutex.d core/sync/package.d core/sync/rwmutex.d \ + core/sync/semaphore.d core/thread/context.d core/thread/fiber.d \ + core/thread/osthread.d core/thread/package.d core/thread/threadbase.d \ core/thread/threadgroup.d core/thread/types.d core/time.d \ core/vararg.d core/volatile.d gcc/attribute.d gcc/attributes.d \ gcc/backtrace.d gcc/builtins.d gcc/deh.d gcc/emutls.d gcc/gthread.d \ gcc/sections/common.d gcc/sections/elf.d gcc/sections/macho.d \ - gcc/sections/package.d gcc/sections/pecoff.d gcc/unwind/arm.d \ - gcc/unwind/arm_common.d gcc/unwind/c6x.d gcc/unwind/generic.d \ - gcc/unwind/package.d gcc/unwind/pe.d object.d rt/aApply.d rt/aApplyR.d \ - rt/aaA.d rt/adi.d rt/arrayassign.d rt/arraycat.d rt/cast_.d \ - rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d rt/ehalloc.d \ - rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \ - rt/profilegc.d rt/sections.d rt/tlsgc.d rt/util/typeinfo.d \ - rt/util/utility.d + gcc/sections/package.d gcc/sections/pecoff.d gcc/simd.d \ + gcc/unwind/arm.d gcc/unwind/arm_common.d gcc/unwind/c6x.d \ + gcc/unwind/generic.d gcc/unwind/package.d gcc/unwind/pe.d object.d \ + rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arrayassign.d \ + rt/arraycat.d rt/cast_.d rt/config.d rt/critical_.d rt/deh.d \ + rt/dmain2.d rt/ehalloc.d rt/invariant.d rt/lifetime.d rt/memory.d \ + rt/minfo.d rt/monitor_.d rt/profilegc.d rt/sections.d rt/tlsgc.d \ + rt/util/typeinfo.d rt/util/utility.d DRUNTIME_DSOURCES_STDCXX = core/stdcpp/allocator.d core/stdcpp/array.d \ core/stdcpp/exception.d core/stdcpp/memory.d core/stdcpp/new_.d \ @@ -917,6 +920,7 @@ DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \ core/sys/dragonflybsd/sys/mman.d core/sys/dragonflybsd/sys/socket.d \ core/sys/dragonflybsd/sys/sysctl.d core/sys/dragonflybsd/time.d +DRUNTIME_DSOURCES_ELF = core/sys/elf/package.d DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/config.d \ core/sys/freebsd/dlfcn.d core/sys/freebsd/err.d \ core/sys/freebsd/execinfo.d core/sys/freebsd/netinet/in_.d \ @@ -958,13 +962,13 @@ DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \ DRUNTIME_DSOURCES_OPENBSD = core/sys/openbsd/dlfcn.d \ core/sys/openbsd/err.d core/sys/openbsd/execinfo.d \ - core/sys/openbsd/pthread_np.d core/sys/openbsd/stdlib.d \ - core/sys/openbsd/string.d core/sys/openbsd/sys/cdefs.d \ - core/sys/openbsd/sys/elf.d core/sys/openbsd/sys/elf32.d \ - core/sys/openbsd/sys/elf64.d core/sys/openbsd/sys/elf_common.d \ - core/sys/openbsd/sys/link_elf.d core/sys/openbsd/sys/mman.d \ - core/sys/openbsd/sys/sysctl.d core/sys/openbsd/time.d \ - core/sys/openbsd/unistd.d + core/sys/openbsd/pthread_np.d core/sys/openbsd/pwd.d \ + core/sys/openbsd/stdlib.d core/sys/openbsd/string.d \ + core/sys/openbsd/sys/cdefs.d core/sys/openbsd/sys/elf.d \ + core/sys/openbsd/sys/elf32.d core/sys/openbsd/sys/elf64.d \ + core/sys/openbsd/sys/elf_common.d core/sys/openbsd/sys/link_elf.d \ + core/sys/openbsd/sys/mman.d core/sys/openbsd/sys/sysctl.d \ + core/sys/openbsd/time.d core/sys/openbsd/unistd.d DRUNTIME_DSOURCES_POSIX = core/sys/posix/aio.d \ core/sys/posix/arpa/inet.d core/sys/posix/config.d \ @@ -1302,6 +1306,7 @@ core/sync/config.lo: core/sync/$(am__dirstamp) core/sync/event.lo: core/sync/$(am__dirstamp) core/sync/exception.lo: core/sync/$(am__dirstamp) core/sync/mutex.lo: core/sync/$(am__dirstamp) +core/sync/package.lo: core/sync/$(am__dirstamp) core/sync/rwmutex.lo: core/sync/$(am__dirstamp) core/sync/semaphore.lo: core/sync/$(am__dirstamp) core/thread/$(am__dirstamp): @@ -1335,6 +1340,7 @@ gcc/sections/elf.lo: gcc/sections/$(am__dirstamp) gcc/sections/macho.lo: gcc/sections/$(am__dirstamp) gcc/sections/package.lo: gcc/sections/$(am__dirstamp) gcc/sections/pecoff.lo: gcc/sections/$(am__dirstamp) +gcc/simd.lo: gcc/$(am__dirstamp) gcc/unwind/$(am__dirstamp): @$(MKDIR_P) gcc/unwind @: > gcc/unwind/$(am__dirstamp) @@ -1373,6 +1379,10 @@ rt/util/$(am__dirstamp): rt/util/typeinfo.lo: rt/util/$(am__dirstamp) rt/util/utility.lo: rt/util/$(am__dirstamp) core/stdc/libgdruntime_la-errno_.lo: core/stdc/$(am__dirstamp) +core/sys/elf/$(am__dirstamp): + @$(MKDIR_P) core/sys/elf + @: > core/sys/elf/$(am__dirstamp) +core/sys/elf/package.lo: core/sys/elf/$(am__dirstamp) core/stdcpp/$(am__dirstamp): @$(MKDIR_P) core/stdcpp @: > core/stdcpp/$(am__dirstamp) @@ -1619,6 +1629,7 @@ core/sys/openbsd/dlfcn.lo: core/sys/openbsd/$(am__dirstamp) core/sys/openbsd/err.lo: core/sys/openbsd/$(am__dirstamp) core/sys/openbsd/execinfo.lo: core/sys/openbsd/$(am__dirstamp) core/sys/openbsd/pthread_np.lo: core/sys/openbsd/$(am__dirstamp) +core/sys/openbsd/pwd.lo: core/sys/openbsd/$(am__dirstamp) core/sys/openbsd/stdlib.lo: core/sys/openbsd/$(am__dirstamp) core/sys/openbsd/string.lo: core/sys/openbsd/$(am__dirstamp) core/sys/openbsd/sys/$(am__dirstamp): @@ -2014,6 +2025,8 @@ mostlyclean-compile: -rm -f core/sys/dragonflybsd/netinet/*.lo -rm -f core/sys/dragonflybsd/sys/*.$(OBJEXT) -rm -f core/sys/dragonflybsd/sys/*.lo + -rm -f core/sys/elf/*.$(OBJEXT) + -rm -f core/sys/elf/*.lo -rm -f core/sys/freebsd/*.$(OBJEXT) -rm -f core/sys/freebsd/*.lo -rm -f core/sys/freebsd/netinet/*.$(OBJEXT) @@ -2182,6 +2195,7 @@ clean-libtool: -rm -rf core/sys/dragonflybsd/.libs core/sys/dragonflybsd/_libs -rm -rf core/sys/dragonflybsd/netinet/.libs core/sys/dragonflybsd/netinet/_libs -rm -rf core/sys/dragonflybsd/sys/.libs core/sys/dragonflybsd/sys/_libs + -rm -rf core/sys/elf/.libs core/sys/elf/_libs -rm -rf core/sys/freebsd/.libs core/sys/freebsd/_libs -rm -rf core/sys/freebsd/netinet/.libs core/sys/freebsd/netinet/_libs -rm -rf core/sys/freebsd/sys/.libs core/sys/freebsd/sys/_libs @@ -2343,6 +2357,7 @@ distclean-generic: -rm -f core/sys/dragonflybsd/$(am__dirstamp) -rm -f core/sys/dragonflybsd/netinet/$(am__dirstamp) -rm -f core/sys/dragonflybsd/sys/$(am__dirstamp) + -rm -f core/sys/elf/$(am__dirstamp) -rm -f core/sys/freebsd/$(am__dirstamp) -rm -f core/sys/freebsd/netinet/$(am__dirstamp) -rm -f core/sys/freebsd/sys/$(am__dirstamp) diff --git a/libphobos/libdruntime/__builtins.di b/libphobos/libdruntime/__builtins.di index cd64881..cf05333 100644 --- a/libphobos/libdruntime/__builtins.di +++ b/libphobos/libdruntime/__builtins.di @@ -19,22 +19,86 @@ module __builtins; * into the D compiler. */ -import core.stdc.stdarg; - -alias va_list = core.stdc.stdarg.va_list; +alias va_list = imported!"core.stdc.stdarg".va_list; version (Posix) { version (X86_64) - alias __va_list_tag = core.stdc.stdarg.__va_list_tag; + alias __va_list_tag = imported!"core.stdc.stdarg".__va_list_tag; } -alias __builtin_va_start = core.stdc.stdarg.va_start; +alias __builtin_va_start = imported!"core.stdc.stdarg".va_start; -alias __builtin_va_end = core.stdc.stdarg.va_end; +alias __builtin_va_end = imported!"core.stdc.stdarg".va_end; -alias __builtin_va_copy = core.stdc.stdarg.va_copy; +alias __builtin_va_copy = imported!"core.stdc.stdarg".va_copy; /* dmd's ImportC rewrites __builtin_va_arg into an instantiation of va_arg */ -alias va_arg = core.stdc.stdarg.va_arg; +alias va_arg = imported!"core.stdc.stdarg".va_arg; + +version (CRuntime_Microsoft) +{ + //https://docs.microsoft.com/en-us/cpp/cpp/int8-int16-int32-int64?view=msvc-170 + alias __int8 = byte; + alias __int16 = short; + alias __int32 = int; + alias __int64 = long; +} + +/*********** floating point *************/ + +/* https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html + */ + +version (DigitalMars) +{ + double __builtin_inf()() { return double.infinity; } + float __builtin_inff()() { return float.infinity; } + real __builtin_infl()() { return real.infinity; } + + alias __builtin_huge_val = __builtin_inf; + alias __builtin_huge_valf = __builtin_inff; + alias __builtin_huge_vall = __builtin_infl; + + alias __builtin_fabs = imported!"core.stdc.math".fabs; + alias __builtin_fabsf = imported!"core.stdc.math".fabsf; + alias __builtin_fabsl = imported!"core.stdc.math".fabsl; + + ushort __builtin_bswap16()(ushort value) + { + import core.bitop; + return core.bitop.byteswap(value); + } + + uint __builtin_bswap32()(uint value) + { + import core.bitop; + return core.bitop.bswap(value); + } + + ulong __builtin_bswap64()(ulong value) + { + import core.bitop; + return core.bitop.bswap(value); + } + + // Lazily imported on first use + private alias c_long = imported!"core.stdc.config".c_long; + + // Stub these out to no-ops + int __builtin_constant_p(T)(T exp) { return 0; } // should be something like __traits(compiles, enum X = expr) + c_long __builtin_expect()(c_long exp, c_long c) { return exp; } + void* __builtin_assume_aligned()(const void* p, size_t align_, ...) { return cast(void*)p; } + + // https://releases.llvm.org/13.0.0/tools/clang/docs/LanguageExtensions.html#builtin-assume + void __builtin_assume(T)(lazy T arg) { } + + /* Header on macOS for arm64 references this. + * Don't need to implement it, it just needs to compile + */ + align (16) struct __uint128_t + { + ulong a, b; + } +} diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c index b00d90d..348b223 100644 --- a/libphobos/libdruntime/config/mingw/msvc.c +++ b/libphobos/libdruntime/config/mingw/msvc.c @@ -50,7 +50,7 @@ init_msvc (void) core_stdc_stderr = stderr; #if __MSVCRT_VERSION__ >= 0xE00 - msvcUsedUCRT = 1; + msvcUsesUCRT = 1; #endif } diff --git a/libphobos/libdruntime/core/atomic.d b/libphobos/libdruntime/core/atomic.d index e6a82e5..4af3fdf 100644 --- a/libphobos/libdruntime/core/atomic.d +++ b/libphobos/libdruntime/core/atomic.d @@ -292,7 +292,7 @@ template cas(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder. in (atomicPtrIsProperlyAligned(here), "Argument `here` is not properly aligned") { // resolve implicit conversions - T arg1 = ifThis; + const T arg1 = ifThis; T arg2 = writeThis; static if (__traits(isFloating, T)) @@ -1276,4 +1276,13 @@ version (CoreUnittest) shared NoIndirections n; static assert(is(typeof(atomicLoad(n)) == NoIndirections)); } + + unittest // Issue 21631 + { + shared uint si1 = 45; + shared uint si2 = 38; + shared uint* psi = &si1; + + assert((&psi).cas(cast(const) psi, &si2)); + } } diff --git a/libphobos/libdruntime/core/attribute.d b/libphobos/libdruntime/core/attribute.d index b0b973f..8a1dc8a 100644 --- a/libphobos/libdruntime/core/attribute.d +++ b/libphobos/libdruntime/core/attribute.d @@ -76,14 +76,14 @@ else * The attribute can only be attached to methods or constructors which * have Objective-C linkage. That is, a method or a constructor in a * class or interface declared as $(D_CODE extern(Objective-C)). - * ), + * ) * - * $(LI It cannot be attached to a method or constructor that is a template), + * $(LI It cannot be attached to a method or constructor that is a template) * * $(LI * The number of colons in the string need to match the number of * arguments the method accept. - * ), + * ) * * $(LI It can only be used once in a method declaration) * ) @@ -181,21 +181,21 @@ version (UdaOptional) * $(UL * $(LI * There can only be one such attribute per symbol. - * ), + * ) * $(LI * The attribute can only be attached to an `extern(C++)` symbol * (`struct`, `class`, `enum`, function, and their templated counterparts). - * ), + * ) * $(LI * The attribute cannot be applied to C++ namespaces. * This is to prevent confusion with the C++ semantic, which allows it to * be applied to namespaces. - * ), + * ) * $(LI * The string arguments must only contain valid characters * for C++ name mangling which currently include alphanumerics * and the underscore character. - * ), + * ) * ) * * This UDA is not transitive, and inner scope do not inherit outer scopes' @@ -241,3 +241,52 @@ version (UdaGNUAbiTag) struct gnuAbiTag this.tags = tags; } } + +/** + * Use this attribute to ensure that values of a `struct` or `union` type are + * not discarded. + * + * The value of an expression is considered to be discarded if + * + * $(UL + * $(LI + * the expression is the top-level expression in a statement or the + * left-hand expression in a comma expression, and + * ) + * $(LI + * the expression is not an assignment (`=`, `+=`, etc.), increment + * (`++`), or decrement (`--`) expression. + * ) + * ) + * + * If the declaration of a `struct` or `union` type has the `@mustuse` + * attribute, the compiler will emit an error any time a value of that type + * would be discarded. + * + * Currently, `@mustuse` is only recognized by the compiler when attached to + * `struct` and `union` declarations. To allow for future expansion, attaching + * `@mustuse` to a `class`, `interface`, `enum`, or function declaration is + * currently forbidden, and will result in a compile-time error. All other uses + * of `@mustuse` are ignored. + * + * Examples: + * --- + * @mustuse struct ErrorCode { int value; } + * + * extern(C) ErrorCode doSomething(); + * + * void main() + * { + * // error: would discard a value of type ErrorCode + * //doSomething(); + * + * ErrorCode result; + * // ok: value is assigned to a variable + * result = doSomething(); + * + * // ok: can ignore the value explicitly with a cast + * cast(void) doSomething(); + * } + * --- + */ +enum mustuse; diff --git a/libphobos/libdruntime/core/bitop.d b/libphobos/libdruntime/core/bitop.d index 40f2242..59445f0 100644 --- a/libphobos/libdruntime/core/bitop.d +++ b/libphobos/libdruntime/core/bitop.d @@ -758,19 +758,6 @@ version (DigitalMars) version (AnyX86) } -// @@@DEPRECATED_2.099@@@ -deprecated("volatileLoad has been moved to core.volatile. Use core.volatile.volatileLoad instead.") -{ - public import core.volatile : volatileLoad; -} - -// @@@DEPRECATED_2.099@@@ -deprecated("volatileStore has been moved to core.volatile. Use core.volatile.volatileStore instead.") -{ - public import core.volatile : volatileStore; -} - - /** * Reverses the order of bits in a 32-bit integer. */ diff --git a/libphobos/libdruntime/core/demangle.d b/libphobos/libdruntime/core/demangle.d index 930e0cd..cb8d433 100644 --- a/libphobos/libdruntime/core/demangle.d +++ b/libphobos/libdruntime/core/demangle.d @@ -1339,7 +1339,7 @@ pure @safe: TypeFunction: CallConvention FuncAttrs Arguments ArgClose Type */ - char[] parseTypeFunction( char[] name = null, IsDelegate isdg = IsDelegate.no ) return + char[] parseTypeFunction( char[] name = null, IsDelegate isdg = IsDelegate.no ) return scope { debug(trace) printf( "parseTypeFunction+\n" ); debug(trace) scope(success) printf( "parseTypeFunction-\n" ); diff --git a/libphobos/libdruntime/core/exception.d b/libphobos/libdruntime/core/exception.d index a692866..81aa43b 100644 --- a/libphobos/libdruntime/core/exception.d +++ b/libphobos/libdruntime/core/exception.d @@ -19,29 +19,6 @@ void __switch_errorT()(string file = __FILE__, size_t line = __LINE__) @trusted assert(0, "No appropriate switch clause found"); } -version (D_BetterC) -{ - // When compiling with -betterC we use template functions so if they are - // used the bodies are copied into the user's program so there is no need - // for the D runtime during linking. - - // In the future we might want to convert all functions in this module to - // templates even for ordinary builds instead of providing them as an - // extern(C) library. - - void onOutOfMemoryError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted - { - assert(0, "Memory allocation failed"); - } - alias onOutOfMemoryErrorNoGC = onOutOfMemoryError; - - void onInvalidMemoryOperationError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted - { - assert(0, "Invalid memory operation"); - } -} -else: - /** * Thrown on a range error. */ @@ -218,17 +195,17 @@ private void rangeMsgPut(ref char[] r, scope const(char)[] e) @nogc nothrow pure */ class AssertError : Error { - @safe pure nothrow this( string file, size_t line ) + @safe pure nothrow @nogc this( string file, size_t line ) { this(cast(Throwable)null, file, line); } - @safe pure nothrow this( Throwable next, string file = __FILE__, size_t line = __LINE__ ) + @safe pure nothrow @nogc this( Throwable next, string file = __FILE__, size_t line = __LINE__ ) { this( "Assertion failure", file, line, next); } - @safe pure nothrow this( string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null ) + @safe pure nothrow @nogc this( string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null ) { super( msg, file, line, next ); } @@ -692,26 +669,49 @@ extern (C) void onFinalizeError( TypeInfo info, Throwable e, string file = __FIL throw staticError!FinalizeError(info, e, file, line); } -/** - * A callback for out of memory errors in D. An $(LREF OutOfMemoryError) will be - * thrown. - * - * Throws: - * $(LREF OutOfMemoryError). - */ -extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */ +version (D_BetterC) { - // NOTE: Since an out of memory condition exists, no allocation must occur - // while generating this object. - throw staticError!OutOfMemoryError(); -} + // When compiling with -betterC we use template functions so if they are + // used the bodies are copied into the user's program so there is no need + // for the D runtime during linking. -extern (C) void onOutOfMemoryErrorNoGC() @trusted nothrow @nogc -{ - // suppress stacktrace until they are @nogc - throw staticError!OutOfMemoryError(false); + // In the future we might want to convert all functions in this module to + // templates even for ordinary builds instead of providing them as an + // extern(C) library. + + void onOutOfMemoryError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted + { + assert(0, "Memory allocation failed"); + } + alias onOutOfMemoryErrorNoGC = onOutOfMemoryError; + + void onInvalidMemoryOperationError()(void* pretend_sideffect = null) @nogc nothrow pure @trusted + { + assert(0, "Invalid memory operation"); + } } +else +{ + /** + * A callback for out of memory errors in D. An $(LREF OutOfMemoryError) will be + * thrown. + * + * Throws: + * $(LREF OutOfMemoryError). + */ + extern (C) void onOutOfMemoryError(void* pretend_sideffect = null) @trusted pure nothrow @nogc /* dmd @@@BUG11461@@@ */ + { + // NOTE: Since an out of memory condition exists, no allocation must occur + // while generating this object. + throw staticError!OutOfMemoryError(); + } + extern (C) void onOutOfMemoryErrorNoGC() @trusted nothrow @nogc + { + // suppress stacktrace until they are @nogc + throw staticError!OutOfMemoryError(false); + } +} /** * A callback for invalid memory operations in D. An diff --git a/libphobos/libdruntime/core/gc/gcinterface.d b/libphobos/libdruntime/core/gc/gcinterface.d index e8cdf11..5560c62 100644 --- a/libphobos/libdruntime/core/gc/gcinterface.d +++ b/libphobos/libdruntime/core/gc/gcinterface.d @@ -141,13 +141,13 @@ interface GC * Retrieve statistics about garbage collection. * Useful for debugging and tuning. */ - core.memory.GC.Stats stats() nothrow; + core.memory.GC.Stats stats() @safe nothrow @nogc; /** * Retrieve profile statistics about garbage collection. * Useful for debugging and tuning. */ - core.memory.GC.ProfileStats profileStats() nothrow @safe; + core.memory.GC.ProfileStats profileStats() @safe nothrow @nogc; /** * add p to list of roots diff --git a/libphobos/libdruntime/core/int128.d b/libphobos/libdruntime/core/int128.d index aad2cf2..e4326fd 100644 --- a/libphobos/libdruntime/core/int128.d +++ b/libphobos/libdruntime/core/int128.d @@ -18,15 +18,26 @@ alias I = long; alias U = ulong; enum Ubits = uint(U.sizeof * 8); -align(16) struct Cent +version (X86_64) private enum Cent_alignment = 16; +else private enum Cent_alignment = (size_t.sizeof * 2); + +align(Cent_alignment) struct Cent { - U lo; // low 64 bits - U hi; // high 64 bits + version (LittleEndian) + { + U lo; // low 64 bits + U hi; // high 64 bits + } + else + { + U hi; // high 64 bits + U lo; // low 64 bits + } } -enum One = Cent(1); -enum Zero = Cent(); -enum MinusOne = neg(One); +enum Cent One = { lo:1 }; +enum Cent Zero = { lo:0 }; +enum Cent MinusOne = neg(One); /***************************** * Test against 0 @@ -320,7 +331,8 @@ Cent ror(Cent c, uint n) pure Cent and(Cent c1, Cent c2) { - return Cent(c1.lo & c2.lo, c1.hi & c2.hi); + const Cent ret = { lo:c1.lo & c2.lo, hi:c1.hi & c2.hi }; + return ret; } /**************************** @@ -334,7 +346,8 @@ Cent and(Cent c1, Cent c2) pure Cent or(Cent c1, Cent c2) { - return Cent(c1.lo | c2.lo, c1.hi | c2.hi); + const Cent ret = { lo:c1.lo | c2.lo, hi:c1.hi | c2.hi }; + return ret; } /**************************** @@ -348,7 +361,8 @@ Cent or(Cent c1, Cent c2) pure Cent xor(Cent c1, Cent c2) { - return Cent(c1.lo ^ c2.lo, c1.hi ^ c2.hi); + const Cent ret = { lo:c1.lo ^ c2.lo, hi:c1.hi ^ c2.hi }; + return ret; } /**************************** @@ -363,7 +377,8 @@ pure Cent add(Cent c1, Cent c2) { U r = cast(U)(c1.lo + c2.lo); - return Cent(r, cast(U)(c1.hi + c2.hi + (r < c1.lo))); + const Cent ret = { lo:r, hi:cast(U)(c1.hi + c2.hi + (r < c1.lo)) }; + return ret; } /**************************** @@ -419,9 +434,9 @@ Cent mul(Cent c1, Cent c2) const c1h1 = c1.hi >> mulshift; r3 = c1h1 * c2l0 + (r3 & mulmask); - return Cent((r0 & mulmask) + (r1 & mulmask) * (mulmask + 1), - (r2 & mulmask) + (r3 & mulmask) * (mulmask + 1)); - + const Cent ret = { lo:(r0 & mulmask) + (r1 & mulmask) * (mulmask + 1), + hi:(r2 & mulmask) + (r3 & mulmask) * (mulmask + 1) }; + return ret; } @@ -523,8 +538,10 @@ Cent udivmod(Cent c1, Cent c2, out Cent modulus) if (c1.hi == 0 && c2.hi == 0) { // Single precision divide - modulus = Cent(c1.lo % c2.lo); - return Cent(c1.lo / c2.lo); + const Cent rem = { lo:c1.lo % c2.lo }; + modulus = rem; + const Cent ret = { lo:c1.lo / c2.lo }; + return ret; } if (c1.hi == 0) { @@ -539,10 +556,11 @@ Cent udivmod(Cent c1, Cent c2, out Cent modulus) const q1 = (c1.hi < c2.lo) ? 0 : (c1.hi / c2.lo); if (q1) c1.hi = c1.hi % c2.lo; - U rem; - const q0 = udivmod128_64(c1, c2.lo, rem); - modulus = Cent(rem); - return Cent(q0, q1); + Cent rem; + const q0 = udivmod128_64(c1, c2.lo, rem.lo); + modulus = rem; + const Cent ret = { lo:q0, hi:q1 }; + return ret; } // Full cent precision division. @@ -560,10 +578,10 @@ Cent udivmod(Cent c1, Cent c2, out Cent modulus) // Get quotient from divide unsigned operation. U rem_ignored; - const q1 = udivmod128_64(u1, v1, rem_ignored); + const Cent q1 = { lo:udivmod128_64(u1, v1, rem_ignored) }; // Undo normalization and division of c1 by 2. - Cent quotient = shr(shl(Cent(q1), shift), 63); + Cent quotient = shr(shl(q1, shift), 63); // Make quotient correct or too small by 1 if (tst(quotient)) @@ -770,43 +788,44 @@ version (unittest) unittest { - const C0 = Zero; - const C1 = One; - const C2 = Cent(2); - const C3 = Cent(3); - const C5 = Cent(5); - const C10 = Cent(10); - const C20 = Cent(20); - const C30 = Cent(30); - const C100 = Cent(100); - - const Cm1 = neg(One); - const Cm3 = neg(C3); - const Cm10 = neg(C10); - - const C3_1 = Cent(1,3); - const C3_2 = Cent(2,3); - const C4_8 = Cent(8, 4); - const C5_0 = Cent(0, 5); - const C7_1 = Cent(1,7); - const C7_9 = Cent(9,7); - const C9_3 = Cent(3,9); - const C10_0 = Cent(0,10); - const C10_1 = Cent(1,10); - const C10_3 = Cent(3,10); - const C11_3 = Cent(3,11); - const C20_0 = Cent(0,20); - const C90_30 = Cent(30,90); - - const Cm10_0 = inc(com(C10_0)); // Cent(0, -10); - const Cm10_1 = inc(com(C10_1)); // Cent(-1, -11); - const Cm10_3 = inc(com(C10_3)); // Cent(-3, -11); - - enum Cs_3 = Cent(3, I.min); - - const Cbig_1 = Cent(0xa3ccac1832952398, 0xc3ac542864f652f8); - const Cbig_2 = Cent(0x5267b85f8a42fc20, 0); - const Cbig_3 = Cent(0xf0000000ffffffff, 0); + const Cent C0 = Zero; + const Cent C1 = One; + const Cent C2 = { lo:2 }; + const Cent C3 = { lo:3 }; + const Cent C5 = { lo:5 }; + const Cent C10 = { lo:10 }; + const Cent C20 = { lo:20 }; + const Cent C30 = { lo:30 }; + const Cent C100 = { lo:100 }; + + const Cent Cm1 = neg(One); + const Cent Cm3 = neg(C3); + const Cent Cm10 = neg(C10); + + const Cent C3_1 = { lo:1, hi:3 }; + const Cent C3_2 = { lo:2, hi:3 }; + const Cent C4_8 = { lo:8, hi:4 }; + const Cent C5_0 = { lo:0, hi:5 }; + const Cent C7_1 = { lo:1, hi:7 }; + const Cent C7_9 = { lo:9, hi:7 }; + const Cent C9_3 = { lo:3, hi:9 }; + const Cent C10_0 = { lo:0, hi:10 }; + const Cent C10_1 = { lo:1, hi:10 }; + const Cent C10_3 = { lo:3, hi:10 }; + const Cent C11_3 = { lo:3, hi:11 }; + const Cent C20_0 = { lo:0, hi:20 }; + const Cent C90_30 = { lo:30, hi:90 }; + + const Cent Cm10_0 = inc(com(C10_0)); // Cent(lo=0, hi=-10); + const Cent Cm10_1 = inc(com(C10_1)); // Cent(lo=-1, hi=-11); + const Cent Cm10_3 = inc(com(C10_3)); // Cent(lo=-3, hi=-11); + const Cent Cm20_0 = inc(com(C20_0)); // Cent(lo=0, hi=-20); + + enum Cent Cs_3 = { lo:3, hi:I.min }; + + const Cent Cbig_1 = { lo:0xa3ccac1832952398, hi:0xc3ac542864f652f8 }; + const Cent Cbig_2 = { lo:0x5267b85f8a42fc20, hi:0 }; + const Cent Cbig_3 = { lo:0xf0000000ffffffff, hi:0 }; /************************/ @@ -892,18 +911,27 @@ unittest assert(div(mul(C90_30, C2), C2) == C90_30); assert(div(mul(C90_30, C2), C90_30) == C2); - assert(divmod(Cbig_1, Cbig_2, modulus) == Cent(0x4496aa309d4d4a2f, U.max)); - assert(modulus == Cent(0xd83203d0fdc799b8, U.max)); - assert(udivmod(Cbig_1, Cbig_2, modulus) == Cent(0x5fe0e9bace2bedad, 2)); - assert(modulus == Cent(0x2c923125a68721f8, 0)); - assert(div(Cbig_1, Cbig_3) == Cent(0xbfa6c02b5aff8b86, U.max)); - assert(udiv(Cbig_1, Cbig_3) == Cent(0xd0b7d13b48cb350f, 0)); + const Cent Cb1divb2 = { lo:0x4496aa309d4d4a2f, hi:U.max }; + const Cent Cb1modb2 = { lo:0xd83203d0fdc799b8, hi:U.max }; + assert(divmod(Cbig_1, Cbig_2, modulus) == Cb1divb2); + assert(modulus == Cb1modb2); + + const Cent Cb1udivb2 = { lo:0x5fe0e9bace2bedad, hi:2 }; + const Cent Cb1umodb2 = { lo:0x2c923125a68721f8, hi:0 }; + assert(udivmod(Cbig_1, Cbig_2, modulus) == Cb1udivb2); + assert(modulus == Cb1umodb2); + + const Cent Cb1divb3 = { lo:0xbfa6c02b5aff8b86, hi:U.max }; + const Cent Cb1udivb3 = { lo:0xd0b7d13b48cb350f, hi:0 }; + assert(div(Cbig_1, Cbig_3) == Cb1divb3); + assert(udiv(Cbig_1, Cbig_3) == Cb1udivb3); assert(mul(Cm10, C1) == Cm10); assert(mul(C1, Cm10) == Cm10); assert(mul(C9_3, C10) == C90_30); assert(mul(Cs_3, C10) == C30); assert(mul(Cm10, Cm10) == C100); + assert(mul(C20_0, Cm1) == Cm20_0); assert( or(C4_8, C3_1) == C7_9); assert(and(C4_8, C7_9) == C4_8); diff --git a/libphobos/libdruntime/core/internal/array/appending.d b/libphobos/libdruntime/core/internal/array/appending.d index 1e58ddc..d416efe 100644 --- a/libphobos/libdruntime/core/internal/array/appending.d +++ b/libphobos/libdruntime/core/internal/array/appending.d @@ -35,14 +35,14 @@ template _d_arrayappendcTXImpl(Tarr : T[], T) * is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations. */ static if (isCopyingNothrow!T) // `nothrow` deduction doesn't work, so this is needed - ref Tarr _d_arrayappendcTX(return scope ref Tarr px, size_t n) @trusted pure nothrow + ref Tarr _d_arrayappendcTX(return ref scope Tarr px, size_t n) @trusted pure nothrow { pragma(inline, false); mixin(_d_arrayappendcTXBody); } else - ref Tarr _d_arrayappendcTX(return scope ref Tarr px, size_t n) @trusted pure nothrow + ref Tarr _d_arrayappendcTX(return ref scope Tarr px, size_t n) @trusted pure nothrow { pragma(inline, false); @@ -76,79 +76,70 @@ template _d_arrayappendcTXImpl(Tarr : T[], T) alias _d_arrayappendcTXTrace = _d_HookTraceImpl!(Tarr, _d_arrayappendcTX, errorMessage); } -/// Implementation of `_d_arrayappendT` and `_d_arrayappendTTrace` -template _d_arrayappendTImpl(Tarr : T[], T) +/// Implementation of `_d_arrayappendT` +ref Tarr _d_arrayappendT(Tarr : T[], T)(return ref scope Tarr x, scope Tarr y) @trusted { - import core.internal.array.utils : _d_HookTraceImpl; - - private enum errorMessage = "Cannot append to array if compiling without support for runtime type information!"; - - /** - * Append array `y` to array `x`. - * Params: - * x = what array to append to, taken as a reference - * y = what should be appended - * Returns: - * The new value of `x` - * Bugs: - * This function template was ported from a much older runtime hook that bypassed safety, - * purity, and throwabilty checks. To prevent breaking existing code, this function template - * is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations. - */ - static if (isCopyingNothrow!T) - ref Tarr _d_arrayappendT(return scope ref Tarr x, scope Tarr y) @trusted pure nothrow - { - pragma(inline, false); + pragma(inline, false); - mixin(_d_arrayappendTBody); - } - else - ref Tarr _d_arrayappendT(return scope ref Tarr x, scope Tarr y) @trusted pure - { - pragma(inline, false); - - mixin(_d_arrayappendTBody); - } + import core.stdc.string : memcpy; + import core.internal.traits : hasElaborateCopyConstructor, Unqual; + import core.lifetime : copyEmplace; - private enum _d_arrayappendTBody = q{ - import core.stdc.string : memcpy; - import core.internal.traits : hasElaborateCopyConstructor, Unqual; - import core.lifetime : copyEmplace; + enum hasPostblit = __traits(hasPostblit, T); + auto length = x.length; - auto length = x.length; + _d_arrayappendcTXImpl!Tarr._d_arrayappendcTX(x, y.length); - _d_arrayappendcTXImpl!Tarr._d_arrayappendcTX(x, y.length); - - static if (hasElaborateCopyConstructor!T) - { - foreach (i; 0 .. y.length) - copyEmplace(y[i], x[length + i]); - } - else + // Only call `copyEmplace` if `T` has a copy ctor and no postblit. + static if (hasElaborateCopyConstructor!T && !hasPostblit) + { + foreach (i, ref elem; y) + copyEmplace(elem, x[length + i]); + } + else + { + if (y.length) { // blit all elements at once - if (y.length) - memcpy(cast(Unqual!T *)&x[length], cast(Unqual!T *)&y[0], y.length * T.sizeof); + auto xptr = cast(Unqual!T *)&x[length]; + immutable size = T.sizeof; + + memcpy(xptr, cast(Unqual!T *)&y[0], y.length * size); + + // call postblits if they exist + static if (hasPostblit) + { + auto eptr = xptr + y.length; + for (auto ptr = xptr; ptr < eptr; ptr++) + ptr.__xpostblit(); + } } + } - return x; - }; + return x; +} - /** - * TraceGC wrapper around $(REF _d_arrayappendT, rt,array,appending,_d_arrayappendTImpl). - * Bugs: - * This function template was ported from a much older runtime hook that bypassed safety, - * purity, and throwabilty checks. To prevent breaking existing code, this function template - * is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations. - */ - alias _d_arrayappendTTrace = _d_HookTraceImpl!(Tarr, _d_arrayappendT, errorMessage); +/** + * TraceGC wrapper around $(REF _d_arrayappendT, core,internal,array,appending). + */ +ref Tarr _d_arrayappendTTrace(Tarr : T[], T)(string file, int line, string funcname, return ref scope Tarr x, scope Tarr y) @trusted +{ + version (D_TypeInfo) + { + import core.internal.array.utils: TraceHook, gcStatsPure, accumulatePure; + mixin(TraceHook!(Tarr.stringof, "_d_arrayappendT")); + + return _d_arrayappendT(x, y); + } + else + assert(0, "Cannot append to array if compiling without support for runtime type information!"); } @safe unittest { double[] arr1; foreach (i; 0 .. 4) - _d_arrayappendTImpl!(typeof(arr1))._d_arrayappendT(arr1, [cast(double)i]); + _d_arrayappendT(arr1, [cast(double)i]); assert(arr1 == [0.0, 1.0, 2.0, 3.0]); } @@ -167,7 +158,7 @@ template _d_arrayappendTImpl(Tarr : T[], T) Item[] arr2 = [Item(), Item()]; Item[] arr1_org = [Item(), Item()]; arr1_org ~= arr2; - _d_arrayappendTImpl!(typeof(arr1))._d_arrayappendT(arr1, arr2); + _d_arrayappendT(arr1, arr2); // postblit should have triggered on at least the items in arr2 assert(blitted >= arr2.length); @@ -187,7 +178,7 @@ template _d_arrayappendTImpl(Tarr : T[], T) Item[][] arr1 = [[Item()]]; Item[][] arr2 = [[Item()]]; - _d_arrayappendTImpl!(typeof(arr1))._d_arrayappendT(arr1, arr2); + _d_arrayappendT(arr1, arr2); // no postblit should have happened because arr{1,2} contain dynamic arrays assert(blitted == 0); @@ -207,7 +198,7 @@ template _d_arrayappendTImpl(Tarr : T[], T) Item[1][] arr1 = [[Item()]]; Item[1][] arr2 = [[Item()]]; - _d_arrayappendTImpl!(typeof(arr1))._d_arrayappendT(arr1, arr2); + _d_arrayappendT(arr1, arr2); // copy constructor should have been invoked because arr{1,2} contain static arrays assert(copied >= arr2.length); } @@ -215,8 +206,8 @@ template _d_arrayappendTImpl(Tarr : T[], T) @safe nothrow unittest { string str; - _d_arrayappendTImpl!(typeof(str))._d_arrayappendT(str, "a"); - _d_arrayappendTImpl!(typeof(str))._d_arrayappendT(str, "b"); - _d_arrayappendTImpl!(typeof(str))._d_arrayappendT(str, "c"); + _d_arrayappendT(str, "a"); + _d_arrayappendT(str, "b"); + _d_arrayappendT(str, "c"); assert(str == "abc"); } diff --git a/libphobos/libdruntime/core/internal/array/casting.d b/libphobos/libdruntime/core/internal/array/casting.d index e862f8e..4366da8 100644 --- a/libphobos/libdruntime/core/internal/array/casting.d +++ b/libphobos/libdruntime/core/internal/array/casting.d @@ -17,12 +17,13 @@ builds. It is separate from `__ArrayCast` to minimize code bloat. Params: - fromType = name of the type being cast from - fromSize = total size in bytes of the array being cast from - toType = name of the type being cast o - toSize = total size in bytes of the array being cast to + fromType = name of the type being cast from + fromSize = total size in bytes of the array being cast from + fromLength = length of array being cast from + toType = name of the type being cast to + toElemSize = element size of array being cast to */ -private void onArrayCastError()(string fromType, size_t fromSize, string toType, size_t toSize) @trusted +private void onArrayCastError()(string fromType, size_t fromSize, size_t fromLength, string toType, size_t toElemSize) @trusted { import core.internal.string : unsignedToTempString; import core.memory : pureMalloc; @@ -45,17 +46,22 @@ private void onArrayCastError()(string fromType, size_t fromSize, string toType, index += N; } - add("An array of size "); - auto s = unsignedToTempString(fromSize); + add("`"); + add(fromType); + add("[]` of length "); + auto s = unsignedToTempString(fromLength); add(s[]); - add(" does not align on an array of size "); - s = unsignedToTempString(toSize); + add(" cannot be cast to `"); + add(toType); + add("[]` as its length in bytes ("); + s = unsignedToTempString(fromSize); add(s[]); - add(", so `"); - add(fromType); - add("` cannot be cast to `"); + add(") is not a multiple of `"); add(toType); - add("`"); + add(".sizeof` ("); + s = unsignedToTempString(toElemSize); + add(s[]); + add(")."); msg[index] = '\0'; // null-termination // first argument must evaluate to `false` at compile-time to maintain memory safety in release builds @@ -64,7 +70,7 @@ private void onArrayCastError()(string fromType, size_t fromSize, string toType, /** The compiler lowers expressions of `cast(TTo[])TFrom[]` to -this implementation. +this implementation. Note that this does not detect alignment problems. Params: from = the array to reinterpret-cast @@ -79,7 +85,7 @@ TTo[] __ArrayCast(TFrom, TTo)(return scope TFrom[] from) @nogc pure @trusted if ((fromSize % TTo.sizeof) != 0) { - onArrayCastError(TFrom.stringof, fromSize, TTo.stringof, toLength * TTo.sizeof); + onArrayCastError(TFrom.stringof, fromSize, from.length, TTo.stringof, TTo.sizeof); } struct Array @@ -113,3 +119,26 @@ TTo[] __ArrayCast(TFrom, TTo)(return scope TFrom[] from) @nogc pure @trusted foreach (v; s) assert(v == cast(short) 0xabab); } + +@system nothrow unittest +{ + string msg; + try + { + auto str = "hello"; + auto wstr = cast(wstring) str; + } + catch (Throwable t) + msg = t.msg; + + static immutable expected = "`immutable(char)[]` of length 5 cannot be cast to `immutable(wchar)[]` as " ~ + "its length in bytes (5) is not a multiple of `immutable(wchar).sizeof` (2)."; + + if (msg != expected) + { + import core.stdc.stdio; + printf("Expected: |%.*s|\n", cast(int) expected.length, expected.ptr); + printf("Actual : |%.*s|\n", cast(int) msg.length, msg.ptr); + assert(false); + } +} diff --git a/libphobos/libdruntime/core/internal/array/comparison.d b/libphobos/libdruntime/core/internal/array/comparison.d index 1a68b9b..821f96e 100644 --- a/libphobos/libdruntime/core/internal/array/comparison.d +++ b/libphobos/libdruntime/core/internal/array/comparison.d @@ -60,24 +60,21 @@ int __cmp(T)(scope const T[] lhs, scope const T[] rhs) @trusted immutable len = lhs.length <= rhs.length ? lhs.length : rhs.length; foreach (const u; 0 .. len) { - static if (__traits(isFloating, T)) + auto a = lhs.ptr[u], b = rhs.ptr[u]; + static if (is(T : creal)) { - immutable a = lhs.ptr[u], b = rhs.ptr[u]; - static if (is(T == cfloat) || is(T == cdouble) - || is(T == creal)) - { - // Use rt.cmath2._Ccmp instead ? - auto r = (a.re > b.re) - (a.re < b.re); - if (!r) r = (a.im > b.im) - (a.im < b.im); - } - else - { - const r = (a > b) - (a < b); - } - if (r) return r; + // Use rt.cmath2._Ccmp instead ? + // Also: if NaN is present, numbers will appear equal. + auto r = (a.re > b.re) - (a.re < b.re); + if (!r) r = (a.im > b.im) - (a.im < b.im); + } + else + { + // This pattern for three-way comparison is better than conditional operators + // See e.g. https://godbolt.org/z/3j4vh1 + const r = (a > b) - (a < b); } - else if (lhs.ptr[u] != rhs.ptr[u]) - return lhs.ptr[u] < rhs.ptr[u] ? -1 : 1; + if (r) return r; } return (lhs.length > rhs.length) - (lhs.length < rhs.length); } @@ -117,8 +114,8 @@ if (!__traits(isScalar, T1) && !__traits(isScalar, T2)) } else static if (__traits(compiles, at(s1, u) < at(s2, u))) { - if (at(s1, u) != at(s2, u)) - return at(s1, u) < at(s2, u) ? -1 : 1; + if (int result = (at(s1, u) > at(s2, u)) - (at(s1, u) < at(s2, u))) + return result; } else { diff --git a/libphobos/libdruntime/core/internal/array/equality.d b/libphobos/libdruntime/core/internal/array/equality.d index b12e2f2..d3fdd65 100644 --- a/libphobos/libdruntime/core/internal/array/equality.d +++ b/libphobos/libdruntime/core/internal/array/equality.d @@ -21,8 +21,7 @@ bool __equals(T1, T2)(scope const T1[] lhs, scope const T2[] rhs) @nogc nothrow pure @trusted if (__traits(isScalar, T1) && __traits(isScalar, T2)) { - if (lhs.length != rhs.length) - return false; + const length = lhs.length; static if (T1.sizeof == T2.sizeof // Signedness needs to match for types that promote to int. @@ -31,20 +30,21 @@ if (__traits(isScalar, T1) && __traits(isScalar, T2)) && (T1.sizeof >= 4 || __traits(isUnsigned, T1) == __traits(isUnsigned, T2)) && !__traits(isFloating, T1) && !__traits(isFloating, T2)) { - if (!__ctfe) + if (__ctfe) + return length == rhs.length && isEqual(lhs.ptr, rhs.ptr, length); + else { // This would improperly allow equality of integers and pointers // but the CTFE branch will stop this function from compiling then. import core.stdc.string : memcmp; - return lhs.length == 0 || - 0 == memcmp(cast(const void*) lhs.ptr, cast(const void*) rhs.ptr, lhs.length * T1.sizeof); + return length == rhs.length && + (!length || 0 == memcmp(cast(const void*) lhs.ptr, cast(const void*) rhs.ptr, length * T1.sizeof)); } } - - foreach (const i; 0 .. lhs.length) - if (lhs.ptr[i] != rhs.ptr[i]) - return false; - return true; + else + { + return length == rhs.length && isEqual(lhs.ptr, rhs.ptr, length); + } } bool __equals(T1, T2)(scope T1[] lhs, scope T2[] rhs) @@ -89,6 +89,19 @@ if (!__traits(isScalar, T1) || !__traits(isScalar, T2)) } } +/****************************** + * Helper function for __equals(). + * Outlined to enable __equals() to be inlined, as dmd cannot inline loops. + */ +private +bool isEqual(T1, T2)(scope const T1* t1, scope const T2* t2, size_t length) +{ + foreach (const i; 0 .. length) + if (t1[i] != t2[i]) + return false; + return true; +} + @safe unittest { assert(__equals([], [])); diff --git a/libphobos/libdruntime/core/internal/array/utils.d b/libphobos/libdruntime/core/internal/array/utils.d index 7a829a0..41aa57f 100644 --- a/libphobos/libdruntime/core/internal/array/utils.d +++ b/libphobos/libdruntime/core/internal/array/utils.d @@ -11,7 +11,7 @@ module core.internal.array.utils; import core.internal.traits : Parameters; -private auto gcStatsPure() nothrow pure +auto gcStatsPure() nothrow pure { import core.memory : GC; @@ -19,7 +19,7 @@ private auto gcStatsPure() nothrow pure return impureBypass(); } -private ulong accumulatePure(string file, int line, string funcname, string name, ulong size) nothrow pure +ulong accumulatePure(string file, int line, string funcname, string name, ulong size) nothrow pure { static ulong impureBypass(string file, int line, string funcname, string name, ulong size) @nogc nothrow { @@ -35,41 +35,32 @@ private ulong accumulatePure(string file, int line, string funcname, string name } /** - * TraceGC wrapper around runtime hook `Hook`. + * TraceGC wrapper generator around the runtime hook `Hook`. * Params: - * T = Type of hook to report to accumulate - * Hook = The hook to wrap - * errorMessage = The error message incase `version != D_TypeInfo` - * file = File that called `_d_HookTraceImpl` - * line = Line inside of `file` that called `_d_HookTraceImpl` - * funcname = Function that called `_d_HookTraceImpl` - * parameters = Parameters that will be used to call `Hook` - * Bugs: - * This function template needs be between the compiler and a much older runtime hook that bypassed safety, - * purity, and throwabilty checks. To prevent breaking existing code, this function template - * is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations. -*/ -auto _d_HookTraceImpl(T, alias Hook, string errorMessage)(string file, int line, string funcname, Parameters!Hook parameters) @trusted pure + * Type = The type of hook to report to accumulate + * Hook = The name hook to wrap + */ +template TraceHook(string Type, string Hook) { - version (D_TypeInfo) - { + const char[] TraceHook = q{ + import core.internal.array.utils : gcStatsPure, accumulatePure; + pragma(inline, false); - string name = T.stringof; + string name = } ~ "`" ~ Type ~ "`;" ~ q{ // FIXME: use rt.tracegc.accumulator when it is accessable in the future. version (tracegc) - { + } ~ "{\n" ~ q{ import core.stdc.stdio; printf("%sTrace file = '%.*s' line = %d function = '%.*s' type = %.*s\n", - Hook.stringof.ptr, + } ~ "\"" ~ Hook ~ "\".ptr," ~ q{ file.length, file.ptr, line, funcname.length, funcname.ptr, name.length, name.ptr ); - } - + } ~ "}\n" ~ q{ ulong currentlyAllocated = gcStatsPure().allocatedInCurrentThread; scope(exit) @@ -86,6 +77,29 @@ auto _d_HookTraceImpl(T, alias Hook, string errorMessage)(string file, int line, assert(0); } } + }; +} + +/** + * TraceGC wrapper around runtime hook `Hook`. + * Params: + * T = Type of hook to report to accumulate + * Hook = The hook to wrap + * errorMessage = The error message incase `version != D_TypeInfo` + * file = File that called `_d_HookTraceImpl` + * line = Line inside of `file` that called `_d_HookTraceImpl` + * funcname = Function that called `_d_HookTraceImpl` + * parameters = Parameters that will be used to call `Hook` + * Bugs: + * This function template needs be between the compiler and a much older runtime hook that bypassed safety, + * purity, and throwabilty checks. To prevent breaking existing code, this function template + * is temporarily declared `@trusted pure` until the implementation can be brought up to modern D expectations. +*/ +auto _d_HookTraceImpl(T, alias Hook, string errorMessage)(string file, int line, string funcname, Parameters!Hook parameters) @trusted pure +{ + version (D_TypeInfo) + { + mixin(TraceHook!(T.stringof, __traits(identifier, Hook))); return Hook(parameters); } else diff --git a/libphobos/libdruntime/core/internal/convert.d b/libphobos/libdruntime/core/internal/convert.d index a876fcc..92eb243 100644 --- a/libphobos/libdruntime/core/internal/convert.d +++ b/libphobos/libdruntime/core/internal/convert.d @@ -741,28 +741,6 @@ const(ubyte)[] toUbyte(T)(const ref scope T val) if (is(T == __vector)) } } -// @@@DEPRECATED_2022-02@@@ -deprecated -@trusted pure nothrow @nogc -const(ubyte)[] toUbyte(T)(const ref return scope T val) if (__traits(isFloating, T) && is(T : creal)) -{ - if (__ctfe) - { - auto re = val.re; - auto im = val.im; - auto a = re.toUbyte(); - auto b = im.toUbyte(); - ubyte[] result = ctfe_alloc(a.length + b.length); - result[0 .. a.length] = a[0 .. a.length]; - result[a.length .. $] = b[0 .. b.length]; - return result; - } - else - { - return (cast(const(ubyte)*)&val)[0 .. T.sizeof]; - } -} - @trusted pure nothrow @nogc const(ubyte)[] toUbyte(T)(const ref return scope T val) if (is(T == enum)) { diff --git a/libphobos/libdruntime/core/internal/gc/bits.d b/libphobos/libdruntime/core/internal/gc/bits.d index d50c38f..aa94e40 100644 --- a/libphobos/libdruntime/core/internal/gc/bits.d +++ b/libphobos/libdruntime/core/internal/gc/bits.d @@ -60,7 +60,7 @@ struct GCBits onOutOfMemoryError(); } - wordtype test(size_t i) const nothrow + wordtype test(size_t i) const scope @trusted pure nothrow @nogc in { assert(i < nbits); @@ -70,7 +70,7 @@ struct GCBits return core.bitop.bt(data, i); } - int set(size_t i) nothrow + int set(size_t i) scope @trusted pure nothrow @nogc in { assert(i < nbits); @@ -80,7 +80,7 @@ struct GCBits return core.bitop.bts(data, i); } - int clear(size_t i) nothrow + int clear(size_t i) scope @trusted pure nothrow @nogc in { assert(i <= nbits); @@ -91,7 +91,7 @@ struct GCBits } // return non-zero if bit already set - size_t setLocked(size_t i) nothrow + size_t setLocked(size_t i) scope @trusted pure nothrow @nogc { version (GNU) { @@ -112,7 +112,7 @@ struct GCBits } else version (D_InlineAsm_X86) { - asm @nogc nothrow { + asm pure @nogc nothrow { mov EAX, this; mov ECX, data[EAX]; mov EDX, i; @@ -123,7 +123,7 @@ struct GCBits } else version (D_InlineAsm_X86_64) { - asm @nogc nothrow { + asm pure @nogc nothrow { mov RAX, this; mov RAX, data[RAX]; mov RDX, i; @@ -239,7 +239,9 @@ struct GCBits size_t cntWords = lastWord - firstWord; copyWordsShifted(firstWord, cntWords, firstOff, source); - wordtype src = (source[cntWords - 1] >> (BITS_PER_WORD - firstOff)) | (source[cntWords] << firstOff); + wordtype src = (source[cntWords - 1] >> (BITS_PER_WORD - firstOff)); + if (lastOff >= firstOff) // prevent buffer overread + src |= (source[cntWords] << firstOff); wordtype mask = (BITS_2 << lastOff) - 1; data[lastWord] = (data[lastWord] & ~mask) | (src & mask); } diff --git a/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d b/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d index 87c45fb..e29e426 100644 --- a/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d +++ b/libphobos/libdruntime/core/internal/gc/impl/conservative/gc.d @@ -38,6 +38,8 @@ import core.gc.config; import core.gc.gcinterface; import core.internal.container.treap; +import core.internal.spinlock; +import core.internal.gc.pooltable; import cstdlib = core.stdc.stdlib : calloc, free, malloc, realloc; import core.stdc.string : memcpy, memset, memmove; @@ -145,7 +147,6 @@ class ConservativeGC : GC Gcx *gcx; // implementation - import core.internal.spinlock; static gcLock = shared(AlignedSpinLock)(SpinLock.Contention.lengthy); static bool _inFinalizer; __gshared bool isPrecise = false; @@ -155,7 +156,7 @@ class ConservativeGC : GC * * Throws: InvalidMemoryOperationError on recursive locking during finalization. */ - static void lockNR() @nogc nothrow + static void lockNR() @safe @nogc nothrow { if (_inFinalizer) onInvalidMemoryOperationError(); @@ -685,7 +686,7 @@ class ConservativeGC : GC else if (pagenum + newsz <= pool.npages) { // Attempt to expand in place (TODO: merge with extend) - if (lpool.pagetable[pagenum + psz] != B_FREE) + if (lpool.pagetable[pagenum + psz] != Bins.B_FREE) return doMalloc(); auto newPages = newsz - psz; @@ -695,7 +696,7 @@ class ConservativeGC : GC debug (MEMSTOMP) memset(p + psize, 0xF0, size - psize); debug (PRINTF) printFreeInfo(pool); - memset(&lpool.pagetable[pagenum + psz], B_PAGEPLUS, newPages); + memset(&lpool.pagetable[pagenum + psz], Bins.B_PAGEPLUS, newPages); lpool.bPageOffsets[pagenum] = cast(uint) newsz; for (auto offset = psz; offset < newsz; offset++) lpool.bPageOffsets[pagenum + offset] = cast(uint) offset; @@ -766,7 +767,7 @@ class ConservativeGC : GC auto lpool = cast(LargeObjectPool*) pool; size_t pagenum = lpool.pagenumOf(p); - if (lpool.pagetable[pagenum] != B_PAGE) + if (lpool.pagetable[pagenum] != Bins.B_PAGE) return 0; size_t psz = lpool.bPageOffsets[pagenum]; @@ -777,7 +778,7 @@ class ConservativeGC : GC if (pagenum + psz >= lpool.npages) return 0; - if (lpool.pagetable[pagenum + psz] != B_FREE) + if (lpool.pagetable[pagenum + psz] != Bins.B_FREE) return 0; size_t freesz = lpool.bPageOffsets[pagenum + psz]; @@ -785,7 +786,7 @@ class ConservativeGC : GC return 0; size_t sz = freesz > maxsz ? maxsz : freesz; debug (MEMSTOMP) memset(pool.baseAddr + (pagenum + psz) * PAGESIZE, 0xF0, sz * PAGESIZE); - memset(lpool.pagetable + pagenum + psz, B_PAGEPLUS, sz); + memset(lpool.pagetable + pagenum + psz, Bins.B_PAGEPLUS, sz); lpool.bPageOffsets[pagenum] = cast(uint) (psz + sz); for (auto offset = psz; offset < psz + sz; offset++) lpool.bPageOffsets[pagenum + offset] = cast(uint) offset; @@ -874,11 +875,11 @@ class ConservativeGC : GC debug(PRINTF) printf("pool base = %p, PAGENUM = %d of %d, bin = %d\n", pool.baseAddr, pagenum, pool.npages, pool.pagetable[pagenum]); debug(PRINTF) if (pool.isLargeObject) printf("Block size = %d\n", pool.bPageOffsets[pagenum]); - bin = cast(Bins)pool.pagetable[pagenum]; + bin = pool.pagetable[pagenum]; // Verify that the pointer is at the beginning of a block, // no action should be taken if p is an interior pointer - if (bin > B_PAGE) // B_PAGEPLUS or B_FREE + if (bin > Bins.B_PAGE) // B_PAGEPLUS or B_FREE return; size_t off = (sentinel_sub(p) - pool.baseAddr); size_t base = baseOffset(off, bin); @@ -893,7 +894,7 @@ class ConservativeGC : GC if (pool.isLargeObject) // if large alloc { biti = cast(size_t)(p - pool.baseAddr) >> pool.ShiftBy.Large; - assert(bin == B_PAGE); + assert(bin == Bins.B_PAGE); auto lpool = cast(LargeObjectPool*) pool; // Free pages @@ -1094,13 +1095,13 @@ class ConservativeGC : GC pool = gcx.findPool(p); assert(pool); pagenum = pool.pagenumOf(p); - bin = cast(Bins)pool.pagetable[pagenum]; - assert(bin <= B_PAGE); + bin = pool.pagetable[pagenum]; + assert(bin <= Bins.B_PAGE); assert(p == cast(void*)baseOffset(cast(size_t)p, bin)); debug (PTRCHECK2) { - if (bin < B_PAGE) + if (bin < Bins.B_PAGE) { // Check that p is not on a free list List *list; @@ -1299,7 +1300,7 @@ class ConservativeGC : GC } - core.memory.GC.Stats stats() nothrow + core.memory.GC.Stats stats() @safe nothrow @nogc { typeof(return) ret; @@ -1332,13 +1333,20 @@ class ConservativeGC : GC // // Implementation of getStats // - private void getStatsNoSync(out core.memory.GC.Stats stats) nothrow + private void getStatsNoSync(out core.memory.GC.Stats stats) @trusted nothrow @nogc { - foreach (pool; gcx.pooltable[0 .. gcx.npools]) + // This function is trusted for two reasons: `pool.pagetable` is a pointer, + // which is being sliced in the below foreach, and so is `binPageChain`, + // also sliced a bit later in this function. + // However, both usages are safe as long as the assumption that `npools` + // defines the limit for `pagetable`'s length holds true (see allocation). + // The slicing happens at __LINE__ + 4 and __LINE__ + 24. + // `@trusted` delegates are not used to prevent any performance issue. + foreach (pool; gcx.pooltable[]) { foreach (bin; pool.pagetable[0 .. pool.npages]) { - if (bin == B_FREE) + if (bin == Bins.B_FREE) stats.freeSize += PAGESIZE; else stats.usedSize += PAGESIZE; @@ -1346,13 +1354,13 @@ class ConservativeGC : GC } size_t freeListSize; - foreach (n; 0 .. B_PAGE) + foreach (n; 0 .. Bins.B_PAGE) { immutable sz = binsize[n]; for (List *list = gcx.bucket[n]; list; list = list.next) freeListSize += sz; - foreach (pool; gcx.pooltable[0 .. gcx.npools]) + foreach (pool; gcx.pooltable[]) { if (pool.isLargeObject) continue; @@ -1381,7 +1389,7 @@ enum } -enum +enum Bins : ubyte { B_16, B_32, @@ -1405,10 +1413,6 @@ enum B_MAX, } - -alias ubyte Bins; - - struct List { List *next; @@ -1416,12 +1420,12 @@ struct List } // non power of two sizes optimized for small remainder within page (<= 64 bytes) -immutable short[B_NUMSMALL + 1] binsize = [ 16, 32, 48, 64, 96, 128, 176, 256, 368, 512, 816, 1024, 1360, 2048, 4096 ]; -immutable short[PAGESIZE / 16][B_NUMSMALL + 1] binbase = calcBinBase(); +immutable short[Bins.B_NUMSMALL + 1] binsize = [ 16, 32, 48, 64, 96, 128, 176, 256, 368, 512, 816, 1024, 1360, 2048, 4096 ]; +immutable short[PAGESIZE / 16][Bins.B_NUMSMALL + 1] binbase = calcBinBase(); -short[PAGESIZE / 16][B_NUMSMALL + 1] calcBinBase() +short[PAGESIZE / 16][Bins.B_NUMSMALL + 1] calcBinBase() { - short[PAGESIZE / 16][B_NUMSMALL + 1] bin; + short[PAGESIZE / 16][Bins.B_NUMSMALL + 1] bin; foreach (i, size; binsize) { @@ -1440,7 +1444,7 @@ short[PAGESIZE / 16][B_NUMSMALL + 1] calcBinBase() size_t baseOffset(size_t offset, Bins bin) @nogc nothrow { - assert(bin <= B_PAGE); + assert(bin <= Bins.B_PAGE); return (offset & ~(PAGESIZE - 1)) + binbase[bin][(offset & (PAGESIZE - 1)) >> 4]; } @@ -1448,9 +1452,9 @@ alias PageBits = GCBits.wordtype[PAGESIZE / 16 / GCBits.BITS_PER_WORD]; static assert(PAGESIZE % (GCBits.BITS_PER_WORD * 16) == 0); // bitmask with bits set at base offsets of objects -immutable PageBits[B_NUMSMALL] baseOffsetBits = (){ - PageBits[B_NUMSMALL] bits; - foreach (bin; 0..B_NUMSMALL) +immutable PageBits[Bins.B_NUMSMALL] baseOffsetBits = (){ + PageBits[Bins.B_NUMSMALL] bits; + foreach (bin; 0 .. Bins.B_NUMSMALL) { size_t size = binsize[bin]; const top = PAGESIZE - size + 1; // ensure <size> bytes available even if unaligned @@ -1475,7 +1479,6 @@ private void set(ref PageBits bits, size_t i) @nogc pure nothrow struct Gcx { - import core.internal.spinlock; auto rootsLock = shared(AlignedSpinLock)(SpinLock.Contention.brief); auto rangesLock = shared(AlignedSpinLock)(SpinLock.Contention.brief); Treap!Root roots; @@ -1491,11 +1494,9 @@ struct Gcx debug(INVARIANT) bool inCollection; uint disabled; // turn off collections if >0 - import core.internal.gc.pooltable; - private @property size_t npools() pure const nothrow { return pooltable.length; } PoolTable!Pool pooltable; - List*[B_NUMSMALL] bucket; // free list for each small size + List*[Bins.B_NUMSMALL] bucket; // free list for each small size // run a collection when reaching those thresholds (number of used pages) float smallCollectThreshold, largeCollectThreshold; @@ -1508,7 +1509,7 @@ struct Gcx else alias leakDetector = LeakDetector; - SmallObjectPool*[B_NUMSMALL] recoverPool; + SmallObjectPool*[Bins.B_NUMSMALL] recoverPool; version (Posix) __gshared Gcx* instance; void initialize() @@ -1592,9 +1593,8 @@ struct Gcx debug(INVARIANT) initialized = false; - for (size_t i = 0; i < npools; i++) + foreach (Pool* pool; this.pooltable[]) { - Pool *pool = pooltable[i]; mappedPages -= pool.npages; pool.Dtor(); cstdlib.free(pool); @@ -1635,7 +1635,7 @@ struct Gcx if (!inCollection) (cast()rangesLock).unlock(); - for (size_t i = 0; i < B_NUMSMALL; i++) + for (size_t i = 0; i < Bins.B_NUMSMALL; i++) { size_t j = 0; List* prev, pprev, ppprev; // keep a short history to inspect in the debugger @@ -1752,7 +1752,7 @@ struct Gcx ConservativeGC._inFinalizer = true; scope (failure) ConservativeGC._inFinalizer = false; - foreach (pool; pooltable[0 .. npools]) + foreach (pool; this.pooltable[]) { if (!pool.finals.nbits) continue; @@ -1816,18 +1816,18 @@ struct Gcx /** * Computes the bin table using CTFE. */ - static byte[2049] ctfeBins() nothrow + static Bins[2049] ctfeBins() nothrow { - byte[2049] ret; + Bins[2049] ret; size_t p = 0; - for (Bins b = B_16; b <= B_2048; b++) + for (Bins b = Bins.B_16; b <= Bins.B_2048; b++) for ( ; p <= binsize[b]; p++) ret[p] = b; return ret; } - static const byte[2049] binTable = ctfeBins(); + static immutable Bins[2049] binTable = ctfeBins(); /** * Allocate a new pool of at least size bytes. @@ -1994,7 +1994,7 @@ struct Gcx bool tryAlloc() nothrow { - foreach (p; pooltable[0 .. npools]) + foreach (p; this.pooltable[]) { if (!p.isLargeObject || p.freepages < npages) continue; @@ -2094,10 +2094,11 @@ struct Gcx } // Allocate successively larger pools up to 8 megs - if (npools) - { size_t n; + if (this.pooltable.length) + { + size_t n; - n = config.minPoolSize + config.incPoolSize * npools; + n = config.minPoolSize + config.incPoolSize * this.pooltable.length; if (n > config.maxPoolSize) n = config.maxPoolSize; // cap pool size n /= PAGESIZE; // convert bytes to pages @@ -2139,9 +2140,8 @@ struct Gcx List* allocPage(Bins bin) nothrow { //debug(PRINTF) printf("Gcx::allocPage(bin = %d)\n", bin); - for (size_t n = 0; n < npools; n++) + foreach (Pool* pool; this.pooltable[]) { - Pool* pool = pooltable[n]; if (pool.isLargeObject) continue; if (List* p = (cast(SmallObjectPool*)pool).allocPage(bin)) @@ -2275,7 +2275,7 @@ struct Gcx // let dmd allocate a register for this.pools auto pools = pooltable.pools; - const highpool = pooltable.npools - 1; + const highpool = pooltable.length - 1; const minAddr = pooltable.minAddr; size_t memSize = pooltable.maxAddr - minAddr; Pool* pool = null; @@ -2300,7 +2300,6 @@ struct Gcx bitpos -= rng.bmplength; rng.pbase += rng.bmplength; } - import core.bitop; if (!core.bitop.bt(rng.ptrbmp, bitpos)) { debug(MARK_PRINTF) printf("\t\tskipping non-pointer\n"); @@ -2335,7 +2334,7 @@ struct Gcx printf("\t\tfound pool %p, base=%p, pn = %lld, bin = %d\n", pool, pool.baseAddr, cast(long)pn, bin); // Adjust bit to be at start of allocated memory block - if (bin < B_PAGE) + if (bin < Bins.B_PAGE) { // We don't care abou setting pointsToBase correctly // because it's ignored for small object pools anyhow. @@ -2356,7 +2355,7 @@ struct Gcx goto LaddRange; } } - else if (bin == B_PAGE) + else if (bin == Bins.B_PAGE) { biti = offset >> Pool.ShiftBy.Large; //debug(PRINTF) printf("\t\tbiti = x%x\n", biti); @@ -2376,7 +2375,7 @@ struct Gcx goto LaddLargeRange; } } - else if (bin == B_PAGEPLUS) + else if (bin == Bins.B_PAGEPLUS) { pn -= pool.bPageOffsets[pn]; biti = pn * (PAGESIZE >> Pool.ShiftBy.Large); @@ -2429,7 +2428,7 @@ struct Gcx else { // Don't mark bits in B_FREE pages - assert(bin == B_FREE); + assert(bin == Bins.B_FREE); } } LnextPtr: @@ -2526,9 +2525,8 @@ struct Gcx { debug(COLLECT_PRINTF) printf("preparing mark.\n"); - for (size_t n = 0; n < npools; n++) + foreach (Pool* pool; this.pooltable[]) { - Pool* pool = pooltable[n]; if (pool.isLargeObject) pool.mark.zero(); else @@ -2598,10 +2596,9 @@ struct Gcx size_t freedLargePages; size_t freedSmallPages; size_t freed; - for (size_t n = 0; n < npools; n++) + foreach (Pool* pool; this.pooltable[]) { size_t pn; - Pool* pool = pooltable[n]; if (pool.isLargeObject) { @@ -2612,12 +2609,12 @@ struct Gcx { npages = pool.bPageOffsets[pn]; Bins bin = cast(Bins)pool.pagetable[pn]; - if (bin == B_FREE) + if (bin == Bins.B_FREE) { numFree += npages; continue; } - assert(bin == B_PAGE); + assert(bin == Bins.B_PAGE); size_t biti = pn; if (!pool.mark.test(biti)) @@ -2637,7 +2634,7 @@ struct Gcx debug(COLLECT_PRINTF) printf("\tcollecting big %p\n", p); leakDetector.log_free(q, sentinel_size(q, npages * PAGESIZE - SENTINEL_EXTRA)); - pool.pagetable[pn..pn+npages] = B_FREE; + pool.pagetable[pn..pn+npages] = Bins.B_FREE; if (pn < pool.searchStart) pool.searchStart = pn; freedLargePages += npages; pool.freepages += npages; @@ -2671,7 +2668,7 @@ struct Gcx { Bins bin = cast(Bins)pool.pagetable[pn]; - if (bin < B_PAGE) + if (bin < Bins.B_PAGE) { auto freebitsdata = pool.freebits.data + pn * PageBits.length; auto markdata = pool.mark.data + pn * PageBits.length; @@ -2767,7 +2764,7 @@ struct Gcx { pool.freeAllPageBits(pn); - pool.pagetable[pn] = B_FREE; + pool.pagetable[pn] = Bins.B_FREE; // add to free chain pool.binPageChain[pn] = cast(uint) pool.searchStart; pool.searchStart = pn; @@ -2789,7 +2786,8 @@ struct Gcx assert(freedLargePages <= usedLargePages); usedLargePages -= freedLargePages; - debug(COLLECT_PRINTF) printf("\tfree'd %u bytes, %u pages from %u pools\n", freed, freedLargePages, npools); + debug(COLLECT_PRINTF) printf("\tfree'd %u bytes, %u pages from %u pools\n", + freed, freedLargePages, this.pooltable.length); assert(freedSmallPages <= usedSmallPages); usedSmallPages -= freedSmallPages; @@ -2854,12 +2852,12 @@ struct Gcx private SmallObjectPool* setNextRecoverPool(Bins bin, size_t poolIndex) nothrow { Pool* pool; - while (poolIndex < npools && - ((pool = pooltable[poolIndex]).isLargeObject || + while (poolIndex < this.pooltable.length && + ((pool = this.pooltable[poolIndex]).isLargeObject || pool.recoverPageFirst[bin] >= pool.npages)) poolIndex++; - return recoverPool[bin] = poolIndex < npools ? cast(SmallObjectPool*)pool : null; + return recoverPool[bin] = poolIndex < this.pooltable.length ? cast(SmallObjectPool*)pool : null; } version (COLLECT_FORK) @@ -2928,7 +2926,6 @@ struct Gcx import core.stdc.stdlib : _Exit; debug (PRINTF_TO_FILE) { - import core.stdc.stdio : fflush; fflush(null); // avoid duplicated FILE* output } version (OSX) @@ -2938,19 +2935,18 @@ struct Gcx else version (linux) { // clone() fits better as we don't want to do anything but scanning in the child process. - // no fork-handlera are called, so we can avoid deadlocks due to malloc locks. Probably related: + // no fork-handlers are called, so we can avoid deadlocks due to malloc locks. Probably related: // https://sourceware.org/bugzilla/show_bug.cgi?id=4737 import core.sys.linux.sched : clone; import core.sys.posix.signal : SIGCHLD; - enum CLONE_CHILD_CLEARTID = 0x00200000; /* Register exit futex and memory */ - const flags = CLONE_CHILD_CLEARTID | SIGCHLD; // child thread id not needed + const flags = SIGCHLD; // exit signal scope int delegate() scope dg = &child_mark; extern(C) static int wrap_delegate(void* arg) { auto dg = cast(int delegate() scope*)arg; return (*dg)(); } - char[256] stackbuf; // enough stack space for clone() to place some info for the child without stomping the parent stack + ubyte[256] stackbuf; // enough stack space for clone() to place some info for the child without stomping the parent stack auto stack = stackbuf.ptr + (isStackGrowingDown ? stackbuf.length : 0); auto pid = clone(&wrap_delegate, stack, flags, &dg); } @@ -2960,7 +2956,6 @@ struct Gcx auto pid = fork(); fork_needs_lock = true; } - assert(pid != -1); switch (pid) { case -1: // fork() failed, retry without forking @@ -3031,7 +3026,7 @@ struct Gcx //printf("\tpool address range = %p .. %p\n", minAddr, maxAddr); version (COLLECT_FORK) - bool doFork = shouldFork; + alias doFork = shouldFork; else enum doFork = false; @@ -3086,6 +3081,7 @@ Lmark: final switch (forkResult) { case ChildStatus.error: + // fork() failed, retry without forking disableFork(); goto Lmark; case ChildStatus.running: @@ -3153,7 +3149,7 @@ Lmark: // init bucket lists bucket[] = null; - foreach (Bins bin; 0..B_NUMSMALL) + foreach (Bins bin; Bins.B_16 .. Bins.B_NUMSMALL) setNextRecoverPool(bin, 0); stop = currTime; @@ -3188,24 +3184,24 @@ Lmark: auto pn = offset / PAGESIZE; auto bins = cast(Bins)pool.pagetable[pn]; size_t biti = void; - if (bins < B_PAGE) + if (bins < Bins.B_PAGE) { biti = baseOffset(offset, bins) >> pool.ShiftBy.Small; // doesn't need to check freebits because no pointer must exist // to a block that was free before starting the collection } - else if (bins == B_PAGE) + else if (bins == Bins.B_PAGE) { biti = pn * (PAGESIZE >> pool.ShiftBy.Large); } - else if (bins == B_PAGEPLUS) + else if (bins == Bins.B_PAGEPLUS) { pn -= pool.bPageOffsets[pn]; biti = pn * (PAGESIZE >> pool.ShiftBy.Large); } - else // bins == B_FREE + else // bins == Bins.B_FREE { - assert(bins == B_FREE); + assert(bins == Bins.B_FREE); return IsMarked.no; } return pool.mark.test(biti) ? IsMarked.yes : IsMarked.no; @@ -3262,8 +3258,11 @@ Lmark: /* ============================ Parallel scanning =============================== */ version (COLLECT_PARALLEL): - import core.sync.event; + import core.atomic; + import core.cpuid; + import core.sync.event; + private: // disable invariants for background threads static struct ScanThreadData @@ -3334,7 +3333,6 @@ Lmark: int maxParallelThreads() nothrow { - import core.cpuid; auto threads = threadsPerCPU(); if (threads == 0) @@ -3512,7 +3510,7 @@ struct Pool GCBits is_pointer; // precise GC only: per-word, not per-block like the rest of them (SmallObjectPool only) size_t npages; size_t freepages; // The number of pages not in use. - ubyte* pagetable; + Bins* pagetable; bool isLargeObject; @@ -3541,7 +3539,7 @@ struct Pool enum PageRecovered = uint.max; // first of chain of pages to recover (SmallObjectPool only) - uint[B_NUMSMALL] recoverPageFirst; + uint[Bins.B_NUMSMALL] recoverPageFirst; // precise GC: TypeInfo.rtInfo for allocation (LargeObjectPool only) immutable(size_t)** rtinfo; @@ -3611,7 +3609,7 @@ struct Pool noscan.alloc(nbits); appendable.alloc(nbits); - pagetable = cast(ubyte*)cstdlib.malloc(npages); + pagetable = cast(Bins*)cstdlib.malloc(npages * Bins.sizeof); if (!pagetable) onOutOfMemoryErrorNoGC(); @@ -3635,7 +3633,7 @@ struct Pool } } - memset(pagetable, B_FREE, npages); + memset(pagetable, Bins.B_FREE, npages); this.npages = npages; this.freepages = npages; @@ -3852,7 +3850,7 @@ struct Pool } public - @property bool isFree() const pure nothrow + @property bool isFree() const scope @safe pure nothrow @nogc { return npages == freepages; } @@ -3883,10 +3881,10 @@ struct Pool { size_t offset = cast(size_t)(p - baseAddr); size_t pn = offset / PAGESIZE; - Bins bin = cast(Bins)pagetable[pn]; + Bins bin = pagetable[pn]; // Adjust bit to be at start of allocated memory block - if (bin < B_NUMSMALL) + if (bin < Bins.B_NUMSMALL) { auto baseOff = baseOffset(offset, bin); const biti = baseOff >> Pool.ShiftBy.Small; @@ -3894,11 +3892,11 @@ struct Pool return null; return baseAddr + baseOff; } - if (bin == B_PAGE) + if (bin == Bins.B_PAGE) { return baseAddr + (offset & (offset.max ^ (PAGESIZE-1))); } - if (bin == B_PAGEPLUS) + if (bin == Bins.B_PAGEPLUS) { size_t pageOffset = bPageOffsets[pn]; offset -= pageOffset * PAGESIZE; @@ -3907,7 +3905,7 @@ struct Pool return baseAddr + (offset & (offset.max ^ (PAGESIZE-1))); } // we are in a B_FREE page - assert(bin == B_FREE); + assert(bin == Bins.B_FREE); return null; } @@ -3944,8 +3942,8 @@ struct Pool { for (size_t i = 0; i < npages; i++) { - Bins bin = cast(Bins)pagetable[i]; - assert(bin < B_MAX); + Bins bin = pagetable[i]; + assert(bin < Bins.B_MAX); } } } @@ -4053,19 +4051,19 @@ struct LargeObjectPool uint np = bPageOffsets[n]; assert(np > 0 && np <= npages - n); - if (pagetable[n] == B_PAGE) + if (pagetable[n] == Bins.B_PAGE) { for (uint p = 1; p < np; p++) { - assert(pagetable[n + p] == B_PAGEPLUS); + assert(pagetable[n + p] == Bins.B_PAGEPLUS); assert(bPageOffsets[n + p] == p); } } - else if (pagetable[n] == B_FREE) + else if (pagetable[n] == Bins.B_FREE) { for (uint p = 1; p < np; p++) { - assert(pagetable[n + p] == B_FREE); + assert(pagetable[n + p] == Bins.B_FREE); } assert(bPageOffsets[n + np - 1] == np); } @@ -4086,17 +4084,17 @@ struct LargeObjectPool //debug(PRINTF) printf("Pool::allocPages(n = %d)\n", n); size_t largest = 0; - if (pagetable[searchStart] == B_PAGEPLUS) + if (pagetable[searchStart] == Bins.B_PAGEPLUS) { searchStart -= bPageOffsets[searchStart]; // jump to B_PAGE searchStart += bPageOffsets[searchStart]; } - while (searchStart < npages && pagetable[searchStart] == B_PAGE) + while (searchStart < npages && pagetable[searchStart] == Bins.B_PAGE) searchStart += bPageOffsets[searchStart]; for (size_t i = searchStart; i < npages; ) { - assert(pagetable[i] == B_FREE); + assert(pagetable[i] == Bins.B_FREE); auto p = bPageOffsets[i]; if (p > n) @@ -4107,11 +4105,11 @@ struct LargeObjectPool if (p == n) { L_found: - pagetable[i] = B_PAGE; + pagetable[i] = Bins.B_PAGE; bPageOffsets[i] = cast(uint) n; if (n > 1) { - memset(&pagetable[i + 1], B_PAGEPLUS, n - 1); + memset(&pagetable[i + 1], Bins.B_PAGEPLUS, n - 1); for (auto offset = 1; offset < n; offset++) bPageOffsets[i + offset] = cast(uint) offset; } @@ -4122,7 +4120,7 @@ struct LargeObjectPool largest = p; i += p; - while (i < npages && pagetable[i] == B_PAGE) + while (i < npages && pagetable[i] == Bins.B_PAGE) { // we have the size information, so we skip a whole bunch of pages. i += bPageOffsets[i]; @@ -4145,8 +4143,8 @@ struct LargeObjectPool for (size_t i = pagenum; i < npages + pagenum; i++) { - assert(pagetable[i] < B_FREE); - pagetable[i] = B_FREE; + assert(pagetable[i] < Bins.B_FREE); + pagetable[i] = Bins.B_FREE; } freepages += npages; largestFree = freepages; // invalidate @@ -4157,8 +4155,8 @@ struct LargeObjectPool */ void setFreePageOffsets(size_t page, size_t num) nothrow @nogc { - assert(pagetable[page] == B_FREE); - assert(pagetable[page + num - 1] == B_FREE); + assert(pagetable[page] == Bins.B_FREE); + assert(pagetable[page + num - 1] == Bins.B_FREE); bPageOffsets[page] = cast(uint)num; if (num > 1) bPageOffsets[page + num - 1] = cast(uint)num; @@ -4168,7 +4166,7 @@ struct LargeObjectPool { static if (bwd) { - if (page > 0 && pagetable[page - 1] == B_FREE) + if (page > 0 && pagetable[page - 1] == Bins.B_FREE) { auto sz = bPageOffsets[page - 1]; page -= sz; @@ -4177,7 +4175,7 @@ struct LargeObjectPool } static if (fwd) { - if (page + num < npages && pagetable[page + num] == B_FREE) + if (page + num < npages && pagetable[page + num] == Bins.B_FREE) num += bPageOffsets[page + num]; } setFreePageOffsets(page, num); @@ -4197,8 +4195,8 @@ struct LargeObjectPool if (cast(size_t)p & (PAGESIZE - 1)) // check for interior pointer return 0; size_t pagenum = pagenumOf(p); - Bins bin = cast(Bins)pagetable[pagenum]; - if (bin != B_PAGE) + Bins bin = pagetable[pagenum]; + if (bin != Bins.B_PAGE) return 0; return bPageOffsets[pagenum]; } @@ -4208,7 +4206,7 @@ struct LargeObjectPool */ size_t getSize(size_t pn) const nothrow @nogc { - assert(pagetable[pn] == B_PAGE); + assert(pagetable[pn] == Bins.B_PAGE); return cast(size_t) bPageOffsets[pn] * PAGESIZE; } @@ -4221,11 +4219,11 @@ struct LargeObjectPool size_t offset = cast(size_t)(p - baseAddr); size_t pn = offset / PAGESIZE; - Bins bin = cast(Bins)pagetable[pn]; + Bins bin = pagetable[pn]; - if (bin == B_PAGEPLUS) + if (bin == Bins.B_PAGEPLUS) pn -= bPageOffsets[pn]; - else if (bin != B_PAGE) + else if (bin != Bins.B_PAGE) return info; // no info for free pages info.base = baseAddr + pn * PAGESIZE; @@ -4238,8 +4236,8 @@ struct LargeObjectPool { foreach (pn; 0 .. npages) { - Bins bin = cast(Bins)pagetable[pn]; - if (bin > B_PAGE) + Bins bin = pagetable[pn]; + if (bin > Bins.B_PAGE) continue; size_t biti = pn; @@ -4265,7 +4263,7 @@ struct LargeObjectPool size_t n = 1; for (; pn + n < npages; ++n) - if (pagetable[pn + n] != B_PAGEPLUS) + if (pagetable[pn + n] != Bins.B_PAGEPLUS) break; debug (MEMSTOMP) memset(baseAddr + pn * PAGESIZE, 0xF3, n * PAGESIZE); freePages(pn, n); @@ -4285,7 +4283,7 @@ struct SmallObjectPool { //base.Invariant(); uint cntRecover = 0; - foreach (Bins bin; 0 .. B_NUMSMALL) + foreach (Bins bin; Bins.B_16 .. Bins.B_NUMSMALL) { for (auto pn = recoverPageFirst[bin]; pn < npages; pn = binPageChain[pn]) { @@ -4296,7 +4294,7 @@ struct SmallObjectPool uint cntFree = 0; for (auto pn = searchStart; pn < npages; pn = binPageChain[pn]) { - assert(pagetable[pn] == B_FREE); + assert(pagetable[pn] == Bins.B_FREE); cntFree++; } assert(cntFree == freepages); @@ -4315,8 +4313,8 @@ struct SmallObjectPool do { size_t pagenum = pagenumOf(p); - Bins bin = cast(Bins)pagetable[pagenum]; - assert(bin < B_PAGE); + Bins bin = pagetable[pagenum]; + assert(bin < Bins.B_PAGE); if (p != cast(void*)baseOffset(cast(size_t)p, bin)) // check for interior pointer return 0; const biti = cast(size_t)(p - baseAddr) >> ShiftBy.Small; @@ -4330,9 +4328,9 @@ struct SmallObjectPool BlkInfo info; size_t offset = cast(size_t)(p - baseAddr); size_t pn = offset / PAGESIZE; - Bins bin = cast(Bins)pagetable[pn]; + Bins bin = pagetable[pn]; - if (bin >= B_PAGE) + if (bin >= Bins.B_PAGE) return info; auto base = cast(void*)baseOffset(cast(size_t)p, bin); @@ -4352,8 +4350,8 @@ struct SmallObjectPool { foreach (pn; 0 .. npages) { - Bins bin = cast(Bins)pagetable[pn]; - if (bin >= B_PAGE) + Bins bin = pagetable[pn]; + if (bin >= Bins.B_PAGE) continue; immutable size = binsize[bin]; @@ -4404,13 +4402,13 @@ struct SmallObjectPool if (searchStart >= npages) return null; - assert(pagetable[searchStart] == B_FREE); + assert(pagetable[searchStart] == Bins.B_FREE); L1: size_t pn = searchStart; searchStart = binPageChain[searchStart]; binPageChain[pn] = Pool.PageRecovered; - pagetable[pn] = cast(ubyte)bin; + pagetable[pn] = bin; freepages--; // Convert page to free list @@ -4537,7 +4535,7 @@ debug(PRINTF) void printFreeInfo(Pool* pool) nothrow { uint nReallyFree; foreach (i; 0..pool.npages) { - if (pool.pagetable[i] >= B_FREE) nReallyFree++; + if (pool.pagetable[i] >= Bins.B_FREE) nReallyFree++; } printf("Pool %p: %d really free, %d supposedly free\n", pool, nReallyFree, pool.freepages); @@ -4770,7 +4768,7 @@ debug (LOGGING) size_t offset = cast(size_t)(p - pool.baseAddr); size_t biti; size_t pn = offset / PAGESIZE; - Bins bin = cast(Bins)pool.pagetable[pn]; + Bins bin = pool.pagetable[pn]; biti = (offset & (PAGESIZE - 1)) >> pool.shiftBy; debug(PRINTF) printf("\tbin = %d, offset = x%x, biti = x%x\n", bin, offset, biti); } @@ -4921,7 +4919,7 @@ unittest assert(p + (260 << 20) == q); assert(q + (65 << 20) == r); GC.free(q); - // should trigger "assert(bin == B_FREE);" in mark due to dangling pointer q: + // should trigger "assert(bin == Bins.B_FREE);" in mark due to dangling pointer q: GC.collect(); // should trigger "break;" in extendNoSync: size_t sz = GC.extend(p, 64 << 20, 66 << 20); // trigger size after p large enough (but limited) diff --git a/libphobos/libdruntime/core/internal/gc/pooltable.d b/libphobos/libdruntime/core/internal/gc/pooltable.d index 5924f9c..0966338 100644 --- a/libphobos/libdruntime/core/internal/gc/pooltable.d +++ b/libphobos/libdruntime/core/internal/gc/pooltable.d @@ -13,15 +13,14 @@ struct PoolTable(Pool) { import core.stdc.string : memmove; -nothrow: - void Dtor() + void Dtor() nothrow @nogc { cstdlib.free(pools); pools = null; npools = 0; } - bool insert(Pool* pool) + bool insert(Pool* pool) nothrow @nogc { auto newpools = cast(Pool **)cstdlib.realloc(pools, (npools + 1) * pools[0].sizeof); if (!newpools) @@ -51,25 +50,31 @@ nothrow: return true; } - @property size_t length() pure const + @property size_t length() const scope @safe pure nothrow @nogc { return npools; } - ref inout(Pool*) opIndex(size_t idx) inout pure + ref inout(Pool*) opIndex(size_t idx) inout return @trusted pure nothrow @nogc in { assert(idx < length); } do { return pools[idx]; } - inout(Pool*)[] opSlice(size_t a, size_t b) inout pure + inout(Pool*)[] opSlice(size_t a, size_t b) inout return @trusted pure nothrow @nogc in { assert(a <= length && b <= length); } do { return pools[a .. b]; } + /// Returns: A slice over all pools in this `PoolTable` + inout(Pool*)[] opSlice() inout return @trusted pure nothrow @nogc + { + return this.pools[0 .. this.length]; + } + alias opDollar = length; /** @@ -77,7 +82,7 @@ nothrow: * Return null if not in a Pool. * Assume pooltable[] is sorted. */ - Pool *findPool(void *p) nothrow + Pool *findPool(void *p) nothrow @nogc { if (p >= minAddr && p < maxAddr) { @@ -109,7 +114,7 @@ nothrow: } // semi-stable partition, returns right half for which pred is false - Pool*[] minimize() pure + Pool*[] minimize() pure nothrow @nogc { static void swap(ref Pool* a, ref Pool* b) { @@ -151,7 +156,7 @@ nothrow: return pools[npools .. len]; } - void Invariant() const + void Invariant() const nothrow @nogc { if (!npools) return; @@ -165,8 +170,8 @@ nothrow: assert(_maxAddr == pools[npools - 1].topAddr); } - @property const(void)* minAddr() pure const { return _minAddr; } - @property const(void)* maxAddr() pure const { return _maxAddr; } + @property const(void)* minAddr() const @safe pure nothrow @nogc { return _minAddr; } + @property const(void)* maxAddr() const @safe pure nothrow @nogc { return _maxAddr; } package: Pool** pools; @@ -184,7 +189,7 @@ unittest { byte* baseAddr, topAddr; size_t freepages, npages, ptIndex; - @property bool isFree() const pure nothrow { return freepages == npages; } + @property bool isFree() const scope pure nothrow @nogc { return freepages == npages; } } PoolTable!MockPool pooltable; diff --git a/libphobos/libdruntime/core/internal/gc/proxy.d b/libphobos/libdruntime/core/internal/gc/proxy.d index 2c89472..695ef06 100644 --- a/libphobos/libdruntime/core/internal/gc/proxy.d +++ b/libphobos/libdruntime/core/internal/gc/proxy.d @@ -209,12 +209,12 @@ extern (C) return instance.query( p ); } - core.memory.GC.Stats gc_stats() nothrow + core.memory.GC.Stats gc_stats() @safe nothrow @nogc { return instance.stats(); } - core.memory.GC.ProfileStats gc_profileStats() nothrow @safe + core.memory.GC.ProfileStats gc_profileStats() @safe nothrow @nogc { return instance.profileStats(); } diff --git a/libphobos/libdruntime/core/internal/parseoptions.d b/libphobos/libdruntime/core/internal/parseoptions.d index 9920443..ed6251f 100644 --- a/libphobos/libdruntime/core/internal/parseoptions.d +++ b/libphobos/libdruntime/core/internal/parseoptions.d @@ -168,6 +168,7 @@ inout(char)[] find(alias pred)(inout(char)[] str) } bool parse(T : size_t)(const(char)[] optname, ref inout(char)[] str, ref T res, const(char)[] errName, bool mayHaveSuffix = false) +if (is(T == size_t)) in { assert(str.length); } do { @@ -242,6 +243,22 @@ do if (v > res.max) return parseError("a number " ~ T.max.stringof ~ " or below", optname, str[0 .. i], errName); str = str[i .. $]; + res = v; + return true; +} + +bool parse(T : size_t)(const(char)[] optname, ref inout(char)[] str, ref T res, const(char)[] errName, bool mayHaveSuffix = false) +if (!is(T == size_t)) +in { assert(str.length); } +do +{ + const oldStr = str; + size_t v; + if (!parse!size_t(optname, str, v, errName, mayHaveSuffix)) + return false; + + if (v > res.max) + return parseError("a number " ~ T.max.stringof ~ " or below", optname, oldStr[0 .. $-str.length], errName); res = cast(T) v; return true; } diff --git a/libphobos/libdruntime/core/internal/traits.d b/libphobos/libdruntime/core/internal/traits.d index 0d733f2..0b4890c 100644 --- a/libphobos/libdruntime/core/internal/traits.d +++ b/libphobos/libdruntime/core/internal/traits.d @@ -234,7 +234,7 @@ if (Ts.length > 0) template classInstanceAlignment(T) if (is(T == class)) { - alias classInstanceAlignment = maxAlignment!(void*, typeof(T.tupleof)); + enum classInstanceAlignment = __traits(classInstanceAlignment, T); } /// See $(REF hasElaborateMove, std,traits) diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d index 091269a..371308d 100644 --- a/libphobos/libdruntime/core/lifetime.d +++ b/libphobos/libdruntime/core/lifetime.d @@ -200,12 +200,10 @@ Returns: The newly constructed object. T emplace(T, Args...)(void[] chunk, auto ref Args args) if (is(T == class)) { - import core.internal.traits : maxAlignment; - enum classSize = __traits(classInstanceSize, T); assert(chunk.length >= classSize, "chunk size too small."); - enum alignment = maxAlignment!(void*, typeof(T.tupleof)); + enum alignment = __traits(classInstanceAlignment, T); assert((cast(size_t) chunk.ptr) % alignment == 0, "chunk is not aligned."); return emplace!T(cast(T)(chunk.ptr), forward!args); @@ -242,9 +240,7 @@ T emplace(T, Args...)(void[] chunk, auto ref Args args) int virtualGetI() { return i; } } - import core.internal.traits : classInstanceAlignment; - - align(classInstanceAlignment!C) byte[__traits(classInstanceSize, C)] buffer; + align(__traits(classInstanceAlignment, C)) byte[__traits(classInstanceSize, C)] buffer; C c = emplace!C(buffer[], 42); assert(c.virtualGetI() == 42); } @@ -290,7 +286,8 @@ T emplace(T, Args...)(void[] chunk, auto ref Args args) } int var = 6; - align(__conv_EmplaceTestClass.alignof) ubyte[__traits(classInstanceSize, __conv_EmplaceTestClass)] buf; + align(__traits(classInstanceAlignment, __conv_EmplaceTestClass)) + ubyte[__traits(classInstanceSize, __conv_EmplaceTestClass)] buf; auto support = (() @trusted => cast(__conv_EmplaceTestClass)(buf.ptr))(); auto fromRval = emplace!__conv_EmplaceTestClass(support, 1); @@ -1198,7 +1195,7 @@ pure nothrow @safe /* @nogc */ unittest } void[] buf; - static align(A.alignof) byte[__traits(classInstanceSize, A)] sbuf; + static align(__traits(classInstanceAlignment, A)) byte[__traits(classInstanceSize, A)] sbuf; buf = sbuf[]; auto a = emplace!A(buf, 55); assert(a.x == 55 && a.y == 55); @@ -1273,7 +1270,9 @@ void copyEmplace(S, T)(ref S source, ref T target) @system } else static if (__traits(hasCopyConstructor, T)) { - emplace(cast(Unqual!(T)*) &target); // blit T.init + // https://issues.dlang.org/show_bug.cgi?id=22766 + import core.internal.lifetime : emplaceInitializer; + emplaceInitializer(*(cast(Unqual!T*)&target)); static if (__traits(isNested, T)) { // copy context pointer @@ -1373,6 +1372,22 @@ void copyEmplace(S, T)(ref S source, ref T target) @system static assert(!__traits(compiles, copyEmplace(ss, t))); } +// https://issues.dlang.org/show_bug.cgi?id=22766 +@system pure nothrow @nogc unittest +{ + static struct S + { + @disable this(); + this(int) @safe pure nothrow @nogc{} + this(ref const(S) other) @safe pure nothrow @nogc {} + } + + S s1 = S(1); + S s2 = void; + copyEmplace(s1, s2); + assert(s2 == S(1)); +} + version (DigitalMars) version (X86) version (Posix) version = DMD_X86_Posix; // don't violate immutability for reference types @@ -2633,22 +2648,25 @@ if (!Init.length || } /** - * Allocate an exception of type `T` from the exception pool and call its constructor. - * It has the same interface as `rt.lifetime._d_newclass()`. - * `T` must be Throwable or derived from it, must declare an explicit ctor - * and cannot be a COM or C++ class. + * Allocate an exception of type `T` from the exception pool. + * `T` must be `Throwable` or derived from it and cannot be a COM or C++ class. + * + * Note: + * This function does not call the constructor of `T` because that would require + * `forward!args`, which causes errors with -dip1008. This inconvenience will be + * removed once -dip1008 works as intended. + * * Returns: - * constructed instance of the type + * allocated instance of type `T` */ -T _d_newThrowable(T, Args...)(auto ref Args args) @trusted - if (is(T : Throwable) && is(typeof(T.__ctor(forward!args))) && - __traits(getLinkage, T) == "D") +T _d_newThrowable(T)() @trusted + if (is(T : Throwable) && __traits(getLinkage, T) == "D") { debug(PRINTF) printf("_d_newThrowable(%s)\n", cast(char*) T.stringof); - import core.stdc.stdlib : malloc; + import core.memory : pureMalloc; auto init = __traits(initSymbol, T); - void* p = malloc(init.length); + void* p = pureMalloc(init.length); if (!p) { import core.exception : onOutOfMemoryError; @@ -2672,33 +2690,22 @@ T _d_newThrowable(T, Args...)(auto ref Args args) @trusted (cast(Throwable) p).refcount() = 1; - auto t = cast(T) p; - t.__ctor(forward!args); - - return t; + return cast(T) p; } @system unittest { class E : Exception { - int x; - - this(int x, string msg = "", Throwable nextInChain = null) + this(string msg = "", Throwable nextInChain = null) { super(msg, nextInChain); - this.x = x; } } - auto exc = _d_newThrowable!Exception("Exception"); - assert(exc.refcount() == 1); - assert(exc.msg == "Exception"); - - static assert(!__traits(compiles, _d_newThrowable!E())); + Throwable exc = _d_newThrowable!Exception(); + Throwable e = _d_newThrowable!E(); - auto e = _d_newThrowable!E(42, "E", null); + assert(exc.refcount() == 1); assert(e.refcount() == 1); - assert(e.x == 42); - assert(e.msg == "E"); } diff --git a/libphobos/libdruntime/core/math.d b/libphobos/libdruntime/core/math.d index 4d46b67..30fc130 100644 --- a/libphobos/libdruntime/core/math.d +++ b/libphobos/libdruntime/core/math.d @@ -36,6 +36,7 @@ nothrow: * greater than long.max, the result is * indeterminate. */ +deprecated("rndtonl is to be removed by 2.100. Please use round instead") extern (C) real rndtonl(real x); pure: diff --git a/libphobos/libdruntime/core/memory.d b/libphobos/libdruntime/core/memory.d index 6ba569a..7d1356a 100644 --- a/libphobos/libdruntime/core/memory.d +++ b/libphobos/libdruntime/core/memory.d @@ -31,14 +31,14 @@ $(LI Maintain another reference to that same data in another thread that the GC does know about.) $(LI Disable GC collection cycles while that thread is active with $(LREF disable)/$(LREF enable).) - $(LI Register the thread with the GC using $(REF thread_attachThis, core,thread)/$(REF thread_detachThis, core,thread).) + $(LI Register the thread with the GC using $(REF thread_attachThis, core,thread,osthread)/$(REF thread_detachThis, core,thread,threadbase).) ) ) ) * * Notes_to_implementors: * $(UL - * $(LI On POSIX systems, the signals SIGUSR1 and SIGUSR2 are reserved + * $(LI On POSIX systems, the signals `SIGRTMIN` and `SIGRTMIN + 1` are reserved * by this module for use in the garbage collector implementation. * Typically, they will be used to stop and resume other threads * when performing a collection, but an implementation may choose @@ -133,7 +133,7 @@ private } extern (C) BlkInfo_ gc_query(return scope void* p) pure nothrow; - extern (C) GC.Stats gc_stats ( ) nothrow @nogc; + extern (C) GC.Stats gc_stats ( ) @safe nothrow @nogc; extern (C) GC.ProfileStats gc_profileStats ( ) nothrow @nogc @safe; } @@ -766,7 +766,7 @@ extern(D): * Returns runtime stats for currently active GC implementation * See `core.memory.GC.Stats` for list of available metrics. */ - static Stats stats() nothrow + static Stats stats() @safe nothrow @nogc { return gc_stats(); } @@ -1229,7 +1229,10 @@ void __delete(T)(ref T x) @system else static if (is(T == U*, U)) { static if (is(U == struct)) - _destructRecurse(*x); + { + if (x) + _destructRecurse(*x); + } } else static if (is(T : E[], E)) { @@ -1334,6 +1337,10 @@ unittest assert(a is null); assert(dtorCalled); assert(GC.addrOf(cast(void*) a) == null); + + // https://issues.dlang.org/show_bug.cgi?id=22779 + A *aptr; + __delete(aptr); } /// Deleting arrays diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d index 81d2d26..d1378af 100644 --- a/libphobos/libdruntime/core/runtime.d +++ b/libphobos/libdruntime/core/runtime.d @@ -285,7 +285,7 @@ struct Runtime * an appropriate calling context from which to begin the trace. * * Params: - * h = The new trace handler. Set to null to use the default handler. + * h = The new trace handler. Set to null to disable exception backtracing. */ extern(C) pragma(mangle, "rt_setTraceHandler") static @property void traceHandler(TraceHandler h); diff --git a/libphobos/libdruntime/core/simd.d b/libphobos/libdruntime/core/simd.d index 11a4711..f1bf59b 100644 --- a/libphobos/libdruntime/core/simd.d +++ b/libphobos/libdruntime/core/simd.d @@ -409,6 +409,28 @@ version (D_SIMD) * op2 = second operand * Returns: * result of opcode + * Example: + --- + import core.simd; + import core.stdc.stdio; + + void main() + { + float4 A = [2.34f, -70000.0f, 0.00001f, 345.5f]; + float4 R = A; + R = cast(float4) __simd(XMM.RCPSS, R, A); + printf("%g %g %g %g\n", R.array[0], R.array[1], R.array[2], R.array[3]); + } + --- + * Prints `0.427368 -70000 1e-05 345.5`. + * The use of the two operand form for `XMM.RCPSS` is necessary because the result of the instruction + * contains elements of both operands. + * Example: + --- + double[2] A = [56.0, -75.0]; + double2 R = cast(double2) __simd(XMM.LODUPD, *cast(double2*)A.ptr); + --- + * The cast to `double2*` is necessary because the type of `*A.ptr` is `double`. */ pure @safe void16 __simd(XMM opcode, void16 op1, void16 op2); @@ -480,6 +502,7 @@ version (D_SIMD) /***** * For "store" operations of the form: * op1 op= op2 + * such as MOVLPS. * Returns: * op2 * These cannot be marked as pure, as semantic() doesn't check them. @@ -487,6 +510,7 @@ version (D_SIMD) @safe void16 __simd_sto(XMM opcode, void16 op1, void16 op2); @safe void16 __simd_sto(XMM opcode, double op1, void16 op2); /// @safe void16 __simd_sto(XMM opcode, float op1, void16 op2); /// + @safe void16 __simd_sto(XMM opcode, void16 op1, long op2); /// /// unittest diff --git a/libphobos/libdruntime/core/stdc/config.d b/libphobos/libdruntime/core/stdc/config.d index 44bb707..c576e99 100644 --- a/libphobos/libdruntime/core/stdc/config.d +++ b/libphobos/libdruntime/core/stdc/config.d @@ -34,7 +34,7 @@ version (StdDdoc) alias ddoc_long = int; alias ddoc_ulong = uint; } - struct ddoc_complex(T) { T re; T im; }; + struct ddoc_complex(T) { T re; T im; } } /*** @@ -185,6 +185,37 @@ else version (Posix) alias ulong cpp_ulonglong; } } +else version (WASI) +{ + static if ( (void*).sizeof > int.sizeof ) + { + enum __c_longlong : long; + enum __c_ulonglong : ulong; + + alias long c_long; + alias ulong c_ulong; + + alias long cpp_long; + alias ulong cpp_ulong; + + alias __c_longlong cpp_longlong; + alias __c_ulonglong cpp_ulonglong; + } + else + { + enum __c_long : int; + enum __c_ulong : uint; + + alias int c_long; + alias uint c_ulong; + + alias __c_long cpp_long; + alias __c_ulong cpp_ulong; + + alias long cpp_longlong; + alias ulong cpp_ulonglong; + } +} version (GNU) alias c_long_double = real; diff --git a/libphobos/libdruntime/core/stdc/errno.d b/libphobos/libdruntime/core/stdc/errno.d index 57bc15d..24b4138 100644 --- a/libphobos/libdruntime/core/stdc/errno.d +++ b/libphobos/libdruntime/core/stdc/errno.d @@ -2079,6 +2079,143 @@ else version (Haiku) enum B_NO_TRANSLATOR = (B_TRANSLATION_ERROR_BASE + 1); enum B_ILLEGAL_DATA = (B_TRANSLATION_ERROR_BASE + 2); } +else version (WASI) +{ + enum EPERM = 1; + enum ENOENT = 2; + enum ESRCH = 3; + enum EINTR = 4; + enum EIO = 5; + enum ENXIO = 6; + enum E2BIG = 7; + enum ENOEXEC = 8; + enum EBADF = 9; + enum ECHILD = 10; + enum EAGAIN = 11; + enum ENOMEM = 12; + enum EACCES = 13; + enum EFAULT = 14; + enum ENOTBLK = 15; + enum EBUSY = 16; + enum EEXIST = 17; + enum EXDEV = 18; + enum ENODEV = 19; + enum ENOTDIR = 20; + enum EISDIR = 21; + enum EINVAL = 22; + enum ENFILE = 23; + enum EMFILE = 24; + enum ENOTTY = 25; + enum ETXTBSY = 26; + enum EFBIG = 27; + enum ENOSPC = 28; + enum ESPIPE = 29; + enum EROFS = 30; + enum EMLINK = 31; + enum EPIPE = 32; + enum EDOM = 33; + enum ERANGE = 34; + enum EDEADLK = 35; + enum ENAMETOOLONG = 36; + enum ENOLCK = 37; + enum ENOSYS = 38; + enum ENOTEMPTY = 39; + enum ELOOP = 40; + enum EWOULDBLOCK = EAGAIN; + enum ENOMSG = 42; + enum EIDRM = 43; + enum ECHRNG = 44; + enum EL2NSYNC = 45; + enum EL3HLT = 46; + enum EL3RST = 47; + enum ELNRNG = 48; + enum EUNATCH = 49; + enum ENOCSI = 50; + enum EL2HLT = 51; + enum EBADE = 52; + enum EBADR = 53; + enum EXFULL = 54; + enum ENOANO = 55; + enum EBADRQC = 56; + enum EBADSLT = 57; + enum EDEADLOCK = EDEADLK; + enum EBFONT = 59; + enum ENOSTR = 60; + enum ENODATA = 61; + enum ETIME = 62; + enum ENOSR = 63; + enum ENONET = 64; + enum ENOPKG = 65; + enum EREMOTE = 66; + enum ENOLINK = 67; + enum EADV = 68; + enum ESRMNT = 69; + enum ECOMM = 70; + enum EPROTO = 71; + enum EMULTIHOP = 72; + enum EDOTDOT = 73; + enum EBADMSG = 74; + enum EOVERFLOW = 75; + enum ENOTUNIQ = 76; + enum EBADFD = 77; + enum EREMCHG = 78; + enum ELIBACC = 79; + enum ELIBBAD = 80; + enum ELIBSCN = 81; + enum ELIBMAX = 82; + enum ELIBEXEC = 83; + enum EILSEQ = 84; + enum ERESTART = 85; + enum ESTRPIPE = 86; + enum EUSERS = 87; + enum ENOTSOCK = 88; + enum EDESTADDRREQ = 89; + enum EMSGSIZE = 90; + enum EPROTOTYPE = 91; + enum ENOPROTOOPT = 92; + enum EPROTONOSUPPORT = 93; + enum ESOCKTNOSUPPORT = 94; + enum EOPNOTSUPP = 95; + enum ENOTSUP = EOPNOTSUPP; + enum EPFNOSUPPORT = 96; + enum EAFNOSUPPORT = 97; + enum EADDRINUSE = 98; + enum EADDRNOTAVAIL = 99; + enum ENETDOWN = 100; + enum ENETUNREACH = 101; + enum ENETRESET = 102; + enum ECONNABORTED = 103; + enum ECONNRESET = 104; + enum ENOBUFS = 105; + enum EISCONN = 106; + enum ENOTCONN = 107; + enum ESHUTDOWN = 108; + enum ETOOMANYREFS = 109; + enum ETIMEDOUT = 110; + enum ECONNREFUSED = 111; + enum EHOSTDOWN = 112; + enum EHOSTUNREACH = 113; + enum EALREADY = 114; + enum EINPROGRESS = 115; + enum ESTALE = 116; + enum EUCLEAN = 117; + enum ENOTNAM = 118; + enum ENAVAIL = 119; + enum EISNAM = 120; + enum EREMOTEIO = 121; + enum EDQUOT = 122; + enum ENOMEDIUM = 123; + enum EMEDIUMTYPE = 124; + enum ECANCELED = 125; + enum ENOKEY = 126; + enum EKEYEXPIRED = 127; + enum EKEYREVOKED = 128; + enum EKEYREJECTED = 129; + enum EOWNERDEAD = 130; + enum ENOTRECOVERABLE = 131; + enum ERFKILL = 132; + enum EHWPOISON = 133; +} else { static assert(false, "Unsupported platform"); diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d index 3002c02..88123fb 100644 --- a/libphobos/libdruntime/core/stdc/fenv.d +++ b/libphobos/libdruntime/core/stdc/fenv.d @@ -151,6 +151,8 @@ version (GNUFP) // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/sparc/fpu/bits/fenv.h else version (SPARC_Any) { + import core.stdc.config : c_ulong; + alias fenv_t = c_ulong; alias fexcept_t = c_ulong; } diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d index 0c5da0b..0393ea5 100644 --- a/libphobos/libdruntime/core/stdc/math.d +++ b/libphobos/libdruntime/core/stdc/math.d @@ -90,6 +90,13 @@ else version (DragonFlyBSD) /// enum int FP_ILOGBNAN = int.max; } +else version (Solaris) +{ + /// + enum int FP_ILOGB0 = -int.max; + /// + enum int FP_ILOGBNAN = int.max; +} else version (CRuntime_Bionic) { /// @@ -1380,18 +1387,128 @@ else version (DragonFlyBSD) } else version (Solaris) { - pure int __isnanf(float x); - pure int __isnan(double x); - pure int __isnanl(real x); + enum + { + FP_INFINITE = 3, + FP_NAN = 4, + FP_NORMAL = 2, + FP_SUBNORMAL = 1, + FP_ZERO = 0, + } + + enum + { + /// + FP_FAST_FMA = 0, + /// + FP_FAST_FMAF = 0, + /// + FP_FAST_FMAL = 0, + } + + extern (D) + { + //int fpclassify(real-floating x); + /// + pure int fpclassify(float x) + { + return isnan(x) ? FP_NAN : isinf(x) ? FP_INFINITE : + isnormal(x) ? FP_NORMAL : x == 0.0f ? FP_ZERO : + FP_SUBNORMAL; + } + + /// + pure int fpclassify(double x) + { + return isnan(x) ? FP_NAN : isinf(x) ? FP_INFINITE : + isnormal(x) ? FP_NORMAL : x == 0.0 ? FP_ZERO : + FP_SUBNORMAL; + } + + /// + pure int fpclassify(real x) + { + return isnan(x) ? FP_NAN : isinf(x) ? FP_INFINITE : + isnormal(x) ? FP_NORMAL : x == 0.0L ? FP_ZERO : + FP_SUBNORMAL; + } + + //int isfinite(real-floating x); + /// + pure int isfinite(float x) { return !isnan(x) && !isinf(x); } + /// + pure int isfinite(double x) { return !isnan(x) && !isinf(x); } + /// + pure int isfinite(real x) { return !isnan(x) && !isinf(x); } + + //int isinf(real-floating x); + /// + pure int isinf(float x) { return x == float.infinity || x == -float.infinity; } + /// + pure int isinf(double x) { return x == double.infinity || x == -double.infinity; } + /// + pure int isinf(real x) { return x == real.infinity || x == -real.infinity; } //int isnan(real-floating x); - /// - pragma(mangle, "__isnanf") pure int isnan(float x); /// - pragma(mangle, "__isnan") pure int isnan(double x); + pure int isnan(float x) { return x != x; } /// - pragma(mangle, real.sizeof == double.sizeof ? "__isnan" : "__isnanl") - pure int isnan(real x); + pure int isnan(double x) { return x != x; } + /// + pure int isnan(real x) { return x != x; } + + //int isnormal(real-floating x); + /// + pure int isnormal(float x) + { + import core.math; + return isfinite(x) && fabs(x) >= float.min_normal; + } + /// + pure int isnormal(double x) + { + import core.math; + return isfinite(x) && fabs(x) >= double.min_normal; + } + /// + pure int isnormal(real x) + { + import core.math; + return isfinite(x) && fabs(x) >= real.min_normal; + } + + //int signbit(real-floating x); + /// + pure int signbit(float x) + { + version (SPARC_Any) + return cast(int)(*cast(uint*)&x >> 31); + else version (X86_Any) + return cast(int)(*cast(uint*)&x >> 31); + else + static assert(false, "Architecture not supported."); + } + /// + pure int signbit(double x) + { + version (SPARC_Any) + return cast(int)(*cast(uint*)&x >> 31); + else version (X86_Any) + return cast(int)((cast(uint*)&x)[1] >> 31); + else + static assert(false, "Architecture not supported."); + } + /// + pure int signbit(real x) + { + version (SPARC_Any) + return cast(int)(*cast(uint*)&x >> 31); + else version (X86_Any) + return cast(int)((cast(ushort *)&x)[4] >> 15); + else + static assert(false, "Architecture not supported."); + } + } } else version (CRuntime_Bionic) { diff --git a/libphobos/libdruntime/core/stdc/stdarg.d b/libphobos/libdruntime/core/stdc/stdarg.d index 9a67f2e..646905e 100644 --- a/libphobos/libdruntime/core/stdc/stdarg.d +++ b/libphobos/libdruntime/core/stdc/stdarg.d @@ -47,6 +47,8 @@ version (MIPS32) version = MIPS_Any; version (MIPS64) version = MIPS_Any; version (PPC) version = PPC_Any; version (PPC64) version = PPC_Any; +version (RISCV32) version = RISCV_Any; +version (RISCV64) version = RISCV_Any; version (GNU) { @@ -130,6 +132,12 @@ else version (AAPCS64) { alias va_list = core.internal.vararg.aarch64.va_list; } +else version (RISCV_Any) +{ + // The va_list type is void*, according to RISCV Calling Convention + // https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc + alias va_list = void*; +} else { alias va_list = char*; // incl. unknown platforms @@ -259,6 +267,19 @@ T va_arg(T)(ref va_list ap) ap += T.sizeof.alignUp; return *p; } + else version (RISCV_Any) + { + static if (T.sizeof > (size_t.sizeof << 1)) + auto p = *cast(T**) ap; + else + { + static if (T.alignof == (size_t.sizeof << 1)) + ap = ap.alignUp!(size_t.sizeof << 1); + auto p = cast(T*) ap; + } + ap += T.sizeof.alignUp; + return *p; + } else static assert(0, "Unsupported platform"); } diff --git a/libphobos/libdruntime/core/stdc/stddef.d b/libphobos/libdruntime/core/stdc/stddef.d index 1d1d962..56b3c9b 100644 --- a/libphobos/libdruntime/core/stdc/stddef.d +++ b/libphobos/libdruntime/core/stdc/stddef.d @@ -34,3 +34,8 @@ else version (Posix) /// alias dchar wchar_t; } +else version (WASI) +{ + /// + alias dchar wchar_t; +} diff --git a/libphobos/libdruntime/core/stdc/stdint.d b/libphobos/libdruntime/core/stdc/stdint.d index 9db2fda..476c42f 100644 --- a/libphobos/libdruntime/core/stdc/stdint.d +++ b/libphobos/libdruntime/core/stdc/stdint.d @@ -36,20 +36,7 @@ extern (C): nothrow: @nogc: -// These are defined the same way as D basic types, so the definition is -// platform-independant -alias int8_t = byte; /// -alias int16_t = short; /// -alias uint8_t = ubyte; /// -alias uint16_t = ushort; /// - -// 32 bit types and need to be defined on-platform basis, because -// they might have C++ binary mangling of `int` or `long`. -// 64-bit types respectively might be mangled as `long` or `long long` - -// It would seem correct to define intmax_t and uintmax_t here, but C and C++ -// compilers don't in practice always set them to the maximum supported value. -// See https://quuxplusone.github.io/blog/2019/02/28/is-int128-integral/ + static if (is(ucent)) { alias int128_t = cent; /// @@ -58,6 +45,10 @@ static if (is(ucent)) version (Windows) { + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// version (CRuntime_DigitalMars) { alias int32_t = cpp_long; /// @@ -71,23 +62,31 @@ version (Windows) alias int64_t = long; /// alias uint64_t = ulong; /// - alias int_least8_t = byte; /// - alias uint_least8_t = ubyte; /// - alias int_least16_t = short; /// - alias uint_least16_t = ushort; /// - alias int_least32_t = int32_t; /// + alias int_least8_t = byte; /// + alias uint_least8_t = ubyte; /// + alias int_least16_t = short; /// + alias uint_least16_t = ushort; /// + alias int_least32_t = int32_t; /// alias uint_least32_t = uint32_t; /// - alias int_least64_t = long; /// - alias uint_least64_t = ulong; /// + alias int_least64_t = long; /// + alias uint_least64_t = ulong; /// - alias int_fast8_t = byte; /// - alias uint_fast8_t = ubyte; /// - alias int_fast16_t = int; /// - alias uint_fast16_t = uint; /// - alias int_fast32_t = int32_t; /// + alias int_fast8_t = byte; /// + alias uint_fast8_t = ubyte; /// + version (MinGW) + { + alias int_fast16_t = short; /// + alias uint_fast16_t = ushort; /// + } + else + { + alias int_fast16_t = int; /// + alias uint_fast16_t = uint; /// + } + alias int_fast32_t = int32_t; /// alias uint_fast32_t = uint32_t; /// - alias int_fast64_t = long; /// - alias uint_fast64_t = ulong; /// + alias int_fast64_t = long; /// + alias uint_fast64_t = ulong; /// alias intptr_t = ptrdiff_t; /// alias uintptr_t = size_t; /// @@ -96,6 +95,10 @@ version (Windows) } else version (Darwin) { + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// alias int32_t = int; /// alias uint32_t = uint; /// alias int64_t = cpp_longlong; /// @@ -124,32 +127,27 @@ else version (Darwin) alias intmax_t = long; /// alias uintmax_t = ulong; /// } -else version (Posix) +else version (linux) { - alias int32_t = int; /// - alias uint32_t = uint; /// - alias int64_t = long; /// - alias uint64_t = ulong; /// - - alias int_least8_t = byte; /// - alias uint_least8_t = ubyte; /// - alias int_least16_t = short; /// + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = long; /// + alias uint64_t = ulong; /// + + alias int_least8_t = byte; /// + alias uint_least8_t = ubyte; /// + alias int_least16_t = short; /// alias uint_least16_t = ushort; /// - alias int_least32_t = int; /// - alias uint_least32_t = uint; /// - alias int_least64_t = long; /// - alias uint_least64_t = ulong;/// + alias int_least32_t = int; /// + alias uint_least32_t = uint; /// + alias int_least64_t = long; /// + alias uint_least64_t = ulong; /// - version (FreeBSD) - { - alias int_fast8_t = int; /// - alias uint_fast8_t = uint; /// - alias int_fast16_t = int; /// - alias uint_fast16_t = uint; /// - alias int_fast32_t = int; /// - alias uint_fast32_t = uint; /// - } - else version (CRuntime_Musl) + version (CRuntime_Musl) { alias int_fast8_t = byte; /// alias uint_fast8_t = ubyte; /// @@ -167,17 +165,256 @@ else version (Posix) alias int_fast32_t = ptrdiff_t; /// alias uint_fast32_t = size_t; /// } - alias int_fast64_t = long; /// + alias int_fast64_t = long; /// + alias uint_fast64_t = ulong; /// + + alias intptr_t = ptrdiff_t; /// + alias uintptr_t = size_t; /// + alias intmax_t = long; /// + alias uintmax_t = ulong; /// +} +else version (CRuntime_Glibc) +{ + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = long; /// + alias uint64_t = ulong; /// + + alias int_least8_t = byte; /// + alias uint_least8_t = ubyte; /// + alias int_least16_t = short; /// + alias uint_least16_t = ushort; /// + alias int_least32_t = int; /// + alias uint_least32_t = uint; /// + alias int_least64_t = long; /// + alias uint_least64_t = ulong; /// + + alias int_fast8_t = byte; /// + alias uint_fast8_t = ubyte; /// + alias int_fast16_t = ptrdiff_t; /// + alias uint_fast16_t = size_t; /// + alias int_fast32_t = ptrdiff_t; /// + alias uint_fast32_t = size_t; /// + alias int_fast64_t = long; /// + alias uint_fast64_t = ulong; /// + + alias intptr_t = ptrdiff_t; /// + alias uintptr_t = size_t; /// + alias intmax_t = long; /// + alias uintmax_t = ulong; /// +} +else version (DragonFlyBSD) +{ + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = long; /// + alias uint64_t = ulong; /// + + alias int_least8_t = int8_t; /// + alias uint_least8_t = uint8_t; /// + alias int_least16_t = int16_t; /// + alias uint_least16_t = uint16_t; /// + alias int_least32_t = int32_t; /// + alias uint_least32_t = uint32_t; /// + alias int_least64_t = int64_t; /// + alias uint_least64_t = uint64_t; /// + + alias int_fast8_t = int32_t; /// + alias uint_fast8_t = uint32_t; /// + alias int_fast16_t = int32_t; /// + alias uint_fast16_t = uint32_t; /// + alias int_fast32_t = int32_t; /// + alias uint_fast32_t = uint32_t; /// + alias int_fast64_t = int64_t; /// + alias uint_fast64_t = uint64_t; /// + + alias intptr_t = ptrdiff_t; /// + alias uintptr_t = size_t; /// + alias intmax_t = long; /// + alias uintmax_t = ulong; /// +} +else version (FreeBSD) +{ + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = long; /// + alias uint64_t = ulong; /// + + alias int_least8_t = byte; /// + alias uint_least8_t = ubyte; /// + alias int_least16_t = short; /// + alias uint_least16_t = ushort; /// + alias int_least32_t = int; /// + alias uint_least32_t = uint; /// + alias int_least64_t = long; /// + alias uint_least64_t = ulong; /// + + alias int_fast8_t = int; /// + alias uint_fast8_t = uint; /// + alias int_fast16_t = int; /// + alias uint_fast16_t = uint; /// + alias int_fast32_t = int; /// + alias uint_fast32_t = uint; /// + alias int_fast64_t = long; /// alias uint_fast64_t = ulong; /// alias intptr_t = ptrdiff_t; /// - alias uintptr_t = size_t; /// - alias intmax_t = long; /// - alias uintmax_t = ulong; /// + alias uintptr_t = size_t; /// + alias intmax_t = long; /// + alias uintmax_t = ulong; /// +} +else version (NetBSD) +{ + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = long; /// + alias uint64_t = ulong; /// + + alias int_least8_t = int8_t; /// + alias uint_least8_t = uint8_t; /// + alias int_least16_t = int16_t; /// + alias uint_least16_t = uint16_t; /// + alias int_least32_t = int32_t; /// + alias uint_least32_t = uint32_t; /// + alias int_least64_t = int64_t; /// + alias uint_least64_t = uint64_t; /// + + alias int_fast8_t = int32_t; /// + alias uint_fast8_t = uint32_t; /// + alias int_fast16_t = int32_t; /// + alias uint_fast16_t = uint32_t; /// + alias int_fast32_t = int32_t; /// + alias uint_fast32_t = uint32_t; /// + alias int_fast64_t = int64_t; /// + alias uint_fast64_t = uint64_t; /// + + alias intptr_t = ptrdiff_t; /// + alias uintptr_t = size_t; /// + alias intmax_t = long; /// + alias uintmax_t = ulong; /// +} +else version (OpenBSD) +{ + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = cpp_longlong; /// + alias uint64_t = cpp_ulonglong; /// + + alias int_least8_t = byte; /// + alias uint_least8_t = ubyte; /// + alias int_least16_t = short; /// + alias uint_least16_t = ushort; /// + alias int_least32_t = int; /// + alias uint_least32_t = uint; /// + alias int_least64_t = cpp_longlong; /// + alias uint_least64_t = cpp_ulonglong; /// + + alias int_fast8_t = int; /// + alias uint_fast8_t = uint; /// + alias int_fast16_t = int; /// + alias uint_fast16_t = uint; /// + alias int_fast32_t = int; /// + alias uint_fast32_t = uint; /// + alias int_fast64_t = cpp_longlong; /// + alias uint_fast64_t = cpp_ulonglong; /// + + alias intptr_t = cpp_long; /// + alias uintptr_t = cpp_ulong; /// + alias intmax_t = cpp_longlong; /// + alias uintmax_t = cpp_ulonglong; /// +} +else version (Solaris) +{ + alias int8_t = char; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = long; /// + alias uint64_t = ulong; /// + + alias int_least8_t = char; /// + alias uint_least8_t = ubyte; /// + alias int_least16_t = short; /// + alias uint_least16_t = ushort; /// + alias int_least32_t = int; /// + alias uint_least32_t = uint; /// + alias int_least64_t = long; /// + alias uint_least64_t = ulong; /// + + alias int_fast8_t = char; /// + alias uint_fast8_t = ubyte; /// + alias int_fast16_t = int; /// + alias uint_fast16_t = uint; /// + alias int_fast32_t = int; /// + alias uint_fast32_t = uint; /// + alias int_fast64_t = long; /// + alias uint_fast64_t = ulong; /// + + alias intptr_t = ptrdiff_t; /// + alias uintptr_t = size_t; /// + alias intmax_t = long; /// + alias uintmax_t = ulong; /// +} +else version (WASI) +{ + alias int8_t = byte; /// + alias int16_t = short; /// + alias uint8_t = ubyte; /// + alias uint16_t = ushort; /// + alias int32_t = int; /// + alias uint32_t = uint; /// + alias int64_t = long; /// + alias uint64_t = ulong; /// + + alias int_least8_t = byte; /// + alias uint_least8_t = ubyte; /// + alias int_least16_t = short; /// + alias uint_least16_t = ushort; /// + alias int_least32_t = int; /// + alias uint_least32_t = uint; /// + alias int_least64_t = long; /// + alias uint_least64_t = ulong; /// + + alias int_fast8_t = byte; /// + alias uint_fast8_t = ubyte; /// + alias int_fast16_t = ptrdiff_t; /// + alias uint_fast16_t = size_t; /// + alias int_fast32_t = ptrdiff_t; /// + alias uint_fast32_t = size_t; /// + + alias int_fast64_t = long; /// + alias uint_fast64_t = ulong; /// + + alias intptr_t = ptrdiff_t; /// + alias uintptr_t = size_t; /// + alias intmax_t = long; /// + alias uintmax_t = ulong; /// } else { - static assert(0); + static assert(false, "Unsupported architecture."); } diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d index c76b922..2e83811 100644 --- a/libphobos/libdruntime/core/stdc/stdio.d +++ b/libphobos/libdruntime/core/stdc/stdio.d @@ -347,6 +347,24 @@ else version (CRuntime_UClibc) L_tmpnam = 20 } } +else version (WASI) +{ + enum + { + /// + BUFSIZ = 1024, + /// + EOF = -1, + /// + FOPEN_MAX = 1000, + /// + FILENAME_MAX = 4096, + /// + TMP_MAX = 10000, + /// + L_tmpnam = 20 + } +} else { static assert( false, "Unsupported platform" ); @@ -449,6 +467,20 @@ else version (CRuntime_Glibc) /// alias shared(_IO_FILE) FILE; } +else version (WASI) +{ + union fpos_t + { + char[16] __opaque = 0; + double __align; + } + struct _IO_FILE; + + /// + alias _IO_FILE _iobuf; // needed for phobos + /// + alias shared(_IO_FILE) FILE; +} else version (CRuntime_Musl) { union fpos_t @@ -700,9 +732,8 @@ else version (Solaris) } else version (CRuntime_Bionic) { - import core.sys.posix.sys.types : off_t; /// - alias off_t fpos_t; + alias c_long fpos_t; // couldn't use off_t because of static if issue /// struct __sFILE @@ -745,12 +776,10 @@ else version (CRuntime_UClibc) import core.stdc.stddef : wchar_t; import core.sys.posix.sys.types : ssize_t, pthread_mutex_t; - alias long off_t; - /// struct fpos_t { - off_t __pos; + long __pos; // couldn't use off_t because of static if issue mbstate_t __state; int __mblen_pending; } @@ -759,7 +788,7 @@ else version (CRuntime_UClibc) { ssize_t function(void* __cookie, char* __buf, size_t __bufsize) read; ssize_t function(void* __cookie, const char* __buf, size_t __bufsize) write; - int function(void* __cookie, off_t* __pos, int __whence) seek; + int function(void* __cookie, long* __pos, int __whence) seek; int function(void* __cookie) close; } @@ -900,12 +929,14 @@ else version (CRuntime_Microsoft) extern shared void function() _fcloseallp; + FILE* __acrt_iob_func(int hnd); // VS2015+, reimplemented in msvc.d for VS2013- + /// - shared FILE* stdin; // = &__iob_func()[0]; + FILE* stdin()() { return __acrt_iob_func(0); } /// - shared FILE* stdout; // = &__iob_func()[1]; + FILE* stdout()() { return __acrt_iob_func(1); } /// - shared FILE* stderr; // = &__iob_func()[2]; + FILE* stderr()() { return __acrt_iob_func(2); } } else version (CRuntime_Glibc) { @@ -984,7 +1015,7 @@ else version (NetBSD) _IONBF = 2, } - private extern __gshared FILE[3] __sF; + private extern shared FILE[3] __sF; @property auto __stdin()() { return &__sF[0]; } @property auto __stdout()() { return &__sF[1]; } @property auto __stderr()() { return &__sF[2]; } @@ -1007,7 +1038,7 @@ else version (OpenBSD) _IONBF = 2, } - private extern __gshared FILE[3] __sF; + private extern shared FILE[3] __sF; @property auto __stdin()() { return &__sF[0]; } @property auto __stdout()() { return &__sF[1]; } @property auto __stderr()() { return &__sF[2]; } @@ -1062,11 +1093,11 @@ else version (Solaris) private extern shared FILE[_NFILE] __iob; /// - shared stdin = &__iob[0]; + @property auto stdin()() { return &__iob[0]; } /// - shared stdout = &__iob[1]; + @property auto stdout()() { return &__iob[1]; } /// - shared stderr = &__iob[2]; + @property auto stderr()() { return &__iob[2]; } } else version (CRuntime_Bionic) { @@ -1083,11 +1114,11 @@ else version (CRuntime_Bionic) private extern shared FILE[3] __sF; /// - shared stdin = &__sF[0]; + @property auto stdin()() { return &__sF[0]; } /// - shared stdout = &__sF[1]; + @property auto stdout()() { return &__sF[1]; } /// - shared stderr = &__sF[2]; + @property auto stderr()() { return &__sF[2]; } } else version (CRuntime_Musl) { @@ -1126,6 +1157,24 @@ else version (CRuntime_UClibc) /// extern shared FILE* stderr; } +else version (WASI) +{ + // needs tail const + extern shared FILE* stdin; + /// + extern shared FILE* stdout; + /// + extern shared FILE* stderr; + enum + { + /// + _IOFBF = 0, + /// + _IOLBF = 1, + /// + _IONBF = 2, + } +} else { static assert( false, "Unsupported platform" ); @@ -1794,6 +1843,28 @@ else version (CRuntime_UClibc) pragma(printf) int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); } +else version (WASI) +{ + // No unsafe pointer manipulation. + @trusted + { + /// + void rewind(FILE* stream); + /// + pure void clearerr(FILE* stream); + /// + pure int feof(FILE* stream); + /// + pure int ferror(FILE* stream); + /// + int fileno(FILE *); + } + + /// + int snprintf(scope char* s, size_t n, scope const char* format, ...); + /// + int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); +} else { static assert( false, "Unsupported platform" ); diff --git a/libphobos/libdruntime/core/stdc/stdlib.d b/libphobos/libdruntime/core/stdc/stdlib.d index 92f8f70..920c311 100644 --- a/libphobos/libdruntime/core/stdc/stdlib.d +++ b/libphobos/libdruntime/core/stdc/stdlib.d @@ -69,8 +69,8 @@ struct div_t /// struct ldiv_t { - int quot, - rem; + c_long quot, + rem; } /// @@ -99,6 +99,7 @@ else version (Solaris) enum RAND_MAX = 0x7fff; else version (CRuntime_Bionic) enum RAND_MAX = 0x7fffffff; else version (CRuntime_Musl) enum RAND_MAX = 0x7fffffff; else version (CRuntime_UClibc) enum RAND_MAX = 0x7fffffff; +else version (WASI) enum RAND_MAX = 0x7fffffff; else static assert( false, "Unsupported platform" ); /// diff --git a/libphobos/libdruntime/core/stdcpp/exception.d b/libphobos/libdruntime/core/stdcpp/exception.d index d65cd8d..d533996 100644 --- a/libphobos/libdruntime/core/stdcpp/exception.d +++ b/libphobos/libdruntime/core/stdcpp/exception.d @@ -69,7 +69,7 @@ version (GenericBaseException) { @nogc: /// - this() nothrow {} + extern(D) this() nothrow {} /// @weak ~this() nothrow {} // HACK: this should extern, but then we have link errors! @@ -77,7 +77,7 @@ version (GenericBaseException) @weak const(char)* what() const nothrow { return "unknown"; } // HACK: this should extern, but then we have link errors! protected: - this(const(char)*, int = 1) nothrow { this(); } // compat with MS derived classes + extern(D) this(const(char)*, int = 1) nothrow { this(); } // compat with MS derived classes } } else version (CppRuntime_DigitalMars) @@ -87,7 +87,7 @@ else version (CppRuntime_DigitalMars) { @nogc: /// - this() nothrow {} + extern(D) this() nothrow {} //virtual ~this(); void dtor() { } // reserve slot in vtbl[] @@ -105,7 +105,7 @@ else version (CppRuntime_Microsoft) { @nogc: /// - this(const(char)* message = "unknown", int = 1) nothrow { msg = message; } + extern(D) this(const(char)* message = "unknown", int = 1) nothrow { msg = message; } /// @weak ~this() nothrow {} @@ -131,7 +131,7 @@ class bad_exception : exception { @nogc: /// - this(const(char)* message = "bad exception") { super(message); } + extern(D) this(const(char)* message = "bad exception") nothrow { super(message); } version (GenericBaseException) { diff --git a/libphobos/libdruntime/core/stdcpp/new_.d b/libphobos/libdruntime/core/stdcpp/new_.d index 77c179c..6a598ba 100644 --- a/libphobos/libdruntime/core/stdcpp/new_.d +++ b/libphobos/libdruntime/core/stdcpp/new_.d @@ -26,7 +26,7 @@ extern (C++, "std") struct nothrow_t {} /// - enum align_val_t : size_t { defaultAlignment = __STDCPP_DEFAULT_NEW_ALIGNMENT__ }; + enum align_val_t : size_t { defaultAlignment = __STDCPP_DEFAULT_NEW_ALIGNMENT__ } /// class bad_alloc : exception diff --git a/libphobos/libdruntime/core/stdcpp/string.d b/libphobos/libdruntime/core/stdcpp/string.d index 1cdb0f4..defbd83 100644 --- a/libphobos/libdruntime/core/stdcpp/string.d +++ b/libphobos/libdruntime/core/stdcpp/string.d @@ -343,7 +343,7 @@ extern(D): /// inout(T)* data() inout @safe { return _Get_data()._Myptr; } /// - inout(T)[] as_array() inout nothrow @trusted { return _Get_data()._Myptr[0 .. _Get_data()._Mysize]; } + inout(T)[] as_array() scope return inout nothrow @trusted { return _Get_data()._Myptr[0 .. _Get_data()._Mysize]; } /// ref inout(T) at(size_type i) inout nothrow @trusted { return _Get_data()._Myptr[0 .. _Get_data()._Mysize][i]; } @@ -1920,7 +1920,7 @@ extern(D): /// inout(T)* data() inout @safe { return __get_pointer(); } /// - inout(T)[] as_array() inout nothrow @trusted { return __get_pointer()[0 .. size()]; } + inout(T)[] as_array() scope return inout nothrow @trusted { return __get_pointer()[0 .. size()]; } /// ref inout(T) at(size_type i) inout nothrow @trusted { return __get_pointer()[0 .. size()][i]; } @@ -2497,8 +2497,8 @@ extern(C++, (StdNamespace)): extern(D) @safe @nogc: pragma(inline, true) { - ref inout(Alloc) _Getal() inout pure nothrow { return _Mypair._Myval1; } - ref inout(ValTy) _Get_data() inout pure nothrow { return _Mypair._Myval2; } + ref inout(Alloc) _Getal() return inout pure nothrow { return _Mypair._Myval1; } + ref inout(ValTy) _Get_data() return inout pure nothrow { return _Mypair._Myval2; } } void _Orphan_all() nothrow { _Get_data._Base._Orphan_all(); } diff --git a/libphobos/libdruntime/core/stdcpp/typeinfo.d b/libphobos/libdruntime/core/stdcpp/typeinfo.d index 53b25c5..24f2938 100644 --- a/libphobos/libdruntime/core/stdcpp/typeinfo.d +++ b/libphobos/libdruntime/core/stdcpp/typeinfo.d @@ -18,10 +18,10 @@ version (CppRuntime_DigitalMars) import core.stdcpp.exception; extern (C++, "std"): - @nogc: class type_info { + @nogc: void* pdata; public: @@ -41,8 +41,9 @@ version (CppRuntime_DigitalMars) class bad_cast : exception { - this() nothrow { } - this(const bad_cast) nothrow { } + @nogc: + extern(D) this() nothrow { } + extern(D) this(const bad_cast) nothrow { } //bad_cast operator=(const bad_cast) nothrow { return this; } //virtual ~this() nothrow; override const(char)* what() const nothrow; @@ -50,8 +51,9 @@ version (CppRuntime_DigitalMars) class bad_typeid : exception { - this() nothrow { } - this(const bad_typeid) nothrow { } + @nogc: + extern(D) this() nothrow { } + extern(D) this(const bad_typeid) nothrow { } //bad_typeid operator=(const bad_typeid) nothrow { return this; } //virtual ~this() nothrow; override const (char)* what() const nothrow; @@ -62,7 +64,6 @@ else version (CppRuntime_Microsoft) import core.stdcpp.exception; extern (C++, "std"): - @nogc: struct __type_info_node { @@ -74,6 +75,7 @@ else version (CppRuntime_Microsoft) class type_info { + @nogc: @weak ~this() nothrow {} //bool operator==(const type_info rhs) const; //bool operator!=(const type_info rhs) const; @@ -88,13 +90,15 @@ else version (CppRuntime_Microsoft) class bad_cast : exception { - this(const(char)* msg = "bad cast") @nogc nothrow { super(msg); } + @nogc: + extern(D) this(const(char)* msg = "bad cast") nothrow { super(msg); } //virtual ~this(); } class bad_typeid : exception { - this(const(char)* msg = "bad typeid") @nogc nothrow { super(msg); } + @nogc: + extern(D) this(const(char)* msg = "bad typeid") nothrow { super(msg); } //virtual ~this(); } } @@ -108,10 +112,10 @@ else version (CppRuntime_Gcc) } extern (C++, "std"): - @nogc: abstract class type_info { + @nogc: @weak ~this() {} @weak final const(char)* name() const nothrow { @@ -133,19 +137,21 @@ else version (CppRuntime_Gcc) protected: const(char)* _name; - this(const(char)* name) { _name = name; } + extern(D) this(const(char)* name) { _name = name; } } class bad_cast : exception { - this() nothrow {} + @nogc: + extern(D) this() nothrow {} //~this(); @weak override const(char)* what() const nothrow { return "bad cast"; } } class bad_typeid : exception { - this() nothrow {} + @nogc: + extern(D) this() nothrow {} //~this(); @weak override const(char)* what() const nothrow { return "bad typeid"; } } @@ -155,10 +161,10 @@ else version (CppRuntime_Clang) import core.stdcpp.exception; extern (C++, "std"): - @nogc: abstract class type_info { + @nogc: @weak ~this() {} @weak final const(char)* name() const nothrow { @@ -173,19 +179,21 @@ else version (CppRuntime_Clang) protected: const(char)* __type_name; - this(const(char)* __n) { __type_name = __n; } + extern(D) this(const(char)* __n) { __type_name = __n; } } class bad_cast : exception { - this() nothrow {} + @nogc: + extern(D) this() nothrow {} //~this(); @weak override const(char)* what() const nothrow { return "bad cast"; } } class bad_typeid : exception { - this() nothrow {} + @nogc: + extern(D) this() nothrow {} //~this(); @weak override const(char)* what() const nothrow { return "bad typeid"; } } diff --git a/libphobos/libdruntime/core/stdcpp/xutility.d b/libphobos/libdruntime/core/stdcpp/xutility.d index fa61701..0142d0b9 100644 --- a/libphobos/libdruntime/core/stdcpp/xutility.d +++ b/libphobos/libdruntime/core/stdcpp/xutility.d @@ -23,14 +23,27 @@ else enum StdNamespace = "std"; } +/** + * Possible values of the `__cplusplus` macro provided by C++ compilers + * + * For foolproofness, use ordering comparison, e.g. `__cplusplus >= CppStdRevision.cpp17`. + */ enum CppStdRevision : uint { cpp98 = 199711, cpp11 = 201103, cpp14 = 201402, - cpp17 = 201703 + cpp17 = 201703, + cpp20 = 202002, } +/** + * Returns the target C++ version, encoded as C++ compilers do + * + * C++ compilers provide a `__cplusplus` macro which returns an integer + * representing the targetted standard. This manifest provides the same + * interface, retrieved from the compiler via a `__traits`. + */ enum __cplusplus = __traits(getTargetInfo, "cppStd"); // wrangle C++ features diff --git a/libphobos/libdruntime/core/sync/package.d b/libphobos/libdruntime/core/sync/package.d new file mode 100644 index 0000000..fe389a0 --- /dev/null +++ b/libphobos/libdruntime/core/sync/package.d @@ -0,0 +1,20 @@ +/** + * Provides thread synchronization tools such as mutexes, semaphores and barriers. + * + * License: Distributed under the + * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). + * (See accompanying file LICENSE) + * Authors: Sean Kelly, Rainer Schuetze + * Source: $(DRUNTIMESRC core/sync/package.d) + */ + +module core.sync; + +public import core.sync.barrier; +public import core.sync.condition; +public import core.sync.config; +public import core.sync.event; +public import core.sync.exception; +public import core.sync.mutex; +public import core.sync.rwmutex; +public import core.sync.semaphore; diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf32.d b/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf32.d index 035bba5..c796cd8 100644 --- a/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf32.d +++ b/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf32.d @@ -13,60 +13,11 @@ extern (C): import core.stdc.stdint; public import core.sys.dragonflybsd.sys.elf_common; -alias uint16_t Elf32_Half; -alias uint32_t Elf32_Word; -alias int32_t Elf32_Sword; alias uint64_t Elf32_Lword; -alias uint32_t Elf32_Addr; -alias uint32_t Elf32_Off; alias Elf32_Word Elf32_Hashelt; alias Elf32_Word Elf32_Size; alias Elf32_Sword Elf32_Ssize; -struct Elf32_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} - -struct Elf32_Shdr -{ - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} - -struct Elf32_Phdr -{ - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; -} - struct Elf32_Dyn { Elf32_Sword d_tag; @@ -77,44 +28,8 @@ struct Elf32_Dyn } _d_un d_un; } -struct Elf32_Rel -{ - Elf32_Addr r_offset; - Elf32_Word r_info; -} - -struct Elf32_Rela -{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} - -extern (D) pure @safe -{ - auto ELF32_R_SYM(V)(V val) { return val >> 8; } - auto ELF32_R_TYPE(V)(V val) { return val & 0xff; } - auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); } -} - alias Elf_Note Elf32_Nhdr; -struct Elf32_Move -{ - Elf32_Lword m_value; - Elf32_Word m_info; - Elf32_Word m_poffset; - Elf32_Half m_repeat; - Elf32_Half m_stride; -} - -extern (D) pure -{ - auto ELF32_M_SYM(I)(I info) @safe { return info >> 8; } - auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } -} - struct Elf32_Cap { Elf32_Word c_tag; @@ -125,63 +40,7 @@ struct Elf32_Cap } _c_un c_un; } -struct Elf32_Sym -{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - ubyte st_info; - ubyte st_other; - Elf32_Half st_shndx; -} - -extern (D) pure -{ - auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF32_ST_TYPE(T)(T val) @safe { return val & 0xf; } - auto ELF32_ST_INFO(B, T)(B bind, T type) @safe { return (bind << 4) + (type & 0xf); } - auto ELF32_ST_VISIBILITY(O)(O o) @safe { return o & 0x03; } -} - -struct Elf32_Verdef -{ - Elf32_Half vd_version; - Elf32_Half vd_flags; - Elf32_Half vd_ndx; - Elf32_Half vd_cnt; - Elf32_Word vd_hash; - Elf32_Word vd_aux; - Elf32_Word vd_next; -} - -struct Elf32_Verdaux -{ - Elf32_Word vda_name; - Elf32_Word vda_next; -} - -struct Elf32_Verneed -{ - Elf32_Half vn_version; - Elf32_Half vn_cnt; - Elf32_Word vn_file; - Elf32_Word vn_aux; - Elf32_Word vn_next; -} - -struct Elf32_Vernaux -{ - Elf32_Word vna_hash; - Elf32_Half vna_flags; - Elf32_Half vna_other; - Elf32_Word vna_name; - Elf32_Word vna_next; -} - -alias Elf32_Half Elf32_Versym; - -struct Elf32_Syminfo +extern (D) { - Elf32_Half si_boundto; - Elf32_Half si_flags; + auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } } diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf64.d b/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf64.d index f7d9247..89e3ca3 100644 --- a/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf64.d +++ b/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf64.d @@ -13,62 +13,11 @@ extern (C): import core.stdc.stdint; public import core.sys.dragonflybsd.sys.elf_common; -alias uint16_t Elf64_Half; -alias uint32_t Elf64_Word; -alias int32_t Elf64_Sword; alias uint64_t Elf64_Lword; -alias uint64_t Elf64_Xword; -alias int64_t Elf64_Sxword; -alias uint64_t Elf64_Addr; -alias uint64_t Elf64_Off; alias Elf64_Word Elf64_Hashelt; alias Elf64_Xword Elf64_Size; alias Elf64_Sxword Elf64_Ssize; -struct Elf64_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; -} - -struct Elf64_Shdr -{ - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -} - -struct Elf64_Phdr -{ - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf64_Xword p_filesz; - Elf64_Xword p_memsz; - Elf64_Xword p_align; -} - struct Elf64_Dyn { Elf64_Sxword d_tag; @@ -79,25 +28,8 @@ struct Elf64_Dyn } _d_un d_un; } -struct Elf64_Rel -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; -} - -struct Elf64_Rela -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; - Elf64_Sxword r_addend; -} - extern (D) pure { - auto ELF64_R_SYM(I)(I i) @safe { return i >> 32; } - auto ELF64_R_TYPE(I)(I i) @safe { return i & 0xffffffff; } - auto ELF64_R_INFO(S, T)(S sym, T type) @safe { return (sym << 32) + (type & 0xffffffff); } - auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; } auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; } auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } @@ -105,22 +37,6 @@ extern (D) pure alias Elf_Note Elf64_Nhdr; -struct Elf64_Move -{ - Elf64_Lword m_value; - Elf64_Xword m_info; - Elf64_Xword m_poffset; - Elf64_Half m_repeat; - Elf64_Half m_stride; -} - -extern (D) pure -{ - auto ELF64_M_SYM(I)(I info) @safe { return info >> 8; } - auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF64_M_INFO(S, SZ)(S sym, SZ size) @safe { return (sym << 8) + cast(ubyte)size; } -} - struct Elf64_Cap { Elf64_Xword c_tag; @@ -131,63 +47,7 @@ struct Elf64_Cap } _c_un c_un; } -struct Elf64_Sym -{ - Elf64_Word st_name; - ubyte st_info; - ubyte st_other; - Elf64_Half st_shndx; - Elf64_Addr st_value; - Elf64_Xword st_size; -} - -extern (D) pure -{ - auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF64_ST_TYPE(T)(T val) @safe { return val & 0xf; } - auto ELF64_ST_INFO(B, T)(B bind, T type) @safe { return (bind << 4) + (type & 0xf); } - auto ELF64_ST_VISIBILITY(O)(O o) @safe { return o & 0x03; } -} - -struct Elf64_Verdef -{ - Elf64_Half vd_version; - Elf64_Half vd_flags; - Elf64_Half vd_ndx; - Elf64_Half vd_cnt; - Elf64_Word vd_hash; - Elf64_Word vd_aux; - Elf64_Word vd_next; -} - -struct Elf64_Verdaux -{ - Elf64_Word vda_name; - Elf64_Word vda_next; -} - -struct Elf64_Verneed -{ - Elf64_Half vn_version; - Elf64_Half vn_cnt; - Elf64_Word vn_file; - Elf64_Word vn_aux; - Elf64_Word vn_next; -} - -struct Elf64_Vernaux -{ - Elf64_Word vna_hash; - Elf64_Half vna_flags; - Elf64_Half vna_other; - Elf64_Word vna_name; - Elf64_Word vna_next; -} - -alias Elf64_Half Elf64_Versym; - -struct Elf64_Syminfo +extern (D) { - Elf64_Half si_boundto; - Elf64_Half si_flags; + auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; } } diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf_common.d b/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf_common.d index eef6a89..90e5861 100644 --- a/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf_common.d +++ b/libphobos/libdruntime/core/sys/dragonflybsd/sys/elf_common.d @@ -11,6 +11,7 @@ version (DragonFlyBSD): extern (C): import core.stdc.stdint; +public import core.sys.elf; struct Elf_Note { @@ -27,60 +28,7 @@ struct Elf_GNU_Hash_Header uint32_t gh_shift2; } -enum EI_MAG0 = 0; -enum EI_MAG1 = 1; -enum EI_MAG2 = 2; -enum EI_MAG3 = 3; -enum EI_CLASS = 4; -enum EI_DATA = 5; -enum EI_VERSION = 6; -enum EI_OSABI = 7; -enum EI_ABIVERSION = 8; enum OLD_EI_BRAND = 8; -enum EI_PAD = 9; -enum EI_NIDENT = 16; - -enum ELFMAG0 = 0x7f; -enum ELFMAG1 = 'E'; -enum ELFMAG2 = 'L'; -enum ELFMAG3 = 'F'; -enum ELFMAG = "\177ELF"; -enum SELFMAG = 4; - -enum EV_NONE = 0; -enum EV_CURRENT = 1; - -enum ELFCLASSNONE = 0; -enum ELFCLASS32 = 1; -enum ELFCLASS64 = 2; - -enum ELFDATANONE = 0; -enum ELFDATA2LSB = 1; -enum ELFDATA2MSB = 2; - -enum ELFOSABI_NONE = 0; -enum ELFOSABI_SYSV = 0; -enum ELFOSABI_HPUX = 1; -enum ELFOSABI_NETBSD = 2; -enum ELFOSABI_LINUX = 3; -enum ELFOSABI_HURD = 4; -enum ELFOSABI_86OPEN = 5; -enum ELFOSABI_SOLARIS = 6; -enum ELFOSABI_AIX = 7; -enum ELFOSABI_MONTEREY = 7; -enum ELFOSABI_IRIX = 8; -enum ELFOSABI_FREEBSD = 9; -enum ELFOSABI_TRU64 = 10; -enum ELFOSABI_MODESTO = 11; -enum ELFOSABI_OPENBSD = 12; -enum ELFOSABI_OPENVMS = 13; -enum ELFOSABI_NSK = 14; -enum ELFOSABI_AROS = 15; -enum ELFOSABI_ARM = 97; -enum ELFOSABI_STANDALONE = 255; - -// just a pointer -enum ELFOSABI_DRAGONFLYBSD = ELFOSABI_NONE; extern (D) pure @safe { @@ -90,587 +38,44 @@ extern (D) pure @safe ehdr.e_ident[EI_MAG3] == ELFMAG3; } } -enum ET_NONE = 0; -enum ET_REL = 1; -enum ET_EXEC = 2; -enum ET_DYN = 3; -enum ET_CORE = 4; -enum ET_LOOS = 0xfe00; -enum ET_HIOS = 0xfeff; -enum ET_LOPROC = 0xff00; -enum ET_HIPROC = 0xffff; - -enum EM_NONE = 0; -enum EM_M32 = 1; -enum EM_SPARC = 2; -enum EM_386 = 3; -enum EM_68K = 4; -enum EM_88K = 5; -enum EM_860 = 7; -enum EM_MIPS = 8; -enum EM_S370 = 9; -enum EM_MIPS_RS3_LE = 10; -enum EM_PARISC = 15; -enum EM_VPP500 = 17; -enum EM_SPARC32PLUS = 18; -enum EM_960 = 19; -enum EM_PPC = 20; -enum EM_PPC64 = 21; -enum EM_S390 = 22; -enum EM_V800 = 36; -enum EM_FR20 = 37; -enum EM_RH32 = 38; -enum EM_RCE = 39; -enum EM_ARM = 40; -enum EM_SH = 42; -enum EM_SPARCV9 = 43; -enum EM_TRICORE = 44; -enum EM_ARC = 45; -enum EM_H8_300 = 46; -enum EM_H8_300H = 47; -enum EM_H8S = 48; -enum EM_H8_500 = 49; -enum EM_IA_64 = 50; -enum EM_MIPS_X = 51; -enum EM_COLDFIRE = 52; -enum EM_68HC12 = 53; -enum EM_MMA = 54; -enum EM_PCP = 55; -enum EM_NCPU = 56; -enum EM_NDR1 = 57; -enum EM_STARCORE = 58; -enum EM_ME16 = 59; -enum EM_ST100 = 60; -enum EM_TINYJ = 61; -enum EM_X86_64 = 62; -enum EM_AMD64 = 62; -enum EM_PDSP = 63; -enum EM_FX66 = 66; -enum EM_ST9PLUS = 67; -enum EM_ST7 = 68; -enum EM_68HC16 = 69; -enum EM_68HC11 = 70; -enum EM_68HC08 = 71; -enum EM_68HC05 = 72; -enum EM_SVX = 73; -enum EM_ST19 = 74; -enum EM_VAX = 75; -enum EM_CRIS = 76; -enum EM_JAVELIN = 77; -enum EM_FIREPATH = 78; -enum EM_ZSP = 79; -enum EM_MMIX = 80; -enum EM_HUANY = 81; -enum EM_PRISM = 82; -enum EM_AVR = 83; -enum EM_FR30 = 84; -enum EM_D10V = 85; -enum EM_D30V = 86; -enum EM_V850 = 87; -enum EM_M32R = 88; -enum EM_MN10300 = 89; -enum EM_MN10200 = 90; -enum EM_PJ = 91; -enum EM_OPENRISC = 92; -enum EM_ARC_A5 = 93; -enum EM_XTENSA = 94; -enum EM_VIDEOCORE = 95; -enum EM_TMM_GPP = 96; -enum EM_NS32K = 97; -enum EM_TPC = 98; -enum EM_SNP1K = 99; -enum EM_ST200 = 100; -enum EM_IP2K = 101; -enum EM_MAX = 102; -enum EM_CR = 103; -enum EM_F2MC16 = 104; -enum EM_MSP430 = 105; -enum EM_BLACKFIN = 106; -enum EM_SE_C33 = 107; -enum EM_SEP = 108; -enum EM_ARCA = 109; -enum EM_UNICORE = 110; -enum EM_DXP = 112; -enum EM_ALTERA_NIOS2 =113; -enum EM_CRX = 114; -enum EM_XGATE = 115; -enum EM_C166 = 116; -enum EM_M16C = 117; -enum EM_DSPIC30F = 118; -enum EM_CE = 119; -enum EM_M32C = 120; -enum EM_res121 = 121; -enum EM_res122 = 122; -enum EM_res123 = 123; -enum EM_res124 = 124; -enum EM_res125 = 125; -enum EM_res126 = 126; -enum EM_res127 = 127; -enum EM_res128 = 128; -enum EM_res129 = 129; -enum EM_res130 = 130; -enum EM_TSK3000 = 131; -enum EM_RS08 = 132; -enum EM_res133 = 133; -enum EM_ECOG2 = 134; -enum EM_SCORE = 135; -enum EM_SCORE7 = 135; -enum EM_DSP24 = 136; -enum EM_VIDEOCORE3 = 137; -enum EM_LATTICEMICO32 = 138; -enum EM_SE_C17 = 139; -enum EM_TI_C6000 = 140; -enum EM_TI_C2000 = 141; -enum EM_TI_C5500 = 142; -enum EM_res143 = 143; -enum EM_res144 = 144; -enum EM_res145 = 145; -enum EM_res146 = 146; -enum EM_res147 = 147; -enum EM_res148 = 148; -enum EM_res149 = 149; -enum EM_res150 = 150; -enum EM_res151 = 151; -enum EM_res152 = 152; -enum EM_res153 = 153; -enum EM_res154 = 154; -enum EM_res155 = 155; -enum EM_res156 = 156; -enum EM_res157 = 157; -enum EM_res158 = 158; -enum EM_res159 = 159; -enum EM_MMDSP_PLUS = 160; -enum EM_CYPRESS_M8C = 161; -enum EM_R32C = 162; -enum EM_TRIMEDIA = 163; -enum EM_QDSP6 = 164; -enum EM_8051 = 165; -enum EM_STXP7X = 166; -enum EM_NDS32 = 167; -enum EM_ECOG1 = 168; -enum EM_ECOG1X = 168; -enum EM_MAXQ30 = 169; -enum EM_XIMO16 = 170; -enum EM_MANIK = 171; -enum EM_CRAYNV2 = 172; -enum EM_RX = 173; -enum EM_METAG = 174; -enum EM_MCST_ELBRUS = 175; -enum EM_ECOG16 = 176; -enum EM_CR16 = 177; -enum EM_ETPU = 178; -enum EM_SLE9X = 179; -enum EM_L1OM = 180; -enum EM_K1OM = 181; -enum EM_INTEL182 = 182; -enum EM_res183 = 183; -enum EM_res184 = 184; -enum EM_AVR32 = 185; -enum EM_STM8 = 186; -enum EM_TILE64 = 187; -enum EM_TILEPRO = 188; -enum EM_MICROBLAZE = 189; -enum EM_CUDA = 190; -enum EM_TILEGX = 191; - enum EM_486 = 6; enum EM_MIPS_RS4_BE = 10; enum EM_ALPHA_STD = 41; -enum EM_ALPHA = 0x9026; - -enum SHN_UNDEF = 0; -enum SHN_LORESERVE = 0xff00; -enum SHN_LOPROC = 0xff00; -enum SHN_HIPROC = 0xff1f; -enum SHN_LOOS = 0xff20; -enum SHN_HIOS = 0xff3f; -enum SHN_ABS = 0xfff1; -enum SHN_COMMON = 0xfff2; -enum SHN_XINDEX = 0xffff; -enum SHN_HIRESERVE = 0xffff; - -enum PT_NULL = 0; -enum PT_LOAD = 1; -enum PT_DYNAMIC = 2; -enum PT_INTERP = 3; -enum PT_NOTE = 4; -enum PT_SHLIB = 5; -enum PT_PHDR = 6; -enum PT_TLS = 7; -enum PT_LOOS = 0x60000000; -enum PT_HIOS = 0x6fffffff; -enum PT_LOPROC = 0x70000000; -enum PT_HIPROC = 0x7fffffff; -enum PT_GNU_EH_FRAME = PT_LOOS + 0x474e550; /* Frame unwind information */ -enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME; /* Solaris uses the same value */ -enum PT_GNU_STACK = PT_LOOS + 0x474e551; /* Stack flags */ -enum PT_GNU_RELRO = PT_LOOS + 0x474e552; /* Read-only after relocation */ - -enum PF_X = 0x1; -enum PF_W = 0x2; -enum PF_R = 0x4; -enum PF_MASKOS = 0x0ff00000; -enum PF_MASKPROC = 0xf0000000; - -enum PN_XNUM = 0xffff; - -enum SHT_NULL = 0; -enum SHT_PROGBITS = 1; -enum SHT_SYMTAB = 2; -enum SHT_STRTAB = 3; -enum SHT_RELA = 4; -enum SHT_HASH = 5; -enum SHT_DYNAMIC = 6; -enum SHT_NOTE = 7; -enum SHT_NOBITS = 8; -enum SHT_REL = 9; -enum SHT_SHLIB = 10; -enum SHT_DYNSYM = 11; - -enum SHT_INIT_ARRAY = 14; -enum SHT_FINI_ARRAY = 15; -enum SHT_PREINIT_ARRAY = 16; -enum SHT_GROUP = 17; -enum SHT_SYMTAB_SHNDX = 18; - -enum SHT_LOOS = 0x60000000; -enum SHT_LOSUNW = 0x6ffffff4; +enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME; enum SHT_GNU_INCREMENTAL_INPUTS = 0x6fff4700; -enum SHT_GNU_ATTRIBUTES = 0x6ffffff5; -enum SHT_GNU_HASH = 0x6ffffff6; -enum SHT_GNU_LIBLIST = 0x6ffffff7; -//enum SHT_SUNW_dof = 0x6ffffff4; -//enum SHT_SUNW_cap = 0x6ffffff5; -//enum SHT_SUNW_SIGNATURE = 0x6ffffff6; enum SHT_SUNW_verdef = 0x6ffffffd; enum SHT_SUNW_verneed = 0x6ffffffe; enum SHT_SUNW_versym = 0x6fffffff; -enum SHT_GNU_verdef = SHT_SUNW_verdef; -enum SHT_GNU_verneed = SHT_SUNW_verneed; -enum SHT_GNU_versym = SHT_SUNW_versym; - -enum SHT_LOPROC = 0x70000000; -enum SHT_HIPROC = 0x7fffffff; -enum SHT_LOUSER = 0x80000000; -enum SHT_HIUSER = 0x8fffffff; - -/* -enum SHT_GNU_HASH = 0x6ffffff6; -enum SHT_SUNW_ANNOTATE = 0x6ffffff7; -enum SHT_SUNW_DEBUGSTR = 0x6ffffff8; -enum SHT_SUNW_DEBUG = 0x6ffffff9; -enum SHT_SUNW_move = 0x6ffffffa; -enum SHT_SUNW_COMDAT = 0x6ffffffb; -enum SHT_SUNW_syminfo = 0x6ffffffc; -enum SHT_HISUNW = 0x6fffffff; -enum SHT_HIOS = 0x6fffffff; -enum SHT_AMD64_UNWIND = 0x70000001; -enum SHT_ARM_EXIDX = 0x70000001; -enum SHT_ARM_PREEMPTMAP = 0x70000002; -enum SHT_ARM_ATTRIBUTES = 0x70000003; -enum SHT_ARM_DEBUGOVERLAY = 0x70000004; -enum SHT_ARM_OVERLAYSECTION = 0x70000005; -enum SHT_MIPS_REGINFO = 0x70000006; -enum SHT_MIPS_OPTIONS = 0x7000000d; -enum SHT_MIPS_DWARF = 0x7000001e; -*/ - -enum SHF_WRITE = (1 << 0); -enum SHF_ALLOC = (1 << 1); -enum SHF_EXECINSTR = (1 << 2); -enum SHF_MERGE = (1 << 4); -enum SHF_STRINGS = (1 << 5); -enum SHF_INFO_LINK = (1 << 6); -enum SHF_LINK_ORDER = (1 << 7); -enum SHF_OS_NONCONFORMING = (1 << 8); -enum SHF_GROUP = (1 << 9); -enum SHF_TLS = (1 << 10); -enum SHF_COMPRESSED = (1 << 11); - -enum SHF_MASKOS = 0x0ff00000; -enum SHF_MASKPROC = 0xf0000000; - enum NT_PRSTATUS = 1; enum NT_FPREGSET = 2; enum NT_PRPSINFO = 3; enum NT_TASKSTRUCT = 4; enum NT_AUXV = 6; -/* -enum NT_THRMISC = 7; -enum NT_PROCSTAT_PROC = 8; -enum NT_PROCSTAT_FILES = 9; -enum NT_PROCSTAT_VMMAP = 10; -enum NT_PROCSTAT_GROUPS = 11; -enum NT_PROCSTAT_UMASK = 12; -enum NT_PROCSTAT_RLIMIT = 13; -enum NT_PROCSTAT_OSREL = 14; -enum NT_PROCSTAT_PSSTRINGS = 15; -enum NT_PROCSTAT_AUXV = 16; -*/ - -enum STN_UNDEF = 0; - -enum STB_LOCAL = 0; -enum STB_GLOBAL = 1; -enum STB_WEAK = 2; -enum STB_NUM = 3; -enum STB_LOOS = 10; -enum STB_HIOS = 12; -enum STB_LOPROC = 13; -enum STB_HIPROC = 15; - -enum STT_NOTYPE = 0; -enum STT_OBJECT = 1; -enum STT_FUNC = 2; -enum STT_SECTION = 3; -enum STT_FILE = 4; -enum STT_COMMON = 5; -enum STT_TLS = 6; -enum STT_NUM = 7; -enum STT_LOOS = 10; -enum STT_GNU_IFUNC = 10; -enum STT_HIOS = 12; -enum STT_LOPROC = 13; -enum STT_HIPROC = 15; - -enum STV_DEFAULT = 0; -enum STV_INTERNAL = 1; -enum STV_HIDDEN = 2; -enum STV_PROTECTED = 3; -/* -enum STV_EXPORTED = 4; -enum STV_SINGLETON = 5; -enum STV_ELIMINATE = 6; -*/ - -enum DT_NULL = 0; -enum DT_NEEDED = 1; -enum DT_PLTRELSZ = 2; -enum DT_PLTGOT = 3; -enum DT_HASH = 4; -enum DT_STRTAB = 5; -enum DT_SYMTAB = 6; -enum DT_RELA = 7; -enum DT_RELASZ = 8; -enum DT_RELAENT = 9; -enum DT_STRSZ = 10; -enum DT_SYMENT = 11; -enum DT_INIT = 12; -enum DT_FINI = 13; -enum DT_SONAME = 14; -enum DT_RPATH = 15; -enum DT_SYMBOLIC = 16; -enum DT_REL = 17; -enum DT_RELSZ = 18; -enum DT_RELENT = 19; -enum DT_PLTREL = 20; -enum DT_DEBUG = 21; -enum DT_TEXTREL = 22; -enum DT_JMPREL = 23; -enum DT_BIND_NOW = 24; -enum DT_INIT_ARRAY = 25; -enum DT_FINI_ARRAY = 26; -enum DT_INIT_ARRAYSZ = 27; -enum DT_FINI_ARRAYSZ = 28; -enum DT_RUNPATH = 29; -enum DT_FLAGS = 30; - -enum DT_ENCODING = 32; -enum DT_PREINIT_ARRAY = 32; -enum DT_PREINIT_ARRAYSZ = 33; -//enum DT_MAXPOSTAGS = 34; -enum DT_LOOS = 0x6000000d; -enum DT_HIOS = 0x6ffff000; -/* -enum DT_SUNW_AUXILIARY = 0x6000000d; -enum DT_SUNW_RTLDINF = 0x6000000e; -enum DT_SUNW_FILTER = 0x6000000f; -enum DT_SUNW_CAP = 0x60000010; -*/ - -enum DT_VALRNGLO = 0x6ffffd00; -enum DT_GNU_PRELINKED = 0x6ffffdf5; -enum DT_GNU_CONFLICTSZ =0x6ffffdf6; -enum DT_GNU_LIBLISTSZ = 0x6ffffdf7; -enum DT_CHECKSUM = 0x6ffffdf8; -enum DT_PLTPADSZ = 0x6ffffdf9; -enum DT_MOVEENT = 0x6ffffdfa; -enum DT_MOVESZ = 0x6ffffdfb; -enum DT_FEATURE_1 = 0x6ffffdfc; -enum DT_POSFLAG_1 = 0x6ffffdfd; -enum DT_SYMINSZ = 0x6ffffdfe; -enum DT_SYMINENT = 0x6ffffdff; -enum DT_VALRNGHI = 0x6ffffdff; -enum DT_ADDRRNGLO = 0x6ffffe00; -enum DT_GNU_HASH = 0x6ffffef5; -enum DT_TLSDESC_PLT = 0x6ffffef6; -enum DT_TLSDESC_GOT = 0x6ffffef7; -enum DT_GNU_CONFLICT = 0x6ffffef8; -enum DT_GNU_LIBLIST = 0x6ffffef9; -enum DT_CONFIG = 0x6ffffefa; -enum DT_DEPAUDIT = 0x6ffffefb; -enum DT_AUDIT = 0x6ffffefc; -enum DT_PLTPAD = 0x6ffffefd; -enum DT_MOVETAB = 0x6ffffefe; -enum DT_SYMINFO = 0x6ffffeff; -enum DT_ADDRRNGHI = 0x6ffffeff; -enum DT_RELACOUNT = 0x6ffffff9; -enum DT_RELCOUNT = 0x6ffffffa; -enum DT_FLAGS_1 = 0x6ffffffb; -enum DT_VERDEF = 0x6ffffffc; -enum DT_VERDEFNUM = 0x6ffffffd; -enum DT_VERNEED = 0x6ffffffe; -enum DT_VERNEEDNUM = 0x6fffffff; -enum DT_VERSYM = 0x6ffffff0; -enum DT_LOPROC = 0x70000000; -//enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001; -enum DT_AUXILIARY = 0x7ffffffd; enum DT_USED = 0x7ffffffe; -enum DT_FILTER = 0x7fffffff; -enum DT_HIPROC = 0x7fffffff; - -enum DTF_1_PARINIT = 0x00000001; -enum DTF_1_CONFEXP = 0x00000002; - -enum DF_P1_LAZYLOAD = 0x00000001; -enum DF_P1_GROUPPERM= 0x00000002; -enum DF_1_NOW = 0x00000001; enum DF_1_BIND_NOW = 0x00000001; -enum DF_1_GLOBAL = 0x00000002; -enum DF_1_GROUP = 0x00000004; -enum DF_1_NODELETE = 0x00000008; -enum DF_1_LOADFLTR = 0x00000010; -enum DF_1_INITFIRST = 0x00000020; -enum DF_1_NOOPEN = 0x00000040; -enum DF_1_ORIGIN = 0x00000080; -enum DF_1_DIRECT = 0x00000100; -enum DF_1_TRANS = 0x00000200; -enum DF_1_INTERPOSE = 0x00000400; -enum DF_1_NODEFLIB = 0x00000800; -enum DF_1_NODUMP = 0x00001000; -enum DF_1_CONLFAT = 0x00002000; -enum DF_ORIGIN = 0x00000001; -enum DF_SYMBOLIC = 0x00000002; -enum DF_TEXTREL = 0x00000004; -enum DF_BIND_NOW = 0x00000008; -enum DF_STATIC_TLS = 0x00000010; - -enum VER_DEF_NONE = 0; -enum VER_DEF_CURRENT = 1; alias VER_NDX VER_DEF_IDX; -enum VER_FLG_BASE = 0x1; -enum VER_FLG_WEAK = 0x2; enum VER_FLG_INFO = 0x4; -enum VER_NDX_LOCAL = 0; -enum VER_NDX_GLOBAL = 1; enum VER_NDX_GIVEN = 2; enum VER_NDX_HIDDEN = 32768; + extern (D) pure @safe { auto VER_NDX(V)(V v) { return v & ~(1u << 15); } } -enum VER_NEED_NONE = 0; -enum VER_NEED_CURRENT = 1; enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; alias VER_NDX VER_NEED_IDX; -/* -enum CA_SUNW_NULL = 0; -enum CA_SUNW_HW_1 = 1; -enum CA_SUNW_SF_1 = 2; -*/ - enum VERSYM_HIDDEN = 0x8000; enum VERSYM_VERSION = 0x7fff; enum ELF_VER_CHR = '@'; - -enum SYMINFO_BT_SELF = 0xffff; -enum SYMINFO_BT_PARENT = 0xfffe; -//enum SYMINFO_BT_NONE = 0xfffd; -//enum SYMINFO_BT_EXTERN = 0xfffc; -enum SYMINFO_BT_LOWRESERVE = 0xff00; - -enum SYMINFO_FLG_DIRECT = 0x0001; -enum SYMINFO_FLG_PASSTHRU = 0x0002; -enum SYMINFO_FLG_COPY = 0x0004; -enum SYMINFO_FLG_LAZYLOAD = 0x0008; -//enum SYMINFO_FLG_DIRECTBIND = 0x0010; -//enum SYMINFO_FLG_NOEXTDIRECT = 0x0020; -//enum SYMINFO_FLG_FILTER = 0x0002; -//enum SYMINFO_FLG_AUXILIARY = 0x0040; - -enum SYMINFO_NONE = 0; -enum SYMINFO_CURRENT = 1; -enum SYMINFO_NUM = 2; - -enum GRP_COMDAT = 0x1; - -enum R_386_NONE = 0; -enum R_386_32 = 1; -enum R_386_PC32 = 2; -enum R_386_GOT32 = 3; -enum R_386_PLT32 = 4; -enum R_386_COPY = 5; -enum R_386_GLOB_DAT = 6; -enum R_386_JMP_SLOT = 7; -enum R_386_RELATIVE = 8; -enum R_386_GOTOFF = 9; -enum R_386_GOTPC = 10; -enum R_386_TLS_TPOFF = 14; -enum R_386_TLS_IE = 15; -enum R_386_TLS_GOTIE = 16; -enum R_386_TLS_LE = 17; -enum R_386_TLS_GD = 18; -enum R_386_TLS_LDM = 19; -enum R_386_TLS_GD_32 = 24; -enum R_386_TLS_GD_PUSH = 25; -enum R_386_TLS_GD_CALL = 26; -enum R_386_TLS_GD_POP = 27; -enum R_386_TLS_LDM_32 = 28; -enum R_386_TLS_LDM_PUSH = 29; -enum R_386_TLS_LDM_CALL = 30; -enum R_386_TLS_LDM_POP = 31; -enum R_386_TLS_LDO_32 = 32; -enum R_386_TLS_IE_32 = 33; -enum R_386_TLS_LE_32 = 34; -enum R_386_TLS_DTPMOD32 = 35; -enum R_386_TLS_DTPOFF32 = 36; -enum R_386_TLS_TPOFF32 = 37; -enum R_386_IRELATIVE = 42; - -enum R_X86_64_NONE = 0; -enum R_X86_64_64 = 1; -enum R_X86_64_PC32 = 2; -enum R_X86_64_GOT32 = 3; -enum R_X86_64_PLT32 = 4; -enum R_X86_64_COPY = 5; -enum R_X86_64_GLOB_DAT = 6; -enum R_X86_64_JMP_SLOT = 7; -enum R_X86_64_RELATIVE = 8; -enum R_X86_64_GOTPCREL = 9; -enum R_X86_64_32 = 10; -enum R_X86_64_32S = 11; -enum R_X86_64_16 = 12; -enum R_X86_64_PC16 = 13; -enum R_X86_64_8 = 14; -enum R_X86_64_PC8 = 15; -enum R_X86_64_DTPMOD64 = 16; -enum R_X86_64_DTPOFF64 = 17; -enum R_X86_64_TPOFF64 = 18; -enum R_X86_64_TLSGD = 19; -enum R_X86_64_TLSLD = 20; -enum R_X86_64_DTPOFF32 = 21; -enum R_X86_64_GOTTPOFF = 22; -enum R_X86_64_TPOFF32 = 23; -enum R_X86_64_IRELATIVE = 37; diff --git a/libphobos/libdruntime/core/sys/elf/package.d b/libphobos/libdruntime/core/sys/elf/package.d new file mode 100644 index 0000000..2dcfd20 --- /dev/null +++ b/libphobos/libdruntime/core/sys/elf/package.d @@ -0,0 +1,2575 @@ +/** + * D header file for standard ELF types, structures, and macros. + * + * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=elf/elf.h, glibc elf/elf.h) + */ +module core.sys.elf; + +extern (C): +pure: +nothrow: +@system: + +import core.stdc.stdint; + +alias uint16_t Elf32_Half; +alias uint16_t Elf64_Half; + +alias uint32_t Elf32_Word; +alias int32_t Elf32_Sword; +alias uint32_t Elf64_Word; +alias int32_t Elf64_Sword; + +alias uint64_t Elf32_Xword; +alias int64_t Elf32_Sxword; +alias uint64_t Elf64_Xword; +alias int64_t Elf64_Sxword; + +alias uint32_t Elf32_Addr; +alias uint64_t Elf64_Addr; + +alias uint32_t Elf32_Off; +alias uint64_t Elf64_Off; + +alias uint16_t Elf32_Section; +alias uint16_t Elf64_Section; + +alias Elf32_Half Elf32_Versym; +alias Elf64_Half Elf64_Versym; + +enum EI_NIDENT = 16; + +struct Elf32_Ehdr +{ + char[EI_NIDENT] e_ident = 0; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} + +struct Elf64_Ehdr +{ + char[EI_NIDENT] e_ident = 0; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} + +enum EI_MAG0 = 0; +enum ELFMAG0 = 0x7f; + +enum EI_MAG1 = 1; +enum ELFMAG1 = 'E'; + +enum EI_MAG2 = 2; +enum ELFMAG2 = 'L'; + +enum EI_MAG3 = 3; +enum ELFMAG3 = 'F'; +enum ELFMAG = "\177ELF"; +enum SELFMAG = 4; + +enum EI_CLASS = 4; +enum ELFCLASSNONE = 0; +enum ELFCLASS32 = 1; +enum ELFCLASS64 = 2; +enum ELFCLASSNUM = 3; + +enum EI_DATA = 5; +enum ELFDATANONE = 0; +enum ELFDATA2LSB = 1; +enum ELFDATA2MSB = 2; +enum ELFDATANUM = 3; + +enum EI_VERSION = 6; + +enum EI_OSABI = 7; +enum ELFOSABI_NONE = 0; +enum ELFOSABI_SYSV = 0; +enum ELFOSABI_HPUX = 1; +enum ELFOSABI_NETBSD = 2; +enum ELFOSABI_GNU = 3; +enum ELFOSABI_LINUX = ELFOSABI_GNU; +enum ELFOSABI_HURD = 4; +enum ELFOSABI_86OPEN = 5; +enum ELFOSABI_SOLARIS = 6; +enum ELFOSABI_AIX = 7; +enum ELFOSABI_MONTEREY = 7; +enum ELFOSABI_IRIX = 8; +enum ELFOSABI_FREEBSD = 9; +enum ELFOSABI_TRU64 = 10; +enum ELFOSABI_MODESTO = 11; +enum ELFOSABI_OPENBSD = 12; +enum ELFOSABI_OPENVMS = 13; +enum ELFOSABI_NSK = 14; +enum ELFOSABI_AROS = 15; +enum ELFOSABI_ARM_AEABI = 64; +enum ELFOSABI_ARM = 97; +enum ELFOSABI_STANDALONE = 255; +enum ELFOSABI_DRAGONFLYBSD = ELFOSABI_NONE; + +enum EI_ABIVERSION = 8; + +enum EI_PAD = 9; + +enum ET_NONE = 0; +enum ET_REL = 1; +enum ET_EXEC = 2; +enum ET_DYN = 3; +enum ET_CORE = 4; +enum ET_NUM = 5; +enum ET_LOOS = 0xfe00; +enum ET_HIOS = 0xfeff; +enum ET_LOPROC = 0xff00; +enum ET_HIPROC = 0xffff; + +enum EM_NONE = 0; +enum EM_M32 = 1; +enum EM_SPARC = 2; +enum EM_386 = 3; +enum EM_68K = 4; +enum EM_88K = 5; +enum EM_860 = 7; +enum EM_MIPS = 8; +enum EM_S370 = 9; +enum EM_MIPS_RS3_LE = 10; + +enum EM_PARISC = 15; +enum EM_VPP500 = 17; +enum EM_SPARC32PLUS = 18; +enum EM_960 = 19; +enum EM_PPC = 20; +enum EM_PPC64 = 21; +enum EM_S390 = 22; + +enum EM_V800 = 36; +enum EM_FR20 = 37; +enum EM_RH32 = 38; +enum EM_RCE = 39; +enum EM_ARM = 40; +enum EM_FAKE_ALPHA = 41; +enum EM_SH = 42; +enum EM_SPARCV9 = 43; +enum EM_TRICORE = 44; +enum EM_ARC = 45; +enum EM_H8_300 = 46; +enum EM_H8_300H = 47; +enum EM_H8S = 48; +enum EM_H8_500 = 49; +enum EM_IA_64 = 50; +enum EM_MIPS_X = 51; +enum EM_COLDFIRE = 52; +enum EM_68HC12 = 53; +enum EM_MMA = 54; +enum EM_PCP = 55; +enum EM_NCPU = 56; +enum EM_NDR1 = 57; +enum EM_STARCORE = 58; +enum EM_ME16 = 59; +enum EM_ST100 = 60; +enum EM_TINYJ = 61; +enum EM_X86_64 = 62; +enum EM_PDSP = 63; + +enum EM_FX66 = 66; +enum EM_ST9PLUS = 67; +enum EM_ST7 = 68; +enum EM_68HC16 = 69; +enum EM_68HC11 = 70; +enum EM_68HC08 = 71; +enum EM_68HC05 = 72; +enum EM_SVX = 73; +enum EM_ST19 = 74; +enum EM_VAX = 75; +enum EM_CRIS = 76; +enum EM_JAVELIN = 77; +enum EM_FIREPATH = 78; +enum EM_ZSP = 79; +enum EM_MMIX = 80; +enum EM_HUANY = 81; +enum EM_PRISM = 82; +enum EM_AVR = 83; +enum EM_FR30 = 84; +enum EM_D10V = 85; +enum EM_D30V = 86; +enum EM_V850 = 87; +enum EM_M32R = 88; +enum EM_MN10300 = 89; +enum EM_MN10200 = 90; +enum EM_PJ = 91; +enum EM_OPENRISC = 92; +enum EM_ARC_A5 = 93; +enum EM_XTENSA = 94; +enum EM_VIDEOCORE = 95; +enum EM_TMM_GPP = 96; +enum EM_NS32K = 97; +enum EM_TPC = 98; +enum EM_SNP1K = 99; +enum EM_ST200 = 100; +enum EM_IP2K = 101; +enum EM_MAX = 102; +enum EM_CR = 103; +enum EM_F2MC16 = 104; +enum EM_MSP430 = 105; +enum EM_BLACKFIN = 106; +enum EM_SE_C33 = 107; +enum EM_SEP = 108; +enum EM_ARCA = 109; +enum EM_UNICORE = 110; +enum EM_DXP = 112; +enum EM_ALTERA_NIOS2 = 113; +enum EM_CRX = 114; +enum EM_XGATE = 115; +enum EM_C166 = 116; +enum EM_M16C = 117; +enum EM_DSPIC30F = 118; +enum EM_CE = 119; +enum EM_M32C = 120; +enum EM_res121 = 121; +enum EM_res122 = 122; +enum EM_res123 = 123; +enum EM_res124 = 124; +enum EM_res125 = 125; +enum EM_res126 = 126; +enum EM_res127 = 127; +enum EM_res128 = 128; +enum EM_res129 = 129; +enum EM_res130 = 130; +enum EM_TSK3000 = 131; +enum EM_RS08 = 132; +enum EM_res133 = 133; +enum EM_ECOG2 = 134; +enum EM_SCORE = 135; +enum EM_SCORE7 = 135; +enum EM_DSP24 = 136; +enum EM_VIDEOCORE3 = 137; +enum EM_LATTICEMICO32 = 138; +enum EM_SE_C17 = 139; +enum EM_TI_C6000 = 140; +enum EM_TI_C2000 = 141; +enum EM_TI_C5500 = 142; +enum EM_TI_ARP32 = 143; +enum EM_TI_PRU = 144; +enum EM_MMDSP_PLUS = 160; +enum EM_CYPRESS_M8C = 161; +enum EM_R32C = 162; +enum EM_TRIMEDIA = 163; +enum EM_QDSP6 = 164; +enum EM_8051 = 165; +enum EM_STXP7X = 166; +enum EM_NDS32 = 167; +enum EM_ECOG1 = 168; +enum EM_ECOG1X = 168; +enum EM_MAXQ30 = 169; +enum EM_XIMO16 = 170; +enum EM_MANIK = 171; +enum EM_CRAYNV2 = 172; +enum EM_RX = 173; +enum EM_METAG = 174; +enum EM_MCST_ELBRUS = 175; +enum EM_ECOG16 = 176; +enum EM_CR16 = 177; +enum EM_ETPU = 178; +enum EM_SLE9X = 179; +enum EM_L1OM = 180; +enum EM_K1OM = 181; +enum EM_INTEL182 = 182; +enum EM_AARCH64 = 183; +enum EM_AVR32 = 185; +enum EM_STM8 = 186; +enum EM_TILE64 = 187; +enum EM_TILEPRO = 188; +enum EM_MICROBLAZE = 189; +enum EM_CUDA = 190; +enum EM_TILEGX = 191; +enum EM_CLOUDSHIELD = 192; +enum EM_COREA_1ST = 193; +enum EM_COREA_2ND = 194; +enum EM_ARCV2 = 195; +enum EM_OPEN8 = 196; +enum EM_RL78 = 197; +enum EM_VIDEOCORE5 = 198; +enum EM_78KOR = 199; +enum EM_56800EX = 200; +enum EM_BA1 = 201; +enum EM_BA2 = 202; +enum EM_XCORE = 203; +enum EM_MCHP_PIC = 204; +enum EM_INTELGT = 205; + +enum EM_KM32 = 210; +enum EM_KMX32 = 211; +enum EM_EMX16 = 212; +enum EM_EMX8 = 213; +enum EM_KVARC = 214; +enum EM_CDP = 215; +enum EM_COGE = 216; +enum EM_COOL = 217; +enum EM_NORC = 218; +enum EM_CSR_KALIMBA = 219; +enum EM_Z80 = 220; +enum EM_VISIUM = 221; +enum EM_FT32 = 222; +enum EM_MOXIE = 223; +enum EM_AMDGPU = 224; + +enum EM_RISCV = 243; + +enum EM_BPF = 247; +enum EM_CSKY = 252; + +enum EM_NUM = 253; + +enum EM_ALPHA = 0x9026; + +enum EV_NONE = 0; +enum EV_CURRENT = 1; +enum EV_NUM = 2; + +struct Elf32_Shdr +{ + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} + +struct Elf64_Shdr +{ + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} + +enum SHN_UNDEF = 0; +enum SHN_LORESERVE = 0xff00; +enum SHN_LOPROC = 0xff00; +enum SHN_BEFORE = 0xff00; +enum SHN_AFTER = 0xff01; +enum SHN_HIPROC = 0xff1f; +enum SHN_LOOS = 0xff20; +enum SHN_HIOS = 0xff3f; +enum SHN_ABS = 0xfff1; +enum SHN_COMMON = 0xfff2; +enum SHN_XINDEX = 0xffff; +enum SHN_HIRESERVE = 0xffff; + +enum SHT_NULL = 0; +enum SHT_PROGBITS = 1; +enum SHT_SYMTAB = 2; +enum SHT_STRTAB = 3; +enum SHT_RELA = 4; +enum SHT_HASH = 5; +enum SHT_DYNAMIC = 6; +enum SHT_NOTE = 7; +enum SHT_NOBITS = 8; +enum SHT_REL = 9; +enum SHT_SHLIB = 10; +enum SHT_DYNSYM = 11; +enum SHT_INIT_ARRAY = 14; +enum SHT_FINI_ARRAY = 15; +enum SHT_PREINIT_ARRAY = 16; +enum SHT_GROUP = 17; +enum SHT_SYMTAB_SHNDX = 18; +enum SHT_NUM = 19; +enum SHT_LOOS = 0x60000000; +enum SHT_GNU_ATTRIBUTES = 0x6ffffff5; +enum SHT_GNU_HASH = 0x6ffffff6; +enum SHT_GNU_LIBLIST = 0x6ffffff7; +enum SHT_CHECKSUM = 0x6ffffff8; +enum SHT_LOSUNW = 0x6ffffffa; +enum SHT_SUNW_move = 0x6ffffffa; +enum SHT_SUNW_COMDAT = 0x6ffffffb; +enum SHT_SUNW_syminfo = 0x6ffffffc; +enum SHT_GNU_verdef = 0x6ffffffd; +enum SHT_GNU_verneed = 0x6ffffffe; +enum SHT_GNU_versym = 0x6fffffff; +enum SHT_HISUNW = 0x6fffffff; +enum SHT_HIOS = 0x6fffffff; +enum SHT_LOPROC = 0x70000000; +enum SHT_HIPROC = 0x7fffffff; +enum SHT_LOUSER = 0x80000000; +enum SHT_HIUSER = 0x8fffffff; + +enum SHF_WRITE = (1 << 0); +enum SHF_ALLOC = (1 << 1); +enum SHF_EXECINSTR = (1 << 2); +enum SHF_MERGE = (1 << 4); +enum SHF_STRINGS = (1 << 5); +enum SHF_INFO_LINK = (1 << 6); +enum SHF_LINK_ORDER = (1 << 7); +enum SHF_OS_NONCONFORMING = (1 << 8); +enum SHF_GROUP = (1 << 9); +enum SHF_TLS = (1 << 10); +enum SHF_COMPRESSED = (1 << 11); +enum SHF_MASKOS = 0x0ff00000; +enum SHF_MASKPROC = 0xf0000000; +enum SHF_ORDERED = (1 << 30); +enum SHF_EXCLUDE = (1 << 31); +enum GRP_COMDAT = 0x1; + +struct Elf32_Sym +{ + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + ubyte st_info; + ubyte st_other; + Elf32_Section st_shndx; +} + +struct Elf64_Sym +{ + Elf64_Word st_name; + ubyte st_info; + ubyte st_other; + Elf64_Section st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} + +struct Elf32_Syminfo +{ + Elf32_Half si_boundto; + Elf32_Half si_flags; +} + +struct Elf64_Syminfo +{ + Elf64_Half si_boundto; + Elf64_Half si_flags; +} + +enum SYMINFO_BT_SELF = 0xffff; +enum SYMINFO_BT_PARENT = 0xfffe; +enum SYMINFO_BT_LOWRESERVE = 0xff00; + +enum SYMINFO_FLG_DIRECT = 0x0001; +enum SYMINFO_FLG_PASSTHRU = 0x0002; +enum SYMINFO_FLG_COPY = 0x0004; +enum SYMINFO_FLG_LAZYLOAD = 0x0008; + +enum SYMINFO_NONE = 0; +enum SYMINFO_CURRENT = 1; +enum SYMINFO_NUM = 2; + +extern (D) +{ + auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } + auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; } + auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } + alias ELF32_ST_BIND ELF64_ST_BIND; + alias ELF32_ST_TYPE ELF64_ST_TYPE; + alias ELF32_ST_INFO ELF64_ST_INFO; +} + +enum STB_LOCAL = 0; +enum STB_GLOBAL = 1; +enum STB_WEAK = 2; +enum STB_NUM = 3; +enum STB_LOOS = 10; +enum STB_GNU_UNIQUE = 10; +enum STB_HIOS = 12; +enum STB_LOPROC = 13; +enum STB_HIPROC = 15; + +enum STT_NOTYPE = 0; +enum STT_OBJECT = 1; +enum STT_FUNC = 2; +enum STT_SECTION = 3; +enum STT_FILE = 4; +enum STT_COMMON = 5; +enum STT_TLS = 6; +enum STT_NUM = 7; +enum STT_LOOS = 10; +enum STT_GNU_IFUNC = 10; +enum STT_HIOS = 12; +enum STT_LOPROC = 13; +enum STT_HIPROC = 15; + +enum STN_UNDEF = 0; + +enum STV_DEFAULT = 0; +enum STV_INTERNAL = 1; +enum STV_HIDDEN = 2; +enum STV_PROTECTED = 3; + +struct Elf32_Rel +{ + Elf32_Addr r_offset; + Elf32_Word r_info; +} + +struct Elf64_Rel +{ + Elf64_Addr r_offset; + Elf64_Xword r_info; +} + +struct Elf32_Rela +{ + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} + +struct Elf64_Rela +{ + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +} + +extern (D) +{ + auto ELF32_R_SYM(V)(V val) { return val >> 8; } + auto ELF32_R_TYPE(V)(V val) { return val & 0xff; } + auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); } + + auto ELF64_R_SYM(I)(I i) { return i >> 32; } + auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; } + auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); } +} + +struct Elf32_Phdr +{ + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} + +struct Elf64_Phdr +{ + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} + +enum PN_XNUM = 0xffff; + +enum PT_NULL = 0; +enum PT_LOAD = 1; +enum PT_DYNAMIC = 2; +enum PT_INTERP = 3; +enum PT_NOTE = 4; +enum PT_SHLIB = 5; +enum PT_PHDR = 6; +enum PT_TLS = 7; +enum PT_NUM = 8; +enum PT_LOOS = 0x60000000; +enum PT_GNU_EH_FRAME = 0x6474e550; +enum PT_GNU_STACK = 0x6474e551; +enum PT_GNU_RELRO = 0x6474e552; +enum PT_LOSUNW = 0x6ffffffa; +enum PT_SUNWBSS = 0x6ffffffa; +enum PT_SUNWSTACK = 0x6ffffffb; +enum PT_HISUNW = 0x6fffffff; +enum PT_HIOS = 0x6fffffff; +enum PT_LOPROC = 0x70000000; +enum PT_HIPROC = 0x7fffffff; + +enum PF_X = (1 << 0); +enum PF_W = (1 << 1); +enum PF_R = (1 << 2); +enum PF_MASKOS = 0x0ff00000; +enum PF_MASKPROC = 0xf0000000; + +enum DT_NULL = 0; +enum DT_NEEDED = 1; +enum DT_PLTRELSZ = 2; +enum DT_PLTGOT = 3; +enum DT_HASH = 4; +enum DT_STRTAB = 5; +enum DT_SYMTAB = 6; +enum DT_RELA = 7; +enum DT_RELASZ = 8; +enum DT_RELAENT = 9; +enum DT_STRSZ = 10; +enum DT_SYMENT = 11; +enum DT_INIT = 12; +enum DT_FINI = 13; +enum DT_SONAME = 14; +enum DT_RPATH = 15; +enum DT_SYMBOLIC = 16; +enum DT_REL = 17; +enum DT_RELSZ = 18; +enum DT_RELENT = 19; +enum DT_PLTREL = 20; +enum DT_DEBUG = 21; +enum DT_TEXTREL = 22; +enum DT_JMPREL = 23; +enum DT_BIND_NOW = 24; +enum DT_INIT_ARRAY = 25; +enum DT_FINI_ARRAY = 26; +enum DT_INIT_ARRAYSZ = 27; +enum DT_FINI_ARRAYSZ = 28; +enum DT_RUNPATH = 29; +enum DT_FLAGS = 30; +enum DT_ENCODING = 32; +enum DT_PREINIT_ARRAY = 32; +enum DT_PREINIT_ARRAYSZ = 33; +enum DT_NUM = 34; +enum DT_LOOS = 0x6000000d; +enum DT_HIOS = 0x6ffff000; +enum DT_LOPROC = 0x70000000; +enum DT_HIPROC = 0x7fffffff; +enum DT_PROCNUM = DT_MIPS_NUM; +enum DT_VALRNGLO = 0x6ffffd00; +enum DT_GNU_PRELINKED = 0x6ffffdf5; +enum DT_GNU_CONFLICTSZ = 0x6ffffdf6; +enum DT_GNU_LIBLISTSZ = 0x6ffffdf7; +enum DT_CHECKSUM = 0x6ffffdf8; +enum DT_PLTPADSZ = 0x6ffffdf9; +enum DT_MOVEENT = 0x6ffffdfa; +enum DT_MOVESZ = 0x6ffffdfb; +enum DT_FEATURE_1 = 0x6ffffdfc; +enum DT_POSFLAG_1 = 0x6ffffdfd; +enum DT_SYMINSZ = 0x6ffffdfe; +enum DT_SYMINENT = 0x6ffffdff; +enum DT_VALRNGHI = 0x6ffffdff; +extern (D) auto DT_VALTAGIDX(T)(T tag) +{ + return DT_VALRNGHI - tag; +} +enum DT_VALNUM = 12; +enum DT_ADDRRNGLO = 0x6ffffe00; +enum DT_GNU_HASH = 0x6ffffef5; +enum DT_TLSDESC_PLT = 0x6ffffef6; +enum DT_TLSDESC_GOT = 0x6ffffef7; +enum DT_GNU_CONFLICT = 0x6ffffef8; +enum DT_GNU_LIBLIST = 0x6ffffef9; +enum DT_CONFIG = 0x6ffffefa; +enum DT_DEPAUDIT = 0x6ffffefb; +enum DT_AUDIT = 0x6ffffefc; +enum DT_PLTPAD = 0x6ffffefd; +enum DT_MOVETAB = 0x6ffffefe; +enum DT_SYMINFO = 0x6ffffeff; +enum DT_ADDRRNGHI = 0x6ffffeff; +extern (D) auto DT_ADDRTAGIDX(T)(T tag) +{ + return DT_ADDRRNGHI - tag; +} +enum DT_ADDRNUM = 11; +enum DT_VERSYM = 0x6ffffff0; + +enum DT_RELACOUNT = 0x6ffffff9; +enum DT_RELCOUNT = 0x6ffffffa; +enum DT_FLAGS_1 = 0x6ffffffb; +enum DT_VERDEF = 0x6ffffffc; +enum DT_VERDEFNUM = 0x6ffffffd; +enum DT_VERNEED = 0x6ffffffe; +enum DT_VERNEEDNUM = 0x6fffffff; +extern (D) auto DT_VERSIONTAGIDX(T)(T tag) +{ + return DT_VERNEEDNUM - tag; +} +enum DT_VERSIONTAGNUM = 16; +enum DT_AUXILIARY = 0x7ffffffd; +enum DT_FILTER = 0x7fffffff; +extern (D) auto DT_EXTRATAGIDX(T)(T tag) +{ + return cast(Elf32_Word)(-(cast(Elf32_Sword)(tag) <<1>>1)-1); +} +enum DT_EXTRANUM = 3; +enum DF_ORIGIN = 0x00000001; +enum DF_SYMBOLIC = 0x00000002; +enum DF_TEXTREL = 0x00000004; +enum DF_BIND_NOW = 0x00000008; +enum DF_STATIC_TLS = 0x00000010; +enum DF_1_NOW = 0x00000001; +enum DF_1_GLOBAL = 0x00000002; +enum DF_1_GROUP = 0x00000004; +enum DF_1_NODELETE = 0x00000008; +enum DF_1_LOADFLTR = 0x00000010; +enum DF_1_INITFIRST = 0x00000020; +enum DF_1_NOOPEN = 0x00000040; +enum DF_1_ORIGIN = 0x00000080; +enum DF_1_DIRECT = 0x00000100; +enum DF_1_TRANS = 0x00000200; +enum DF_1_INTERPOSE = 0x00000400; +enum DF_1_NODEFLIB = 0x00000800; +enum DF_1_NODUMP = 0x00001000; +enum DF_1_CONFALT = 0x00002000; +enum DF_1_ENDFILTEE = 0x00004000; +enum DF_1_DISPRELDNE = 0x00008000; +enum DF_1_DISPRELPND = 0x00010000; +enum DF_1_NODIRECT = 0x00020000; +enum DF_1_IGNMULDEF = 0x00040000; +enum DF_1_NOKSYMS = 0x00080000; +enum DF_1_NOHDR = 0x00100000; +enum DF_1_EDITED = 0x00200000; +enum DF_1_NORELOC = 0x00400000; +enum DF_1_SYMINTPOSE = 0x00800000; +enum DF_1_GLOBAUDIT = 0x01000000; +enum DF_1_SINGLETON = 0x02000000; +enum DTF_1_PARINIT = 0x00000001; +enum DTF_1_CONFEXP = 0x00000002; +enum DF_P1_LAZYLOAD = 0x00000001; +enum DF_P1_GROUPPERM = 0x00000002; + +struct Elf32_Verdef +{ + Elf32_Half vd_version; + Elf32_Half vd_flags; + Elf32_Half vd_ndx; + Elf32_Half vd_cnt; + Elf32_Word vd_hash; + Elf32_Word vd_aux; + Elf32_Word vd_next; +} + +struct Elf64_Verdef +{ + Elf64_Half vd_version; + Elf64_Half vd_flags; + Elf64_Half vd_ndx; + Elf64_Half vd_cnt; + Elf64_Word vd_hash; + Elf64_Word vd_aux; + Elf64_Word vd_next; +} +enum VER_DEF_NONE = 0; +enum VER_DEF_CURRENT = 1; +enum VER_DEF_NUM = 2; +enum VER_FLG_BASE = 0x1; +enum VER_FLG_WEAK = 0x2; +enum VER_NDX_LOCAL = 0; +enum VER_NDX_GLOBAL = 1; +enum VER_NDX_LORESERVE = 0xff00; +enum VER_NDX_ELIMINATE = 0xff01; + +struct Elf32_Verdaux +{ + Elf32_Word vda_name; + Elf32_Word vda_next; +} + +struct Elf64_Verdaux +{ + Elf64_Word vda_name; + Elf64_Word vda_next; +} + +struct Elf32_Verneed +{ + Elf32_Half vn_version; + Elf32_Half vn_cnt; + Elf32_Word vn_file; + Elf32_Word vn_aux; + Elf32_Word vn_next; +} + +struct Elf64_Verneed +{ + Elf64_Half vn_version; + Elf64_Half vn_cnt; + Elf64_Word vn_file; + Elf64_Word vn_aux; + Elf64_Word vn_next; +} +enum VER_NEED_NONE = 0; +enum VER_NEED_CURRENT = 1; +enum VER_NEED_NUM = 2; + +struct Elf32_Vernaux +{ + Elf32_Word vna_hash; + Elf32_Half vna_flags; + Elf32_Half vna_other; + Elf32_Word vna_name; + Elf32_Word vna_next; +} + +struct Elf64_Vernaux +{ + Elf64_Word vna_hash; + Elf64_Half vna_flags; + Elf64_Half vna_other; + Elf64_Word vna_name; + Elf64_Word vna_next; +} + +enum ELF_NOTE_SOLARIS = "SUNW Solaris"; +enum ELF_NOTE_GNU = "GNU"; +enum ELF_NOTE_PAGESIZE_HINT = 1; +enum ELF_NOTE_ABI = 1; +enum ELF_NOTE_OS_LINUX = 0; +enum ELF_NOTE_OS_GNU = 1; +enum ELF_NOTE_OS_SOLARIS2 = 2; +enum ELF_NOTE_OS_FREEBSD = 3; + +struct Elf32_Move +{ + Elf32_Xword m_value; + Elf32_Word m_info; + Elf32_Word m_poffset; + Elf32_Half m_repeat; + Elf32_Half m_stride; +} + +struct Elf64_Move +{ + Elf64_Xword m_value; + Elf64_Xword m_info; + Elf64_Xword m_poffset; + Elf64_Half m_repeat; + Elf64_Half m_stride; +} +extern (D) +{ + auto ELF32_M_SYM(I)(I info) { return info >> 8; } + auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; } + auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } +} + +alias ELF32_M_SYM ELF64_M_SYM; +alias ELF32_M_SIZE ELF64_M_SIZE; +alias ELF32_M_INFO ELF64_M_INFO; +enum EF_CPU32 = 0x00810000; + +enum R_68K_NONE = 0; +enum R_68K_32 = 1; +enum R_68K_16 = 2; +enum R_68K_8 = 3; +enum R_68K_PC32 = 4; +enum R_68K_PC16 = 5; +enum R_68K_PC8 = 6; +enum R_68K_GOT32 = 7; +enum R_68K_GOT16 = 8; +enum R_68K_GOT8 = 9; +enum R_68K_GOT32O = 10; +enum R_68K_GOT16O = 11; +enum R_68K_GOT8O = 12; +enum R_68K_PLT32 = 13; +enum R_68K_PLT16 = 14; +enum R_68K_PLT8 = 15; +enum R_68K_PLT32O = 16; +enum R_68K_PLT16O = 17; +enum R_68K_PLT8O = 18; +enum R_68K_COPY = 19; +enum R_68K_GLOB_DAT = 20; +enum R_68K_JMP_SLOT = 21; +enum R_68K_RELATIVE = 22; +enum R_68K_TLS_GD32 = 25; +enum R_68K_TLS_GD16 = 26; +enum R_68K_TLS_GD8 = 27; +enum R_68K_TLS_LDM32 = 28; +enum R_68K_TLS_LDM16 = 29; +enum R_68K_TLS_LDM8 = 30; +enum R_68K_TLS_LDO32 = 31; +enum R_68K_TLS_LDO16 = 32; +enum R_68K_TLS_LDO8 = 33; +enum R_68K_TLS_IE32 = 34; +enum R_68K_TLS_IE16 = 35; +enum R_68K_TLS_IE8 = 36; +enum R_68K_TLS_LE32 = 37; +enum R_68K_TLS_LE16 = 38; +enum R_68K_TLS_LE8 = 39; +enum R_68K_TLS_DTPMOD32 = 40; +enum R_68K_TLS_DTPREL32 = 41; +enum R_68K_TLS_TPREL32 = 42; +enum R_68K_NUM = 43; + +enum R_386_NONE = 0; +enum R_386_32 = 1; +enum R_386_PC32 = 2; +enum R_386_GOT32 = 3; +enum R_386_PLT32 = 4; +enum R_386_COPY = 5; +enum R_386_GLOB_DAT = 6; +enum R_386_JMP_SLOT = 7; +enum R_386_RELATIVE = 8; +enum R_386_GOTOFF = 9; +enum R_386_GOTPC = 10; +enum R_386_32PLT = 11; +enum R_386_TLS_TPOFF = 14; +enum R_386_TLS_IE = 15; +enum R_386_TLS_GOTIE = 16; +enum R_386_TLS_LE = 17; +enum R_386_TLS_GD = 18; +enum R_386_TLS_LDM = 19; +enum R_386_16 = 20; +enum R_386_PC16 = 21; +enum R_386_8 = 22; +enum R_386_PC8 = 23; +enum R_386_TLS_GD_32 = 24; +enum R_386_TLS_GD_PUSH = 25; +enum R_386_TLS_GD_CALL = 26; +enum R_386_TLS_GD_POP = 27; +enum R_386_TLS_LDM_32 = 28; +enum R_386_TLS_LDM_PUSH = 29; +enum R_386_TLS_LDM_CALL = 30; +enum R_386_TLS_LDM_POP = 31; +enum R_386_TLS_LDO_32 = 32; +enum R_386_TLS_IE_32 = 33; +enum R_386_TLS_LE_32 = 34; +enum R_386_TLS_DTPMOD32 = 35; +enum R_386_TLS_DTPOFF32 = 36; +enum R_386_TLS_TPOFF32 = 37; +enum R_386_SIZE32 = 38; +enum R_386_TLS_GOTDESC = 39; +enum R_386_TLS_DESC_CALL = 40; +enum R_386_TLS_DESC = 41; +enum R_386_IRELATIVE = 42; +enum R_386_NUM = 43; + +enum STT_SPARC_REGISTER = 13; + +enum EF_SPARCV9_MM = 3; +enum EF_SPARCV9_TSO = 0; +enum EF_SPARCV9_PSO = 1; +enum EF_SPARCV9_RMO = 2; +enum EF_SPARC_LEDATA = 0x800000; +enum EF_SPARC_EXT_MASK = 0xFFFF00; +enum EF_SPARC_32PLUS = 0x000100; +enum EF_SPARC_SUN_US1 = 0x000200; +enum EF_SPARC_HAL_R1 = 0x000400; +enum EF_SPARC_SUN_US3 = 0x000800; + +enum R_SPARC_NONE = 0; +enum R_SPARC_8 = 1; +enum R_SPARC_16 = 2; +enum R_SPARC_32 = 3; +enum R_SPARC_DISP8 = 4; +enum R_SPARC_DISP16 = 5; +enum R_SPARC_DISP32 = 6; +enum R_SPARC_WDISP30 = 7; +enum R_SPARC_WDISP22 = 8; +enum R_SPARC_HI22 = 9; +enum R_SPARC_22 = 10; +enum R_SPARC_13 = 11; +enum R_SPARC_LO10 = 12; +enum R_SPARC_GOT10 = 13; +enum R_SPARC_GOT13 = 14; +enum R_SPARC_GOT22 = 15; +enum R_SPARC_PC10 = 16; +enum R_SPARC_PC22 = 17; +enum R_SPARC_WPLT30 = 18; +enum R_SPARC_COPY = 19; +enum R_SPARC_GLOB_DAT = 20; +enum R_SPARC_JMP_SLOT = 21; +enum R_SPARC_RELATIVE = 22; +enum R_SPARC_UA32 = 23; + +enum R_SPARC_PLT32 = 24; +enum R_SPARC_HIPLT22 = 25; +enum R_SPARC_LOPLT10 = 26; +enum R_SPARC_PCPLT32 = 27; +enum R_SPARC_PCPLT22 = 28; +enum R_SPARC_PCPLT10 = 29; +enum R_SPARC_10 = 30; +enum R_SPARC_11 = 31; +enum R_SPARC_64 = 32; +enum R_SPARC_OLO10 = 33; +enum R_SPARC_HH22 = 34; +enum R_SPARC_HM10 = 35; +enum R_SPARC_LM22 = 36; +enum R_SPARC_PC_HH22 = 37; +enum R_SPARC_PC_HM10 = 38; +enum R_SPARC_PC_LM22 = 39; +enum R_SPARC_WDISP16 = 40; +enum R_SPARC_WDISP19 = 41; +enum R_SPARC_GLOB_JMP = 42; +enum R_SPARC_7 = 43; +enum R_SPARC_5 = 44; +enum R_SPARC_6 = 45; +enum R_SPARC_DISP64 = 46; +enum R_SPARC_PLT64 = 47; +enum R_SPARC_HIX22 = 48; +enum R_SPARC_LOX10 = 49; +enum R_SPARC_H44 = 50; +enum R_SPARC_M44 = 51; +enum R_SPARC_L44 = 52; +enum R_SPARC_REGISTER = 53; +enum R_SPARC_UA64 = 54; +enum R_SPARC_UA16 = 55; +enum R_SPARC_TLS_GD_HI22 = 56; +enum R_SPARC_TLS_GD_LO10 = 57; +enum R_SPARC_TLS_GD_ADD = 58; +enum R_SPARC_TLS_GD_CALL = 59; +enum R_SPARC_TLS_LDM_HI22 = 60; +enum R_SPARC_TLS_LDM_LO10 = 61; +enum R_SPARC_TLS_LDM_ADD = 62; +enum R_SPARC_TLS_LDM_CALL = 63; +enum R_SPARC_TLS_LDO_HIX22 = 64; +enum R_SPARC_TLS_LDO_LOX10 = 65; +enum R_SPARC_TLS_LDO_ADD = 66; +enum R_SPARC_TLS_IE_HI22 = 67; +enum R_SPARC_TLS_IE_LO10 = 68; +enum R_SPARC_TLS_IE_LD = 69; +enum R_SPARC_TLS_IE_LDX = 70; +enum R_SPARC_TLS_IE_ADD = 71; +enum R_SPARC_TLS_LE_HIX22 = 72; +enum R_SPARC_TLS_LE_LOX10 = 73; +enum R_SPARC_TLS_DTPMOD32 = 74; +enum R_SPARC_TLS_DTPMOD64 = 75; +enum R_SPARC_TLS_DTPOFF32 = 76; +enum R_SPARC_TLS_DTPOFF64 = 77; +enum R_SPARC_TLS_TPOFF32 = 78; +enum R_SPARC_TLS_TPOFF64 = 79; +enum R_SPARC_GOTDATA_HIX22 = 80; +enum R_SPARC_GOTDATA_LOX10 = 81; +enum R_SPARC_GOTDATA_OP_HIX22 = 82; +enum R_SPARC_GOTDATA_OP_LOX10 = 83; +enum R_SPARC_GOTDATA_OP = 84; +enum R_SPARC_H34 = 85; +enum R_SPARC_SIZE32 = 86; +enum R_SPARC_SIZE64 = 87; +enum R_SPARC_WDISP10 = 88; +enum R_SPARC_JMP_IREL = 248; +enum R_SPARC_IRELATIVE = 249; +enum R_SPARC_GNU_VTINHERIT = 250; +enum R_SPARC_GNU_VTENTRY = 251; +enum R_SPARC_REV32 = 252; +enum R_SPARC_NUM = 253; + +enum DT_SPARC_REGISTER = 0x70000001; +enum DT_SPARC_NUM = 2; + +enum EF_MIPS_NOREORDER = 1; +enum EF_MIPS_PIC = 2; +enum EF_MIPS_CPIC = 4; +enum EF_MIPS_XGOT = 8; +enum EF_MIPS_64BIT_WHIRL = 16; +enum EF_MIPS_ABI2 = 32; +enum EF_MIPS_ABI_ON32 = 64; +enum EF_MIPS_ARCH = 0xf0000000; + +enum EF_MIPS_ARCH_1 = 0x00000000; +enum EF_MIPS_ARCH_2 = 0x10000000; +enum EF_MIPS_ARCH_3 = 0x20000000; +enum EF_MIPS_ARCH_4 = 0x30000000; +enum EF_MIPS_ARCH_5 = 0x40000000; +enum EF_MIPS_ARCH_32 = 0x50000000; +enum EF_MIPS_ARCH_64 = 0x60000000; +enum EF_MIPS_ARCH_32R2 = 0x70000000; +enum EF_MIPS_ARCH_64R2 = 0x80000000; + +enum E_MIPS_ARCH_1 = EF_MIPS_ARCH_1; +enum E_MIPS_ARCH_2 = EF_MIPS_ARCH_2; +enum E_MIPS_ARCH_3 = EF_MIPS_ARCH_3; +enum E_MIPS_ARCH_4 = EF_MIPS_ARCH_4; +enum E_MIPS_ARCH_5 = EF_MIPS_ARCH_5; +enum E_MIPS_ARCH_32 = EF_MIPS_ARCH_32; +enum E_MIPS_ARCH_64 = EF_MIPS_ARCH_64; + +enum SHN_MIPS_ACOMMON = 0xff00; +enum SHN_MIPS_TEXT = 0xff01; +enum SHN_MIPS_DATA = 0xff02; +enum SHN_MIPS_SCOMMON = 0xff03; +enum SHN_MIPS_SUNDEFINED = 0xff04; + +enum SHT_MIPS_LIBLIST = 0x70000000; +enum SHT_MIPS_MSYM = 0x70000001; +enum SHT_MIPS_CONFLICT = 0x70000002; +enum SHT_MIPS_GPTAB = 0x70000003; +enum SHT_MIPS_UCODE = 0x70000004; +enum SHT_MIPS_DEBUG = 0x70000005; +enum SHT_MIPS_REGINFO = 0x70000006; +enum SHT_MIPS_PACKAGE = 0x70000007; +enum SHT_MIPS_PACKSYM = 0x70000008; +enum SHT_MIPS_RELD = 0x70000009; +enum SHT_MIPS_IFACE = 0x7000000b; +enum SHT_MIPS_CONTENT = 0x7000000c; +enum SHT_MIPS_OPTIONS = 0x7000000d; +enum SHT_MIPS_SHDR = 0x70000010; +enum SHT_MIPS_FDESC = 0x70000011; +enum SHT_MIPS_EXTSYM = 0x70000012; +enum SHT_MIPS_DENSE = 0x70000013; +enum SHT_MIPS_PDESC = 0x70000014; +enum SHT_MIPS_LOCSYM = 0x70000015; +enum SHT_MIPS_AUXSYM = 0x70000016; +enum SHT_MIPS_OPTSYM = 0x70000017; +enum SHT_MIPS_LOCSTR = 0x70000018; +enum SHT_MIPS_LINE = 0x70000019; +enum SHT_MIPS_RFDESC = 0x7000001a; +enum SHT_MIPS_DELTASYM = 0x7000001b; +enum SHT_MIPS_DELTAINST = 0x7000001c; +enum SHT_MIPS_DELTACLASS = 0x7000001d; +enum SHT_MIPS_DWARF = 0x7000001e; +enum SHT_MIPS_DELTADECL = 0x7000001f; +enum SHT_MIPS_SYMBOL_LIB = 0x70000020; +enum SHT_MIPS_EVENTS = 0x70000021; +enum SHT_MIPS_TRANSLATE = 0x70000022; +enum SHT_MIPS_PIXIE = 0x70000023; +enum SHT_MIPS_XLATE = 0x70000024; +enum SHT_MIPS_XLATE_DEBUG = 0x70000025; +enum SHT_MIPS_WHIRL = 0x70000026; +enum SHT_MIPS_EH_REGION = 0x70000027; +enum SHT_MIPS_XLATE_OLD = 0x70000028; +enum SHT_MIPS_PDR_EXCEPTION = 0x70000029; + +enum SHF_MIPS_GPREL = 0x10000000; +enum SHF_MIPS_MERGE = 0x20000000; +enum SHF_MIPS_ADDR = 0x40000000; +enum SHF_MIPS_STRINGS = 0x80000000; +enum SHF_MIPS_NOSTRIP = 0x08000000; +enum SHF_MIPS_LOCAL = 0x04000000; +enum SHF_MIPS_NAMES = 0x02000000; +enum SHF_MIPS_NODUPE = 0x01000000; +enum STO_MIPS_DEFAULT = 0x0; +enum STO_MIPS_INTERNAL = 0x1; +enum STO_MIPS_HIDDEN = 0x2; +enum STO_MIPS_PROTECTED = 0x3; +enum STO_MIPS_PLT = 0x8; +enum STO_MIPS_SC_ALIGN_UNUSED = 0xff; +enum STB_MIPS_SPLIT_COMMON = 13; + +union Elf32_gptab +{ + struct _gt_header + { + Elf32_Word gt_current_g_value; + Elf32_Word gt_unused; + } _gt_header gt_header; + struct _gt_entry + { + Elf32_Word gt_g_value; + Elf32_Word gt_bytes; + } _gt_entry gt_entry; +} + +struct Elf32_RegInfo +{ + Elf32_Word ri_gprmask; + Elf32_Word[4] ri_cprmask; + Elf32_Sword ri_gp_value; +} + +struct Elf_Options +{ + ubyte kind; + ubyte size; + Elf32_Section section; + Elf32_Word info; +} + +enum ODK_NULL = 0; +enum ODK_REGINFO = 1; +enum ODK_EXCEPTIONS = 2; +enum ODK_PAD = 3; +enum ODK_HWPATCH = 4; +enum ODK_FILL = 5; +enum ODK_TAGS = 6; +enum ODK_HWAND = 7; +enum ODK_HWOR = 8; + +enum OEX_FPU_MIN = 0x1f; +enum OEX_FPU_MAX = 0x1f00; +enum OEX_PAGE0 = 0x10000; +enum OEX_SMM = 0x20000; +enum OEX_FPDBUG = 0x40000; +enum OEX_PRECISEFP = OEX_FPDBUG; +enum OEX_DISMISS = 0x80000; + +enum OEX_FPU_INVAL = 0x10; +enum OEX_FPU_DIV0 = 0x08; +enum OEX_FPU_OFLO = 0x04; +enum OEX_FPU_UFLO = 0x02; +enum OEX_FPU_INEX = 0x01; + +enum OHW_R4KEOP = 0x1; +enum OHW_R8KPFETCH = 0x2; +enum OHW_R5KEOP = 0x4; +enum OHW_R5KCVTL = 0x8; + +enum OPAD_PREFIX = 0x1; +enum OPAD_POSTFIX = 0x2; +enum OPAD_SYMBOL = 0x4; + +struct Elf_Options_Hw +{ + Elf32_Word hwp_flags1; + Elf32_Word hwp_flags2; +} + +enum OHWA0_R4KEOP_CHECKED = 0x00000001; +enum OHWA1_R4KEOP_CLEAN = 0x00000002; + +enum R_MIPS_NONE = 0; +enum R_MIPS_16 = 1; +enum R_MIPS_32 = 2; +enum R_MIPS_REL32 = 3; +enum R_MIPS_26 = 4; +enum R_MIPS_HI16 = 5; +enum R_MIPS_LO16 = 6; +enum R_MIPS_GPREL16 = 7; +enum R_MIPS_LITERAL = 8; +enum R_MIPS_GOT16 = 9; +enum R_MIPS_PC16 = 10; +enum R_MIPS_CALL16 = 11; +enum R_MIPS_GPREL32 = 12; + +enum R_MIPS_SHIFT5 = 16; +enum R_MIPS_SHIFT6 = 17; +enum R_MIPS_64 = 18; +enum R_MIPS_GOT_DISP = 19; +enum R_MIPS_GOT_PAGE = 20; +enum R_MIPS_GOT_OFST = 21; +enum R_MIPS_GOT_HI16 = 22; +enum R_MIPS_GOT_LO16 = 23; +enum R_MIPS_SUB = 24; +enum R_MIPS_INSERT_A = 25; +enum R_MIPS_INSERT_B = 26; +enum R_MIPS_DELETE = 27; +enum R_MIPS_HIGHER = 28; +enum R_MIPS_HIGHEST = 29; +enum R_MIPS_CALL_HI16 = 30; +enum R_MIPS_CALL_LO16 = 31; +enum R_MIPS_SCN_DISP = 32; +enum R_MIPS_REL16 = 33; +enum R_MIPS_ADD_IMMEDIATE = 34; +enum R_MIPS_PJUMP = 35; +enum R_MIPS_RELGOT = 36; +enum R_MIPS_JALR = 37; +enum R_MIPS_TLS_DTPMOD32 = 38; +enum R_MIPS_TLS_DTPREL32 = 39; +enum R_MIPS_TLS_DTPMOD64 = 40; +enum R_MIPS_TLS_DTPREL64 = 41; +enum R_MIPS_TLS_GD = 42; +enum R_MIPS_TLS_LDM = 43; +enum R_MIPS_TLS_DTPREL_HI16 = 44; +enum R_MIPS_TLS_DTPREL_LO16 = 45; +enum R_MIPS_TLS_GOTTPREL = 46; +enum R_MIPS_TLS_TPREL32 = 47; +enum R_MIPS_TLS_TPREL64 = 48; +enum R_MIPS_TLS_TPREL_HI16 = 49; +enum R_MIPS_TLS_TPREL_LO16 = 50; +enum R_MIPS_GLOB_DAT = 51; +enum R_MIPS_COPY = 126; +enum R_MIPS_JUMP_SLOT = 127; +enum R_MIPS_NUM = 128; + +enum PT_MIPS_REGINFO = 0x70000000; +enum PT_MIPS_RTPROC = 0x70000001; +enum PT_MIPS_OPTIONS = 0x70000002; + +enum PF_MIPS_LOCAL = 0x10000000; + +enum DT_MIPS_RLD_VERSION = 0x70000001; +enum DT_MIPS_TIME_STAMP = 0x70000002; +enum DT_MIPS_ICHECKSUM = 0x70000003; +enum DT_MIPS_IVERSION = 0x70000004; +enum DT_MIPS_FLAGS = 0x70000005; +enum DT_MIPS_BASE_ADDRESS = 0x70000006; +enum DT_MIPS_MSYM = 0x70000007; +enum DT_MIPS_CONFLICT = 0x70000008; +enum DT_MIPS_LIBLIST = 0x70000009; +enum DT_MIPS_LOCAL_GOTNO = 0x7000000a; +enum DT_MIPS_CONFLICTNO = 0x7000000b; +enum DT_MIPS_LIBLISTNO = 0x70000010; +enum DT_MIPS_SYMTABNO = 0x70000011; +enum DT_MIPS_UNREFEXTNO = 0x70000012; +enum DT_MIPS_GOTSYM = 0x70000013; +enum DT_MIPS_HIPAGENO = 0x70000014; +enum DT_MIPS_RLD_MAP = 0x70000016; +enum DT_MIPS_DELTA_CLASS = 0x70000017; +enum DT_MIPS_DELTA_CLASS_NO = 0x70000018; +enum DT_MIPS_DELTA_INSTANCE = 0x70000019; +enum DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a; +enum DT_MIPS_DELTA_RELOC = 0x7000001b; +enum DT_MIPS_DELTA_RELOC_NO = 0x7000001c; +enum DT_MIPS_DELTA_SYM = 0x7000001d; +enum DT_MIPS_DELTA_SYM_NO = 0x7000001e; +enum DT_MIPS_DELTA_CLASSSYM = 0x70000020; +enum DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021; +enum DT_MIPS_CXX_FLAGS = 0x70000022; +enum DT_MIPS_PIXIE_INIT = 0x70000023; +enum DT_MIPS_SYMBOL_LIB = 0x70000024; +enum DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025; +enum DT_MIPS_LOCAL_GOTIDX = 0x70000026; +enum DT_MIPS_HIDDEN_GOTIDX = 0x70000027; +enum DT_MIPS_PROTECTED_GOTIDX = 0x70000028; +enum DT_MIPS_OPTIONS = 0x70000029; +enum DT_MIPS_INTERFACE = 0x7000002a; +enum DT_MIPS_DYNSTR_ALIGN = 0x7000002b; +enum DT_MIPS_INTERFACE_SIZE = 0x7000002c; +enum DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d; +enum DT_MIPS_PERF_SUFFIX = 0x7000002e; +enum DT_MIPS_COMPACT_SIZE = 0x7000002f; +enum DT_MIPS_GP_VALUE = 0x70000030; +enum DT_MIPS_AUX_DYNAMIC = 0x70000031; +enum DT_MIPS_PLTGOT = 0x70000032; +enum DT_MIPS_RWPLT = 0x70000034; +enum DT_MIPS_NUM = 0x35; + +enum RHF_NONE = 0; +enum RHF_QUICKSTART = (1 << 0); +enum RHF_NOTPOT = (1 << 1); +enum RHF_NO_LIBRARY_REPLACEMENT = (1 << 2); +enum RHF_NO_MOVE = (1 << 3); +enum RHF_SGI_ONLY = (1 << 4); +enum RHF_GUARANTEE_INIT = (1 << 5); +enum RHF_DELTA_C_PLUS_PLUS = (1 << 6); +enum RHF_GUARANTEE_START_INIT = (1 << 7); +enum RHF_PIXIE = (1 << 8); +enum RHF_DEFAULT_DELAY_LOAD = (1 << 9); +enum RHF_REQUICKSTART = (1 << 10); +enum RHF_REQUICKSTARTED = (1 << 11); +enum RHF_CORD = (1 << 12); +enum RHF_NO_UNRES_UNDEF = (1 << 13); +enum RHF_RLD_ORDER_SAFE = (1 << 14); + +struct Elf32_Lib +{ + Elf32_Word l_name; + Elf32_Word l_time_stamp; + Elf32_Word l_checksum; + Elf32_Word l_version; + Elf32_Word l_flags; +} + +struct Elf64_Lib +{ + Elf64_Word l_name; + Elf64_Word l_time_stamp; + Elf64_Word l_checksum; + Elf64_Word l_version; + Elf64_Word l_flags; +} + +enum LL_NONE = 0; +enum LL_EXACT_MATCH = (1 << 0); +enum LL_IGNORE_INT_VER = (1 << 1); +enum LL_REQUIRE_MINOR = (1 << 2); +enum LL_EXPORTS = (1 << 3); +enum LL_DELAY_LOAD = (1 << 4); +enum LL_DELTA = (1 << 5); + +alias Elf32_Addr Elf32_Conflict; + +enum EF_PARISC_TRAPNIL = 0x00010000; +enum EF_PARISC_EXT = 0x00020000; +enum EF_PARISC_LSB = 0x00040000; +enum EF_PARISC_WIDE = 0x00080000; +enum EF_PARISC_NO_KABP = 0x00100000; +enum EF_PARISC_LAZYSWAP = 0x00400000; +enum EF_PARISC_ARCH = 0x0000ffff; + +enum EFA_PARISC_1_0 = 0x020b; +enum EFA_PARISC_1_1 = 0x0210; +enum EFA_PARISC_2_0 = 0x0214; + +enum SHN_PARISC_ANSI_COMMON = 0xff00; +enum SHN_PARISC_HUGE_COMMON = 0xff01; + +enum SHT_PARISC_EXT = 0x70000000; +enum SHT_PARISC_UNWIND = 0x70000001; +enum SHT_PARISC_DOC = 0x70000002; + +enum SHF_PARISC_SHORT = 0x20000000; +enum SHF_PARISC_HUGE = 0x40000000; +enum SHF_PARISC_SBP = 0x80000000; + +enum STT_PARISC_MILLICODE = 13; + +enum STT_HP_OPAQUE = (STT_LOOS + 0x1); +enum STT_HP_STUB = (STT_LOOS + 0x2); + +enum R_PARISC_NONE = 0; +enum R_PARISC_DIR32 = 1; +enum R_PARISC_DIR21L = 2; +enum R_PARISC_DIR17R = 3; +enum R_PARISC_DIR17F = 4; +enum R_PARISC_DIR14R = 6; +enum R_PARISC_PCREL32 = 9; +enum R_PARISC_PCREL21L = 10; +enum R_PARISC_PCREL17R = 11; +enum R_PARISC_PCREL17F = 12; +enum R_PARISC_PCREL14R = 14; +enum R_PARISC_DPREL21L = 18; +enum R_PARISC_DPREL14R = 22; +enum R_PARISC_GPREL21L = 26; +enum R_PARISC_GPREL14R = 30; +enum R_PARISC_LTOFF21L = 34; +enum R_PARISC_LTOFF14R = 38; +enum R_PARISC_SECREL32 = 41; +enum R_PARISC_SEGBASE = 48; +enum R_PARISC_SEGREL32 = 49; +enum R_PARISC_PLTOFF21L = 50; +enum R_PARISC_PLTOFF14R = 54; +enum R_PARISC_LTOFF_FPTR32 = 57; +enum R_PARISC_LTOFF_FPTR21L = 58; +enum R_PARISC_LTOFF_FPTR14R = 62; +enum R_PARISC_FPTR64 = 64; +enum R_PARISC_PLABEL32 = 65; +enum R_PARISC_PLABEL21L = 66; +enum R_PARISC_PLABEL14R = 70; +enum R_PARISC_PCREL64 = 72; +enum R_PARISC_PCREL22F = 74; +enum R_PARISC_PCREL14WR = 75; +enum R_PARISC_PCREL14DR = 76; +enum R_PARISC_PCREL16F = 77; +enum R_PARISC_PCREL16WF = 78; +enum R_PARISC_PCREL16DF = 79; +enum R_PARISC_DIR64 = 80; +enum R_PARISC_DIR14WR = 83; +enum R_PARISC_DIR14DR = 84; +enum R_PARISC_DIR16F = 85; +enum R_PARISC_DIR16WF = 86; +enum R_PARISC_DIR16DF = 87; +enum R_PARISC_GPREL64 = 88; +enum R_PARISC_GPREL14WR = 91; +enum R_PARISC_GPREL14DR = 92; +enum R_PARISC_GPREL16F = 93; +enum R_PARISC_GPREL16WF = 94; +enum R_PARISC_GPREL16DF = 95; +enum R_PARISC_LTOFF64 = 96; +enum R_PARISC_LTOFF14WR = 99; +enum R_PARISC_LTOFF14DR = 100; +enum R_PARISC_LTOFF16F = 101; +enum R_PARISC_LTOFF16WF = 102; +enum R_PARISC_LTOFF16DF = 103; +enum R_PARISC_SECREL64 = 104; +enum R_PARISC_SEGREL64 = 112; +enum R_PARISC_PLTOFF14WR = 115; +enum R_PARISC_PLTOFF14DR = 116; +enum R_PARISC_PLTOFF16F = 117; +enum R_PARISC_PLTOFF16WF = 118; +enum R_PARISC_PLTOFF16DF = 119; +enum R_PARISC_LTOFF_FPTR64 = 120; +enum R_PARISC_LTOFF_FPTR14WR = 123; +enum R_PARISC_LTOFF_FPTR14DR = 124; +enum R_PARISC_LTOFF_FPTR16F = 125; +enum R_PARISC_LTOFF_FPTR16WF = 126; +enum R_PARISC_LTOFF_FPTR16DF = 127; +enum R_PARISC_LORESERVE = 128; +enum R_PARISC_COPY = 128; +enum R_PARISC_IPLT = 129; +enum R_PARISC_EPLT = 130; +enum R_PARISC_TPREL32 = 153; +enum R_PARISC_TPREL21L = 154; +enum R_PARISC_TPREL14R = 158; +enum R_PARISC_LTOFF_TP21L = 162; +enum R_PARISC_LTOFF_TP14R = 166; +enum R_PARISC_LTOFF_TP14F = 167; +enum R_PARISC_TPREL64 = 216; +enum R_PARISC_TPREL14WR = 219; +enum R_PARISC_TPREL14DR = 220; +enum R_PARISC_TPREL16F = 221; +enum R_PARISC_TPREL16WF = 222; +enum R_PARISC_TPREL16DF = 223; +enum R_PARISC_LTOFF_TP64 = 224; +enum R_PARISC_LTOFF_TP14WR = 227; +enum R_PARISC_LTOFF_TP14DR = 228; +enum R_PARISC_LTOFF_TP16F = 229; +enum R_PARISC_LTOFF_TP16WF = 230; +enum R_PARISC_LTOFF_TP16DF = 231; +enum R_PARISC_GNU_VTENTRY = 232; +enum R_PARISC_GNU_VTINHERIT = 233; +enum R_PARISC_TLS_GD21L = 234; +enum R_PARISC_TLS_GD14R = 235; +enum R_PARISC_TLS_GDCALL = 236; +enum R_PARISC_TLS_LDM21L = 237; +enum R_PARISC_TLS_LDM14R = 238; +enum R_PARISC_TLS_LDMCALL = 239; +enum R_PARISC_TLS_LDO21L = 240; +enum R_PARISC_TLS_LDO14R = 241; +enum R_PARISC_TLS_DTPMOD32 = 242; +enum R_PARISC_TLS_DTPMOD64 = 243; +enum R_PARISC_TLS_DTPOFF32 = 244; +enum R_PARISC_TLS_DTPOFF64 = 245; +enum R_PARISC_TLS_LE21L = R_PARISC_TPREL21L; +enum R_PARISC_TLS_LE14R = R_PARISC_TPREL14R; +enum R_PARISC_TLS_IE21L = R_PARISC_LTOFF_TP21L; +enum R_PARISC_TLS_IE14R = R_PARISC_LTOFF_TP14R; +enum R_PARISC_TLS_TPREL32 = R_PARISC_TPREL32; +enum R_PARISC_TLS_TPREL64 = R_PARISC_TPREL64; +enum R_PARISC_HIRESERVE = 255; + +enum PT_HP_TLS = (PT_LOOS + 0x0); +enum PT_HP_CORE_NONE = (PT_LOOS + 0x1); +enum PT_HP_CORE_VERSION = (PT_LOOS + 0x2); +enum PT_HP_CORE_KERNEL = (PT_LOOS + 0x3); +enum PT_HP_CORE_COMM = (PT_LOOS + 0x4); +enum PT_HP_CORE_PROC = (PT_LOOS + 0x5); +enum PT_HP_CORE_LOADABLE = (PT_LOOS + 0x6); +enum PT_HP_CORE_STACK = (PT_LOOS + 0x7); +enum PT_HP_CORE_SHM = (PT_LOOS + 0x8); +enum PT_HP_CORE_MMF = (PT_LOOS + 0x9); +enum PT_HP_PARALLEL = (PT_LOOS + 0x10); +enum PT_HP_FASTBIND = (PT_LOOS + 0x11); +enum PT_HP_OPT_ANNOT = (PT_LOOS + 0x12); +enum PT_HP_HSL_ANNOT = (PT_LOOS + 0x13); +enum PT_HP_STACK = (PT_LOOS + 0x14); + +enum PT_PARISC_ARCHEXT = 0x70000000; +enum PT_PARISC_UNWIND = 0x70000001; + +enum PF_PARISC_SBP = 0x08000000; + +enum PF_HP_PAGE_SIZE = 0x00100000; +enum PF_HP_FAR_SHARED = 0x00200000; +enum PF_HP_NEAR_SHARED = 0x00400000; +enum PF_HP_CODE = 0x01000000; +enum PF_HP_MODIFY = 0x02000000; +enum PF_HP_LAZYSWAP = 0x04000000; +enum PF_HP_SBP = 0x08000000; + +enum EF_ALPHA_32BIT = 1; +enum EF_ALPHA_CANRELAX = 2; +enum SHT_ALPHA_DEBUG = 0x70000001; +enum SHT_ALPHA_REGINFO = 0x70000002; + +enum SHF_ALPHA_GPREL = 0x10000000; +enum STO_ALPHA_NOPV = 0x80; +enum STO_ALPHA_STD_GPLOAD = 0x88; + +enum R_ALPHA_NONE = 0; +enum R_ALPHA_REFLONG = 1; +enum R_ALPHA_REFQUAD = 2; +enum R_ALPHA_GPREL32 = 3; +enum R_ALPHA_LITERAL = 4; +enum R_ALPHA_LITUSE = 5; +enum R_ALPHA_GPDISP = 6; +enum R_ALPHA_BRADDR = 7; +enum R_ALPHA_HINT = 8; +enum R_ALPHA_SREL16 = 9; +enum R_ALPHA_SREL32 = 10; +enum R_ALPHA_SREL64 = 11; +enum R_ALPHA_GPRELHIGH = 17; +enum R_ALPHA_GPRELLOW = 18; +enum R_ALPHA_GPREL16 = 19; +enum R_ALPHA_COPY = 24; +enum R_ALPHA_GLOB_DAT = 25; +enum R_ALPHA_JMP_SLOT = 26; +enum R_ALPHA_RELATIVE = 27; +enum R_ALPHA_TLS_GD_HI = 28; +enum R_ALPHA_TLSGD = 29; +enum R_ALPHA_TLS_LDM = 30; +enum R_ALPHA_DTPMOD64 = 31; +enum R_ALPHA_GOTDTPREL = 32; +enum R_ALPHA_DTPREL64 = 33; +enum R_ALPHA_DTPRELHI = 34; +enum R_ALPHA_DTPRELLO = 35; +enum R_ALPHA_DTPREL16 = 36; +enum R_ALPHA_GOTTPREL = 37; +enum R_ALPHA_TPREL64 = 38; +enum R_ALPHA_TPRELHI = 39; +enum R_ALPHA_TPRELLO = 40; +enum R_ALPHA_TPREL16 = 41; +enum R_ALPHA_NUM = 46; +enum LITUSE_ALPHA_ADDR = 0; +enum LITUSE_ALPHA_BASE = 1; +enum LITUSE_ALPHA_BYTOFF = 2; +enum LITUSE_ALPHA_JSR = 3; +enum LITUSE_ALPHA_TLS_GD = 4; +enum LITUSE_ALPHA_TLS_LDM = 5; +enum DT_ALPHA_PLTRO = (DT_LOPROC + 0); +enum DT_ALPHA_NUM = 1; +enum EF_PPC_EMB = 0x80000000; +enum EF_PPC_RELOCATABLE = 0x00010000; +enum EF_PPC_RELOCATABLE_LIB = 0x00008000; +enum R_PPC_NONE = 0; +enum R_PPC_ADDR32 = 1; +enum R_PPC_ADDR24 = 2; +enum R_PPC_ADDR16 = 3; +enum R_PPC_ADDR16_LO = 4; +enum R_PPC_ADDR16_HI = 5; +enum R_PPC_ADDR16_HA = 6; +enum R_PPC_ADDR14 = 7; +enum R_PPC_ADDR14_BRTAKEN = 8; +enum R_PPC_ADDR14_BRNTAKEN = 9; +enum R_PPC_REL24 = 10; +enum R_PPC_REL14 = 11; +enum R_PPC_REL14_BRTAKEN = 12; +enum R_PPC_REL14_BRNTAKEN = 13; +enum R_PPC_GOT16 = 14; +enum R_PPC_GOT16_LO = 15; +enum R_PPC_GOT16_HI = 16; +enum R_PPC_GOT16_HA = 17; +enum R_PPC_PLTREL24 = 18; +enum R_PPC_COPY = 19; +enum R_PPC_GLOB_DAT = 20; +enum R_PPC_JMP_SLOT = 21; +enum R_PPC_RELATIVE = 22; +enum R_PPC_LOCAL24PC = 23; +enum R_PPC_UADDR32 = 24; +enum R_PPC_UADDR16 = 25; +enum R_PPC_REL32 = 26; +enum R_PPC_PLT32 = 27; +enum R_PPC_PLTREL32 = 28; +enum R_PPC_PLT16_LO = 29; +enum R_PPC_PLT16_HI = 30; +enum R_PPC_PLT16_HA = 31; +enum R_PPC_SDAREL16 = 32; +enum R_PPC_SECTOFF = 33; +enum R_PPC_SECTOFF_LO = 34; +enum R_PPC_SECTOFF_HI = 35; +enum R_PPC_SECTOFF_HA = 36; +enum R_PPC_TLS = 67; +enum R_PPC_DTPMOD32 = 68; +enum R_PPC_TPREL16 = 69; +enum R_PPC_TPREL16_LO = 70; +enum R_PPC_TPREL16_HI = 71; +enum R_PPC_TPREL16_HA = 72; +enum R_PPC_TPREL32 = 73; +enum R_PPC_DTPREL16 = 74; +enum R_PPC_DTPREL16_LO = 75; +enum R_PPC_DTPREL16_HI = 76; +enum R_PPC_DTPREL16_HA = 77; +enum R_PPC_DTPREL32 = 78; +enum R_PPC_GOT_TLSGD16 = 79; +enum R_PPC_GOT_TLSGD16_LO = 80; +enum R_PPC_GOT_TLSGD16_HI = 81; +enum R_PPC_GOT_TLSGD16_HA = 82; +enum R_PPC_GOT_TLSLD16 = 83; +enum R_PPC_GOT_TLSLD16_LO = 84; +enum R_PPC_GOT_TLSLD16_HI = 85; +enum R_PPC_GOT_TLSLD16_HA = 86; +enum R_PPC_GOT_TPREL16 = 87; +enum R_PPC_GOT_TPREL16_LO = 88; +enum R_PPC_GOT_TPREL16_HI = 89; +enum R_PPC_GOT_TPREL16_HA = 90; +enum R_PPC_GOT_DTPREL16 = 91; +enum R_PPC_GOT_DTPREL16_LO = 92; +enum R_PPC_GOT_DTPREL16_HI = 93; +enum R_PPC_GOT_DTPREL16_HA = 94; +enum R_PPC_EMB_NADDR32 = 101; +enum R_PPC_EMB_NADDR16 = 102; +enum R_PPC_EMB_NADDR16_LO = 103; +enum R_PPC_EMB_NADDR16_HI = 104; +enum R_PPC_EMB_NADDR16_HA = 105; +enum R_PPC_EMB_SDAI16 = 106; +enum R_PPC_EMB_SDA2I16 = 107; +enum R_PPC_EMB_SDA2REL = 108; +enum R_PPC_EMB_SDA21 = 109; +enum R_PPC_EMB_MRKREF = 110; +enum R_PPC_EMB_RELSEC16 = 111; +enum R_PPC_EMB_RELST_LO = 112; +enum R_PPC_EMB_RELST_HI = 113; +enum R_PPC_EMB_RELST_HA = 114; +enum R_PPC_EMB_BIT_FLD = 115; +enum R_PPC_EMB_RELSDA = 116; +enum R_PPC_DIAB_SDA21_LO = 180; +enum R_PPC_DIAB_SDA21_HI = 181; +enum R_PPC_DIAB_SDA21_HA = 182; +enum R_PPC_DIAB_RELSDA_LO = 183; +enum R_PPC_DIAB_RELSDA_HI = 184; +enum R_PPC_DIAB_RELSDA_HA = 185; +enum R_PPC_IRELATIVE = 248; +enum R_PPC_REL16 = 249; +enum R_PPC_REL16_LO = 250; +enum R_PPC_REL16_HI = 251; +enum R_PPC_REL16_HA = 252; +enum R_PPC_TOC16 = 255; +enum DT_PPC_GOT = (DT_LOPROC + 0); +enum DT_PPC_NUM = 1; +enum R_PPC64_NONE = R_PPC_NONE; +enum R_PPC64_ADDR32 = R_PPC_ADDR32; +enum R_PPC64_ADDR24 = R_PPC_ADDR24; +enum R_PPC64_ADDR16 = R_PPC_ADDR16; +enum R_PPC64_ADDR16_LO = R_PPC_ADDR16_LO; +enum R_PPC64_ADDR16_HI = R_PPC_ADDR16_HI; +enum R_PPC64_ADDR16_HA = R_PPC_ADDR16_HA; +enum R_PPC64_ADDR14 = R_PPC_ADDR14; +enum R_PPC64_ADDR14_BRTAKEN = R_PPC_ADDR14_BRTAKEN; +enum R_PPC64_ADDR14_BRNTAKEN = R_PPC_ADDR14_BRNTAKEN; +enum R_PPC64_REL24 = R_PPC_REL24; +enum R_PPC64_REL14 = R_PPC_REL14; +enum R_PPC64_REL14_BRTAKEN = R_PPC_REL14_BRTAKEN; +enum R_PPC64_REL14_BRNTAKEN = R_PPC_REL14_BRNTAKEN; +enum R_PPC64_GOT16 = R_PPC_GOT16; +enum R_PPC64_GOT16_LO = R_PPC_GOT16_LO; +enum R_PPC64_GOT16_HI = R_PPC_GOT16_HI; +enum R_PPC64_GOT16_HA = R_PPC_GOT16_HA; + +enum R_PPC64_COPY = R_PPC_COPY; +enum R_PPC64_GLOB_DAT = R_PPC_GLOB_DAT; +enum R_PPC64_JMP_SLOT = R_PPC_JMP_SLOT; +enum R_PPC64_RELATIVE = R_PPC_RELATIVE; + +enum R_PPC64_UADDR32 = R_PPC_UADDR32; +enum R_PPC64_UADDR16 = R_PPC_UADDR16; +enum R_PPC64_REL32 = R_PPC_REL32; +enum R_PPC64_PLT32 = R_PPC_PLT32; +enum R_PPC64_PLTREL32 = R_PPC_PLTREL32; +enum R_PPC64_PLT16_LO = R_PPC_PLT16_LO; +enum R_PPC64_PLT16_HI = R_PPC_PLT16_HI; +enum R_PPC64_PLT16_HA = R_PPC_PLT16_HA; + +enum R_PPC64_SECTOFF = R_PPC_SECTOFF; +enum R_PPC64_SECTOFF_LO = R_PPC_SECTOFF_LO; +enum R_PPC64_SECTOFF_HI = R_PPC_SECTOFF_HI; +enum R_PPC64_SECTOFF_HA = R_PPC_SECTOFF_HA; +enum R_PPC64_ADDR30 = 37; +enum R_PPC64_ADDR64 = 38; +enum R_PPC64_ADDR16_HIGHER = 39; +enum R_PPC64_ADDR16_HIGHERA = 40; +enum R_PPC64_ADDR16_HIGHEST = 41; +enum R_PPC64_ADDR16_HIGHESTA = 42; +enum R_PPC64_UADDR64 = 43; +enum R_PPC64_REL64 = 44; +enum R_PPC64_PLT64 = 45; +enum R_PPC64_PLTREL64 = 46; +enum R_PPC64_TOC16 = 47; +enum R_PPC64_TOC16_LO = 48; +enum R_PPC64_TOC16_HI = 49; +enum R_PPC64_TOC16_HA = 50; +enum R_PPC64_TOC = 51; +enum R_PPC64_PLTGOT16 = 52; +enum R_PPC64_PLTGOT16_LO = 53; +enum R_PPC64_PLTGOT16_HI = 54; +enum R_PPC64_PLTGOT16_HA = 55; + +enum R_PPC64_ADDR16_DS = 56; +enum R_PPC64_ADDR16_LO_DS = 57; +enum R_PPC64_GOT16_DS = 58; +enum R_PPC64_GOT16_LO_DS = 59; +enum R_PPC64_PLT16_LO_DS = 60; +enum R_PPC64_SECTOFF_DS = 61; +enum R_PPC64_SECTOFF_LO_DS = 62; +enum R_PPC64_TOC16_DS = 63; +enum R_PPC64_TOC16_LO_DS = 64; +enum R_PPC64_PLTGOT16_DS = 65; +enum R_PPC64_PLTGOT16_LO_DS = 66; +enum R_PPC64_TLS = 67; +enum R_PPC64_DTPMOD64 = 68; +enum R_PPC64_TPREL16 = 69; +enum R_PPC64_TPREL16_LO = 70; +enum R_PPC64_TPREL16_HI = 71; +enum R_PPC64_TPREL16_HA = 72; +enum R_PPC64_TPREL64 = 73; +enum R_PPC64_DTPREL16 = 74; +enum R_PPC64_DTPREL16_LO = 75; +enum R_PPC64_DTPREL16_HI = 76; +enum R_PPC64_DTPREL16_HA = 77; +enum R_PPC64_DTPREL64 = 78; +enum R_PPC64_GOT_TLSGD16 = 79; +enum R_PPC64_GOT_TLSGD16_LO = 80; +enum R_PPC64_GOT_TLSGD16_HI = 81; +enum R_PPC64_GOT_TLSGD16_HA = 82; +enum R_PPC64_GOT_TLSLD16 = 83; +enum R_PPC64_GOT_TLSLD16_LO = 84; +enum R_PPC64_GOT_TLSLD16_HI = 85; +enum R_PPC64_GOT_TLSLD16_HA = 86; +enum R_PPC64_GOT_TPREL16_DS = 87; +enum R_PPC64_GOT_TPREL16_LO_DS = 88; +enum R_PPC64_GOT_TPREL16_HI = 89; +enum R_PPC64_GOT_TPREL16_HA = 90; +enum R_PPC64_GOT_DTPREL16_DS = 91; +enum R_PPC64_GOT_DTPREL16_LO_DS = 92; +enum R_PPC64_GOT_DTPREL16_HI = 93; +enum R_PPC64_GOT_DTPREL16_HA = 94; +enum R_PPC64_TPREL16_DS = 95; +enum R_PPC64_TPREL16_LO_DS = 96; +enum R_PPC64_TPREL16_HIGHER = 97; +enum R_PPC64_TPREL16_HIGHERA = 98; +enum R_PPC64_TPREL16_HIGHEST = 99; +enum R_PPC64_TPREL16_HIGHESTA = 100; +enum R_PPC64_DTPREL16_DS = 101; +enum R_PPC64_DTPREL16_LO_DS = 102; +enum R_PPC64_DTPREL16_HIGHER = 103; +enum R_PPC64_DTPREL16_HIGHERA = 104; +enum R_PPC64_DTPREL16_HIGHEST = 105; +enum R_PPC64_DTPREL16_HIGHESTA = 106; +enum R_PPC64_JMP_IREL = 247; +enum R_PPC64_IRELATIVE = 248; +enum R_PPC64_REL16 = 249; +enum R_PPC64_REL16_LO = 250; +enum R_PPC64_REL16_HI = 251; +enum R_PPC64_REL16_HA = 252; +enum DT_PPC64_GLINK = (DT_LOPROC + 0); +enum DT_PPC64_OPD = (DT_LOPROC + 1); +enum DT_PPC64_OPDSZ = (DT_LOPROC + 2); +enum DT_PPC64_NUM = 3; +enum EF_ARM_RELEXEC = 0x01; +enum EF_ARM_HASENTRY = 0x02; +enum EF_ARM_INTERWORK = 0x04; +enum EF_ARM_APCS_26 = 0x08; +enum EF_ARM_APCS_FLOAT = 0x10; +enum EF_ARM_PIC = 0x20; +enum EF_ARM_ALIGN8 = 0x40; +enum EF_ARM_NEW_ABI = 0x80; +enum EF_ARM_OLD_ABI = 0x100; +enum EF_ARM_SOFT_FLOAT = 0x200; +enum EF_ARM_VFP_FLOAT = 0x400; +enum EF_ARM_MAVERICK_FLOAT = 0x800; + +enum EF_ARM_ABI_FLOAT_SOFT = 0x200; +enum EF_ARM_ABI_FLOAT_HARD = 0x400; +enum EF_ARM_SYMSARESORTED = 0x04; +enum EF_ARM_DYNSYMSUSESEGIDX = 0x08; +enum EF_ARM_MAPSYMSFIRST = 0x10; +enum EF_ARM_EABIMASK = 0XFF000000; +enum EF_ARM_BE8 = 0x00800000; +enum EF_ARM_LE8 = 0x00400000; + +extern (D) auto EF_ARM_EABI_VERSION(F)(F flags) { return flags & EF_ARM_EABIMASK; } +enum EF_ARM_EABI_UNKNOWN = 0x00000000; +enum EF_ARM_EABI_VER1 = 0x01000000; +enum EF_ARM_EABI_VER2 = 0x02000000; +enum EF_ARM_EABI_VER3 = 0x03000000; +enum EF_ARM_EABI_VER4 = 0x04000000; +enum EF_ARM_EABI_VER5 = 0x05000000; +enum STT_ARM_TFUNC = STT_LOPROC; +enum STT_ARM_16BIT = STT_HIPROC; +enum SHF_ARM_ENTRYSECT = 0x10000000; +enum SHF_ARM_COMDEF = 0x80000000; +enum PF_ARM_SB = 0x10000000; +enum PF_ARM_PI = 0x20000000; +enum PF_ARM_ABS = 0x40000000; +enum PT_ARM_EXIDX = (PT_LOPROC + 1); +enum SHT_ARM_EXIDX = (SHT_LOPROC + 1); +enum SHT_ARM_PREEMPTMAP = (SHT_LOPROC + 2); +enum SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3); + +enum R_AARCH64_NONE = 0; +enum R_AARCH64_ABS64 = 257; +enum R_AARCH64_ABS32 = 258; +enum R_AARCH64_COPY = 1024; +enum R_AARCH64_GLOB_DAT = 1025; +enum R_AARCH64_JUMP_SLOT = 1026; +enum R_AARCH64_RELATIVE = 1027; +enum R_AARCH64_TLS_DTPMOD64 = 1028; +enum R_AARCH64_TLS_DTPREL64 = 1029; +enum R_AARCH64_TLS_TPREL64 = 1030; +enum R_AARCH64_TLSDESC = 1031; + +enum R_ARM_NONE = 0; +enum R_ARM_PC24 = 1; +enum R_ARM_ABS32 = 2; +enum R_ARM_REL32 = 3; +enum R_ARM_PC13 = 4; +enum R_ARM_ABS16 = 5; +enum R_ARM_ABS12 = 6; +enum R_ARM_THM_ABS5 = 7; +enum R_ARM_ABS8 = 8; +enum R_ARM_SBREL32 = 9; +enum R_ARM_THM_PC22 = 10; +enum R_ARM_THM_PC8 = 11; +enum R_ARM_AMP_VCALL9 = 12; +enum R_ARM_SWI24 = 13; +enum R_ARM_TLS_DESC = 13; +enum R_ARM_THM_SWI8 = 14; +enum R_ARM_XPC25 = 15; +enum R_ARM_THM_XPC22 = 16; +enum R_ARM_TLS_DTPMOD32 = 17; +enum R_ARM_TLS_DTPOFF32 = 18; +enum R_ARM_TLS_TPOFF32 = 19; +enum R_ARM_COPY = 20; +enum R_ARM_GLOB_DAT = 21; +enum R_ARM_JUMP_SLOT = 22; +enum R_ARM_RELATIVE = 23; +enum R_ARM_GOTOFF = 24; +enum R_ARM_GOTPC = 25; +enum R_ARM_GOT32 = 26; +enum R_ARM_PLT32 = 27; +enum R_ARM_ALU_PCREL_7_0 = 32; +enum R_ARM_ALU_PCREL_15_8 = 33; +enum R_ARM_ALU_PCREL_23_15 = 34; +enum R_ARM_LDR_SBREL_11_0 = 35; +enum R_ARM_ALU_SBREL_19_12 = 36; +enum R_ARM_ALU_SBREL_27_20 = 37; +enum R_ARM_TLS_GOTDESC = 90; +enum R_ARM_TLS_CALL = 91; +enum R_ARM_TLS_DESCSEQ = 92; +enum R_ARM_THM_TLS_CALL = 93; +enum R_ARM_GNU_VTENTRY = 100; +enum R_ARM_GNU_VTINHERIT = 101; +enum R_ARM_THM_PC11 = 102; +enum R_ARM_THM_PC9 = 103; +enum R_ARM_TLS_GD32 = 104; +enum R_ARM_TLS_LDM32 = 105; +enum R_ARM_TLS_LDO32 = 106; +enum R_ARM_TLS_IE32 = 107; +enum R_ARM_TLS_LE32 = 108; +enum R_ARM_THM_TLS_DESCSEQ = 129; +enum R_ARM_IRELATIVE = 160; +enum R_ARM_RXPC25 = 249; +enum R_ARM_RSBREL32 = 250; +enum R_ARM_THM_RPC22 = 251; +enum R_ARM_RREL32 = 252; +enum R_ARM_RABS22 = 253; +enum R_ARM_RPC24 = 254; +enum R_ARM_RBASE = 255; +enum R_ARM_NUM = 256; +enum EF_IA_64_MASKOS = 0x0000000f; +enum EF_IA_64_ABI64 = 0x00000010; +enum EF_IA_64_ARCH = 0xff000000; +enum PT_IA_64_ARCHEXT = (PT_LOPROC + 0); +enum PT_IA_64_UNWIND = (PT_LOPROC + 1); +enum PT_IA_64_HP_OPT_ANOT = (PT_LOOS + 0x12); +enum PT_IA_64_HP_HSL_ANOT = (PT_LOOS + 0x13); +enum PT_IA_64_HP_STACK = (PT_LOOS + 0x14); +enum PF_IA_64_NORECOV = 0x80000000; +enum SHT_IA_64_EXT = (SHT_LOPROC + 0); +enum SHT_IA_64_UNWIND = (SHT_LOPROC + 1); +enum SHF_IA_64_SHORT = 0x10000000; +enum SHF_IA_64_NORECOV = 0x20000000; +enum DT_IA_64_PLT_RESERVE = (DT_LOPROC + 0); +enum DT_IA_64_NUM = 1; +enum R_IA64_NONE = 0x00; +enum R_IA64_IMM14 = 0x21; +enum R_IA64_IMM22 = 0x22; +enum R_IA64_IMM64 = 0x23; +enum R_IA64_DIR32MSB = 0x24; +enum R_IA64_DIR32LSB = 0x25; +enum R_IA64_DIR64MSB = 0x26; +enum R_IA64_DIR64LSB = 0x27; +enum R_IA64_GPREL22 = 0x2a; +enum R_IA64_GPREL64I = 0x2b; +enum R_IA64_GPREL32MSB = 0x2c; +enum R_IA64_GPREL32LSB = 0x2d; +enum R_IA64_GPREL64MSB = 0x2e; +enum R_IA64_GPREL64LSB = 0x2f; +enum R_IA64_LTOFF22 = 0x32; +enum R_IA64_LTOFF64I = 0x33; +enum R_IA64_PLTOFF22 = 0x3a; +enum R_IA64_PLTOFF64I = 0x3b; +enum R_IA64_PLTOFF64MSB = 0x3e; +enum R_IA64_PLTOFF64LSB = 0x3f; +enum R_IA64_FPTR64I = 0x43; +enum R_IA64_FPTR32MSB = 0x44; +enum R_IA64_FPTR32LSB = 0x45; +enum R_IA64_FPTR64MSB = 0x46; +enum R_IA64_FPTR64LSB = 0x47; +enum R_IA64_PCREL60B = 0x48; +enum R_IA64_PCREL21B = 0x49; +enum R_IA64_PCREL21M = 0x4a; +enum R_IA64_PCREL21F = 0x4b; +enum R_IA64_PCREL32MSB = 0x4c; +enum R_IA64_PCREL32LSB = 0x4d; +enum R_IA64_PCREL64MSB = 0x4e; +enum R_IA64_PCREL64LSB = 0x4f; +enum R_IA64_LTOFF_FPTR22 = 0x52; +enum R_IA64_LTOFF_FPTR64I = 0x53; +enum R_IA64_LTOFF_FPTR32MSB = 0x54; +enum R_IA64_LTOFF_FPTR32LSB = 0x55; +enum R_IA64_LTOFF_FPTR64MSB = 0x56; +enum R_IA64_LTOFF_FPTR64LSB = 0x57; +enum R_IA64_SEGREL32MSB = 0x5c; +enum R_IA64_SEGREL32LSB = 0x5d; +enum R_IA64_SEGREL64MSB = 0x5e; +enum R_IA64_SEGREL64LSB = 0x5f; +enum R_IA64_SECREL32MSB = 0x64; +enum R_IA64_SECREL32LSB = 0x65; +enum R_IA64_SECREL64MSB = 0x66; +enum R_IA64_SECREL64LSB = 0x67; +enum R_IA64_REL32MSB = 0x6c; +enum R_IA64_REL32LSB = 0x6d; +enum R_IA64_REL64MSB = 0x6e; +enum R_IA64_REL64LSB = 0x6f; +enum R_IA64_LTV32MSB = 0x74; +enum R_IA64_LTV32LSB = 0x75; +enum R_IA64_LTV64MSB = 0x76; +enum R_IA64_LTV64LSB = 0x77; +enum R_IA64_PCREL21BI = 0x79; +enum R_IA64_PCREL22 = 0x7a; +enum R_IA64_PCREL64I = 0x7b; +enum R_IA64_IPLTMSB = 0x80; +enum R_IA64_IPLTLSB = 0x81; +enum R_IA64_COPY = 0x84; +enum R_IA64_SUB = 0x85; +enum R_IA64_LTOFF22X = 0x86; +enum R_IA64_LDXMOV = 0x87; +enum R_IA64_TPREL14 = 0x91; +enum R_IA64_TPREL22 = 0x92; +enum R_IA64_TPREL64I = 0x93; +enum R_IA64_TPREL64MSB = 0x96; +enum R_IA64_TPREL64LSB = 0x97; +enum R_IA64_LTOFF_TPREL22 = 0x9a; +enum R_IA64_DTPMOD64MSB = 0xa6; +enum R_IA64_DTPMOD64LSB = 0xa7; +enum R_IA64_LTOFF_DTPMOD22 = 0xaa; +enum R_IA64_DTPREL14 = 0xb1; +enum R_IA64_DTPREL22 = 0xb2; +enum R_IA64_DTPREL64I = 0xb3; +enum R_IA64_DTPREL32MSB = 0xb4; +enum R_IA64_DTPREL32LSB = 0xb5; +enum R_IA64_DTPREL64MSB = 0xb6; +enum R_IA64_DTPREL64LSB = 0xb7; +enum R_IA64_LTOFF_DTPREL22 = 0xba; +enum EF_SH_MACH_MASK = 0x1f; +enum EF_SH_UNKNOWN = 0x0; +enum EF_SH1 = 0x1; +enum EF_SH2 = 0x2; +enum EF_SH3 = 0x3; +enum EF_SH_DSP = 0x4; +enum EF_SH3_DSP = 0x5; +enum EF_SH4AL_DSP = 0x6; +enum EF_SH3E = 0x8; +enum EF_SH4 = 0x9; +enum EF_SH2E = 0xb; +enum EF_SH4A = 0xc; +enum EF_SH2A = 0xd; +enum EF_SH4_NOFPU = 0x10; +enum EF_SH4A_NOFPU = 0x11; +enum EF_SH4_NOMMU_NOFPU = 0x12; +enum EF_SH2A_NOFPU = 0x13; +enum EF_SH3_NOMMU = 0x14; +enum EF_SH2A_SH4_NOFPU = 0x15; +enum EF_SH2A_SH3_NOFPU = 0x16; +enum EF_SH2A_SH4 = 0x17; +enum EF_SH2A_SH3E = 0x18; +enum R_SH_NONE = 0; +enum R_SH_DIR32 = 1; +enum R_SH_REL32 = 2; +enum R_SH_DIR8WPN = 3; +enum R_SH_IND12W = 4; +enum R_SH_DIR8WPL = 5; +enum R_SH_DIR8WPZ = 6; +enum R_SH_DIR8BP = 7; +enum R_SH_DIR8W = 8; +enum R_SH_DIR8L = 9; +enum R_SH_SWITCH16 = 25; +enum R_SH_SWITCH32 = 26; +enum R_SH_USES = 27; +enum R_SH_COUNT = 28; +enum R_SH_ALIGN = 29; +enum R_SH_CODE = 30; +enum R_SH_DATA = 31; +enum R_SH_LABEL = 32; +enum R_SH_SWITCH8 = 33; +enum R_SH_GNU_VTINHERIT = 34; +enum R_SH_GNU_VTENTRY = 35; +enum R_SH_TLS_GD_32 = 144; +enum R_SH_TLS_LD_32 = 145; +enum R_SH_TLS_LDO_32 = 146; +enum R_SH_TLS_IE_32 = 147; +enum R_SH_TLS_LE_32 = 148; +enum R_SH_TLS_DTPMOD32 = 149; +enum R_SH_TLS_DTPOFF32 = 150; +enum R_SH_TLS_TPOFF32 = 151; +enum R_SH_GOT32 = 160; +enum R_SH_PLT32 = 161; +enum R_SH_COPY = 162; +enum R_SH_GLOB_DAT = 163; +enum R_SH_JMP_SLOT = 164; +enum R_SH_RELATIVE = 165; +enum R_SH_GOTOFF = 166; +enum R_SH_GOTPC = 167; +enum R_SH_NUM = 256; + +enum EF_S390_HIGH_GPRS = 0x00000001; + +enum R_390_NONE = 0; +enum R_390_8 = 1; +enum R_390_12 = 2; +enum R_390_16 = 3; +enum R_390_32 = 4; +enum R_390_PC32 = 5; +enum R_390_GOT12 = 6; +enum R_390_GOT32 = 7; +enum R_390_PLT32 = 8; +enum R_390_COPY = 9; +enum R_390_GLOB_DAT = 10; +enum R_390_JMP_SLOT = 11; +enum R_390_RELATIVE = 12; +enum R_390_GOTOFF32 = 13; +enum R_390_GOTPC = 14; +enum R_390_GOT16 = 15; +enum R_390_PC16 = 16; +enum R_390_PC16DBL = 17; +enum R_390_PLT16DBL = 18; +enum R_390_PC32DBL = 19; +enum R_390_PLT32DBL = 20; +enum R_390_GOTPCDBL = 21; +enum R_390_64 = 22; +enum R_390_PC64 = 23; +enum R_390_GOT64 = 24; +enum R_390_PLT64 = 25; +enum R_390_GOTENT = 26; +enum R_390_GOTOFF16 = 27; +enum R_390_GOTOFF64 = 28; +enum R_390_GOTPLT12 = 29; +enum R_390_GOTPLT16 = 30; +enum R_390_GOTPLT32 = 31; +enum R_390_GOTPLT64 = 32; +enum R_390_GOTPLTENT = 33; +enum R_390_PLTOFF16 = 34; +enum R_390_PLTOFF32 = 35; +enum R_390_PLTOFF64 = 36; +enum R_390_TLS_LOAD = 37; +enum R_390_TLS_GDCALL = 38; +enum R_390_TLS_LDCALL = 39; +enum R_390_TLS_GD32 = 40; +enum R_390_TLS_GD64 = 41; +enum R_390_TLS_GOTIE12 = 42; +enum R_390_TLS_GOTIE32 = 43; +enum R_390_TLS_GOTIE64 = 44; +enum R_390_TLS_LDM32 = 45; +enum R_390_TLS_LDM64 = 46; +enum R_390_TLS_IE32 = 47; +enum R_390_TLS_IE64 = 48; +enum R_390_TLS_IEENT = 49; +enum R_390_TLS_LE32 = 50; +enum R_390_TLS_LE64 = 51; +enum R_390_TLS_LDO32 = 52; +enum R_390_TLS_LDO64 = 53; +enum R_390_TLS_DTPMOD = 54; +enum R_390_TLS_DTPOFF = 55; +enum R_390_TLS_TPOFF = 56; +enum R_390_20 = 57; +enum R_390_GOT20 = 58; +enum R_390_GOTPLT20 = 59; +enum R_390_TLS_GOTIE20 = 60; +enum R_390_IRELATIVE = 61; +enum R_390_NUM = 62; +enum R_CRIS_NONE = 0; +enum R_CRIS_8 = 1; +enum R_CRIS_16 = 2; +enum R_CRIS_32 = 3; +enum R_CRIS_8_PCREL = 4; +enum R_CRIS_16_PCREL = 5; +enum R_CRIS_32_PCREL = 6; +enum R_CRIS_GNU_VTINHERIT = 7; +enum R_CRIS_GNU_VTENTRY = 8; +enum R_CRIS_COPY = 9; +enum R_CRIS_GLOB_DAT = 10; +enum R_CRIS_JUMP_SLOT = 11; +enum R_CRIS_RELATIVE = 12; +enum R_CRIS_16_GOT = 13; +enum R_CRIS_32_GOT = 14; +enum R_CRIS_16_GOTPLT = 15; +enum R_CRIS_32_GOTPLT = 16; +enum R_CRIS_32_GOTREL = 17; +enum R_CRIS_32_PLT_GOTREL = 18; +enum R_CRIS_32_PLT_PCREL = 19; + +enum R_CRIS_NUM = 20; +enum R_X86_64_NONE = 0; +enum R_X86_64_64 = 1; +enum R_X86_64_PC32 = 2; +enum R_X86_64_GOT32 = 3; +enum R_X86_64_PLT32 = 4; +enum R_X86_64_COPY = 5; +enum R_X86_64_GLOB_DAT = 6; +enum R_X86_64_JUMP_SLOT = 7; +enum R_X86_64_RELATIVE = 8; +enum R_X86_64_GOTPCREL = 9; +enum R_X86_64_32 = 10; +enum R_X86_64_32S = 11; +enum R_X86_64_16 = 12; +enum R_X86_64_PC16 = 13; +enum R_X86_64_8 = 14; +enum R_X86_64_PC8 = 15; +enum R_X86_64_DTPMOD64 = 16; +enum R_X86_64_DTPOFF64 = 17; +enum R_X86_64_TPOFF64 = 18; +enum R_X86_64_TLSGD = 19; +enum R_X86_64_TLSLD = 20; +enum R_X86_64_DTPOFF32 = 21; +enum R_X86_64_GOTTPOFF = 22; +enum R_X86_64_TPOFF32 = 23; +enum R_X86_64_PC64 = 24; +enum R_X86_64_GOTOFF64 = 25; +enum R_X86_64_GOTPC32 = 26; +enum R_X86_64_GOT64 = 27; +enum R_X86_64_GOTPCREL64 = 28; +enum R_X86_64_GOTPC64 = 29; +enum R_X86_64_GOTPLT64 = 30; +enum R_X86_64_PLTOFF64 = 31; +enum R_X86_64_SIZE32 = 32; +enum R_X86_64_SIZE64 = 33; +enum R_X86_64_GOTPC32_TLSDESC = 34; +enum R_X86_64_TLSDESC_CALL = 35; +enum R_X86_64_TLSDESC = 36; +enum R_X86_64_IRELATIVE = 37; +enum R_X86_64_RELATIVE64 = 38; + +enum R_X86_64_NUM = 39; +enum R_MN10300_NONE = 0; +enum R_MN10300_32 = 1; +enum R_MN10300_16 = 2; +enum R_MN10300_8 = 3; +enum R_MN10300_PCREL32 = 4; +enum R_MN10300_PCREL16 = 5; +enum R_MN10300_PCREL8 = 6; +enum R_MN10300_GNU_VTINHERIT = 7; +enum R_MN10300_GNU_VTENTRY = 8; +enum R_MN10300_24 = 9; +enum R_MN10300_GOTPC32 = 10; +enum R_MN10300_GOTPC16 = 11; +enum R_MN10300_GOTOFF32 = 12; +enum R_MN10300_GOTOFF24 = 13; +enum R_MN10300_GOTOFF16 = 14; +enum R_MN10300_PLT32 = 15; +enum R_MN10300_PLT16 = 16; +enum R_MN10300_GOT32 = 17; +enum R_MN10300_GOT24 = 18; +enum R_MN10300_GOT16 = 19; +enum R_MN10300_COPY = 20; +enum R_MN10300_GLOB_DAT = 21; +enum R_MN10300_JMP_SLOT = 22; +enum R_MN10300_RELATIVE = 23; +enum R_MN10300_TLS_GD = 24; +enum R_MN10300_TLS_LD = 25; +enum R_MN10300_TLS_LDO = 26; +enum R_MN10300_TLS_GOTIE = 27; +enum R_MN10300_TLS_IE = 28; +enum R_MN10300_TLS_LE = 29; +enum R_MN10300_TLS_DTPMOD = 30; +enum R_MN10300_TLS_DTPOFF = 31; +enum R_MN10300_TLS_TPOFF = 32; +enum R_MN10300_SYM_DIFF = 33; +enum R_MN10300_ALIGN = 34; +enum R_MN10300_NUM = 35; +enum R_M32R_NONE = 0; +enum R_M32R_16 = 1; +enum R_M32R_32 = 2; +enum R_M32R_24 = 3; +enum R_M32R_10_PCREL = 4; +enum R_M32R_18_PCREL = 5; +enum R_M32R_26_PCREL = 6; +enum R_M32R_HI16_ULO = 7; +enum R_M32R_HI16_SLO = 8; +enum R_M32R_LO16 = 9; +enum R_M32R_SDA16 = 10; +enum R_M32R_GNU_VTINHERIT = 11; +enum R_M32R_GNU_VTENTRY = 12; +enum R_M32R_16_RELA = 33; +enum R_M32R_32_RELA = 34; +enum R_M32R_24_RELA = 35; +enum R_M32R_10_PCREL_RELA = 36; +enum R_M32R_18_PCREL_RELA = 37; +enum R_M32R_26_PCREL_RELA = 38; +enum R_M32R_HI16_ULO_RELA = 39; +enum R_M32R_HI16_SLO_RELA = 40; +enum R_M32R_LO16_RELA = 41; +enum R_M32R_SDA16_RELA = 42; +enum R_M32R_RELA_GNU_VTINHERIT = 43; +enum R_M32R_RELA_GNU_VTENTRY = 44; +enum R_M32R_REL32 = 45; + +enum R_M32R_GOT24 = 48; +enum R_M32R_26_PLTREL = 49; +enum R_M32R_COPY = 50; +enum R_M32R_GLOB_DAT = 51; +enum R_M32R_JMP_SLOT = 52; +enum R_M32R_RELATIVE = 53; +enum R_M32R_GOTOFF = 54; +enum R_M32R_GOTPC24 = 55; +enum R_M32R_GOT16_HI_ULO = 56; +enum R_M32R_GOT16_HI_SLO = 57; +enum R_M32R_GOT16_LO = 58; +enum R_M32R_GOTPC_HI_ULO = 59; +enum R_M32R_GOTPC_HI_SLO = 60; +enum R_M32R_GOTPC_LO = 61; +enum R_M32R_GOTOFF_HI_ULO = 62; +enum R_M32R_GOTOFF_HI_SLO = 63; +enum R_M32R_GOTOFF_LO = 64; +enum R_M32R_NUM = 256; +enum R_TILEPRO_NONE = 0; +enum R_TILEPRO_32 = 1; +enum R_TILEPRO_16 = 2; +enum R_TILEPRO_8 = 3; +enum R_TILEPRO_32_PCREL = 4; +enum R_TILEPRO_16_PCREL = 5; +enum R_TILEPRO_8_PCREL = 6; +enum R_TILEPRO_LO16 = 7; +enum R_TILEPRO_HI16 = 8; +enum R_TILEPRO_HA16 = 9; +enum R_TILEPRO_COPY = 10; +enum R_TILEPRO_GLOB_DAT = 11; +enum R_TILEPRO_JMP_SLOT = 12; +enum R_TILEPRO_RELATIVE = 13; +enum R_TILEPRO_BROFF_X1 = 14; +enum R_TILEPRO_JOFFLONG_X1 = 15; +enum R_TILEPRO_JOFFLONG_X1_PLT = 16; +enum R_TILEPRO_IMM8_X0 = 17; +enum R_TILEPRO_IMM8_Y0 = 18; +enum R_TILEPRO_IMM8_X1 = 19; +enum R_TILEPRO_IMM8_Y1 = 20; +enum R_TILEPRO_MT_IMM15_X1 = 21; +enum R_TILEPRO_MF_IMM15_X1 = 22; +enum R_TILEPRO_IMM16_X0 = 23; +enum R_TILEPRO_IMM16_X1 = 24; +enum R_TILEPRO_IMM16_X0_LO = 25; +enum R_TILEPRO_IMM16_X1_LO = 26; +enum R_TILEPRO_IMM16_X0_HI = 27; +enum R_TILEPRO_IMM16_X1_HI = 28; +enum R_TILEPRO_IMM16_X0_HA = 29; +enum R_TILEPRO_IMM16_X1_HA = 30; +enum R_TILEPRO_IMM16_X0_PCREL = 31; +enum R_TILEPRO_IMM16_X1_PCREL = 32; +enum R_TILEPRO_IMM16_X0_LO_PCREL = 33; +enum R_TILEPRO_IMM16_X1_LO_PCREL = 34; +enum R_TILEPRO_IMM16_X0_HI_PCREL = 35; +enum R_TILEPRO_IMM16_X1_HI_PCREL = 36; +enum R_TILEPRO_IMM16_X0_HA_PCREL = 37; +enum R_TILEPRO_IMM16_X1_HA_PCREL = 38; +enum R_TILEPRO_IMM16_X0_GOT = 39; +enum R_TILEPRO_IMM16_X1_GOT = 40; +enum R_TILEPRO_IMM16_X0_GOT_LO = 41; +enum R_TILEPRO_IMM16_X1_GOT_LO = 42; +enum R_TILEPRO_IMM16_X0_GOT_HI = 43; +enum R_TILEPRO_IMM16_X1_GOT_HI = 44; +enum R_TILEPRO_IMM16_X0_GOT_HA = 45; +enum R_TILEPRO_IMM16_X1_GOT_HA = 46; +enum R_TILEPRO_MMSTART_X0 = 47; +enum R_TILEPRO_MMEND_X0 = 48; +enum R_TILEPRO_MMSTART_X1 = 49; +enum R_TILEPRO_MMEND_X1 = 50; +enum R_TILEPRO_SHAMT_X0 = 51; +enum R_TILEPRO_SHAMT_X1 = 52; +enum R_TILEPRO_SHAMT_Y0 = 53; +enum R_TILEPRO_SHAMT_Y1 = 54; +enum R_TILEPRO_DEST_IMM8_X1 = 55; +enum R_TILEPRO_TLS_GD_CALL = 60; +enum R_TILEPRO_IMM8_X0_TLS_GD_ADD = 61; +enum R_TILEPRO_IMM8_X1_TLS_GD_ADD = 62; +enum R_TILEPRO_IMM8_Y0_TLS_GD_ADD = 63; +enum R_TILEPRO_IMM8_Y1_TLS_GD_ADD = 64; +enum R_TILEPRO_TLS_IE_LOAD = 65; +enum R_TILEPRO_IMM16_X0_TLS_GD = 66; +enum R_TILEPRO_IMM16_X1_TLS_GD = 67; +enum R_TILEPRO_IMM16_X0_TLS_GD_LO = 68; +enum R_TILEPRO_IMM16_X1_TLS_GD_LO = 69; +enum R_TILEPRO_IMM16_X0_TLS_GD_HI = 70; +enum R_TILEPRO_IMM16_X1_TLS_GD_HI = 71; +enum R_TILEPRO_IMM16_X0_TLS_GD_HA = 72; +enum R_TILEPRO_IMM16_X1_TLS_GD_HA = 73; +enum R_TILEPRO_IMM16_X0_TLS_IE = 74; +enum R_TILEPRO_IMM16_X1_TLS_IE = 75; +enum R_TILEPRO_IMM16_X0_TLS_IE_LO = 76; +enum R_TILEPRO_IMM16_X1_TLS_IE_LO = 77; +enum R_TILEPRO_IMM16_X0_TLS_IE_HI = 78; +enum R_TILEPRO_IMM16_X1_TLS_IE_HI = 79; +enum R_TILEPRO_IMM16_X0_TLS_IE_HA = 80; +enum R_TILEPRO_IMM16_X1_TLS_IE_HA = 81; +enum R_TILEPRO_TLS_DTPMOD32 = 82; +enum R_TILEPRO_TLS_DTPOFF32 = 83; +enum R_TILEPRO_TLS_TPOFF32 = 84; +enum R_TILEPRO_IMM16_X0_TLS_LE = 85; +enum R_TILEPRO_IMM16_X1_TLS_LE = 86; +enum R_TILEPRO_IMM16_X0_TLS_LE_LO = 87; +enum R_TILEPRO_IMM16_X1_TLS_LE_LO = 88; +enum R_TILEPRO_IMM16_X0_TLS_LE_HI = 89; +enum R_TILEPRO_IMM16_X1_TLS_LE_HI = 90; +enum R_TILEPRO_IMM16_X0_TLS_LE_HA = 91; +enum R_TILEPRO_IMM16_X1_TLS_LE_HA = 92; + +enum R_TILEPRO_GNU_VTINHERIT = 128; +enum R_TILEPRO_GNU_VTENTRY = 129; + +enum R_TILEPRO_NUM = 130; +enum R_TILEGX_NONE = 0; +enum R_TILEGX_64 = 1; +enum R_TILEGX_32 = 2; +enum R_TILEGX_16 = 3; +enum R_TILEGX_8 = 4; +enum R_TILEGX_64_PCREL = 5; +enum R_TILEGX_32_PCREL = 6; +enum R_TILEGX_16_PCREL = 7; +enum R_TILEGX_8_PCREL = 8; +enum R_TILEGX_HW0 = 9; +enum R_TILEGX_HW1 = 10; +enum R_TILEGX_HW2 = 11; +enum R_TILEGX_HW3 = 12; +enum R_TILEGX_HW0_LAST = 13; +enum R_TILEGX_HW1_LAST = 14; +enum R_TILEGX_HW2_LAST = 15; +enum R_TILEGX_COPY = 16; +enum R_TILEGX_GLOB_DAT = 17; +enum R_TILEGX_JMP_SLOT = 18; +enum R_TILEGX_RELATIVE = 19; +enum R_TILEGX_BROFF_X1 = 20; +enum R_TILEGX_JUMPOFF_X1 = 21; +enum R_TILEGX_JUMPOFF_X1_PLT = 22; +enum R_TILEGX_IMM8_X0 = 23; +enum R_TILEGX_IMM8_Y0 = 24; +enum R_TILEGX_IMM8_X1 = 25; +enum R_TILEGX_IMM8_Y1 = 26; +enum R_TILEGX_DEST_IMM8_X1 = 27; +enum R_TILEGX_MT_IMM14_X1 = 28; +enum R_TILEGX_MF_IMM14_X1 = 29; +enum R_TILEGX_MMSTART_X0 = 30; +enum R_TILEGX_MMEND_X0 = 31; +enum R_TILEGX_SHAMT_X0 = 32; +enum R_TILEGX_SHAMT_X1 = 33; +enum R_TILEGX_SHAMT_Y0 = 34; +enum R_TILEGX_SHAMT_Y1 = 35; +enum R_TILEGX_IMM16_X0_HW0 = 36; +enum R_TILEGX_IMM16_X1_HW0 = 37; +enum R_TILEGX_IMM16_X0_HW1 = 38; +enum R_TILEGX_IMM16_X1_HW1 = 39; +enum R_TILEGX_IMM16_X0_HW2 = 40; +enum R_TILEGX_IMM16_X1_HW2 = 41; +enum R_TILEGX_IMM16_X0_HW3 = 42; +enum R_TILEGX_IMM16_X1_HW3 = 43; +enum R_TILEGX_IMM16_X0_HW0_LAST = 44; +enum R_TILEGX_IMM16_X1_HW0_LAST = 45; +enum R_TILEGX_IMM16_X0_HW1_LAST = 46; +enum R_TILEGX_IMM16_X1_HW1_LAST = 47; +enum R_TILEGX_IMM16_X0_HW2_LAST = 48; +enum R_TILEGX_IMM16_X1_HW2_LAST = 49; +enum R_TILEGX_IMM16_X0_HW0_PCREL = 50; +enum R_TILEGX_IMM16_X1_HW0_PCREL = 51; +enum R_TILEGX_IMM16_X0_HW1_PCREL = 52; +enum R_TILEGX_IMM16_X1_HW1_PCREL = 53; +enum R_TILEGX_IMM16_X0_HW2_PCREL = 54; +enum R_TILEGX_IMM16_X1_HW2_PCREL = 55; +enum R_TILEGX_IMM16_X0_HW3_PCREL = 56; +enum R_TILEGX_IMM16_X1_HW3_PCREL = 57; +enum R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58; +enum R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59; +enum R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60; +enum R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61; +enum R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62; +enum R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63; +enum R_TILEGX_IMM16_X0_HW0_GOT = 64; +enum R_TILEGX_IMM16_X1_HW0_GOT = 65; +enum R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66; +enum R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67; +enum R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68; +enum R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69; +enum R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70; +enum R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71; +enum R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72; +enum R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73; +enum R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74; +enum R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75; +enum R_TILEGX_IMM16_X0_HW3_PLT_PCREL = 76; +enum R_TILEGX_IMM16_X1_HW3_PLT_PCREL = 77; +enum R_TILEGX_IMM16_X0_HW0_TLS_GD = 78; +enum R_TILEGX_IMM16_X1_HW0_TLS_GD = 79; +enum R_TILEGX_IMM16_X0_HW0_TLS_LE = 80; +enum R_TILEGX_IMM16_X1_HW0_TLS_LE = 81; +enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82; +enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83; +enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84; +enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85; +enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86; +enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87; +enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88; +enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89; +enum R_TILEGX_IMM16_X0_HW0_TLS_IE = 92; +enum R_TILEGX_IMM16_X1_HW0_TLS_IE = 93; +enum R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94; +enum R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95; +enum R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96; +enum R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97; +enum R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98; +enum R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99; +enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100; +enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101; +enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102; +enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103; +enum R_TILEGX_TLS_DTPMOD64 = 106; +enum R_TILEGX_TLS_DTPOFF64 = 107; +enum R_TILEGX_TLS_TPOFF64 = 108; +enum R_TILEGX_TLS_DTPMOD32 = 109; +enum R_TILEGX_TLS_DTPOFF32 = 110; +enum R_TILEGX_TLS_TPOFF32 = 111; +enum R_TILEGX_TLS_GD_CALL = 112; +enum R_TILEGX_IMM8_X0_TLS_GD_ADD = 113; +enum R_TILEGX_IMM8_X1_TLS_GD_ADD = 114; +enum R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115; +enum R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116; +enum R_TILEGX_TLS_IE_LOAD = 117; +enum R_TILEGX_IMM8_X0_TLS_ADD = 118; +enum R_TILEGX_IMM8_X1_TLS_ADD = 119; +enum R_TILEGX_IMM8_Y0_TLS_ADD = 120; +enum R_TILEGX_IMM8_Y1_TLS_ADD = 121; + +enum R_TILEGX_GNU_VTINHERIT = 128; +enum R_TILEGX_GNU_VTENTRY = 129; + +enum R_TILEGX_NUM = 130; + +enum EF_RISCV_RVC = 0x0001; +enum EF_RISCV_FLOAT_ABI = 0x0006; +enum EF_RISCV_FLOAT_ABI_SOFT = 0x0000; +enum EF_RISCV_FLOAT_ABI_SINGLE = 0x0002; +enum EF_RISCV_FLOAT_ABI_DOUBLE = 0x0004; +enum EF_RISCV_FLOAT_ABI_QUAD = 0x0006; +enum R_RISCV_NONE = 0; +enum R_RISCV_32 = 1; +enum R_RISCV_64 = 2; +enum R_RISCV_RELATIVE = 3; +enum R_RISCV_COPY = 4; +enum R_RISCV_JUMP_SLOT = 5; +enum R_RISCV_TLS_DTPMOD32 = 6; +enum R_RISCV_TLS_DTPMOD64 = 7; +enum R_RISCV_TLS_DTPREL32 = 8; +enum R_RISCV_TLS_DTPREL64 = 9; +enum R_RISCV_TLS_TPREL32 = 10; +enum R_RISCV_TLS_TPREL64 = 11; +enum R_RISCV_BRANCH = 16; +enum R_RISCV_JAL = 17; +enum R_RISCV_CALL = 18; +enum R_RISCV_CALL_PLT = 19; +enum R_RISCV_GOT_HI20 = 20; +enum R_RISCV_TLS_GOT_HI20 = 21; +enum R_RISCV_TLS_GD_HI20 = 22; +enum R_RISCV_PCREL_HI20 = 23; +enum R_RISCV_PCREL_LO12_I = 24; +enum R_RISCV_PCREL_LO12_S = 25; +enum R_RISCV_HI20 = 26; +enum R_RISCV_LO12_I = 27; +enum R_RISCV_LO12_S = 28; +enum R_RISCV_TPREL_HI20 = 29; +enum R_RISCV_TPREL_LO12_I = 30; +enum R_RISCV_TPREL_LO12_S = 31; +enum R_RISCV_TPREL_ADD = 32; +enum R_RISCV_ADD8 = 33; +enum R_RISCV_ADD16 = 34; +enum R_RISCV_ADD32 = 35; +enum R_RISCV_ADD64 = 36; +enum R_RISCV_SUB8 = 37; +enum R_RISCV_SUB16 = 38; +enum R_RISCV_SUB32 = 39; +enum R_RISCV_SUB64 = 40; +enum R_RISCV_GNU_VTINHERIT = 41; +enum R_RISCV_GNU_VTENTRY = 42; +enum R_RISCV_ALIGN = 43; +enum R_RISCV_RVC_BRANCH = 44; +enum R_RISCV_RVC_JUMP = 45; +enum R_RISCV_RVC_LUI = 46; +enum R_RISCV_GPREL_I = 47; +enum R_RISCV_GPREL_S = 48; +enum R_RISCV_TPREL_I = 49; +enum R_RISCV_TPREL_S = 50; +enum R_RISCV_RELAX = 51; +enum R_RISCV_SUB6 = 52; +enum R_RISCV_SET6 = 53; +enum R_RISCV_SET8 = 54; +enum R_RISCV_SET16 = 55; +enum R_RISCV_SET32 = 56; +enum R_RISCV_32_PCREL = 57; +enum R_RISCV_IRELATIVE = 58; +enum R_RISCV_NUM = 59; diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/elf32.d b/libphobos/libdruntime/core/sys/freebsd/sys/elf32.d index 63cc4f9..4e8ae28 100644 --- a/libphobos/libdruntime/core/sys/freebsd/sys/elf32.d +++ b/libphobos/libdruntime/core/sys/freebsd/sys/elf32.d @@ -13,60 +13,11 @@ nothrow: import core.stdc.stdint; public import core.sys.freebsd.sys.elf_common; -alias uint16_t Elf32_Half; -alias uint32_t Elf32_Word; -alias int32_t Elf32_Sword; alias uint64_t Elf32_Lword; -alias uint32_t Elf32_Addr; -alias uint32_t Elf32_Off; alias Elf32_Word Elf32_Hashelt; alias Elf32_Word Elf32_Size; alias Elf32_Sword Elf32_Ssize; -struct Elf32_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} - -struct Elf32_Shdr -{ - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} - -struct Elf32_Phdr -{ - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; -} - struct Elf32_Dyn { Elf32_Sword d_tag; @@ -77,44 +28,8 @@ struct Elf32_Dyn } _d_un d_un; } -struct Elf32_Rel -{ - Elf32_Addr r_offset; - Elf32_Word r_info; -} - -struct Elf32_Rela -{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} - -extern (D) -{ - auto ELF32_R_SYM(V)(V val) { return val >> 8; } - auto ELF32_R_TYPE(V)(V val) { return val & 0xff; } - auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); } -} - alias Elf_Note Elf32_Nhdr; -struct Elf32_Move -{ - Elf32_Lword m_value; - Elf32_Word m_info; - Elf32_Word m_poffset; - Elf32_Half m_repeat; - Elf32_Half m_stride; -} - -extern (D) -{ - auto ELF32_M_SYM(I)(I info) { return info >> 8; } - auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } -} - struct Elf32_Cap { Elf32_Word c_tag; @@ -125,63 +40,7 @@ struct Elf32_Cap } _c_un c_un; } -struct Elf32_Sym -{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - ubyte st_info; - ubyte st_other; - Elf32_Half st_shndx; -} - extern (D) { - auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; } - auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } } - -struct Elf32_Verdef -{ - Elf32_Half vd_version; - Elf32_Half vd_flags; - Elf32_Half vd_ndx; - Elf32_Half vd_cnt; - Elf32_Word vd_hash; - Elf32_Word vd_aux; - Elf32_Word vd_next; -} - -struct Elf32_Verdaux -{ - Elf32_Word vda_name; - Elf32_Word vda_next; -} - -struct Elf32_Verneed -{ - Elf32_Half vn_version; - Elf32_Half vn_cnt; - Elf32_Word vn_file; - Elf32_Word vn_aux; - Elf32_Word vn_next; -} - -struct Elf32_Vernaux -{ - Elf32_Word vna_hash; - Elf32_Half vna_flags; - Elf32_Half vna_other; - Elf32_Word vna_name; - Elf32_Word vna_next; -} - -alias Elf32_Half Elf32_Versym; - -struct Elf32_Syminfo -{ - Elf32_Half si_boundto; - Elf32_Half si_flags; -} diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/elf64.d b/libphobos/libdruntime/core/sys/freebsd/sys/elf64.d index 8c63e04..c56460c 100644 --- a/libphobos/libdruntime/core/sys/freebsd/sys/elf64.d +++ b/libphobos/libdruntime/core/sys/freebsd/sys/elf64.d @@ -13,71 +13,11 @@ nothrow: import core.stdc.stdint; public import core.sys.freebsd.sys.elf_common; -alias uint16_t Elf64_Half; -alias uint32_t Elf64_Word; -alias int32_t Elf64_Sword; alias uint64_t Elf64_Lword; -alias uint64_t Elf64_Xword; -alias int64_t Elf64_Sxword; -alias uint64_t Elf64_Addr; -alias uint64_t Elf64_Off; alias Elf64_Word Elf64_Hashelt; alias Elf64_Xword Elf64_Size; alias Elf64_Sxword Elf64_Ssize; -struct Elf64_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; -} - -struct Elf64_Lib -{ - Elf64_Word l_name; - Elf64_Word l_time_stamp; - Elf64_Word l_checksum; - Elf64_Word l_version; - Elf64_Word l_flags; -} - -struct Elf64_Shdr -{ - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -} - -struct Elf64_Phdr -{ - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf64_Xword p_filesz; - Elf64_Xword p_memsz; - Elf64_Xword p_align; -} - struct Elf64_Dyn { Elf64_Sxword d_tag; @@ -88,25 +28,8 @@ struct Elf64_Dyn } _d_un d_un; } -struct Elf64_Rel -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; -} - -struct Elf64_Rela -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; - Elf64_Sxword r_addend; -} - extern (D) { - auto ELF64_R_SYM(I)(I i) { return i >> 32; } - auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; } - auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type & 0xffffffff); } - auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; } auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; } auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } @@ -114,22 +37,6 @@ extern (D) alias Elf_Note Elf64_Nhdr; -struct Elf64_Move -{ - Elf64_Lword m_value; - Elf64_Xword m_info; - Elf64_Xword m_poffset; - Elf64_Half m_repeat; - Elf64_Half m_stride; -} - -extern (D) -{ - auto ELF64_M_SYM(I)(I info) { return info >> 8; } - auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF64_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } -} - struct Elf64_Cap { Elf64_Xword c_tag; @@ -140,63 +47,7 @@ struct Elf64_Cap } _c_un c_un; } -struct Elf64_Sym -{ - Elf64_Word st_name; - ubyte st_info; - ubyte st_other; - Elf64_Half st_shndx; - Elf64_Addr st_value; - Elf64_Xword st_size; -} - extern (D) { - auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF64_ST_TYPE(T)(T val) { return val & 0xf; } - auto ELF64_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; } } - -struct Elf64_Verdef -{ - Elf64_Half vd_version; - Elf64_Half vd_flags; - Elf64_Half vd_ndx; - Elf64_Half vd_cnt; - Elf64_Word vd_hash; - Elf64_Word vd_aux; - Elf64_Word vd_next; -} - -struct Elf64_Verdaux -{ - Elf64_Word vda_name; - Elf64_Word vda_next; -} - -struct Elf64_Verneed -{ - Elf64_Half vn_version; - Elf64_Half vn_cnt; - Elf64_Word vn_file; - Elf64_Word vn_aux; - Elf64_Word vn_next; -} - -struct Elf64_Vernaux -{ - Elf64_Word vna_hash; - Elf64_Half vna_flags; - Elf64_Half vna_other; - Elf64_Word vna_name; - Elf64_Word vna_next; -} - -alias Elf64_Half Elf64_Versym; - -struct Elf64_Syminfo -{ - Elf64_Half si_boundto; - Elf64_Half si_flags; -} diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/elf_common.d b/libphobos/libdruntime/core/sys/freebsd/sys/elf_common.d index 455de95..05e78bf 100644 --- a/libphobos/libdruntime/core/sys/freebsd/sys/elf_common.d +++ b/libphobos/libdruntime/core/sys/freebsd/sys/elf_common.d @@ -11,6 +11,7 @@ pure: nothrow: import core.stdc.stdint; +public import core.sys.elf; struct Elf_Note { @@ -27,57 +28,7 @@ struct Elf_GNU_Hash_Header uint32_t gh_shift2; } -enum EI_MAG0 = 0; -enum EI_MAG1 = 1; -enum EI_MAG2 = 2; -enum EI_MAG3 = 3; -enum EI_CLASS = 4; -enum EI_DATA = 5; -enum EI_VERSION = 6; -enum EI_OSABI = 7; -enum EI_ABIVERSION = 8; enum OLD_EI_BRAND = 8; -enum EI_PAD = 9; -enum EI_NIDENT = 16; - -enum ELFMAG0 = 0x7f; -enum ELFMAG1 = 'E'; -enum ELFMAG2 = 'L'; -enum ELFMAG3 = 'F'; -enum ELFMAG = "\177ELF"; -enum SELFMAG = 4; - -enum EV_NONE = 0; -enum EV_CURRENT = 1; - -enum ELFCLASSNONE = 0; -enum ELFCLASS32 = 1; -enum ELFCLASS64 = 2; - -enum ELFDATANONE = 0; -enum ELFDATA2LSB = 1; -enum ELFDATA2MSB = 2; - -enum ELFOSABI_NONE = 0; -enum ELFOSABI_SYSV = 0; -enum ELFOSABI_HPUX = 1; -enum ELFOSABI_NETBSD = 2; -enum ELFOSABI_LINUX = 3; -enum ELFOSABI_HURD = 4; -enum ELFOSABI_86OPEN = 5; -enum ELFOSABI_SOLARIS = 6; -enum ELFOSABI_AIX = 7; -enum ELFOSABI_MONTEREY = 7; -enum ELFOSABI_IRIX = 8; -enum ELFOSABI_FREEBSD = 9; -enum ELFOSABI_TRU64 = 10; -enum ELFOSABI_MODESTO = 11; -enum ELFOSABI_OPENBSD = 12; -enum ELFOSABI_OPENVMS = 13; -enum ELFOSABI_NSK = 14; -enum ELFOSABI_AROS = 15; -enum ELFOSABI_ARM = 97; -enum ELFOSABI_STANDALONE = 255; extern (D) { @@ -87,306 +38,28 @@ extern (D) ehdr.e_ident[EI_MAG3] == ELFMAG3; } } -enum ET_NONE = 0; -enum ET_REL = 1; -enum ET_EXEC = 2; -enum ET_DYN = 3; -enum ET_CORE = 4; -enum ET_LOOS = 0xfe00; -enum ET_HIOS = 0xfeff; -enum ET_LOPROC = 0xff00; -enum ET_HIPROC = 0xffff; - -enum EM_NONE = 0; -enum EM_M32 = 1; -enum EM_SPARC = 2; -enum EM_386 = 3; -enum EM_68K = 4; -enum EM_88K = 5; -enum EM_860 = 7; -enum EM_MIPS = 8; -enum EM_S370 = 9; -enum EM_MIPS_RS3_LE = 10; -enum EM_PARISC = 15; -enum EM_VPP500 = 17; -enum EM_SPARC32PLUS = 18; -enum EM_960 = 19; -enum EM_PPC = 20; -enum EM_PPC64 = 21; -enum EM_S390 = 22; -enum EM_V800 = 36; -enum EM_FR20 = 37; -enum EM_RH32 = 38; -enum EM_RCE = 39; -enum EM_ARM = 40; -enum EM_SH = 42; -enum EM_SPARCV9 = 43; -enum EM_TRICORE = 44; -enum EM_ARC = 45; -enum EM_H8_300 = 46; -enum EM_H8_300H = 47; -enum EM_H8S = 48; -enum EM_H8_500 = 49; -enum EM_IA_64 = 50; -enum EM_MIPS_X = 51; -enum EM_COLDFIRE = 52; -enum EM_68HC12 = 53; -enum EM_MMA = 54; -enum EM_PCP = 55; -enum EM_NCPU = 56; -enum EM_NDR1 = 57; -enum EM_STARCORE = 58; -enum EM_ME16 = 59; -enum EM_ST100 = 60; -enum EM_TINYJ = 61; -enum EM_X86_64 = 62; -enum EM_AMD64 = 62; -enum EM_PDSP = 63; -enum EM_FX66 = 66; -enum EM_ST9PLUS = 67; -enum EM_ST7 = 68; -enum EM_68HC16 = 69; -enum EM_68HC11 = 70; -enum EM_68HC08 = 71; -enum EM_68HC05 = 72; -enum EM_SVX = 73; -enum EM_ST19 = 74; -enum EM_VAX = 75; -enum EM_CRIS = 76; -enum EM_JAVELIN = 77; -enum EM_FIREPATH = 78; -enum EM_ZSP = 79; -enum EM_MMIX = 80; -enum EM_HUANY = 81; -enum EM_PRISM = 82; -enum EM_AVR = 83; -enum EM_FR30 = 84; -enum EM_D10V = 85; -enum EM_D30V = 86; -enum EM_V850 = 87; -enum EM_M32R = 88; -enum EM_MN10300 = 89; -enum EM_MN10200 = 90; -enum EM_PJ = 91; -enum EM_OPENRISC = 92; -enum EM_ARC_A5 = 93; -enum EM_XTENSA = 94; -enum EM_VIDEOCORE = 95; -enum EM_TMM_GPP = 96; -enum EM_NS32K = 97; -enum EM_TPC = 98; -enum EM_SNP1K = 99; -enum EM_ST200 = 100; -enum EM_IP2K = 101; -enum EM_MAX = 102; -enum EM_CR = 103; -enum EM_F2MC16 = 104; -enum EM_MSP430 = 105; -enum EM_BLACKFIN = 106; -enum EM_SE_C33 = 107; -enum EM_SEP = 108; -enum EM_ARCA = 109; -enum EM_UNICORE = 110; - enum EM_486 = 6; enum EM_MIPS_RS4_BE = 10; enum EM_ALPHA_STD = 41; -enum EM_ALPHA = 0x9026; - -enum SHN_UNDEF = 0; -enum SHN_LORESERVE = 0xff00; -enum SHN_LOPROC = 0xff00; -enum SHN_HIPROC = 0xff1f; -enum SHN_LOOS = 0xff20; -enum SHN_HIOS = 0xff3f; -enum SHN_ABS = 0xfff1; -enum SHN_COMMON = 0xfff2; -enum SHN_XINDEX = 0xffff; -enum SHN_HIRESERVE = 0xffff; - -enum SHT_NULL = 0; -enum SHT_PROGBITS = 1; -enum SHT_SYMTAB = 2; -enum SHT_STRTAB = 3; -enum SHT_RELA = 4; -enum SHT_HASH = 5; -enum SHT_DYNAMIC = 6; -enum SHT_NOTE = 7; -enum SHT_NOBITS = 8; -enum SHT_REL = 9; -enum SHT_SHLIB = 10; -enum SHT_DYNSYM = 11; -enum SHT_INIT_ARRAY = 14; -enum SHT_FINI_ARRAY = 15; -enum SHT_PREINIT_ARRAY = 16; -enum SHT_GROUP = 17; -enum SHT_SYMTAB_SHNDX = 18; -enum SHT_LOOS = 0x60000000; -enum SHT_LOSUNW = 0x6ffffff4; enum SHT_SUNW_dof = 0x6ffffff4; enum SHT_SUNW_cap = 0x6ffffff5; enum SHT_SUNW_SIGNATURE = 0x6ffffff6; -enum SHT_GNU_HASH = 0x6ffffff6; -enum SHT_SUNW_ANNOTATE = 0x6ffffff7; -enum SHT_SUNW_DEBUGSTR = 0x6ffffff8; -enum SHT_SUNW_DEBUG = 0x6ffffff9; -enum SHT_SUNW_move = 0x6ffffffa; -enum SHT_SUNW_COMDAT = 0x6ffffffb; -enum SHT_SUNW_syminfo = 0x6ffffffc; enum SHT_SUNW_verdef = 0x6ffffffd; -enum SHT_GNU_verdef = 0x6ffffffd; enum SHT_SUNW_verneed = 0x6ffffffe; -enum SHT_GNU_verneed = 0x6ffffffe; enum SHT_SUNW_versym = 0x6fffffff; -enum SHT_GNU_versym = 0x6fffffff; -enum SHT_HISUNW = 0x6fffffff; -enum SHT_HIOS = 0x6fffffff; -enum SHT_LOPROC = 0x70000000; -enum SHT_AMD64_UNWIND = 0x70000001; -enum SHT_ARM_EXIDX = 0x70000001; -enum SHT_ARM_PREEMPTMAP = 0x70000002; -enum SHT_ARM_ATTRIBUTES = 0x70000003; -enum SHT_ARM_DEBUGOVERLAY = 0x70000004; -enum SHT_ARM_OVERLAYSECTION = 0x70000005; -enum SHT_MIPS_REGINFO = 0x70000006; -enum SHT_MIPS_OPTIONS = 0x7000000d; -enum SHT_MIPS_DWARF = 0x7000001e; -enum SHT_HIPROC = 0x7fffffff; -enum SHT_LOUSER = 0x80000000; -enum SHT_HIUSER = 0x8fffffff; -enum SHF_WRITE = (1 << 0); -enum SHF_ALLOC = (1 << 1); -enum SHF_EXECINSTR = (1 << 2); -enum SHF_MERGE = (1 << 4); -enum SHF_STRINGS = (1 << 5); -enum SHF_INFO_LINK = (1 << 6); -enum SHF_LINK_ORDER = (1 << 7); -enum SHF_OS_NONCONFORMING = (1 << 8); -enum SHF_GROUP = (1 << 9); -enum SHF_TLS = (1 << 10); -enum SHF_COMPRESSED = (1 << 11); -enum SHF_MASKOS = 0x0ff00000; -enum SHF_MASKPROC = 0xf0000000; - -enum PT_NULL = 0; -enum PT_LOAD = 1; -enum PT_DYNAMIC = 2; -enum PT_INTERP = 3; -enum PT_NOTE = 4; -enum PT_SHLIB = 5; -enum PT_PHDR = 6; -enum PT_TLS = 7; -enum PT_LOOS = 0x60000000; -enum PT_SUNW_UNWIND = 0x6464e550; -enum PT_GNU_EH_FRAME = 0x6474e550; -enum PT_GNU_STACK = 0x6474e551; -enum PT_GNU_RELRO = 0x6474e552; -enum PT_LOSUNW = 0x6ffffffa; -enum PT_SUNWBSS = 0x6ffffffa; -enum PT_SUNWSTACK = 0x6ffffffb; enum PT_SUNWDTRACE = 0x6ffffffc; enum PT_SUNWCAP = 0x6ffffffd; -enum PT_HISUNW = 0x6fffffff; -enum PT_HIOS = 0x6fffffff; -enum PT_LOPROC = 0x70000000; -enum PT_HIPROC = 0x7fffffff; - -enum PF_X = (1 << 0); -enum PF_W = (1 << 1); -enum PF_R = (1 << 2); -enum PF_MASKOS = 0x0ff00000; -enum PF_MASKPROC = 0xf0000000; -enum PN_XNUM = 0xffff; - -enum DT_NULL = 0; -enum DT_NEEDED = 1; -enum DT_PLTRELSZ = 2; -enum DT_PLTGOT = 3; -enum DT_HASH = 4; -enum DT_STRTAB = 5; -enum DT_SYMTAB = 6; -enum DT_RELA = 7; -enum DT_RELASZ = 8; -enum DT_RELAENT = 9; -enum DT_STRSZ = 10; -enum DT_SYMENT = 11; -enum DT_INIT = 12; -enum DT_FINI = 13; -enum DT_SONAME = 14; -enum DT_RPATH = 15; -enum DT_SYMBOLIC = 16; -enum DT_REL = 17; -enum DT_RELSZ = 18; -enum DT_RELENT = 19; -enum DT_PLTREL = 20; -enum DT_DEBUG = 21; -enum DT_TEXTREL = 22; -enum DT_JMPREL = 23; -enum DT_BIND_NOW = 24; -enum DT_INIT_ARRAY = 25; -enum DT_FINI_ARRAY = 26; -enum DT_INIT_ARRAYSZ = 27; -enum DT_FINI_ARRAYSZ = 28; -enum DT_RUNPATH = 29; -enum DT_FLAGS = 30; -enum DT_ENCODING = 32; -enum DT_PREINIT_ARRAY = 32; -enum DT_PREINIT_ARRAYSZ = 33; enum DT_MAXPOSTAGS = 34; -enum DT_LOOS = 0x6000000d; enum DT_SUNW_AUXILIARY = 0x6000000d; enum DT_SUNW_RTLDINF = 0x6000000e; enum DT_SUNW_FILTER = 0x6000000f; enum DT_SUNW_CAP = 0x60000010; -enum DT_HIOS = 0x6ffff000; -enum DT_VALRNGLO = 0x6ffffd00; -enum DT_CHECKSUM = 0x6ffffdf8; -enum DT_PLTPADSZ = 0x6ffffdf9; -enum DT_MOVEENT = 0x6ffffdfa; -enum DT_MOVESZ = 0x6ffffdfb; -enum DT_FEATURE_1 = 0x6ffffdfc; -enum DT_POSFLAG_1 = 0x6ffffdfd; -enum DT_SYMINSZ = 0x6ffffdfe; -enum DT_SYMINENT = 0x6ffffdff; -enum DT_VALRNGHI = 0x6ffffdff; -enum DT_ADDRRNGLO = 0x6ffffe00; -enum DT_GNU_HASH = 0x6ffffef5; -enum DT_CONFIG = 0x6ffffefa; -enum DT_DEPAUDIT = 0x6ffffefb; -enum DT_AUDIT = 0x6ffffefc; -enum DT_PLTPAD = 0x6ffffefd; -enum DT_MOVETAB = 0x6ffffefe; -enum DT_SYMINFO = 0x6ffffeff; -enum DT_ADDRRNGHI = 0x6ffffeff; -enum DT_VERSYM = 0x6ffffff0; -enum DT_RELACOUNT = 0x6ffffff9; -enum DT_RELCOUNT = 0x6ffffffa; -enum DT_FLAGS_1 = 0x6ffffffb; -enum DT_VERDEF = 0x6ffffffc; -enum DT_VERDEFNUM = 0x6ffffffd; -enum DT_VERNEED = 0x6ffffffe; -enum DT_VERNEEDNUM = 0x6fffffff; -enum DT_LOPROC = 0x70000000; enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001; -enum DT_AUXILIARY = 0x7ffffffd; enum DT_USED = 0x7ffffffe; -enum DT_FILTER = 0x7fffffff; -enum DT_HIPROC = 0x7fffffff; - -enum DF_ORIGIN = 0x00000001; -enum DF_SYMBOLIC = 0x00000002; -enum DF_TEXTREL = 0x00000004; -enum DF_BIND_NOW = 0x00000008; -enum DF_STATIC_TLS = 0x00000010; enum DF_1_BIND_NOW = 0x00000001; -enum DF_1_GLOBAL = 0x00000002; -enum DF_1_NODELETE = 0x00000008; -enum DF_1_LOADFLTR = 0x00000010; -enum DF_1_NOOPEN = 0x00000040; -enum DF_1_NODEFLIB = 0x00000800; enum NT_PRSTATUS = 1; enum NT_FPREGSET = 2; @@ -402,55 +75,19 @@ enum NT_PROCSTAT_OSREL = 14; enum NT_PROCSTAT_PSSTRINGS = 15; enum NT_PROCSTAT_AUXV = 16; -enum STB_LOCAL = 0; -enum STB_GLOBAL = 1; -enum STB_WEAK = 2; -enum STB_NUM = 3; -enum STB_LOOS = 10; -enum STB_HIOS = 12; -enum STB_LOPROC = 13; -enum STB_HIPROC = 15; - -enum STT_NOTYPE = 0; -enum STT_OBJECT = 1; -enum STT_FUNC = 2; -enum STT_SECTION = 3; -enum STT_FILE = 4; -enum STT_COMMON = 5; -enum STT_TLS = 6; -enum STT_NUM = 7; -enum STT_LOOS = 10; -enum STT_GNU_IFUNC = 10; -enum STT_HIOS = 12; -enum STT_LOPROC = 13; -enum STT_HIPROC = 15; - -enum STV_DEFAULT = 0; -enum STV_INTERNAL = 1; -enum STV_HIDDEN = 2; -enum STV_PROTECTED = 3; enum STV_EXPORTED = 4; enum STV_SINGLETON = 5; enum STV_ELIMINATE = 6; -enum STN_UNDEF = 0; - -enum VER_DEF_CURRENT = 1; alias VER_NDX VER_DEF_IDX; -enum VER_FLG_BASE = 0x1; -enum VER_FLG_WEAK = 0x2; - -enum VER_NEED_CURRENT = 1; enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; alias VER_NDX VER_NEED_IDX; -enum VER_NDX_LOCAL = 0; -enum VER_NDX_GLOBAL = 1; enum VER_NDX_GIVEN = 2; - enum VER_NDX_HIDDEN = 32768; + extern (D) { auto VER_NDX(V)(V v) { return v & ~(1u << 15); } @@ -460,420 +97,28 @@ enum CA_SUNW_NULL = 0; enum CA_SUNW_HW_1 = 1; enum CA_SUNW_SF_1 = 2; -enum SYMINFO_FLG_DIRECT = 0x0001; -enum SYMINFO_FLG_PASSTHRU = 0x0002; -enum SYMINFO_FLG_COPY = 0x0004; -enum SYMINFO_FLG_LAZYLOAD = 0x0008; enum SYMINFO_FLG_DIRECTBIND = 0x0010; enum SYMINFO_FLG_NOEXTDIRECT = 0x0020; enum SYMINFO_FLG_FILTER = 0x0002; enum SYMINFO_FLG_AUXILIARY = 0x0040; -enum SYMINFO_BT_SELF = 0xffff; -enum SYMINFO_BT_PARENT = 0xfffe; enum SYMINFO_BT_NONE = 0xfffd; enum SYMINFO_BT_EXTERN = 0xfffc; -enum SYMINFO_BT_LOWRESERVE = 0xff00; - -enum SYMINFO_NONE = 0; -enum SYMINFO_CURRENT = 1; -enum SYMINFO_NUM = 2; - -enum R_386_NONE = 0; -enum R_386_32 = 1; -enum R_386_PC32 = 2; -enum R_386_GOT32 = 3; -enum R_386_PLT32 = 4; -enum R_386_COPY = 5; -enum R_386_GLOB_DAT = 6; -enum R_386_JMP_SLOT = 7; -enum R_386_RELATIVE = 8; -enum R_386_GOTOFF = 9; -enum R_386_GOTPC = 10; -enum R_386_TLS_TPOFF = 14; -enum R_386_TLS_IE = 15; -enum R_386_TLS_GOTIE = 16; -enum R_386_TLS_LE = 17; -enum R_386_TLS_GD = 18; -enum R_386_TLS_LDM = 19; -enum R_386_TLS_GD_32 = 24; -enum R_386_TLS_GD_PUSH = 25; -enum R_386_TLS_GD_CALL = 26; -enum R_386_TLS_GD_POP = 27; -enum R_386_TLS_LDM_32 = 28; -enum R_386_TLS_LDM_PUSH = 29; -enum R_386_TLS_LDM_CALL = 30; -enum R_386_TLS_LDM_POP = 31; -enum R_386_TLS_LDO_32 = 32; -enum R_386_TLS_IE_32 = 33; -enum R_386_TLS_LE_32 = 34; -enum R_386_TLS_DTPMOD32 = 35; -enum R_386_TLS_DTPOFF32 = 36; -enum R_386_TLS_TPOFF32 = 37; -enum R_386_IRELATIVE = 42; - -enum R_ARM_NONE = 0; -enum R_ARM_PC24 = 1; -enum R_ARM_ABS32 = 2; -enum R_ARM_REL32 = 3; -enum R_ARM_PC13 = 4; -enum R_ARM_ABS16 = 5; -enum R_ARM_ABS12 = 6; -enum R_ARM_THM_ABS5 = 7; -enum R_ARM_ABS8 = 8; -enum R_ARM_SBREL32 = 9; -enum R_ARM_THM_PC22 = 10; -enum R_ARM_THM_PC8 = 11; -enum R_ARM_AMP_VCALL9 = 12; -enum R_ARM_SWI24 = 13; -enum R_ARM_THM_SWI8 = 14; -enum R_ARM_XPC25 = 15; -enum R_ARM_THM_XPC22 = 16; -enum R_ARM_TLS_DTPMOD32 = 17; -enum R_ARM_TLS_DTPOFF32 = 18; -enum R_ARM_TLS_TPOFF32 = 19; -enum R_ARM_COPY = 20; -enum R_ARM_GLOB_DAT = 21; -enum R_ARM_JUMP_SLOT = 22; -enum R_ARM_RELATIVE = 23; -enum R_ARM_GOTOFF = 24; -enum R_ARM_GOTPC = 25; -enum R_ARM_GOT32 = 26; -enum R_ARM_PLT32 = 27; -enum R_ARM_GNU_VTENTRY = 100; -enum R_ARM_GNU_VTINHERIT = 101; -enum R_ARM_RSBREL32 = 250; -enum R_ARM_THM_RPC22 = 251; -enum R_ARM_RREL32 = 252; -enum R_ARM_RABS32 = 253; -enum R_ARM_RPC24 = 254; -enum R_ARM_RBASE = 255; - -enum R_IA_64_NONE = 0; -enum R_IA_64_IMM14 = 0x21; -enum R_IA_64_IMM22 = 0x22; -enum R_IA_64_IMM64 = 0x23; -enum R_IA_64_DIR32MSB = 0x24; -enum R_IA_64_DIR32LSB = 0x25; -enum R_IA_64_DIR64MSB = 0x26; -enum R_IA_64_DIR64LSB = 0x27; -enum R_IA_64_GPREL22 = 0x2a; -enum R_IA_64_GPREL64I = 0x2b; -enum R_IA_64_GPREL32MSB = 0x2c; -enum R_IA_64_GPREL32LSB = 0x2d; -enum R_IA_64_GPREL64MSB = 0x2e; -enum R_IA_64_GPREL64LSB = 0x2f; -enum R_IA_64_LTOFF22 = 0x32; -enum R_IA_64_LTOFF64I = 0x33; -enum R_IA_64_PLTOFF22 = 0x3a; -enum R_IA_64_PLTOFF64I = 0x3b; -enum R_IA_64_PLTOFF64MSB = 0x3e; -enum R_IA_64_PLTOFF64LSB = 0x3f; -enum R_IA_64_FPTR64I = 0x43; -enum R_IA_64_FPTR32MSB = 0x44; -enum R_IA_64_FPTR32LSB = 0x45; -enum R_IA_64_FPTR64MSB = 0x46; -enum R_IA_64_FPTR64LSB = 0x47; -enum R_IA_64_PCREL60B = 0x48; -enum R_IA_64_PCREL21B = 0x49; -enum R_IA_64_PCREL21M = 0x4a; -enum R_IA_64_PCREL21F = 0x4b; -enum R_IA_64_PCREL32MSB = 0x4c; -enum R_IA_64_PCREL32LSB = 0x4d; -enum R_IA_64_PCREL64MSB = 0x4e; -enum R_IA_64_PCREL64LSB = 0x4f; -enum R_IA_64_LTOFF_FPTR22 = 0x52; -enum R_IA_64_LTOFF_FPTR64I = 0x53; -enum R_IA_64_LTOFF_FPTR32MSB = 0x54; -enum R_IA_64_LTOFF_FPTR32LSB = 0x55; -enum R_IA_64_LTOFF_FPTR64MSB = 0x56; -enum R_IA_64_LTOFF_FPTR64LSB = 0x57; -enum R_IA_64_SEGREL32MSB = 0x5c; -enum R_IA_64_SEGREL32LSB = 0x5d; -enum R_IA_64_SEGREL64MSB = 0x5e; -enum R_IA_64_SEGREL64LSB = 0x5f; -enum R_IA_64_SECREL32MSB = 0x64; -enum R_IA_64_SECREL32LSB = 0x65; -enum R_IA_64_SECREL64MSB = 0x66; -enum R_IA_64_SECREL64LSB = 0x67; -enum R_IA_64_REL32MSB = 0x6c; -enum R_IA_64_REL32LSB = 0x6d; -enum R_IA_64_REL64MSB = 0x6e; -enum R_IA_64_REL64LSB = 0x6f; -enum R_IA_64_LTV32MSB = 0x74; -enum R_IA_64_LTV32LSB = 0x75; -enum R_IA_64_LTV64MSB = 0x76; -enum R_IA_64_LTV64LSB = 0x77; -enum R_IA_64_PCREL21BI = 0x79; -enum R_IA_64_PCREL22 = 0x7a; -enum R_IA_64_PCREL64I = 0x7b; -enum R_IA_64_IPLTMSB = 0x80; -enum R_IA_64_IPLTLSB = 0x81; -enum R_IA_64_SUB = 0x85; -enum R_IA_64_LTOFF22X = 0x86; -enum R_IA_64_LDXMOV = 0x87; -enum R_IA_64_TPREL14 = 0x91; -enum R_IA_64_TPREL22 = 0x92; -enum R_IA_64_TPREL64I = 0x93; -enum R_IA_64_TPREL64MSB = 0x96; -enum R_IA_64_TPREL64LSB = 0x97; -enum R_IA_64_LTOFF_TPREL22 = 0x9a; -enum R_IA_64_DTPMOD64MSB = 0xa6; -enum R_IA_64_DTPMOD64LSB = 0xa7; -enum R_IA_64_LTOFF_DTPMOD22 = 0xaa; -enum R_IA_64_DTPREL14 = 0xb1; -enum R_IA_64_DTPREL22 = 0xb2; -enum R_IA_64_DTPREL64I = 0xb3; -enum R_IA_64_DTPREL32MSB = 0xb4; -enum R_IA_64_DTPREL32LSB = 0xb5; -enum R_IA_64_DTPREL64MSB = 0xb6; -enum R_IA_64_DTPREL64LSB = 0xb7; -enum R_IA_64_LTOFF_DTPREL22 = 0xba; - -enum R_MIPS_NONE = 0; -enum R_MIPS_16 = 1; -enum R_MIPS_32 = 2; -enum R_MIPS_REL32 = 3; -enum R_MIPS_26 = 4; -enum R_MIPS_HI16 = 5; -enum R_MIPS_LO16 = 6; -enum R_MIPS_GPREL16 = 7; -enum R_MIPS_LITERAL = 8; -enum R_MIPS_GOT16 = 9; -enum R_MIPS_PC16 = 10; -enum R_MIPS_CALL16 = 11; -enum R_MIPS_GPREL32 = 12; -enum R_MIPS_GOTHI16 = 21; -enum R_MIPS_GOTLO16 = 22; -enum R_MIPS_CALLHI16 = 30; -enum R_MIPS_CALLLO16 = 31; - -enum R_PPC_NONE = 0; -enum R_PPC_ADDR32 = 1; -enum R_PPC_ADDR24 = 2; -enum R_PPC_ADDR16 = 3; -enum R_PPC_ADDR16_LO = 4; -enum R_PPC_ADDR16_HI = 5; -enum R_PPC_ADDR16_HA = 6; -enum R_PPC_ADDR14 = 7; -enum R_PPC_ADDR14_BRTAKEN = 8; -enum R_PPC_ADDR14_BRNTAKEN = 9; -enum R_PPC_REL24 = 10; -enum R_PPC_REL14 = 11; -enum R_PPC_REL14_BRTAKEN = 12; -enum R_PPC_REL14_BRNTAKEN = 13; -enum R_PPC_GOT16 = 14; -enum R_PPC_GOT16_LO = 15; -enum R_PPC_GOT16_HI = 16; -enum R_PPC_GOT16_HA = 17; -enum R_PPC_PLTREL24 = 18; -enum R_PPC_COPY = 19; -enum R_PPC_GLOB_DAT = 20; -enum R_PPC_JMP_SLOT = 21; -enum R_PPC_RELATIVE = 22; -enum R_PPC_LOCAL24PC = 23; -enum R_PPC_UADDR32 = 24; -enum R_PPC_UADDR16 = 25; -enum R_PPC_REL32 = 26; -enum R_PPC_PLT32 = 27; -enum R_PPC_PLTREL32 = 28; -enum R_PPC_PLT16_LO = 29; -enum R_PPC_PLT16_HI = 30; -enum R_PPC_PLT16_HA = 31; -enum R_PPC_SDAREL16 = 32; -enum R_PPC_SECTOFF = 33; -enum R_PPC_SECTOFF_LO = 34; -enum R_PPC_SECTOFF_HI = 35; -enum R_PPC_SECTOFF_HA = 36; - -enum R_PPC64_ADDR64 = 38; -enum R_PPC64_ADDR16_HIGHER = 39; -enum R_PPC64_ADDR16_HIGHERA = 40; -enum R_PPC64_ADDR16_HIGHEST = 41; -enum R_PPC64_ADDR16_HIGHESTA = 42; -enum R_PPC64_UADDR64 = 43; -enum R_PPC64_REL64 = 44; -enum R_PPC64_PLT64 = 45; -enum R_PPC64_PLTREL64 = 46; -enum R_PPC64_TOC16 = 47; -enum R_PPC64_TOC16_LO = 48; -enum R_PPC64_TOC16_HI = 49; -enum R_PPC64_TOC16_HA = 50; -enum R_PPC64_TOC = 51; -enum R_PPC64_DTPMOD64 = 68; -enum R_PPC64_TPREL64 = 73; -enum R_PPC64_DTPREL64 = 78; - -enum R_PPC_TLS = 67; -enum R_PPC_DTPMOD32 = 68; -enum R_PPC_TPREL16 = 69; -enum R_PPC_TPREL16_LO = 70; -enum R_PPC_TPREL16_HI = 71; -enum R_PPC_TPREL16_HA = 72; -enum R_PPC_TPREL32 = 73; -enum R_PPC_DTPREL16 = 74; -enum R_PPC_DTPREL16_LO = 75; -enum R_PPC_DTPREL16_HI = 76; -enum R_PPC_DTPREL16_HA = 77; -enum R_PPC_DTPREL32 = 78; -enum R_PPC_GOT_TLSGD16 = 79; -enum R_PPC_GOT_TLSGD16_LO = 80; -enum R_PPC_GOT_TLSGD16_HI = 81; -enum R_PPC_GOT_TLSGD16_HA = 82; -enum R_PPC_GOT_TLSLD16 = 83; -enum R_PPC_GOT_TLSLD16_LO = 84; -enum R_PPC_GOT_TLSLD16_HI = 85; -enum R_PPC_GOT_TLSLD16_HA = 86; -enum R_PPC_GOT_TPREL16 = 87; -enum R_PPC_GOT_TPREL16_LO = 88; -enum R_PPC_GOT_TPREL16_HI = 89; -enum R_PPC_GOT_TPREL16_HA = 90; - -enum R_PPC_EMB_NADDR32 = 101; -enum R_PPC_EMB_NADDR16 = 102; -enum R_PPC_EMB_NADDR16_LO = 103; -enum R_PPC_EMB_NADDR16_HI = 104; -enum R_PPC_EMB_NADDR16_HA = 105; -enum R_PPC_EMB_SDAI16 = 106; -enum R_PPC_EMB_SDA2I16 = 107; -enum R_PPC_EMB_SDA2REL = 108; -enum R_PPC_EMB_SDA21 = 109; -enum R_PPC_EMB_MRKREF = 110; -enum R_PPC_EMB_RELSEC16 = 111; -enum R_PPC_EMB_RELST_LO = 112; -enum R_PPC_EMB_RELST_HI = 113; -enum R_PPC_EMB_RELST_HA = 114; -enum R_PPC_EMB_BIT_FLD = 115; -enum R_PPC_EMB_RELSDA = 116; - -enum R_SPARC_NONE = 0; -enum R_SPARC_8 = 1; -enum R_SPARC_16 = 2; -enum R_SPARC_32 = 3; -enum R_SPARC_DISP8 = 4; -enum R_SPARC_DISP16 = 5; -enum R_SPARC_DISP32 = 6; -enum R_SPARC_WDISP30 = 7; -enum R_SPARC_WDISP22 = 8; -enum R_SPARC_HI22 = 9; -enum R_SPARC_22 = 10; -enum R_SPARC_13 = 11; -enum R_SPARC_LO10 = 12; -enum R_SPARC_GOT10 = 13; -enum R_SPARC_GOT13 = 14; -enum R_SPARC_GOT22 = 15; -enum R_SPARC_PC10 = 16; -enum R_SPARC_PC22 = 17; -enum R_SPARC_WPLT30 = 18; -enum R_SPARC_COPY = 19; -enum R_SPARC_GLOB_DAT = 20; -enum R_SPARC_JMP_SLOT = 21; -enum R_SPARC_RELATIVE = 22; -enum R_SPARC_UA32 = 23; -enum R_SPARC_PLT32 = 24; -enum R_SPARC_HIPLT22 = 25; -enum R_SPARC_LOPLT10 = 26; -enum R_SPARC_PCPLT32 = 27; -enum R_SPARC_PCPLT22 = 28; -enum R_SPARC_PCPLT10 = 29; -enum R_SPARC_10 = 30; -enum R_SPARC_11 = 31; -enum R_SPARC_64 = 32; -enum R_SPARC_OLO10 = 33; -enum R_SPARC_HH22 = 34; -enum R_SPARC_HM10 = 35; -enum R_SPARC_LM22 = 36; -enum R_SPARC_PC_HH22 = 37; -enum R_SPARC_PC_HM10 = 38; -enum R_SPARC_PC_LM22 = 39; -enum R_SPARC_WDISP16 = 40; -enum R_SPARC_WDISP19 = 41; -enum R_SPARC_GLOB_JMP = 42; -enum R_SPARC_7 = 43; -enum R_SPARC_5 = 44; -enum R_SPARC_6 = 45; -enum R_SPARC_DISP64 = 46; -enum R_SPARC_PLT64 = 47; -enum R_SPARC_HIX22 = 48; -enum R_SPARC_LOX10 = 49; -enum R_SPARC_H44 = 50; -enum R_SPARC_M44 = 51; -enum R_SPARC_L44 = 52; -enum R_SPARC_REGISTER = 53; -enum R_SPARC_UA64 = 54; -enum R_SPARC_UA16 = 55; -enum R_SPARC_TLS_GD_HI22 = 56; -enum R_SPARC_TLS_GD_LO10 = 57; -enum R_SPARC_TLS_GD_ADD = 58; -enum R_SPARC_TLS_GD_CALL = 59; -enum R_SPARC_TLS_LDM_HI22 = 60; -enum R_SPARC_TLS_LDM_LO10 = 61; -enum R_SPARC_TLS_LDM_ADD = 62; -enum R_SPARC_TLS_LDM_CALL = 63; -enum R_SPARC_TLS_LDO_HIX22 = 64; -enum R_SPARC_TLS_LDO_LOX10 = 65; -enum R_SPARC_TLS_LDO_ADD = 66; -enum R_SPARC_TLS_IE_HI22 = 67; -enum R_SPARC_TLS_IE_LO10 = 68; -enum R_SPARC_TLS_IE_LD = 69; -enum R_SPARC_TLS_IE_LDX = 70; -enum R_SPARC_TLS_IE_ADD = 71; -enum R_SPARC_TLS_LE_HIX22 = 72; -enum R_SPARC_TLS_LE_LOX10 = 73; -enum R_SPARC_TLS_DTPMOD32 = 74; -enum R_SPARC_TLS_DTPMOD64 = 75; -enum R_SPARC_TLS_DTPOFF32 = 76; -enum R_SPARC_TLS_DTPOFF64 = 77; -enum R_SPARC_TLS_TPOFF32 = 78; -enum R_SPARC_TLS_TPOFF64 = 79; - -enum R_X86_64_NONE = 0; -enum R_X86_64_64 = 1; -enum R_X86_64_PC32 = 2; -enum R_X86_64_GOT32 = 3; -enum R_X86_64_PLT32 = 4; -enum R_X86_64_COPY = 5; -enum R_X86_64_GLOB_DAT = 6; -enum R_X86_64_JMP_SLOT = 7; -enum R_X86_64_RELATIVE = 8; -enum R_X86_64_GOTPCREL = 9; -enum R_X86_64_32 = 10; -enum R_X86_64_32S = 11; -enum R_X86_64_16 = 12; -enum R_X86_64_PC16 = 13; -enum R_X86_64_8 = 14; -enum R_X86_64_PC8 = 15; -enum R_X86_64_DTPMOD64 = 16; -enum R_X86_64_DTPOFF64 = 17; -enum R_X86_64_TPOFF64 = 18; -enum R_X86_64_TLSGD = 19; -enum R_X86_64_TLSLD = 20; -enum R_X86_64_DTPOFF32 = 21; -enum R_X86_64_GOTTPOFF = 22; -enum R_X86_64_TPOFF32 = 23; -enum R_X86_64_IRELATIVE = 37; version (PPC64) { -enum __ELF_WORD_SIZE = 64; -enum ELF_ARCH = EM_PPC64; -enum ELF_MACHINE_OK(x) = ((x) == EM_PPC64); + enum __ELF_WORD_SIZE = 64; + enum ELF_ARCH = EM_PPC64; + enum ELF_MACHINE_OK(x) = ((x) == EM_PPC64); } version (PPC) { -enum __ELF_WORD_SIZE = 32; -enum ELF_ARCH = EM_PPC; -enum ELF_ARCH32 = EM_PPC; -enum ELF_MACHINE_OK(x) = ((x) == EM_PPC); + enum __ELF_WORD_SIZE = 32; + enum ELF_ARCH = EM_PPC; + enum ELF_ARCH32 = EM_PPC; + enum ELF_MACHINE_OK(x) = ((x) == EM_PPC); } -/** - * Auxiliary vector entries for passing information to the interpreter. - * - * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t", - * but POSIX lays claim to all symbols ending with "_t". - */ - struct Elf32_Auxinfo { int a_type; @@ -896,12 +141,6 @@ struct Elf64_Auxinfo } } -// __ElfType(Auxinfo); - -/** - * Values for a_type. - */ - enum AT_NULL = 0; enum AT_IGNORE = 1; enum AT_EXECFD = 2; @@ -926,31 +165,23 @@ enum AT_STACKPROT = 21; enum AT_TIMEKEEP = 22; enum AT_COUNT = 23; -/** - * Relocation types. - */ - enum R_PPC_COUNT = 37; enum R_PPC_EMB_COUNT = (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1); -/** - * Define "machine" characteristics - */ - version (PPC64) { -enum ELF_TARG_CLASS = ELFCLASS64; -enum ELF_TARG_DATA = ELFDATA2MSB; -enum ELF_TARG_MACH = EM_PPC64; -enum ELF_TARG_VER = 1; + enum ELF_TARG_CLASS = ELFCLASS64; + enum ELF_TARG_DATA = ELFDATA2MSB; + enum ELF_TARG_MACH = EM_PPC64; + enum ELF_TARG_VER = 1; } version (PPC) { -enum ELF_TARG_CLASS = ELFCLASS32; -enum ELF_TARG_DATA = ELFDATA2MSB; -enum ELF_TARG_MACH = EM_PPC; -enum ELF_TARG_VER = 1; + enum ELF_TARG_CLASS = ELFCLASS32; + enum ELF_TARG_DATA = ELFDATA2MSB; + enum ELF_TARG_MACH = EM_PPC; + enum ELF_TARG_VER = 1; } enum ET_DYN_LOAD_ADDR = 0x01010000; diff --git a/libphobos/libdruntime/core/sys/linux/config.d b/libphobos/libdruntime/core/sys/linux/config.d index 03d3e17..5d38244f 100644 --- a/libphobos/libdruntime/core/sys/linux/config.d +++ b/libphobos/libdruntime/core/sys/linux/config.d @@ -24,6 +24,9 @@ deprecated("use _DEFAULT_SOURCE") enum _SVID_SOURCE = true; } +deprecated("use _DEFAULT_SOURCE") enum __USE_MISC = _DEFAULT_SOURCE; +deprecated("use _ATFILE_SOURCE") enum __USE_ATFILE = _ATFILE_SOURCE; +deprecated("use _GNU_SOURCE") enum __USE_GNU = _GNU_SOURCE; diff --git a/libphobos/libdruntime/core/sys/linux/dlfcn.d b/libphobos/libdruntime/core/sys/linux/dlfcn.d index 4a12284..fbb8462 100644 --- a/libphobos/libdruntime/core/sys/linux/dlfcn.d +++ b/libphobos/libdruntime/core/sys/linux/dlfcn.d @@ -34,7 +34,7 @@ import core.sys.linux.config; version (X86_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h - static if (__USE_GNU) + static if (_GNU_SOURCE) { RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) { @@ -48,7 +48,7 @@ version (X86_Any) else version (HPPA_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/hppa/bits/dlfcn.h - static if (__USE_GNU) + static if (_GNU_SOURCE) { RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) { @@ -62,7 +62,7 @@ else version (HPPA_Any) else version (MIPS_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=ports/sysdeps/mips/bits/dlfcn.h - static if (__USE_GNU) + static if (_GNU_SOURCE) { RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) { @@ -76,7 +76,7 @@ else version (MIPS_Any) else version (PPC_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h - static if (__USE_GNU) + static if (_GNU_SOURCE) { RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) { @@ -90,7 +90,7 @@ else version (PPC_Any) else version (ARM_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h - static if (__USE_GNU) + static if (_GNU_SOURCE) { RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) { @@ -104,7 +104,7 @@ else version (ARM_Any) else version (RISCV_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h - static if (__USE_GNU) + static if (_GNU_SOURCE) { RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) { @@ -118,7 +118,7 @@ else version (RISCV_Any) else version (SPARC_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h - static if (__USE_GNU) + static if (_GNU_SOURCE) { RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) { @@ -132,7 +132,7 @@ else version (SPARC_Any) else version (IBMZ_Any) { // http://sourceware.org/git/?p=glibc.git;a=blob;f=bits/dlfcn.h - static if (__USE_GNU) + static if (_GNU_SOURCE) { RT DL_CALL_FCT(RT, Args...)(RT function(Args) fctp, auto ref Args args) { @@ -148,7 +148,7 @@ else // <bits/dlfcn.h> -static if (__USE_GNU) +static if (_GNU_SOURCE) { enum RTLD_NEXT = cast(void *)-1L; enum RTLD_DEFAULT = cast(void *)0; @@ -161,7 +161,7 @@ static if (__USE_GNU) // int dlclose(void* __handle); // POSIX // void* dlsym(void* __handle, const scope char* __name); // POSIX -static if (__USE_GNU) +static if (_GNU_SOURCE) { void* dlmopen(Lmid_t __nsid, const scope char* __file, int __mode); void* dlvsym(void* __handle, const scope char* __name, const scope char* __version); @@ -169,7 +169,7 @@ static if (__USE_GNU) // char* dlerror(); // POSIX -static if (__USE_GNU) +static if (_GNU_SOURCE) { int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags); diff --git a/libphobos/libdruntime/core/sys/linux/elf.d b/libphobos/libdruntime/core/sys/linux/elf.d index 4d0b227..168b936 100644 --- a/libphobos/libdruntime/core/sys/linux/elf.d +++ b/libphobos/libdruntime/core/sys/linux/elf.d @@ -12,494 +12,28 @@ nothrow: @system: import core.stdc.stdint; - -alias uint16_t Elf32_Half; -alias uint16_t Elf64_Half; - -alias uint32_t Elf32_Word; -alias int32_t Elf32_Sword; -alias uint32_t Elf64_Word; -alias int32_t Elf64_Sword; - -alias uint64_t Elf32_Xword; -alias int64_t Elf32_Sxword; -alias uint64_t Elf64_Xword; -alias int64_t Elf64_Sxword; - -alias uint32_t Elf32_Addr; -alias uint64_t Elf64_Addr; - -alias uint32_t Elf32_Off; -alias uint64_t Elf64_Off; - -alias uint16_t Elf32_Section; -alias uint16_t Elf64_Section; - -alias Elf32_Half Elf32_Versym; -alias Elf64_Half Elf64_Versym; - - -enum EI_NIDENT = 16; - -struct Elf32_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} - -struct Elf64_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; -} - -enum EI_MAG0 = 0; -enum ELFMAG0 = 0x7f; - -enum EI_MAG1 = 1; -enum ELFMAG1 = 'E'; - -enum EI_MAG2 = 2; -enum ELFMAG2 = 'L'; - -enum EI_MAG3 = 3; -enum ELFMAG3 = 'F'; -enum ELFMAG = "\177ELF"; -enum SELFMAG = 4; - -enum EI_CLASS = 4; -enum ELFCLASSNONE = 0; -enum ELFCLASS32 = 1; -enum ELFCLASS64 = 2; -enum ELFCLASSNUM = 3; - -enum EI_DATA = 5; -enum ELFDATANONE = 0; -enum ELFDATA2LSB = 1; -enum ELFDATA2MSB = 2; -enum ELFDATANUM = 3; - -enum EI_VERSION = 6; - -enum EI_OSABI = 7; -enum ELFOSABI_NONE = 0; -enum ELFOSABI_SYSV = 0; -enum ELFOSABI_HPUX = 1; -enum ELFOSABI_NETBSD = 2; -enum ELFOSABI_GNU = 3; -enum ELFOSABI_LINUX = ELFOSABI_GNU; -enum ELFOSABI_SOLARIS = 6; -enum ELFOSABI_AIX = 7; -enum ELFOSABI_IRIX = 8; -enum ELFOSABI_FREEBSD = 9; -enum ELFOSABI_TRU64 = 10; -enum ELFOSABI_MODESTO = 11; -enum ELFOSABI_OPENBSD = 12; -enum ELFOSABI_ARM_AEABI = 64; -enum ELFOSABI_ARM = 97; -enum ELFOSABI_STANDALONE = 255; -enum ELFOSABI_DRAGONFLYBSD = ELFOSABI_NONE; - -enum EI_ABIVERSION = 8; - -enum EI_PAD = 9; - -enum ET_NONE = 0; -enum ET_REL = 1; -enum ET_EXEC = 2; -enum ET_DYN = 3; -enum ET_CORE = 4; -enum ET_NUM = 5; -enum ET_LOOS = 0xfe00; -enum ET_HIOS = 0xfeff; -enum ET_LOPROC = 0xff00; -enum ET_HIPROC = 0xffff; - -enum EM_NONE = 0; -enum EM_M32 = 1; -enum EM_SPARC = 2; -enum EM_386 = 3; -enum EM_68K = 4; -enum EM_88K = 5; -enum EM_860 = 7; -enum EM_MIPS = 8; -enum EM_S370 = 9; -enum EM_MIPS_RS3_LE = 10; - -enum EM_PARISC = 15; -enum EM_VPP500 = 17; -enum EM_SPARC32PLUS = 18; -enum EM_960 = 19; -enum EM_PPC = 20; -enum EM_PPC64 = 21; -enum EM_S390 = 22; - -enum EM_V800 = 36; -enum EM_FR20 = 37; -enum EM_RH32 = 38; -enum EM_RCE = 39; -enum EM_ARM = 40; -enum EM_FAKE_ALPHA = 41; -enum EM_SH = 42; -enum EM_SPARCV9 = 43; -enum EM_TRICORE = 44; -enum EM_ARC = 45; -enum EM_H8_300 = 46; -enum EM_H8_300H = 47; -enum EM_H8S = 48; -enum EM_H8_500 = 49; -enum EM_IA_64 = 50; -enum EM_MIPS_X = 51; -enum EM_COLDFIRE = 52; -enum EM_68HC12 = 53; -enum EM_MMA = 54; -enum EM_PCP = 55; -enum EM_NCPU = 56; -enum EM_NDR1 = 57; -enum EM_STARCORE = 58; -enum EM_ME16 = 59; -enum EM_ST100 = 60; -enum EM_TINYJ = 61; -enum EM_X86_64 = 62; -enum EM_PDSP = 63; - -enum EM_FX66 = 66; -enum EM_ST9PLUS = 67; -enum EM_ST7 = 68; -enum EM_68HC16 = 69; -enum EM_68HC11 = 70; -enum EM_68HC08 = 71; -enum EM_68HC05 = 72; -enum EM_SVX = 73; -enum EM_ST19 = 74; -enum EM_VAX = 75; -enum EM_CRIS = 76; -enum EM_JAVELIN = 77; -enum EM_FIREPATH = 78; -enum EM_ZSP = 79; -enum EM_MMIX = 80; -enum EM_HUANY = 81; -enum EM_PRISM = 82; -enum EM_AVR = 83; -enum EM_FR30 = 84; -enum EM_D10V = 85; -enum EM_D30V = 86; -enum EM_V850 = 87; -enum EM_M32R = 88; -enum EM_MN10300 = 89; -enum EM_MN10200 = 90; -enum EM_PJ = 91; -enum EM_OPENRISC = 92; -enum EM_ARC_A5 = 93; -enum EM_XTENSA = 94; -enum EM_AARCH64 = 183; -enum EM_TILEPRO = 188; -enum EM_TILEGX = 191; -enum EM_NUM = 192; - -enum EM_ALPHA = 0x9026; - -enum EV_NONE = 0; -enum EV_CURRENT = 1; -enum EV_NUM = 2; - -struct Elf32_Shdr -{ - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} - -struct Elf64_Shdr -{ - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -} - -enum SHN_UNDEF = 0; -enum SHN_LORESERVE = 0xff00; -enum SHN_LOPROC = 0xff00; -enum SHN_BEFORE = 0xff00; -enum SHN_AFTER = 0xff01; -enum SHN_HIPROC = 0xff1f; -enum SHN_LOOS = 0xff20; -enum SHN_HIOS = 0xff3f; -enum SHN_ABS = 0xfff1; -enum SHN_COMMON = 0xfff2; -enum SHN_XINDEX = 0xffff; -enum SHN_HIRESERVE = 0xffff; - -enum SHT_NULL = 0; -enum SHT_PROGBITS = 1; -enum SHT_SYMTAB = 2; -enum SHT_STRTAB = 3; -enum SHT_RELA = 4; -enum SHT_HASH = 5; -enum SHT_DYNAMIC = 6; -enum SHT_NOTE = 7; -enum SHT_NOBITS = 8; -enum SHT_REL = 9; -enum SHT_SHLIB = 10; -enum SHT_DYNSYM = 11; -enum SHT_INIT_ARRAY = 14; -enum SHT_FINI_ARRAY = 15; -enum SHT_PREINIT_ARRAY = 16; -enum SHT_GROUP = 17; -enum SHT_SYMTAB_SHNDX = 18; -enum SHT_NUM = 19; -enum SHT_LOOS = 0x60000000; -enum SHT_GNU_ATTRIBUTES = 0x6ffffff5; -enum SHT_GNU_HASH = 0x6ffffff6; -enum SHT_GNU_LIBLIST = 0x6ffffff7; -enum SHT_CHECKSUM = 0x6ffffff8; -enum SHT_LOSUNW = 0x6ffffffa; -enum SHT_SUNW_move = 0x6ffffffa; -enum SHT_SUNW_COMDAT = 0x6ffffffb; -enum SHT_SUNW_syminfo = 0x6ffffffc; -enum SHT_GNU_verdef = 0x6ffffffd; -enum SHT_GNU_verneed = 0x6ffffffe; -enum SHT_GNU_versym = 0x6fffffff; -enum SHT_HISUNW = 0x6fffffff; -enum SHT_HIOS = 0x6fffffff; -enum SHT_LOPROC = 0x70000000; -enum SHT_HIPROC = 0x7fffffff; -enum SHT_LOUSER = 0x80000000; -enum SHT_HIUSER = 0x8fffffff; - -enum SHF_WRITE = (1 << 0); -enum SHF_ALLOC = (1 << 1); -enum SHF_EXECINSTR = (1 << 2); -enum SHF_MERGE = (1 << 4); -enum SHF_STRINGS = (1 << 5); -enum SHF_INFO_LINK = (1 << 6); -enum SHF_LINK_ORDER = (1 << 7); -enum SHF_OS_NONCONFORMING = (1 << 8); -enum SHF_GROUP = (1 << 9); -enum SHF_TLS = (1 << 10); -enum SHF_COMPRESSED = (1 << 11); -enum SHF_MASKOS = 0x0ff00000; -enum SHF_MASKPROC = 0xf0000000; -enum SHF_ORDERED = (1 << 30); -enum SHF_EXCLUDE = (1 << 31); -enum GRP_COMDAT = 0x1; - -struct Elf32_Sym -{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - ubyte st_info; - ubyte st_other; - Elf32_Section st_shndx; -} - -struct Elf64_Sym -{ - Elf64_Word st_name; - ubyte st_info; - ubyte st_other; - Elf64_Section st_shndx; - Elf64_Addr st_value; - Elf64_Xword st_size; -} - -struct Elf32_Syminfo -{ - Elf32_Half si_boundto; - Elf32_Half si_flags; -} - -struct Elf64_Syminfo -{ - Elf64_Half si_boundto; - Elf64_Half si_flags; -} -enum SYMINFO_BT_SELF = 0xffff; -enum SYMINFO_BT_PARENT = 0xfffe; -enum SYMINFO_BT_LOWRESERVE = 0xff00; -enum SYMINFO_FLG_DIRECT = 0x0001; -enum SYMINFO_FLG_PASSTHRU = 0x0002; -enum SYMINFO_FLG_COPY = 0x0004; -enum SYMINFO_FLG_LAZYLOAD = 0x0008; -enum SYMINFO_NONE = 0; -enum SYMINFO_CURRENT = 1; -enum SYMINFO_NUM = 2; - -extern (D) -{ - auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; } - auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } - alias ELF32_ST_BIND ELF64_ST_BIND; - alias ELF32_ST_TYPE ELF64_ST_TYPE; - alias ELF32_ST_INFO ELF64_ST_INFO; -} - -enum STB_LOCAL = 0; -enum STB_GLOBAL = 1; -enum STB_WEAK = 2; -enum STB_NUM = 3; -enum STB_LOOS = 10; -enum STB_GNU_UNIQUE = 10; -enum STB_HIOS = 12; -enum STB_LOPROC = 13; -enum STB_HIPROC = 15; - -enum STT_NOTYPE = 0; -enum STT_OBJECT = 1; -enum STT_FUNC = 2; -enum STT_SECTION = 3; -enum STT_FILE = 4; -enum STT_COMMON = 5; -enum STT_TLS = 6; -enum STT_NUM = 7; -enum STT_LOOS = 10; -enum STT_GNU_IFUNC = 10; -enum STT_HIOS = 12; -enum STT_LOPROC = 13; -enum STT_HIPROC = 15; - -enum STN_UNDEF = 0; +public import core.sys.elf; extern (D) { auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY; } -enum STV_DEFAULT = 0; -enum STV_INTERNAL = 1; -enum STV_HIDDEN = 2; -enum STV_PROTECTED = 3; - -struct Elf32_Rel -{ - Elf32_Addr r_offset; - Elf32_Word r_info; -} - -struct Elf64_Rel -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; -} - -struct Elf32_Rela -{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} - -struct Elf64_Rela -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; - Elf64_Sxword r_addend; -} - -extern (D) -{ - auto ELF32_R_SYM(V)(V val) { return val >> 8; } - auto ELF32_R_TYPE(V)(V val) { return val & 0xff; } - auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); } - - auto ELF64_R_SYM(I)(I i) { return i >> 32; } - auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; } - auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); } -} -struct Elf32_Phdr +struct Elf32_Nhdr { - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; } -struct Elf64_Phdr +struct Elf64_Nhdr { - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf64_Xword p_filesz; - Elf64_Xword p_memsz; - Elf64_Xword p_align; + Elf64_Word n_namesz; + Elf64_Word n_descsz; + Elf64_Word n_type; } -enum PN_XNUM = 0xffff; - -enum PT_NULL = 0; -enum PT_LOAD = 1; -enum PT_DYNAMIC = 2; -enum PT_INTERP = 3; -enum PT_NOTE = 4; -enum PT_SHLIB = 5; -enum PT_PHDR = 6; -enum PT_TLS = 7; -enum PT_NUM = 8; -enum PT_LOOS = 0x60000000; -enum PT_GNU_EH_FRAME = 0x6474e550; -enum PT_GNU_STACK = 0x6474e551; -enum PT_GNU_RELRO = 0x6474e552; -enum PT_LOSUNW = 0x6ffffffa; -enum PT_SUNWBSS = 0x6ffffffa; -enum PT_SUNWSTACK = 0x6ffffffb; -enum PT_HISUNW = 0x6fffffff; -enum PT_HIOS = 0x6fffffff; -enum PT_LOPROC = 0x70000000; -enum PT_HIPROC = 0x7fffffff; - -enum PF_X = (1 << 0); -enum PF_W = (1 << 1); -enum PF_R = (1 << 2); -enum PF_MASKOS = 0x0ff00000; -enum PF_MASKPROC = 0xf0000000; - enum NT_PRSTATUS = 1; enum NT_FPREGSET = 2; enum NT_PRPSINFO = 3; @@ -561,222 +95,10 @@ struct Elf64_Dyn } _d_un d_un; } -enum DT_NULL = 0; -enum DT_NEEDED = 1; -enum DT_PLTRELSZ = 2; -enum DT_PLTGOT = 3; -enum DT_HASH = 4; -enum DT_STRTAB = 5; -enum DT_SYMTAB = 6; -enum DT_RELA = 7; -enum DT_RELASZ = 8; -enum DT_RELAENT = 9; -enum DT_STRSZ = 10; -enum DT_SYMENT = 11; -enum DT_INIT = 12; -enum DT_FINI = 13; -enum DT_SONAME = 14; -enum DT_RPATH = 15; -enum DT_SYMBOLIC = 16; -enum DT_REL = 17; -enum DT_RELSZ = 18; -enum DT_RELENT = 19; -enum DT_PLTREL = 20; -enum DT_DEBUG = 21; -enum DT_TEXTREL = 22; -enum DT_JMPREL = 23; -enum DT_BIND_NOW = 24; -enum DT_INIT_ARRAY = 25; -enum DT_FINI_ARRAY = 26; -enum DT_INIT_ARRAYSZ = 27; -enum DT_FINI_ARRAYSZ = 28; -enum DT_RUNPATH = 29; -enum DT_FLAGS = 30; -enum DT_ENCODING = 32; -enum DT_PREINIT_ARRAY = 32; -enum DT_PREINIT_ARRAYSZ = 33; -enum DT_NUM = 34; -enum DT_LOOS = 0x6000000d; -enum DT_HIOS = 0x6ffff000; -enum DT_LOPROC = 0x70000000; -enum DT_HIPROC = 0x7fffffff; -enum DT_PROCNUM = DT_MIPS_NUM; -enum DT_VALRNGLO = 0x6ffffd00; -enum DT_GNU_PRELINKED = 0x6ffffdf5; -enum DT_GNU_CONFLICTSZ = 0x6ffffdf6; -enum DT_GNU_LIBLISTSZ = 0x6ffffdf7; -enum DT_CHECKSUM = 0x6ffffdf8; -enum DT_PLTPADSZ = 0x6ffffdf9; -enum DT_MOVEENT = 0x6ffffdfa; -enum DT_MOVESZ = 0x6ffffdfb; -enum DT_FEATURE_1 = 0x6ffffdfc; -enum DT_POSFLAG_1 = 0x6ffffdfd; -enum DT_SYMINSZ = 0x6ffffdfe; -enum DT_SYMINENT = 0x6ffffdff; -enum DT_VALRNGHI = 0x6ffffdff; -extern (D) auto DT_VALTAGIDX(T)(T tag) -{ - return DT_VALRNGHI - tag; -} -enum DT_VALNUM = 12; -enum DT_ADDRRNGLO = 0x6ffffe00; -enum DT_GNU_HASH = 0x6ffffef5; -enum DT_TLSDESC_PLT = 0x6ffffef6; -enum DT_TLSDESC_GOT = 0x6ffffef7; -enum DT_GNU_CONFLICT = 0x6ffffef8; -enum DT_GNU_LIBLIST = 0x6ffffef9; -enum DT_CONFIG = 0x6ffffefa; -enum DT_DEPAUDIT = 0x6ffffefb; -enum DT_AUDIT = 0x6ffffefc; -enum DT_PLTPAD = 0x6ffffefd; -enum DT_MOVETAB = 0x6ffffefe; -enum DT_SYMINFO = 0x6ffffeff; -enum DT_ADDRRNGHI = 0x6ffffeff; -extern (D) auto DT_ADDRTAGIDX(T)(T tag) -{ - return DT_ADDRRNGHI - tag; -} -enum DT_ADDRNUM = 11; -enum DT_VERSYM = 0x6ffffff0; - -enum DT_RELACOUNT = 0x6ffffff9; -enum DT_RELCOUNT = 0x6ffffffa; -enum DT_FLAGS_1 = 0x6ffffffb; -enum DT_VERDEF = 0x6ffffffc; -enum DT_VERDEFNUM = 0x6ffffffd; -enum DT_VERNEED = 0x6ffffffe; -enum DT_VERNEEDNUM = 0x6fffffff; -extern (D) auto DT_VERSIONTAGIDX(T)(T tag) -{ - return DT_VERNEEDNUM - tag; -} -enum DT_VERSIONTAGNUM = 16; -enum DT_AUXILIARY = 0x7ffffffd; -enum DT_FILTER = 0x7fffffff; -extern (D) auto DT_EXTRATAGIDX(T)(T tag) -{ - return cast(Elf32_Word)(-(cast(Elf32_Sword)(tag) <<1>>1)-1); -} -enum DT_EXTRANUM = 3; -enum DF_ORIGIN = 0x00000001; -enum DF_SYMBOLIC = 0x00000002; -enum DF_TEXTREL = 0x00000004; -enum DF_BIND_NOW = 0x00000008; -enum DF_STATIC_TLS = 0x00000010; -enum DF_1_NOW = 0x00000001; -enum DF_1_GLOBAL = 0x00000002; -enum DF_1_GROUP = 0x00000004; -enum DF_1_NODELETE = 0x00000008; -enum DF_1_LOADFLTR = 0x00000010; -enum DF_1_INITFIRST = 0x00000020; -enum DF_1_NOOPEN = 0x00000040; -enum DF_1_ORIGIN = 0x00000080; -enum DF_1_DIRECT = 0x00000100; -enum DF_1_TRANS = 0x00000200; -enum DF_1_INTERPOSE = 0x00000400; -enum DF_1_NODEFLIB = 0x00000800; -enum DF_1_NODUMP = 0x00001000; -enum DF_1_CONFALT = 0x00002000; -enum DF_1_ENDFILTEE = 0x00004000; -enum DF_1_DISPRELDNE = 0x00008000; -enum DF_1_DISPRELPND = 0x00010000; -enum DF_1_NODIRECT = 0x00020000; -enum DF_1_IGNMULDEF = 0x00040000; -enum DF_1_NOKSYMS = 0x00080000; -enum DF_1_NOHDR = 0x00100000; -enum DF_1_EDITED = 0x00200000; -enum DF_1_NORELOC = 0x00400000; -enum DF_1_SYMINTPOSE = 0x00800000; -enum DF_1_GLOBAUDIT = 0x01000000; -enum DF_1_SINGLETON = 0x02000000; -enum DTF_1_PARINIT = 0x00000001; -enum DTF_1_CONFEXP = 0x00000002; -enum DF_P1_LAZYLOAD = 0x00000001; -enum DF_P1_GROUPPERM = 0x00000002; - -struct Elf32_Verdef -{ - Elf32_Half vd_version; - Elf32_Half vd_flags; - Elf32_Half vd_ndx; - Elf32_Half vd_cnt; - Elf32_Word vd_hash; - Elf32_Word vd_aux; - Elf32_Word vd_next; -} - -struct Elf64_Verdef -{ - Elf64_Half vd_version; - Elf64_Half vd_flags; - Elf64_Half vd_ndx; - Elf64_Half vd_cnt; - Elf64_Word vd_hash; - Elf64_Word vd_aux; - Elf64_Word vd_next; -} -enum VER_DEF_NONE = 0; -enum VER_DEF_CURRENT = 1; -enum VER_DEF_NUM = 2; -enum VER_FLG_BASE = 0x1; -enum VER_FLG_WEAK = 0x2; -enum VER_NDX_LOCAL = 0; -enum VER_NDX_GLOBAL = 1; -enum VER_NDX_LORESERVE = 0xff00; -enum VER_NDX_ELIMINATE = 0xff01; - -struct Elf32_Verdaux -{ - Elf32_Word vda_name; - Elf32_Word vda_next; -} - -struct Elf64_Verdaux -{ - Elf64_Word vda_name; - Elf64_Word vda_next; -} - -struct Elf32_Verneed -{ - Elf32_Half vn_version; - Elf32_Half vn_cnt; - Elf32_Word vn_file; - Elf32_Word vn_aux; - Elf32_Word vn_next; -} - -struct Elf64_Verneed -{ - Elf64_Half vn_version; - Elf64_Half vn_cnt; - Elf64_Word vn_file; - Elf64_Word vn_aux; - Elf64_Word vn_next; -} -enum VER_NEED_NONE = 0; -enum VER_NEED_CURRENT = 1; -enum VER_NEED_NUM = 2; - -struct Elf32_Vernaux -{ - Elf32_Word vna_hash; - Elf32_Half vna_flags; - Elf32_Half vna_other; - Elf32_Word vna_name; - Elf32_Word vna_next; -} - -struct Elf64_Vernaux -{ - Elf64_Word vna_hash; - Elf64_Half vna_flags; - Elf64_Half vna_other; - Elf64_Word vna_name; - Elf64_Word vna_next; -} -// duplicate -// enum VER_FLG_WEAK = 0x2; +enum NT_GNU_ABI_TAG = 1; +enum NT_GNU_HWCAP = 2; +enum NT_GNU_BUILD_ID = 3; +enum NT_GNU_GOLD_VERSION = 4; struct Elf32_auxv_t { @@ -836,1698 +158,3 @@ enum AT_L1I_CACHESHAPE = 34; enum AT_L1D_CACHESHAPE = 35; enum AT_L2_CACHESHAPE = 36; enum AT_L3_CACHESHAPE = 37; - -struct Elf32_Nhdr -{ - Elf32_Word n_namesz; - Elf32_Word n_descsz; - Elf32_Word n_type; -} - -struct Elf64_Nhdr -{ - Elf64_Word n_namesz; - Elf64_Word n_descsz; - Elf64_Word n_type; -} -enum ELF_NOTE_SOLARIS = "SUNW Solaris"; -enum ELF_NOTE_GNU = "GNU"; -enum ELF_NOTE_PAGESIZE_HINT = 1; -enum NT_GNU_ABI_TAG = 1; -enum ELF_NOTE_ABI = NT_GNU_ABI_TAG; -enum ELF_NOTE_OS_LINUX = 0; -enum ELF_NOTE_OS_GNU = 1; -enum ELF_NOTE_OS_SOLARIS2 = 2; -enum ELF_NOTE_OS_FREEBSD = 3; -enum NT_GNU_HWCAP = 2; -enum NT_GNU_BUILD_ID = 3; -enum NT_GNU_GOLD_VERSION = 4; -struct Elf32_Move -{ - Elf32_Xword m_value; - Elf32_Word m_info; - Elf32_Word m_poffset; - Elf32_Half m_repeat; - Elf32_Half m_stride; -} - -struct Elf64_Move -{ - Elf64_Xword m_value; - Elf64_Xword m_info; - Elf64_Xword m_poffset; - Elf64_Half m_repeat; - Elf64_Half m_stride; -} -extern (D) -{ - auto ELF32_M_SYM(I)(I info) { return info >> 8; } - auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } -} - -alias ELF32_M_SYM ELF64_M_SYM; -alias ELF32_M_SIZE ELF64_M_SIZE; -alias ELF32_M_INFO ELF64_M_INFO; -enum EF_CPU32 = 0x00810000; - -enum R_68K_NONE = 0; -enum R_68K_32 = 1; -enum R_68K_16 = 2; -enum R_68K_8 = 3; -enum R_68K_PC32 = 4; -enum R_68K_PC16 = 5; -enum R_68K_PC8 = 6; -enum R_68K_GOT32 = 7; -enum R_68K_GOT16 = 8; -enum R_68K_GOT8 = 9; -enum R_68K_GOT32O = 10; -enum R_68K_GOT16O = 11; -enum R_68K_GOT8O = 12; -enum R_68K_PLT32 = 13; -enum R_68K_PLT16 = 14; -enum R_68K_PLT8 = 15; -enum R_68K_PLT32O = 16; -enum R_68K_PLT16O = 17; -enum R_68K_PLT8O = 18; -enum R_68K_COPY = 19; -enum R_68K_GLOB_DAT = 20; -enum R_68K_JMP_SLOT = 21; -enum R_68K_RELATIVE = 22; -enum R_68K_TLS_GD32 = 25; -enum R_68K_TLS_GD16 = 26; -enum R_68K_TLS_GD8 = 27; -enum R_68K_TLS_LDM32 = 28; -enum R_68K_TLS_LDM16 = 29; -enum R_68K_TLS_LDM8 = 30; -enum R_68K_TLS_LDO32 = 31; -enum R_68K_TLS_LDO16 = 32; -enum R_68K_TLS_LDO8 = 33; -enum R_68K_TLS_IE32 = 34; -enum R_68K_TLS_IE16 = 35; -enum R_68K_TLS_IE8 = 36; -enum R_68K_TLS_LE32 = 37; -enum R_68K_TLS_LE16 = 38; -enum R_68K_TLS_LE8 = 39; -enum R_68K_TLS_DTPMOD32 = 40; -enum R_68K_TLS_DTPREL32 = 41; -enum R_68K_TLS_TPREL32 = 42; -enum R_68K_NUM = 43; - -enum R_386_NONE = 0; -enum R_386_32 = 1; -enum R_386_PC32 = 2; -enum R_386_GOT32 = 3; -enum R_386_PLT32 = 4; -enum R_386_COPY = 5; -enum R_386_GLOB_DAT = 6; -enum R_386_JMP_SLOT = 7; -enum R_386_RELATIVE = 8; -enum R_386_GOTOFF = 9; -enum R_386_GOTPC = 10; -enum R_386_32PLT = 11; -enum R_386_TLS_TPOFF = 14; -enum R_386_TLS_IE = 15; -enum R_386_TLS_GOTIE = 16; -enum R_386_TLS_LE = 17; -enum R_386_TLS_GD = 18; -enum R_386_TLS_LDM = 19; -enum R_386_16 = 20; -enum R_386_PC16 = 21; -enum R_386_8 = 22; -enum R_386_PC8 = 23; -enum R_386_TLS_GD_32 = 24; -enum R_386_TLS_GD_PUSH = 25; -enum R_386_TLS_GD_CALL = 26; -enum R_386_TLS_GD_POP = 27; -enum R_386_TLS_LDM_32 = 28; -enum R_386_TLS_LDM_PUSH = 29; -enum R_386_TLS_LDM_CALL = 30; -enum R_386_TLS_LDM_POP = 31; -enum R_386_TLS_LDO_32 = 32; -enum R_386_TLS_IE_32 = 33; -enum R_386_TLS_LE_32 = 34; -enum R_386_TLS_DTPMOD32 = 35; -enum R_386_TLS_DTPOFF32 = 36; -enum R_386_TLS_TPOFF32 = 37; -enum R_386_SIZE32 = 38; -enum R_386_TLS_GOTDESC = 39; -enum R_386_TLS_DESC_CALL = 40; -enum R_386_TLS_DESC = 41; -enum R_386_IRELATIVE = 42; -enum R_386_NUM = 43; - -enum STT_SPARC_REGISTER = 13; - -enum EF_SPARCV9_MM = 3; -enum EF_SPARCV9_TSO = 0; -enum EF_SPARCV9_PSO = 1; -enum EF_SPARCV9_RMO = 2; -enum EF_SPARC_LEDATA = 0x800000; -enum EF_SPARC_EXT_MASK = 0xFFFF00; -enum EF_SPARC_32PLUS = 0x000100; -enum EF_SPARC_SUN_US1 = 0x000200; -enum EF_SPARC_HAL_R1 = 0x000400; -enum EF_SPARC_SUN_US3 = 0x000800; - -enum R_SPARC_NONE = 0; -enum R_SPARC_8 = 1; -enum R_SPARC_16 = 2; -enum R_SPARC_32 = 3; -enum R_SPARC_DISP8 = 4; -enum R_SPARC_DISP16 = 5; -enum R_SPARC_DISP32 = 6; -enum R_SPARC_WDISP30 = 7; -enum R_SPARC_WDISP22 = 8; -enum R_SPARC_HI22 = 9; -enum R_SPARC_22 = 10; -enum R_SPARC_13 = 11; -enum R_SPARC_LO10 = 12; -enum R_SPARC_GOT10 = 13; -enum R_SPARC_GOT13 = 14; -enum R_SPARC_GOT22 = 15; -enum R_SPARC_PC10 = 16; -enum R_SPARC_PC22 = 17; -enum R_SPARC_WPLT30 = 18; -enum R_SPARC_COPY = 19; -enum R_SPARC_GLOB_DAT = 20; -enum R_SPARC_JMP_SLOT = 21; -enum R_SPARC_RELATIVE = 22; -enum R_SPARC_UA32 = 23; - -enum R_SPARC_PLT32 = 24; -enum R_SPARC_HIPLT22 = 25; -enum R_SPARC_LOPLT10 = 26; -enum R_SPARC_PCPLT32 = 27; -enum R_SPARC_PCPLT22 = 28; -enum R_SPARC_PCPLT10 = 29; -enum R_SPARC_10 = 30; -enum R_SPARC_11 = 31; -enum R_SPARC_64 = 32; -enum R_SPARC_OLO10 = 33; -enum R_SPARC_HH22 = 34; -enum R_SPARC_HM10 = 35; -enum R_SPARC_LM22 = 36; -enum R_SPARC_PC_HH22 = 37; -enum R_SPARC_PC_HM10 = 38; -enum R_SPARC_PC_LM22 = 39; -enum R_SPARC_WDISP16 = 40; -enum R_SPARC_WDISP19 = 41; -enum R_SPARC_GLOB_JMP = 42; -enum R_SPARC_7 = 43; -enum R_SPARC_5 = 44; -enum R_SPARC_6 = 45; -enum R_SPARC_DISP64 = 46; -enum R_SPARC_PLT64 = 47; -enum R_SPARC_HIX22 = 48; -enum R_SPARC_LOX10 = 49; -enum R_SPARC_H44 = 50; -enum R_SPARC_M44 = 51; -enum R_SPARC_L44 = 52; -enum R_SPARC_REGISTER = 53; -enum R_SPARC_UA64 = 54; -enum R_SPARC_UA16 = 55; -enum R_SPARC_TLS_GD_HI22 = 56; -enum R_SPARC_TLS_GD_LO10 = 57; -enum R_SPARC_TLS_GD_ADD = 58; -enum R_SPARC_TLS_GD_CALL = 59; -enum R_SPARC_TLS_LDM_HI22 = 60; -enum R_SPARC_TLS_LDM_LO10 = 61; -enum R_SPARC_TLS_LDM_ADD = 62; -enum R_SPARC_TLS_LDM_CALL = 63; -enum R_SPARC_TLS_LDO_HIX22 = 64; -enum R_SPARC_TLS_LDO_LOX10 = 65; -enum R_SPARC_TLS_LDO_ADD = 66; -enum R_SPARC_TLS_IE_HI22 = 67; -enum R_SPARC_TLS_IE_LO10 = 68; -enum R_SPARC_TLS_IE_LD = 69; -enum R_SPARC_TLS_IE_LDX = 70; -enum R_SPARC_TLS_IE_ADD = 71; -enum R_SPARC_TLS_LE_HIX22 = 72; -enum R_SPARC_TLS_LE_LOX10 = 73; -enum R_SPARC_TLS_DTPMOD32 = 74; -enum R_SPARC_TLS_DTPMOD64 = 75; -enum R_SPARC_TLS_DTPOFF32 = 76; -enum R_SPARC_TLS_DTPOFF64 = 77; -enum R_SPARC_TLS_TPOFF32 = 78; -enum R_SPARC_TLS_TPOFF64 = 79; -enum R_SPARC_GOTDATA_HIX22 = 80; -enum R_SPARC_GOTDATA_LOX10 = 81; -enum R_SPARC_GOTDATA_OP_HIX22 = 82; -enum R_SPARC_GOTDATA_OP_LOX10 = 83; -enum R_SPARC_GOTDATA_OP = 84; -enum R_SPARC_H34 = 85; -enum R_SPARC_SIZE32 = 86; -enum R_SPARC_SIZE64 = 87; -enum R_SPARC_WDISP10 = 88; -enum R_SPARC_JMP_IREL = 248; -enum R_SPARC_IRELATIVE = 249; -enum R_SPARC_GNU_VTINHERIT = 250; -enum R_SPARC_GNU_VTENTRY = 251; -enum R_SPARC_REV32 = 252; -enum R_SPARC_NUM = 253; - -enum DT_SPARC_REGISTER = 0x70000001; -enum DT_SPARC_NUM = 2; - -enum EF_MIPS_NOREORDER = 1; -enum EF_MIPS_PIC = 2; -enum EF_MIPS_CPIC = 4; -enum EF_MIPS_XGOT = 8; -enum EF_MIPS_64BIT_WHIRL = 16; -enum EF_MIPS_ABI2 = 32; -enum EF_MIPS_ABI_ON32 = 64; -enum EF_MIPS_ARCH = 0xf0000000; - -enum EF_MIPS_ARCH_1 = 0x00000000; -enum EF_MIPS_ARCH_2 = 0x10000000; -enum EF_MIPS_ARCH_3 = 0x20000000; -enum EF_MIPS_ARCH_4 = 0x30000000; -enum EF_MIPS_ARCH_5 = 0x40000000; -enum EF_MIPS_ARCH_32 = 0x50000000; -enum EF_MIPS_ARCH_64 = 0x60000000; -enum EF_MIPS_ARCH_32R2 = 0x70000000; -enum EF_MIPS_ARCH_64R2 = 0x80000000; - -enum E_MIPS_ARCH_1 = EF_MIPS_ARCH_1; -enum E_MIPS_ARCH_2 = EF_MIPS_ARCH_2; -enum E_MIPS_ARCH_3 = EF_MIPS_ARCH_3; -enum E_MIPS_ARCH_4 = EF_MIPS_ARCH_4; -enum E_MIPS_ARCH_5 = EF_MIPS_ARCH_5; -enum E_MIPS_ARCH_32 = EF_MIPS_ARCH_32; -enum E_MIPS_ARCH_64 = EF_MIPS_ARCH_64; - -enum SHN_MIPS_ACOMMON = 0xff00; -enum SHN_MIPS_TEXT = 0xff01; -enum SHN_MIPS_DATA = 0xff02; -enum SHN_MIPS_SCOMMON = 0xff03; -enum SHN_MIPS_SUNDEFINED = 0xff04; - -enum SHT_MIPS_LIBLIST = 0x70000000; -enum SHT_MIPS_MSYM = 0x70000001; -enum SHT_MIPS_CONFLICT = 0x70000002; -enum SHT_MIPS_GPTAB = 0x70000003; -enum SHT_MIPS_UCODE = 0x70000004; -enum SHT_MIPS_DEBUG = 0x70000005; -enum SHT_MIPS_REGINFO = 0x70000006; -enum SHT_MIPS_PACKAGE = 0x70000007; -enum SHT_MIPS_PACKSYM = 0x70000008; -enum SHT_MIPS_RELD = 0x70000009; -enum SHT_MIPS_IFACE = 0x7000000b; -enum SHT_MIPS_CONTENT = 0x7000000c; -enum SHT_MIPS_OPTIONS = 0x7000000d; -enum SHT_MIPS_SHDR = 0x70000010; -enum SHT_MIPS_FDESC = 0x70000011; -enum SHT_MIPS_EXTSYM = 0x70000012; -enum SHT_MIPS_DENSE = 0x70000013; -enum SHT_MIPS_PDESC = 0x70000014; -enum SHT_MIPS_LOCSYM = 0x70000015; -enum SHT_MIPS_AUXSYM = 0x70000016; -enum SHT_MIPS_OPTSYM = 0x70000017; -enum SHT_MIPS_LOCSTR = 0x70000018; -enum SHT_MIPS_LINE = 0x70000019; -enum SHT_MIPS_RFDESC = 0x7000001a; -enum SHT_MIPS_DELTASYM = 0x7000001b; -enum SHT_MIPS_DELTAINST = 0x7000001c; -enum SHT_MIPS_DELTACLASS = 0x7000001d; -enum SHT_MIPS_DWARF = 0x7000001e; -enum SHT_MIPS_DELTADECL = 0x7000001f; -enum SHT_MIPS_SYMBOL_LIB = 0x70000020; -enum SHT_MIPS_EVENTS = 0x70000021; -enum SHT_MIPS_TRANSLATE = 0x70000022; -enum SHT_MIPS_PIXIE = 0x70000023; -enum SHT_MIPS_XLATE = 0x70000024; -enum SHT_MIPS_XLATE_DEBUG = 0x70000025; -enum SHT_MIPS_WHIRL = 0x70000026; -enum SHT_MIPS_EH_REGION = 0x70000027; -enum SHT_MIPS_XLATE_OLD = 0x70000028; -enum SHT_MIPS_PDR_EXCEPTION = 0x70000029; - -enum SHF_MIPS_GPREL = 0x10000000; -enum SHF_MIPS_MERGE = 0x20000000; -enum SHF_MIPS_ADDR = 0x40000000; -enum SHF_MIPS_STRINGS = 0x80000000; -enum SHF_MIPS_NOSTRIP = 0x08000000; -enum SHF_MIPS_LOCAL = 0x04000000; -enum SHF_MIPS_NAMES = 0x02000000; -enum SHF_MIPS_NODUPE = 0x01000000; -enum STO_MIPS_DEFAULT = 0x0; -enum STO_MIPS_INTERNAL = 0x1; -enum STO_MIPS_HIDDEN = 0x2; -enum STO_MIPS_PROTECTED = 0x3; -enum STO_MIPS_PLT = 0x8; -enum STO_MIPS_SC_ALIGN_UNUSED = 0xff; -enum STB_MIPS_SPLIT_COMMON = 13; - -union Elf32_gptab -{ - struct _gt_header - { - Elf32_Word gt_current_g_value; - Elf32_Word gt_unused; - } _gt_header gt_header; - struct _gt_entry - { - Elf32_Word gt_g_value; - Elf32_Word gt_bytes; - } _gt_entry gt_entry; -} - -struct Elf32_RegInfo -{ - Elf32_Word ri_gprmask; - Elf32_Word[4] ri_cprmask; - Elf32_Sword ri_gp_value; -} - -struct Elf_Options -{ - ubyte kind; - ubyte size; - Elf32_Section section; - Elf32_Word info; -} - -enum ODK_NULL = 0; -enum ODK_REGINFO = 1; -enum ODK_EXCEPTIONS = 2; -enum ODK_PAD = 3; -enum ODK_HWPATCH = 4; -enum ODK_FILL = 5; -enum ODK_TAGS = 6; -enum ODK_HWAND = 7; -enum ODK_HWOR = 8; - -enum OEX_FPU_MIN = 0x1f; -enum OEX_FPU_MAX = 0x1f00; -enum OEX_PAGE0 = 0x10000; -enum OEX_SMM = 0x20000; -enum OEX_FPDBUG = 0x40000; -enum OEX_PRECISEFP = OEX_FPDBUG; -enum OEX_DISMISS = 0x80000; - -enum OEX_FPU_INVAL = 0x10; -enum OEX_FPU_DIV0 = 0x08; -enum OEX_FPU_OFLO = 0x04; -enum OEX_FPU_UFLO = 0x02; -enum OEX_FPU_INEX = 0x01; - -enum OHW_R4KEOP = 0x1; -enum OHW_R8KPFETCH = 0x2; -enum OHW_R5KEOP = 0x4; -enum OHW_R5KCVTL = 0x8; - -enum OPAD_PREFIX = 0x1; -enum OPAD_POSTFIX = 0x2; -enum OPAD_SYMBOL = 0x4; - -struct Elf_Options_Hw -{ - Elf32_Word hwp_flags1; - Elf32_Word hwp_flags2; -} - -enum OHWA0_R4KEOP_CHECKED = 0x00000001; -enum OHWA1_R4KEOP_CLEAN = 0x00000002; - -enum R_MIPS_NONE = 0; -enum R_MIPS_16 = 1; -enum R_MIPS_32 = 2; -enum R_MIPS_REL32 = 3; -enum R_MIPS_26 = 4; -enum R_MIPS_HI16 = 5; -enum R_MIPS_LO16 = 6; -enum R_MIPS_GPREL16 = 7; -enum R_MIPS_LITERAL = 8; -enum R_MIPS_GOT16 = 9; -enum R_MIPS_PC16 = 10; -enum R_MIPS_CALL16 = 11; -enum R_MIPS_GPREL32 = 12; - -enum R_MIPS_SHIFT5 = 16; -enum R_MIPS_SHIFT6 = 17; -enum R_MIPS_64 = 18; -enum R_MIPS_GOT_DISP = 19; -enum R_MIPS_GOT_PAGE = 20; -enum R_MIPS_GOT_OFST = 21; -enum R_MIPS_GOT_HI16 = 22; -enum R_MIPS_GOT_LO16 = 23; -enum R_MIPS_SUB = 24; -enum R_MIPS_INSERT_A = 25; -enum R_MIPS_INSERT_B = 26; -enum R_MIPS_DELETE = 27; -enum R_MIPS_HIGHER = 28; -enum R_MIPS_HIGHEST = 29; -enum R_MIPS_CALL_HI16 = 30; -enum R_MIPS_CALL_LO16 = 31; -enum R_MIPS_SCN_DISP = 32; -enum R_MIPS_REL16 = 33; -enum R_MIPS_ADD_IMMEDIATE = 34; -enum R_MIPS_PJUMP = 35; -enum R_MIPS_RELGOT = 36; -enum R_MIPS_JALR = 37; -enum R_MIPS_TLS_DTPMOD32 = 38; -enum R_MIPS_TLS_DTPREL32 = 39; -enum R_MIPS_TLS_DTPMOD64 = 40; -enum R_MIPS_TLS_DTPREL64 = 41; -enum R_MIPS_TLS_GD = 42; -enum R_MIPS_TLS_LDM = 43; -enum R_MIPS_TLS_DTPREL_HI16 = 44; -enum R_MIPS_TLS_DTPREL_LO16 = 45; -enum R_MIPS_TLS_GOTTPREL = 46; -enum R_MIPS_TLS_TPREL32 = 47; -enum R_MIPS_TLS_TPREL64 = 48; -enum R_MIPS_TLS_TPREL_HI16 = 49; -enum R_MIPS_TLS_TPREL_LO16 = 50; -enum R_MIPS_GLOB_DAT = 51; -enum R_MIPS_COPY = 126; -enum R_MIPS_JUMP_SLOT = 127; -enum R_MIPS_NUM = 128; - -enum PT_MIPS_REGINFO = 0x70000000; -enum PT_MIPS_RTPROC = 0x70000001; -enum PT_MIPS_OPTIONS = 0x70000002; - -enum PF_MIPS_LOCAL = 0x10000000; - -enum DT_MIPS_RLD_VERSION = 0x70000001; -enum DT_MIPS_TIME_STAMP = 0x70000002; -enum DT_MIPS_ICHECKSUM = 0x70000003; -enum DT_MIPS_IVERSION = 0x70000004; -enum DT_MIPS_FLAGS = 0x70000005; -enum DT_MIPS_BASE_ADDRESS = 0x70000006; -enum DT_MIPS_MSYM = 0x70000007; -enum DT_MIPS_CONFLICT = 0x70000008; -enum DT_MIPS_LIBLIST = 0x70000009; -enum DT_MIPS_LOCAL_GOTNO = 0x7000000a; -enum DT_MIPS_CONFLICTNO = 0x7000000b; -enum DT_MIPS_LIBLISTNO = 0x70000010; -enum DT_MIPS_SYMTABNO = 0x70000011; -enum DT_MIPS_UNREFEXTNO = 0x70000012; -enum DT_MIPS_GOTSYM = 0x70000013; -enum DT_MIPS_HIPAGENO = 0x70000014; -enum DT_MIPS_RLD_MAP = 0x70000016; -enum DT_MIPS_DELTA_CLASS = 0x70000017; -enum DT_MIPS_DELTA_CLASS_NO = 0x70000018; -enum DT_MIPS_DELTA_INSTANCE = 0x70000019; -enum DT_MIPS_DELTA_INSTANCE_NO = 0x7000001a; -enum DT_MIPS_DELTA_RELOC = 0x7000001b; -enum DT_MIPS_DELTA_RELOC_NO = 0x7000001c; -enum DT_MIPS_DELTA_SYM = 0x7000001d; -enum DT_MIPS_DELTA_SYM_NO = 0x7000001e; -enum DT_MIPS_DELTA_CLASSSYM = 0x70000020; -enum DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021; -enum DT_MIPS_CXX_FLAGS = 0x70000022; -enum DT_MIPS_PIXIE_INIT = 0x70000023; -enum DT_MIPS_SYMBOL_LIB = 0x70000024; -enum DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025; -enum DT_MIPS_LOCAL_GOTIDX = 0x70000026; -enum DT_MIPS_HIDDEN_GOTIDX = 0x70000027; -enum DT_MIPS_PROTECTED_GOTIDX = 0x70000028; -enum DT_MIPS_OPTIONS = 0x70000029; -enum DT_MIPS_INTERFACE = 0x7000002a; -enum DT_MIPS_DYNSTR_ALIGN = 0x7000002b; -enum DT_MIPS_INTERFACE_SIZE = 0x7000002c; -enum DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002d; -enum DT_MIPS_PERF_SUFFIX = 0x7000002e; -enum DT_MIPS_COMPACT_SIZE = 0x7000002f; -enum DT_MIPS_GP_VALUE = 0x70000030; -enum DT_MIPS_AUX_DYNAMIC = 0x70000031; -enum DT_MIPS_PLTGOT = 0x70000032; -enum DT_MIPS_RWPLT = 0x70000034; -enum DT_MIPS_NUM = 0x35; - -enum RHF_NONE = 0; -enum RHF_QUICKSTART = (1 << 0); -enum RHF_NOTPOT = (1 << 1); -enum RHF_NO_LIBRARY_REPLACEMENT = (1 << 2); -enum RHF_NO_MOVE = (1 << 3); -enum RHF_SGI_ONLY = (1 << 4); -enum RHF_GUARANTEE_INIT = (1 << 5); -enum RHF_DELTA_C_PLUS_PLUS = (1 << 6); -enum RHF_GUARANTEE_START_INIT = (1 << 7); -enum RHF_PIXIE = (1 << 8); -enum RHF_DEFAULT_DELAY_LOAD = (1 << 9); -enum RHF_REQUICKSTART = (1 << 10); -enum RHF_REQUICKSTARTED = (1 << 11); -enum RHF_CORD = (1 << 12); -enum RHF_NO_UNRES_UNDEF = (1 << 13); -enum RHF_RLD_ORDER_SAFE = (1 << 14); - -struct Elf32_Lib -{ - Elf32_Word l_name; - Elf32_Word l_time_stamp; - Elf32_Word l_checksum; - Elf32_Word l_version; - Elf32_Word l_flags; -} - -struct Elf64_Lib -{ - Elf64_Word l_name; - Elf64_Word l_time_stamp; - Elf64_Word l_checksum; - Elf64_Word l_version; - Elf64_Word l_flags; -} - -enum LL_NONE = 0; -enum LL_EXACT_MATCH = (1 << 0); -enum LL_IGNORE_INT_VER = (1 << 1); -enum LL_REQUIRE_MINOR = (1 << 2); -enum LL_EXPORTS = (1 << 3); -enum LL_DELAY_LOAD = (1 << 4); -enum LL_DELTA = (1 << 5); - -alias Elf32_Addr Elf32_Conflict; - -enum EF_PARISC_TRAPNIL = 0x00010000; -enum EF_PARISC_EXT = 0x00020000; -enum EF_PARISC_LSB = 0x00040000; -enum EF_PARISC_WIDE = 0x00080000; -enum EF_PARISC_NO_KABP = 0x00100000; -enum EF_PARISC_LAZYSWAP = 0x00400000; -enum EF_PARISC_ARCH = 0x0000ffff; - -enum EFA_PARISC_1_0 = 0x020b; -enum EFA_PARISC_1_1 = 0x0210; -enum EFA_PARISC_2_0 = 0x0214; - -enum SHN_PARISC_ANSI_COMMON = 0xff00; -enum SHN_PARISC_HUGE_COMMON = 0xff01; - -enum SHT_PARISC_EXT = 0x70000000; -enum SHT_PARISC_UNWIND = 0x70000001; -enum SHT_PARISC_DOC = 0x70000002; - -enum SHF_PARISC_SHORT = 0x20000000; -enum SHF_PARISC_HUGE = 0x40000000; -enum SHF_PARISC_SBP = 0x80000000; - -enum STT_PARISC_MILLICODE = 13; - -enum STT_HP_OPAQUE = (STT_LOOS + 0x1); -enum STT_HP_STUB = (STT_LOOS + 0x2); - -enum R_PARISC_NONE = 0; -enum R_PARISC_DIR32 = 1; -enum R_PARISC_DIR21L = 2; -enum R_PARISC_DIR17R = 3; -enum R_PARISC_DIR17F = 4; -enum R_PARISC_DIR14R = 6; -enum R_PARISC_PCREL32 = 9; -enum R_PARISC_PCREL21L = 10; -enum R_PARISC_PCREL17R = 11; -enum R_PARISC_PCREL17F = 12; -enum R_PARISC_PCREL14R = 14; -enum R_PARISC_DPREL21L = 18; -enum R_PARISC_DPREL14R = 22; -enum R_PARISC_GPREL21L = 26; -enum R_PARISC_GPREL14R = 30; -enum R_PARISC_LTOFF21L = 34; -enum R_PARISC_LTOFF14R = 38; -enum R_PARISC_SECREL32 = 41; -enum R_PARISC_SEGBASE = 48; -enum R_PARISC_SEGREL32 = 49; -enum R_PARISC_PLTOFF21L = 50; -enum R_PARISC_PLTOFF14R = 54; -enum R_PARISC_LTOFF_FPTR32 = 57; -enum R_PARISC_LTOFF_FPTR21L = 58; -enum R_PARISC_LTOFF_FPTR14R = 62; -enum R_PARISC_FPTR64 = 64; -enum R_PARISC_PLABEL32 = 65; -enum R_PARISC_PLABEL21L = 66; -enum R_PARISC_PLABEL14R = 70; -enum R_PARISC_PCREL64 = 72; -enum R_PARISC_PCREL22F = 74; -enum R_PARISC_PCREL14WR = 75; -enum R_PARISC_PCREL14DR = 76; -enum R_PARISC_PCREL16F = 77; -enum R_PARISC_PCREL16WF = 78; -enum R_PARISC_PCREL16DF = 79; -enum R_PARISC_DIR64 = 80; -enum R_PARISC_DIR14WR = 83; -enum R_PARISC_DIR14DR = 84; -enum R_PARISC_DIR16F = 85; -enum R_PARISC_DIR16WF = 86; -enum R_PARISC_DIR16DF = 87; -enum R_PARISC_GPREL64 = 88; -enum R_PARISC_GPREL14WR = 91; -enum R_PARISC_GPREL14DR = 92; -enum R_PARISC_GPREL16F = 93; -enum R_PARISC_GPREL16WF = 94; -enum R_PARISC_GPREL16DF = 95; -enum R_PARISC_LTOFF64 = 96; -enum R_PARISC_LTOFF14WR = 99; -enum R_PARISC_LTOFF14DR = 100; -enum R_PARISC_LTOFF16F = 101; -enum R_PARISC_LTOFF16WF = 102; -enum R_PARISC_LTOFF16DF = 103; -enum R_PARISC_SECREL64 = 104; -enum R_PARISC_SEGREL64 = 112; -enum R_PARISC_PLTOFF14WR = 115; -enum R_PARISC_PLTOFF14DR = 116; -enum R_PARISC_PLTOFF16F = 117; -enum R_PARISC_PLTOFF16WF = 118; -enum R_PARISC_PLTOFF16DF = 119; -enum R_PARISC_LTOFF_FPTR64 = 120; -enum R_PARISC_LTOFF_FPTR14WR = 123; -enum R_PARISC_LTOFF_FPTR14DR = 124; -enum R_PARISC_LTOFF_FPTR16F = 125; -enum R_PARISC_LTOFF_FPTR16WF = 126; -enum R_PARISC_LTOFF_FPTR16DF = 127; -enum R_PARISC_LORESERVE = 128; -enum R_PARISC_COPY = 128; -enum R_PARISC_IPLT = 129; -enum R_PARISC_EPLT = 130; -enum R_PARISC_TPREL32 = 153; -enum R_PARISC_TPREL21L = 154; -enum R_PARISC_TPREL14R = 158; -enum R_PARISC_LTOFF_TP21L = 162; -enum R_PARISC_LTOFF_TP14R = 166; -enum R_PARISC_LTOFF_TP14F = 167; -enum R_PARISC_TPREL64 = 216; -enum R_PARISC_TPREL14WR = 219; -enum R_PARISC_TPREL14DR = 220; -enum R_PARISC_TPREL16F = 221; -enum R_PARISC_TPREL16WF = 222; -enum R_PARISC_TPREL16DF = 223; -enum R_PARISC_LTOFF_TP64 = 224; -enum R_PARISC_LTOFF_TP14WR = 227; -enum R_PARISC_LTOFF_TP14DR = 228; -enum R_PARISC_LTOFF_TP16F = 229; -enum R_PARISC_LTOFF_TP16WF = 230; -enum R_PARISC_LTOFF_TP16DF = 231; -enum R_PARISC_GNU_VTENTRY = 232; -enum R_PARISC_GNU_VTINHERIT = 233; -enum R_PARISC_TLS_GD21L = 234; -enum R_PARISC_TLS_GD14R = 235; -enum R_PARISC_TLS_GDCALL = 236; -enum R_PARISC_TLS_LDM21L = 237; -enum R_PARISC_TLS_LDM14R = 238; -enum R_PARISC_TLS_LDMCALL = 239; -enum R_PARISC_TLS_LDO21L = 240; -enum R_PARISC_TLS_LDO14R = 241; -enum R_PARISC_TLS_DTPMOD32 = 242; -enum R_PARISC_TLS_DTPMOD64 = 243; -enum R_PARISC_TLS_DTPOFF32 = 244; -enum R_PARISC_TLS_DTPOFF64 = 245; -enum R_PARISC_TLS_LE21L = R_PARISC_TPREL21L; -enum R_PARISC_TLS_LE14R = R_PARISC_TPREL14R; -enum R_PARISC_TLS_IE21L = R_PARISC_LTOFF_TP21L; -enum R_PARISC_TLS_IE14R = R_PARISC_LTOFF_TP14R; -enum R_PARISC_TLS_TPREL32 = R_PARISC_TPREL32; -enum R_PARISC_TLS_TPREL64 = R_PARISC_TPREL64; -enum R_PARISC_HIRESERVE = 255; - -enum PT_HP_TLS = (PT_LOOS + 0x0); -enum PT_HP_CORE_NONE = (PT_LOOS + 0x1); -enum PT_HP_CORE_VERSION = (PT_LOOS + 0x2); -enum PT_HP_CORE_KERNEL = (PT_LOOS + 0x3); -enum PT_HP_CORE_COMM = (PT_LOOS + 0x4); -enum PT_HP_CORE_PROC = (PT_LOOS + 0x5); -enum PT_HP_CORE_LOADABLE = (PT_LOOS + 0x6); -enum PT_HP_CORE_STACK = (PT_LOOS + 0x7); -enum PT_HP_CORE_SHM = (PT_LOOS + 0x8); -enum PT_HP_CORE_MMF = (PT_LOOS + 0x9); -enum PT_HP_PARALLEL = (PT_LOOS + 0x10); -enum PT_HP_FASTBIND = (PT_LOOS + 0x11); -enum PT_HP_OPT_ANNOT = (PT_LOOS + 0x12); -enum PT_HP_HSL_ANNOT = (PT_LOOS + 0x13); -enum PT_HP_STACK = (PT_LOOS + 0x14); - -enum PT_PARISC_ARCHEXT = 0x70000000; -enum PT_PARISC_UNWIND = 0x70000001; - -enum PF_PARISC_SBP = 0x08000000; - -enum PF_HP_PAGE_SIZE = 0x00100000; -enum PF_HP_FAR_SHARED = 0x00200000; -enum PF_HP_NEAR_SHARED = 0x00400000; -enum PF_HP_CODE = 0x01000000; -enum PF_HP_MODIFY = 0x02000000; -enum PF_HP_LAZYSWAP = 0x04000000; -enum PF_HP_SBP = 0x08000000; - -enum EF_ALPHA_32BIT = 1; -enum EF_ALPHA_CANRELAX = 2; -enum SHT_ALPHA_DEBUG = 0x70000001; -enum SHT_ALPHA_REGINFO = 0x70000002; - -enum SHF_ALPHA_GPREL = 0x10000000; -enum STO_ALPHA_NOPV = 0x80; -enum STO_ALPHA_STD_GPLOAD = 0x88; - -enum R_ALPHA_NONE = 0; -enum R_ALPHA_REFLONG = 1; -enum R_ALPHA_REFQUAD = 2; -enum R_ALPHA_GPREL32 = 3; -enum R_ALPHA_LITERAL = 4; -enum R_ALPHA_LITUSE = 5; -enum R_ALPHA_GPDISP = 6; -enum R_ALPHA_BRADDR = 7; -enum R_ALPHA_HINT = 8; -enum R_ALPHA_SREL16 = 9; -enum R_ALPHA_SREL32 = 10; -enum R_ALPHA_SREL64 = 11; -enum R_ALPHA_GPRELHIGH = 17; -enum R_ALPHA_GPRELLOW = 18; -enum R_ALPHA_GPREL16 = 19; -enum R_ALPHA_COPY = 24; -enum R_ALPHA_GLOB_DAT = 25; -enum R_ALPHA_JMP_SLOT = 26; -enum R_ALPHA_RELATIVE = 27; -enum R_ALPHA_TLS_GD_HI = 28; -enum R_ALPHA_TLSGD = 29; -enum R_ALPHA_TLS_LDM = 30; -enum R_ALPHA_DTPMOD64 = 31; -enum R_ALPHA_GOTDTPREL = 32; -enum R_ALPHA_DTPREL64 = 33; -enum R_ALPHA_DTPRELHI = 34; -enum R_ALPHA_DTPRELLO = 35; -enum R_ALPHA_DTPREL16 = 36; -enum R_ALPHA_GOTTPREL = 37; -enum R_ALPHA_TPREL64 = 38; -enum R_ALPHA_TPRELHI = 39; -enum R_ALPHA_TPRELLO = 40; -enum R_ALPHA_TPREL16 = 41; -enum R_ALPHA_NUM = 46; -enum LITUSE_ALPHA_ADDR = 0; -enum LITUSE_ALPHA_BASE = 1; -enum LITUSE_ALPHA_BYTOFF = 2; -enum LITUSE_ALPHA_JSR = 3; -enum LITUSE_ALPHA_TLS_GD = 4; -enum LITUSE_ALPHA_TLS_LDM = 5; -enum DT_ALPHA_PLTRO = (DT_LOPROC + 0); -enum DT_ALPHA_NUM = 1; -enum EF_PPC_EMB = 0x80000000; -enum EF_PPC_RELOCATABLE = 0x00010000; -enum EF_PPC_RELOCATABLE_LIB = 0x00008000; -enum R_PPC_NONE = 0; -enum R_PPC_ADDR32 = 1; -enum R_PPC_ADDR24 = 2; -enum R_PPC_ADDR16 = 3; -enum R_PPC_ADDR16_LO = 4; -enum R_PPC_ADDR16_HI = 5; -enum R_PPC_ADDR16_HA = 6; -enum R_PPC_ADDR14 = 7; -enum R_PPC_ADDR14_BRTAKEN = 8; -enum R_PPC_ADDR14_BRNTAKEN = 9; -enum R_PPC_REL24 = 10; -enum R_PPC_REL14 = 11; -enum R_PPC_REL14_BRTAKEN = 12; -enum R_PPC_REL14_BRNTAKEN = 13; -enum R_PPC_GOT16 = 14; -enum R_PPC_GOT16_LO = 15; -enum R_PPC_GOT16_HI = 16; -enum R_PPC_GOT16_HA = 17; -enum R_PPC_PLTREL24 = 18; -enum R_PPC_COPY = 19; -enum R_PPC_GLOB_DAT = 20; -enum R_PPC_JMP_SLOT = 21; -enum R_PPC_RELATIVE = 22; -enum R_PPC_LOCAL24PC = 23; -enum R_PPC_UADDR32 = 24; -enum R_PPC_UADDR16 = 25; -enum R_PPC_REL32 = 26; -enum R_PPC_PLT32 = 27; -enum R_PPC_PLTREL32 = 28; -enum R_PPC_PLT16_LO = 29; -enum R_PPC_PLT16_HI = 30; -enum R_PPC_PLT16_HA = 31; -enum R_PPC_SDAREL16 = 32; -enum R_PPC_SECTOFF = 33; -enum R_PPC_SECTOFF_LO = 34; -enum R_PPC_SECTOFF_HI = 35; -enum R_PPC_SECTOFF_HA = 36; -enum R_PPC_TLS = 67; -enum R_PPC_DTPMOD32 = 68; -enum R_PPC_TPREL16 = 69; -enum R_PPC_TPREL16_LO = 70; -enum R_PPC_TPREL16_HI = 71; -enum R_PPC_TPREL16_HA = 72; -enum R_PPC_TPREL32 = 73; -enum R_PPC_DTPREL16 = 74; -enum R_PPC_DTPREL16_LO = 75; -enum R_PPC_DTPREL16_HI = 76; -enum R_PPC_DTPREL16_HA = 77; -enum R_PPC_DTPREL32 = 78; -enum R_PPC_GOT_TLSGD16 = 79; -enum R_PPC_GOT_TLSGD16_LO = 80; -enum R_PPC_GOT_TLSGD16_HI = 81; -enum R_PPC_GOT_TLSGD16_HA = 82; -enum R_PPC_GOT_TLSLD16 = 83; -enum R_PPC_GOT_TLSLD16_LO = 84; -enum R_PPC_GOT_TLSLD16_HI = 85; -enum R_PPC_GOT_TLSLD16_HA = 86; -enum R_PPC_GOT_TPREL16 = 87; -enum R_PPC_GOT_TPREL16_LO = 88; -enum R_PPC_GOT_TPREL16_HI = 89; -enum R_PPC_GOT_TPREL16_HA = 90; -enum R_PPC_GOT_DTPREL16 = 91; -enum R_PPC_GOT_DTPREL16_LO = 92; -enum R_PPC_GOT_DTPREL16_HI = 93; -enum R_PPC_GOT_DTPREL16_HA = 94; -enum R_PPC_EMB_NADDR32 = 101; -enum R_PPC_EMB_NADDR16 = 102; -enum R_PPC_EMB_NADDR16_LO = 103; -enum R_PPC_EMB_NADDR16_HI = 104; -enum R_PPC_EMB_NADDR16_HA = 105; -enum R_PPC_EMB_SDAI16 = 106; -enum R_PPC_EMB_SDA2I16 = 107; -enum R_PPC_EMB_SDA2REL = 108; -enum R_PPC_EMB_SDA21 = 109; -enum R_PPC_EMB_MRKREF = 110; -enum R_PPC_EMB_RELSEC16 = 111; -enum R_PPC_EMB_RELST_LO = 112; -enum R_PPC_EMB_RELST_HI = 113; -enum R_PPC_EMB_RELST_HA = 114; -enum R_PPC_EMB_BIT_FLD = 115; -enum R_PPC_EMB_RELSDA = 116; -enum R_PPC_DIAB_SDA21_LO = 180; -enum R_PPC_DIAB_SDA21_HI = 181; -enum R_PPC_DIAB_SDA21_HA = 182; -enum R_PPC_DIAB_RELSDA_LO = 183; -enum R_PPC_DIAB_RELSDA_HI = 184; -enum R_PPC_DIAB_RELSDA_HA = 185; -enum R_PPC_IRELATIVE = 248; -enum R_PPC_REL16 = 249; -enum R_PPC_REL16_LO = 250; -enum R_PPC_REL16_HI = 251; -enum R_PPC_REL16_HA = 252; -enum R_PPC_TOC16 = 255; -enum DT_PPC_GOT = (DT_LOPROC + 0); -enum DT_PPC_NUM = 1; -enum R_PPC64_NONE = R_PPC_NONE; -enum R_PPC64_ADDR32 = R_PPC_ADDR32; -enum R_PPC64_ADDR24 = R_PPC_ADDR24; -enum R_PPC64_ADDR16 = R_PPC_ADDR16; -enum R_PPC64_ADDR16_LO = R_PPC_ADDR16_LO; -enum R_PPC64_ADDR16_HI = R_PPC_ADDR16_HI; -enum R_PPC64_ADDR16_HA = R_PPC_ADDR16_HA; -enum R_PPC64_ADDR14 = R_PPC_ADDR14; -enum R_PPC64_ADDR14_BRTAKEN = R_PPC_ADDR14_BRTAKEN; -enum R_PPC64_ADDR14_BRNTAKEN = R_PPC_ADDR14_BRNTAKEN; -enum R_PPC64_REL24 = R_PPC_REL24; -enum R_PPC64_REL14 = R_PPC_REL14; -enum R_PPC64_REL14_BRTAKEN = R_PPC_REL14_BRTAKEN; -enum R_PPC64_REL14_BRNTAKEN = R_PPC_REL14_BRNTAKEN; -enum R_PPC64_GOT16 = R_PPC_GOT16; -enum R_PPC64_GOT16_LO = R_PPC_GOT16_LO; -enum R_PPC64_GOT16_HI = R_PPC_GOT16_HI; -enum R_PPC64_GOT16_HA = R_PPC_GOT16_HA; - -enum R_PPC64_COPY = R_PPC_COPY; -enum R_PPC64_GLOB_DAT = R_PPC_GLOB_DAT; -enum R_PPC64_JMP_SLOT = R_PPC_JMP_SLOT; -enum R_PPC64_RELATIVE = R_PPC_RELATIVE; - -enum R_PPC64_UADDR32 = R_PPC_UADDR32; -enum R_PPC64_UADDR16 = R_PPC_UADDR16; -enum R_PPC64_REL32 = R_PPC_REL32; -enum R_PPC64_PLT32 = R_PPC_PLT32; -enum R_PPC64_PLTREL32 = R_PPC_PLTREL32; -enum R_PPC64_PLT16_LO = R_PPC_PLT16_LO; -enum R_PPC64_PLT16_HI = R_PPC_PLT16_HI; -enum R_PPC64_PLT16_HA = R_PPC_PLT16_HA; - -enum R_PPC64_SECTOFF = R_PPC_SECTOFF; -enum R_PPC64_SECTOFF_LO = R_PPC_SECTOFF_LO; -enum R_PPC64_SECTOFF_HI = R_PPC_SECTOFF_HI; -enum R_PPC64_SECTOFF_HA = R_PPC_SECTOFF_HA; -enum R_PPC64_ADDR30 = 37; -enum R_PPC64_ADDR64 = 38; -enum R_PPC64_ADDR16_HIGHER = 39; -enum R_PPC64_ADDR16_HIGHERA = 40; -enum R_PPC64_ADDR16_HIGHEST = 41; -enum R_PPC64_ADDR16_HIGHESTA = 42; -enum R_PPC64_UADDR64 = 43; -enum R_PPC64_REL64 = 44; -enum R_PPC64_PLT64 = 45; -enum R_PPC64_PLTREL64 = 46; -enum R_PPC64_TOC16 = 47; -enum R_PPC64_TOC16_LO = 48; -enum R_PPC64_TOC16_HI = 49; -enum R_PPC64_TOC16_HA = 50; -enum R_PPC64_TOC = 51; -enum R_PPC64_PLTGOT16 = 52; -enum R_PPC64_PLTGOT16_LO = 53; -enum R_PPC64_PLTGOT16_HI = 54; -enum R_PPC64_PLTGOT16_HA = 55; - -enum R_PPC64_ADDR16_DS = 56; -enum R_PPC64_ADDR16_LO_DS = 57; -enum R_PPC64_GOT16_DS = 58; -enum R_PPC64_GOT16_LO_DS = 59; -enum R_PPC64_PLT16_LO_DS = 60; -enum R_PPC64_SECTOFF_DS = 61; -enum R_PPC64_SECTOFF_LO_DS = 62; -enum R_PPC64_TOC16_DS = 63; -enum R_PPC64_TOC16_LO_DS = 64; -enum R_PPC64_PLTGOT16_DS = 65; -enum R_PPC64_PLTGOT16_LO_DS = 66; -enum R_PPC64_TLS = 67; -enum R_PPC64_DTPMOD64 = 68; -enum R_PPC64_TPREL16 = 69; -enum R_PPC64_TPREL16_LO = 70; -enum R_PPC64_TPREL16_HI = 71; -enum R_PPC64_TPREL16_HA = 72; -enum R_PPC64_TPREL64 = 73; -enum R_PPC64_DTPREL16 = 74; -enum R_PPC64_DTPREL16_LO = 75; -enum R_PPC64_DTPREL16_HI = 76; -enum R_PPC64_DTPREL16_HA = 77; -enum R_PPC64_DTPREL64 = 78; -enum R_PPC64_GOT_TLSGD16 = 79; -enum R_PPC64_GOT_TLSGD16_LO = 80; -enum R_PPC64_GOT_TLSGD16_HI = 81; -enum R_PPC64_GOT_TLSGD16_HA = 82; -enum R_PPC64_GOT_TLSLD16 = 83; -enum R_PPC64_GOT_TLSLD16_LO = 84; -enum R_PPC64_GOT_TLSLD16_HI = 85; -enum R_PPC64_GOT_TLSLD16_HA = 86; -enum R_PPC64_GOT_TPREL16_DS = 87; -enum R_PPC64_GOT_TPREL16_LO_DS = 88; -enum R_PPC64_GOT_TPREL16_HI = 89; -enum R_PPC64_GOT_TPREL16_HA = 90; -enum R_PPC64_GOT_DTPREL16_DS = 91; -enum R_PPC64_GOT_DTPREL16_LO_DS = 92; -enum R_PPC64_GOT_DTPREL16_HI = 93; -enum R_PPC64_GOT_DTPREL16_HA = 94; -enum R_PPC64_TPREL16_DS = 95; -enum R_PPC64_TPREL16_LO_DS = 96; -enum R_PPC64_TPREL16_HIGHER = 97; -enum R_PPC64_TPREL16_HIGHERA = 98; -enum R_PPC64_TPREL16_HIGHEST = 99; -enum R_PPC64_TPREL16_HIGHESTA = 100; -enum R_PPC64_DTPREL16_DS = 101; -enum R_PPC64_DTPREL16_LO_DS = 102; -enum R_PPC64_DTPREL16_HIGHER = 103; -enum R_PPC64_DTPREL16_HIGHERA = 104; -enum R_PPC64_DTPREL16_HIGHEST = 105; -enum R_PPC64_DTPREL16_HIGHESTA = 106; -enum R_PPC64_JMP_IREL = 247; -enum R_PPC64_IRELATIVE = 248; -enum R_PPC64_REL16 = 249; -enum R_PPC64_REL16_LO = 250; -enum R_PPC64_REL16_HI = 251; -enum R_PPC64_REL16_HA = 252; -enum DT_PPC64_GLINK = (DT_LOPROC + 0); -enum DT_PPC64_OPD = (DT_LOPROC + 1); -enum DT_PPC64_OPDSZ = (DT_LOPROC + 2); -enum DT_PPC64_NUM = 3; -enum EF_ARM_RELEXEC = 0x01; -enum EF_ARM_HASENTRY = 0x02; -enum EF_ARM_INTERWORK = 0x04; -enum EF_ARM_APCS_26 = 0x08; -enum EF_ARM_APCS_FLOAT = 0x10; -enum EF_ARM_PIC = 0x20; -enum EF_ARM_ALIGN8 = 0x40; -enum EF_ARM_NEW_ABI = 0x80; -enum EF_ARM_OLD_ABI = 0x100; -enum EF_ARM_SOFT_FLOAT = 0x200; -enum EF_ARM_VFP_FLOAT = 0x400; -enum EF_ARM_MAVERICK_FLOAT = 0x800; - -enum EF_ARM_ABI_FLOAT_SOFT = 0x200; -enum EF_ARM_ABI_FLOAT_HARD = 0x400; -enum EF_ARM_SYMSARESORTED = 0x04; -enum EF_ARM_DYNSYMSUSESEGIDX = 0x08; -enum EF_ARM_MAPSYMSFIRST = 0x10; -enum EF_ARM_EABIMASK = 0XFF000000; -enum EF_ARM_BE8 = 0x00800000; -enum EF_ARM_LE8 = 0x00400000; - -extern (D) auto EF_ARM_EABI_VERSION(F)(F flags) { return flags & EF_ARM_EABIMASK; } -enum EF_ARM_EABI_UNKNOWN = 0x00000000; -enum EF_ARM_EABI_VER1 = 0x01000000; -enum EF_ARM_EABI_VER2 = 0x02000000; -enum EF_ARM_EABI_VER3 = 0x03000000; -enum EF_ARM_EABI_VER4 = 0x04000000; -enum EF_ARM_EABI_VER5 = 0x05000000; -enum STT_ARM_TFUNC = STT_LOPROC; -enum STT_ARM_16BIT = STT_HIPROC; -enum SHF_ARM_ENTRYSECT = 0x10000000; -enum SHF_ARM_COMDEF = 0x80000000; -enum PF_ARM_SB = 0x10000000; -enum PF_ARM_PI = 0x20000000; -enum PF_ARM_ABS = 0x40000000; -enum PT_ARM_EXIDX = (PT_LOPROC + 1); -enum SHT_ARM_EXIDX = (SHT_LOPROC + 1); -enum SHT_ARM_PREEMPTMAP = (SHT_LOPROC + 2); -enum SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3); - -enum R_AARCH64_NONE = 0; -enum R_AARCH64_ABS64 = 257; -enum R_AARCH64_ABS32 = 258; -enum R_AARCH64_COPY = 1024; -enum R_AARCH64_GLOB_DAT = 1025; -enum R_AARCH64_JUMP_SLOT = 1026; -enum R_AARCH64_RELATIVE = 1027; -enum R_AARCH64_TLS_DTPMOD64 = 1028; -enum R_AARCH64_TLS_DTPREL64 = 1029; -enum R_AARCH64_TLS_TPREL64 = 1030; -enum R_AARCH64_TLSDESC = 1031; - -enum R_ARM_NONE = 0; -enum R_ARM_PC24 = 1; -enum R_ARM_ABS32 = 2; -enum R_ARM_REL32 = 3; -enum R_ARM_PC13 = 4; -enum R_ARM_ABS16 = 5; -enum R_ARM_ABS12 = 6; -enum R_ARM_THM_ABS5 = 7; -enum R_ARM_ABS8 = 8; -enum R_ARM_SBREL32 = 9; -enum R_ARM_THM_PC22 = 10; -enum R_ARM_THM_PC8 = 11; -enum R_ARM_AMP_VCALL9 = 12; -enum R_ARM_SWI24 = 13; -enum R_ARM_TLS_DESC = 13; -enum R_ARM_THM_SWI8 = 14; -enum R_ARM_XPC25 = 15; -enum R_ARM_THM_XPC22 = 16; -enum R_ARM_TLS_DTPMOD32 = 17; -enum R_ARM_TLS_DTPOFF32 = 18; -enum R_ARM_TLS_TPOFF32 = 19; -enum R_ARM_COPY = 20; -enum R_ARM_GLOB_DAT = 21; -enum R_ARM_JUMP_SLOT = 22; -enum R_ARM_RELATIVE = 23; -enum R_ARM_GOTOFF = 24; -enum R_ARM_GOTPC = 25; -enum R_ARM_GOT32 = 26; -enum R_ARM_PLT32 = 27; -enum R_ARM_ALU_PCREL_7_0 = 32; -enum R_ARM_ALU_PCREL_15_8 = 33; -enum R_ARM_ALU_PCREL_23_15 = 34; -enum R_ARM_LDR_SBREL_11_0 = 35; -enum R_ARM_ALU_SBREL_19_12 = 36; -enum R_ARM_ALU_SBREL_27_20 = 37; -enum R_ARM_TLS_GOTDESC = 90; -enum R_ARM_TLS_CALL = 91; -enum R_ARM_TLS_DESCSEQ = 92; -enum R_ARM_THM_TLS_CALL = 93; -enum R_ARM_GNU_VTENTRY = 100; -enum R_ARM_GNU_VTINHERIT = 101; -enum R_ARM_THM_PC11 = 102; -enum R_ARM_THM_PC9 = 103; -enum R_ARM_TLS_GD32 = 104; -enum R_ARM_TLS_LDM32 = 105; -enum R_ARM_TLS_LDO32 = 106; -enum R_ARM_TLS_IE32 = 107; -enum R_ARM_TLS_LE32 = 108; -enum R_ARM_THM_TLS_DESCSEQ = 129; -enum R_ARM_IRELATIVE = 160; -enum R_ARM_RXPC25 = 249; -enum R_ARM_RSBREL32 = 250; -enum R_ARM_THM_RPC22 = 251; -enum R_ARM_RREL32 = 252; -enum R_ARM_RABS22 = 253; -enum R_ARM_RPC24 = 254; -enum R_ARM_RBASE = 255; -enum R_ARM_NUM = 256; -enum EF_IA_64_MASKOS = 0x0000000f; -enum EF_IA_64_ABI64 = 0x00000010; -enum EF_IA_64_ARCH = 0xff000000; -enum PT_IA_64_ARCHEXT = (PT_LOPROC + 0); -enum PT_IA_64_UNWIND = (PT_LOPROC + 1); -enum PT_IA_64_HP_OPT_ANOT = (PT_LOOS + 0x12); -enum PT_IA_64_HP_HSL_ANOT = (PT_LOOS + 0x13); -enum PT_IA_64_HP_STACK = (PT_LOOS + 0x14); -enum PF_IA_64_NORECOV = 0x80000000; -enum SHT_IA_64_EXT = (SHT_LOPROC + 0); -enum SHT_IA_64_UNWIND = (SHT_LOPROC + 1); -enum SHF_IA_64_SHORT = 0x10000000; -enum SHF_IA_64_NORECOV = 0x20000000; -enum DT_IA_64_PLT_RESERVE = (DT_LOPROC + 0); -enum DT_IA_64_NUM = 1; -enum R_IA64_NONE = 0x00; -enum R_IA64_IMM14 = 0x21; -enum R_IA64_IMM22 = 0x22; -enum R_IA64_IMM64 = 0x23; -enum R_IA64_DIR32MSB = 0x24; -enum R_IA64_DIR32LSB = 0x25; -enum R_IA64_DIR64MSB = 0x26; -enum R_IA64_DIR64LSB = 0x27; -enum R_IA64_GPREL22 = 0x2a; -enum R_IA64_GPREL64I = 0x2b; -enum R_IA64_GPREL32MSB = 0x2c; -enum R_IA64_GPREL32LSB = 0x2d; -enum R_IA64_GPREL64MSB = 0x2e; -enum R_IA64_GPREL64LSB = 0x2f; -enum R_IA64_LTOFF22 = 0x32; -enum R_IA64_LTOFF64I = 0x33; -enum R_IA64_PLTOFF22 = 0x3a; -enum R_IA64_PLTOFF64I = 0x3b; -enum R_IA64_PLTOFF64MSB = 0x3e; -enum R_IA64_PLTOFF64LSB = 0x3f; -enum R_IA64_FPTR64I = 0x43; -enum R_IA64_FPTR32MSB = 0x44; -enum R_IA64_FPTR32LSB = 0x45; -enum R_IA64_FPTR64MSB = 0x46; -enum R_IA64_FPTR64LSB = 0x47; -enum R_IA64_PCREL60B = 0x48; -enum R_IA64_PCREL21B = 0x49; -enum R_IA64_PCREL21M = 0x4a; -enum R_IA64_PCREL21F = 0x4b; -enum R_IA64_PCREL32MSB = 0x4c; -enum R_IA64_PCREL32LSB = 0x4d; -enum R_IA64_PCREL64MSB = 0x4e; -enum R_IA64_PCREL64LSB = 0x4f; -enum R_IA64_LTOFF_FPTR22 = 0x52; -enum R_IA64_LTOFF_FPTR64I = 0x53; -enum R_IA64_LTOFF_FPTR32MSB = 0x54; -enum R_IA64_LTOFF_FPTR32LSB = 0x55; -enum R_IA64_LTOFF_FPTR64MSB = 0x56; -enum R_IA64_LTOFF_FPTR64LSB = 0x57; -enum R_IA64_SEGREL32MSB = 0x5c; -enum R_IA64_SEGREL32LSB = 0x5d; -enum R_IA64_SEGREL64MSB = 0x5e; -enum R_IA64_SEGREL64LSB = 0x5f; -enum R_IA64_SECREL32MSB = 0x64; -enum R_IA64_SECREL32LSB = 0x65; -enum R_IA64_SECREL64MSB = 0x66; -enum R_IA64_SECREL64LSB = 0x67; -enum R_IA64_REL32MSB = 0x6c; -enum R_IA64_REL32LSB = 0x6d; -enum R_IA64_REL64MSB = 0x6e; -enum R_IA64_REL64LSB = 0x6f; -enum R_IA64_LTV32MSB = 0x74; -enum R_IA64_LTV32LSB = 0x75; -enum R_IA64_LTV64MSB = 0x76; -enum R_IA64_LTV64LSB = 0x77; -enum R_IA64_PCREL21BI = 0x79; -enum R_IA64_PCREL22 = 0x7a; -enum R_IA64_PCREL64I = 0x7b; -enum R_IA64_IPLTMSB = 0x80; -enum R_IA64_IPLTLSB = 0x81; -enum R_IA64_COPY = 0x84; -enum R_IA64_SUB = 0x85; -enum R_IA64_LTOFF22X = 0x86; -enum R_IA64_LDXMOV = 0x87; -enum R_IA64_TPREL14 = 0x91; -enum R_IA64_TPREL22 = 0x92; -enum R_IA64_TPREL64I = 0x93; -enum R_IA64_TPREL64MSB = 0x96; -enum R_IA64_TPREL64LSB = 0x97; -enum R_IA64_LTOFF_TPREL22 = 0x9a; -enum R_IA64_DTPMOD64MSB = 0xa6; -enum R_IA64_DTPMOD64LSB = 0xa7; -enum R_IA64_LTOFF_DTPMOD22 = 0xaa; -enum R_IA64_DTPREL14 = 0xb1; -enum R_IA64_DTPREL22 = 0xb2; -enum R_IA64_DTPREL64I = 0xb3; -enum R_IA64_DTPREL32MSB = 0xb4; -enum R_IA64_DTPREL32LSB = 0xb5; -enum R_IA64_DTPREL64MSB = 0xb6; -enum R_IA64_DTPREL64LSB = 0xb7; -enum R_IA64_LTOFF_DTPREL22 = 0xba; -enum EF_SH_MACH_MASK = 0x1f; -enum EF_SH_UNKNOWN = 0x0; -enum EF_SH1 = 0x1; -enum EF_SH2 = 0x2; -enum EF_SH3 = 0x3; -enum EF_SH_DSP = 0x4; -enum EF_SH3_DSP = 0x5; -enum EF_SH4AL_DSP = 0x6; -enum EF_SH3E = 0x8; -enum EF_SH4 = 0x9; -enum EF_SH2E = 0xb; -enum EF_SH4A = 0xc; -enum EF_SH2A = 0xd; -enum EF_SH4_NOFPU = 0x10; -enum EF_SH4A_NOFPU = 0x11; -enum EF_SH4_NOMMU_NOFPU = 0x12; -enum EF_SH2A_NOFPU = 0x13; -enum EF_SH3_NOMMU = 0x14; -enum EF_SH2A_SH4_NOFPU = 0x15; -enum EF_SH2A_SH3_NOFPU = 0x16; -enum EF_SH2A_SH4 = 0x17; -enum EF_SH2A_SH3E = 0x18; -enum R_SH_NONE = 0; -enum R_SH_DIR32 = 1; -enum R_SH_REL32 = 2; -enum R_SH_DIR8WPN = 3; -enum R_SH_IND12W = 4; -enum R_SH_DIR8WPL = 5; -enum R_SH_DIR8WPZ = 6; -enum R_SH_DIR8BP = 7; -enum R_SH_DIR8W = 8; -enum R_SH_DIR8L = 9; -enum R_SH_SWITCH16 = 25; -enum R_SH_SWITCH32 = 26; -enum R_SH_USES = 27; -enum R_SH_COUNT = 28; -enum R_SH_ALIGN = 29; -enum R_SH_CODE = 30; -enum R_SH_DATA = 31; -enum R_SH_LABEL = 32; -enum R_SH_SWITCH8 = 33; -enum R_SH_GNU_VTINHERIT = 34; -enum R_SH_GNU_VTENTRY = 35; -enum R_SH_TLS_GD_32 = 144; -enum R_SH_TLS_LD_32 = 145; -enum R_SH_TLS_LDO_32 = 146; -enum R_SH_TLS_IE_32 = 147; -enum R_SH_TLS_LE_32 = 148; -enum R_SH_TLS_DTPMOD32 = 149; -enum R_SH_TLS_DTPOFF32 = 150; -enum R_SH_TLS_TPOFF32 = 151; -enum R_SH_GOT32 = 160; -enum R_SH_PLT32 = 161; -enum R_SH_COPY = 162; -enum R_SH_GLOB_DAT = 163; -enum R_SH_JMP_SLOT = 164; -enum R_SH_RELATIVE = 165; -enum R_SH_GOTOFF = 166; -enum R_SH_GOTPC = 167; -enum R_SH_NUM = 256; - -enum EF_S390_HIGH_GPRS = 0x00000001; - -enum R_390_NONE = 0; -enum R_390_8 = 1; -enum R_390_12 = 2; -enum R_390_16 = 3; -enum R_390_32 = 4; -enum R_390_PC32 = 5; -enum R_390_GOT12 = 6; -enum R_390_GOT32 = 7; -enum R_390_PLT32 = 8; -enum R_390_COPY = 9; -enum R_390_GLOB_DAT = 10; -enum R_390_JMP_SLOT = 11; -enum R_390_RELATIVE = 12; -enum R_390_GOTOFF32 = 13; -enum R_390_GOTPC = 14; -enum R_390_GOT16 = 15; -enum R_390_PC16 = 16; -enum R_390_PC16DBL = 17; -enum R_390_PLT16DBL = 18; -enum R_390_PC32DBL = 19; -enum R_390_PLT32DBL = 20; -enum R_390_GOTPCDBL = 21; -enum R_390_64 = 22; -enum R_390_PC64 = 23; -enum R_390_GOT64 = 24; -enum R_390_PLT64 = 25; -enum R_390_GOTENT = 26; -enum R_390_GOTOFF16 = 27; -enum R_390_GOTOFF64 = 28; -enum R_390_GOTPLT12 = 29; -enum R_390_GOTPLT16 = 30; -enum R_390_GOTPLT32 = 31; -enum R_390_GOTPLT64 = 32; -enum R_390_GOTPLTENT = 33; -enum R_390_PLTOFF16 = 34; -enum R_390_PLTOFF32 = 35; -enum R_390_PLTOFF64 = 36; -enum R_390_TLS_LOAD = 37; -enum R_390_TLS_GDCALL = 38; -enum R_390_TLS_LDCALL = 39; -enum R_390_TLS_GD32 = 40; -enum R_390_TLS_GD64 = 41; -enum R_390_TLS_GOTIE12 = 42; -enum R_390_TLS_GOTIE32 = 43; -enum R_390_TLS_GOTIE64 = 44; -enum R_390_TLS_LDM32 = 45; -enum R_390_TLS_LDM64 = 46; -enum R_390_TLS_IE32 = 47; -enum R_390_TLS_IE64 = 48; -enum R_390_TLS_IEENT = 49; -enum R_390_TLS_LE32 = 50; -enum R_390_TLS_LE64 = 51; -enum R_390_TLS_LDO32 = 52; -enum R_390_TLS_LDO64 = 53; -enum R_390_TLS_DTPMOD = 54; -enum R_390_TLS_DTPOFF = 55; -enum R_390_TLS_TPOFF = 56; -enum R_390_20 = 57; -enum R_390_GOT20 = 58; -enum R_390_GOTPLT20 = 59; -enum R_390_TLS_GOTIE20 = 60; -enum R_390_IRELATIVE = 61; -enum R_390_NUM = 62; -enum R_CRIS_NONE = 0; -enum R_CRIS_8 = 1; -enum R_CRIS_16 = 2; -enum R_CRIS_32 = 3; -enum R_CRIS_8_PCREL = 4; -enum R_CRIS_16_PCREL = 5; -enum R_CRIS_32_PCREL = 6; -enum R_CRIS_GNU_VTINHERIT = 7; -enum R_CRIS_GNU_VTENTRY = 8; -enum R_CRIS_COPY = 9; -enum R_CRIS_GLOB_DAT = 10; -enum R_CRIS_JUMP_SLOT = 11; -enum R_CRIS_RELATIVE = 12; -enum R_CRIS_16_GOT = 13; -enum R_CRIS_32_GOT = 14; -enum R_CRIS_16_GOTPLT = 15; -enum R_CRIS_32_GOTPLT = 16; -enum R_CRIS_32_GOTREL = 17; -enum R_CRIS_32_PLT_GOTREL = 18; -enum R_CRIS_32_PLT_PCREL = 19; - -enum R_CRIS_NUM = 20; -enum R_X86_64_NONE = 0; -enum R_X86_64_64 = 1; -enum R_X86_64_PC32 = 2; -enum R_X86_64_GOT32 = 3; -enum R_X86_64_PLT32 = 4; -enum R_X86_64_COPY = 5; -enum R_X86_64_GLOB_DAT = 6; -enum R_X86_64_JUMP_SLOT = 7; -enum R_X86_64_RELATIVE = 8; -enum R_X86_64_GOTPCREL = 9; -enum R_X86_64_32 = 10; -enum R_X86_64_32S = 11; -enum R_X86_64_16 = 12; -enum R_X86_64_PC16 = 13; -enum R_X86_64_8 = 14; -enum R_X86_64_PC8 = 15; -enum R_X86_64_DTPMOD64 = 16; -enum R_X86_64_DTPOFF64 = 17; -enum R_X86_64_TPOFF64 = 18; -enum R_X86_64_TLSGD = 19; -enum R_X86_64_TLSLD = 20; -enum R_X86_64_DTPOFF32 = 21; -enum R_X86_64_GOTTPOFF = 22; -enum R_X86_64_TPOFF32 = 23; -enum R_X86_64_PC64 = 24; -enum R_X86_64_GOTOFF64 = 25; -enum R_X86_64_GOTPC32 = 26; -enum R_X86_64_GOT64 = 27; -enum R_X86_64_GOTPCREL64 = 28; -enum R_X86_64_GOTPC64 = 29; -enum R_X86_64_GOTPLT64 = 30; -enum R_X86_64_PLTOFF64 = 31; -enum R_X86_64_SIZE32 = 32; -enum R_X86_64_SIZE64 = 33; -enum R_X86_64_GOTPC32_TLSDESC = 34; -enum R_X86_64_TLSDESC_CALL = 35; -enum R_X86_64_TLSDESC = 36; -enum R_X86_64_IRELATIVE = 37; -enum R_X86_64_RELATIVE64 = 38; - -enum R_X86_64_NUM = 39; -enum R_MN10300_NONE = 0; -enum R_MN10300_32 = 1; -enum R_MN10300_16 = 2; -enum R_MN10300_8 = 3; -enum R_MN10300_PCREL32 = 4; -enum R_MN10300_PCREL16 = 5; -enum R_MN10300_PCREL8 = 6; -enum R_MN10300_GNU_VTINHERIT = 7; -enum R_MN10300_GNU_VTENTRY = 8; -enum R_MN10300_24 = 9; -enum R_MN10300_GOTPC32 = 10; -enum R_MN10300_GOTPC16 = 11; -enum R_MN10300_GOTOFF32 = 12; -enum R_MN10300_GOTOFF24 = 13; -enum R_MN10300_GOTOFF16 = 14; -enum R_MN10300_PLT32 = 15; -enum R_MN10300_PLT16 = 16; -enum R_MN10300_GOT32 = 17; -enum R_MN10300_GOT24 = 18; -enum R_MN10300_GOT16 = 19; -enum R_MN10300_COPY = 20; -enum R_MN10300_GLOB_DAT = 21; -enum R_MN10300_JMP_SLOT = 22; -enum R_MN10300_RELATIVE = 23; -enum R_MN10300_TLS_GD = 24; -enum R_MN10300_TLS_LD = 25; -enum R_MN10300_TLS_LDO = 26; -enum R_MN10300_TLS_GOTIE = 27; -enum R_MN10300_TLS_IE = 28; -enum R_MN10300_TLS_LE = 29; -enum R_MN10300_TLS_DTPMOD = 30; -enum R_MN10300_TLS_DTPOFF = 31; -enum R_MN10300_TLS_TPOFF = 32; -enum R_MN10300_SYM_DIFF = 33; -enum R_MN10300_ALIGN = 34; -enum R_MN10300_NUM = 35; -enum R_M32R_NONE = 0; -enum R_M32R_16 = 1; -enum R_M32R_32 = 2; -enum R_M32R_24 = 3; -enum R_M32R_10_PCREL = 4; -enum R_M32R_18_PCREL = 5; -enum R_M32R_26_PCREL = 6; -enum R_M32R_HI16_ULO = 7; -enum R_M32R_HI16_SLO = 8; -enum R_M32R_LO16 = 9; -enum R_M32R_SDA16 = 10; -enum R_M32R_GNU_VTINHERIT = 11; -enum R_M32R_GNU_VTENTRY = 12; -enum R_M32R_16_RELA = 33; -enum R_M32R_32_RELA = 34; -enum R_M32R_24_RELA = 35; -enum R_M32R_10_PCREL_RELA = 36; -enum R_M32R_18_PCREL_RELA = 37; -enum R_M32R_26_PCREL_RELA = 38; -enum R_M32R_HI16_ULO_RELA = 39; -enum R_M32R_HI16_SLO_RELA = 40; -enum R_M32R_LO16_RELA = 41; -enum R_M32R_SDA16_RELA = 42; -enum R_M32R_RELA_GNU_VTINHERIT = 43; -enum R_M32R_RELA_GNU_VTENTRY = 44; -enum R_M32R_REL32 = 45; - -enum R_M32R_GOT24 = 48; -enum R_M32R_26_PLTREL = 49; -enum R_M32R_COPY = 50; -enum R_M32R_GLOB_DAT = 51; -enum R_M32R_JMP_SLOT = 52; -enum R_M32R_RELATIVE = 53; -enum R_M32R_GOTOFF = 54; -enum R_M32R_GOTPC24 = 55; -enum R_M32R_GOT16_HI_ULO = 56; -enum R_M32R_GOT16_HI_SLO = 57; -enum R_M32R_GOT16_LO = 58; -enum R_M32R_GOTPC_HI_ULO = 59; -enum R_M32R_GOTPC_HI_SLO = 60; -enum R_M32R_GOTPC_LO = 61; -enum R_M32R_GOTOFF_HI_ULO = 62; -enum R_M32R_GOTOFF_HI_SLO = 63; -enum R_M32R_GOTOFF_LO = 64; -enum R_M32R_NUM = 256; -enum R_TILEPRO_NONE = 0; -enum R_TILEPRO_32 = 1; -enum R_TILEPRO_16 = 2; -enum R_TILEPRO_8 = 3; -enum R_TILEPRO_32_PCREL = 4; -enum R_TILEPRO_16_PCREL = 5; -enum R_TILEPRO_8_PCREL = 6; -enum R_TILEPRO_LO16 = 7; -enum R_TILEPRO_HI16 = 8; -enum R_TILEPRO_HA16 = 9; -enum R_TILEPRO_COPY = 10; -enum R_TILEPRO_GLOB_DAT = 11; -enum R_TILEPRO_JMP_SLOT = 12; -enum R_TILEPRO_RELATIVE = 13; -enum R_TILEPRO_BROFF_X1 = 14; -enum R_TILEPRO_JOFFLONG_X1 = 15; -enum R_TILEPRO_JOFFLONG_X1_PLT = 16; -enum R_TILEPRO_IMM8_X0 = 17; -enum R_TILEPRO_IMM8_Y0 = 18; -enum R_TILEPRO_IMM8_X1 = 19; -enum R_TILEPRO_IMM8_Y1 = 20; -enum R_TILEPRO_MT_IMM15_X1 = 21; -enum R_TILEPRO_MF_IMM15_X1 = 22; -enum R_TILEPRO_IMM16_X0 = 23; -enum R_TILEPRO_IMM16_X1 = 24; -enum R_TILEPRO_IMM16_X0_LO = 25; -enum R_TILEPRO_IMM16_X1_LO = 26; -enum R_TILEPRO_IMM16_X0_HI = 27; -enum R_TILEPRO_IMM16_X1_HI = 28; -enum R_TILEPRO_IMM16_X0_HA = 29; -enum R_TILEPRO_IMM16_X1_HA = 30; -enum R_TILEPRO_IMM16_X0_PCREL = 31; -enum R_TILEPRO_IMM16_X1_PCREL = 32; -enum R_TILEPRO_IMM16_X0_LO_PCREL = 33; -enum R_TILEPRO_IMM16_X1_LO_PCREL = 34; -enum R_TILEPRO_IMM16_X0_HI_PCREL = 35; -enum R_TILEPRO_IMM16_X1_HI_PCREL = 36; -enum R_TILEPRO_IMM16_X0_HA_PCREL = 37; -enum R_TILEPRO_IMM16_X1_HA_PCREL = 38; -enum R_TILEPRO_IMM16_X0_GOT = 39; -enum R_TILEPRO_IMM16_X1_GOT = 40; -enum R_TILEPRO_IMM16_X0_GOT_LO = 41; -enum R_TILEPRO_IMM16_X1_GOT_LO = 42; -enum R_TILEPRO_IMM16_X0_GOT_HI = 43; -enum R_TILEPRO_IMM16_X1_GOT_HI = 44; -enum R_TILEPRO_IMM16_X0_GOT_HA = 45; -enum R_TILEPRO_IMM16_X1_GOT_HA = 46; -enum R_TILEPRO_MMSTART_X0 = 47; -enum R_TILEPRO_MMEND_X0 = 48; -enum R_TILEPRO_MMSTART_X1 = 49; -enum R_TILEPRO_MMEND_X1 = 50; -enum R_TILEPRO_SHAMT_X0 = 51; -enum R_TILEPRO_SHAMT_X1 = 52; -enum R_TILEPRO_SHAMT_Y0 = 53; -enum R_TILEPRO_SHAMT_Y1 = 54; -enum R_TILEPRO_DEST_IMM8_X1 = 55; -enum R_TILEPRO_TLS_GD_CALL = 60; -enum R_TILEPRO_IMM8_X0_TLS_GD_ADD = 61; -enum R_TILEPRO_IMM8_X1_TLS_GD_ADD = 62; -enum R_TILEPRO_IMM8_Y0_TLS_GD_ADD = 63; -enum R_TILEPRO_IMM8_Y1_TLS_GD_ADD = 64; -enum R_TILEPRO_TLS_IE_LOAD = 65; -enum R_TILEPRO_IMM16_X0_TLS_GD = 66; -enum R_TILEPRO_IMM16_X1_TLS_GD = 67; -enum R_TILEPRO_IMM16_X0_TLS_GD_LO = 68; -enum R_TILEPRO_IMM16_X1_TLS_GD_LO = 69; -enum R_TILEPRO_IMM16_X0_TLS_GD_HI = 70; -enum R_TILEPRO_IMM16_X1_TLS_GD_HI = 71; -enum R_TILEPRO_IMM16_X0_TLS_GD_HA = 72; -enum R_TILEPRO_IMM16_X1_TLS_GD_HA = 73; -enum R_TILEPRO_IMM16_X0_TLS_IE = 74; -enum R_TILEPRO_IMM16_X1_TLS_IE = 75; -enum R_TILEPRO_IMM16_X0_TLS_IE_LO = 76; -enum R_TILEPRO_IMM16_X1_TLS_IE_LO = 77; -enum R_TILEPRO_IMM16_X0_TLS_IE_HI = 78; -enum R_TILEPRO_IMM16_X1_TLS_IE_HI = 79; -enum R_TILEPRO_IMM16_X0_TLS_IE_HA = 80; -enum R_TILEPRO_IMM16_X1_TLS_IE_HA = 81; -enum R_TILEPRO_TLS_DTPMOD32 = 82; -enum R_TILEPRO_TLS_DTPOFF32 = 83; -enum R_TILEPRO_TLS_TPOFF32 = 84; -enum R_TILEPRO_IMM16_X0_TLS_LE = 85; -enum R_TILEPRO_IMM16_X1_TLS_LE = 86; -enum R_TILEPRO_IMM16_X0_TLS_LE_LO = 87; -enum R_TILEPRO_IMM16_X1_TLS_LE_LO = 88; -enum R_TILEPRO_IMM16_X0_TLS_LE_HI = 89; -enum R_TILEPRO_IMM16_X1_TLS_LE_HI = 90; -enum R_TILEPRO_IMM16_X0_TLS_LE_HA = 91; -enum R_TILEPRO_IMM16_X1_TLS_LE_HA = 92; - -enum R_TILEPRO_GNU_VTINHERIT = 128; -enum R_TILEPRO_GNU_VTENTRY = 129; - -enum R_TILEPRO_NUM = 130; -enum R_TILEGX_NONE = 0; -enum R_TILEGX_64 = 1; -enum R_TILEGX_32 = 2; -enum R_TILEGX_16 = 3; -enum R_TILEGX_8 = 4; -enum R_TILEGX_64_PCREL = 5; -enum R_TILEGX_32_PCREL = 6; -enum R_TILEGX_16_PCREL = 7; -enum R_TILEGX_8_PCREL = 8; -enum R_TILEGX_HW0 = 9; -enum R_TILEGX_HW1 = 10; -enum R_TILEGX_HW2 = 11; -enum R_TILEGX_HW3 = 12; -enum R_TILEGX_HW0_LAST = 13; -enum R_TILEGX_HW1_LAST = 14; -enum R_TILEGX_HW2_LAST = 15; -enum R_TILEGX_COPY = 16; -enum R_TILEGX_GLOB_DAT = 17; -enum R_TILEGX_JMP_SLOT = 18; -enum R_TILEGX_RELATIVE = 19; -enum R_TILEGX_BROFF_X1 = 20; -enum R_TILEGX_JUMPOFF_X1 = 21; -enum R_TILEGX_JUMPOFF_X1_PLT = 22; -enum R_TILEGX_IMM8_X0 = 23; -enum R_TILEGX_IMM8_Y0 = 24; -enum R_TILEGX_IMM8_X1 = 25; -enum R_TILEGX_IMM8_Y1 = 26; -enum R_TILEGX_DEST_IMM8_X1 = 27; -enum R_TILEGX_MT_IMM14_X1 = 28; -enum R_TILEGX_MF_IMM14_X1 = 29; -enum R_TILEGX_MMSTART_X0 = 30; -enum R_TILEGX_MMEND_X0 = 31; -enum R_TILEGX_SHAMT_X0 = 32; -enum R_TILEGX_SHAMT_X1 = 33; -enum R_TILEGX_SHAMT_Y0 = 34; -enum R_TILEGX_SHAMT_Y1 = 35; -enum R_TILEGX_IMM16_X0_HW0 = 36; -enum R_TILEGX_IMM16_X1_HW0 = 37; -enum R_TILEGX_IMM16_X0_HW1 = 38; -enum R_TILEGX_IMM16_X1_HW1 = 39; -enum R_TILEGX_IMM16_X0_HW2 = 40; -enum R_TILEGX_IMM16_X1_HW2 = 41; -enum R_TILEGX_IMM16_X0_HW3 = 42; -enum R_TILEGX_IMM16_X1_HW3 = 43; -enum R_TILEGX_IMM16_X0_HW0_LAST = 44; -enum R_TILEGX_IMM16_X1_HW0_LAST = 45; -enum R_TILEGX_IMM16_X0_HW1_LAST = 46; -enum R_TILEGX_IMM16_X1_HW1_LAST = 47; -enum R_TILEGX_IMM16_X0_HW2_LAST = 48; -enum R_TILEGX_IMM16_X1_HW2_LAST = 49; -enum R_TILEGX_IMM16_X0_HW0_PCREL = 50; -enum R_TILEGX_IMM16_X1_HW0_PCREL = 51; -enum R_TILEGX_IMM16_X0_HW1_PCREL = 52; -enum R_TILEGX_IMM16_X1_HW1_PCREL = 53; -enum R_TILEGX_IMM16_X0_HW2_PCREL = 54; -enum R_TILEGX_IMM16_X1_HW2_PCREL = 55; -enum R_TILEGX_IMM16_X0_HW3_PCREL = 56; -enum R_TILEGX_IMM16_X1_HW3_PCREL = 57; -enum R_TILEGX_IMM16_X0_HW0_LAST_PCREL = 58; -enum R_TILEGX_IMM16_X1_HW0_LAST_PCREL = 59; -enum R_TILEGX_IMM16_X0_HW1_LAST_PCREL = 60; -enum R_TILEGX_IMM16_X1_HW1_LAST_PCREL = 61; -enum R_TILEGX_IMM16_X0_HW2_LAST_PCREL = 62; -enum R_TILEGX_IMM16_X1_HW2_LAST_PCREL = 63; -enum R_TILEGX_IMM16_X0_HW0_GOT = 64; -enum R_TILEGX_IMM16_X1_HW0_GOT = 65; -enum R_TILEGX_IMM16_X0_HW0_PLT_PCREL = 66; -enum R_TILEGX_IMM16_X1_HW0_PLT_PCREL = 67; -enum R_TILEGX_IMM16_X0_HW1_PLT_PCREL = 68; -enum R_TILEGX_IMM16_X1_HW1_PLT_PCREL = 69; -enum R_TILEGX_IMM16_X0_HW2_PLT_PCREL = 70; -enum R_TILEGX_IMM16_X1_HW2_PLT_PCREL = 71; -enum R_TILEGX_IMM16_X0_HW0_LAST_GOT = 72; -enum R_TILEGX_IMM16_X1_HW0_LAST_GOT = 73; -enum R_TILEGX_IMM16_X0_HW1_LAST_GOT = 74; -enum R_TILEGX_IMM16_X1_HW1_LAST_GOT = 75; -enum R_TILEGX_IMM16_X0_HW3_PLT_PCREL = 76; -enum R_TILEGX_IMM16_X1_HW3_PLT_PCREL = 77; -enum R_TILEGX_IMM16_X0_HW0_TLS_GD = 78; -enum R_TILEGX_IMM16_X1_HW0_TLS_GD = 79; -enum R_TILEGX_IMM16_X0_HW0_TLS_LE = 80; -enum R_TILEGX_IMM16_X1_HW0_TLS_LE = 81; -enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE = 82; -enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE = 83; -enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE = 84; -enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE = 85; -enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD = 86; -enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD = 87; -enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD = 88; -enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD = 89; -enum R_TILEGX_IMM16_X0_HW0_TLS_IE = 92; -enum R_TILEGX_IMM16_X1_HW0_TLS_IE = 93; -enum R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL = 94; -enum R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL = 95; -enum R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL = 96; -enum R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL = 97; -enum R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL = 98; -enum R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL = 99; -enum R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE = 100; -enum R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE = 101; -enum R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE = 102; -enum R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE = 103; -enum R_TILEGX_TLS_DTPMOD64 = 106; -enum R_TILEGX_TLS_DTPOFF64 = 107; -enum R_TILEGX_TLS_TPOFF64 = 108; -enum R_TILEGX_TLS_DTPMOD32 = 109; -enum R_TILEGX_TLS_DTPOFF32 = 110; -enum R_TILEGX_TLS_TPOFF32 = 111; -enum R_TILEGX_TLS_GD_CALL = 112; -enum R_TILEGX_IMM8_X0_TLS_GD_ADD = 113; -enum R_TILEGX_IMM8_X1_TLS_GD_ADD = 114; -enum R_TILEGX_IMM8_Y0_TLS_GD_ADD = 115; -enum R_TILEGX_IMM8_Y1_TLS_GD_ADD = 116; -enum R_TILEGX_TLS_IE_LOAD = 117; -enum R_TILEGX_IMM8_X0_TLS_ADD = 118; -enum R_TILEGX_IMM8_X1_TLS_ADD = 119; -enum R_TILEGX_IMM8_Y0_TLS_ADD = 120; -enum R_TILEGX_IMM8_Y1_TLS_ADD = 121; - -enum R_TILEGX_GNU_VTINHERIT = 128; -enum R_TILEGX_GNU_VTENTRY = 129; - -enum R_TILEGX_NUM = 130; diff --git a/libphobos/libdruntime/core/sys/linux/errno.d b/libphobos/libdruntime/core/sys/linux/errno.d index 02ae151..d7a39ac 100644 --- a/libphobos/libdruntime/core/sys/linux/errno.d +++ b/libphobos/libdruntime/core/sys/linux/errno.d @@ -13,7 +13,7 @@ nothrow: public import core.stdc.errno; import core.sys.linux.config; -static if (__USE_GNU) +static if (_GNU_SOURCE) { extern __gshared char* program_invocation_name, program_invocation_short_name; alias error_t = int; diff --git a/libphobos/libdruntime/core/sys/linux/netinet/in_.d b/libphobos/libdruntime/core/sys/linux/netinet/in_.d index 67bf654..1b428f5 100644 --- a/libphobos/libdruntime/core/sys/linux/netinet/in_.d +++ b/libphobos/libdruntime/core/sys/linux/netinet/in_.d @@ -115,7 +115,7 @@ version (linux_libc) enum IN6ADDR_ANY_INIT = in6_addr.init; enum IN6ADDR_LOOPBACK_INIT = in6_addr([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]); - version (gnu_libc) static if (__USE_MISC) + version (gnu_libc) static if (_DEFAULT_SOURCE) { struct ip_mreq { @@ -174,13 +174,13 @@ version (linux_libc) extern(D) bool IN6_ARE_ADDR_EQUAL(in6_addr* a, in6_addr* b) pure @safe { return *a == *b; } - version (gnu_libc) static if (__USE_MISC) + version (gnu_libc) static if (_DEFAULT_SOURCE) { int bindresvport(int __sockfd, sockaddr_in* __sock_in); int bindresvport6(int __sockfd, sockaddr_in6* _); } - version (gnu_libc) static if (__USE_GNU) + version (gnu_libc) static if (_GNU_SOURCE) { struct in6_pktinfo { @@ -254,7 +254,7 @@ version (linux_libc) enum IP_DROP_SOURCE_MEMBERSHIP = 40; enum IP_MSFILTER = 41; - version (gnu_libc) static if (__USE_MISC) + version (gnu_libc) static if (_DEFAULT_SOURCE) { enum MCAST_JOIN_GROUP = 42; enum MCAST_BLOCK_SOURCE = 43; @@ -307,7 +307,7 @@ version (linux_libc) enum IP_DEFAULT_MULTICAST_LOOP = 1; enum IP_MAX_MEMBERSHIPS = 20; - version (gnu_libc) static if (__USE_MISC) + version (gnu_libc) static if (_DEFAULT_SOURCE) { struct ip_opts { diff --git a/libphobos/libdruntime/core/sys/linux/string.d b/libphobos/libdruntime/core/sys/linux/string.d index e3c94cf6..880faa4 100644 --- a/libphobos/libdruntime/core/sys/linux/string.d +++ b/libphobos/libdruntime/core/sys/linux/string.d @@ -16,7 +16,7 @@ nothrow: @nogc: @system: -static if (__USE_GNU) +static if (_GNU_SOURCE) { pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); } diff --git a/libphobos/libdruntime/core/sys/linux/sys/mman.d b/libphobos/libdruntime/core/sys/linux/sys/mman.d index a6548a7..649e2af 100644 --- a/libphobos/libdruntime/core/sys/linux/sys/mman.d +++ b/libphobos/libdruntime/core/sys/linux/sys/mman.d @@ -37,7 +37,7 @@ version (PPC_Any) { enum PROT_SAO = 0x10; - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x00100, MAP_DENYWRITE = 0x00800, @@ -60,7 +60,7 @@ version (PPC_Any) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/riscv/bits/mman.h else version (RISCV_Any) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x00100, MAP_DENYWRITE = 0x00800, @@ -85,7 +85,7 @@ else version (RISCV_Any) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/s390/bits/mman.h else version (IBMZ_Any) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x00100, MAP_DENYWRITE = 0x00800, @@ -101,7 +101,7 @@ else version (IBMZ_Any) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sh/bits/mman.h else version (SH) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x0100, MAP_DENYWRITE = 0x0800, @@ -117,7 +117,7 @@ else version (SH) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/bits/mman.h else version (SPARC_Any) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x0200, MAP_DENYWRITE = 0x0800, @@ -141,9 +141,9 @@ else version (SPARC_Any) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/bits/mman.h else version (X86_Any) { - static if (__USE_MISC) enum MAP_32BIT = 0x40; + static if (_DEFAULT_SOURCE) enum MAP_32BIT = 0x40; - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x00100, MAP_DENYWRITE = 0x00800, @@ -159,7 +159,7 @@ else version (X86_Any) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/aarch64/bits/mman.h else version (AArch64) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x00100, MAP_DENYWRITE = 0x00800, @@ -187,11 +187,11 @@ else version (Alpha) enum MAP_SHARED = 0x01; enum MAP_PRIVATE = 0x02; - static if (__USE_MISC) + static if (_DEFAULT_SOURCE) enum MAP_TYPE = 0x0f; enum MAP_FIXED = 0x10; - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_FILE = 0, MAP_ANONYMOUS = MAP_ANON, @@ -201,7 +201,7 @@ else version (Alpha) MAP_HUGE_MASK = 0x3f, } - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x01000, MAP_DENYWRITE = 0x02000, @@ -229,13 +229,13 @@ else version (Alpha) // MCL_FUTURE = 16384, // } - static if (__USE_GNU) enum + static if (_GNU_SOURCE) enum { MREMAP_MAYMOVE = 1, MREMAP_FIXED = 2, } - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MADV_NORMAL = 0, MADV_RANDOM = 1, @@ -255,7 +255,7 @@ else version (Alpha) } // in core.sys.posix.sys.mman - // static if (__USE_XOPEN2K) enum + // static if (_XOPEN_SOURCE >= 600) enum // { // POSIX_MADV_NORMAL = 0, // POSIX_MADV_RANDOM = 1, @@ -267,7 +267,7 @@ else version (Alpha) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/arm/bits/mman.h else version (ARM) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x00100, MAP_DENYWRITE = 0x00800, @@ -295,11 +295,11 @@ else version (HPPA_Any) enum MAP_SHARED = 0x01; enum MAP_PRIVATE = 0x02; - static if (__USE_MISC) + static if (_DEFAULT_SOURCE) enum MAP_TYPE = 0x0f; enum MAP_FIXED = 0x04; - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_FILE = 0, MAP_ANONYMOUS = MAP_ANON, @@ -310,7 +310,7 @@ else version (HPPA_Any) MAP_HUGE_MASK = 0x3f, } - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_DENYWRITE = 0x0800, MAP_EXECUTABLE = 0x1000, @@ -336,13 +336,13 @@ else version (HPPA_Any) // MCL_FUTURE = 2, // } - static if (__USE_GNU) enum + static if (_GNU_SOURCE) enum { MREMAP_MAYMOVE = 1, MREMAP_FIXED = 2, } - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MADV_NORMAL = 0, MADV_RANDOM = 1, @@ -375,7 +375,7 @@ else version (HPPA_Any) } // in core.sys.posix.sys.mman - // static if (__USE_XOPEN2K) enum + // static if (_XOPEN_SOURCE >= 600) enum // { // POSIX_MADV_NORMAL = 0, // POSIX_MADV_RANDOM = 1, @@ -387,7 +387,7 @@ else version (HPPA_Any) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/ia64/bits/mman.h else version (IA64) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x00100, MAP_GROWSUP = 0x00200, @@ -404,7 +404,7 @@ else version (IA64) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/m68k/bits/mman.h else version (M68K) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_GROWSDOWN = 0x00100, MAP_DENYWRITE = 0x00800, @@ -420,7 +420,7 @@ else version (M68K) // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/mman.h else version (MIPS_Any) { - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_NORESERVE = 0x0400, MAP_GROWSDOWN = 0x1000, @@ -460,11 +460,11 @@ else enum MAP_SHARED = 0x01; enum MAP_PRIVATE = 0x02; - static if (__USE_MISC) + static if (_DEFAULT_SOURCE) enum MAP_TYPE = 0x0f; enum MAP_FIXED = 0x10; - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MAP_FILE = 0, MAP_ANONYMOUS = MAP_ANON, @@ -482,13 +482,13 @@ else // MS_INVALIDATE = 2, // } - static if (__USE_GNU) enum + static if (_GNU_SOURCE) enum { MREMAP_MAYMOVE = 1, MREMAP_FIXED = 2, } - static if (__USE_MISC) enum + static if (_DEFAULT_SOURCE) enum { MADV_NORMAL = 0, MADV_RANDOM = 1, @@ -508,7 +508,7 @@ else } // in core.sys.posix.sys.mman - // static if (__USE_XOPEN2K) enum + // static if (_XOPEN_SOURCE >= 600) enum // { // POSIX_MADV_NORMAL = 0, // POSIX_MADV_RANDOM = 1, @@ -530,12 +530,12 @@ else // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sparc/bits/mman.h version (SPARC_Any) { - static if (__USE_MISC) enum MAP_RENAME = MAP_ANONYMOUS; + static if (_DEFAULT_SOURCE) enum MAP_RENAME = MAP_ANONYMOUS; } // http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/mips/bits/mman.h else version (MIPS_Any) { - static if (__USE_MISC) enum MAP_RENAME = MAP_ANONYMOUS; + static if (_DEFAULT_SOURCE) enum MAP_RENAME = MAP_ANONYMOUS; } // http://sourceware.org/git/?p=glibc.git;a=blob;f=misc/sys/mman.h @@ -548,14 +548,14 @@ else version (MIPS_Any) // int munmap(void*, size_t); // int mprotect(void *__addr, size_t __len, int __prot); // int msync(void *__addr, size_t __len, int __flags); -static if (__USE_MISC) int madvise(void *__addr, size_t __len, int __advice); -// static if (__USE_XOPEN2K) int posix_madvise(void *__addr, size_t __len, int __advice); +static if (_DEFAULT_SOURCE) int madvise(void *__addr, size_t __len, int __advice); +// static if (_XOPEN_SOURCE >= 600) int posix_madvise(void *__addr, size_t __len, int __advice); // int mlock(const(void) *__addr, size_t __len); // int munlock(const(void) *__addr, size_t __len); // int mlockall(int __flags); // int munlockall(); -static if (__USE_MISC) int mincore(void *__start, size_t __len, ubyte *__vec); -static if (__USE_GNU) void *mremap(void *__addr, size_t __old_len, size_t __new_len, int __flags, ...); -static if (__USE_GNU) int remap_file_pages(void *__start, size_t __size, int __prot, size_t __pgoff, int __flags); +static if (_DEFAULT_SOURCE) int mincore(void *__start, size_t __len, ubyte *__vec); +static if (_GNU_SOURCE) void *mremap(void *__addr, size_t __old_len, size_t __new_len, int __flags, ...); +static if (_GNU_SOURCE) int remap_file_pages(void *__start, size_t __size, int __prot, size_t __pgoff, int __flags); // int shm_open(in char *__name, int __oflag, mode_t __mode); // int shm_unlink(in char *__name); diff --git a/libphobos/libdruntime/core/sys/netbsd/sys/elf32.d b/libphobos/libdruntime/core/sys/netbsd/sys/elf32.d index ac623d6..48386f6 100644 --- a/libphobos/libdruntime/core/sys/netbsd/sys/elf32.d +++ b/libphobos/libdruntime/core/sys/netbsd/sys/elf32.d @@ -13,60 +13,11 @@ nothrow: import core.stdc.stdint; public import core.sys.netbsd.sys.elf_common; -alias uint16_t Elf32_Half; -alias uint32_t Elf32_Word; -alias int32_t Elf32_Sword; alias uint64_t Elf32_Lword; -alias uint32_t Elf32_Addr; -alias uint32_t Elf32_Off; alias Elf32_Word Elf32_Hashelt; alias Elf32_Word Elf32_Size; alias Elf32_Sword Elf32_Ssize; -struct Elf32_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} - -struct Elf32_Shdr -{ - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} - -struct Elf32_Phdr -{ - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; -} - struct Elf32_Dyn { Elf32_Sword d_tag; @@ -77,44 +28,8 @@ struct Elf32_Dyn } _d_un d_un; } -struct Elf32_Rel -{ - Elf32_Addr r_offset; - Elf32_Word r_info; -} - -struct Elf32_Rela -{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} - -extern (D) -{ - auto ELF32_R_SYM(V)(V val) { return val >> 8; } - auto ELF32_R_TYPE(V)(V val) { return val & 0xff; } - auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); } -} - alias Elf_Note Elf32_Nhdr; -struct Elf32_Move -{ - Elf32_Lword m_value; - Elf32_Word m_info; - Elf32_Word m_poffset; - Elf32_Half m_repeat; - Elf32_Half m_stride; -} - -extern (D) -{ - auto ELF32_M_SYM(I)(I info) { return info >> 8; } - auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } -} - struct Elf32_Cap { Elf32_Word c_tag; @@ -125,63 +40,7 @@ struct Elf32_Cap } _c_un c_un; } -struct Elf32_Sym -{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - ubyte st_info; - ubyte st_other; - Elf32_Half st_shndx; -} - extern (D) { - auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; } - auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } } - -struct Elf32_Verdef -{ - Elf32_Half vd_version; - Elf32_Half vd_flags; - Elf32_Half vd_ndx; - Elf32_Half vd_cnt; - Elf32_Word vd_hash; - Elf32_Word vd_aux; - Elf32_Word vd_next; -} - -struct Elf32_Verdaux -{ - Elf32_Word vda_name; - Elf32_Word vda_next; -} - -struct Elf32_Verneed -{ - Elf32_Half vn_version; - Elf32_Half vn_cnt; - Elf32_Word vn_file; - Elf32_Word vn_aux; - Elf32_Word vn_next; -} - -struct Elf32_Vernaux -{ - Elf32_Word vna_hash; - Elf32_Half vna_flags; - Elf32_Half vna_other; - Elf32_Word vna_name; - Elf32_Word vna_next; -} - -alias Elf32_Half Elf32_Versym; - -struct Elf32_Syminfo -{ - Elf32_Half si_boundto; - Elf32_Half si_flags; -} diff --git a/libphobos/libdruntime/core/sys/netbsd/sys/elf64.d b/libphobos/libdruntime/core/sys/netbsd/sys/elf64.d index 659ac40..3eeaa90 100644 --- a/libphobos/libdruntime/core/sys/netbsd/sys/elf64.d +++ b/libphobos/libdruntime/core/sys/netbsd/sys/elf64.d @@ -13,62 +13,11 @@ nothrow: import core.stdc.stdint; public import core.sys.netbsd.sys.elf_common; -alias uint16_t Elf64_Half; -alias uint32_t Elf64_Word; -alias int32_t Elf64_Sword; alias uint64_t Elf64_Lword; -alias uint64_t Elf64_Xword; -alias int64_t Elf64_Sxword; -alias uint64_t Elf64_Addr; -alias uint64_t Elf64_Off; alias Elf64_Word Elf64_Hashelt; alias Elf64_Xword Elf64_Size; alias Elf64_Sxword Elf64_Ssize; -struct Elf64_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; -} - -struct Elf64_Shdr -{ - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -} - -struct Elf64_Phdr -{ - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf64_Xword p_filesz; - Elf64_Xword p_memsz; - Elf64_Xword p_align; -} - struct Elf64_Dyn { Elf64_Sxword d_tag; @@ -79,25 +28,8 @@ struct Elf64_Dyn } _d_un d_un; } -struct Elf64_Rel -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; -} - -struct Elf64_Rela -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; - Elf64_Sxword r_addend; -} - extern (D) { - auto ELF64_R_SYM(I)(I i) { return i >> 32; } - auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; } - auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type & 0xffffffff); } - auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; } auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; } auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } @@ -105,22 +37,6 @@ extern (D) alias Elf_Note Elf64_Nhdr; -struct Elf64_Move -{ - Elf64_Lword m_value; - Elf64_Xword m_info; - Elf64_Xword m_poffset; - Elf64_Half m_repeat; - Elf64_Half m_stride; -} - -extern (D) -{ - auto ELF64_M_SYM(I)(I info) { return info >> 8; } - auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF64_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } -} - struct Elf64_Cap { Elf64_Xword c_tag; @@ -131,63 +47,7 @@ struct Elf64_Cap } _c_un c_un; } -struct Elf64_Sym -{ - Elf64_Word st_name; - ubyte st_info; - ubyte st_other; - Elf64_Half st_shndx; - Elf64_Addr st_value; - Elf64_Xword st_size; -} - extern (D) { - auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF64_ST_TYPE(T)(T val) { return val & 0xf; } - auto ELF64_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; } } - -struct Elf64_Verdef -{ - Elf64_Half vd_version; - Elf64_Half vd_flags; - Elf64_Half vd_ndx; - Elf64_Half vd_cnt; - Elf64_Word vd_hash; - Elf64_Word vd_aux; - Elf64_Word vd_next; -} - -struct Elf64_Verdaux -{ - Elf64_Word vda_name; - Elf64_Word vda_next; -} - -struct Elf64_Verneed -{ - Elf64_Half vn_version; - Elf64_Half vn_cnt; - Elf64_Word vn_file; - Elf64_Word vn_aux; - Elf64_Word vn_next; -} - -struct Elf64_Vernaux -{ - Elf64_Word vna_hash; - Elf64_Half vna_flags; - Elf64_Half vna_other; - Elf64_Word vna_name; - Elf64_Word vna_next; -} - -alias Elf64_Half Elf64_Versym; - -struct Elf64_Syminfo -{ - Elf64_Half si_boundto; - Elf64_Half si_flags; -} diff --git a/libphobos/libdruntime/core/sys/netbsd/sys/elf_common.d b/libphobos/libdruntime/core/sys/netbsd/sys/elf_common.d index 91d8933..6c911bd 100644 --- a/libphobos/libdruntime/core/sys/netbsd/sys/elf_common.d +++ b/libphobos/libdruntime/core/sys/netbsd/sys/elf_common.d @@ -11,6 +11,7 @@ pure: nothrow: import core.stdc.stdint; +public import core.sys.elf; struct Elf_Note { @@ -27,58 +28,7 @@ struct Elf_GNU_Hash_Header uint32_t gh_shift2; } -enum EI_MAG0 = 0; -enum EI_MAG1 = 1; -enum EI_MAG2 = 2; -enum EI_MAG3 = 3; -enum EI_CLASS = 4; -enum EI_DATA = 5; -enum EI_VERSION = 6; -enum EI_OSABI = 7; -enum EI_ABIVERSION = 8; enum OLD_EI_BRAND = 8; -enum EI_PAD = 9; -enum EI_NIDENT = 16; - -enum ELFMAG0 = 0x7f; -enum ELFMAG1 = 'E'; -enum ELFMAG2 = 'L'; -enum ELFMAG3 = 'F'; -enum ELFMAG = "\177ELF"; -enum SELFMAG = 4; - -enum EV_NONE = 0; -enum EV_CURRENT = 1; - -enum ELFCLASSNONE = 0; -enum ELFCLASS32 = 1; -enum ELFCLASS64 = 2; - -enum ELFDATANONE = 0; -enum ELFDATA2LSB = 1; -enum ELFDATA2MSB = 2; - -enum ELFOSABI_NONE = 0; -enum ELFOSABI_SYSV = 0; -enum ELFOSABI_HPUX = 1; -enum ELFOSABI_NETBSD = 2; -enum ELFOSABI_LINUX = 3; -enum ELFOSABI_HURD = 4; -enum ELFOSABI_86OPEN = 5; -enum ELFOSABI_SOLARIS = 6; -enum ELFOSABI_AIX = 7; -enum ELFOSABI_MONTEREY = 7; -enum ELFOSABI_IRIX = 8; -enum ELFOSABI_FREEBSD = 9; -enum ELFOSABI_TRU64 = 10; -enum ELFOSABI_MODESTO = 11; -enum ELFOSABI_OPENBSD = 12; -enum ELFOSABI_OPENVMS = 13; -enum ELFOSABI_NSK = 14; -enum ELFOSABI_AROS = 15; -enum ELFOSABI_ARM = 97; -enum ELFOSABI_STANDALONE = 255; -enum ELFOSABI_DRAGONFLYBSD = ELFOSABI_NONE; extern (D) { @@ -88,310 +38,31 @@ extern (D) ehdr.e_ident[EI_MAG3] == ELFMAG3; } } -enum ET_NONE = 0; -enum ET_REL = 1; -enum ET_EXEC = 2; -enum ET_DYN = 3; -enum ET_CORE = 4; -enum ET_LOOS = 0xfe00; -enum ET_HIOS = 0xfeff; -enum ET_LOPROC = 0xff00; -enum ET_HIPROC = 0xffff; - -enum EM_NONE = 0; -enum EM_M32 = 1; -enum EM_SPARC = 2; -enum EM_386 = 3; -enum EM_68K = 4; -enum EM_88K = 5; -enum EM_860 = 7; -enum EM_MIPS = 8; -enum EM_S370 = 9; -enum EM_MIPS_RS3_LE = 10; -enum EM_PARISC = 15; -enum EM_VPP500 = 17; -enum EM_SPARC32PLUS = 18; -enum EM_960 = 19; -enum EM_PPC = 20; -enum EM_PPC64 = 21; -enum EM_S390 = 22; -enum EM_V800 = 36; -enum EM_FR20 = 37; -enum EM_RH32 = 38; -enum EM_RCE = 39; -enum EM_ARM = 40; -enum EM_SH = 42; -enum EM_SPARCV9 = 43; -enum EM_TRICORE = 44; -enum EM_ARC = 45; -enum EM_H8_300 = 46; -enum EM_H8_300H = 47; -enum EM_H8S = 48; -enum EM_H8_500 = 49; -enum EM_IA_64 = 50; -enum EM_MIPS_X = 51; -enum EM_COLDFIRE = 52; -enum EM_68HC12 = 53; -enum EM_MMA = 54; -enum EM_PCP = 55; -enum EM_NCPU = 56; -enum EM_NDR1 = 57; -enum EM_STARCORE = 58; -enum EM_ME16 = 59; -enum EM_ST100 = 60; -enum EM_TINYJ = 61; -enum EM_X86_64 = 62; -enum EM_AMD64 = 62; -enum EM_PDSP = 63; -enum EM_FX66 = 66; -enum EM_ST9PLUS = 67; -enum EM_ST7 = 68; -enum EM_68HC16 = 69; -enum EM_68HC11 = 70; -enum EM_68HC08 = 71; -enum EM_68HC05 = 72; -enum EM_SVX = 73; -enum EM_ST19 = 74; -enum EM_VAX = 75; -enum EM_CRIS = 76; -enum EM_JAVELIN = 77; -enum EM_FIREPATH = 78; -enum EM_ZSP = 79; -enum EM_MMIX = 80; -enum EM_HUANY = 81; -enum EM_PRISM = 82; -enum EM_AVR = 83; -enum EM_FR30 = 84; -enum EM_D10V = 85; -enum EM_D30V = 86; -enum EM_V850 = 87; -enum EM_M32R = 88; -enum EM_MN10300 = 89; -enum EM_MN10200 = 90; -enum EM_PJ = 91; -enum EM_OPENRISC = 92; -enum EM_ARC_A5 = 93; -enum EM_XTENSA = 94; -enum EM_VIDEOCORE = 95; -enum EM_TMM_GPP = 96; -enum EM_NS32K = 97; -enum EM_TPC = 98; -enum EM_SNP1K = 99; -enum EM_ST200 = 100; -enum EM_IP2K = 101; -enum EM_MAX = 102; -enum EM_CR = 103; -enum EM_F2MC16 = 104; -enum EM_MSP430 = 105; -enum EM_BLACKFIN = 106; -enum EM_SE_C33 = 107; -enum EM_SEP = 108; -enum EM_ARCA = 109; -enum EM_UNICORE = 110; -enum EM_AARCH64 = 183; /* AArch64 64-bit ARM microprocessor */ - -/* Unofficial machine types follow */ -enum EM_AVR32 = 6317; /* used by NetBSD/avr32 */ -enum EM_ALPHA_EXP = 36902; /* used by NetBSD/alpha; obsolete */ +enum EM_AVR32 = 6317; +enum EM_ALPHA_EXP = 36902; enum EM_486 = 6; enum EM_MIPS_RS4_BE = 10; enum EM_ALPHA_STD = 41; -enum EM_ALPHA = 0x9026; - -enum SHN_UNDEF = 0; -enum SHN_LORESERVE = 0xff00; -enum SHN_LOPROC = 0xff00; -enum SHN_HIPROC = 0xff1f; -enum SHN_LOOS = 0xff20; -enum SHN_HIOS = 0xff3f; -enum SHN_ABS = 0xfff1; -enum SHN_COMMON = 0xfff2; -enum SHN_XINDEX = 0xffff; -enum SHN_HIRESERVE = 0xffff; -enum SHT_NULL = 0; -enum SHT_PROGBITS = 1; -enum SHT_SYMTAB = 2; -enum SHT_STRTAB = 3; -enum SHT_RELA = 4; -enum SHT_HASH = 5; -enum SHT_DYNAMIC = 6; -enum SHT_NOTE = 7; -enum SHT_NOBITS = 8; -enum SHT_REL = 9; -enum SHT_SHLIB = 10; -enum SHT_DYNSYM = 11; -enum SHT_INIT_ARRAY = 14; -enum SHT_FINI_ARRAY = 15; -enum SHT_PREINIT_ARRAY = 16; -enum SHT_GROUP = 17; -enum SHT_SYMTAB_SHNDX = 18; -enum SHT_LOOS = 0x60000000; -enum SHT_LOSUNW = 0x6ffffff4; enum SHT_SUNW_dof = 0x6ffffff4; enum SHT_SUNW_cap = 0x6ffffff5; enum SHT_SUNW_SIGNATURE = 0x6ffffff6; -enum SHT_GNU_HASH = 0x6ffffff6; -enum SHT_SUNW_ANNOTATE = 0x6ffffff7; -enum SHT_SUNW_DEBUGSTR = 0x6ffffff8; -enum SHT_SUNW_DEBUG = 0x6ffffff9; -enum SHT_SUNW_move = 0x6ffffffa; -enum SHT_SUNW_COMDAT = 0x6ffffffb; -enum SHT_SUNW_syminfo = 0x6ffffffc; enum SHT_SUNW_verdef = 0x6ffffffd; -enum SHT_GNU_verdef = 0x6ffffffd; enum SHT_SUNW_verneed = 0x6ffffffe; -enum SHT_GNU_verneed = 0x6ffffffe; enum SHT_SUNW_versym = 0x6fffffff; -enum SHT_GNU_versym = 0x6fffffff; -enum SHT_HISUNW = 0x6fffffff; -enum SHT_HIOS = 0x6fffffff; -enum SHT_LOPROC = 0x70000000; -enum SHT_AMD64_UNWIND = 0x70000001; -enum SHT_ARM_EXIDX = 0x70000001; -enum SHT_ARM_PREEMPTMAP = 0x70000002; -enum SHT_ARM_ATTRIBUTES = 0x70000003; -enum SHT_ARM_DEBUGOVERLAY = 0x70000004; -enum SHT_ARM_OVERLAYSECTION = 0x70000005; -enum SHT_MIPS_REGINFO = 0x70000006; -enum SHT_MIPS_OPTIONS = 0x7000000d; -enum SHT_MIPS_DWARF = 0x7000001e; -enum SHT_HIPROC = 0x7fffffff; -enum SHT_LOUSER = 0x80000000; -enum SHT_HIUSER = 0x8fffffff; -enum SHF_WRITE = (1 << 0); -enum SHF_ALLOC = (1 << 1); -enum SHF_EXECINSTR = (1 << 2); -enum SHF_MERGE = (1 << 4); -enum SHF_STRINGS = (1 << 5); -enum SHF_INFO_LINK = (1 << 6); -enum SHF_LINK_ORDER = (1 << 7); -enum SHF_OS_NONCONFORMING = (1 << 8); -enum SHF_GROUP = (1 << 9); -enum SHF_TLS = (1 << 10); -enum SHF_MASKOS = 0x0ff00000; -enum SHF_MASKPROC = 0xf0000000; - -enum PT_NULL = 0; -enum PT_LOAD = 1; -enum PT_DYNAMIC = 2; -enum PT_INTERP = 3; -enum PT_NOTE = 4; -enum PT_SHLIB = 5; -enum PT_PHDR = 6; -enum PT_TLS = 7; -enum PT_LOOS = 0x60000000; -enum PT_SUNW_UNWIND = 0x6464e550; -enum PT_GNU_EH_FRAME = 0x6474e550; -enum PT_GNU_STACK = 0x6474e551; -enum PT_GNU_RELRO = 0x6474e552; -enum PT_LOSUNW = 0x6ffffffa; -enum PT_SUNWBSS = 0x6ffffffa; -enum PT_SUNWSTACK = 0x6ffffffb; enum PT_SUNWDTRACE = 0x6ffffffc; enum PT_SUNWCAP = 0x6ffffffd; -enum PT_HISUNW = 0x6fffffff; -enum PT_HIOS = 0x6fffffff; -enum PT_LOPROC = 0x70000000; -enum PT_HIPROC = 0x7fffffff; - -enum PF_X = (1 << 0); -enum PF_W = (1 << 1); -enum PF_R = (1 << 2); -enum PF_MASKOS = 0x0ff00000; -enum PF_MASKPROC = 0xf0000000; - -enum PN_XNUM = 0xffff; - -enum DT_NULL = 0; -enum DT_NEEDED = 1; -enum DT_PLTRELSZ = 2; -enum DT_PLTGOT = 3; -enum DT_HASH = 4; -enum DT_STRTAB = 5; -enum DT_SYMTAB = 6; -enum DT_RELA = 7; -enum DT_RELASZ = 8; -enum DT_RELAENT = 9; -enum DT_STRSZ = 10; -enum DT_SYMENT = 11; -enum DT_INIT = 12; -enum DT_FINI = 13; -enum DT_SONAME = 14; -enum DT_RPATH = 15; -enum DT_SYMBOLIC = 16; -enum DT_REL = 17; -enum DT_RELSZ = 18; -enum DT_RELENT = 19; -enum DT_PLTREL = 20; -enum DT_DEBUG = 21; -enum DT_TEXTREL = 22; -enum DT_JMPREL = 23; -enum DT_BIND_NOW = 24; -enum DT_INIT_ARRAY = 25; -enum DT_FINI_ARRAY = 26; -enum DT_INIT_ARRAYSZ = 27; -enum DT_FINI_ARRAYSZ = 28; -enum DT_RUNPATH = 29; -enum DT_FLAGS = 30; -enum DT_ENCODING = 32; -enum DT_PREINIT_ARRAY = 32; -enum DT_PREINIT_ARRAYSZ = 33; enum DT_MAXPOSTAGS = 34; -enum DT_LOOS = 0x6000000d; enum DT_SUNW_AUXILIARY = 0x6000000d; enum DT_SUNW_RTLDINF = 0x6000000e; enum DT_SUNW_FILTER = 0x6000000f; enum DT_SUNW_CAP = 0x60000010; -enum DT_HIOS = 0x6ffff000; -enum DT_VALRNGLO = 0x6ffffd00; -enum DT_CHECKSUM = 0x6ffffdf8; -enum DT_PLTPADSZ = 0x6ffffdf9; -enum DT_MOVEENT = 0x6ffffdfa; -enum DT_MOVESZ = 0x6ffffdfb; -enum DT_FEATURE_1 = 0x6ffffdfc; -enum DT_POSFLAG_1 = 0x6ffffdfd; -enum DT_SYMINSZ = 0x6ffffdfe; -enum DT_SYMINENT = 0x6ffffdff; -enum DT_VALRNGHI = 0x6ffffdff; -enum DT_ADDRRNGLO = 0x6ffffe00; -enum DT_GNU_HASH = 0x6ffffef5; -enum DT_CONFIG = 0x6ffffefa; -enum DT_DEPAUDIT = 0x6ffffefb; -enum DT_AUDIT = 0x6ffffefc; -enum DT_PLTPAD = 0x6ffffefd; -enum DT_MOVETAB = 0x6ffffefe; -enum DT_SYMINFO = 0x6ffffeff; -enum DT_ADDRRNGHI = 0x6ffffeff; -enum DT_VERSYM = 0x6ffffff0; -enum DT_RELACOUNT = 0x6ffffff9; -enum DT_RELCOUNT = 0x6ffffffa; -enum DT_FLAGS_1 = 0x6ffffffb; -enum DT_VERDEF = 0x6ffffffc; -enum DT_VERDEFNUM = 0x6ffffffd; -enum DT_VERNEED = 0x6ffffffe; -enum DT_VERNEEDNUM = 0x6fffffff; -enum DT_LOPROC = 0x70000000; enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001; -enum DT_AUXILIARY = 0x7ffffffd; enum DT_USED = 0x7ffffffe; -enum DT_FILTER = 0x7fffffff; -enum DT_HIPROC = 0x7fffffff; - -enum DF_ORIGIN = 0x00000001; -enum DF_SYMBOLIC = 0x00000002; -enum DF_TEXTREL = 0x00000004; -enum DF_BIND_NOW = 0x00000008; -enum DF_STATIC_TLS = 0x00000010; enum DF_1_BIND_NOW = 0x00000001; -enum DF_1_GLOBAL = 0x00000002; -enum DF_1_NODELETE = 0x00000008; -enum DF_1_LOADFLTR = 0x00000010; -enum DF_1_NOOPEN = 0x00000040; -enum DF_1_NODEFLIB = 0x00000800; enum NT_PRSTATUS = 1; enum NT_FPREGSET = 2; @@ -407,55 +78,19 @@ enum NT_PROCSTAT_OSREL = 14; enum NT_PROCSTAT_PSSTRINGS = 15; enum NT_PROCSTAT_AUXV = 16; -enum STB_LOCAL = 0; -enum STB_GLOBAL = 1; -enum STB_WEAK = 2; -enum STB_NUM = 3; -enum STB_LOOS = 10; -enum STB_HIOS = 12; -enum STB_LOPROC = 13; -enum STB_HIPROC = 15; - -enum STT_NOTYPE = 0; -enum STT_OBJECT = 1; -enum STT_FUNC = 2; -enum STT_SECTION = 3; -enum STT_FILE = 4; -enum STT_COMMON = 5; -enum STT_TLS = 6; -enum STT_NUM = 7; -enum STT_LOOS = 10; -enum STT_GNU_IFUNC = 10; -enum STT_HIOS = 12; -enum STT_LOPROC = 13; -enum STT_HIPROC = 15; - -enum STV_DEFAULT = 0; -enum STV_INTERNAL = 1; -enum STV_HIDDEN = 2; -enum STV_PROTECTED = 3; enum STV_EXPORTED = 4; enum STV_SINGLETON = 5; enum STV_ELIMINATE = 6; -enum STN_UNDEF = 0; - -enum VER_DEF_CURRENT = 1; alias VER_NDX VER_DEF_IDX; -enum VER_FLG_BASE = 0x1; -enum VER_FLG_WEAK = 0x2; - -enum VER_NEED_CURRENT = 1; enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; alias VER_NDX VER_NEED_IDX; -enum VER_NDX_LOCAL = 0; -enum VER_NDX_GLOBAL = 1; enum VER_NDX_GIVEN = 2; - enum VER_NDX_HIDDEN = 32768; + extern (D) { auto VER_NDX(V)(V v) { return v & ~(1u << 15); } @@ -465,395 +100,10 @@ enum CA_SUNW_NULL = 0; enum CA_SUNW_HW_1 = 1; enum CA_SUNW_SF_1 = 2; -enum SYMINFO_FLG_DIRECT = 0x0001; -enum SYMINFO_FLG_PASSTHRU = 0x0002; -enum SYMINFO_FLG_COPY = 0x0004; -enum SYMINFO_FLG_LAZYLOAD = 0x0008; enum SYMINFO_FLG_DIRECTBIND = 0x0010; enum SYMINFO_FLG_NOEXTDIRECT = 0x0020; enum SYMINFO_FLG_FILTER = 0x0002; enum SYMINFO_FLG_AUXILIARY = 0x0040; -enum SYMINFO_BT_SELF = 0xffff; -enum SYMINFO_BT_PARENT = 0xfffe; enum SYMINFO_BT_NONE = 0xfffd; enum SYMINFO_BT_EXTERN = 0xfffc; -enum SYMINFO_BT_LOWRESERVE = 0xff00; - -enum SYMINFO_NONE = 0; -enum SYMINFO_CURRENT = 1; -enum SYMINFO_NUM = 2; - -enum R_386_NONE = 0; -enum R_386_32 = 1; -enum R_386_PC32 = 2; -enum R_386_GOT32 = 3; -enum R_386_PLT32 = 4; -enum R_386_COPY = 5; -enum R_386_GLOB_DAT = 6; -enum R_386_JMP_SLOT = 7; -enum R_386_RELATIVE = 8; -enum R_386_GOTOFF = 9; -enum R_386_GOTPC = 10; -enum R_386_TLS_TPOFF = 14; -enum R_386_TLS_IE = 15; -enum R_386_TLS_GOTIE = 16; -enum R_386_TLS_LE = 17; -enum R_386_TLS_GD = 18; -enum R_386_TLS_LDM = 19; -enum R_386_TLS_GD_32 = 24; -enum R_386_TLS_GD_PUSH = 25; -enum R_386_TLS_GD_CALL = 26; -enum R_386_TLS_GD_POP = 27; -enum R_386_TLS_LDM_32 = 28; -enum R_386_TLS_LDM_PUSH = 29; -enum R_386_TLS_LDM_CALL = 30; -enum R_386_TLS_LDM_POP = 31; -enum R_386_TLS_LDO_32 = 32; -enum R_386_TLS_IE_32 = 33; -enum R_386_TLS_LE_32 = 34; -enum R_386_TLS_DTPMOD32 = 35; -enum R_386_TLS_DTPOFF32 = 36; -enum R_386_TLS_TPOFF32 = 37; -enum R_386_IRELATIVE = 42; - -enum R_ARM_NONE = 0; -enum R_ARM_PC24 = 1; -enum R_ARM_ABS32 = 2; -enum R_ARM_REL32 = 3; -enum R_ARM_PC13 = 4; -enum R_ARM_ABS16 = 5; -enum R_ARM_ABS12 = 6; -enum R_ARM_THM_ABS5 = 7; -enum R_ARM_ABS8 = 8; -enum R_ARM_SBREL32 = 9; -enum R_ARM_THM_PC22 = 10; -enum R_ARM_THM_PC8 = 11; -enum R_ARM_AMP_VCALL9 = 12; -enum R_ARM_SWI24 = 13; -enum R_ARM_THM_SWI8 = 14; -enum R_ARM_XPC25 = 15; -enum R_ARM_THM_XPC22 = 16; -enum R_ARM_TLS_DTPMOD32 = 17; -enum R_ARM_TLS_DTPOFF32 = 18; -enum R_ARM_TLS_TPOFF32 = 19; -enum R_ARM_COPY = 20; -enum R_ARM_GLOB_DAT = 21; -enum R_ARM_JUMP_SLOT = 22; -enum R_ARM_RELATIVE = 23; -enum R_ARM_GOTOFF = 24; -enum R_ARM_GOTPC = 25; -enum R_ARM_GOT32 = 26; -enum R_ARM_PLT32 = 27; -enum R_ARM_GNU_VTENTRY = 100; -enum R_ARM_GNU_VTINHERIT = 101; -enum R_ARM_RSBREL32 = 250; -enum R_ARM_THM_RPC22 = 251; -enum R_ARM_RREL32 = 252; -enum R_ARM_RABS32 = 253; -enum R_ARM_RPC24 = 254; -enum R_ARM_RBASE = 255; - -enum R_IA_64_NONE = 0; -enum R_IA_64_IMM14 = 0x21; -enum R_IA_64_IMM22 = 0x22; -enum R_IA_64_IMM64 = 0x23; -enum R_IA_64_DIR32MSB = 0x24; -enum R_IA_64_DIR32LSB = 0x25; -enum R_IA_64_DIR64MSB = 0x26; -enum R_IA_64_DIR64LSB = 0x27; -enum R_IA_64_GPREL22 = 0x2a; -enum R_IA_64_GPREL64I = 0x2b; -enum R_IA_64_GPREL32MSB = 0x2c; -enum R_IA_64_GPREL32LSB = 0x2d; -enum R_IA_64_GPREL64MSB = 0x2e; -enum R_IA_64_GPREL64LSB = 0x2f; -enum R_IA_64_LTOFF22 = 0x32; -enum R_IA_64_LTOFF64I = 0x33; -enum R_IA_64_PLTOFF22 = 0x3a; -enum R_IA_64_PLTOFF64I = 0x3b; -enum R_IA_64_PLTOFF64MSB = 0x3e; -enum R_IA_64_PLTOFF64LSB = 0x3f; -enum R_IA_64_FPTR64I = 0x43; -enum R_IA_64_FPTR32MSB = 0x44; -enum R_IA_64_FPTR32LSB = 0x45; -enum R_IA_64_FPTR64MSB = 0x46; -enum R_IA_64_FPTR64LSB = 0x47; -enum R_IA_64_PCREL60B = 0x48; -enum R_IA_64_PCREL21B = 0x49; -enum R_IA_64_PCREL21M = 0x4a; -enum R_IA_64_PCREL21F = 0x4b; -enum R_IA_64_PCREL32MSB = 0x4c; -enum R_IA_64_PCREL32LSB = 0x4d; -enum R_IA_64_PCREL64MSB = 0x4e; -enum R_IA_64_PCREL64LSB = 0x4f; -enum R_IA_64_LTOFF_FPTR22 = 0x52; -enum R_IA_64_LTOFF_FPTR64I = 0x53; -enum R_IA_64_LTOFF_FPTR32MSB = 0x54; -enum R_IA_64_LTOFF_FPTR32LSB = 0x55; -enum R_IA_64_LTOFF_FPTR64MSB = 0x56; -enum R_IA_64_LTOFF_FPTR64LSB = 0x57; -enum R_IA_64_SEGREL32MSB = 0x5c; -enum R_IA_64_SEGREL32LSB = 0x5d; -enum R_IA_64_SEGREL64MSB = 0x5e; -enum R_IA_64_SEGREL64LSB = 0x5f; -enum R_IA_64_SECREL32MSB = 0x64; -enum R_IA_64_SECREL32LSB = 0x65; -enum R_IA_64_SECREL64MSB = 0x66; -enum R_IA_64_SECREL64LSB = 0x67; -enum R_IA_64_REL32MSB = 0x6c; -enum R_IA_64_REL32LSB = 0x6d; -enum R_IA_64_REL64MSB = 0x6e; -enum R_IA_64_REL64LSB = 0x6f; -enum R_IA_64_LTV32MSB = 0x74; -enum R_IA_64_LTV32LSB = 0x75; -enum R_IA_64_LTV64MSB = 0x76; -enum R_IA_64_LTV64LSB = 0x77; -enum R_IA_64_PCREL21BI = 0x79; -enum R_IA_64_PCREL22 = 0x7a; -enum R_IA_64_PCREL64I = 0x7b; -enum R_IA_64_IPLTMSB = 0x80; -enum R_IA_64_IPLTLSB = 0x81; -enum R_IA_64_SUB = 0x85; -enum R_IA_64_LTOFF22X = 0x86; -enum R_IA_64_LDXMOV = 0x87; -enum R_IA_64_TPREL14 = 0x91; -enum R_IA_64_TPREL22 = 0x92; -enum R_IA_64_TPREL64I = 0x93; -enum R_IA_64_TPREL64MSB = 0x96; -enum R_IA_64_TPREL64LSB = 0x97; -enum R_IA_64_LTOFF_TPREL22 = 0x9a; -enum R_IA_64_DTPMOD64MSB = 0xa6; -enum R_IA_64_DTPMOD64LSB = 0xa7; -enum R_IA_64_LTOFF_DTPMOD22 = 0xaa; -enum R_IA_64_DTPREL14 = 0xb1; -enum R_IA_64_DTPREL22 = 0xb2; -enum R_IA_64_DTPREL64I = 0xb3; -enum R_IA_64_DTPREL32MSB = 0xb4; -enum R_IA_64_DTPREL32LSB = 0xb5; -enum R_IA_64_DTPREL64MSB = 0xb6; -enum R_IA_64_DTPREL64LSB = 0xb7; -enum R_IA_64_LTOFF_DTPREL22 = 0xba; - -enum R_MIPS_NONE = 0; -enum R_MIPS_16 = 1; -enum R_MIPS_32 = 2; -enum R_MIPS_REL32 = 3; -enum R_MIPS_26 = 4; -enum R_MIPS_HI16 = 5; -enum R_MIPS_LO16 = 6; -enum R_MIPS_GPREL16 = 7; -enum R_MIPS_LITERAL = 8; -enum R_MIPS_GOT16 = 9; -enum R_MIPS_PC16 = 10; -enum R_MIPS_CALL16 = 11; -enum R_MIPS_GPREL32 = 12; -enum R_MIPS_GOTHI16 = 21; -enum R_MIPS_GOTLO16 = 22; -enum R_MIPS_CALLHI16 = 30; -enum R_MIPS_CALLLO16 = 31; - -enum R_PPC_NONE = 0; -enum R_PPC_ADDR32 = 1; -enum R_PPC_ADDR24 = 2; -enum R_PPC_ADDR16 = 3; -enum R_PPC_ADDR16_LO = 4; -enum R_PPC_ADDR16_HI = 5; -enum R_PPC_ADDR16_HA = 6; -enum R_PPC_ADDR14 = 7; -enum R_PPC_ADDR14_BRTAKEN = 8; -enum R_PPC_ADDR14_BRNTAKEN = 9; -enum R_PPC_REL24 = 10; -enum R_PPC_REL14 = 11; -enum R_PPC_REL14_BRTAKEN = 12; -enum R_PPC_REL14_BRNTAKEN = 13; -enum R_PPC_GOT16 = 14; -enum R_PPC_GOT16_LO = 15; -enum R_PPC_GOT16_HI = 16; -enum R_PPC_GOT16_HA = 17; -enum R_PPC_PLTREL24 = 18; -enum R_PPC_COPY = 19; -enum R_PPC_GLOB_DAT = 20; -enum R_PPC_JMP_SLOT = 21; -enum R_PPC_RELATIVE = 22; -enum R_PPC_LOCAL24PC = 23; -enum R_PPC_UADDR32 = 24; -enum R_PPC_UADDR16 = 25; -enum R_PPC_REL32 = 26; -enum R_PPC_PLT32 = 27; -enum R_PPC_PLTREL32 = 28; -enum R_PPC_PLT16_LO = 29; -enum R_PPC_PLT16_HI = 30; -enum R_PPC_PLT16_HA = 31; -enum R_PPC_SDAREL16 = 32; -enum R_PPC_SECTOFF = 33; -enum R_PPC_SECTOFF_LO = 34; -enum R_PPC_SECTOFF_HI = 35; -enum R_PPC_SECTOFF_HA = 36; - -enum R_PPC64_ADDR64 = 38; -enum R_PPC64_ADDR16_HIGHER = 39; -enum R_PPC64_ADDR16_HIGHERA = 40; -enum R_PPC64_ADDR16_HIGHEST = 41; -enum R_PPC64_ADDR16_HIGHESTA = 42; -enum R_PPC64_UADDR64 = 43; -enum R_PPC64_REL64 = 44; -enum R_PPC64_PLT64 = 45; -enum R_PPC64_PLTREL64 = 46; -enum R_PPC64_TOC16 = 47; -enum R_PPC64_TOC16_LO = 48; -enum R_PPC64_TOC16_HI = 49; -enum R_PPC64_TOC16_HA = 50; -enum R_PPC64_TOC = 51; -enum R_PPC64_DTPMOD64 = 68; -enum R_PPC64_TPREL64 = 73; -enum R_PPC64_DTPREL64 = 78; - -enum R_PPC_TLS = 67; -enum R_PPC_DTPMOD32 = 68; -enum R_PPC_TPREL16 = 69; -enum R_PPC_TPREL16_LO = 70; -enum R_PPC_TPREL16_HI = 71; -enum R_PPC_TPREL16_HA = 72; -enum R_PPC_TPREL32 = 73; -enum R_PPC_DTPREL16 = 74; -enum R_PPC_DTPREL16_LO = 75; -enum R_PPC_DTPREL16_HI = 76; -enum R_PPC_DTPREL16_HA = 77; -enum R_PPC_DTPREL32 = 78; -enum R_PPC_GOT_TLSGD16 = 79; -enum R_PPC_GOT_TLSGD16_LO = 80; -enum R_PPC_GOT_TLSGD16_HI = 81; -enum R_PPC_GOT_TLSGD16_HA = 82; -enum R_PPC_GOT_TLSLD16 = 83; -enum R_PPC_GOT_TLSLD16_LO = 84; -enum R_PPC_GOT_TLSLD16_HI = 85; -enum R_PPC_GOT_TLSLD16_HA = 86; -enum R_PPC_GOT_TPREL16 = 87; -enum R_PPC_GOT_TPREL16_LO = 88; -enum R_PPC_GOT_TPREL16_HI = 89; -enum R_PPC_GOT_TPREL16_HA = 90; - -enum R_PPC_EMB_NADDR32 = 101; -enum R_PPC_EMB_NADDR16 = 102; -enum R_PPC_EMB_NADDR16_LO = 103; -enum R_PPC_EMB_NADDR16_HI = 104; -enum R_PPC_EMB_NADDR16_HA = 105; -enum R_PPC_EMB_SDAI16 = 106; -enum R_PPC_EMB_SDA2I16 = 107; -enum R_PPC_EMB_SDA2REL = 108; -enum R_PPC_EMB_SDA21 = 109; -enum R_PPC_EMB_MRKREF = 110; -enum R_PPC_EMB_RELSEC16 = 111; -enum R_PPC_EMB_RELST_LO = 112; -enum R_PPC_EMB_RELST_HI = 113; -enum R_PPC_EMB_RELST_HA = 114; -enum R_PPC_EMB_BIT_FLD = 115; -enum R_PPC_EMB_RELSDA = 116; - -enum R_SPARC_NONE = 0; -enum R_SPARC_8 = 1; -enum R_SPARC_16 = 2; -enum R_SPARC_32 = 3; -enum R_SPARC_DISP8 = 4; -enum R_SPARC_DISP16 = 5; -enum R_SPARC_DISP32 = 6; -enum R_SPARC_WDISP30 = 7; -enum R_SPARC_WDISP22 = 8; -enum R_SPARC_HI22 = 9; -enum R_SPARC_22 = 10; -enum R_SPARC_13 = 11; -enum R_SPARC_LO10 = 12; -enum R_SPARC_GOT10 = 13; -enum R_SPARC_GOT13 = 14; -enum R_SPARC_GOT22 = 15; -enum R_SPARC_PC10 = 16; -enum R_SPARC_PC22 = 17; -enum R_SPARC_WPLT30 = 18; -enum R_SPARC_COPY = 19; -enum R_SPARC_GLOB_DAT = 20; -enum R_SPARC_JMP_SLOT = 21; -enum R_SPARC_RELATIVE = 22; -enum R_SPARC_UA32 = 23; -enum R_SPARC_PLT32 = 24; -enum R_SPARC_HIPLT22 = 25; -enum R_SPARC_LOPLT10 = 26; -enum R_SPARC_PCPLT32 = 27; -enum R_SPARC_PCPLT22 = 28; -enum R_SPARC_PCPLT10 = 29; -enum R_SPARC_10 = 30; -enum R_SPARC_11 = 31; -enum R_SPARC_64 = 32; -enum R_SPARC_OLO10 = 33; -enum R_SPARC_HH22 = 34; -enum R_SPARC_HM10 = 35; -enum R_SPARC_LM22 = 36; -enum R_SPARC_PC_HH22 = 37; -enum R_SPARC_PC_HM10 = 38; -enum R_SPARC_PC_LM22 = 39; -enum R_SPARC_WDISP16 = 40; -enum R_SPARC_WDISP19 = 41; -enum R_SPARC_GLOB_JMP = 42; -enum R_SPARC_7 = 43; -enum R_SPARC_5 = 44; -enum R_SPARC_6 = 45; -enum R_SPARC_DISP64 = 46; -enum R_SPARC_PLT64 = 47; -enum R_SPARC_HIX22 = 48; -enum R_SPARC_LOX10 = 49; -enum R_SPARC_H44 = 50; -enum R_SPARC_M44 = 51; -enum R_SPARC_L44 = 52; -enum R_SPARC_REGISTER = 53; -enum R_SPARC_UA64 = 54; -enum R_SPARC_UA16 = 55; -enum R_SPARC_TLS_GD_HI22 = 56; -enum R_SPARC_TLS_GD_LO10 = 57; -enum R_SPARC_TLS_GD_ADD = 58; -enum R_SPARC_TLS_GD_CALL = 59; -enum R_SPARC_TLS_LDM_HI22 = 60; -enum R_SPARC_TLS_LDM_LO10 = 61; -enum R_SPARC_TLS_LDM_ADD = 62; -enum R_SPARC_TLS_LDM_CALL = 63; -enum R_SPARC_TLS_LDO_HIX22 = 64; -enum R_SPARC_TLS_LDO_LOX10 = 65; -enum R_SPARC_TLS_LDO_ADD = 66; -enum R_SPARC_TLS_IE_HI22 = 67; -enum R_SPARC_TLS_IE_LO10 = 68; -enum R_SPARC_TLS_IE_LD = 69; -enum R_SPARC_TLS_IE_LDX = 70; -enum R_SPARC_TLS_IE_ADD = 71; -enum R_SPARC_TLS_LE_HIX22 = 72; -enum R_SPARC_TLS_LE_LOX10 = 73; -enum R_SPARC_TLS_DTPMOD32 = 74; -enum R_SPARC_TLS_DTPMOD64 = 75; -enum R_SPARC_TLS_DTPOFF32 = 76; -enum R_SPARC_TLS_DTPOFF64 = 77; -enum R_SPARC_TLS_TPOFF32 = 78; -enum R_SPARC_TLS_TPOFF64 = 79; - -enum R_X86_64_NONE = 0; -enum R_X86_64_64 = 1; -enum R_X86_64_PC32 = 2; -enum R_X86_64_GOT32 = 3; -enum R_X86_64_PLT32 = 4; -enum R_X86_64_COPY = 5; -enum R_X86_64_GLOB_DAT = 6; -enum R_X86_64_JMP_SLOT = 7; -enum R_X86_64_RELATIVE = 8; -enum R_X86_64_GOTPCREL = 9; -enum R_X86_64_32 = 10; -enum R_X86_64_32S = 11; -enum R_X86_64_16 = 12; -enum R_X86_64_PC16 = 13; -enum R_X86_64_8 = 14; -enum R_X86_64_PC8 = 15; -enum R_X86_64_DTPMOD64 = 16; -enum R_X86_64_DTPOFF64 = 17; -enum R_X86_64_TPOFF64 = 18; -enum R_X86_64_TLSGD = 19; -enum R_X86_64_TLSLD = 20; -enum R_X86_64_DTPOFF32 = 21; -enum R_X86_64_GOTTPOFF = 22; -enum R_X86_64_TPOFF32 = 23; -enum R_X86_64_IRELATIVE = 37; diff --git a/libphobos/libdruntime/core/sys/openbsd/pwd.d b/libphobos/libdruntime/core/sys/openbsd/pwd.d new file mode 100644 index 0000000..f6a35a8 --- /dev/null +++ b/libphobos/libdruntime/core/sys/openbsd/pwd.d @@ -0,0 +1,19 @@ +/** + * D header file for OpenBSD pwd.h. + * + * Copyright: Copyright © 2022, The D Language Foundation + * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. + * Authors: Brian Callahan + */ +module core.sys.openbsd.pwd; + +version (OpenBSD): +extern (C): +nothrow: +@nogc: + +public import core.sys.posix.pwd; +import core.sys.posix.sys.types : uid_t; + +passwd* getpwnam_shadow(scope const char*); +passwd* getpwuid_shadow(uid_t); diff --git a/libphobos/libdruntime/core/sys/openbsd/sys/elf32.d b/libphobos/libdruntime/core/sys/openbsd/sys/elf32.d index dae977a..c561121 100644 --- a/libphobos/libdruntime/core/sys/openbsd/sys/elf32.d +++ b/libphobos/libdruntime/core/sys/openbsd/sys/elf32.d @@ -7,66 +7,18 @@ module core.sys.openbsd.sys.elf32; version (OpenBSD): - extern (C): +pure: +nothrow: import core.stdc.stdint; public import core.sys.openbsd.sys.elf_common; -alias uint16_t Elf32_Half; -alias uint32_t Elf32_Word; -alias int32_t Elf32_Sword; alias uint64_t Elf32_Lword; -alias uint32_t Elf32_Addr; -alias uint32_t Elf32_Off; alias Elf32_Word Elf32_Hashelt; alias Elf32_Word Elf32_Size; alias Elf32_Sword Elf32_Ssize; -struct Elf32_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} - -struct Elf32_Shdr -{ - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} - -struct Elf32_Phdr -{ - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; -} - struct Elf32_Dyn { Elf32_Sword d_tag; @@ -77,44 +29,8 @@ struct Elf32_Dyn } _d_un d_un; } -struct Elf32_Rel -{ - Elf32_Addr r_offset; - Elf32_Word r_info; -} - -struct Elf32_Rela -{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} - -extern (D) pure @safe -{ - auto ELF32_R_SYM(V)(V val) { return val >> 8; } - auto ELF32_R_TYPE(V)(V val) { return val & 0xff; } - auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); } -} - alias Elf_Note Elf32_Nhdr; -struct Elf32_Move -{ - Elf32_Lword m_value; - Elf32_Word m_info; - Elf32_Word m_poffset; - Elf32_Half m_repeat; - Elf32_Half m_stride; -} - -extern (D) pure -{ - auto ELF32_M_SYM(I)(I info) @safe { return info >> 8; } - auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } -} - struct Elf32_Cap { Elf32_Word c_tag; @@ -125,63 +41,7 @@ struct Elf32_Cap } _c_un c_un; } -struct Elf32_Sym -{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - ubyte st_info; - ubyte st_other; - Elf32_Half st_shndx; -} - -extern (D) pure -{ - auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF32_ST_TYPE(T)(T val) @safe { return val & 0xf; } - auto ELF32_ST_INFO(B, T)(B bind, T type) @safe { return (bind << 4) + (type & 0xf); } - auto ELF32_ST_VISIBILITY(O)(O o) @safe { return o & 0x03; } -} - -struct Elf32_Verdef -{ - Elf32_Half vd_version; - Elf32_Half vd_flags; - Elf32_Half vd_ndx; - Elf32_Half vd_cnt; - Elf32_Word vd_hash; - Elf32_Word vd_aux; - Elf32_Word vd_next; -} - -struct Elf32_Verdaux -{ - Elf32_Word vda_name; - Elf32_Word vda_next; -} - -struct Elf32_Verneed -{ - Elf32_Half vn_version; - Elf32_Half vn_cnt; - Elf32_Word vn_file; - Elf32_Word vn_aux; - Elf32_Word vn_next; -} - -struct Elf32_Vernaux -{ - Elf32_Word vna_hash; - Elf32_Half vna_flags; - Elf32_Half vna_other; - Elf32_Word vna_name; - Elf32_Word vna_next; -} - -alias Elf32_Half Elf32_Versym; - -struct Elf32_Syminfo +extern (D) { - Elf32_Half si_boundto; - Elf32_Half si_flags; + auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } } diff --git a/libphobos/libdruntime/core/sys/openbsd/sys/elf64.d b/libphobos/libdruntime/core/sys/openbsd/sys/elf64.d index e26a5fc..47f84d4 100644 --- a/libphobos/libdruntime/core/sys/openbsd/sys/elf64.d +++ b/libphobos/libdruntime/core/sys/openbsd/sys/elf64.d @@ -7,68 +7,18 @@ module core.sys.openbsd.sys.elf64; version (OpenBSD): - extern (C): +pure: +nothrow: import core.stdc.stdint; public import core.sys.openbsd.sys.elf_common; -alias uint16_t Elf64_Half; -alias uint32_t Elf64_Word; -alias int32_t Elf64_Sword; alias uint64_t Elf64_Lword; -alias uint64_t Elf64_Xword; -alias int64_t Elf64_Sxword; -alias uint64_t Elf64_Addr; -alias uint64_t Elf64_Off; alias Elf64_Word Elf64_Hashelt; alias Elf64_Xword Elf64_Size; alias Elf64_Sxword Elf64_Ssize; -struct Elf64_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; -} - -struct Elf64_Shdr -{ - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -} - -struct Elf64_Phdr -{ - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf64_Xword p_filesz; - Elf64_Xword p_memsz; - Elf64_Xword p_align; -} - struct Elf64_Dyn { Elf64_Sxword d_tag; @@ -79,25 +29,8 @@ struct Elf64_Dyn } _d_un d_un; } -struct Elf64_Rel -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; -} - -struct Elf64_Rela -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; - Elf64_Sxword r_addend; -} - extern (D) pure { - auto ELF64_R_SYM(I)(I i) @safe { return i >> 32; } - auto ELF64_R_TYPE(I)(I i) @safe { return i & 0xffffffff; } - auto ELF64_R_INFO(S, T)(S sym, T type) @safe { return (sym << 32) + (type & 0xffffffff); } - auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; } auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; } auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } @@ -105,22 +38,6 @@ extern (D) pure alias Elf_Note Elf64_Nhdr; -struct Elf64_Move -{ - Elf64_Lword m_value; - Elf64_Xword m_info; - Elf64_Xword m_poffset; - Elf64_Half m_repeat; - Elf64_Half m_stride; -} - -extern (D) pure -{ - auto ELF64_M_SYM(I)(I info) @safe { return info >> 8; } - auto ELF64_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF64_M_INFO(S, SZ)(S sym, SZ size) @safe { return (sym << 8) + cast(ubyte)size; } -} - struct Elf64_Cap { Elf64_Xword c_tag; @@ -131,63 +48,7 @@ struct Elf64_Cap } _c_un c_un; } -struct Elf64_Sym -{ - Elf64_Word st_name; - ubyte st_info; - ubyte st_other; - Elf64_Half st_shndx; - Elf64_Addr st_value; - Elf64_Xword st_size; -} - -extern (D) pure -{ - auto ELF64_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF64_ST_TYPE(T)(T val) @safe { return val & 0xf; } - auto ELF64_ST_INFO(B, T)(B bind, T type) @safe { return (bind << 4) + (type & 0xf); } - auto ELF64_ST_VISIBILITY(O)(O o) @safe { return o & 0x03; } -} - -struct Elf64_Verdef -{ - Elf64_Half vd_version; - Elf64_Half vd_flags; - Elf64_Half vd_ndx; - Elf64_Half vd_cnt; - Elf64_Word vd_hash; - Elf64_Word vd_aux; - Elf64_Word vd_next; -} - -struct Elf64_Verdaux -{ - Elf64_Word vda_name; - Elf64_Word vda_next; -} - -struct Elf64_Verneed -{ - Elf64_Half vn_version; - Elf64_Half vn_cnt; - Elf64_Word vn_file; - Elf64_Word vn_aux; - Elf64_Word vn_next; -} - -struct Elf64_Vernaux -{ - Elf64_Word vna_hash; - Elf64_Half vna_flags; - Elf64_Half vna_other; - Elf64_Word vna_name; - Elf64_Word vna_next; -} - -alias Elf64_Half Elf64_Versym; - -struct Elf64_Syminfo +extern (D) { - Elf64_Half si_boundto; - Elf64_Half si_flags; + auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; } } diff --git a/libphobos/libdruntime/core/sys/openbsd/sys/elf_common.d b/libphobos/libdruntime/core/sys/openbsd/sys/elf_common.d index bcd2701..4812e1f 100644 --- a/libphobos/libdruntime/core/sys/openbsd/sys/elf_common.d +++ b/libphobos/libdruntime/core/sys/openbsd/sys/elf_common.d @@ -7,10 +7,12 @@ module core.sys.openbsd.sys.elf_common; version (OpenBSD): - extern (C): +pure: +nothrow: import core.stdc.stdint; +public import core.sys.elf; struct Elf_Note { @@ -27,60 +29,7 @@ struct Elf_GNU_Hash_Header uint32_t gh_shift2; } -enum EI_MAG0 = 0; -enum EI_MAG1 = 1; -enum EI_MAG2 = 2; -enum EI_MAG3 = 3; -enum EI_CLASS = 4; -enum EI_DATA = 5; -enum EI_VERSION = 6; -enum EI_OSABI = 7; -enum EI_ABIVERSION = 8; enum OLD_EI_BRAND = 8; -enum EI_PAD = 9; -enum EI_NIDENT = 16; - -enum ELFMAG0 = 0x7f; -enum ELFMAG1 = 'E'; -enum ELFMAG2 = 'L'; -enum ELFMAG3 = 'F'; -enum ELFMAG = "\177ELF"; -enum SELFMAG = 4; - -enum EV_NONE = 0; -enum EV_CURRENT = 1; - -enum ELFCLASSNONE = 0; -enum ELFCLASS32 = 1; -enum ELFCLASS64 = 2; - -enum ELFDATANONE = 0; -enum ELFDATA2LSB = 1; -enum ELFDATA2MSB = 2; - -enum ELFOSABI_NONE = 0; -enum ELFOSABI_SYSV = 0; -enum ELFOSABI_HPUX = 1; -enum ELFOSABI_NETBSD = 2; -enum ELFOSABI_LINUX = 3; -enum ELFOSABI_HURD = 4; -enum ELFOSABI_86OPEN = 5; -enum ELFOSABI_SOLARIS = 6; -enum ELFOSABI_AIX = 7; -enum ELFOSABI_MONTEREY = 7; -enum ELFOSABI_IRIX = 8; -enum ELFOSABI_FREEBSD = 9; -enum ELFOSABI_TRU64 = 10; -enum ELFOSABI_MODESTO = 11; -enum ELFOSABI_OPENBSD = 12; -enum ELFOSABI_OPENVMS = 13; -enum ELFOSABI_NSK = 14; -enum ELFOSABI_AROS = 15; -enum ELFOSABI_ARM = 97; -enum ELFOSABI_STANDALONE = 255; - -// just a pointer -enum ELFOSABI_DRAGONFLYBSD = ELFOSABI_NONE; extern (D) pure @safe { @@ -90,587 +39,44 @@ extern (D) pure @safe ehdr.e_ident[EI_MAG3] == ELFMAG3; } } -enum ET_NONE = 0; -enum ET_REL = 1; -enum ET_EXEC = 2; -enum ET_DYN = 3; -enum ET_CORE = 4; -enum ET_LOOS = 0xfe00; -enum ET_HIOS = 0xfeff; -enum ET_LOPROC = 0xff00; -enum ET_HIPROC = 0xffff; - -enum EM_NONE = 0; -enum EM_M32 = 1; -enum EM_SPARC = 2; -enum EM_386 = 3; -enum EM_68K = 4; -enum EM_88K = 5; -enum EM_860 = 7; -enum EM_MIPS = 8; -enum EM_S370 = 9; -enum EM_MIPS_RS3_LE = 10; -enum EM_PARISC = 15; -enum EM_VPP500 = 17; -enum EM_SPARC32PLUS = 18; -enum EM_960 = 19; -enum EM_PPC = 20; -enum EM_PPC64 = 21; -enum EM_S390 = 22; -enum EM_V800 = 36; -enum EM_FR20 = 37; -enum EM_RH32 = 38; -enum EM_RCE = 39; -enum EM_ARM = 40; -enum EM_SH = 42; -enum EM_SPARCV9 = 43; -enum EM_TRICORE = 44; -enum EM_ARC = 45; -enum EM_H8_300 = 46; -enum EM_H8_300H = 47; -enum EM_H8S = 48; -enum EM_H8_500 = 49; -enum EM_IA_64 = 50; -enum EM_MIPS_X = 51; -enum EM_COLDFIRE = 52; -enum EM_68HC12 = 53; -enum EM_MMA = 54; -enum EM_PCP = 55; -enum EM_NCPU = 56; -enum EM_NDR1 = 57; -enum EM_STARCORE = 58; -enum EM_ME16 = 59; -enum EM_ST100 = 60; -enum EM_TINYJ = 61; -enum EM_X86_64 = 62; -enum EM_AMD64 = 62; -enum EM_PDSP = 63; -enum EM_FX66 = 66; -enum EM_ST9PLUS = 67; -enum EM_ST7 = 68; -enum EM_68HC16 = 69; -enum EM_68HC11 = 70; -enum EM_68HC08 = 71; -enum EM_68HC05 = 72; -enum EM_SVX = 73; -enum EM_ST19 = 74; -enum EM_VAX = 75; -enum EM_CRIS = 76; -enum EM_JAVELIN = 77; -enum EM_FIREPATH = 78; -enum EM_ZSP = 79; -enum EM_MMIX = 80; -enum EM_HUANY = 81; -enum EM_PRISM = 82; -enum EM_AVR = 83; -enum EM_FR30 = 84; -enum EM_D10V = 85; -enum EM_D30V = 86; -enum EM_V850 = 87; -enum EM_M32R = 88; -enum EM_MN10300 = 89; -enum EM_MN10200 = 90; -enum EM_PJ = 91; -enum EM_OPENRISC = 92; -enum EM_ARC_A5 = 93; -enum EM_XTENSA = 94; -enum EM_VIDEOCORE = 95; -enum EM_TMM_GPP = 96; -enum EM_NS32K = 97; -enum EM_TPC = 98; -enum EM_SNP1K = 99; -enum EM_ST200 = 100; -enum EM_IP2K = 101; -enum EM_MAX = 102; -enum EM_CR = 103; -enum EM_F2MC16 = 104; -enum EM_MSP430 = 105; -enum EM_BLACKFIN = 106; -enum EM_SE_C33 = 107; -enum EM_SEP = 108; -enum EM_ARCA = 109; -enum EM_UNICORE = 110; -enum EM_DXP = 112; -enum EM_ALTERA_NIOS2 =113; -enum EM_CRX = 114; -enum EM_XGATE = 115; -enum EM_C166 = 116; -enum EM_M16C = 117; -enum EM_DSPIC30F = 118; -enum EM_CE = 119; -enum EM_M32C = 120; -enum EM_res121 = 121; -enum EM_res122 = 122; -enum EM_res123 = 123; -enum EM_res124 = 124; -enum EM_res125 = 125; -enum EM_res126 = 126; -enum EM_res127 = 127; -enum EM_res128 = 128; -enum EM_res129 = 129; -enum EM_res130 = 130; -enum EM_TSK3000 = 131; -enum EM_RS08 = 132; -enum EM_res133 = 133; -enum EM_ECOG2 = 134; -enum EM_SCORE = 135; -enum EM_SCORE7 = 135; -enum EM_DSP24 = 136; -enum EM_VIDEOCORE3 = 137; -enum EM_LATTICEMICO32 = 138; -enum EM_SE_C17 = 139; -enum EM_TI_C6000 = 140; -enum EM_TI_C2000 = 141; -enum EM_TI_C5500 = 142; -enum EM_res143 = 143; -enum EM_res144 = 144; -enum EM_res145 = 145; -enum EM_res146 = 146; -enum EM_res147 = 147; -enum EM_res148 = 148; -enum EM_res149 = 149; -enum EM_res150 = 150; -enum EM_res151 = 151; -enum EM_res152 = 152; -enum EM_res153 = 153; -enum EM_res154 = 154; -enum EM_res155 = 155; -enum EM_res156 = 156; -enum EM_res157 = 157; -enum EM_res158 = 158; -enum EM_res159 = 159; -enum EM_MMDSP_PLUS = 160; -enum EM_CYPRESS_M8C = 161; -enum EM_R32C = 162; -enum EM_TRIMEDIA = 163; -enum EM_QDSP6 = 164; -enum EM_8051 = 165; -enum EM_STXP7X = 166; -enum EM_NDS32 = 167; -enum EM_ECOG1 = 168; -enum EM_ECOG1X = 168; -enum EM_MAXQ30 = 169; -enum EM_XIMO16 = 170; -enum EM_MANIK = 171; -enum EM_CRAYNV2 = 172; -enum EM_RX = 173; -enum EM_METAG = 174; -enum EM_MCST_ELBRUS = 175; -enum EM_ECOG16 = 176; -enum EM_CR16 = 177; -enum EM_ETPU = 178; -enum EM_SLE9X = 179; -enum EM_L1OM = 180; -enum EM_K1OM = 181; -enum EM_INTEL182 = 182; -enum EM_res183 = 183; -enum EM_res184 = 184; -enum EM_AVR32 = 185; -enum EM_STM8 = 186; -enum EM_TILE64 = 187; -enum EM_TILEPRO = 188; -enum EM_MICROBLAZE = 189; -enum EM_CUDA = 190; -enum EM_TILEGX = 191; - enum EM_486 = 6; enum EM_MIPS_RS4_BE = 10; enum EM_ALPHA_STD = 41; -enum EM_ALPHA = 0x9026; - -enum SHN_UNDEF = 0; -enum SHN_LORESERVE = 0xff00; -enum SHN_LOPROC = 0xff00; -enum SHN_HIPROC = 0xff1f; -enum SHN_LOOS = 0xff20; -enum SHN_HIOS = 0xff3f; -enum SHN_ABS = 0xfff1; -enum SHN_COMMON = 0xfff2; -enum SHN_XINDEX = 0xffff; -enum SHN_HIRESERVE = 0xffff; -enum PT_NULL = 0; -enum PT_LOAD = 1; -enum PT_DYNAMIC = 2; -enum PT_INTERP = 3; -enum PT_NOTE = 4; -enum PT_SHLIB = 5; -enum PT_PHDR = 6; -enum PT_TLS = 7; -enum PT_LOOS = 0x60000000; -enum PT_HIOS = 0x6fffffff; -enum PT_LOPROC = 0x70000000; -enum PT_HIPROC = 0x7fffffff; - -enum PT_GNU_EH_FRAME = PT_LOOS + 0x474e550; /* Frame unwind information */ -enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME; /* Solaris uses the same value */ -enum PT_GNU_STACK = PT_LOOS + 0x474e551; /* Stack flags */ -enum PT_GNU_RELRO = PT_LOOS + 0x474e552; /* Read-only after relocation */ - -enum PF_X = 0x1; -enum PF_W = 0x2; -enum PF_R = 0x4; -enum PF_MASKOS = 0x0ff00000; -enum PF_MASKPROC = 0xf0000000; - -enum PN_XNUM = 0xffff; - -enum SHT_NULL = 0; -enum SHT_PROGBITS = 1; -enum SHT_SYMTAB = 2; -enum SHT_STRTAB = 3; -enum SHT_RELA = 4; -enum SHT_HASH = 5; -enum SHT_DYNAMIC = 6; -enum SHT_NOTE = 7; -enum SHT_NOBITS = 8; -enum SHT_REL = 9; -enum SHT_SHLIB = 10; -enum SHT_DYNSYM = 11; - -enum SHT_INIT_ARRAY = 14; -enum SHT_FINI_ARRAY = 15; -enum SHT_PREINIT_ARRAY = 16; -enum SHT_GROUP = 17; -enum SHT_SYMTAB_SHNDX = 18; - -enum SHT_LOOS = 0x60000000; -enum SHT_LOSUNW = 0x6ffffff4; +enum PT_SUNW_EH_FRAME = PT_GNU_EH_FRAME; enum SHT_GNU_INCREMENTAL_INPUTS = 0x6fff4700; -enum SHT_GNU_ATTRIBUTES = 0x6ffffff5; -enum SHT_GNU_HASH = 0x6ffffff6; -enum SHT_GNU_LIBLIST = 0x6ffffff7; -//enum SHT_SUNW_dof = 0x6ffffff4; -//enum SHT_SUNW_cap = 0x6ffffff5; -//enum SHT_SUNW_SIGNATURE = 0x6ffffff6; enum SHT_SUNW_verdef = 0x6ffffffd; enum SHT_SUNW_verneed = 0x6ffffffe; enum SHT_SUNW_versym = 0x6fffffff; -enum SHT_GNU_verdef = SHT_SUNW_verdef; -enum SHT_GNU_verneed = SHT_SUNW_verneed; -enum SHT_GNU_versym = SHT_SUNW_versym; - -enum SHT_LOPROC = 0x70000000; -enum SHT_HIPROC = 0x7fffffff; -enum SHT_LOUSER = 0x80000000; -enum SHT_HIUSER = 0x8fffffff; - -/* -enum SHT_GNU_HASH = 0x6ffffff6; -enum SHT_SUNW_ANNOTATE = 0x6ffffff7; -enum SHT_SUNW_DEBUGSTR = 0x6ffffff8; -enum SHT_SUNW_DEBUG = 0x6ffffff9; -enum SHT_SUNW_move = 0x6ffffffa; -enum SHT_SUNW_COMDAT = 0x6ffffffb; -enum SHT_SUNW_syminfo = 0x6ffffffc; -enum SHT_HISUNW = 0x6fffffff; -enum SHT_HIOS = 0x6fffffff; -enum SHT_AMD64_UNWIND = 0x70000001; -enum SHT_ARM_EXIDX = 0x70000001; -enum SHT_ARM_PREEMPTMAP = 0x70000002; -enum SHT_ARM_ATTRIBUTES = 0x70000003; -enum SHT_ARM_DEBUGOVERLAY = 0x70000004; -enum SHT_ARM_OVERLAYSECTION = 0x70000005; -enum SHT_MIPS_REGINFO = 0x70000006; -enum SHT_MIPS_OPTIONS = 0x7000000d; -enum SHT_MIPS_DWARF = 0x7000001e; -*/ - -enum SHF_WRITE = (1 << 0); -enum SHF_ALLOC = (1 << 1); -enum SHF_EXECINSTR = (1 << 2); -enum SHF_MERGE = (1 << 4); -enum SHF_STRINGS = (1 << 5); -enum SHF_INFO_LINK = (1 << 6); -enum SHF_LINK_ORDER = (1 << 7); -enum SHF_OS_NONCONFORMING = (1 << 8); -enum SHF_GROUP = (1 << 9); -enum SHF_TLS = (1 << 10); -enum SHF_COMPRESSED = (1 << 11); - -enum SHF_MASKOS = 0x0ff00000; -enum SHF_MASKPROC = 0xf0000000; - enum NT_PRSTATUS = 1; enum NT_FPREGSET = 2; enum NT_PRPSINFO = 3; enum NT_TASKSTRUCT = 4; enum NT_AUXV = 6; -/* -enum NT_THRMISC = 7; -enum NT_PROCSTAT_PROC = 8; -enum NT_PROCSTAT_FILES = 9; -enum NT_PROCSTAT_VMMAP = 10; -enum NT_PROCSTAT_GROUPS = 11; -enum NT_PROCSTAT_UMASK = 12; -enum NT_PROCSTAT_RLIMIT = 13; -enum NT_PROCSTAT_OSREL = 14; -enum NT_PROCSTAT_PSSTRINGS = 15; -enum NT_PROCSTAT_AUXV = 16; -*/ - -enum STN_UNDEF = 0; - -enum STB_LOCAL = 0; -enum STB_GLOBAL = 1; -enum STB_WEAK = 2; -enum STB_NUM = 3; -enum STB_LOOS = 10; -enum STB_HIOS = 12; -enum STB_LOPROC = 13; -enum STB_HIPROC = 15; - -enum STT_NOTYPE = 0; -enum STT_OBJECT = 1; -enum STT_FUNC = 2; -enum STT_SECTION = 3; -enum STT_FILE = 4; -enum STT_COMMON = 5; -enum STT_TLS = 6; -enum STT_NUM = 7; -enum STT_LOOS = 10; -enum STT_GNU_IFUNC = 10; -enum STT_HIOS = 12; -enum STT_LOPROC = 13; -enum STT_HIPROC = 15; - -enum STV_DEFAULT = 0; -enum STV_INTERNAL = 1; -enum STV_HIDDEN = 2; -enum STV_PROTECTED = 3; -/* -enum STV_EXPORTED = 4; -enum STV_SINGLETON = 5; -enum STV_ELIMINATE = 6; -*/ - -enum DT_NULL = 0; -enum DT_NEEDED = 1; -enum DT_PLTRELSZ = 2; -enum DT_PLTGOT = 3; -enum DT_HASH = 4; -enum DT_STRTAB = 5; -enum DT_SYMTAB = 6; -enum DT_RELA = 7; -enum DT_RELASZ = 8; -enum DT_RELAENT = 9; -enum DT_STRSZ = 10; -enum DT_SYMENT = 11; -enum DT_INIT = 12; -enum DT_FINI = 13; -enum DT_SONAME = 14; -enum DT_RPATH = 15; -enum DT_SYMBOLIC = 16; -enum DT_REL = 17; -enum DT_RELSZ = 18; -enum DT_RELENT = 19; -enum DT_PLTREL = 20; -enum DT_DEBUG = 21; -enum DT_TEXTREL = 22; -enum DT_JMPREL = 23; -enum DT_BIND_NOW = 24; -enum DT_INIT_ARRAY = 25; -enum DT_FINI_ARRAY = 26; -enum DT_INIT_ARRAYSZ = 27; -enum DT_FINI_ARRAYSZ = 28; -enum DT_RUNPATH = 29; -enum DT_FLAGS = 30; - -enum DT_ENCODING = 32; -enum DT_PREINIT_ARRAY = 32; -enum DT_PREINIT_ARRAYSZ = 33; -//enum DT_MAXPOSTAGS = 34; -enum DT_LOOS = 0x6000000d; -enum DT_HIOS = 0x6ffff000; -/* -enum DT_SUNW_AUXILIARY = 0x6000000d; -enum DT_SUNW_RTLDINF = 0x6000000e; -enum DT_SUNW_FILTER = 0x6000000f; -enum DT_SUNW_CAP = 0x60000010; -*/ - -enum DT_VALRNGLO = 0x6ffffd00; -enum DT_GNU_PRELINKED = 0x6ffffdf5; -enum DT_GNU_CONFLICTSZ =0x6ffffdf6; -enum DT_GNU_LIBLISTSZ = 0x6ffffdf7; -enum DT_CHECKSUM = 0x6ffffdf8; -enum DT_PLTPADSZ = 0x6ffffdf9; -enum DT_MOVEENT = 0x6ffffdfa; -enum DT_MOVESZ = 0x6ffffdfb; -enum DT_FEATURE_1 = 0x6ffffdfc; -enum DT_POSFLAG_1 = 0x6ffffdfd; -enum DT_SYMINSZ = 0x6ffffdfe; -enum DT_SYMINENT = 0x6ffffdff; -enum DT_VALRNGHI = 0x6ffffdff; -enum DT_ADDRRNGLO = 0x6ffffe00; -enum DT_GNU_HASH = 0x6ffffef5; -enum DT_TLSDESC_PLT = 0x6ffffef6; -enum DT_TLSDESC_GOT = 0x6ffffef7; -enum DT_GNU_CONFLICT = 0x6ffffef8; -enum DT_GNU_LIBLIST = 0x6ffffef9; -enum DT_CONFIG = 0x6ffffefa; -enum DT_DEPAUDIT = 0x6ffffefb; -enum DT_AUDIT = 0x6ffffefc; -enum DT_PLTPAD = 0x6ffffefd; -enum DT_MOVETAB = 0x6ffffefe; -enum DT_SYMINFO = 0x6ffffeff; -enum DT_ADDRRNGHI = 0x6ffffeff; -enum DT_RELACOUNT = 0x6ffffff9; -enum DT_RELCOUNT = 0x6ffffffa; -enum DT_FLAGS_1 = 0x6ffffffb; -enum DT_VERDEF = 0x6ffffffc; -enum DT_VERDEFNUM = 0x6ffffffd; -enum DT_VERNEED = 0x6ffffffe; -enum DT_VERNEEDNUM = 0x6fffffff; -enum DT_VERSYM = 0x6ffffff0; -enum DT_LOPROC = 0x70000000; -//enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001; -enum DT_AUXILIARY = 0x7ffffffd; enum DT_USED = 0x7ffffffe; -enum DT_FILTER = 0x7fffffff; -enum DT_HIPROC = 0x7fffffff; - -enum DTF_1_PARINIT = 0x00000001; -enum DTF_1_CONFEXP = 0x00000002; - -enum DF_P1_LAZYLOAD = 0x00000001; -enum DF_P1_GROUPPERM= 0x00000002; -enum DF_1_NOW = 0x00000001; enum DF_1_BIND_NOW = 0x00000001; -enum DF_1_GLOBAL = 0x00000002; -enum DF_1_GROUP = 0x00000004; -enum DF_1_NODELETE = 0x00000008; -enum DF_1_LOADFLTR = 0x00000010; -enum DF_1_INITFIRST = 0x00000020; -enum DF_1_NOOPEN = 0x00000040; -enum DF_1_ORIGIN = 0x00000080; -enum DF_1_DIRECT = 0x00000100; -enum DF_1_TRANS = 0x00000200; -enum DF_1_INTERPOSE = 0x00000400; -enum DF_1_NODEFLIB = 0x00000800; -enum DF_1_NODUMP = 0x00001000; -enum DF_1_CONLFAT = 0x00002000; -enum DF_ORIGIN = 0x00000001; -enum DF_SYMBOLIC = 0x00000002; -enum DF_TEXTREL = 0x00000004; -enum DF_BIND_NOW = 0x00000008; -enum DF_STATIC_TLS = 0x00000010; - -enum VER_DEF_NONE = 0; -enum VER_DEF_CURRENT = 1; alias VER_NDX VER_DEF_IDX; -enum VER_FLG_BASE = 0x1; -enum VER_FLG_WEAK = 0x2; enum VER_FLG_INFO = 0x4; -enum VER_NDX_LOCAL = 0; -enum VER_NDX_GLOBAL = 1; enum VER_NDX_GIVEN = 2; enum VER_NDX_HIDDEN = 32768; + extern (D) pure @safe { auto VER_NDX(V)(V v) { return v & ~(1u << 15); } } -enum VER_NEED_NONE = 0; -enum VER_NEED_CURRENT = 1; enum VER_NEED_WEAK = 32768; enum VER_NEED_HIDDEN = VER_NDX_HIDDEN; alias VER_NDX VER_NEED_IDX; -/* -enum CA_SUNW_NULL = 0; -enum CA_SUNW_HW_1 = 1; -enum CA_SUNW_SF_1 = 2; -*/ - enum VERSYM_HIDDEN = 0x8000; enum VERSYM_VERSION = 0x7fff; enum ELF_VER_CHR = '@'; - -enum SYMINFO_BT_SELF = 0xffff; -enum SYMINFO_BT_PARENT = 0xfffe; -//enum SYMINFO_BT_NONE = 0xfffd; -//enum SYMINFO_BT_EXTERN = 0xfffc; -enum SYMINFO_BT_LOWRESERVE = 0xff00; - -enum SYMINFO_FLG_DIRECT = 0x0001; -enum SYMINFO_FLG_PASSTHRU = 0x0002; -enum SYMINFO_FLG_COPY = 0x0004; -enum SYMINFO_FLG_LAZYLOAD = 0x0008; -//enum SYMINFO_FLG_DIRECTBIND = 0x0010; -//enum SYMINFO_FLG_NOEXTDIRECT = 0x0020; -//enum SYMINFO_FLG_FILTER = 0x0002; -//enum SYMINFO_FLG_AUXILIARY = 0x0040; - -enum SYMINFO_NONE = 0; -enum SYMINFO_CURRENT = 1; -enum SYMINFO_NUM = 2; - -enum GRP_COMDAT = 0x1; - -enum R_386_NONE = 0; -enum R_386_32 = 1; -enum R_386_PC32 = 2; -enum R_386_GOT32 = 3; -enum R_386_PLT32 = 4; -enum R_386_COPY = 5; -enum R_386_GLOB_DAT = 6; -enum R_386_JMP_SLOT = 7; -enum R_386_RELATIVE = 8; -enum R_386_GOTOFF = 9; -enum R_386_GOTPC = 10; -enum R_386_TLS_TPOFF = 14; -enum R_386_TLS_IE = 15; -enum R_386_TLS_GOTIE = 16; -enum R_386_TLS_LE = 17; -enum R_386_TLS_GD = 18; -enum R_386_TLS_LDM = 19; -enum R_386_TLS_GD_32 = 24; -enum R_386_TLS_GD_PUSH = 25; -enum R_386_TLS_GD_CALL = 26; -enum R_386_TLS_GD_POP = 27; -enum R_386_TLS_LDM_32 = 28; -enum R_386_TLS_LDM_PUSH = 29; -enum R_386_TLS_LDM_CALL = 30; -enum R_386_TLS_LDM_POP = 31; -enum R_386_TLS_LDO_32 = 32; -enum R_386_TLS_IE_32 = 33; -enum R_386_TLS_LE_32 = 34; -enum R_386_TLS_DTPMOD32 = 35; -enum R_386_TLS_DTPOFF32 = 36; -enum R_386_TLS_TPOFF32 = 37; -enum R_386_IRELATIVE = 42; - -enum R_X86_64_NONE = 0; -enum R_X86_64_64 = 1; -enum R_X86_64_PC32 = 2; -enum R_X86_64_GOT32 = 3; -enum R_X86_64_PLT32 = 4; -enum R_X86_64_COPY = 5; -enum R_X86_64_GLOB_DAT = 6; -enum R_X86_64_JMP_SLOT = 7; -enum R_X86_64_RELATIVE = 8; -enum R_X86_64_GOTPCREL = 9; -enum R_X86_64_32 = 10; -enum R_X86_64_32S = 11; -enum R_X86_64_16 = 12; -enum R_X86_64_PC16 = 13; -enum R_X86_64_8 = 14; -enum R_X86_64_PC8 = 15; -enum R_X86_64_DTPMOD64 = 16; -enum R_X86_64_DTPOFF64 = 17; -enum R_X86_64_TPOFF64 = 18; -enum R_X86_64_TLSGD = 19; -enum R_X86_64_TLSLD = 20; -enum R_X86_64_DTPOFF32 = 21; -enum R_X86_64_GOTTPOFF = 22; -enum R_X86_64_TPOFF32 = 23; -enum R_X86_64_IRELATIVE = 37; diff --git a/libphobos/libdruntime/core/sys/posix/aio.d b/libphobos/libdruntime/core/sys/posix/aio.d index f4e0f12..a76846e 100644 --- a/libphobos/libdruntime/core/sys/posix/aio.d +++ b/libphobos/libdruntime/core/sys/posix/aio.d @@ -99,57 +99,7 @@ else version (CRuntime_Musl) } else version (CRuntime_UClibc) { - import core.sys.posix.config; - import core.sys.posix.sys.types; - - struct aiocb - { - int aio_fildes; - int aio_lio_opcode; - int aio_reqprio; - void* aio_buf; //volatile - size_t aio_nbytes; - sigevent aio_sigevent; - - aiocb* __next_prio; - int __abs_prio; - int __policy; - int __error_code; - ssize_t __return_value; - - static if (__USE_LARGEFILE64) - { - off_t aio_offset; - ubyte[off64_t.sizeof - off_t.sizeof] __pad; - } - else - { - off64_t aio_offset; - } - ubyte[32] __unused; - } - - static if (__USE_LARGEFILE64) - { - struct aiocb64 - { - int aio_fildes; - int aio_lio_opcode; - int aio_reqprio; - void* aio_buf; //volatile - size_t aio_nbytes; - sigevent aio_sigevent; - - aiocb* __next_prio; - int __abs_prio; - int __policy; - int __error_code; - ssize_t __return_value; - - off64_t aio_offset; - ubyte[32] __unused; - } - } + // UClibc does not implement aiocb. } else version (Darwin) { @@ -272,15 +222,6 @@ else version (CRuntime_Musl) AIO_ALLDONE } } -else version (CRuntime_UClibc) -{ - enum - { - AIO_CANCELED, - AIO_NOTCANCELED, - AIO_ALLDONE - } -} else version (Darwin) { enum @@ -328,15 +269,6 @@ else version (CRuntime_Musl) LIO_NOP } } -else version (CRuntime_UClibc) -{ - enum - { - LIO_READ, - LIO_WRITE, - LIO_NOP - } -} else version (Darwin) { enum @@ -382,14 +314,6 @@ else version (CRuntime_Musl) LIO_NOWAIT } } -else version (CRuntime_UClibc) -{ - enum - { - LIO_WAIT, - LIO_NOWAIT - } -} else version (Darwin) { enum @@ -456,37 +380,7 @@ else version (CRuntime_Bionic) } else version (CRuntime_UClibc) { - static if (__USE_LARGEFILE64) - { - int aio_read64(aiocb64* aiocbp); - int aio_write64(aiocb64* aiocbp); - int aio_fsync64(int op, aiocb64* aiocbp); - int aio_error64(const(aiocb64)* aiocbp); - ssize_t aio_return64(aiocb64* aiocbp); - int aio_suspend64(const(aiocb64*)* aiocb_list, int nitems, const(timespec)* timeout); - int aio_cancel64(int fd, aiocb64* aiocbp); - int lio_listio64(int mode, const(aiocb64*)* aiocb_list, int nitems, sigevent* sevp); - - alias aio_read = aio_read64; - alias aio_write = aio_write64; - alias aio_fsync = aio_fsync64; - alias aio_error = aio_error64; - alias aio_return = aio_return64; - alias aio_suspend = aio_suspend64; - alias aio_cancel = aio_cancel64; - alias lio_listio = lio_listio64; - } - else - { - int aio_read(aiocb* aiocbp); - int aio_write(aiocb* aiocbp); - int aio_fsync(int op, aiocb* aiocbp); - int aio_error(const(aiocb)* aiocbp); - ssize_t aio_return(aiocb* aiocbp); - int aio_suspend(const(aiocb*)* aiocb_list, int nitems, const(timespec)* timeout); - int aio_cancel(int fd, aiocb* aiocbp); - int lio_listio(int mode, const(aiocb*)* aiocb_list, int nitems, sigevent* sevp); - } + // UClibc does not implement aio.h } else version (OpenBSD) { @@ -507,27 +401,7 @@ else /* Functions outside/extending POSIX requirement. */ version (CRuntime_Glibc) { - static if (__USE_GNU) - { - /* To customize the implementation one can use the following struct. */ - struct aioinit - { - int aio_threads; - int aio_num; - int aio_locks; - int aio_usedba; - int aio_debug; - int aio_numusers; - int aio_idle_time; - int aio_reserved; - } - - void aio_init(const(aioinit)* init); - } -} -else version (CRuntime_UClibc) -{ - static if (__USE_GNU) + static if (_GNU_SOURCE) { /* To customize the implementation one can use the following struct. */ struct aioinit diff --git a/libphobos/libdruntime/core/sys/posix/config.d b/libphobos/libdruntime/core/sys/posix/config.d index 3b575fa..7bd0722 100644 --- a/libphobos/libdruntime/core/sys/posix/config.d +++ b/libphobos/libdruntime/core/sys/posix/config.d @@ -51,14 +51,24 @@ version (CRuntime_Glibc) enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; - enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; - enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; - enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; - enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; + deprecated("use _XOPEN_SOURCE >= 600") + { + enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; + enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; + } + deprecated("use _XOPEN_SOURCE >= 700") + { + enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; + enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; + } + deprecated("use _DEFAULT_SOURCE") enum __USE_MISC = _DEFAULT_SOURCE; + deprecated("use _ATFILE_SOURCE") enum __USE_ATFILE = _ATFILE_SOURCE; + deprecated("use _GNU_SOURCE") enum __USE_GNU = _GNU_SOURCE; + deprecated("use _REENTRANT") enum __USE_REENTRANT = _REENTRANT; version (D_LP64) @@ -68,6 +78,10 @@ version (CRuntime_Glibc) } else version (CRuntime_Musl) { + enum _GNU_SOURCE = false; + enum _DEFAULT_SOURCE = false; + enum _ATFILE_SOURCE = false; + // off_t is always 64 bits on Musl enum _FILE_OFFSET_BITS = 64; @@ -99,14 +113,24 @@ else version (CRuntime_UClibc) enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; - enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; - enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; - enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; - enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; + deprecated("use _XOPEN_SOURCE >= 600") + { + enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; + enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; + } + deprecated("use _XOPEN_SOURCE >= 700") + { + enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; + enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; + } + deprecated("use _DEFAULT_SOURCE") enum __USE_MISC = _DEFAULT_SOURCE; + deprecated("use _ATFILE_SOURCE") enum __USE_ATFILE = _ATFILE_SOURCE; + deprecated("use _GNU_SOURCE") enum __USE_GNU = _GNU_SOURCE; + deprecated("use _REENTRANT") enum __USE_REENTRANT = _REENTRANT; version (D_LP64) @@ -117,7 +141,11 @@ else version (CRuntime_UClibc) else version (CRuntime_Bionic) { enum _GNU_SOURCE = false; + enum _DEFAULT_SOURCE = false; + enum _ATFILE_SOURCE = false; + enum __USE_FILE_OFFSET64 = false; // see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md + deprecated("use _GNU_SOURCE") enum __USE_GNU = _GNU_SOURCE; version (D_LP64) @@ -187,10 +215,16 @@ else version (Solaris) enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; - enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; - enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; - enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; - enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; + deprecated("use _XOPEN_SOURCE >= 600") + { + enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; + enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; + } + deprecated("use _XOPEN_SOURCE >= 700") + { + enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; + enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; + } version (D_LP64) enum __WORDSIZE = 64; diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d index 3c196d2..dc0a183 100644 --- a/libphobos/libdruntime/core/sys/posix/fcntl.d +++ b/libphobos/libdruntime/core/sys/posix/fcntl.d @@ -123,6 +123,12 @@ version (linux) enum F_SETLK = 6; enum F_SETLKW = 7; } + else version (RISCV64) + { + enum F_GETLK = 5; + enum F_SETLK = 6; + enum F_SETLKW = 7; + } else version (SystemZ) { static assert(off_t.sizeof == 8); diff --git a/libphobos/libdruntime/core/sys/posix/locale.d b/libphobos/libdruntime/core/sys/posix/locale.d index 18558a2..85e2fb6 100644 --- a/libphobos/libdruntime/core/sys/posix/locale.d +++ b/libphobos/libdruntime/core/sys/posix/locale.d @@ -31,7 +31,7 @@ version (FreeBSD) version = DarwinBSDLocale; version (NetBSD) version = DarwinBSDLocale; -version (DragonflyBSD) +version (DragonFlyBSD) version = DarwinBSDLocale; version (CRuntime_Glibc) diff --git a/libphobos/libdruntime/core/sys/posix/spawn.d b/libphobos/libdruntime/core/sys/posix/spawn.d index 86b1751..cfa3a40 100644 --- a/libphobos/libdruntime/core/sys/posix/spawn.d +++ b/libphobos/libdruntime/core/sys/posix/spawn.d @@ -100,8 +100,8 @@ version (linux) POSIX_SPAWN_SETSCHEDPARAM = 0x10, POSIX_SPAWN_SETSCHEDULER = 0x20 } - import core.sys.posix.config : __USE_GNU; - static if (__USE_GNU) + import core.sys.posix.config : _GNU_SOURCE; + static if (_GNU_SOURCE) { enum { @@ -140,8 +140,8 @@ version (linux) POSIX_SPAWN_SETSCHEDPARAM = 16, POSIX_SPAWN_SETSCHEDULER = 32 } - import core.sys.posix.config : __USE_GNU; - static if (__USE_GNU) + import core.sys.posix.config : _GNU_SOURCE; + static if (_GNU_SOURCE) { enum { @@ -196,8 +196,8 @@ version (linux) POSIX_SPAWN_SETSCHEDPARAM = 0x10, POSIX_SPAWN_SETSCHEDULER = 0x20 } - import core.sys.posix.config : __USE_GNU; - static if (__USE_GNU) + import core.sys.posix.config : _GNU_SOURCE; + static if (_GNU_SOURCE) { enum { diff --git a/libphobos/libdruntime/core/sys/posix/sys/ipc.d b/libphobos/libdruntime/core/sys/posix/sys/ipc.d index 18a6cbd..1718243 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/ipc.d +++ b/libphobos/libdruntime/core/sys/posix/sys/ipc.d @@ -83,7 +83,26 @@ version (linux) } else version (Darwin) { + align(4) struct ipc_perm + { + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; + ushort _seq; + key_t _key; + } + + enum IPC_CREAT = 0x0200; // 01000 + enum IPC_EXCL = 0x0400; // 02000 + enum IPC_NOWAIT = 0x0800; // 04000 + + enum key_t IPC_PRIVATE = 0; + enum IPC_RMID = 0; + enum IPC_SET = 1; + enum IPC_STAT = 2; } else version (FreeBSD) { @@ -188,6 +207,46 @@ else version (DragonFlyBSD) enum IPC_SET = 1; enum IPC_STAT = 2; } +else version (Solaris) +{ + version (D_LP64) + { + struct ipc_perm + { + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; + uint seq; + key_t key; + } + } + else + { + struct ipc_perm + { + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; + uint seq; + key_t key; + int[4] pad; + } + } + + enum IPC_CREAT = 0x200; + enum IPC_EXCL = 0x400; + enum IPC_NOWAIT = 0x800; + + enum key_t IPC_PRIVATE = 0; + + enum IPC_RMID = 10; + enum IPC_SET = 11; + enum IPC_STAT = 12; +} else { static assert(false, "Unsupported platform"); @@ -203,7 +262,7 @@ version (CRuntime_Glibc) } else version (Darwin) { - + key_t ftok(const scope char*, int); } else version (FreeBSD) { @@ -221,6 +280,10 @@ else version (DragonFlyBSD) { key_t ftok(const scope char*, int); } +else version (Solaris) +{ + key_t ftok(const scope char*, int); +} else version (CRuntime_Bionic) { key_t ftok(const scope char*, int); diff --git a/libphobos/libdruntime/core/sys/posix/sys/mman.d b/libphobos/libdruntime/core/sys/posix/sys/mman.d index 33ce88f..430f215 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/mman.d +++ b/libphobos/libdruntime/core/sys/posix/sys/mman.d @@ -56,7 +56,7 @@ int posix_madvise(void*, size_t, int); version (CRuntime_Glibc) { - static if (__USE_XOPEN2K) + static if (_XOPEN_SOURCE >= 600) { int posix_madvise(void *__addr, size_t __len, int __advice); } @@ -303,7 +303,7 @@ else version (CRuntime_Musl) } else version (CRuntime_UClibc) { - static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off64_t); + static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off_t); static if (__USE_FILE_OFFSET64) alias mmap = mmap64; else diff --git a/libphobos/libdruntime/core/sys/posix/sys/shm.d b/libphobos/libdruntime/core/sys/posix/sys/shm.d index ce34141..d04e792 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/shm.d +++ b/libphobos/libdruntime/core/sys/posix/sys/shm.d @@ -259,6 +259,18 @@ else version (CRuntime_Musl) int shmdt(const scope void*); int shmget(key_t, size_t, int); } +else version (CRuntime_Bionic) +{ + enum SHMLBA = 4096; + + deprecated("Not useful on Android because it's disallowed by SELinux") + { + void* shmat(int, const scope void*, int); + int shmctl(int, int, shmid_ds*); + int shmdt(const scope void*); + int shmget(key_t, size_t, int); + } +} else version (CRuntime_UClibc) { int __getpagesize(); diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d index 670ead7..3a7b753 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/socket.d +++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d @@ -589,9 +589,24 @@ else version (Darwin) struct cmsghdr { - socklen_t cmsg_len; - int cmsg_level; - int cmsg_type; + socklen_t cmsg_len; + int cmsg_level; + int cmsg_type; + } + + + extern (D) + { + socklen_t CMSG_ALIGN(socklen_t len) pure nothrow @nogc { return (len + socklen_t.sizeof - 1) & cast(socklen_t) (~(socklen_t.sizeof - 1)); } + socklen_t CMSG_SPACE(socklen_t len) pure nothrow @nogc { return CMSG_ALIGN(len) + CMSG_ALIGN(cmsghdr.sizeof); } + socklen_t CMSG_LEN(socklen_t len) pure nothrow @nogc { return CMSG_ALIGN(cmsghdr.sizeof) + len; } + + inout(ubyte)* CMSG_DATA( return scope inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); } + + inout(cmsghdr)* CMSG_FIRSTHDR( inout(msghdr)* mhdr ) pure nothrow @nogc + { + return ( cast(socklen_t)mhdr.msg_controllen >= cmsghdr.sizeof ? cast(inout(cmsghdr)*) mhdr.msg_control : cast(inout(cmsghdr)*) null ); + } } enum : uint @@ -599,18 +614,6 @@ else version (Darwin) SCM_RIGHTS = 0x01 } - /+ - CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ - ALIGN(sizeof(struct cmsghdr))) - CMSG_NXTHDR(mhdr, cmsg) \ - (((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len) + \ - ALIGN(sizeof(struct cmsghdr)) > \ - (unsigned char *)(mhdr)->msg_control +(mhdr)->msg_controllen) ? \ - (struct cmsghdr *)0 /* NULL */ : \ - (struct cmsghdr *)((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len))) - CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) - +/ - struct linger { int l_onoff; @@ -1038,9 +1041,9 @@ else version (OpenBSD) { ubyte ss_len; sa_family_t ss_family; - byte[6] __ss_pad1; + ubyte[6] __ss_pad1; long __ss_align; - byte[240] __ss_pad2; + ubyte[240] __ss_pad2; } struct msghdr @@ -1063,20 +1066,25 @@ else version (OpenBSD) enum : uint { - SCM_RIGHTS = 0x01 + SCM_RIGHTS = 0x01, + SCM_TIMESTAMP = 0x04 } private // <sys/_types.h> { - extern (D) size_t _ALIGN(size_t p) { return (p + _ALIGNBYTES) & ~_ALIGNBYTES; } + enum _ALIGNBYTES = c_long.sizeof - 1; + extern (D) size_t _ALIGN(size_t p) pure nothrow @nogc + { + return (p + _ALIGNBYTES) & ~_ALIGNBYTES; + } } - extern (D) ubyte* CMSG_DATA(cmsghdr* cmsg) + extern (D) ubyte* CMSG_DATA(cmsghdr* cmsg) pure nothrow @nogc { return cast(ubyte*) cmsg + _ALIGN(cmsghdr.sizeof); } - extern (D) cmsghdr* CMSG_NXTHDR(msghdr* mhdr, cmsghdr* cmsg) + extern (D) cmsghdr* CMSG_NXTHDR(msghdr* mhdr, cmsghdr* cmsg) pure nothrow @nogc { if (cast(ubyte*) cmsg + _ALIGN(cmsg.cmsg_len) + _ALIGN(cmsghdr.sizeof) > cast(ubyte*) mhdr.msg_control + mhdr.msg_controllen) @@ -1085,11 +1093,24 @@ else version (OpenBSD) return cast(cmsghdr*) (cast(ubyte*) cmsg + _ALIGN(cmsg.cmsg_len)); } - extern (D) cmsghdr* CMSG_FIRSTHDR(msghdr* mhdr) + extern (D) cmsghdr* CMSG_FIRSTHDR(msghdr* mhdr) pure nothrow @nogc { return mhdr.msg_controllen >= cmsghdr.sizeof ? cast(cmsghdr*) mhdr.msg_control : null; } + extern (D) + { + size_t CMSG_LEN(size_t len) pure nothrow @nogc + { + return _ALIGN(cmsghdr.sizeof) + len; + } + } + + extern (D) size_t CMSG_SPACE(size_t len) pure nothrow @nogc + { + return _ALIGN(cmsghdr.sizeof) + _ALIGN(len); + } + struct linger { int l_onoff; diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d index 51455a9..1fb4e44 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/stat.d +++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d @@ -89,7 +89,7 @@ version (linux) off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; - static if (__USE_MISC || __USE_XOPEN2K8) + static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) { timespec st_atim; timespec st_mtim; @@ -136,7 +136,7 @@ version (linux) off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; - static if (__USE_MISC || __USE_XOPEN2K8) + static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) { timespec st_atim; timespec st_mtim; @@ -218,7 +218,7 @@ version (linux) __blkcnt64_t st_blocks; } - static if ( __USE_MISC || __USE_XOPEN2K8) + static if ( _DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) { __timespec st_atim; __timespec st_mtim; @@ -278,7 +278,7 @@ version (linux) c_long[3] st_pad2; off_t st_size; } - static if (__USE_MISC || __USE_XOPEN2K8) + static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) { timespec st_atim; timespec st_mtim; @@ -339,7 +339,7 @@ version (linux) uint[3] st_pad2; off_t st_size; } - static if (__USE_MISC || __USE_XOPEN2K8) + static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) { timespec st_atim; timespec st_mtim; @@ -388,50 +388,93 @@ version (linux) { struct stat_t { - c_ulong st_dev; - ino_t st_ino; + dev_t st_dev; + static if (!__USE_FILE_OFFSET64) + { + ushort __pad1; + ino_t st_ino; + } + else + ino_t st_ino; mode_t st_mode; nlink_t st_nlink; uid_t st_uid; gid_t st_gid; - c_ulong st_rdev; + dev_t st_rdev; + ushort __pad2; off_t st_size; - c_ulong st_blksize; - c_ulong st_blocks; - c_ulong st_atime; - c_ulong st_atime_nsec; - c_ulong st_mtime; - c_ulong st_mtime_nsec; - c_ulong st_ctime; - c_ulong st_ctime_nsec; + blksize_t st_blksize; + blkcnt_t st_blocks; + static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) + { + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } + } + else + { + time_t st_atime; + c_ulong st_atimensec; + time_t st_mtime; + c_ulong st_mtimensec; + time_t st_ctime; + c_ulong st_ctimensec; + } c_ulong __unused4; c_ulong __unused5; } + static if (__USE_FILE_OFFSET64) + static assert(stat_t.sizeof == 104); + else + static assert(stat_t.sizeof == 88); } else version (PPC64) { struct stat_t { - c_ulong st_dev; + dev_t st_dev; ino_t st_ino; nlink_t st_nlink; mode_t st_mode; uid_t st_uid; gid_t st_gid; - c_ulong st_rdev; + int __pad2; + dev_t st_rdev; off_t st_size; - c_ulong st_blksize; - c_ulong st_blocks; - c_ulong st_atime; - c_ulong st_atime_nsec; - c_ulong st_mtime; - c_ulong st_mtime_nsec; - c_ulong st_ctime; - c_ulong st_ctime_nsec; + blksize_t st_blksize; + blkcnt_t st_blocks; + static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) + { + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } + } + else + { + time_t st_atime; + c_ulong st_atimensec; + time_t st_mtime; + c_ulong st_mtimensec; + time_t st_ctime; + c_ulong st_ctimensec; + } c_ulong __unused4; c_ulong __unused5; c_ulong __unused6; } + static assert(stat_t.sizeof == 144); } else version (RISCV_Any) { @@ -491,7 +534,7 @@ version (linux) __blkcnt_t st_blocks; } - static if (__USE_MISC) + static if (_DEFAULT_SOURCE) { __timespec st_atim; __timespec st_mtim; @@ -573,7 +616,7 @@ version (linux) __blkcnt64_t st_blocks; } - static if ( __USE_MISC || __USE_XOPEN2K8) + static if ( _DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) { __timespec st_atim; __timespec st_mtim; @@ -668,7 +711,7 @@ version (linux) __blkcnt64_t st_blocks; } - static if (__USE_MISC) + static if (_DEFAULT_SOURCE) { __timespec st_atim; __timespec st_mtim; @@ -753,7 +796,7 @@ version (linux) __blkcnt64_t st_blocks; } - static if (__USE_XOPEN2K8) + static if (_XOPEN_SOURCE >= 700) { __timespec st_atim; __timespec st_mtim; @@ -830,7 +873,7 @@ version (linux) __blkcnt_t st_blocks; else __blkcnt64_t st_blocks; - static if (__USE_XOPEN2K8) + static if (_XOPEN_SOURCE >= 700) { __timespec st_atim; __timespec st_mtim; @@ -894,7 +937,7 @@ version (linux) int __glibc_reserved0; __dev_t st_rdev; __off_t st_size; - static if (__USE_XOPEN2K8) + static if (_XOPEN_SOURCE >= 700) { __timespec st_atim; __timespec st_mtim; @@ -919,7 +962,7 @@ version (linux) __blkcnt_t st_blocks; c_long[3] __glibc_reserved; } - static if (__USE_XOPEN2K8) + static if (_XOPEN_SOURCE >= 700) static assert(stat_t.sizeof == 144); else static assert(stat_t.sizeof == 144); diff --git a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d index 49c8450..df9030d 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d +++ b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d @@ -44,7 +44,7 @@ version (CRuntime_Glibc) { } /* Definitions for the flag in `f_flag'. These definitions should be kept in sync with the definitions in <sys/mount.h>. */ - static if (__USE_GNU) + static if (_GNU_SOURCE) { enum FFlag { diff --git a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d index 02cf799..ec229dd 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/types.d +++ b/libphobos/libdruntime/core/sys/posix/sys/types.d @@ -322,7 +322,7 @@ else version (Darwin) alias uint fsfilcnt_t; alias c_long clock_t; alias uint id_t; - // key_t + alias int key_t; alias int suseconds_t; alias uint useconds_t; } diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elf.d b/libphobos/libdruntime/core/sys/solaris/sys/elf.d index 7a46d52..687e7f7 100644 --- a/libphobos/libdruntime/core/sys/solaris/sys/elf.d +++ b/libphobos/libdruntime/core/sys/solaris/sys/elf.d @@ -9,7 +9,7 @@ version (Solaris): extern (C): nothrow: -public import core.sys.solaris.sys.elftypes; +public import core.sys.elf; enum ELF32_FSZ_ADDR = 4; enum ELF32_FSZ_HALF = 2; @@ -25,333 +25,24 @@ enum ELF64_FSZ_WORD = 4; enum ELF64_FSZ_SXWORD = 8; enum ELF64_FSZ_XWORD = 8; -enum EI_NIDENT = 16; - -struct Elf32_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf32_Half e_type; - Elf32_Half e_machine; - Elf32_Word e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - Elf32_Word e_flags; - Elf32_Half e_ehsize; - Elf32_Half e_phentsize; - Elf32_Half e_phnum; - Elf32_Half e_shentsize; - Elf32_Half e_shnum; - Elf32_Half e_shstrndx; -} - -struct Elf64_Ehdr -{ - char[EI_NIDENT] e_ident = 0; - Elf64_Half e_type; - Elf64_Half e_machine; - Elf64_Word e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Word e_flags; - Elf64_Half e_ehsize; - Elf64_Half e_phentsize; - Elf64_Half e_phnum; - Elf64_Half e_shentsize; - Elf64_Half e_shnum; - Elf64_Half e_shstrndx; -} - -enum EI_MAG0 = 0; -enum EI_MAG1 = 1; -enum EI_MAG2 = 2; -enum EI_MAG3 = 3; -enum EI_CLASS = 4; -enum EI_DATA = 5; -enum EI_VERSION = 6; -enum EI_OSABI = 7; -enum EI_ABIVERSION = 8; -enum EI_PAD = 9; - -enum ELFMAG0 = 0x7f; -enum ELFMAG1 = 'E'; -enum ELFMAG2 = 'L'; -enum ELFMAG3 = 'F'; -enum ELFMAG = "\177ELF"; -enum SELFMAG = 4; - -enum ELFCLASSNONE = 0; -enum ELFCLASS32 = 1; -enum ELFCLASS64 = 2; -enum ELFCLASSNUM = 3; - -enum ELFDATANONE = 0; -enum ELFDATA2LSB = 1; -enum ELFDATA2MSB = 2; -enum ELFDATANUM = 3; - -enum ET_NONE = 0; -enum ET_REL = 1; -enum ET_EXEC = 2; -enum ET_DYN = 3; -enum ET_CORE = 4; -enum ET_NUM = 5; -enum ET_LOOS = 0xfe00; enum ET_LOSUNW = 0xfeff; enum ET_SUNWPSEUDO = 0xfeff; enum ET_HISUNW = 0xfeff; -enum ET_HIOS = 0xfeff; -enum ET_LOPROC = 0xff00; -enum ET_HIPROC = 0xffff; - -enum EM_NONE = 0; -enum EM_M32 = 1; -enum EM_SPARC = 2; -enum EM_386 = 3; -enum EM_68K = 4; -enum EM_88K = 5; -enum EM_486 = 6; -enum EM_860 = 7; -enum EM_MIPS = 8; -enum EM_S370 = 9; -enum EM_MIPS_RS3_LE = 10; -enum EM_RS6000 = 11; -enum EM_UNKNOWN12 = 12; -enum EM_UNKNOWN13 = 13; -enum EM_UNKNOWN14 = 14; -enum EM_PA_RISC = 15; -enum EM_PARISC = EM_PA_RISC; -enum EM_nCUBE = 16; -enum EM_VPP500 = 17; -enum EM_SPARC32PLUS = 18; -enum EM_960 = 19; -enum EM_PPC = 20; -enum EM_PPC64 = 21; -enum EM_S390 = 22; -enum EM_UNKNOWN22 = EM_S390; -enum EM_UNKNOWN23 = 23; -enum EM_UNKNOWN24 = 24; -enum EM_UNKNOWN25 = 25; -enum EM_UNKNOWN26 = 26; -enum EM_UNKNOWN27 = 27; -enum EM_UNKNOWN28 = 28; -enum EM_UNKNOWN29 = 29; -enum EM_UNKNOWN30 = 30; -enum EM_UNKNOWN31 = 31; -enum EM_UNKNOWN32 = 32; -enum EM_UNKNOWN33 = 33; -enum EM_UNKNOWN34 = 34; -enum EM_UNKNOWN35 = 35; -enum EM_V800 = 36; -enum EM_FR20 = 37; -enum EM_RH32 = 38; -enum EM_RCE = 39; -enum EM_ARM = 40; -enum EM_ALPHA = 41; -enum EM_SH = 42; -enum EM_SPARCV9 = 43; -enum EM_TRICORE = 44; -enum EM_ARC = 45; -enum EM_H8_300 = 46; -enum EM_H8_300H = 47; -enum EM_H8S = 48; -enum EM_H8_500 = 49; -enum EM_IA_64 = 50; -enum EM_MIPS_X = 51; -enum EM_COLDFIRE = 52; -enum EM_68HC12 = 53; -enum EM_MMA = 54; -enum EM_PCP = 55; -enum EM_NCPU = 56; -enum EM_NDR1 = 57; -enum EM_STARCORE = 58; -enum EM_ME16 = 59; -enum EM_ST100 = 60; -enum EM_TINYJ = 61; -enum EM_AMD64 = 62; -enum EM_X86_64 = EM_AMD64; -enum EM_PDSP = 63; -enum EM_UNKNOWN64 = 64; -enum EM_UNKNOWN65 = 65; -enum EM_FX66 = 66; -enum EM_ST9PLUS = 67; -enum EM_ST7 = 68; -enum EM_68HC16 = 69; -enum EM_68HC11 = 70; -enum EM_68HC08 = 71; -enum EM_68HC05 = 72; -enum EM_SVX = 73; -enum EM_ST19 = 74; -enum EM_VAX = 75; -enum EM_CRIS = 76; -enum EM_JAVELIN = 77; -enum EM_FIREPATH = 78; -enum EM_ZSP = 79; -enum EM_MMIX = 80; -enum EM_HUANY = 81; -enum EM_PRISM = 82; -enum EM_AVR = 83; -enum EM_FR30 = 84; -enum EM_D10V = 85; -enum EM_D30V = 86; -enum EM_V850 = 87; -enum EM_M32R = 88; -enum EM_MN10300 = 89; -enum EM_MN10200 = 90; -enum EM_PJ = 91; -enum EM_OPENRISC = 92; -enum EM_ARC_A5 = 93; -enum EM_XTENSA = 94; -enum EM_NUM = 95; - -enum EV_NONE = 0; -enum EV_CURRENT = 1; -enum EV_NUM = 2; - - -enum ELFOSABI_NONE = 0; -enum ELFOSABI_SYSV = ELFOSABI_NONE; -enum ELFOSABI_HPUX = 1; -enum ELFOSABI_NETBSD = 2; -enum ELFOSABI_LINUX = 3; -enum ELFOSABI_UNKNOWN4 = 4; -enum ELFOSABI_UNKNOWN5 = 5; -enum ELFOSABI_SOLARIS = 6; -enum ELFOSABI_AIX = 7; -enum ELFOSABI_IRIX = 8; -enum ELFOSABI_FREEBSD = 9; -enum ELFOSABI_TRU64 = 10; -enum ELFOSABI_MODESTO = 11; -enum ELFOSABI_OPENBSD = 12; -enum ELFOSABI_OPENVMS = 13; -enum ELFOSABI_NSK = 14; -enum ELFOSABI_AROS = 15; -enum ELFOSABI_ARM = 97; -enum ELFOSABI_STANDALONE = 255; -enum ELFOSABI_DRAGONFLYBSD= ELFOSABI_NONE; enum EAV_SUNW_NONE = 0; enum EAV_SUNW_CURRENT = 1; enum EAV_SUNW_NUM = 2; -struct Elf32_Phdr -{ - Elf32_Word p_type; - Elf32_Off p_offset; - Elf32_Addr p_vaddr; - Elf32_Addr p_paddr; - Elf32_Word p_filesz; - Elf32_Word p_memsz; - Elf32_Word p_flags; - Elf32_Word p_align; -} - -struct Elf64_Phdr -{ - Elf64_Word p_type; - Elf64_Word p_flags; - Elf64_Off p_offset; - Elf64_Addr p_vaddr; - Elf64_Addr p_paddr; - Elf64_Xword p_filesz; - Elf64_Xword p_memsz; - Elf64_Xword p_align; -} - -enum PT_NULL = 0; -enum PT_LOAD = 1; -enum PT_DYNAMIC = 2; -enum PT_INTERP = 3; -enum PT_NOTE = 4; -enum PT_SHLIB = 5; -enum PT_PHDR = 6; -enum PT_TLS = 7; -enum PT_NUM = 8; - -enum PT_LOOS = 0x60000000; - enum PT_SUNW_UNWIND = 0x6464e550; enum PT_SUNW_EH_FRAME = 0x6474e550; -enum PT_GNU_EH_FRAME = PT_SUNW_EH_FRAME; -enum PT_GNU_STACK = 0x6474e551; -enum PT_GNU_RELRO = 0x6474e552; - -enum PT_LOSUNW = 0x6ffffffa; -enum PT_SUNWBSS = 0x6ffffffa; -enum PT_SUNWSTACK = 0x6ffffffb; enum PT_SUNWDTRACE = 0x6ffffffc; enum PT_SUNWCAP = 0x6ffffffd; -enum PT_HISUNW = 0x6fffffff; -enum PT_HIOS = 0x6fffffff; -enum PT_LOPROC = 0x70000000; -enum PT_HIPROC = 0x7fffffff; - -enum PF_R = 0x4; -enum PF_W = 0x2; -enum PF_X = 0x1; - -enum PF_MASKOS = 0x0ff00000; -enum PF_MASKPROC = 0xf0000000; enum PF_SUNW_FAILURE = 0x00100000; enum PF_SUNW_KILLED = 0x00200000; enum PF_SUNW_SIGINFO = 0x00400000; -enum PN_XNUM = 0xffff; - -struct Elf32_Shdr -{ - Elf32_Word sh_name; - Elf32_Word sh_type; - Elf32_Word sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - Elf32_Word sh_size; - Elf32_Word sh_link; - Elf32_Word sh_info; - Elf32_Word sh_addralign; - Elf32_Word sh_entsize; -} - -struct Elf64_Shdr -{ - Elf64_Word sh_name; - Elf64_Word sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Word sh_link; - Elf64_Word sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -} - -enum SHT_NULL = 0; -enum SHT_PROGBITS = 1; -enum SHT_SYMTAB = 2; -enum SHT_STRTAB = 3; -enum SHT_RELA = 4; -enum SHT_HASH = 5; -enum SHT_DYNAMIC = 6; -enum SHT_NOTE = 7; -enum SHT_NOBITS = 8; -enum SHT_REL = 9; -enum SHT_SHLIB = 10; -enum SHT_DYNSYM = 11; -enum SHT_UNKNOWN12 = 12; -enum SHT_UNKNOWN13 = 13; -enum SHT_INIT_ARRAY = 14; -enum SHT_FINI_ARRAY = 15; -enum SHT_PREINIT_ARRAY = 16; -enum SHT_GROUP = 17; -enum SHT_SYMTAB_SHNDX = 18; -enum SHT_NUM = 19; - -enum SHT_LOOS = 0x60000000; -enum SHT_LOSUNW = 0x6fffffef; enum SHT_SUNW_capchain = 0x6fffffef; enum SHT_SUNW_capinfo = 0x6ffffff0; enum SHT_SUNW_symsort = 0x6ffffff1; @@ -363,106 +54,9 @@ enum SHT_SUNW_SIGNATURE = 0x6ffffff6; enum SHT_SUNW_ANNOTATE = 0x6ffffff7; enum SHT_SUNW_DEBUGSTR = 0x6ffffff8; enum SHT_SUNW_DEBUG = 0x6ffffff9; -enum SHT_SUNW_move = 0x6ffffffa; -enum SHT_SUNW_COMDAT = 0x6ffffffb; -enum SHT_SUNW_syminfo = 0x6ffffffc; enum SHT_SUNW_verdef = 0x6ffffffd; -enum SHT_GNU_verdef = SHT_SUNW_verdef; enum SHT_SUNW_verneed = 0x6ffffffe; -enum SHT_GNU_verneed = SHT_SUNW_verneed; enum SHT_SUNW_versym = 0x6fffffff; -enum SHT_GNU_versym = SHT_SUNW_versym; -enum SHT_HISUNW = 0x6fffffff; -enum SHT_HIOS = 0x6fffffff; -enum SHT_GNU_ATTRIBUTES = 0x6ffffff5; -enum SHT_GNU_HASH = 0x6ffffff6; -enum SHT_GNU_LIBLIST = 0x6ffffff7; -enum SHT_CHECKSUM = 0x6ffffff8; -enum SHT_LOPROC = 0x70000000; -enum SHT_HIPROC = 0x7fffffff; -enum SHT_LOUSER = 0x80000000; -enum SHT_HIUSER = 0xffffffff; - -enum SHF_WRITE = 0x01; -enum SHF_ALLOC = 0x02; -enum SHF_EXECINSTR = 0x04; -enum SHF_MERGE = 0x10; -enum SHF_STRINGS = 0x20; -enum SHF_INFO_LINK = 0x40; -enum SHF_LINK_ORDER = 0x80; -enum SHF_OS_NONCONFORMING = 0x100; -enum SHF_GROUP = 0x200; -enum SHF_TLS = 0x400; -enum SHF_COMPRESSED = 0x800; -enum SHF_MASKOS = 0x0ff00000; - -enum SHF_MASKPROC = 0xf0000000; - -enum SHN_UNDEF = 0; -enum SHN_LORESERVE = 0xff00; -enum SHN_LOPROC = 0xff00; -enum SHN_HIPROC = 0xff1f; -enum SHN_LOOS = 0xff20; -enum SHN_LOSUNW = 0xff3f; -enum SHN_SUNW_IGNORE = 0xff3f; -enum SHN_HISUNW = 0xff3f; -enum SHN_HIOS = 0xff3f; -enum SHN_ABS = 0xfff1; -enum SHN_COMMON = 0xfff2; -enum SHN_XINDEX = 0xffff; -enum SHN_HIRESERVE = 0xffff; - -struct Elf32_Sym -{ - Elf32_Word st_name; - Elf32_Addr st_value; - Elf32_Word st_size; - ubyte st_info; - ubyte st_other; - Elf32_Half st_shndx; -} - -struct Elf64_Sym -{ - Elf64_Word st_name; - ubyte st_info; - ubyte st_other; - Elf64_Half st_shndx; - Elf64_Addr st_value; - Elf64_Xword st_size; -} - -enum STN_UNDEF = 0; - -extern (D) -{ - auto ELF32_ST_BIND(T)(T val) { return cast(ubyte)val >> 4; } - auto ELF32_ST_TYPE(T)(T val) { return val & 0xf; } - auto ELF32_ST_INFO(B, T)(B bind, T type) { return (bind << 4) + (type & 0xf); } - alias ELF32_ST_BIND ELF64_ST_BIND; - alias ELF32_ST_TYPE ELF64_ST_TYPE; - alias ELF32_ST_INFO ELF64_ST_INFO; -} - -enum STB_LOCAL = 0; -enum STB_GLOBAL = 1; -enum STB_WEAK = 2; -enum STB_NUM = 3; -enum STB_LOPROC = 13; -enum STB_HIPROC = 15; - -enum STT_NOTYPE = 0; -enum STT_OBJECT = 1; -enum STT_FUNC = 2; -enum STT_SECTION = 3; -enum STT_FILE = 4; -enum STT_COMMON = 5; -enum STT_TLS = 6; -enum STT_NUM = 7; -enum STT_LOOS = 10; -enum STT_HIOS = 12; -enum STT_LOPROC = 13; -enum STT_HIPROC = 15; extern (D) { @@ -470,58 +64,18 @@ extern (D) alias ELF32_ST_VISIBILITY ELF64_ST_VISIBILITY; } -enum STV_DEFAULT = 0; -enum STV_INTERNAL = 1; -enum STV_HIDDEN = 2; -enum STV_PROTECTED = 3; enum STV_EXPORTED = 4; enum STV_SINGLETON = 5; enum STV_ELIMINATE = 6; enum STV_NUM = 7; -struct Elf32_Rel -{ - Elf32_Addr r_offset; - Elf32_Word r_info; -} - -struct Elf32_Rela -{ - Elf32_Addr r_offset; - Elf32_Word r_info; - Elf32_Sword r_addend; -} - -struct Elf64_Rel -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; -} - -struct Elf64_Rela -{ - Elf64_Addr r_offset; - Elf64_Xword r_info; - Elf64_Sxword r_addend; -} - extern (D) { - auto ELF32_R_SYM(V)(V val) { return val >> 8; } - auto ELF32_R_TYPE(V)(V val) { return val & 0xff; } - auto ELF32_R_INFO(S, T)(S sym, T type) { return (sym << 8) + (type & 0xff); } - - auto ELF64_R_SYM(I)(I i) { return i >> 32; } - auto ELF64_R_TYPE(I)(I i) { return i & 0xffffffff; } - auto ELF64_R_INFO(S, T)(S sym, T type) { return (sym << 32) + (type); } - auto ELF64_R_TYPE_DATA(I)(I i) { return (i << 32) >> 40; } auto ELF64_R_TYPE_ID(I)(I i) { return (i << 56) >> 56; } auto ELF64_R_TYPE_INFO(S, T)(S sym, T type) { return (sym <<8) + (type); } } -enum GRP_COMDAT = 0x01; - struct Elf32_Nhdr { Elf32_Word n_namesz; @@ -536,35 +90,6 @@ struct Elf64_Nhdr Elf64_Word n_type; } -struct Elf32_Move -{ - Elf32_Lword m_value; - Elf32_Word m_info; - Elf32_Word m_poffset; - Elf32_Half m_repeat; - Elf32_Half m_stride; -} - -extern (D) -{ - auto ELF32_M_SYM(I)(I info) { return info >> 8; } - auto ELF32_M_SIZE(I)(I info) { return cast(ubyte)info; } - auto ELF32_M_INFO(S, SZ)(S sym, SZ size) { return (sym << 8) + cast(ubyte)size; } -} - -struct Elf64_Move -{ - Elf64_Lword m_value; - Elf64_Xword m_info; - Elf64_Xword m_poffset; - Elf64_Half m_repeat; - Elf64_Half m_stride; -} - -alias ELF32_M_SYM ELF64_M_SYM; -alias ELF32_M_SIZE ELF64_M_SIZE; -alias ELF32_M_INFO ELF64_M_INFO; - struct Elf32_Cap { Elf32_Word c_tag; @@ -578,7 +103,6 @@ struct Elf32_Cap alias Elf32_Word Elf32_Capinfo; alias Elf32_Word Elf32_Capchain; - alias ELF32_M_SYM ELF32_C_SYM; alias ELF32_M_SIZE ELF32_C_GROUP; alias ELF32_M_INFO ELF32_C_INFO; @@ -596,13 +120,6 @@ struct Elf64_Cap alias Elf64_Xword Elf64_Capinfo; alias Elf64_Word Elf64_Capchain; -/* - * Macros to compose and decompose values for capabilities info. - * - * sym = ELF64_C_SYM(info) - * grp = ELF64_C_GROUP(info) - * info = ELF64_C_INFO(sym, grp) - */ extern (D) { auto ELF64_C_SYM(I)(I info) { return info >> 32; } @@ -656,6 +173,3 @@ enum NT_ZONENAME = 21; enum NT_FDINFO = 22; enum NT_SPYMASTER = 23; enum NT_NUM = 23; - -enum SHF_ORDERED = 0x40000000; -enum SHF_EXCLUDE = 0x80000000; diff --git a/libphobos/libdruntime/core/sys/solaris/sys/elftypes.d b/libphobos/libdruntime/core/sys/solaris/sys/elftypes.d index a43cc5a..fe8cfef 100644 --- a/libphobos/libdruntime/core/sys/solaris/sys/elftypes.d +++ b/libphobos/libdruntime/core/sys/solaris/sys/elftypes.d @@ -11,18 +11,12 @@ nothrow: import core.stdc.stdint; -alias uint32_t Elf32_Addr; -alias uint16_t Elf32_Half; -alias uint32_t Elf32_Off; -alias int32_t Elf32_Sword; -alias uint32_t Elf32_Word; +public import core.sys.elf : + Elf32_Addr, Elf32_Half, Elf32_Off, + Elf32_Sword, Elf32_Word, + Elf64_Addr, Elf64_Half, Elf64_Off, + Elf64_Sword, Elf64_Sxword, + Elf64_Word, Elf64_Xword; -alias uint64_t Elf64_Addr; -alias uint16_t Elf64_Half; -alias uint64_t Elf64_Off; -alias int32_t Elf64_Sword; -alias int64_t Elf64_Sxword; -alias uint32_t Elf64_Word; -alias uint64_t Elf64_Xword; alias uint64_t Elf64_Lword; alias uint64_t Elf32_Lword; diff --git a/libphobos/libdruntime/core/sys/solaris/sys/link.d b/libphobos/libdruntime/core/sys/solaris/sys/link.d index d9d47c0..9176b17 100644 --- a/libphobos/libdruntime/core/sys/solaris/sys/link.d +++ b/libphobos/libdruntime/core/sys/solaris/sys/link.d @@ -10,6 +10,7 @@ extern (C): nothrow: public import core.sys.solaris.sys.elftypes; +public import core.sys.elf; import core.stdc.config; struct Elf32_Dyn @@ -33,45 +34,8 @@ struct Elf64_Dyn } _d_un d_un; } -enum DT_NULL = 0; -enum DT_NEEDED = 1; -enum DT_PLTRELSZ = 2; -enum DT_PLTGOT = 3; -enum DT_HASH = 4; -enum DT_STRTAB = 5; -enum DT_SYMTAB = 6; -enum DT_RELA = 7; -enum DT_RELASZ = 8; -enum DT_RELAENT = 9; -enum DT_STRSZ = 10; -enum DT_SYMENT = 11; -enum DT_INIT = 12; -enum DT_FINI = 13; -enum DT_SONAME = 14; -enum DT_RPATH = 15; -enum DT_SYMBOLIC = 16; -enum DT_REL = 17; -enum DT_RELSZ = 18; -enum DT_RELENT = 19; -enum DT_PLTREL = 20; -enum DT_DEBUG = 21; -enum DT_TEXTREL = 22; -enum DT_JMPREL = 23; -enum DT_BIND_NOW = 24; -enum DT_INIT_ARRAY = 25; -enum DT_FINI_ARRAY = 26; -enum DT_INIT_ARRAYSZ = 27; -enum DT_FINI_ARRAYSZ = 28; -enum DT_RUNPATH = 29; -enum DT_FLAGS = 30; - -enum DT_ENCODING = 32; -enum DT_PREINIT_ARRAY = 32; -enum DT_PREINIT_ARRAYSZ = 33; - enum DT_MAXPOSTAGS = 34; -enum DT_LOOS = 0x6000000d; enum DT_SUNW_AUXILIARY = 0x6000000d; enum DT_SUNW_RTLDINF = 0x6000000e; enum DT_SUNW_FILTER = 0x6000000f; @@ -92,205 +56,15 @@ enum DT_SUNW_LDMACH = 0x6000001b; enum DT_SUNW_CAPCHAINENT = 0x6000001d; enum DT_SUNW_CAPCHAINSZ = 0x6000001f; -enum DT_HIOS = 0x6ffff000; - enum DT_DEPRECATED_SPARC_REGISTER = 0x7000001; -enum DT_VALRNGLO = 0x6ffffd00; - -enum DT_GNU_PRELINKED = 0x6ffffdf5; -enum DT_GNU_CONFLICTSZ = 0x6ffffdf6; -enum DT_GNU_LIBLISTSZ = 0x6ffffdf7; -enum DT_CHECKSUM = 0x6ffffdf8; -enum DT_PLTPADSZ = 0x6ffffdf9; -enum DT_MOVEENT = 0x6ffffdfa; -enum DT_MOVESZ = 0x6ffffdfb; -enum DT_FEATURE_1 = 0x6ffffdfc; -enum DT_POSFLAG_1 = 0x6ffffdfd; -enum DT_SYMINSZ = 0x6ffffdfe; -enum DT_SYMINENT = 0x6ffffdff; -enum DT_VALRNGHI = 0x6ffffdff; - -enum DT_ADDRRNGLO = 0x6ffffe00; - -enum DT_GNU_HASH = 0x6ffffef5; -enum DT_TLSDESC_PLT = 0x6ffffef6; -enum DT_TLSDESC_GOT = 0x6ffffef7; -enum DT_GNU_CONFLICT = 0x6ffffef8; -enum DT_GNU_LIBLIST = 0x6ffffef9; - -enum DT_CONFIG = 0x6ffffefa; -enum DT_DEPAUDIT = 0x6ffffefb; -enum DT_AUDIT = 0x6ffffefc; -enum DT_PLTPAD = 0x6ffffefd; -enum DT_MOVETAB = 0x6ffffefe; -enum DT_SYMINFO = 0x6ffffeff; -enum DT_ADDRRNGHI = 0x6ffffeff; - -enum DT_VERSYM = 0x6ffffff0; - -enum DT_RELACOUNT = 0x6ffffff9; -enum DT_RELCOUNT = 0x6ffffffa; -enum DT_FLAGS_1 = 0x6ffffffb; -enum DT_VERDEF = 0x6ffffffc; -enum DT_VERDEFNUM = 0x6ffffffd; -enum DT_VERNEED = 0x6ffffffe; -enum DT_VERNEEDNUM = 0x6fffffff; - -enum DT_LOPROC = 0x70000000; -enum DT_AUXILIARY = 0x7ffffffd; enum DT_USED = 0x7ffffffe; -enum DT_FILTER = 0x7fffffff; -enum DT_HIPROC = 0x7fffffff; -enum DF_ORIGIN = 0x00000001; -enum DF_SYMBOLIC = 0x00000002; -enum DF_TEXTREL = 0x00000004; -enum DF_BIND_NOW = 0x00000008; -enum DF_STATIC_TLS = 0x00000010; - -enum DF_P1_LAZYLOAD = 0x00000001; -enum DF_P1_GROUPPERM = 0x00000002; enum DF_P1_DEFERRED = 0x00000004; -enum DF_1_NOW = 0x00000001; -enum DF_1_GLOBAL = 0x00000002; -enum DF_1_GROUP = 0x00000004; -enum DF_1_NODELETE = 0x00000008; -enum DF_1_LOADFLTR = 0x00000010; -enum DF_1_INITFIRST = 0x00000020; -enum DF_1_NOOPEN = 0x00000040; -enum DF_1_ORIGIN = 0x00000080; -enum DF_1_DIRECT = 0x00000100; -enum DF_1_TRANS = 0x00000200; -enum DF_1_INTERPOSE = 0x00000400; -enum DF_1_NODEFLIB = 0x00000800; -enum DF_1_NODUMP = 0x00001000; -enum DF_1_CONFALT = 0x00002000; -enum DF_1_ENDFILTEE = 0x00004000; -enum DF_1_DISPRELDNE = 0x00008000; -enum DF_1_DISPRELPND = 0x00010000; -enum DF_1_NODIRECT = 0x00020000; -enum DF_1_IGNMULDEF = 0x00040000; -enum DF_1_NOKSYMS = 0x00080000; -enum DF_1_NOHDR = 0x00100000; -enum DF_1_EDITED = 0x00200000; -enum DF_1_NORELOC = 0x00400000; -enum DF_1_SYMINTPOSE = 0x00800000; -enum DF_1_GLOBAUDIT = 0x01000000; -enum DF_1_SINGLETON = 0x02000000; - -enum DTF_1_PARINIT = 0x00000001; -enum DTF_1_CONFEXP = 0x00000002; - -struct Elf32_Verdef -{ - Elf32_Half vd_version; - Elf32_Half vd_flags; - Elf32_Half vd_ndx; - Elf32_Half vd_cnt; - Elf32_Word vd_hash; - Elf32_Word vd_aux; - Elf32_Word vd_next; -} - -struct Elf32_Verdaux -{ - Elf32_Word vda_name; - Elf32_Word vda_next; -} - -struct Elf32_Verneed -{ - Elf32_Half vn_version; - Elf32_Half vn_cnt; - Elf32_Word vn_file; - Elf32_Word vn_aux; - Elf32_Word vn_next; -} - -struct Elf32_Vernaux -{ - Elf32_Word vna_hash; - Elf32_Half vna_flags; - Elf32_Half vna_other; - Elf32_Word vna_name; - Elf32_Word vna_next; -} - -alias Elf32_Half Elf32_Versym; - -struct Elf32_Syminfo -{ - Elf32_Half si_boundto; - Elf32_Half si_flags; -} - -struct Elf64_Verdef -{ - Elf64_Half vd_version; - Elf64_Half vd_flags; - Elf64_Half vd_ndx; - Elf64_Half vd_cnt; - Elf64_Word vd_hash; - Elf64_Word vd_aux; - Elf64_Word vd_next; -} - -struct Elf64_Verdaux -{ - Elf64_Word vda_name; - Elf64_Word vda_next; -} - -struct Elf64_Verneed -{ - Elf64_Half vn_version; - Elf64_Half vn_cnt; - Elf64_Word vn_file; - Elf64_Word vn_aux; - Elf64_Word vn_next; -} - -struct Elf64_Vernaux -{ - Elf64_Word vna_hash; - Elf64_Half vna_flags; - Elf64_Half vna_other; - Elf64_Word vna_name; - Elf64_Word vna_next; -} - -alias Elf64_Half Elf64_Versym; - -struct Elf64_Syminfo -{ - Elf64_Half si_boundto; - Elf64_Half si_flags; -} - -enum VER_NDX_LOCAL = 0; -enum VER_NDX_GLOBAL = 1; -enum VER_NDX_LORESERVE = 0xff00; -enum VER_NDX_ELIMINATE = 0xff01; - -enum VER_FLG_BASE = 0x1; -enum VER_FLG_WEAK = 0x2; enum VER_FLG_INFO = 0x4; -enum VER_DEF_NONE = 0; -enum VER_DEF_CURRENT = 1; -enum VER_DEF_NUM = 2; - -enum VER_NEED_NONE = 0; -enum VER_NEED_CURRENT = 1; -enum VER_NEED_NUM = 2; - -enum SYMINFO_FLG_DIRECT = 0x0001; enum SYMINFO_FLG_FILTER = 0x0002; -enum SYMINFO_FLG_PASSTHRU = SYMINFO_FLG_FILTER; -enum SYMINFO_FLG_COPY = 0x0004; -enum SYMINFO_FLG_LAZYLOAD = 0x0008; enum SYMINFO_FLG_DIRECTBIND = 0x0010; enum SYMINFO_FLG_NOEXTDIRECT = 0x0020; enum SYMINFO_FLG_AUXILIARY = 0x0040; @@ -298,15 +72,8 @@ enum SYMINFO_FLG_INTERPOSE = 0x0080; enum SYMINFO_FLG_CAP = 0x0100; enum SYMINFO_FLG_DEFERRED = 0x0200; -enum SYMINFO_BT_SELF = 0xffff; -enum SYMINFO_BT_PARENT = 0xfffe; enum SYMINFO_BT_NONE = 0xfffd; enum SYMINFO_BT_EXTERN = 0xfffc; -enum SYMINFO_BT_LOWRESERVE = 0xff00; - -enum SYMINFO_NONE = 0; -enum SYMINFO_CURRENT = 1; -enum SYMINFO_NUM = 2; alias link_map Link_map; diff --git a/libphobos/libdruntime/core/sys/windows/objbase.d b/libphobos/libdruntime/core/sys/windows/objbase.d index 3695ea6..bb9e7ea 100644 --- a/libphobos/libdruntime/core/sys/windows/objbase.d +++ b/libphobos/libdruntime/core/sys/windows/objbase.d @@ -9,6 +9,7 @@ module core.sys.windows.objbase; version (Windows): @system: +nothrow: pragma(lib, "ole32"); import core.sys.windows.cguid, core.sys.windows.objidl, core.sys.windows.unknwn, core.sys.windows.wtypes; diff --git a/libphobos/libdruntime/core/sys/windows/stat.d b/libphobos/libdruntime/core/sys/windows/stat.d index c9ee6ce..16f66e1 100644 --- a/libphobos/libdruntime/core/sys/windows/stat.d +++ b/libphobos/libdruntime/core/sys/windows/stat.d @@ -8,6 +8,8 @@ version (Windows): extern (C) nothrow @nogc: @system: +import core.sys.windows.stdc.time; + // Posix version is in core.sys.posix.sys.stat enum S_IFMT = 0xF000; @@ -30,22 +32,49 @@ int S_ISDIR(int m) { return (m & S_IFMT) == S_IFDIR; } int S_ISCHR(int m) { return (m & S_IFMT) == S_IFCHR; } } -struct struct_stat +version (CRuntime_DigitalMars) { - short st_dev; - ushort st_ino; - ushort st_mode; - short st_nlink; - ushort st_uid; - ushort st_gid; - short st_rdev; - short dummy; - int st_size; - int st_atime; - int st_mtime; - int st_ctime; + struct struct_stat + { + short st_dev; + ushort st_ino; + ushort st_mode; + short st_nlink; + ushort st_uid; + ushort st_gid; + short st_rdev; + short dummy; + int st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; + } + + int stat(const(char)*, struct_stat *); + int fstat(int, struct_stat *) @trusted; + int _wstat(const(wchar)*, struct_stat *); } +else version (CRuntime_Microsoft) +{ + struct struct_stat + { + uint st_dev; + ushort st_ino; + ushort st_mode; + short st_nlink; + short st_uid; + short st_gid; + uint st_rdev; + int st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; + } -int stat(const(char)*, struct_stat *); -int fstat(int, struct_stat *) @trusted; -int _wstat(const(wchar)*, struct_stat *); + // These assume time_t is 32 bits (which druntime's definition currently is) + // Add pragma(mangle) to use _stat64 etc. when time_t is made 64-bit + // See also: https://issues.dlang.org/show_bug.cgi?id=21134 + int stat(const(char)*, struct_stat *); + int fstat(int, struct_stat *) @trusted; + int _wstat(const(wchar)*, struct_stat *); +} diff --git a/libphobos/libdruntime/core/sys/windows/unknwn.d b/libphobos/libdruntime/core/sys/windows/unknwn.d index 49d5abf..6db1db8 100644 --- a/libphobos/libdruntime/core/sys/windows/unknwn.d +++ b/libphobos/libdruntime/core/sys/windows/unknwn.d @@ -9,6 +9,7 @@ module core.sys.windows.unknwn; version (Windows): @system: +nothrow: import core.sys.windows.objfwd, core.sys.windows.windef, core.sys.windows.wtypes; import core.sys.windows.basetyps; diff --git a/libphobos/libdruntime/core/sys/windows/winsock2.d b/libphobos/libdruntime/core/sys/windows/winsock2.d index 55a45be..8a4b1fd 100644 --- a/libphobos/libdruntime/core/sys/windows/winsock2.d +++ b/libphobos/libdruntime/core/sys/windows/winsock2.d @@ -45,15 +45,15 @@ enum NI_MAXSERV = 32; @nogc { int WSAStartup(ushort wVersionRequested, LPWSADATA lpWSAData); -int WSACleanup(); -SOCKET socket(int af, int type, int protocol); +@trusted int WSACleanup(); +@trusted SOCKET socket(int af, int type, int protocol); int ioctlsocket(SOCKET s, int cmd, uint* argp); int bind(SOCKET s, const(sockaddr)* name, socklen_t namelen); int connect(SOCKET s, const(sockaddr)* name, socklen_t namelen); -int listen(SOCKET s, int backlog); +@trusted int listen(SOCKET s, int backlog); SOCKET accept(SOCKET s, sockaddr* addr, socklen_t* addrlen); -int closesocket(SOCKET s); -int shutdown(SOCKET s, int how); +@trusted int closesocket(SOCKET s); +@trusted int shutdown(SOCKET s, int how); int getpeername(SOCKET s, sockaddr* name, socklen_t* namelen); int getsockname(SOCKET s, sockaddr* name, socklen_t* namelen); int send(SOCKET s, const(void)* buf, int len, int flags); @@ -64,11 +64,11 @@ int getsockopt(SOCKET s, int level, int optname, void* optval, socklen_t* optlen int setsockopt(SOCKET s, int level, int optname, const(void)* optval, socklen_t optlen); uint inet_addr(const char* cp); int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds, const(timeval)* timeout); -char* inet_ntoa(in_addr ina); +@trusted char* inet_ntoa(in_addr ina); hostent* gethostbyname(const char* name); hostent* gethostbyaddr(const(void)* addr, int len, int type); protoent* getprotobyname(const char* name); -protoent* getprotobynumber(int number); +@trusted protoent* getprotobynumber(int number); servent* getservbyname(const char* name, const char* proto); servent* getservbyport(int port, const char* proto); } diff --git a/libphobos/libdruntime/core/thread/context.d b/libphobos/libdruntime/core/thread/context.d index 1b3c0ca..e477269 100644 --- a/libphobos/libdruntime/core/thread/context.d +++ b/libphobos/libdruntime/core/thread/context.d @@ -6,7 +6,7 @@ * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). * (See accompanying file LICENSE) * Authors: Sean Kelly, Walter Bright, Alex Rønne Petersen, Martin Nowak - * Source: $(DRUNTIMESRC core/thread/package.d) + * Source: $(DRUNTIMESRC core/thread/context.d) */ module core.thread.context; diff --git a/libphobos/libdruntime/core/thread/fiber.d b/libphobos/libdruntime/core/thread/fiber.d index bd53eed..efbad7d 100644 --- a/libphobos/libdruntime/core/thread/fiber.d +++ b/libphobos/libdruntime/core/thread/fiber.d @@ -653,14 +653,9 @@ class Fiber */ this( void delegate() dg, size_t sz = PAGESIZE * defaultStackPages, size_t guardPageSize = PAGESIZE ) nothrow - in - { - assert( dg ); - } - do { allocStack( sz, guardPageSize ); - reset( dg ); + reset( cast(void delegate() const) dg ); } diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d index ca36809..415430c 100644 --- a/libphobos/libdruntime/core/thread/osthread.d +++ b/libphobos/libdruntime/core/thread/osthread.d @@ -1251,7 +1251,7 @@ version (CoreDdoc) { /** * Instruct the thread module, when initialized, to use a different set of - * signals besides SIGUSR1 and SIGUSR2 for suspension and resumption of threads. + * signals besides SIGRTMIN and SIGRTMIN + 1 for suspension and resumption of threads. * This function should be called at most once, prior to thread_init(). * This function is Posix-only. */ @@ -1281,8 +1281,8 @@ else version (Posix) version (Posix) { - private __gshared int suspendSignalNumber = SIGUSR1; - private __gshared int resumeSignalNumber = SIGUSR2; + private __gshared int suspendSignalNumber; + private __gshared int resumeSignalNumber; } private extern (D) ThreadBase attachThread(ThreadBase _thisThread) @nogc nothrow @@ -1333,6 +1333,9 @@ private extern (D) ThreadBase attachThread(ThreadBase _thisThread) @nogc nothrow * must be called after thread_attachThis: * * extern (C) void rt_moduleTlsCtor(); + * + * See_Also: + * $(REF thread_detachThis, core,thread,threadbase) */ extern(C) Thread thread_attachThis() { @@ -2101,7 +2104,7 @@ private extern (D) void resume(ThreadBase _t) nothrow @nogc * garbage collector on startup and before any other thread routines * are called. */ -extern (C) void thread_init() @nogc +extern (C) void thread_init() @nogc nothrow { // NOTE: If thread_init itself performs any allocations then the thread // routines reserved for garbage collector use may be called while @@ -2112,11 +2115,6 @@ extern (C) void thread_init() @nogc initLowlevelThreads(); Thread.initLocks(); - // The Android VM runtime intercepts SIGUSR1 and apparently doesn't allow - // its signal handler to run, so swap the two signals on Android, since - // thread_resumeHandler does nothing. - version (Android) thread_setGCSignals(SIGUSR2, SIGUSR1); - version (Darwin) { // thread id different in forked child process @@ -2132,6 +2130,25 @@ extern (C) void thread_init() @nogc } else version (Posix) { + version (OpenBSD) + { + // OpenBSD does not support SIGRTMIN or SIGRTMAX + // Use SIGUSR1 for SIGRTMIN, SIGUSR2 for SIGRTMIN + 1 + // And use 32 for SIGRTMAX (32 is the max signal number on OpenBSD) + enum SIGRTMIN = SIGUSR1; + enum SIGRTMAX = 32; + } + + if ( suspendSignalNumber == 0 ) + { + suspendSignalNumber = SIGRTMIN; + } + + if ( resumeSignalNumber == 0 ) + { + resumeSignalNumber = SIGRTMIN + 1; + assert(resumeSignalNumber <= SIGRTMAX); + } int status; sigaction_t suspend = void; sigaction_t resume = void; @@ -2177,13 +2194,13 @@ extern (C) void thread_init() @nogc } private alias MainThreadStore = void[__traits(classInstanceSize, Thread)]; -package __gshared align(Thread.alignof) MainThreadStore _mainThreadStore; +package __gshared align(__traits(classInstanceAlignment, Thread)) MainThreadStore _mainThreadStore; /** * Terminates the thread module. No other thread routine may be called * afterwards. */ -extern (C) void thread_term() @nogc +extern (C) void thread_term() @nogc nothrow { thread_term_tpl!(Thread)(_mainThreadStore); } diff --git a/libphobos/libdruntime/core/thread/threadbase.d b/libphobos/libdruntime/core/thread/threadbase.d index 9cee4d8..909bffc 100644 --- a/libphobos/libdruntime/core/thread/threadbase.d +++ b/libphobos/libdruntime/core/thread/threadbase.d @@ -80,9 +80,7 @@ private { // Handling unaligned mutexes are not supported on all platforms, so we must // ensure that the address of all shared data are appropriately aligned. - import core.internal.traits : classInstanceAlignment; - - enum mutexAlign = classInstanceAlignment!Mutex; + enum mutexAlign = __traits(classInstanceAlignment, Mutex); enum mutexClassInstanceSize = __traits(classInstanceSize, Mutex); alias swapContext = externDFunc!("core.thread.osthread.swapContext", void* function(void*) nothrow @nogc); @@ -110,8 +108,8 @@ class ThreadBase m_call = fn; } - this(void delegate() dg, size_t sz = 0) @safe pure nothrow @nogc - in(dg) + this(void delegate() dg, size_t sz = 0) @trusted pure nothrow @nogc + in( cast(const void delegate()) dg) { this(sz); m_call = dg; @@ -571,14 +569,14 @@ package(core.thread): __gshared align(mutexAlign) void[mutexClassInstanceSize] _slock; __gshared align(mutexAlign) void[mutexClassInstanceSize] _criticalRegionLock; - static void initLocks() @nogc + static void initLocks() @nogc nothrow { import core.lifetime : emplace; emplace!Mutex(_slock[]); emplace!Mutex(_criticalRegionLock[]); } - static void termLocks() @nogc + static void termLocks() @nogc nothrow { (cast(Mutex)_slock.ptr).__dtor(); (cast(Mutex)_criticalRegionLock.ptr).__dtor(); @@ -758,13 +756,13 @@ package(core.thread): private alias attachThread = externDFunc!("core.thread.osthread.attachThread", ThreadBase function(ThreadBase) @nogc nothrow); -extern (C) void _d_monitordelete_nogc(Object h) @nogc; +extern (C) void _d_monitordelete_nogc(Object h) @nogc nothrow; /** * Terminates the thread module. No other thread routine may be called * afterwards. */ -package void thread_term_tpl(ThreadT, MainThreadStore)(ref MainThreadStore _mainThreadStore) @nogc +package void thread_term_tpl(ThreadT, MainThreadStore)(ref MainThreadStore _mainThreadStore) @nogc nothrow { assert(_mainThreadStore.ptr is cast(void*) ThreadBase.sm_main); @@ -820,10 +818,13 @@ package ThreadT thread_attachThis_tpl(ThreadT)() * * NOTE: This routine does not run thread-local static destructors when called. * If full functionality as a D thread is desired, the following function - * must be called after thread_detachThis, particularly if the thread is + * must be called before thread_detachThis, particularly if the thread is * being detached at some indeterminate time before program termination: * * $(D extern(C) void rt_moduleTlsDtor();) + * + * See_Also: + * $(REF thread_attachThis, core,thread,osthread) */ extern (C) void thread_detachThis() nothrow @nogc { @@ -1331,13 +1332,13 @@ package return cast(Mutex)ll_lock.ptr; } - void initLowlevelThreads() @nogc + void initLowlevelThreads() @nogc nothrow { import core.lifetime : emplace; emplace(lowlevelLock()); } - void termLowlevelThreads() @nogc + void termLowlevelThreads() @nogc nothrow { lowlevelLock.__dtor(); } diff --git a/libphobos/libdruntime/core/time.d b/libphobos/libdruntime/core/time.d index 0ddf62f..9b8391e 100644 --- a/libphobos/libdruntime/core/time.d +++ b/libphobos/libdruntime/core/time.d @@ -496,6 +496,81 @@ assert(std.datetime.Date(2010, 9, 7) - std.datetime.Date(2010, 10, 3) == +/ struct Duration { + /++ + Converts this `Duration` to a `string`. + + The string is meant to be human readable, not machine parseable (e.g. + whether there is an `'s'` on the end of the unit name usually depends on + whether it's plural or not, and empty units are not included unless the + Duration is `zero`). Any code needing a specific string format should + use `total` or `split` to get the units needed to create the desired + string format and create the string itself. + + The format returned by toString may or may not change in the future. + + Params: + sink = A sink object, expected to be a delegate or aggregate + implementing `opCall` that accepts a `scope const(char)[]` + as argument. + +/ + void toString (SinkT) (scope SinkT sink) const scope + { + static immutable units = [ + "weeks", "days", "hours", "minutes", "seconds", "msecs", "usecs" + ]; + + static void appListSep(SinkT sink, uint pos, bool last) + { + if (pos == 0) + return; + if (!last) + sink(", "); + else + sink(pos == 1 ? " and " : ", and "); + } + + static void appUnitVal(string units)(SinkT sink, long val) + { + immutable plural = val != 1; + string unit; + static if (units == "seconds") + unit = plural ? "secs" : "sec"; + else static if (units == "msecs") + unit = "ms"; + else static if (units == "usecs") + unit = "μs"; + else + unit = plural ? units : units[0 .. $-1]; + sink(signedToTempString(val)); + sink(" "); + sink(unit); + } + + if (_hnsecs == 0) + { + sink("0 hnsecs"); + return; + } + + long hnsecs = _hnsecs; + uint pos; + static foreach (unit; units) + { + if (auto val = splitUnitsFromHNSecs!unit(hnsecs)) + { + appListSep(sink, pos++, hnsecs == 0); + appUnitVal!unit(sink, val); + } + if (hnsecs == 0) + return; + } + if (hnsecs != 0) + { + appListSep(sink, pos++, true); + appUnitVal!"hnsecs"(sink, hnsecs); + } + } + @safe pure: public: @@ -1539,71 +1614,12 @@ public: } } - - /++ - Converts this `Duration` to a `string`. - - The string is meant to be human readable, not machine parseable (e.g. - whether there is an `'s'` on the end of the unit name usually depends on - whether it's plural or not, and empty units are not included unless the - Duration is `zero`). Any code needing a specific string format should - use `total` or `split` to get the units needed to create the desired - string format and create the string itself. - - The format returned by toString may or may not change in the future. - +/ - string toString() const nothrow pure @safe + /// Ditto + string toString() const scope nothrow { - static void appListSep(ref string res, uint pos, bool last) - { - if (pos == 0) - return; - if (!last) - res ~= ", "; - else - res ~= pos == 1 ? " and " : ", and "; - } - - static void appUnitVal(string units)(ref string res, long val) - { - immutable plural = val != 1; - string unit; - static if (units == "seconds") - unit = plural ? "secs" : "sec"; - else static if (units == "msecs") - unit = "ms"; - else static if (units == "usecs") - unit = "μs"; - else - unit = plural ? units : units[0 .. $-1]; - res ~= signedToTempString(val); - res ~= " "; - res ~= unit; - } - - if (_hnsecs == 0) - return "0 hnsecs"; - - template TT(T...) { alias T TT; } - alias units = TT!("weeks", "days", "hours", "minutes", "seconds", "msecs", "usecs"); - - long hnsecs = _hnsecs; string res; uint pos; - foreach (unit; units) - { - if (auto val = splitUnitsFromHNSecs!unit(hnsecs)) - { - appListSep(res, pos++, hnsecs == 0); - appUnitVal!unit(res, val); - } - if (hnsecs == 0) - break; - } - if (hnsecs != 0) - { - appListSep(res, pos++, true); - appUnitVal!"hnsecs"(res, hnsecs); - } - return res; + string result; + this.toString((in char[] data) { result ~= data; }); + return result; } /// @@ -1731,6 +1747,20 @@ unittest assert(myTime == 123.msecs); } +// Ensure `toString` doesn't allocate if the sink doesn't +version (CoreUnittest) @safe pure nothrow @nogc unittest +{ + char[256] buffer; size_t len; + scope sink = (in char[] data) { + assert(data.length + len <= buffer.length); + buffer[len .. len + data.length] = data[]; + len += data.length; + }; + auto dur = Duration(-12_096_020_900_003); + dur.toString(sink); + assert(buffer[0 .. len] == "-2 weeks, -2 secs, -90 ms, and -3 hnsecs"); +} + /++ Converts a $(D TickDuration) to the given units as either an integral value or a floating point value. @@ -2458,7 +2488,7 @@ private immutable long[__traits(allMembers, ClockType).length] _ticksPerSecond; // https://issues.dlang.org/show_bug.cgi?id=14863 // The assert will occur when someone attempts to use _ticksPerSecond for that // value. -extern(C) void _d_initMonoTime() +extern(C) void _d_initMonoTime() @nogc nothrow { // We need a mutable pointer to the ticksPerSecond array. Although this // would appear to break immutability, it is logically the same as a static @@ -3793,7 +3823,7 @@ unittest } version (Darwin) -long machTicksPerSecond() +long machTicksPerSecond() @nogc nothrow { // Be optimistic that ticksPerSecond (1e9*denom/numer) is integral. So far // so good on Darwin based platforms OS X, iOS. diff --git a/libphobos/libdruntime/core/vararg.d b/libphobos/libdruntime/core/vararg.d index 935b2bd..2c3e965 100644 --- a/libphobos/libdruntime/core/vararg.d +++ b/libphobos/libdruntime/core/vararg.d @@ -28,6 +28,8 @@ version (MIPS32) version = MIPS_Any; version (MIPS64) version = MIPS_Any; version (PPC) version = PPC_Any; version (PPC64) version = PPC_Any; +version (RISCV32) version = RISCV_Any; +version (RISCV64) version = RISCV_Any; version (ARM_Any) { @@ -136,6 +138,21 @@ void va_arg()(ref va_list ap, TypeInfo ti, void* parmn) ap += tsize.alignUp; parmn[0..tsize] = p[0..tsize]; } + else version (RISCV_Any) + { + const tsize = ti.tsize; + void* p; + if (tsize > (size_t.sizeof << 1)) + p = *cast(void**) ap; + else + { + if (tsize == (size_t.sizeof << 1)) + ap = ap.alignUp!(size_t.sizeof << 1); + p = cast(void*) ap; + } + ap += tsize.alignUp; + parmn[0..tsize] = p[0..tsize]; + } else static assert(0, "Unsupported platform"); } diff --git a/libphobos/libdruntime/gcc/attributes.d b/libphobos/libdruntime/gcc/attributes.d index 09f684c..9d7f2e1 100644 --- a/libphobos/libdruntime/gcc/attributes.d +++ b/libphobos/libdruntime/gcc/attributes.d @@ -182,6 +182,33 @@ enum flatten = attribute("flatten"); enum no_icf = attribute("no_icf"); /** + * The `@no_sanitize` attribute on functions is used to inform the compiler + * that it should not do sanitization of any option mentioned in + * sanitize_option. A list of values acceptable by the `-fsanitize` option + * can be provided. + * + * Example: + * --- + * import gcc.attributes; + * + * @no_sanitize("alignment", "object-size") void func1() { } + * @no_sanitize("alignment,object-size") void func2() { } + * --- + */ + +auto no_sanitize(A...)(A arguments) + if (allSatisfy!(isStringValue, arguments)) +{ + return attribute("no_sanitize", arguments); +} + +auto no_sanitize(A...)(A arguments) + if (!allSatisfy!(isStringValue, arguments)) +{ + assert(false, "no_sanitize attribute argument not a string constant"); +} + +/** * The `@noclone` attribute prevents a function from being considered for * cloning - a mechanism that produces specialized copies of functions and * which is (currently) performed by interprocedural constant propagation. @@ -275,6 +302,34 @@ auto optimize(A...)(A arguments) } /** + * The `@register` attribute specifies that a local or `__gshared` variable + * is to be given a register storage-class in the C99 sense of the term, and + * will be placed into a register named `registerName`. + * + * The variable needs to boiled down to a data type that fits the target + * register. It also cannot have either thread-local or `extern` storage. + * It is an error to take the address of a register variable. + * + * Example: + * --- + * import gcc.attributes; + * + * @register("ebx") __gshared int ebx = void; + * + * void func() { @register("r10") long r10 = 0x2a; } + * --- + */ +auto register(string registerName) +{ + return attribute("register", registerName); +} + +auto register(A...)(A arguments) +{ + assert(false, "register attribute argument not a string constant"); +} + +/** * The `@restrict` attribute specifies that a function parameter is to be * restrict-qualified in the C99 sense of the term. The parameter needs to * boil down to either a pointer or reference type, such as a D pointer, @@ -317,6 +372,46 @@ auto section(A...)(A arguments) } /** + * The `@simd` attribute enables creation of one or more function versions that + * can process multiple arguments using SIMD instructions from a single + * invocation. Specifying this attribute allows compiler to assume that such + * versions are available at link time (provided in the same or another module). + * Generated versions are target-dependent and described in the corresponding + * Vector ABI document. For x86_64 target this document can be found here. + * https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt + * + * The `@simd_clones` attribute is the same as `@simd`, but also includes a + * `mask` argument. Valid masks values are `notinbranch` or `inbranch`, and + * instructs the compiler to generate non-masked or masked clones + * correspondingly. + * + * Example: + * --- + * import gcc.attributes; + * + * @simd double sqrt(double x); + * @simd("notinbranch") double atan2(double y, double x); + * --- + */ +enum simd = attribute("simd"); + +auto simd_clones(string mask) +{ + if (mask == "notinbranch" || mask == "inbranch") + return attribute("simd", mask); + else + { + assert(false, "unrecognized parameter `" ~ mask + ~ "` for `gcc.attribute.simd_clones`"); + } +} + +auto simd_clones(A...)(A arguments) +{ + assert(false, "simd_clones attribute argument not a string constant"); +} + +/** * The `@symver` attribute creates a symbol version on ELF targets. The syntax * of the string parameter is `name@nodename`. The `name` part of the parameter * is the actual name of the symbol by which it will be externally referenced. @@ -425,6 +520,30 @@ auto target_clones(A...)(A arguments) enum used = attribute("used"); /** + * The `@visibility` attribute affects the linkage of the declaration to which + * it is attached. It can be applied to variables, types, and functions. + * + * There are four supported visibility_type values: `default`, `hidden`, + * `protected`, or `internal` visibility. + * + * Example: + * --- + * import gcc.attributes; + * + * @visibility("protected") void func() { } + * --- + */ +auto visibility(string visibilityName) +{ + return attribute("visibility", visibilityName); +} + +auto visibility(A...)(A arguments) +{ + assert(false, "visibility attribute argument not a string constant"); +} + +/** * The `@weak` attribute causes a declaration of an external symbol to be * emitted as a weak symbol rather than a global. This is primarily useful in * defining library functions that can be overridden in user code, though it can @@ -543,6 +662,16 @@ enum dynamicCompileEmit = false; enum fastmath = optimize("Ofast"); /** + * Sets the visibility of a function or global variable to "hidden". + * Such symbols aren't directly accessible from outside the DSO + * (executable or DLL/.so/.dylib) and are resolved inside the DSO + * during linking. If unreferenced within the DSO, the linker can + * strip a hidden symbol. + * An `export` visibility overrides this attribute. + */ +enum hidden = visibility("hidden"); + +/** * Adds GCC's "naked" attribute to a function, disabling function prologue / * epilogue emission. * Intended to be used in combination with basic `asm` statement. While using @@ -561,6 +690,14 @@ enum fastmath = optimize("Ofast"); enum naked = attribute("naked"); /** + * Disables a particular sanitizer for this function. + * Valid sanitizer names are all names accepted by `-fsanitize=` commandline option. + * Multiple sanitizers can be disabled by applying this UDA multiple times, e.g. + * `@noSanitize("address") `@noSanitize("thread")` to disable both ASan and TSan. + */ +alias noSanitize = no_sanitize; + +/** * Sets the optimization strategy for a function. * Valid strategies are "none", "optsize", "minsize". The strategies are * mutually exclusive. diff --git a/libphobos/libdruntime/gcc/emutls.d b/libphobos/libdruntime/gcc/emutls.d index 6d9fb30..ee36032 100644 --- a/libphobos/libdruntime/gcc/emutls.d +++ b/libphobos/libdruntime/gcc/emutls.d @@ -223,9 +223,9 @@ void** emutlsAlloc(shared __emutls_object* obj) nothrow @nogc } /* - * When a thread has finished, remove the TLS array from the GC - * scan list emutlsArrays, free all allocated TLS variables and - * finally free the array. + * When a thread has finished, free all allocated TLS variables and empty the + * array. The pointer is not free'd as it is stil referenced by the GC scan + * list emutlsArrays, which gets destroyed when druntime is unloaded. */ extern (C) void emutlsDestroyThread(void* ptr) nothrow @nogc { @@ -237,7 +237,7 @@ extern (C) void emutlsDestroyThread(void* ptr) nothrow @nogc free(entry[-1]); } - free(arr); + arr.length = 0; } /* diff --git a/libphobos/libdruntime/gcc/simd.d b/libphobos/libdruntime/gcc/simd.d new file mode 100644 index 0000000..ffca50f --- /dev/null +++ b/libphobos/libdruntime/gcc/simd.d @@ -0,0 +1,359 @@ +// GNU D Compiler SIMD support functions and intrinsics. +// Copyright (C) 2022 Free Software Foundation, Inc. + +// GCC 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 3, or (at your option) any later +// version. + +// GCC is distributed in the hope that 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +module gcc.simd; + +pure: +nothrow: +@safe: +@nogc: +pragma(inline, true): + +/** +* Emit prefetch instruction. +* Params: +* address = address to be prefetched +* writeFetch = true for write fetch, false for read fetch +* locality = 0..3 (0 meaning least local, 3 meaning most local) +*/ +void prefetch(bool writeFetch, ubyte locality)(const(void)* address) +{ + static assert(locality < 4, "0..3 expected for locality"); + import gcc.builtins : __builtin_prefetch; + __builtin_prefetch(address, writeFetch, locality); +} + +/** + * Load unaligned vector from address. + * This is a compiler intrinsic. + * Params: + * p = pointer to vector + * Returns: + * vector + */ +V loadUnaligned(V)(const V* p) if (isVectorType!V); + +/** + * Store vector to unaligned address. + * This is a compiler intrinsic. + * Params: + * p = pointer to vector + * value = value to store + * Returns: + * value + */ +V storeUnaligned(V)(V* p, V value) if (isVectorType!V); + +/** + * Construct a permutation of elements from one or two vectors, returning a + * vector of the same type as the input vector(s). The `mask` is an integral + * vector with the same width and element count as the output vector. + * Params: + * op1 = input vector + * op2 = input vector + * mask = integer vector mask + * Returns: + * vector with the same type as `op1` and `op2` + * Example: + * --- + * int4 a = [1, 2, 3, 4]; + * int4 b = [5, 6, 7, 8]; + * int4 mask1 = [0, 1, 1, 3]; + * int4 mask2 = [0, 4, 2, 5]; + * assert(shuffle(a, mask1).array == [1, 2, 2, 4]); + * assert(shuffle(a, b, mask2).array == [1, 5, 3, 6]); + * --- + */ +template shuffle(V0, V1, M) +{ + static assert(isVectorType!V0, "first argument must be vector"); + static assert(isVectorType!V1, "second argument must be vector"); + static assert(is(BaseType!V0 == BaseType!V1), + "first and second argument vectors must have the same element type"); + static assert(isVectorType!M && is(BaseType!M : long), + "last argument must be an integer vector"); + static assert(numElements!V0 == numElements!M && numElements!V1 == numElements!M, + "argument vectors and mask vector should have the same number of elements"); + static assert(BaseType!V0.sizeof == BaseType!M.sizeof, + "argument vectors and mask vector should have the same element type size"); + + V0 shuffle(V0 op1, V1 op2, M mask); +} + +/// Ditto +template shuffle(V, M) +{ + static assert(isVectorType!V, "first argument must be a vector"); + static assert(isVectorType!M && is(BaseType!M : long), + "last argument must be an integer vector"); + static assert(numElements!V == numElements!M, + "argument vector and mask vector should have the same number of elements"); + static assert(BaseType!V.sizeof == BaseType!M.sizeof, + "argument vector and mask vector should have the same element type size"); + + V shuffle(V op1, M mask) + { + return shuffle(op1, op1, mask); + } +} + +/** + * Construct a permutation of elements from two vectors, returning a vector with + * the same element type as the input vector(s), and same length as the `mask`. + * Params: + * op1 = input vector + * op2 = input vector + * index = elements indices of the vectors that should be extracted and returned + * Returns: + * vector with the same element type as `op1` and `op2`, but has an element count + * equal to the number of indices in `index`. + * Example: + * --- + * int8 a = [1, -2, 3, -4, 5, -6, 7, -8]; + * int4 b = shufflevector(a, a, 0, 2, 4, 6); + * assert(b.array == [1, 3, 5, 7]); + * int4 c = [-2, -4, -6, -8]; + * int d = shufflevector(c, b, 4, 0, 5, 1, 6, 2, 7, 3); + * assert(d.array == a.array); + * --- + */ +template shufflevector(V1, V2, M...) +{ + static assert(isVectorType!V1, "first argument must be vector"); + static assert(isVectorType!V2, "second argument must be vector"); + static assert(is(BaseType!V1 == BaseType!V2), + "first and second argument vectors must have the same element type"); + static assert(isPowerOf2!(M.length), + "number of index arguments must be a power of 2"); + + __vector(BaseType!V1[M.length]) shufflevector(V1 op1, V2 op2, M index); +} + +/// Ditto +template shufflevector(V, index...) +{ + // Defined for compatibility with LDC. + static assert(isVectorType!V, "first argument must be a vector type"); + static assert(numElements!V == index.length, + "number of index arguments must be the same number of vector elements"); + + private template ctfeConstants(m...) + { + static if (m.length == 0) enum ctfeConstants = 1; + else enum ctfeConstants = m[0] | ctfeConstants!(m[1 .. $]); + } + static assert(__traits(compiles, ctfeConstants!index), + "all index arguments must be compile time constants"); + + private template validIndexes(m...) + { + static if (m.length == 0) enum validIndexes = true; + else enum validIndexes = (cast(long)m[0] > -1) && validIndexes!(m[1 .. $]); + } + static assert(validIndexes!index, + "all index arguments must be greater than or equal to 0"); + + V shufflevector(V op1, V op2) + { + return shufflevector(op1, op2, index); + } +} + +/** + * Extracts a single scalar element from a vector at a specified index. + * Defined for compatibility with LDC. + * Params: + * val = vector to extract element from + * idx = index indicating the position from which to extract the element + * Returns: + * scalar of the same type as the element type of val + * Example: + * --- + * int4 a = [0, 10, 20, 30]; + * int k = extractelement!(int4, 2)(a); + * assert(k == 20); + * --- + */ +BaseType!V extractelement(V, int idx)(V val) + if (isVectorType!V && idx < numElements!V) +{ + return val[idx]; +} + +/** + * Inserts a scalar element into a vector at a specified index. + * Defined for compatibility with LDC. + * Params: + * val = vector to assign element to + * elt = scalar whose type is the element type of val + * idx = index indicating the position from which to extract the element + * Returns: + * vector of the same type as val + * Example: + * --- + * int4 a = [0, 10, 20, 30]; + * int4 b = insertelement!(int4, 2)(a, 50); + * assert(b.array == [0, 10, 50, 30]); + * --- + */ +V insertelement(V, int idx)(V val, BaseType!V elt) + if (isVectorType!V && idx < numElements!V) +{ + val[idx] = elt; + return val; +} + +/** + * Convert a vector from one integral or floating vector type to another. + * The result is an integral or floating vector that has had every element + * cast to the element type of the return type. + * Params: + * from = input vector + * Returns: + * converted vector + * Example: + * --- + * int4 a = [1, -2, 3, -4]; + * float4 b = [1.5, -2.5, 3, 7]; + * assert(convertvector!float4(a).array == [1, -2, 3, -4]); + * assert(convertvector!double4(a).array == [1, -2, 3, -4]); + * assert(convertvector!double4(b).array == [1.5, -2.5, 3, 7]); + * assert(convertvector!int4(b).array == [1, -2, 3, 7]); + * --- + */ + +template convertvector(V, T) +{ + static assert(isVectorType!V && (is(BaseType!V : long) || is(BaseType!V : real)), + "first argument must be an integer or floating vector type"); + static assert(isVectorType!T && (is(BaseType!T : long) || is(BaseType!T : real)), + "second argument must be an integer or floating vector"); + static assert(numElements!V == numElements!T, + "first and second argument vectors should have the same number of elements"); + + V convertvector(T); +} + +/** + * Construct a conditional merge of elements from two vectors, returning a + * vector of the same type as the input vector(s). The `mask` is an integral + * vector with the same width and element count as the output vector. + * Params: + * op1 = input vector + * op2 = input vector + * mask = integer vector mask + * Returns: + * vector with the same type as `op1` and `op2` + * Example: + * --- + * int4 a = [1, 2, 3, 4]; + * int4 b = [5, 6, 7, 8]; + * int4 mask1 = [0, 1, 1, 3]; + * int4 mask2 = [0, 4, 2, 5]; + * assert(shuffle(a, mask1).array == [1, 2, 2, 4]); + * assert(shuffle(a, b, mask2).array == [1, 5, 3, 6]); + * --- + */ +template blendvector(V0, V1, M) +{ + static assert(isVectorType!V0, "first argument must be vector"); + static assert(isVectorType!V1, "second argument must be vector"); + static assert(is(BaseType!V0 == BaseType!V1), + "first and second argument vectors must have the same element type"); + static assert(isVectorType!M && is(BaseType!M : long), + "last argument must be an integer vector"); + static assert(numElements!V0 == numElements!M && numElements!V1 == numElements!M, + "argument vectors and mask vector should have the same number of elements"); + static assert(BaseType!V0.sizeof == BaseType!M.sizeof, + "argument vectors and mask vector should have the same element type size"); + + V0 blendvector(V0 op1, V1 op2, M mask); +} + +/** + * Perform an element-wise comparison between two vectors, producing `0` when + * the comparison is false and `-1` (all bits are set to 1) otherwise. + * Params: + * op1 = input vector + * op2 = input vector + * Returns: + * vector of the same width and number of elements as the comparison + * operands with a signed integral element type + * Example: + * --- + * float4 a = [1, 3, 5, 7]; + * float4 b = [2, 3, 4, 5]; + * int4 c = greaterMask!float4(a, b); + * assert(c.array == [0, 0, -1, -1]); + * --- + */ +V equalMask(V)(V op1, V op2) if (isVectorType!V); +/// Ditto +V notEqualMask(V)(V op1, V op2) if (isVectorType!V); +/// Ditto +V greaterMask(V)(V op1, V op2) if (isVectorType!V); +/// Ditto +V greaterOrEqualMask(V)(V op1, V op2) if (isVectorType!V); + +/** + * Perform an element-wise logical comparison between two vectors, producing + * `0` when the comparison is false and `-1` (all bits are set to 1) otherwise. + * Params: + * op1 = input vector + * op2 = input vector + * Returns: + * vector of the same width and number of elements as the comparison + * operands with a signed integral element type + */ +V notMask(V)(V op1) if (isVectorType!V) +{ + return equalMask(op1, 0); +} + +/// Ditto +V andAndMask(V)(V op1, V op2) if (isVectorType!V) +{ + return notEqualMask(op1, 0) & notEqualMask(op2, 0); +} + +/// Ditto +V orOrMask(V)(V op1, V op2) if (isVectorType!V) +{ + return notEqualMask(op1, 0) | notEqualMask(op2, 0); +} + +// Private helper templates. +private: + +enum bool isVectorType(T) = is(T : __vector(V[N]), V, size_t N); + +template BaseType(V) +{ + alias typeof(V.array[0]) BaseType; +} + +template numElements(V) +{ + enum numElements = V.sizeof / BaseType!(V).sizeof; +} + +enum bool isPowerOf2(int Y) = Y && (Y & -Y) == Y; diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d index 7bb6bec..fe65c09 100644 --- a/libphobos/libdruntime/object.d +++ b/libphobos/libdruntime/object.d @@ -1481,7 +1481,7 @@ class TypeInfo_Delegate : TypeInfo override size_t getHash(scope const void* p) @trusted const { - return hashOf(*cast(void delegate()*)p); + return hashOf(*cast(const void delegate() *)p); } override bool equals(in void* p1, in void* p2) const @@ -1885,8 +1885,8 @@ class TypeInfo_Struct : TypeInfo return false; else if (xopEquals) { - const dg = _memberFunc(p2, xopEquals); - return dg.xopEquals(p1); + const dg = _memberFunc(p1, xopEquals); + return dg.xopEquals(p2); } else if (p1 == p2) return true; @@ -2649,13 +2649,18 @@ class Throwable : Object /** * Get the message describing the error. - * Base behavior is to return the `Throwable.msg` field. - * Override to return some other error message. + * + * This getter is an alternative way to access the Exception's message, + * with the added advantage of being override-able in subclasses. + * Subclasses are hence free to do their own memory managements without + * being tied to the requirement of providing a `string` in a field. + * + * The default behavior is to return the `Throwable.msg` field. * * Returns: - * Error message + * A message representing the cause of the `Throwable` */ - @__future const(char)[] message() const + @__future const(char)[] message() const @safe nothrow { return this.msg; } @@ -2825,8 +2830,8 @@ extern (C) private struct AA { void* impl; } // size_t _aaLen(in AA aa) pure nothrow @nogc; - private void* _aaGetY(AA* paa, const TypeInfo_AssociativeArray ti, const size_t valsz, const scope void* pkey) pure nothrow; - private void* _aaGetX(AA* paa, const TypeInfo_AssociativeArray ti, const size_t valsz, const scope void* pkey, out bool found) pure nothrow; + private void* _aaGetY(scope AA* paa, const TypeInfo_AssociativeArray ti, const size_t valsz, const scope void* pkey) pure nothrow; + private void* _aaGetX(scope AA* paa, const TypeInfo_AssociativeArray ti, const size_t valsz, const scope void* pkey, out bool found) pure nothrow; // inout(void)* _aaGetRvalueX(inout AA aa, in TypeInfo keyti, in size_t valsz, in void* pkey); inout(void[]) _aaValues(inout AA aa, const size_t keysz, const size_t valsz, const TypeInfo tiValueArray) pure nothrow; inout(void[]) _aaKeys(inout AA aa, const size_t keysz, const TypeInfo tiKeyArray) pure nothrow; @@ -4423,7 +4428,7 @@ nothrow @safe @nogc unittest } } -private extern (C) void rt_finalize(void *data, bool det=true) nothrow; +private extern (C) void rt_finalize2(void* p, bool det = true, bool resetMemory = true) nothrow; /// ditto void destroy(bool initialize = true, T)(T obj) if (is(T == class)) @@ -4440,7 +4445,11 @@ void destroy(bool initialize = true, T)(T obj) if (is(T == class)) } } else - rt_finalize(cast(void*)obj); + { + // Bypass overloaded opCast + auto ptr = (() @trusted => *cast(void**) &obj)(); + rt_finalize2(ptr, true, initialize); + } } /// ditto @@ -4702,6 +4711,37 @@ nothrow unittest assert(C.dtorCount == 1); } +// https://issues.dlang.org/show_bug.cgi?id=22832 +nothrow unittest +{ + static struct A {} + static class B + { + A opCast(T : A)() { return A(); } + } + + destroy(B.init); +} + +// make sure destroy!false skips re-initialization +unittest +{ + static struct S { int x; } + static class C { int x; } + static extern(C++) class Cpp { int x; } + + static void test(T)(T inst) + { + inst.x = 123; + destroy!false(inst); + assert(inst.x == 123, T.stringof); + } + + test(S()); + test(new C()); + test(new Cpp()); +} + /// ditto void destroy(bool initialize = true, T)(ref T obj) if (__traits(isStaticArray, T)) @@ -4861,7 +4901,8 @@ they are only intended to be instantiated by the compiler, not the user. public import core.internal.entrypoint : _d_cmain; -public import core.internal.array.appending : _d_arrayappendTImpl; +public import core.internal.array.appending : _d_arrayappendT; +public import core.internal.array.appending : _d_arrayappendTTrace; public import core.internal.array.appending : _d_arrayappendcTXImpl; public import core.internal.array.comparison : __cmp; public import core.internal.array.equality : __equals; diff --git a/libphobos/libdruntime/rt/aApply.d b/libphobos/libdruntime/rt/aApply.d index bea441f..5d5ddb3 100644 --- a/libphobos/libdruntime/rt/aApply.d +++ b/libphobos/libdruntime/rt/aApply.d @@ -1,7 +1,5 @@ /** - * This code handles decoding UTF strings for foreach loops. There are 6 - * combinations of conversions between char, wchar, and dchar, and 2 of each - * of those. + * This code handles decoding UTF strings for foreach loops. * * Copyright: Copyright Digital Mars 2004 - 2010. * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). @@ -15,9 +13,64 @@ import core.internal.utf : decode, toUTF8; /**********************************************/ /* 1 argument versions */ -// dg is D, but _aApplycd() is C -extern (D) alias int delegate(void *) dg_t; +/** +Delegate type corresponding to transformed loop body + +The parameter is a pointer to the current `char`, `wchar` or `dchar` + +Returns: non-zero when a `break` statement is hit +*/ +extern (D) alias dg_t = int delegate(void* c); + +// Note: dg is extern(D), but _aApplycd() is extern(C) + +/** +Loop over a string while changing the UTF encoding + +There are 6 combinations of conversions between `char`, `wchar`, and `dchar`, +and 2 of each of those. + +The naming convention is as follows: + +_aApply{c,d,w}{c,d,w}{1,2} +The first letter corresponds to the input string encoding, and the second letter corresponds to the target character type. + +- c = `char` +- w = `wchar` +- d = `dchar` + +The `1` variant only produces the character, the `2` variant also produces a loop index. + +Examples: +--- +void main() +{ + string str; + wtring wstr; + dstring dstr; + + foreach (dchar c; str) {} + // _aApplycd1 + + foreach (wchar c; dstr) {} + // _aApplydw1 + + foreach (i, wchar c; str) {} + // _aApplycw2 + + foreach (wchar w; wstr) {} + // no conversion +} +--- + +Params: + aa = input string + dg = foreach body transformed into a delegate, similar to `opApply` + +Returns: + non-zero when the loop was exited through a `break` +*/ extern (C) int _aApplycd1(in char[] aa, dg_t dg) { int result; @@ -78,8 +131,7 @@ unittest assert(i == 4); } -/*****************************/ - +/// ditto extern (C) int _aApplywd1(in wchar[] aa, dg_t dg) { int result; @@ -140,8 +192,7 @@ unittest assert(i == 4); } -/*****************************/ - +/// ditto extern (C) int _aApplycw1(in char[] aa, dg_t dg) { int result; @@ -215,8 +266,7 @@ unittest assert(i == 5); } -/*****************************/ - +/// ditto extern (C) int _aApplywc1(in wchar[] aa, dg_t dg) { int result; @@ -296,8 +346,7 @@ unittest assert(i == 9); } -/*****************************/ - +/// ditto extern (C) int _aApplydc1(in dchar[] aa, dg_t dg) { int result; @@ -373,8 +422,7 @@ unittest assert(i == 9); } -/*****************************/ - +/// ditto extern (C) int _aApplydw1(in dchar[] aa, dg_t dg) { int result; @@ -446,9 +494,20 @@ unittest /****************************************************************************/ /* 2 argument versions */ -// dg is D, but _aApplycd2() is C -extern (D) alias int delegate(void *, void *) dg2_t; +/** +Delegate type corresponding to transformed loop body + +Parameters are pointers to a `size_t` loop index, and the current `char`, `wchar` or `dchar`. +Returns: non-zero when a `break` statement is hit +*/ +extern (D) alias dg2_t = int delegate(void* i, void* c); + +// Note: dg is extern(D), but _aApplycd2() is extern(C) + +/** +Variants of _aApplyXXX that include a loop index. +*/ extern (C) int _aApplycd2(in char[] aa, dg2_t dg) { int result; @@ -516,8 +575,7 @@ unittest assert(i == 4); } -/*****************************/ - +/// ditto extern (C) int _aApplywd2(in wchar[] aa, dg2_t dg) { int result; @@ -585,8 +643,7 @@ unittest assert(i == 4); } -/*****************************/ - +/// ditto extern (C) int _aApplycw2(in char[] aa, dg2_t dg) { int result; @@ -665,8 +722,7 @@ unittest assert(i == 5); } -/*****************************/ - +/// ditto extern (C) int _aApplywc2(in wchar[] aa, dg2_t dg) { int result; @@ -751,8 +807,7 @@ unittest assert(i == 9); } -/*****************************/ - +/// ditto extern (C) int _aApplydc2(in dchar[] aa, dg2_t dg) { int result; @@ -832,8 +887,7 @@ unittest assert(i == 9); } -/*****************************/ - +/// ditto extern (C) int _aApplydw2(in dchar[] aa, dg2_t dg) { int result; diff --git a/libphobos/libdruntime/rt/aApplyR.d b/libphobos/libdruntime/rt/aApplyR.d index 7f19fa8..ce3bb9e 100644 --- a/libphobos/libdruntime/rt/aApplyR.d +++ b/libphobos/libdruntime/rt/aApplyR.d @@ -1,7 +1,5 @@ /** - * This code handles decoding UTF strings for foreach_reverse loops. There are - * 6 combinations of conversions between char, wchar, and dchar, and 2 of each - * of those. + * This code handles decoding UTF strings for `foreach_reverse` loops. * * Copyright: Copyright Digital Mars 2004 - 2010. * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). @@ -15,9 +13,27 @@ import core.internal.utf; /**********************************************/ /* 1 argument versions */ -// dg is D, but _aApplyRcd() is C -extern (D) alias int delegate(void *) dg_t; +// Note: dg is extern(D), but _aApplyRcd() is extern(C) +/** +Delegate type corresponding to transformed loop body + +The parameter is a pointer to the current `char`, `wchar` or `dchar` + +Returns: non-zero when a `break` statement is hit +*/ +extern (D) alias dg_t = int delegate(void* c); + +/** +Same as `_aApplyXXX` functions, but for `foreach_reverse` + +Params: + aa = input string + dg = foreach body transformed into a delegate, similar to `opApply` + +Returns: + non-zero when the loop was exited through a `break` +*/ extern (C) int _aApplyRcd1(in char[] aa, dg_t dg) { int result; @@ -90,8 +106,7 @@ unittest assert(i == 4); } -/*****************************/ - +/// ditto extern (C) int _aApplyRwd1(in wchar[] aa, dg_t dg) { int result; @@ -154,8 +169,7 @@ unittest assert(i == 4); } -/*****************************/ - +/// ditto extern (C) int _aApplyRcw1(in char[] aa, dg_t dg) { int result; @@ -241,8 +255,7 @@ unittest assert(i == 5); } -/*****************************/ - +/// ditto extern (C) int _aApplyRwc1(in wchar[] aa, dg_t dg) { int result; @@ -326,8 +339,7 @@ unittest assert(i == 9); } -/*****************************/ - +/// ditto extern (C) int _aApplyRdc1(in dchar[] aa, dg_t dg) { int result; @@ -405,8 +417,7 @@ unittest assert(i == 9); } -/*****************************/ - +/// ditto extern (C) int _aApplyRdw1(in dchar[] aa, dg_t dg) { int result; @@ -477,9 +488,20 @@ unittest /****************************************************************************/ /* 2 argument versions */ -// dg is D, but _aApplyRcd2() is C -extern (D) alias int delegate(void *, void *) dg2_t; +/** +Delegate type corresponding to transformed loop body + +Parameters are pointers to a `size_t` loop index, and the current `char`, `wchar` or `dchar`. +Returns: non-zero when a `break` statement is hit +*/ +extern (D) alias dg2_t = int delegate(void* i, void* c); + +// Note: dg is extern(D), but _aApplyRcd2() is extern(C) + +/** +Variants of _aApplyRXXX that include a loop index. +*/ extern (C) int _aApplyRcd2(in char[] aa, dg2_t dg) { int result; size_t i; @@ -555,8 +577,7 @@ unittest assert(i == 4); } -/*****************************/ - +/// ditto extern (C) int _aApplyRwd2(in wchar[] aa, dg2_t dg) { int result; @@ -621,8 +642,7 @@ unittest assert(i == 4); } -/*****************************/ - +/// ditto extern (C) int _aApplyRcw2(in char[] aa, dg2_t dg) { int result; @@ -710,8 +730,7 @@ unittest assert(i == 5); } -/*****************************/ - +/// ditto extern (C) int _aApplyRwc2(in wchar[] aa, dg2_t dg) { int result; @@ -797,8 +816,7 @@ unittest assert(i == 9); } -/*****************************/ - +/// ditto extern (C) int _aApplyRdc2(in dchar[] aa, dg2_t dg) { int result; @@ -877,8 +895,7 @@ unittest assert(i == 9); } -/*****************************/ - +/// ditto extern (C) int _aApplyRdw2(in dchar[] aa, dg2_t dg) { int result; diff --git a/libphobos/libdruntime/rt/aaA.d b/libphobos/libdruntime/rt/aaA.d index 0c38622..f264b01 100644 --- a/libphobos/libdruntime/rt/aaA.d +++ b/libphobos/libdruntime/rt/aaA.d @@ -50,7 +50,7 @@ struct AA private struct Impl { private: - this(scope const TypeInfo_AssociativeArray ti, size_t sz = INIT_NUM_BUCKETS) + this(scope const TypeInfo_AssociativeArray ti, size_t sz = INIT_NUM_BUCKETS) nothrow { keysz = cast(uint) ti.key.tsize; valsz = cast(uint) ti.value.tsize; @@ -125,7 +125,7 @@ private: } } - void grow(scope const TypeInfo keyti) + void grow(scope const TypeInfo keyti) pure nothrow { // If there are so many deleted entries, that growing would push us // below the shrink threshold, we just purge deleted entries instead. @@ -135,7 +135,7 @@ private: resize(GROW_FAC * dim); } - void shrink(scope const TypeInfo keyti) + void shrink(scope const TypeInfo keyti) pure nothrow { if (dim > INIT_NUM_BUCKETS) resize(dim / GROW_FAC); @@ -233,7 +233,7 @@ package void entryDtor(void* p, const TypeInfo_Struct sti) extra[1].destroy(p + talign(extra[0].tsize, extra[1].talign)); } -private bool hasDtor(const TypeInfo ti) +private bool hasDtor(const TypeInfo ti) pure nothrow { import rt.lifetime : unqualify; @@ -246,7 +246,7 @@ private bool hasDtor(const TypeInfo ti) return false; } -private immutable(void)* getRTInfo(const TypeInfo ti) +private immutable(void)* getRTInfo(const TypeInfo ti) pure nothrow { // classes are references const isNoClass = ti && typeid(ti) !is typeid(TypeInfo_Class); @@ -254,7 +254,7 @@ private immutable(void)* getRTInfo(const TypeInfo ti) } // build type info for Entry with additional key and value fields -TypeInfo_Struct fakeEntryTI(ref Impl aa, const TypeInfo keyti, const TypeInfo valti) +TypeInfo_Struct fakeEntryTI(ref Impl aa, const TypeInfo keyti, const TypeInfo valti) nothrow { import rt.lifetime : unqualify; @@ -319,7 +319,8 @@ TypeInfo_Struct fakeEntryTI(ref Impl aa, const TypeInfo keyti, const TypeInfo va } // build appropriate RTInfo at runtime -immutable(void)* rtinfoEntry(ref Impl aa, immutable(size_t)* keyinfo, immutable(size_t)* valinfo, size_t* rtinfoData, size_t rtinfoSize) +immutable(void)* rtinfoEntry(ref Impl aa, immutable(size_t)* keyinfo, + immutable(size_t)* valinfo, size_t* rtinfoData, size_t rtinfoSize) pure nothrow { enum bitsPerWord = 8 * size_t.sizeof; @@ -456,7 +457,7 @@ private size_t mix(size_t h) @safe pure nothrow @nogc return h; } -private size_t calcHash(scope const void* pkey, scope const TypeInfo keyti) +private size_t calcHash(scope const void* pkey, scope const TypeInfo keyti) nothrow { immutable hash = keyti.getHash(pkey); // highest bit is set to distinguish empty/deleted from filled buckets @@ -485,6 +486,18 @@ pure nothrow @nogc unittest // API Implementation //------------------------------------------------------------------------------ +/** Allocate associative array data. + * Called for `new SomeAA` expression. + * Params: + * ti = TypeInfo for the associative array + * Returns: + * A new associative array. + */ +extern (C) Impl* _aaNew(const TypeInfo_AssociativeArray ti) +{ + return new Impl(ti); +} + /// Determine number of entries in associative array. extern (C) size_t _aaLen(scope const AA aa) pure nothrow @nogc { @@ -504,7 +517,7 @@ extern (C) size_t _aaLen(scope const AA aa) pure nothrow @nogc * If key was not in the aa, a mutable pointer to newly inserted value which * is set to all zeros */ -extern (C) void* _aaGetY(AA* paa, const TypeInfo_AssociativeArray ti, +extern (C) void* _aaGetY(scope AA* paa, const TypeInfo_AssociativeArray ti, const size_t valsz, scope const void* pkey) { bool found; @@ -525,7 +538,7 @@ extern (C) void* _aaGetY(AA* paa, const TypeInfo_AssociativeArray ti, * If key was not in the aa, a mutable pointer to newly inserted value which * is set to all zeros */ -extern (C) void* _aaGetX(AA* paa, const TypeInfo_AssociativeArray ti, +extern (C) void* _aaGetX(scope AA* paa, const TypeInfo_AssociativeArray ti, const size_t valsz, scope const void* pkey, out bool found) { // lazily alloc implementation @@ -736,7 +749,15 @@ extern (C) int _aaApply2(AA aa, const size_t keysz, dg2_t dg) return 0; } -/// Construct an associative array of type ti from keys and value +/** Construct an associative array of type ti from corresponding keys and values. + * Called for an AA literal `[k1:v1, k2:v2]`. + * Params: + * ti = TypeInfo for the associative array + * keys = array of keys + * vals = array of values + * Returns: + * A new associative array opaque pointer, or null if `keys` is empty. + */ extern (C) Impl* _d_assocarrayliteralTX(const TypeInfo_AssociativeArray ti, void[] keys, void[] vals) { diff --git a/libphobos/libdruntime/rt/arrayassign.d b/libphobos/libdruntime/rt/arrayassign.d index 21d50b0..c9db2fc 100644 --- a/libphobos/libdruntime/rt/arrayassign.d +++ b/libphobos/libdruntime/rt/arrayassign.d @@ -19,8 +19,10 @@ private debug(PRINTF) import core.stdc.stdio; } -/** - * Keep for backward binary compatibility. This function can be removed in the future. +/* + * Superseded array assignment hook. Does not take into account destructors: + * https://issues.dlang.org/show_bug.cgi?id=13661 + * Kept for backward binary compatibility. This function can be removed in the future. */ extern (C) void[] _d_arrayassign(TypeInfo ti, void[] from, void[] to) { @@ -40,15 +42,44 @@ extern (C) void[] _d_arrayassign(TypeInfo ti, void[] from, void[] to) } /** - * Does array assignment (not construction) from another - * lvalue array of the same element type. - * Handles overlapping copies. - * Input: - * ti TypeInfo of the element type. - * dst Points target memory. Its .length is equal to the element count, not byte length. - * src Points source memory. Its .length is equal to the element count, not byte length. - * ptmp Temporary memory for element swapping. - */ +Does array assignment (not construction) from another array of the same +element type. + +Handles overlapping copies. + +The `_d_arrayassign_l` variant assumes the right hand side is an lvalue, +while `_d_arrayassign_r` assumes it's an rvalue, which means it doesn't have to call copy constructors. + +Used for static array assignment with non-POD element types: +--- +struct S +{ + ~this() {} // destructor, so not Plain Old Data +} + +void main() +{ + S[3] arr; + S[3] lvalue; + + arr = lvalue; + // Generates: + // S _tmp; + // _d_arrayassign_l(typeid(S), (cast(void*) lvalue.ptr)[0..lvalue.length], (cast(void*) arr.ptr)[0..arr.length], &_tmp); + + S[3] getRvalue() {return lvalue;} + arr = getRvalue(); + // Similar, but `_d_arrayassign_r` +} +--- + +Params: + ti = `TypeInfo` of the array element type. + dst = target memory. Its `.length` is equal to the element count, not byte length. + src = source memory. Its `.length` is equal to the element count, not byte length. + ptmp = Temporary memory for element swapping, must have capacity of `ti.tsize` bytes. +Returns: `dst` +*/ extern (C) void[] _d_arrayassign_l(TypeInfo ti, void[] src, void[] dst, void* ptmp) { debug(PRINTF) printf("_d_arrayassign_l(src = %p,%d, dst = %p,%d) size = %d\n", src.ptr, src.length, dst.ptr, dst.length, ti.tsize); @@ -131,16 +162,7 @@ unittest // Bugzilla 14024 assert(op == "YzXy", op); } -/** - * Does array assignment (not construction) from another - * rvalue array of the same element type. - * Input: - * ti TypeInfo of the element type. - * dst Points target memory. Its .length is equal to the element count, not byte length. - * src Points source memory. Its .length is equal to the element count, not byte length. - * It is always allocated on stack and never overlapping with dst. - * ptmp Temporary memory for element swapping. - */ +/// ditto extern (C) void[] _d_arrayassign_r(TypeInfo ti, void[] src, void[] dst, void* ptmp) { debug(PRINTF) printf("_d_arrayassign_r(src = %p,%d, dst = %p,%d) size = %d\n", src.ptr, src.length, dst.ptr, dst.length, ti.tsize); @@ -163,48 +185,22 @@ extern (C) void[] _d_arrayassign_r(TypeInfo ti, void[] src, void[] dst, void* pt } /** - * Does array initialization (not assignment) from another - * array of the same element type. - * ti is the element type. - */ -extern (C) void[] _d_arrayctor(TypeInfo ti, void[] from, void[] to) -{ - debug(PRINTF) printf("_d_arrayctor(from = %p,%d, to = %p,%d) size = %d\n", from.ptr, from.length, to.ptr, to.length, ti.tsize); - - - auto element_size = ti.tsize; - - enforceRawArraysConformable("initialization", element_size, from, to); - - size_t i; - try - { - for (i = 0; i < to.length; i++) - { - // Copy construction is defined as bit copy followed by postblit. - memcpy(to.ptr + i * element_size, from.ptr + i * element_size, element_size); - ti.postblit(to.ptr + i * element_size); - } - } - catch (Throwable o) - { - /* Destroy, in reverse order, what we've constructed so far - */ - while (i--) - { - ti.destroy(to.ptr + i * element_size); - } - - throw o; - } - return to; -} - - -/** - * Do assignment to an array. - * p[0 .. count] = value; - */ +Set all elements of an array to a single value. + +--- +p[0 .. count] = value; +--- + +Takes into account postblits and destructors, for Plain Old Data elements, +`rt/memset.d` is used. + +Params: + p = pointer to start of array + value = bytes of the element to set. Size is derived from `ti`. + count = amount of array elements to set + ti = type info of the array element type / `value` +Returns: `p` +*/ extern (C) void* _d_arraysetassign(void* p, void* value, int count, TypeInfo ti) { void* pstart = p; @@ -227,36 +223,3 @@ extern (C) void* _d_arraysetassign(void* p, void* value, int count, TypeInfo ti) free(ptmp); return pstart; } - -/** - * Do construction of an array. - * ti[count] p = value; - */ -extern (C) void* _d_arraysetctor(void* p, void* value, int count, TypeInfo ti) -{ - void* pstart = p; - auto element_size = ti.tsize; - - try - { - foreach (i; 0 .. count) - { - // Copy construction is defined as bit copy followed by postblit. - memcpy(p, value, element_size); - ti.postblit(p); - p += element_size; - } - } - catch (Throwable o) - { - // Destroy, in reverse order, what we've constructed so far - while (p > pstart) - { - p -= element_size; - ti.destroy(p); - } - - throw o; - } - return pstart; -} diff --git a/libphobos/libdruntime/rt/critical_.d b/libphobos/libdruntime/rt/critical_.d index ae18122..36552a3 100644 --- a/libphobos/libdruntime/rt/critical_.d +++ b/libphobos/libdruntime/rt/critical_.d @@ -18,13 +18,13 @@ nothrow: import rt.monitor_, core.atomic; -extern (C) void _d_critical_init() +extern (C) void _d_critical_init() @nogc nothrow { initMutex(cast(Mutex*)&gcs.mtx); head = &gcs; } -extern (C) void _d_critical_term() +extern (C) void _d_critical_term() @nogc nothrow { // This function is only ever called by the runtime shutdown code // and therefore is single threaded so the following cast is fine. diff --git a/libphobos/libdruntime/rt/dmain2.d b/libphobos/libdruntime/rt/dmain2.d index 47b67f1..0739b74 100644 --- a/libphobos/libdruntime/rt/dmain2.d +++ b/libphobos/libdruntime/rt/dmain2.d @@ -62,22 +62,21 @@ struct UnitTestResult bool summarize; } -extern (C) void _d_monitor_staticctor(); -extern (C) void _d_monitor_staticdtor(); -extern (C) void _d_critical_init(); -extern (C) void _d_critical_term(); +extern (C) void _d_monitor_staticctor() @nogc nothrow; +extern (C) void _d_monitor_staticdtor() @nogc nothrow; +extern (C) void _d_critical_init() @nogc nothrow; +extern (C) void _d_critical_term() @nogc nothrow; extern (C) void gc_init(); extern (C) void gc_term(); -extern (C) void thread_init() @nogc; -extern (C) void thread_term() @nogc; -extern (C) void lifetime_init(); +extern (C) void thread_init() @nogc nothrow; +extern (C) void thread_term() @nogc nothrow; extern (C) void rt_moduleCtor(); extern (C) void rt_moduleTlsCtor(); extern (C) void rt_moduleDtor(); extern (C) void rt_moduleTlsDtor(); extern (C) void thread_joinAll(); extern (C) UnitTestResult runModuleUnitTests(); -extern (C) void _d_initMonoTime(); +extern (C) void _d_initMonoTime() @nogc nothrow; version (CRuntime_Microsoft) { @@ -134,7 +133,6 @@ extern (C) int rt_init() thread_init(); // TODO: fixme - calls GC.addRange -> Initializes GC initStaticDataGC(); - lifetime_init(); rt_moduleCtor(); rt_moduleTlsCtor(); return 1; @@ -669,7 +667,7 @@ extern (C) void _d_print_throwable(Throwable t) void sink(in char[] buf) scope nothrow { - fprintf(stderr, "%.*s", cast(int)buf.length, buf.ptr); + fwrite(buf.ptr, char.sizeof, buf.length, stderr); } formatThrowable(t, &sink); } diff --git a/libphobos/libdruntime/rt/ehalloc.d b/libphobos/libdruntime/rt/ehalloc.d index 1dcd69a..65f92e3 100644 --- a/libphobos/libdruntime/rt/ehalloc.d +++ b/libphobos/libdruntime/rt/ehalloc.d @@ -18,51 +18,6 @@ debug(PRINTF) import core.stdc.stdio; } -/********************************************** - * Allocate an exception of type `ci` from the exception pool. - * It has the same interface as `rt.lifetime._d_newclass()`. - * The class type must be Throwable or derived from it, - * and cannot be a COM or C++ class. The compiler must enforce - * this. - * Returns: - * default initialized instance of the type - */ - -extern (C) Throwable _d_newThrowable(const TypeInfo_Class ci) -{ - debug(PRINTF) printf("_d_newThrowable(ci = %p, %s)\n", ci, cast(char *)ci.name); - - assert(!(ci.m_flags & TypeInfo_Class.ClassFlags.isCOMclass)); - assert(!(ci.m_flags & TypeInfo_Class.ClassFlags.isCPPclass)); - - import core.stdc.stdlib : malloc; - auto init = ci.initializer; - void* p = malloc(init.length); - if (!p) - { - import core.exception : onOutOfMemoryError; - onOutOfMemoryError(); - } - - debug(PRINTF) printf(" p = %p\n", p); - - // initialize it - p[0 .. init.length] = init[]; - - if (!(ci.m_flags & TypeInfo_Class.ClassFlags.noPointers)) - { - // Inform the GC about the pointers in the object instance - import core.memory : GC; - - GC.addRange(p, init.length, ci); - } - - debug(PRINTF) printf("initialization done\n"); - Throwable t = cast(Throwable)p; - t.refcount() = 1; - return t; -} - /******************************************** * Delete exception instance `t` from the exception pool. diff --git a/libphobos/libdruntime/rt/lifetime.d b/libphobos/libdruntime/rt/lifetime.d index 1f7a81d..026001f 100644 --- a/libphobos/libdruntime/rt/lifetime.d +++ b/libphobos/libdruntime/rt/lifetime.d @@ -40,22 +40,47 @@ private } } -extern (C) void lifetime_init() +// Now-removed symbol, kept around for ABI +// Some programs are dynamically linked, so best to err on the side of keeping symbols around for a while (especially extern(C) ones) +// https://github.com/dlang/druntime/pull/3361 +deprecated extern (C) void lifetime_init() { - // this is run before static ctors, so it is safe to modify immutables } /** - * - */ +Allocate memory using the garbage collector + +DMD uses this to allocate closures: +--- +void f(byte[24] x) +{ + return () => x; // `x` is on stack, must be moved to heap to keep it alive +} +--- + +Params: + sz = number of bytes to allocate + +Returns: pointer to `sz` bytes of free, uninitialized memory, managed by the GC. +*/ extern (C) void* _d_allocmemory(size_t sz) @weak { return GC.malloc(sz); } /** - * - */ +Create a new class instance. + +Allocates memory and sets fields to their initial value, but does not call a constructor. + +--- +new Object() // _d_newclass(typeid(Object)) +--- +Params: + ci = `TypeInfo_Class` object, to provide instance size and initial bytes to copy + +Returns: newly created object +*/ extern (C) Object _d_newclass(const ClassInfo ci) @weak { import core.stdc.stdlib; @@ -163,23 +188,6 @@ extern (C) void _d_delclass(Object* p) @weak } } -/** - * This is called for a delete statement where the value - * being deleted is a pointer to a struct with a destructor - * but doesn't have an overloaded delete operator. - */ -extern (C) void _d_delstruct(void** p, TypeInfo_Struct inf) @weak -{ - if (*p) - { - debug(PRINTF) printf("_d_delstruct(%p, %p)\n", *p, cast(void*)inf); - - inf.destroy(*p); - GC.free(*p); - *p = null; - } -} - // strip const/immutable/shared/inout from type info inout(TypeInfo) unqualify(return scope inout(TypeInfo) cti) pure nothrow @nogc { @@ -367,7 +375,7 @@ bool __setArrayAllocLength(ref BlkInfo info, size_t newlength, bool isshared, co /** get the allocation size of the array for the given block (without padding or type info) */ -size_t __arrayAllocLength(ref BlkInfo info, const TypeInfo tinext) pure nothrow +private size_t __arrayAllocLength(ref BlkInfo info, const TypeInfo tinext) pure nothrow { if (info.size <= 256) return *cast(ubyte *)(info.base + info.size - structTypeInfoSize(tinext) - SMALLPAD); @@ -381,7 +389,7 @@ size_t __arrayAllocLength(ref BlkInfo info, const TypeInfo tinext) pure nothrow /** get the start of the array for the given block */ -void *__arrayStart(return scope BlkInfo info) nothrow pure +private void *__arrayStart(return scope BlkInfo info) nothrow pure { return info.base + ((info.size & BIGLENGTHMASK) ? LARGEPREFIX : 0); } @@ -391,7 +399,7 @@ void *__arrayStart(return scope BlkInfo info) nothrow pure NOT included in the passed in size. Therefore, do NOT call this function with the size of an allocated block. */ -size_t __arrayPad(size_t size, const TypeInfo tinext) nothrow pure @trusted +private size_t __arrayPad(size_t size, const TypeInfo tinext) nothrow pure @trusted { return size > MAXMEDSIZE ? LARGEPAD : ((size > MAXSMALLSIZE ? MEDPAD : SMALLPAD) + structTypeInfoSize(tinext)); } @@ -416,7 +424,7 @@ private void __arrayClearPad(ref BlkInfo info, size_t arrsize, size_t padsize) n allocate an array memory block by applying the proper padding and assigning block attributes if not inherited from the existing block */ -BlkInfo __arrayAlloc(size_t arrsize, const scope TypeInfo ti, const TypeInfo tinext) nothrow pure +private BlkInfo __arrayAlloc(size_t arrsize, const scope TypeInfo ti, const TypeInfo tinext) nothrow pure { import core.checkedint; @@ -438,7 +446,7 @@ BlkInfo __arrayAlloc(size_t arrsize, const scope TypeInfo ti, const TypeInfo tin return bi; } -BlkInfo __arrayAlloc(size_t arrsize, ref BlkInfo info, const scope TypeInfo ti, const TypeInfo tinext) +private BlkInfo __arrayAlloc(size_t arrsize, ref BlkInfo info, const scope TypeInfo ti, const TypeInfo tinext) { import core.checkedint; @@ -461,7 +469,7 @@ BlkInfo __arrayAlloc(size_t arrsize, ref BlkInfo info, const scope TypeInfo ti, /** cache for the lookup of the block info */ -enum N_CACHE_BLOCKS=8; +private enum N_CACHE_BLOCKS=8; // note this is TLS, so no need to sync. BlkInfo *__blkcache_storage; @@ -659,10 +667,15 @@ void __insertBlkInfoCache(BlkInfo bi, BlkInfo *curpos) nothrow } /** - * Shrink the "allocated" length of an array to be the exact size of the array. - * It doesn't matter what the current allocated length of the array is, the - * user is telling the runtime that he knows what he is doing. - */ +Shrink the "allocated" length of an array to be the exact size of the array. + +It doesn't matter what the current allocated length of the array is, the +user is telling the runtime that he knows what he is doing. + +Params: + ti = `TypeInfo` of array type + arr = array to shrink. Its `.length` is element length, not byte length, despite `void` type +*/ extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) /+nothrow+/ { // note, we do not care about shared. We are setting the length no matter @@ -705,7 +718,7 @@ extern(C) void _d_arrayshrinkfit(const TypeInfo ti, void[] arr) /+nothrow+/ } } -package bool hasPostblit(in TypeInfo ti) +package bool hasPostblit(in TypeInfo ti) nothrow pure { return (&ti.postblit).funcptr !is &TypeInfo.postblit; } @@ -741,12 +754,21 @@ void __doPostblit(void *ptr, size_t len, const TypeInfo ti) /** - * set the array capacity. If the array capacity isn't currently large enough - * to hold the requested capacity (in number of elements), then the array is - * resized/reallocated to the appropriate size. Pass in a requested capacity - * of 0 to get the current capacity. Returns the number of elements that can - * actually be stored once the resizing is done. - */ +Set the array capacity. + +If the array capacity isn't currently large enough +to hold the requested capacity (in number of elements), then the array is +resized/reallocated to the appropriate size. + +Pass in a requested capacity of 0 to get the current capacity. + +Params: + ti = type info of element type + newcapacity = requested new capacity + p = pointer to array to set. Its `length` is left unchanged. + +Returns: the number of elements that can actually be stored once the resizing is done +*/ extern(C) size_t _d_arraysetcapacity(const TypeInfo ti, size_t newcapacity, void[]* p) @weak in { @@ -917,9 +939,18 @@ Lcontinue: } /** - * Allocate a new uninitialized array of length elements. - * ti is the type of the resulting array, or pointer to element. - */ +Allocate an array with the garbage collector. + +Has three variants: +- `_d_newarrayU` leave elements uninitialized +- `_d_newarrayT` initializes to 0 (e.g `new int[]`) +- `_d_newarrayiT` initializes based on initializer retrieved from TypeInfo (e.g `new float[]`) + +Params: + ti = the type of the resulting array, (may also be the corresponding `array.ptr` type) + length = `.length` of resulting array +Returns: newly allocated array +*/ extern (C) void[] _d_newarrayU(const scope TypeInfo ti, size_t length) pure nothrow @weak { import core.exception : onOutOfMemoryError; @@ -976,11 +1007,7 @@ Lcontinue: return arrstart[0..length]; } -/** - * Allocate a new array of length elements. - * ti is the type of the resulting array, or pointer to element. - * (For when the array is initialized to 0) - */ +/// ditto extern (C) void[] _d_newarrayT(const TypeInfo ti, size_t length) pure nothrow @weak { import core.stdc.string; @@ -993,9 +1020,7 @@ extern (C) void[] _d_newarrayT(const TypeInfo ti, size_t length) pure nothrow @w return result; } -/** - * For when the array has a non-zero initializer. - */ +/// ditto extern (C) void[] _d_newarrayiT(const TypeInfo ti, size_t length) pure nothrow @weak { import core.internal.traits : AliasSeq; @@ -1011,8 +1036,12 @@ extern (C) void[] _d_newarrayiT(const TypeInfo ti, size_t length) pure nothrow @ foreach (T; AliasSeq!(ubyte, ushort, uint, ulong)) { case T.sizeof: - (cast(T*)result.ptr)[0 .. size * length / T.sizeof] = *cast(T*)init.ptr; - return result; + if (tinext.talign % T.alignof == 0) + { + (cast(T*)result.ptr)[0 .. size * length / T.sizeof] = *cast(T*)init.ptr; + return result; + } + goto default; } default: @@ -1027,10 +1056,10 @@ extern (C) void[] _d_newarrayiT(const TypeInfo ti, size_t length) pure nothrow @ } -/** - * +/* + * Helper for creating multi-dimensional arrays */ -void[] _d_newarrayOpT(alias op)(const TypeInfo ti, size_t[] dims) +private void[] _d_newarrayOpT(alias op)(const TypeInfo ti, size_t[] dims) { debug(PRINTF) printf("_d_newarrayOpT(ndims = %d)\n", dims.length); if (dims.length == 0) @@ -1069,8 +1098,30 @@ void[] _d_newarrayOpT(alias op)(const TypeInfo ti, size_t[] dims) /** - * - */ +Create a new multi-dimensional array + +Has two variants: +- `_d_newarraymTX` which initializes to 0 +- `_d_newarraymiTX` which initializes elements based on `TypeInfo` + +--- +void main() +{ + new int[][](10, 20); + // _d_newarraymTX(typeid(float), [10, 20]); + + new float[][][](10, 20, 30); + // _d_newarraymiTX(typeid(float), [10, 20, 30]); +} +--- + +Params: + ti = `TypeInfo` of the array type + dims = array length values for each dimension + +Returns: + newly allocated array +*/ extern (C) void[] _d_newarraymTX(const TypeInfo ti, size_t[] dims) @weak { debug(PRINTF) printf("_d_newarraymT(dims.length = %d)\n", dims.length); @@ -1083,10 +1134,7 @@ extern (C) void[] _d_newarraymTX(const TypeInfo ti, size_t[] dims) @weak } } - -/** - * - */ +/// ditto extern (C) void[] _d_newarraymiTX(const TypeInfo ti, size_t[] dims) @weak { debug(PRINTF) printf("_d_newarraymiT(dims.length = %d)\n", dims.length); @@ -1100,9 +1148,31 @@ extern (C) void[] _d_newarraymiTX(const TypeInfo ti, size_t[] dims) @weak } /** - * Allocate an uninitialized non-array item. - * This is an optimization to avoid things needed for arrays like the __arrayPad(size). - */ +Allocate an uninitialized non-array item. + +This is an optimization to avoid things needed for arrays like the __arrayPad(size). + +- `_d_newitemU` leaves the item uninitialized +- `_d_newitemT` zero initializes the item +- `_d_newitemiT` uses a non-zero initializer from `TypeInfo` + +Used to allocate struct instances on the heap. +--- +struct Sz {int x = 0;} +struct Si {int x = 3;} + +void main() +{ + new Sz(); // _d_newitemT(typeid(Sz)) + new Si(); // _d_newitemiT(typeid(Si)) +} +--- + +Params: + _ti = `TypeInfo` of item to allocate +Returns: + newly allocated item +*/ extern (C) void* _d_newitemU(scope const TypeInfo _ti) pure nothrow @weak { auto ti = unqualify(_ti); @@ -1118,14 +1188,15 @@ extern (C) void* _d_newitemU(scope const TypeInfo _ti) pure nothrow @weak if (tiSize) { - *cast(TypeInfo*)(p + itemSize) = null; // the GC might not have cleared this area + // the GC might not have cleared the padding area in the block + *cast(TypeInfo*)(p + (itemSize & ~(size_t.sizeof - 1))) = null; *cast(TypeInfo*)(p + blkInf.size - tiSize) = cast() ti; } return p; } -/// Same as above, zero initializes the item. +/// ditto extern (C) void* _d_newitemT(in TypeInfo _ti) pure nothrow @weak { import core.stdc.string; @@ -1145,15 +1216,6 @@ extern (C) void* _d_newitemiT(in TypeInfo _ti) pure nothrow @weak return p; } -/** - * - */ -struct Array -{ - size_t length; - byte* data; -} - debug(PRINTF) { extern(C) void printArrayCache() @@ -1436,6 +1498,7 @@ extern (C) void rt_finalize2(void* p, bool det = true, bool resetMemory = true) } } +/// Backwards compatibility extern (C) void rt_finalize(void* p, bool det = true) nothrow { rt_finalize2(p, det, true); @@ -1454,8 +1517,29 @@ extern (C) void rt_finalizeFromGC(void* p, size_t size, uint attr) nothrow /** - * Resize dynamic arrays with 0 initializers. - */ +Resize a dynamic array by setting the `.length` property + +Newly created elements are initialized to their default value. + +Has two variants: +- `_d_arraysetlengthT` for arrays with elements that initialize to 0 +- `_d_arraysetlengthiT` for non-zero initializers retrieved from `TypeInfo` + +--- +void main() +{ + int[] a = [1, 2]; + a.length = 3; // gets lowered to `_d_arraysetlengthT(typeid(int[]), 3, &a)` +} +--- + +Params: + ti = `TypeInfo` of array + newlength = new value for the array's `.length` + p = pointer to array to update the `.length` of. + While it's cast to `void[]`, its `.length` is still treated as element length. +Returns: `*p` after being updated +*/ extern (C) void[] _d_arraysetlengthT(const TypeInfo ti, size_t newlength, void[]* p) @weak in { @@ -1649,15 +1733,7 @@ do return *p; } - -/** - * Resize arrays for non-zero initializers. - * p pointer to array lvalue to be updated - * newlength new .length property of array - * sizeelem size of each element of array - * initsize size of initializer - * ... initializer - */ +/// ditto extern (C) void[] _d_arraysetlengthiT(const TypeInfo ti, size_t newlength, void[]* p) @weak in { @@ -1867,27 +1943,33 @@ do return *p; } -/** - * Append y[] to array x[] - */ -extern (C) void[] _d_arrayappendT(const TypeInfo ti, ref byte[] x, byte[] y) @weak -{ - import core.stdc.string; - auto length = x.length; - auto tinext = unqualify(ti.next); - auto sizeelem = tinext.tsize; // array element size - _d_arrayappendcTX(ti, x, y.length); - memcpy(x.ptr + length * sizeelem, y.ptr, y.length * sizeelem); - - // do postblit - __doPostblit(x.ptr + length * sizeelem, y.length * sizeelem, tinext); - return x; -} - /** - * - */ +Given an array of length `size` that needs to be expanded to `newlength`, +compute a new capacity. + +Better version by Dave Fladebo: +This uses an inverse logorithmic algorithm to pre-allocate a bit more +space for larger arrays. +- Arrays smaller than PAGESIZE bytes are left as-is, so for the most +common cases, memory allocation is 1 to 1. The small overhead added +doesn't affect small array perf. (it's virtually the same as +current). +- Larger arrays have some space pre-allocated. +- As the arrays grow, the relative pre-allocated space shrinks. +- The logorithmic algorithm allocates relatively more space for +mid-size arrays, making it very fast for medium arrays (for +mid-to-large arrays, this turns out to be quite a bit faster than the +equivalent realloc() code in C, on Linux at least. Small arrays are +just as fast as GCC). +- Perhaps most importantly, overall memory usage and stress on the GC +is decreased significantly for demanding environments. + +Params: + newlength = new `.length` + size = old `.length` +Returns: new capacity for array +*/ size_t newCapacity(size_t newlength, size_t size) { version (none) @@ -1896,24 +1978,6 @@ size_t newCapacity(size_t newlength, size_t size) } else { - /* - * Better version by Dave Fladebo: - * This uses an inverse logorithmic algorithm to pre-allocate a bit more - * space for larger arrays. - * - Arrays smaller than PAGESIZE bytes are left as-is, so for the most - * common cases, memory allocation is 1 to 1. The small overhead added - * doesn't affect small array perf. (it's virtually the same as - * current). - * - Larger arrays have some space pre-allocated. - * - As the arrays grow, the relative pre-allocated space shrinks. - * - The logorithmic algorithm allocates relatively more space for - * mid-size arrays, making it very fast for medium arrays (for - * mid-to-large arrays, this turns out to be quite a bit faster than the - * equivalent realloc() code in C, on Linux at least. Small arrays are - * just as fast as GCC). - * - Perhaps most importantly, overall memory usage and stress on the GC - * is decreased significantly for demanding environments. - */ size_t newcap = newlength * size; size_t newext = 0; @@ -1967,10 +2031,17 @@ size_t newCapacity(size_t newlength, size_t size) } -/************************************** - * Extend an array by n elements. - * Caller must initialize those elements. - */ +/** +Extend an array by n elements. + +Caller must initialize those elements. + +Params: + ti = type info of array type (not element type) + px = array to append to, cast to `byte[]` while keeping the same `.length`. Will be updated. + n = number of elements to append +Returns: `px` after being appended to +*/ extern (C) byte[] _d_arrayappendcTX(const TypeInfo ti, return scope ref byte[] px, size_t n) @weak { @@ -2074,8 +2145,21 @@ byte[] _d_arrayappendcTX(const TypeInfo ti, return scope ref byte[] px, size_t n /** - * Append dchar to char[] - */ +Append `dchar` to `char[]`, converting UTF-32 to UTF-8 + +--- +void main() +{ + char[] s; + s ~= 'α'; +} +--- + +Params: + x = array to append to cast to `byte[]`. Will be modified. + c = `dchar` to append +Returns: updated `x` cast to `void[]` +*/ extern (C) void[] _d_arrayappendcd(ref byte[] x, dchar c) @weak { // c could encode into from 1 to 4 characters @@ -2121,7 +2205,7 @@ extern (C) void[] _d_arrayappendcd(ref byte[] x, dchar c) @weak // Hack because _d_arrayappendT takes `x` as a reference auto xx = cast(shared(char)[])x; - object._d_arrayappendTImpl!(shared(char)[])._d_arrayappendT(xx, cast(shared(char)[])appendthis); + object._d_arrayappendT(xx, cast(shared(char)[])appendthis); x = cast(byte[])xx; return x; } @@ -2156,8 +2240,23 @@ unittest /** - * Append dchar to wchar[] - */ +Append `dchar` to `wchar[]`, converting UTF-32 to UTF-16 + +--- +void main() +{ + dchar x; + wchar[] s; + s ~= 'α'; +} +--- + +Params: + x = array to append to cast to `byte[]`. Will be modified. + c = `dchar` to append + +Returns: updated `x` cast to `void[]` +*/ extern (C) void[] _d_arrayappendwd(ref byte[] x, dchar c) @weak { // c could encode into from 1 to 2 w characters @@ -2182,15 +2281,31 @@ extern (C) void[] _d_arrayappendwd(ref byte[] x, dchar c) @weak // auto xx = (cast(shared(wchar)*)x.ptr)[0 .. x.length]; - object._d_arrayappendTImpl!(shared(wchar)[])._d_arrayappendT(xx, cast(shared(wchar)[])appendthis); + object._d_arrayappendT(xx, cast(shared(wchar)[])appendthis); x = (cast(byte*)xx.ptr)[0 .. xx.length]; return x; } /** - * - */ +Concatenate two arrays into a new array + +--- +void main() +{ + int[] x = [10, 20, 30]; + int[] y = [40, 50]; + int[] c = x ~ y; // _d_arraycatT(typeid(int[]), (cast(byte*) x)[0..x.length], (cast(byte*) y)[0..y.length]); +} +--- + +Params: + ti = type that the two arrays share + x = left hand side array casted to `byte[]`. Despite this cast, its `.length` is original element length, not byte length + y = right hand side array casted to `byte[]`. Despite this cast, its `.length` is original element length, not byte length +Returns: + resulting concatenated array, with `.length` equal to new element length despite `byte` type +*/ extern (C) byte[] _d_arraycatT(const TypeInfo ti, byte[] x, byte[] y) @weak out (result) { @@ -2255,8 +2370,27 @@ do /** - * - */ +Concatenate multiple arrays at once + +This is more efficient than repeatedly concatenating pairs of arrays because the total size is known in advance. + +``` +void main() +{ + int[] a, b, c; + int[] res = a ~ b ~ c; + // _d_arraycatnTX(typeid(int[]), + // [(cast(byte*)a.ptr)[0..a.length], (cast(byte*)b.ptr)[0..b.length], (cast(byte*)c.ptr)[0..c.length]]); +} +``` + +Params: + ti = type of arrays to concatenate and resulting array + arrs = array of arrays to concatenate, cast to `byte[]` while keeping `.length` the same + +Returns: + newly created concatenated array, `.length` equal to the total element length despite `void` type +*/ extern (C) void[] _d_arraycatnTX(const TypeInfo ti, scope byte[][] arrs) @weak { import core.stdc.string; @@ -2295,8 +2429,27 @@ extern (C) void[] _d_arraycatnTX(const TypeInfo ti, scope byte[][] arrs) @weak /** - * Allocate the array, rely on the caller to do the initialization of the array. - */ +Allocate an array literal + +Rely on the caller to do the initialization of the array. + +--- +int[] getArr() +{ + return [10, 20]; + // auto res = cast(int*) _d_arrayliteralTX(typeid(int[]), 2); + // res[0] = 10; + // res[1] = 20; + // return res[0..2]; +} +--- + +Params: + ti = `TypeInfo` of resulting array type + length = `.length` of array literal + +Returns: pointer to allocated array +*/ extern (C) void* _d_arrayliteralTX(const TypeInfo ti, size_t length) @weak { @@ -2602,11 +2755,6 @@ deprecated unittest } dtorCount = 0; - S1* s1 = new S1; - _d_delstruct(cast(void**)&s1, typeid(typeof(*s1))); // delete s1; - assert(dtorCount == 1); - - dtorCount = 0; S1[] arr1 = new S1[7]; _d_delarray_t(cast(void[]*)&arr1, typeid(typeof(arr1[0]))); // delete arr1; assert(dtorCount == 7); diff --git a/libphobos/libdruntime/rt/minfo.d b/libphobos/libdruntime/rt/minfo.d index 0d5cd22..7489150 100644 --- a/libphobos/libdruntime/rt/minfo.d +++ b/libphobos/libdruntime/rt/minfo.d @@ -58,7 +58,7 @@ struct ModuleGroup // target modules are involved in a cycle. // // The return value is malloc'd using C, so it must be freed after use. - private size_t[] genCyclePath(size_t srcidx, size_t targetidx, int[][] edges) + private size_t[] genCyclePath(size_t srcidx, size_t targetidx, int[][] edges) nothrow { import core.bitop : bt, btc, bts; @@ -109,7 +109,7 @@ struct ModuleGroup // release mode. if (distance[target] != curdist) { - throw new Error("internal error printing module cycle"); + assert(0, "internal error printing module cycle"); } // determine the path. This is tricky, because we have to @@ -162,14 +162,13 @@ struct ModuleGroup * Throws: * Exception if it fails. */ - void sortCtors(string cycleHandling) + void sortCtors(string cycleHandling) nothrow { import core.bitop : bts, btr, bt, BitRange; import core.internal.container.hashtab; enum OnCycle { - deprecate, abort, print, ignore @@ -180,7 +179,9 @@ struct ModuleGroup switch (cycleHandling) with(OnCycle) { case "deprecate": - onCycle = deprecate; + import core.stdc.stdio : fprintf, stderr; + // Option deprecated in 2.101, remove in 2.111 + fprintf(stderr, "`--DRT-oncycle=deprecate` is no longer supported, using `abort` instead\n"); break; case "abort": onCycle = abort; @@ -196,7 +197,7 @@ struct ModuleGroup break; default: // invalid cycle handling option. - throw new Error("DRT invalid cycle handling option: " ~ cycleHandling); + assert(0, "DRT invalid cycle handling option: " ~ cycleHandling); } debug (printModuleDependencies) @@ -280,7 +281,7 @@ struct ModuleGroup .free(edges.ptr); } - void buildCycleMessage(size_t sourceIdx, size_t cycleIdx, scope void delegate(string) sink) + void buildCycleMessage(size_t sourceIdx, size_t cycleIdx, scope void delegate(string) nothrow sink) { version (Windows) enum EOL = "\r\n"; @@ -312,7 +313,7 @@ struct ModuleGroup // // If a cycle is detected, returns the index of the module that completes the cycle. // Returns: true for success, false for a deprecated cycle error - bool findDeps(size_t idx, size_t* reachable) + bool findDeps(size_t idx, size_t* reachable) nothrow { static struct stackFrame { @@ -356,14 +357,6 @@ struct ModuleGroup // was already started, this is a cycle. final switch (onCycle) with(OnCycle) { - case deprecate: - // check with old algorithm - if (sortCtorsOld(edges)) - { - // unwind to print deprecation message. - return false; // deprecated cycle error - } - goto case abort; // fall through case abort: string errmsg = ""; @@ -418,7 +411,7 @@ struct ModuleGroup // ctor/dtors that must be dealt with. It recurses only when it finds // dependencies that also have static ctor/dtors. // Returns: true for success, false for a deprecated cycle error - bool processMod(size_t curidx) + bool processMod(size_t curidx) nothrow { immutable ModuleInfo* current = _modules[curidx]; @@ -461,7 +454,7 @@ struct ModuleGroup } // returns `false` if deprecated cycle error otherwise set `result`. - bool doSort(size_t relevantFlags, ref immutable(ModuleInfo)*[] result) + bool doSort(size_t relevantFlags, ref immutable(ModuleInfo)*[] result) nothrow { clearFlags(relevant); clearFlags(ctorstart); @@ -533,193 +526,6 @@ struct ModuleGroup sortCtors(rt_configOption("oncycle")); } - /****************************** - * This is the old ctor sorting algorithm that does not find all cycles. - * - * It is here to allow the deprecated behavior from the original algorithm - * until people have fixed their code. - * - * If no cycles are found, the _ctors and _tlsctors are replaced with the - * ones generated by this algorithm to preserve the old incorrect ordering - * behavior. - * - * Params: - * edges = The module edges as found in the `importedModules` member of - * each ModuleInfo. Generated in sortCtors. - * Returns: - * true if no cycle is found, false if one was. - */ - bool sortCtorsOld(int[][] edges) - { - immutable len = edges.length; - assert(len == _modules.length); - - static struct StackRec - { - @property int mod() - { - return _mods[_idx]; - } - - int[] _mods; - size_t _idx; - } - - auto stack = (cast(StackRec*).calloc(len, StackRec.sizeof))[0 .. len]; - // TODO: reuse GCBits by moving it to core.internal.container - immutable nwords = (len + 8 * size_t.sizeof - 1) / (8 * size_t.sizeof); - auto ctorstart = cast(size_t*).malloc(nwords * size_t.sizeof); - auto ctordone = cast(size_t*).malloc(nwords * size_t.sizeof); - int[] initialEdges = (cast(int *)malloc(int.sizeof * len))[0 .. len]; - if (!stack.ptr || ctorstart is null || ctordone is null || !initialEdges.ptr) - assert(0); - scope (exit) - { - .free(stack.ptr); - .free(ctorstart); - .free(ctordone); - .free(initialEdges.ptr); - } - - // initialize the initial edges - foreach (i, ref v; initialEdges) - v = cast(int)i; - - bool sort(ref immutable(ModuleInfo)*[] ctors, uint mask) - { - import core.bitop; - - ctors = (cast(immutable(ModuleInfo)**).malloc(len * size_t.sizeof))[0 .. len]; - if (!ctors.ptr) - assert(0); - - // clean flags - memset(ctorstart, 0, nwords * size_t.sizeof); - memset(ctordone, 0, nwords * size_t.sizeof); - size_t stackidx = 0; - size_t cidx; - - int[] mods = initialEdges; - - size_t idx; - while (true) - { - while (idx < mods.length) - { - auto m = mods[idx]; - - if (bt(ctordone, m)) - { - // this module has already been processed, skip - ++idx; - continue; - } - else if (bt(ctorstart, m)) - { - /* Trace back to the begin of the cycle. - */ - bool ctorInCycle; - size_t start = stackidx; - while (start--) - { - auto sm = stack[start].mod; - if (sm == m) - break; - assert(sm >= 0); - if (bt(ctorstart, sm)) - ctorInCycle = true; - } - assert(stack[start].mod == m); - if (ctorInCycle) - { - return false; - } - else - { - /* This is also a cycle, but the import chain does not constrain - * the order of initialization, either because the imported - * modules have no ctors or the ctors are standalone. - */ - ++idx; - } - } - else - { - auto curmod = _modules[m]; - if (curmod.flags & mask) - { - if (curmod.flags & MIstandalone || !edges[m].length) - { // trivial ctor => sort in - ctors[cidx++] = curmod; - bts(ctordone, m); - } - else - { // non-trivial ctor => defer - bts(ctorstart, m); - } - } - else // no ctor => mark as visited - { - bts(ctordone, m); - } - - if (edges[m].length) - { - /* Internal runtime error, recursion exceeds number of modules. - */ - (stackidx < len) || assert(0); - - // recurse - stack[stackidx++] = StackRec(mods, idx); - idx = 0; - mods = edges[m]; - } - } - } - - if (stackidx) - { // pop old value from stack - --stackidx; - mods = stack[stackidx]._mods; - idx = stack[stackidx]._idx; - auto m = mods[idx++]; - if (bt(ctorstart, m) && !bts(ctordone, m)) - ctors[cidx++] = _modules[m]; - } - else // done - break; - } - // store final number and shrink array - ctors = (cast(immutable(ModuleInfo)**).realloc(ctors.ptr, cidx * size_t.sizeof))[0 .. cidx]; - return true; - } - - /* Do two passes: ctor/dtor, tlsctor/tlsdtor - */ - immutable(ModuleInfo)*[] _ctors2; - immutable(ModuleInfo)*[] _tlsctors2; - auto result = sort(_ctors2, MIctor | MIdtor) && sort(_tlsctors2, MItlsctor | MItlsdtor); - if (result) // no cycle - { - // fall back to original ordering as part of the deprecation. - if (_ctors.ptr) - .free(_ctors.ptr); - _ctors = _ctors2; - if (_tlsctors.ptr) - .free(_tlsctors.ptr); - _tlsctors = _tlsctors2; - } - else - { - // free any allocated memory that will be forgotten - if (_ctors2.ptr) - .free(_ctors2.ptr); - if (_tlsctors2.ptr) - .free(_tlsctors2.ptr); - } - return result; - } - void runCtors() { // run independent ctors diff --git a/libphobos/libdruntime/rt/monitor_.d b/libphobos/libdruntime/rt/monitor_.d index 0f1d0e9..c1f3f3c 100644 --- a/libphobos/libdruntime/rt/monitor_.d +++ b/libphobos/libdruntime/rt/monitor_.d @@ -54,7 +54,7 @@ extern (C) void _d_monitordelete(Object h, bool det) } // does not call dispose events, for internal use only -extern (C) void _d_monitordelete_nogc(Object h) @nogc +extern (C) void _d_monitordelete_nogc(Object h) @nogc nothrow { auto m = getMonitor(h); if (m is null) @@ -148,7 +148,7 @@ extern (C) void rt_detachDisposeEvent(Object h, DEvent e) nothrow: -extern (C) void _d_monitor_staticctor() +extern (C) void _d_monitor_staticctor() @nogc nothrow { version (Posix) { @@ -158,7 +158,7 @@ extern (C) void _d_monitor_staticctor() initMutex(&gmtx); } -extern (C) void _d_monitor_staticdtor() +extern (C) void _d_monitor_staticdtor() @nogc nothrow { destroyMutex(&gmtx); version (Posix) diff --git a/libphobos/libdruntime/rt/util/typeinfo.d b/libphobos/libdruntime/rt/util/typeinfo.d index 26c24c4..7b55693 100644 --- a/libphobos/libdruntime/rt/util/typeinfo.d +++ b/libphobos/libdruntime/rt/util/typeinfo.d @@ -1,8 +1,8 @@ /** - * This module contains utilities for TypeInfo implementation. + * A few predefined implementations for primitive types and arrays thereof. Also a couple of helpers. * * Copyright: Copyright Kenji Hara 2014-. - * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. + * License: <a href="https://boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. * Authors: Kenji Hara * Source: $(DRUNTIMESRC rt/util/_typeinfo.d) */ @@ -10,100 +10,74 @@ module rt.util.typeinfo; import rt.util.utility : d_cfloat, d_cdouble, d_creal, isComplex; static import core.internal.hash; -template Floating(T) -if (is(T == float) || is(T == double) || is(T == real)) +// Three-way compare for integrals: negative if `lhs < rhs`, positive if `lhs > rhs`, 0 otherwise. +pragma(inline, true) +private int cmp3(T)(const T lhs, const T rhs) +if (__traits(isIntegral, T)) { - pure nothrow @safe: - - bool equals(T f1, T f2) - { - return f1 == f2; - } - - int compare(T d1, T d2) - { - if (d1 != d1 || d2 != d2) // if either are NaN - { - if (d1 != d1) - { - if (d2 != d2) - return 0; - return -1; - } - return 1; - } - return (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1); - } + static if (T.sizeof < int.sizeof) + // Taking the difference will always fit in an int. + return int(lhs) - int(rhs); + else + return (lhs > rhs) - (lhs < rhs); +} - public alias hashOf = core.internal.hash.hashOf; +// Three-way compare for real fp types. NaN is smaller than all valid numbers. +// Code is small and fast, see https://godbolt.org/z/fzb877 +pragma(inline, true) +private int cmp3(T)(const T d1, const T d2) +if (is(T == float) || is(T == double) || is(T == real)) +{ + if (d2 != d2) + return d1 == d1; // 0 if both ar NaN, 1 if d1 is valid and d2 is NaN. + // If d1 is NaN, both comparisons are false so we get -1, as needed. + return (d1 > d2) - !(d1 >= d2); } -// @@@DEPRECATED_2.105@@@ -template Floating(T) +// Three-way compare for complex types. +pragma(inline, true) +private int cmp3(T)(const T f1, const T f2) if (isComplex!T) { - pure nothrow @safe: - - bool equals(T f1, T f2) - { - return f1.re == f2.re && f1.im == f2.im; - } - - int compare(T f1, T f2) - { - int result; - - if (f1.re < f2.re) - result = -1; - else if (f1.re > f2.re) - result = 1; - else if (f1.im < f2.im) - result = -1; - else if (f1.im > f2.im) - result = 1; - else - result = 0; + if (int result = cmp3(f1.re, f2.re)) return result; - } - - size_t hashOf(scope const T val) - { - return core.internal.hash.hashOf(val.re, core.internal.hash.hashOf(val.im)); - } + return cmp3(f1.im, f2.im); } -template Array(T) -if (is(T == float) || is(T == double) || is(T == real)) +unittest { - pure nothrow @safe: - - bool equals(T[] s1, T[] s2) - { - size_t len = s1.length; - if (len != s2.length) - return false; - for (size_t u = 0; u < len; u++) - { - if (!Floating!T.equals(s1[u], s2[u])) - return false; - } - return true; - } - - int compare(T[] s1, T[] s2) - { - size_t len = s1.length; - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - if (int c = Floating!T.compare(s1[u], s2[u])) - return c; - } - return (s1.length > s2.length) - (s1.length < s2.length); - } - - public alias hashOf = core.internal.hash.hashOf; + assert(cmp3(short.max, short.min) > 0); + assert(cmp3(42, 42) == 0); + assert(cmp3(int.max, int.min) > 0); + + double x, y; + assert(cmp3(x, y) == 0); + assert(cmp3(y, x) == 0); + x = 42; + assert(cmp3(x, y) > 0); + assert(cmp3(y, x) < 0); + y = 43; + assert(cmp3(x, y) < 0); + assert(cmp3(y, x) > 0); + y = 42; + assert(cmp3(x, y) == 0); + assert(cmp3(y, x) == 0); + + d_cdouble u, v; + assert(cmp3(u, v) == 0); + assert(cmp3(v, u) == 0); + u = d_cdouble(42, 42); + assert(cmp3(u, v) > 0); + assert(cmp3(v, u) < 0); + v = d_cdouble(43, 42); + assert(cmp3(u, v) < 0); + assert(cmp3(v, u) > 0); + v = d_cdouble(42, 43); + assert(cmp3(u, v) < 0); + assert(cmp3(v, u) > 0); + v = d_cdouble(42, 42); + assert(cmp3(u, v) == 0); + assert(cmp3(v, u) == 0); } // @@@DEPRECATED_2.105@@@ @@ -209,7 +183,7 @@ unittest }(); } -// Reduces to `T` if `cond` is `true` or `U` otherwise. +// Reduces to `T` if `cond` is `true` or `U` otherwise. Consider moving elsewhere if useful. private template Select(bool cond, T, U) { static if (cond) alias Select = T; @@ -238,57 +212,38 @@ if (T.sizeof == Base.sizeof && T.alignof == Base.alignof) static if (is(T == Base)) override size_t getHash(scope const void* p) { - static if (__traits(isFloating, T) || isComplex!T) - return Floating!T.hashOf(*cast(T*)p); - else - return hashOf(*cast(const T *)p); + return hashOf(*cast(const T *)p); } // `equals` is the same for `Base` and `T`, introduce it just once. static if (is(T == Base)) override bool equals(in void* p1, in void* p2) { - static if (__traits(isFloating, T) || isComplex!T) - return Floating!T.equals(*cast(T*)p1, *cast(T*)p2); - else - return *cast(T *)p1 == *cast(T *)p2; + return *cast(const T *)p1 == *cast(const T *)p2; } // `T` and `Base` may have different signedness, so this function is introduced conditionally. static if (is(T == Base) || (__traits(isIntegral, T) && T.max != Base.max)) override int compare(in void* p1, in void* p2) { - static if (__traits(isFloating, T) || isComplex!T) - { - return Floating!T.compare(*cast(T*)p1, *cast(T*)p2); - } - else static if (T.sizeof < int.sizeof) - { - // Taking the difference will always fit in an int. - return int(*cast(T *) p1) - int(*cast(T *) p2); - } - else - { - auto lhs = *cast(T *) p1, rhs = *cast(T *) p2; - return (lhs > rhs) - (lhs < rhs); - } + return cmp3(*cast(const T*) p1, *cast(const T*) p2); } static if (is(T == Base)) - override @property size_t tsize() nothrow pure + override @property size_t tsize() { return T.sizeof; } static if (is(T == Base)) - override @property size_t talign() nothrow pure + override @property size_t talign() { return T.alignof; } // Override initializer only if necessary. static if (is(T == Base) || T.init != Base.init) - override const(void)[] initializer() @trusted + override const(void)[] initializer() { static if (__traits(isZeroInit, T)) { @@ -311,7 +266,7 @@ if (T.sizeof == Base.sizeof && T.alignof == Base.alignof) } static if (is(T == Base) || RTInfo!T != RTInfo!Base) - override @property immutable(void)* rtInfo() nothrow pure const @safe + override @property immutable(void)* rtInfo() { return RTInfo!T; } @@ -377,52 +332,33 @@ private class TypeInfoArrayGeneric(T, Base = T) : Select!(is(T == Base), TypeInf static if (is(T == Base)) override size_t getHash(scope const void* p) @trusted const { - static if (__traits(isFloating, T) || isComplex!T) - return Array!T.hashOf(*cast(T[]*)p); - else - return hashOf(*cast(const T[]*) p); + return hashOf(*cast(const T[]*) p); } static if (is(T == Base)) override bool equals(in void* p1, in void* p2) const { - static if (__traits(isFloating, T) || isComplex!T) - { - return Array!T.equals(*cast(T[]*)p1, *cast(T[]*)p2); - } - else - { - import core.stdc.string; - auto s1 = *cast(T[]*)p1; - auto s2 = *cast(T[]*)p2; - return s1.length == s2.length && - memcmp(s1.ptr, s2.ptr, s1.length) == 0; - } + // Just reuse the builtin. + return *cast(const(T)[]*) p1 == *cast(const(T)[]*) p2; } static if (is(T == Base) || (__traits(isIntegral, T) && T.max != Base.max)) override int compare(in void* p1, in void* p2) const { - static if (__traits(isFloating, T) || isComplex!T) - { - return Array!T.compare(*cast(T[]*)p1, *cast(T[]*)p2); - } - else + // Can't reuse __cmp in object.d because that handles NaN differently. + // (Q: would it make sense to unify behaviors?) + // return __cmp(*cast(const T[]*) p1, *cast(const T[]*) p2); + auto lhs = *cast(const T[]*) p1; + auto rhs = *cast(const T[]*) p2; + size_t len = lhs.length; + if (rhs.length < len) + len = rhs.length; + for (size_t u = 0; u < len; u++) { - auto s1 = *cast(T[]*)p1; - auto s2 = *cast(T[]*)p2; - auto len = s1.length; - - if (s2.length < len) - len = s2.length; - for (size_t u = 0; u < len; u++) - { - if (int result = (s1[u] > s2[u]) - (s1[u] < s2[u])) - return result; - } - return (s1.length > s2.length) - (s1.length < s2.length); + if (int result = cmp3(lhs.ptr[u], rhs.ptr[u])) + return result; } - } + return cmp3(lhs.length, rhs.length); } override @property inout(TypeInfo) next() inout { @@ -692,52 +628,37 @@ unittest // typeof(null) class TypeInfo_n : TypeInfo { - override string toString() const @safe { return "typeof(null)"; } + const: pure: @nogc: nothrow: @safe: - override size_t getHash(scope const void* p) const - { - return 0; - } + override string toString() { return "typeof(null)"; } - override bool equals(in void* p1, in void* p2) const @trusted - { - return true; - } + override size_t getHash(scope const void*) { return 0; } - override int compare(in void* p1, in void* p2) const @trusted - { - return 0; - } + override bool equals(in void*, in void*) { return true; } - override @property size_t tsize() const - { - return typeof(null).sizeof; - } + override int compare(in void*, in void*) { return 0; } - override const(void)[] initializer() const @trusted - { - __gshared immutable void[typeof(null).sizeof] init; - return init; - } + override @property size_t tsize() { return typeof(null).sizeof; } - override void swap(void *p1, void *p2) const @trusted - { - } + override const(void)[] initializer() @trusted { return (cast(void *)null)[0 .. size_t.sizeof]; } - override @property immutable(void)* rtInfo() nothrow pure const @safe { return rtinfoNoPointers; } + override void swap(void*, void*) {} - unittest + override @property immutable(void)* rtInfo() { return rtinfoNoPointers; } +} + +unittest +{ + with (typeid(typeof(null))) { - with (typeid(typeof(null))) - { - assert(toString == "typeof(null)"); - assert(getHash(null) == 0); - assert(equals(null, null)); - assert(compare(null, null) == 0); - assert(tsize == typeof(null).sizeof); - assert(initializer == new ubyte[(void*).sizeof]); - assert(rtInfo == rtinfoNoPointers); - } + assert(toString == "typeof(null)"); + assert(getHash(null) == 0); + assert(equals(null, null)); + assert(compare(null, null) == 0); + assert(tsize == typeof(null).sizeof); + assert(initializer.ptr is null); + assert(initializer.length == typeof(null).sizeof); + assert(rtInfo == rtinfoNoPointers); } } diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index 2babfbe..744e5ad 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -896b1d0e1e8b69bccac0e180ecd1b42a70f95d5b +1516ecad932d88a1618163384e6f69009d125391 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/Makefile.am b/libphobos/src/Makefile.am index 75f8397..da7a200 100644 --- a/libphobos/src/Makefile.am +++ b/libphobos/src/Makefile.am @@ -130,7 +130,7 @@ PHOBOS_DSOURCES = etc/c/curl.d etc/c/zlib.d std/algorithm/comparison.d \ std/experimental/typecons.d std/file.d std/format/internal/floats.d \ std/format/internal/read.d std/format/internal/write.d \ std/format/package.d std/format/read.d std/format/spec.d \ - std/format/write.d std/functional.d std/getopt.d \ + std/format/write.d std/functional.d std/getopt.d std/int128.d \ std/internal/attributes.d std/internal/cstring.d \ std/internal/math/biguintcore.d std/internal/math/biguintnoasm.d \ std/internal/math/errorfunction.d std/internal/math/gammafunction.d \ diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in index f2395e2..6f58fee 100644 --- a/libphobos/src/Makefile.in +++ b/libphobos/src/Makefile.in @@ -228,6 +228,7 @@ am__dirstamp = $(am__leading_dot)dirstamp @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/format/spec.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/format/write.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/functional.lo std/getopt.lo \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/int128.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/attributes.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/cstring.lo \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/math/biguintcore.lo \ @@ -591,7 +592,7 @@ libgphobos_la_LINK = $(LIBTOOL) --tag=D $(libgphobos_la_LIBTOOLFLAGS) \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/experimental/typecons.d std/file.d std/format/internal/floats.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/format/internal/read.d std/format/internal/write.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/format/package.d std/format/read.d std/format/spec.d \ -@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/format/write.d std/functional.d std/getopt.d \ +@ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/format/write.d std/functional.d std/getopt.d std/int128.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/attributes.d std/internal/cstring.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/math/biguintcore.d std/internal/math/biguintnoasm.d \ @ENABLE_LIBDRUNTIME_ONLY_FALSE@ std/internal/math/errorfunction.d std/internal/math/gammafunction.d \ @@ -846,6 +847,7 @@ std/format/spec.lo: std/format/$(am__dirstamp) std/format/write.lo: std/format/$(am__dirstamp) std/functional.lo: std/$(am__dirstamp) std/getopt.lo: std/$(am__dirstamp) +std/int128.lo: std/$(am__dirstamp) std/internal/$(am__dirstamp): @$(MKDIR_P) std/internal @: > std/internal/$(am__dirstamp) diff --git a/libphobos/src/etc/c/zlib.d b/libphobos/src/etc/c/zlib.d index a1b20fe..73c6534 100644 --- a/libphobos/src/etc/c/zlib.d +++ b/libphobos/src/etc/c/zlib.d @@ -2,15 +2,16 @@ /* updated from 1.2.1 to 1.2.3 by Thomas Kuehne */ /* updated from 1.2.3 to 1.2.8 by Dmitry Atamanov */ /* updated from 1.2.8 to 1.2.11 by Iain Buclaw */ +/* updated from 1.2.11 to 1.2.12 by Brian Callahan */ module etc.c.zlib; import core.stdc.config; /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.11, January 15th, 2017 + version 1.2.12, March 11th, 2022 - Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -42,8 +43,8 @@ nothrow: extern (C): // Those are extern(D) as they should be mangled -extern(D) immutable string ZLIB_VERSION = "1.2.11"; -extern(D) immutable ZLIB_VERNUM = 0x12b0; +extern(D) immutable string ZLIB_VERSION = "1.2.12"; +extern(D) immutable ZLIB_VERNUM = 0x12c0; /* The 'zlib' compression library provides in-memory compression and @@ -566,8 +567,7 @@ int deflateInit2(z_streamp strm, } /* This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. + fields zalloc, zfree and opaque must be initialized before by the caller. The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. @@ -586,7 +586,7 @@ int deflateInit2(z_streamp strm, with deflateInit2() with this initialization, or at least in that case use 9 with inflateInit2(). - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + windowBits can also be -8 .. -15 for raw deflate. In this case, -windowBits determines the window size. deflate() will then generate raw deflate data with no zlib header or trailer, and will not compute a check value. @@ -728,11 +728,12 @@ int deflateParams(z_streamp strm, int level, int strategy); used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression approach (which is a function of the level) or the - strategy is changed, and if any input has been consumed in a previous - deflate() call, then the input available so far is compressed with the old - level and strategy using deflate(strm, Z_BLOCK). There are three approaches - for the compression levels 0, 1 .. 3, and 4 .. 9 respectively. The new level - and strategy will take effect at the next call of deflate(). + strategy is changed, and if there have been any deflate() calls since the + state was initialized or reset, then the input available so far is + compressed with the old level and strategy using deflate(strm, Z_BLOCK). + There are three approaches for the compression levels 0, 1 .. 3, and 4 .. 9 + respectively. The new level and strategy will take effect at the next call + of deflate(). If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does not have enough output space to complete, then the parameter change will not @@ -856,7 +857,7 @@ int inflateInit2(z_streamp strm, int windowBits) windowBits can also be zero to request that inflate use the window size in the zlib header of the compressed stream. - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + windowBits can also be -8 .. -15 for raw inflate. In this case, -windowBits determines the window size. inflate() will then process raw deflate data, not looking for a zlib or gzip header, not generating a check value, and not looking for any check values for comparison at the end of the stream. This @@ -873,9 +874,11 @@ int inflateInit2(z_streamp strm, int windowBits) detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see - below), inflate() will not automatically decode concatenated gzip streams. - inflate() will return Z_STREAM_END at the end of the gzip stream. The state - would need to be reset to continue decoding a subsequent gzip stream. + below), inflate() will *not* automatically decode concatenated gzip members. + inflate() will return Z_STREAM_END at the end of the gzip member. The state + would need to be reset to continue decoding a subsequent gzip member. This + *must* be done if there is more data after a gzip member, in order for the + decompression to be compliant with the gzip standard (RFC 1952). inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the @@ -1311,14 +1314,14 @@ alias z_size_t = size_t; gzFile gzopen(const(char)* path, const(char)* mode); /* - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) 'T' will - request transparent writing or appending with no compression and not using - the gzip format. + Open the gzip (.gz) file at path for reading and decompressing, or + compressing and writing. The mode parameter is as in fopen ("rb" or "wb") + but can also include a compression level ("wb9") or a strategy: 'f' for + filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", + 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression + as in "wb9F". (See the description of deflateInit2 for more information + about the strategy parameter.) 'T' will request transparent writing or + appending with no compression and not using the gzip format. "a" can be used instead of "w" to request that the gzip stream that will be written be appended to the file. "+" will result in an error, since @@ -1348,9 +1351,9 @@ gzFile gzopen(const(char)* path, const(char)* mode); gzFile gzdopen(int fd, const(char)* mode); /* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. + Associate a gzFile with the file descriptor fd. File descriptors are + obtained from calls like open, dup, creat, pipe or fileno (if the file has + been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor @@ -1371,13 +1374,13 @@ gzFile gzdopen(int fd, const(char)* mode); int gzbuffer(gzFile file, uint size); /* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Three times that size in buffer space is allocated. A larger buffer - size of, for example, 64K or 128K bytes will noticeably increase the speed - of decompression (reading). + Set the internal buffer size used by this library's functions for file to + size. The default buffer size is 8192 bytes. This function must be called + after gzopen() or gzdopen(), and before any other calls that read or write + the file. The buffer memory allocation is always deferred to the first read + or write. Three times that size in buffer space is allocated. A larger + buffer size of, for example, 64K or 128K bytes will noticeably increase the + speed of decompression (reading). The new buffer size also affects the maximum length for gzprintf(). @@ -1387,9 +1390,9 @@ int gzbuffer(gzFile file, uint size); int gzsetparams(gzFile file, int level, int strategy); /* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. Previously provided - data is flushed before the parameter change. + Dynamically update the compression level and strategy for file. See the + description of deflateInit2 for the meaning of these parameters. Previously + provided data is flushed before applying the parameter changes. gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not opened for writing, Z_ERRNO if there is an error writing the flushed data, @@ -1398,7 +1401,7 @@ int gzsetparams(gzFile file, int level, int strategy); int gzread(gzFile file, void* buf, uint len); /* - Reads the given number of uncompressed bytes from the compressed file. If + Read and decompress up to len uncompressed bytes from file into buf. If the input file is not in gzip format, gzread copies the given number of bytes into the buffer directly from the file. @@ -1428,11 +1431,11 @@ int gzread(gzFile file, void* buf, uint len); z_size_t gzfread(void* buf, z_size_t size, z_size_t nitems, gzFile file); /* - Read up to nitems items of size size from file to buf, otherwise operating - as gzread() does. This duplicates the interface of stdio's fread(), with - size_t request and return types. If the library defines size_t, then - z_size_t is identical to size_t. If not, then z_size_t is an unsigned - integer type that can contain a pointer. + Read and decompress up to nitems items of size size from file into buf, + otherwise operating as gzread() does. This duplicates the interface of + stdio's fread(), with size_t request and return types. If the library + defines size_t, then z_size_t is identical to size_t. If not, then z_size_t + is an unsigned integer type that can contain a pointer. gzfread() returns the number of full items read of size size, or zero if the end of the file was reached and a full item could not be read, or if @@ -1453,14 +1456,13 @@ z_size_t gzfread(void* buf, z_size_t size, z_size_t nitems, gzFile file); int gzwrite(gzFile file, void* buf, uint len); /* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. + Compress and write the len uncompressed bytes at buf to file. gzwrite + returns the number of uncompressed bytes written or 0 in case of error. */ z_size_t gzfwrite(void* buf, z_size_t size, z_size_t nitems, gzFile file); /* - gzfwrite() writes nitems items of size size from buf to file, duplicating + Compress and write nitems items of size size from buf to file, duplicating the interface of stdio's fwrite(), with size_t request and return types. If the library defines size_t, then z_size_t is identical to size_t. If not, then z_size_t is an unsigned integer type that can contain a pointer. @@ -1473,22 +1475,22 @@ z_size_t gzfwrite(void* buf, z_size_t size, z_size_t nitems, gzFile file); int gzprintf(gzFile file, const(char)* format, ...); /* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of + Convert, format, compress, and write the arguments (...) to file under + control of the string format, as in fprintf. gzprintf returns the number of uncompressed bytes actually written, or a negative zlib error code in case of error. The number of uncompressed bytes written is limited to 8191, or one less than the buffer size given to gzbuffer(). The caller should assure that this limit is not exceeded. If it is exceeded, then gzprintf() will return an error (0) with nothing written. In this case, there may also be a buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() + zlib was compiled with the insecure functions sprintf() or vsprintf(), because the secure snprintf() or vsnprintf() functions were not available. This can be determined using zlibCompileFlags(). */ int gzputs(gzFile file, const(char)* s); /* - Writes the given null-terminated string to the compressed file, excluding + Compress and write the given null-terminated string s to file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. @@ -1496,11 +1498,12 @@ int gzputs(gzFile file, const(char)* s); const(char)* gzgets(gzFile file, const(char)* buf, int len); /* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. + Read and decompress bytes from file into buf, until len-1 characters are + read, or until a newline character is read and transferred to buf, or an + end-of-file condition is encountered. If any characters are read or if len + is one, the string is terminated with a null character. If no characters + are read due to an end-of-file or len is less than one, then the buffer is + left untouched. gzgets returns buf which is a null-terminated string, or it returns NULL for end-of-file or in case of error. If there was an error, the contents at @@ -1509,13 +1512,13 @@ const(char)* gzgets(gzFile file, const(char)* buf, int len); int gzputc(gzFile file, int c); /* - Writes c, converted to an unsigned char, into the compressed file. gzputc + Compress and write c, converted to an unsigned char, into file. gzputc returns the value that was written, or -1 in case of error. */ int gzgetc(gzFile file); /* - Reads one byte from the compressed file. gzgetc returns this byte or -1 + Read and decompress one byte from file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. As such, it does not do all of the checking the other functions do. I.e. it does not check to see if file is NULL, nor whether the structure file @@ -1524,8 +1527,8 @@ int gzgetc(gzFile file); int gzungetc(int c, gzFile file); /* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. + Push c back onto the stream for file to be read as the first character on + the next read. At least one character of push-back is always allowed. gzungetc() returns the character pushed, or -1 on failure. gzungetc() will fail if c is -1, and may fail if a character has been pushed but not read yet. If gzungetc is used immediately after gzopen or gzdopen, at least the @@ -1536,9 +1539,9 @@ int gzungetc(int c, gzFile file); int gzflush(gzFile file, int flush); /* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. + Flush all pending output to file. The parameter flush is as in the + deflate() function. The return value is the zlib error number (see function + gzerror below). gzflush is only permitted when writing. If the flush parameter is Z_FINISH, the remaining data is written and the gzip stream is completed in the output. If gzwrite() is called again, a new @@ -1551,8 +1554,8 @@ int gzflush(gzFile file, int flush); z_off_t gzseek(gzFile file, z_off_t offset, int whence); /* - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the + Set the starting position to offset relative to whence for the next gzread + or gzwrite on file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. @@ -1569,39 +1572,39 @@ z_off_t gzseek(gzFile file, z_off_t offset, int whence); int gzrewind(gzFile file); /* - Rewinds the given file. This function is supported only for reading. + Rewind file. This function is supported only for reading. - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). */ z_off_t gztell(gzFile file); /* - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). + Return the starting position for the next gzread or gzwrite on file. + This position represents a number of bytes in the uncompressed data stream, + and is zero when starting, even if appending or reading a gzip stream from + the middle of a file using gzdopen(). gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ z_off_t gzoffset(gzFile file); /* - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. + Return the current compressed (actual) read or write offset of file. This + offset includes the count of bytes that precede the gzip stream, for example + when appending or when using gzdopen() for reading. When reading, the + offset does not include as yet unused buffered input. This information can + be used for a progress indicator. On error, gzoffset() returns -1. */ int gzeof(gzFile file); /* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. + Return true (1) if the end-of-file indicator for file has been set while + reading, false (0) otherwise. Note that the end-of-file indicator is set + only if the read tried to go past the end of the input, but came up short. + Therefore, just like feof(), gzeof() may return false even if there is no + more data to read, in the event that the last read request was for the exact + number of bytes remaining in the input file. This will happen if the input + file size is an exact multiple of the buffer size. If gzeof() returns true, then the read functions will return no more data, unless the end-of-file indicator is reset by gzclearerr() and the input file @@ -1610,7 +1613,7 @@ int gzeof(gzFile file); int gzdirect(gzFile file); /* - Returns true (1) if file is being copied directly while reading, or false + Return true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. If the input file is empty, gzdirect() will return true, since the input @@ -1631,8 +1634,8 @@ int gzdirect(gzFile file); int gzclose(gzFile file); /* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you + Flush all pending output for file, if necessary, close file and + deallocate the (de)compression state. Note that once file is closed, you cannot call gzerror with file, since its structures have been deallocated. gzclose must not be called more than once on the same file, just as free must not be called more than once on the same allocation. @@ -1656,10 +1659,10 @@ int gzclose_w(gzFile file); const(char)* gzerror(gzFile file, int* errnum); /* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. + Return the error message for the last error which occurred on file. + errnum is set to zlib error number. If an error occurred in the file system + and not in the compression library, errnum is set to Z_ERRNO and the + application may consult errno to get the exact error code. The application must not modify the returned string. Future calls to this function may invalidate the previously returned string. If file is @@ -1672,7 +1675,7 @@ const(char)* gzerror(gzFile file, int* errnum); void gzclearerr(gzFile file); /* - Clears the error and end-of-file flags for file. This is analogous to the + Clear the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip file that is being written concurrently. */ @@ -1688,8 +1691,9 @@ void gzclearerr(gzFile file); uint adler32(uint adler, const(ubyte)* buf, uint len); /* Update a running Adler-32 checksum with the bytes buf[0 .. len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. + return the updated checksum. An Adler-32 value is in the range of a 32-bit + unsigned integer. If buf is Z_NULL, this function returns the required + initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed much faster. @@ -1722,9 +1726,10 @@ uint adler32_combine(uint adler1, uint adler2, z_off_t len2); uint crc32(uint crc, const(ubyte)* buf, uint len); /* Update a running CRC-32 with the bytes buf[0 .. len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. + updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. + If buf is Z_NULL, this function returns the required initial value for the + crc. Pre- and post-conditioning (one's complement) is performed within this + function so it shouldn't be done by the application. Usage example: @@ -1736,7 +1741,7 @@ uint crc32(uint crc, const(ubyte)* buf, uint len); if (crc != original_crc) error(); */ -uint crc32_z(uint adler, const(ubyte)* buf, z_size_t len); +uint crc32_z(uint crc, const(ubyte)* buf, z_size_t len); /* Same as crc32(), but with a size_t length. */ @@ -1751,6 +1756,18 @@ uint crc32_combine(uint crc1, uint crc2, z_off_t len2); len2. */ +uint crc32_combine_gen(z_off_t len2); +/* + Return the operator corresponding to length len2, to be used with + crc32_combine_op(). +*/ + +uint crc32_combine_op(uint crc1, uint crc2, uint op); +/* + Give the same result as crc32_combine(), using op in place of len2. op is + is generated from len2 by crc32_combine_gen(). This will be faster than + crc32_combine() if the generated op is used more than once. +*/ /* various hacks, don't look :) */ diff --git a/libphobos/src/std/algorithm/internal.d b/libphobos/src/std/algorithm/internal.d index 3caeefeb..6b45599 100644 --- a/libphobos/src/std/algorithm/internal.d +++ b/libphobos/src/std/algorithm/internal.d @@ -62,4 +62,6 @@ version (StdUnittest) } } +// Used instead of `&object.member` when `member` may be +// either a field or a @property function. package(std) T* addressOf(T)(ref T val) { return &val; } diff --git a/libphobos/src/std/algorithm/setops.d b/libphobos/src/std/algorithm/setops.d index ede1831..cc6f5b7 100644 --- a/libphobos/src/std/algorithm/setops.d +++ b/libphobos/src/std/algorithm/setops.d @@ -404,7 +404,7 @@ if (ranges.length >= 2 && r = ranges[i].save; // rollover } } - @property Result save() scope return + @property Result save() return scope { Result copy = this; foreach (i, r; ranges) diff --git a/libphobos/src/std/base64.d b/libphobos/src/std/base64.d index 866f700..d971dba 100644 --- a/libphobos/src/std/base64.d +++ b/libphobos/src/std/base64.d @@ -63,7 +63,7 @@ import std.range.primitives : empty, front, isInputRange, isOutputRange, import std.traits : isArray; // Make sure module header code examples work correctly. -@safe unittest +pure @safe unittest { ubyte[] data = [0x14, 0xfb, 0x9c, 0x03, 0xd9, 0x7e]; @@ -82,7 +82,7 @@ import std.traits : isArray; alias Base64 = Base64Impl!('+', '/'); /// -@safe unittest +pure @safe unittest { ubyte[] data = [0x83, 0xd7, 0x30, 0x7a, 0x01, 0x3f]; assert(Base64.encode(data) == "g9cwegE/"); @@ -98,7 +98,7 @@ alias Base64 = Base64Impl!('+', '/'); alias Base64URL = Base64Impl!('-', '_'); /// -@safe unittest +pure @safe unittest { ubyte[] data = [0x83, 0xd7, 0x30, 0x7a, 0x01, 0x3f]; assert(Base64URL.encode(data) == "g9cwegE_"); @@ -114,7 +114,7 @@ alias Base64URL = Base64Impl!('-', '_'); alias Base64URLNoPadding = Base64Impl!('-', '_', Base64.NoPadding); /// -@safe unittest +pure @safe unittest { ubyte[] data = [0x83, 0xd7, 0x30, 0x7b, 0xef]; assert(Base64URLNoPadding.encode(data) == "g9cwe-8"); @@ -180,7 +180,7 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=') * Returns: * The length of a Base64 encoding of an array of the given length. */ - @safe + @safe @nogc pure nothrow size_t encodeLength(in size_t sourceLength) { static if (Padding == NoPadding) @@ -218,8 +218,8 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=') * The slice of $(D_PARAM buffer) that contains the encoded string. */ @trusted - pure char[] encode(R1, R2)(in R1 source, return scope R2 buffer) if (isArray!R1 && is(ElementType!R1 : ubyte) && - is(R2 == char[])) + pure char[] encode(R1, R2)(const scope R1 source, return scope R2 buffer) + if (isArray!R1 && is(ElementType!R1 : ubyte) && is(R2 == char[])) in { assert(buffer.length >= encodeLength(source.length), "Insufficient buffer for encoding"); @@ -277,9 +277,9 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=') } /// - @safe unittest + @nogc nothrow @safe unittest { - ubyte[] data = [0x83, 0xd7, 0x30, 0x7a, 0x01, 0x3f]; + ubyte[6] data = [0x83, 0xd7, 0x30, 0x7a, 0x01, 0x3f]; char[32] buffer; // much bigger than necessary // Just to be sure... @@ -287,7 +287,7 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=') assert(buffer.length >= encodedLength); // encode() returns a slice to the provided buffer. - auto encoded = Base64.encode(data, buffer[]); + auto encoded = Base64.encode(data[], buffer[]); assert(encoded is buffer[0 .. encodedLength]); assert(encoded == "g9cwegE/"); } diff --git a/libphobos/src/std/bigint.d b/libphobos/src/std/bigint.d index bbb55c2..b2fcc07 100644 --- a/libphobos/src/std/bigint.d +++ b/libphobos/src/std/bigint.d @@ -414,17 +414,17 @@ public: /** * Implements assignment operators of the form `BigInt op= BigInt`. */ - BigInt opOpAssign(string op, T)(T y) pure nothrow @safe scope return + BigInt opOpAssign(string op, T)(T y) pure nothrow @safe return scope if ((op=="+" || op== "-" || op=="*" || op=="|" || op=="&" || op=="^" || op=="/" || op=="%") && is (T: BigInt)) { static if (op == "+") { - data = BigUint.addOrSub(data, y.data, sign != y.sign, &sign); + data = BigUint.addOrSub(data, y.data, sign != y.sign, sign); } else static if (op == "-") { - data = BigUint.addOrSub(data, y.data, sign == y.sign, &sign); + data = BigUint.addOrSub(data, y.data, sign == y.sign, sign); } else static if (op == "*") { @@ -2244,7 +2244,7 @@ void divMod(const BigInt dividend, const BigInt divisor, out BigInt quotient, ou BigUint.divMod(dividend.data, divisor.data, q, r); quotient.sign = dividend.sign != divisor.sign; quotient.data = q; - remainder.sign = dividend.sign; + remainder.sign = r.isZero() ? false : dividend.sign; remainder.data = r; } @@ -2291,6 +2291,14 @@ void divMod(const BigInt dividend, const BigInt divisor, out BigInt quotient, ou assert(q * d + r == -c); } +// https://issues.dlang.org/show_bug.cgi?id=22771 +@safe pure nothrow unittest +{ + BigInt quotient, remainder; + divMod(BigInt(-50), BigInt(1), quotient, remainder); + assert(remainder == 0); +} + // https://issues.dlang.org/show_bug.cgi?id=19740 @safe unittest { diff --git a/libphobos/src/std/bitmanip.d b/libphobos/src/std/bitmanip.d index 9af9d72..de2e0fb 100644 --- a/libphobos/src/std/bitmanip.d +++ b/libphobos/src/std/bitmanip.d @@ -1447,7 +1447,8 @@ public: size_t bitCount; foreach (i; 0 .. fullWords) bitCount += countBitsSet(_ptr[i]); - bitCount += countBitsSet(_ptr[fullWords] & endMask); + if (endBits) + bitCount += countBitsSet(_ptr[fullWords] & endMask); return bitCount; } else diff --git a/libphobos/src/std/complex.d b/libphobos/src/std/complex.d index 485b548..5a15538 100644 --- a/libphobos/src/std/complex.d +++ b/libphobos/src/std/complex.d @@ -935,7 +935,7 @@ Complex!(CommonType!(T, U)) fromPolar(T, U)(const T modulus, const U argument) import std.math.operations : isClose; import std.math.algebraic : sqrt; import std.math.constants : PI_4; - auto z = fromPolar(core.math.sqrt(2.0), PI_4); + auto z = fromPolar(core.math.sqrt(2.0L), PI_4); assert(isClose(z.re, 1.0L)); assert(isClose(z.im, 1.0L)); } @@ -1695,9 +1695,9 @@ Complex!T log(T)(Complex!T x) @safe pure nothrow @nogc */ Complex!T log10(T)(Complex!T x) @safe pure nothrow @nogc { - static import std.math; + import std.math.constants : LN10; - return log(x) / Complex!T(std.math.log(10.0)); + return log(x) / Complex!T(LN10); } /// diff --git a/libphobos/src/std/container/rbtree.d b/libphobos/src/std/container/rbtree.d index 0b0a0b2..622dee4 100644 --- a/libphobos/src/std/container/rbtree.d +++ b/libphobos/src/std/container/rbtree.d @@ -111,7 +111,7 @@ struct RBNode(V) /** * Get the left child */ - @property inout(RBNode)* left() inout + @property inout(RBNode)* left() inout return scope { return _left; } @@ -119,7 +119,7 @@ struct RBNode(V) /** * Get the right child */ - @property inout(RBNode)* right() inout + @property inout(RBNode)* right() inout return scope { return _right; } @@ -127,7 +127,7 @@ struct RBNode(V) /** * Get the parent */ - @property inout(RBNode)* parent() inout + @property inout(RBNode)* parent() inout return scope { return _parent; } @@ -377,7 +377,7 @@ struct RBNode(V) * Returns the next highest valued node in the tree after this one, or end * if this was the highest-valued node. */ - Node remove(Node end) + Node remove(Node end) return { // // remove this node from the tree, fixing the color if necessary. @@ -558,7 +558,7 @@ struct RBNode(V) /** * Return the leftmost descendant of this node. */ - @property inout(RBNode)* leftmost() inout + @property inout(RBNode)* leftmost() inout return { inout(RBNode)* result = &this; while (result._left !is null) @@ -569,7 +569,7 @@ struct RBNode(V) /** * Return the rightmost descendant of this node */ - @property inout(RBNode)* rightmost() inout + @property inout(RBNode)* rightmost() inout return { inout(RBNode)* result = &this; while (result._right !is null) @@ -583,7 +583,7 @@ struct RBNode(V) * You should never call this on the marker node, as it is assumed that * there is a valid next node. */ - @property inout(RBNode)* next() inout + @property inout(RBNode)* next() inout return { inout(RBNode)* n = &this; if (n.right is null) @@ -602,7 +602,7 @@ struct RBNode(V) * You should never call this on the leftmost node of the tree as it is * assumed that there is a valid previous node. */ - @property inout(RBNode)* prev() inout + @property inout(RBNode)* prev() inout return { inout(RBNode)* n = &this; if (n.left is null) diff --git a/libphobos/src/std/conv.d b/libphobos/src/std/conv.d index a10f4da..8f6c3bf 100644 --- a/libphobos/src/std/conv.d +++ b/libphobos/src/std/conv.d @@ -1153,7 +1153,7 @@ if (!(isImplicitlyConvertible!(S, T) && } // https://issues.dlang.org/show_bug.cgi?id=16108 -@system unittest +@safe unittest { static struct A { @@ -1341,12 +1341,12 @@ if (is (T == immutable) && isExactSomeString!T && is(S == enum)) assert(to!string(a) == "[1.5, 2.5]"); } -@system unittest +@safe unittest { // Conversion representing class object with string class A { - override string toString() const { return "an A"; } + override string toString() @safe const { return "an A"; } } A a; assert(to!string(a) == "null"); @@ -1354,7 +1354,7 @@ if (is (T == immutable) && isExactSomeString!T && is(S == enum)) assert(to!string(a) == "an A"); // https://issues.dlang.org/show_bug.cgi?id=7660 - class C { override string toString() const { return "C"; } } + class C { override string toString() @safe const { return "C"; } } struct S { C c; alias c this; } S s; s.c = new C(); assert(to!string(s) == "C"); @@ -1642,7 +1642,7 @@ if (!isImplicitlyConvertible!(S, T) && Array-to-array conversion (except when target is a string type) converts each element in turn by using `to`. */ -private T toImpl(T, S)(S value) +private T toImpl(T, S)(scope S value) if (!isImplicitlyConvertible!(S, T) && !isSomeString!S && isDynamicArray!S && !isExactSomeString!T && isArray!T) @@ -1739,10 +1739,10 @@ if (!isImplicitlyConvertible!(S, T) && isAssociativeArray!S && foreach (k1, v1; value) { // Cast values temporarily to Unqual!V2 to store them to result variable - result[to!K2(k1)] = cast(Unqual!V2) to!V2(v1); + result[to!K2(k1)] = to!(Unqual!V2)(v1); } // Cast back to original type - return cast(T) result; + return () @trusted { return cast(T) result; }(); } @safe unittest @@ -2850,7 +2850,7 @@ do static if (isNarrowString!Source) { import std.string : representation; - auto s = source.representation; + scope s = source.representation; } else { @@ -2898,7 +2898,7 @@ do } static if (isNarrowString!Source) - source = cast(Source) s; + source = source[$ - s.length .. $]; static if (doCount) { @@ -3115,13 +3115,19 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum static if (isNarrowString!Source) { import std.string : representation; - auto p = source.representation; + scope p = source.representation; } else { alias p = source; } + void advanceSource() + { + static if (isNarrowString!Source) + source = source[$ - p.length .. $]; + } + static immutable real[14] negtab = [ 1e-4096L,1e-2048L,1e-1024L,1e-512L,1e-256L,1e-128L,1e-64L,1e-32L, 1e-16L,1e-8L,1e-4L,1e-2L,1e-1L,1.0L ]; @@ -3138,6 +3144,7 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum enforce(!p.empty, bailOut()); + size_t count = 0; bool sign = false; switch (p.front) @@ -3168,8 +3175,7 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum // skip past the last 'f' ++count; p.popFront(); - static if (isNarrowString!Source) - source = cast(Source) p; + advanceSource(); static if (doCount) { return tuple!("data", "count")(sign ? -Target.infinity : Target.infinity, count); @@ -3189,8 +3195,7 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum p.popFront(); if (p.empty) { - static if (isNarrowString!Source) - source = cast(Source) p; + advanceSource(); static if (doCount) { return tuple!("data", "count")(cast (Target) (sign ? -0.0 : 0.0), count); @@ -3222,8 +3227,7 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum // skip past the last 'n' ++count; p.popFront(); - static if (isNarrowString!Source) - source = cast(Source) p; + advanceSource(); static if (doCount) { return tuple!("data", "count")(Target.nan, count); @@ -3418,8 +3422,7 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum // if overflow occurred enforce(ldval != real.infinity, new ConvException("Range error")); - static if (isNarrowString!Source) - source = cast(Source) p; + advanceSource(); static if (doCount) { return tuple!("data", "count")(cast (Target) (sign ? -ldval : ldval), count); @@ -3430,6 +3433,7 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) && !is(Source == enum } } + /// @safe unittest { @@ -5978,3 +5982,14 @@ if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) && } } } + +// Converts an unsigned integer to a compile-time string constant. +package enum toCtString(ulong n) = n.stringof[0 .. $ - "LU".length]; + +// Check that .stringof does what we expect, since it's not guaranteed by the +// language spec. +@safe /*@betterC*/ unittest +{ + assert(toCtString!0 == "0"); + assert(toCtString!123456 == "123456"); +} diff --git a/libphobos/src/std/datetime/interval.d b/libphobos/src/std/datetime/interval.d index ba2a210..d787e3a 100644 --- a/libphobos/src/std/datetime/interval.d +++ b/libphobos/src/std/datetime/interval.d @@ -7848,12 +7848,12 @@ if (isTimePoint!TP && duration = The duration which separates each successive time point in the range. +/ -TP delegate(scope const TP) everyDuration(TP, Direction dir = Direction.fwd, D)(D duration) nothrow +TP delegate(return scope const TP) everyDuration(TP, Direction dir = Direction.fwd, D)(D duration) nothrow if (isTimePoint!TP && __traits(compiles, TP.init + duration) && (dir == Direction.fwd || dir == Direction.bwd)) { - TP func(scope const TP tp) + TP func(return scope const TP tp) { static if (dir == Direction.fwd) return tp + duration; diff --git a/libphobos/src/std/datetime/systime.d b/libphobos/src/std/datetime/systime.d index 9b2a844..e80f122 100644 --- a/libphobos/src/std/datetime/systime.d +++ b/libphobos/src/std/datetime/systime.d @@ -390,6 +390,33 @@ public: hnsecsToUnixEpoch; } } + else version (Hurd) + { + static if (clockType == ClockType.second) + return unixTimeToStdTime(core.stdc.time.time(null)); + else + { + import core.sys.hurd.time : CLOCK_REALTIME_COARSE; + import core.sys.posix.time : clock_gettime, CLOCK_REALTIME; + static if (clockType == ClockType.coarse) alias clockArg = CLOCK_REALTIME_COARSE; + else static if (clockType == ClockType.normal) alias clockArg = CLOCK_REALTIME; + else static if (clockType == ClockType.precise) alias clockArg = CLOCK_REALTIME; + else static assert(0, "Previous static if is wrong."); + timespec ts = void; + immutable error = clock_gettime(clockArg, &ts); + // Posix clock_gettime called with a valid address and valid clock_id is only + // permitted to fail if the number of seconds does not fit in time_t. If tv_sec + // is long or larger overflow won't happen before 292 billion years A.D. + static if (ts.tv_sec.max < long.max) + { + if (error) + throw new TimeException("Call to clock_gettime() failed"); + } + return convert!("seconds", "hnsecs")(ts.tv_sec) + + ts.tv_nsec / 100 + + hnsecsToUnixEpoch; + } + } else static assert(0, "Unsupported OS"); } else static assert(0, "Unsupported OS"); @@ -693,7 +720,7 @@ public: Returns: The `this` of this `SysTime`. +/ - ref SysTime opAssign()(auto ref const(SysTime) rhs) return scope @safe pure nothrow + ref SysTime opAssign()(auto ref const(SysTime) rhs) scope return @safe pure nothrow { _stdTime = rhs._stdTime; _timezone = rhs._timezone; @@ -6269,7 +6296,7 @@ public: duration = The $(REF Duration, core,time) to add to or subtract from this $(LREF SysTime). +/ - SysTime opBinary(string op)(Duration duration) @safe const pure nothrow scope + SysTime opBinary(string op)(Duration duration) @safe const pure nothrow return scope if (op == "+" || op == "-") { SysTime retval = SysTime(this._stdTime, this._timezone); @@ -7668,7 +7695,7 @@ public: $(LREF SysTime) for the last day in the month that this Date is in. The time portion of endOfMonth is always 23:59:59.9999999. +/ - @property SysTime endOfMonth() @safe const nothrow scope + @property SysTime endOfMonth() @safe const nothrow return scope { immutable hnsecs = adjTime; immutable days = getUnitsFromHNSecs!"days"(hnsecs); @@ -8713,13 +8740,14 @@ public: /++ Creates a $(LREF SysTime) from a string with the format - YYYYMMDDTHHMMSS.FFFFFFFTZ (where F is fractional seconds is the time - zone). Whitespace is stripped from the given string. + YYYYMMDDTHHMMSS.FFFFFFFTZ (where F is fractional seconds and TZ + is the time zone). Whitespace is stripped from the given string. - The exact format is exactly as described in `toISOString` except that - trailing zeroes are permitted - including having fractional seconds with - all zeroes. However, a decimal point with nothing following it is - invalid. Also, while $(LREF toISOString) will never generate a string + The exact format is exactly as described in $(LREF toISOString) except + that trailing zeroes are permitted - including having fractional seconds + with all zeroes. The time zone and fractional seconds are optional, + however, a decimal point with nothing following it is invalid. + Also, while $(LREF toISOString) will never generate a string with more than 7 digits in the fractional seconds (because that's the limit with hecto-nanosecond precision), it will allow more than 7 digits in order to read strings from other sources that have higher precision @@ -9024,13 +9052,14 @@ public: /++ Creates a $(LREF SysTime) from a string with the format - YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds is the - time zone). Whitespace is stripped from the given string. + YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ + is the time zone). Whitespace is stripped from the given string. - The exact format is exactly as described in `toISOExtString` + The exact format is exactly as described in $(LREF toISOExtString) except that trailing zeroes are permitted - including having fractional - seconds with all zeroes. However, a decimal point with nothing following - it is invalid. Also, while $(LREF toISOExtString) will never generate a + seconds with all zeroes. The time zone and fractional seconds are + optional, however, a decimal point with nothing following it is invalid. + Also, while $(LREF toISOExtString) will never generate a string with more than 7 digits in the fractional seconds (because that's the limit with hecto-nanosecond precision), it will allow more than 7 digits in order to read strings from other sources that have higher @@ -9273,13 +9302,14 @@ public: /++ Creates a $(LREF SysTime) from a string with the format - YYYY-MM-DD HH:MM:SS.FFFFFFFTZ (where F is fractional seconds is the - time zone). Whitespace is stripped from the given string. + YYYY-Mon-DD HH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ + is the time zone). Whitespace is stripped from the given string. - The exact format is exactly as described in `toSimpleString` except + The exact format is exactly as described in $(LREF toSimpleString) except that trailing zeroes are permitted - including having fractional seconds - with all zeroes. However, a decimal point with nothing following it is - invalid. Also, while $(LREF toSimpleString) will never generate a + with all zeroes. The time zone and fractional seconds are optional, + however, a decimal point with nothing following it is invalid. + Also, while $(LREF toSimpleString) will never generate a string with more than 7 digits in the fractional seconds (because that's the limit with hecto-nanosecond precision), it will allow more than 7 digits in order to read strings from other sources that have higher diff --git a/libphobos/src/std/exception.d b/libphobos/src/std/exception.d index 4f7f3c3..94a2e7a 100644 --- a/libphobos/src/std/exception.d +++ b/libphobos/src/std/exception.d @@ -1641,7 +1641,7 @@ package string errnoString(int errno) nothrow @trusted class ErrnoException : Exception { /// Operating system error code. - final @property uint errno() nothrow pure @nogc @safe { return _errno; } + final @property uint errno() nothrow pure scope @nogc @safe { return _errno; } private uint _errno; /// Constructor which takes an error message. The current global $(REF errno, core,stdc,errno) value is used as error code. this(string msg, string file = null, size_t line = 0) @safe diff --git a/libphobos/src/std/experimental/allocator/mallocator.d b/libphobos/src/std/experimental/allocator/mallocator.d index 895d588..de9afbb 100644 --- a/libphobos/src/std/experimental/allocator/mallocator.d +++ b/libphobos/src/std/experimental/allocator/mallocator.d @@ -392,6 +392,7 @@ version (Posix) AlignedMallocator.instance.alignedReallocate(c, 32, 32); assert(c.ptr); + version (LDC_AddressSanitizer) {} else // AddressSanitizer does not support such large memory allocations (0x10000000000 max) version (DragonFlyBSD) {} else /* FIXME: Malloc on DragonFly does not return NULL when allocating more than UINTPTR_MAX * $(LINK: https://bugs.dragonflybsd.org/issues/3114, dragonfly bug report) * $(LINK: https://github.com/dlang/druntime/pull/1999#discussion_r157536030, PR Discussion) */ diff --git a/libphobos/src/std/experimental/logger/core.d b/libphobos/src/std/experimental/logger/core.d index afd98ad..d899db7 100644 --- a/libphobos/src/std/experimental/logger/core.d +++ b/libphobos/src/std/experimental/logger/core.d @@ -12,56 +12,6 @@ import std.traits; import std.experimental.logger.filelogger; -/** This template evaluates if the passed `LogLevel` is active. -The previously described version statements are used to decide if the -`LogLevel` is active. The version statements only influence the compile -unit they are used with, therefore this function can only disable logging this -specific compile unit. -*/ -template isLoggingActiveAt(LogLevel ll) -{ - version (StdLoggerDisableLogging) - { - enum isLoggingActiveAt = false; - } - else - { - static if (ll == LogLevel.trace) - { - version (StdLoggerDisableTrace) enum isLoggingActiveAt = false; - } - else static if (ll == LogLevel.info) - { - version (StdLoggerDisableInfo) enum isLoggingActiveAt = false; - } - else static if (ll == LogLevel.warning) - { - version (StdLoggerDisableWarning) enum isLoggingActiveAt = false; - } - else static if (ll == LogLevel.error) - { - version (StdLoggerDisableError) enum isLoggingActiveAt = false; - } - else static if (ll == LogLevel.critical) - { - version (StdLoggerDisableCritical) enum isLoggingActiveAt = false; - } - else static if (ll == LogLevel.fatal) - { - version (StdLoggerDisableFatal) enum isLoggingActiveAt = false; - } - // If `isLoggingActiveAt` didn't get defined above to false, - // we default it to true. - static if (!is(typeof(isLoggingActiveAt) == bool)) - { - enum isLoggingActiveAt = true; - } - } -} - -/// This compile-time flag is `true` if logging is not statically disabled. -enum isLoggingActive = isLoggingActiveAt!(LogLevel.all); - /** This functions is used at runtime to determine if a `LogLevel` is active. The same previously defined version statements are used to disable certain levels. Again the version statements are associated with a compile @@ -71,26 +21,6 @@ pure bool isLoggingEnabled()(LogLevel ll) @safe nothrow @nogc bool isLoggingEnabled()(LogLevel ll, LogLevel loggerLL, LogLevel globalLL, lazy bool condition = true) @safe { - switch (ll) - { - case LogLevel.trace: - version (StdLoggerDisableTrace) return false; - else break; - case LogLevel.info: - version (StdLoggerDisableInfo) return false; - else break; - case LogLevel.warning: - version (StdLoggerDisableWarning) return false; - else break; - case LogLevel.critical: - version (StdLoggerDisableCritical) return false; - else break; - case LogLevel.fatal: - version (StdLoggerDisableFatal) return false; - else break; - default: break; - } - return ll >= globalLL && ll >= loggerLL && ll != LogLevel.off @@ -99,66 +29,6 @@ bool isLoggingEnabled()(LogLevel ll, LogLevel loggerLL, && condition; } -/** This template returns the `LogLevel` named "logLevel" of type $(D -LogLevel) defined in a user defined module where the filename has the -suffix "_loggerconfig.d". This `LogLevel` sets the minimal `LogLevel` -of the module. - -A minimal `LogLevel` can be defined on a per module basis. -In order to define a module `LogLevel` a file with a modulename -"MODULENAME_loggerconfig" must be found. If no such module exists and the -module is a nested module, it is checked if there exists a -"PARENT_MODULE_loggerconfig" module with such a symbol. -If this module exists and it contains a `LogLevel` called logLevel this $(D -LogLevel) will be used. This parent lookup is continued until there is no -parent module. Then the moduleLogLevel is `LogLevel.all`. -*/ -template moduleLogLevel(string moduleName) -if (!moduleName.length) -{ - // default - enum moduleLogLevel = LogLevel.all; -} - -/// -@system unittest -{ - static assert(moduleLogLevel!"" == LogLevel.all); -} - -/// ditto -template moduleLogLevel(string moduleName) -if (moduleName.length) -{ - import std.string : format; - mixin(q{ - static if (__traits(compiles, {import %1$s : logLevel;})) - { - import %1$s : logLevel; - static assert(is(typeof(logLevel) : LogLevel), - "Expect 'logLevel' to be of Type 'LogLevel'."); - // don't enforce enum here - alias moduleLogLevel = logLevel; - } - else - // use logLevel of package or default - alias moduleLogLevel = moduleLogLevel!(parentOf(moduleName)); - }.format(moduleName ~ "_loggerconfig")); -} - -/// -@system unittest -{ - static assert(moduleLogLevel!"not.amodule.path" == LogLevel.all); -} - -private string parentOf(string mod) -{ - foreach_reverse (i, c; mod) - if (c == '.') return mod[0 .. i]; - return null; -} - /* This function formates a `SysTime` into an `OutputRange`. The `SysTime` is formatted similar to @@ -200,14 +70,8 @@ void log(int line = __LINE__, string file = __FILE__, lazy bool condition, lazy A args) if (args.length != 1) { - static if (isLoggingActive) - { - if (ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName) - (ll, condition, args); - } - } + stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName) + (ll, condition, args); } /// Ditto @@ -215,14 +79,8 @@ void log(T, string moduleName = __MODULE__)(const LogLevel ll, lazy bool condition, lazy T arg, int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__) { - static if (isLoggingActive) - { - if (ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.log!(T,moduleName)(ll, condition, arg, line, file, funcName, - prettyFuncName); - } - } + stdThreadLocalLog.log!(T,moduleName)(ll, condition, arg, line, file, funcName, + prettyFuncName); } /** This function logs data. @@ -244,14 +102,8 @@ void log(int line = __LINE__, string file = __FILE__, string moduleName = __MODULE__, A...)(const LogLevel ll, lazy A args) if (args.length > 1 && !is(Unqual!(A[0]) : bool)) { - static if (isLoggingActive) - { - if (ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName) - (ll, args); - } - } + stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName) + (ll, args); } /// Ditto @@ -259,14 +111,8 @@ void log(T, string moduleName = __MODULE__)(const LogLevel ll, lazy T arg, int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__) { - static if (isLoggingActive) - { - if (ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.log!T(ll, arg, line, file, funcName, prettyFuncName, - moduleName); - } - } + stdThreadLocalLog.log!T(ll, arg, line, file, funcName, prettyFuncName, + moduleName); } /** This function logs data. @@ -289,11 +135,8 @@ void log(int line = __LINE__, string file = __FILE__, string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args) if (args.length != 1) { - static if (isLoggingActive) - { - stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName) - (stdThreadLocalLog.logLevel, condition, args); - } + stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName) + (stdThreadLocalLog.logLevel, condition, args); } /// Ditto @@ -301,11 +144,8 @@ void log(T, string moduleName = __MODULE__)(lazy bool condition, lazy T arg, int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__) { - static if (isLoggingActive) - { - stdThreadLocalLog.log!(T,moduleName)(stdThreadLocalLog.logLevel, - condition, arg, line, file, funcName, prettyFuncName); - } + stdThreadLocalLog.log!(T,moduleName)(stdThreadLocalLog.logLevel, + condition, arg, line, file, funcName, prettyFuncName); } /** This function logs data. @@ -328,22 +168,16 @@ if ((args.length > 1 && !is(Unqual!(A[0]) : bool) && !is(Unqual!(A[0]) == LogLevel)) || args.length == 0) { - static if (isLoggingActive) - { - stdThreadLocalLog.log!(line, file, funcName, - prettyFuncName, moduleName)(stdThreadLocalLog.logLevel, args); - } + stdThreadLocalLog.log!(line, file, funcName, + prettyFuncName, moduleName)(stdThreadLocalLog.logLevel, args); } void log(T)(lazy T arg, int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__) { - static if (isLoggingActive) - { - stdThreadLocalLog.log!T(stdThreadLocalLog.logLevel, arg, line, file, - funcName, prettyFuncName, moduleName); - } + stdThreadLocalLog.log!T(stdThreadLocalLog.logLevel, arg, line, file, + funcName, prettyFuncName, moduleName); } /** This function logs data in a `printf`-style manner. @@ -369,14 +203,8 @@ void logf(int line = __LINE__, string file = __FILE__, string moduleName = __MODULE__, A...)(const LogLevel ll, lazy bool condition, lazy string msg, lazy A args) { - static if (isLoggingActive) - { - if (ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName) - (ll, condition, msg, args); - } - } + stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName) + (ll, condition, msg, args); } /** This function logs data in a `printf`-style manner. @@ -400,14 +228,8 @@ void logf(int line = __LINE__, string file = __FILE__, string moduleName = __MODULE__, A...)(const LogLevel ll, lazy string msg, lazy A args) { - static if (isLoggingActive) - { - if (ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName) - (ll, msg, args); - } - } + stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName) + (ll, msg, args); } /** This function logs data in a `printf`-style manner. @@ -431,11 +253,8 @@ void logf(int line = __LINE__, string file = __FILE__, string moduleName = __MODULE__, A...)(lazy bool condition, lazy string msg, lazy A args) { - static if (isLoggingActive) - { - stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName) - (stdThreadLocalLog.logLevel, condition, msg, args); - } + stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName) + (stdThreadLocalLog.logLevel, condition, msg, args); } /** This function logs data in a `printf`-style manner. @@ -457,11 +276,8 @@ void logf(int line = __LINE__, string file = __FILE__, string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(lazy string msg, lazy A args) { - static if (isLoggingActive) - { - stdThreadLocalLog.logf!(line, file, funcName,prettyFuncName, moduleName) - (stdThreadLocalLog.logLevel, msg, args); - } + stdThreadLocalLog.logf!(line, file, funcName,prettyFuncName, moduleName) + (stdThreadLocalLog.logLevel, msg, args); } /** This template provides the global log functions with the `LogLevel` @@ -478,11 +294,8 @@ template defaultLogFunction(LogLevel ll) string moduleName = __MODULE__, A...)(lazy A args) if ((args.length > 0 && !is(Unqual!(A[0]) : bool)) || args.length == 0) { - static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName) - { stdThreadLocalLog.memLogFunctions!(ll).logImpl!(line, file, funcName, prettyFuncName, moduleName)(args); - } } void defaultLogFunction(int line = __LINE__, string file = __FILE__, @@ -490,11 +303,8 @@ template defaultLogFunction(LogLevel ll) string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args) { - static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.memLogFunctions!(ll).logImpl!(line, file, funcName, - prettyFuncName, moduleName)(condition, args); - } + stdThreadLocalLog.memLogFunctions!(ll).logImpl!(line, file, funcName, + prettyFuncName, moduleName)(condition, args); } } @@ -551,11 +361,8 @@ template defaultLogFunctionf(LogLevel ll) string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(lazy string msg, lazy A args) { - static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.memLogFunctions!(ll).logImplf!(line, file, funcName, - prettyFuncName, moduleName)(msg, args); - } + stdThreadLocalLog.memLogFunctions!(ll).logImplf!(line, file, funcName, + prettyFuncName, moduleName)(msg, args); } void defaultLogFunctionf(int line = __LINE__, string file = __FILE__, @@ -564,11 +371,8 @@ template defaultLogFunctionf(LogLevel ll) string moduleName = __MODULE__, A...)(lazy bool condition, lazy string msg, lazy A args) { - static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName) - { - stdThreadLocalLog.memLogFunctions!(ll).logImplf!(line, file, funcName, - prettyFuncName, moduleName)(condition, msg, args); - } + stdThreadLocalLog.memLogFunctions!(ll).logImplf!(line, file, funcName, + prettyFuncName, moduleName)(condition, msg, args); } } @@ -816,32 +620,23 @@ abstract class Logger Tid threadId, SysTime timestamp, Logger logger) @safe { - static if (isLoggingActive) - { - msgAppender = appender!string(); - header = LogEntry(file, line, funcName, prettyFuncName, - moduleName, logLevel, threadId, timestamp, null, logger); - } + msgAppender = appender!string(); + header = LogEntry(file, line, funcName, prettyFuncName, + moduleName, logLevel, threadId, timestamp, null, logger); } /** Logs a part of the log message. */ protected void logMsgPart(scope const(char)[] msg) @safe { - static if (isLoggingActive) - { - msgAppender.put(msg); - } + msgAppender.put(msg); } /** Signals that the message has been written and no more calls to `logMsgPart` follow. */ protected void finishLogMsg() @safe { - static if (isLoggingActive) - { - header.msg = msgAppender.data; - this.writeLogMsg(header); - } + header.msg = msgAppender.data; + this.writeLogMsg(header); } /** The `LogLevel` determines if the log call are processed or dropped @@ -895,16 +690,13 @@ abstract class Logger */ void forwardMsg(ref LogEntry payload) @trusted { - static if (isLoggingActive) synchronized (mutex) + if (isLoggingEnabled(payload.logLevel, this.logLevel_, + globalLogLevel)) { - if (isLoggingEnabled(payload.logLevel, this.logLevel_, - globalLogLevel)) - { - this.writeLogMsg(payload); + this.writeLogMsg(payload); - if (payload.logLevel == LogLevel.fatal) - this.fatalHandler_(); - } + if (payload.logLevel == LogLevel.fatal) + this.fatalHandler_(); } } @@ -944,8 +736,7 @@ abstract class Logger string moduleName = __MODULE__, A...)(lazy A args) if (args.length == 0 || (args.length > 0 && !is(A[0] : bool))) { - static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName) - synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel)) { @@ -991,8 +782,7 @@ abstract class Logger string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args) { - static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName) - synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel, condition)) @@ -1040,8 +830,7 @@ abstract class Logger string moduleName = __MODULE__, A...)(lazy bool condition, lazy string msg, lazy A args) { - static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName) - synchronized (mutex) + synchronized (mutex) { import std.format.write : formattedWrite; @@ -1088,8 +877,7 @@ abstract class Logger string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(lazy string msg, lazy A args) { - static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName) - synchronized (mutex) + synchronized (mutex) { import std.format.write : formattedWrite; @@ -1161,7 +949,7 @@ abstract class Logger lazy bool condition, lazy A args) if (args.length != 1) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel, condition)) { @@ -1185,10 +973,9 @@ abstract class Logger string file = __FILE__, string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { - if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel, - condition) && ll >= moduleLogLevel!moduleName) + if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel, condition)) { this.beginLogMsg(file, line, funcName, prettyFuncName, moduleName, ll, thisTid, Clock.currTime, this); @@ -1230,7 +1017,7 @@ abstract class Logger string moduleName = __MODULE__, A...)(const LogLevel ll, lazy A args) if ((args.length > 1 && !is(Unqual!(A[0]) : bool)) || args.length == 0) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel)) { @@ -1254,7 +1041,7 @@ abstract class Logger string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel)) { @@ -1299,7 +1086,7 @@ abstract class Logger string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args) if (args.length != 1) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(this.logLevel_, this.logLevel_, globalLogLevel, condition)) @@ -1324,7 +1111,7 @@ abstract class Logger string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(this.logLevel_, this.logLevel_, globalLogLevel, condition)) @@ -1371,7 +1158,7 @@ abstract class Logger && !is(immutable A[0] == immutable LogLevel)) || args.length == 0) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(this.logLevel_, this.logLevel_, globalLogLevel)) @@ -1395,7 +1182,7 @@ abstract class Logger string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { if (isLoggingEnabled(this.logLevel_, this.logLevel_, globalLogLevel)) { @@ -1442,7 +1229,7 @@ abstract class Logger string moduleName = __MODULE__, A...)(const LogLevel ll, lazy bool condition, lazy string msg, lazy A args) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { import std.format.write : formattedWrite; @@ -1490,7 +1277,7 @@ abstract class Logger string moduleName = __MODULE__, A...)(const LogLevel ll, lazy string msg, lazy A args) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { import std.format.write : formattedWrite; @@ -1539,7 +1326,7 @@ abstract class Logger string moduleName = __MODULE__, A...)(lazy bool condition, lazy string msg, lazy A args) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { import std.format.write : formattedWrite; @@ -1585,7 +1372,7 @@ abstract class Logger string prettyFuncName = __PRETTY_FUNCTION__, string moduleName = __MODULE__, A...)(lazy string msg, lazy A args) { - static if (isLoggingActive) synchronized (mutex) + synchronized (mutex) { import std.format.write : formattedWrite; @@ -1628,19 +1415,20 @@ private @property Logger defaultSharedLoggerImpl() @trusted import core.lifetime : emplace; import std.stdio : stderr; - __gshared align(FileLogger.alignof) void[__traits(classInstanceSize, FileLogger)] _buffer; + __gshared align(__traits(classInstanceAlignment, FileLogger)) + void[__traits(classInstanceSize, FileLogger)] _buffer; import std.concurrency : initOnce; initOnce!stdSharedDefaultLogger({ auto buffer = cast(ubyte[]) _buffer; - return emplace!FileLogger(buffer, stderr, LogLevel.warning); + return emplace!FileLogger(buffer, stderr, LogLevel.info); }()); return stdSharedDefaultLogger; } /** This property sets and gets the default `Logger`. Unless set to another -logger by the user, the default logger's log level is LogLevel.warning. +logger by the user, the default logger's log level is LogLevel.info. Example: ------------- @@ -1762,9 +1550,8 @@ private @property Logger stdThreadLocalLogImpl() @trusted { import core.lifetime : emplace; - static void*[(__traits(classInstanceSize, StdForwardLogger) - 1) / (void*).sizeof + 1] _buffer; - - auto buffer = cast(ubyte[]) _buffer; + static align(__traits(classInstanceAlignment, StdForwardLogger)) + void[__traits(classInstanceSize, StdForwardLogger)] buffer; if (stdLoggerDefaultThreadLogger is null) { @@ -2008,7 +1795,7 @@ version (StdUnittest) private void testFuncNames(Logger logger) @safe auto oldunspecificLogger = sharedLog; - assert(oldunspecificLogger.logLevel == LogLevel.warning, + assert(oldunspecificLogger.logLevel == LogLevel.info, to!string(oldunspecificLogger.logLevel)); assert(l.logLevel == LogLevel.all); @@ -3064,7 +2851,7 @@ private void trustedStore(T)(ref shared T dst, ref T src) @trusted { auto dl = cast(FileLogger) sharedLog; assert(dl !is null); - assert(dl.logLevel == LogLevel.warning); + assert(dl.logLevel == LogLevel.info); assert(globalLogLevel == LogLevel.all); auto tl = cast(StdForwardLogger) stdThreadLocalLog; diff --git a/libphobos/src/std/experimental/logger/filelogger.d b/libphobos/src/std/experimental/logger/filelogger.d index a0bea77..5112e52 100644 --- a/libphobos/src/std/experimental/logger/filelogger.d +++ b/libphobos/src/std/experimental/logger/filelogger.d @@ -263,7 +263,7 @@ class FileLogger : Logger { auto dl = cast(FileLogger) sharedLog; assert(dl !is null); - assert(dl.logLevel == LogLevel.warning); + assert(dl.logLevel == LogLevel.info); assert(globalLogLevel == LogLevel.all); auto tl = cast(StdForwardLogger) stdThreadLocalLog; diff --git a/libphobos/src/std/experimental/logger/multilogger.d b/libphobos/src/std/experimental/logger/multilogger.d index 90bfb58..9acd23a 100644 --- a/libphobos/src/std/experimental/logger/multilogger.d +++ b/libphobos/src/std/experimental/logger/multilogger.d @@ -191,7 +191,7 @@ class MultiLogger : Logger { auto dl = cast(FileLogger) sharedLog; assert(dl !is null); - assert(dl.logLevel == LogLevel.warning); + assert(dl.logLevel == LogLevel.info); assert(globalLogLevel == LogLevel.all); auto tl = cast(StdForwardLogger) stdThreadLocalLog; diff --git a/libphobos/src/std/experimental/logger/package.d b/libphobos/src/std/experimental/logger/package.d index 79245ec..89dc713 100644 --- a/libphobos/src/std/experimental/logger/package.d +++ b/libphobos/src/std/experimental/logger/package.d @@ -146,26 +146,6 @@ To gain more precise control over the logging process, additionally to overriding the `writeLogMsg` method the methods `beginLogMsg`, `logMsgPart` and `finishLogMsg` can be overridden. -$(H3 Compile Time Disabling of `Logger`) -In order to disable logging at compile time, pass `StdLoggerDisableLogging` as a -version argument to the `D` compiler when compiling your program code. -This will disable all logging functionality. -Specific `LogLevel` can be disabled at compile time as well. -In order to disable logging with the `trace` `LogLevel` pass -`StdLoggerDisableTrace` as a version. -The following table shows which version statement disables which -`LogLevel`. -$(TABLE - $(TR $(TD `LogLevel.trace` ) $(TD StdLoggerDisableTrace)) - $(TR $(TD `LogLevel.info` ) $(TD StdLoggerDisableInfo)) - $(TR $(TD `LogLevel.warning` ) $(TD StdLoggerDisableWarning)) - $(TR $(TD `LogLevel.error` ) $(TD StdLoggerDisableError)) - $(TR $(TD `LogLevel.critical` ) $(TD StdLoggerDisableCritical)) - $(TR $(TD `LogLevel.fatal` ) $(TD StdLoggerDisableFatal)) -) -Such a version statement will only disable logging in the associated compile -unit. - $(H3 Provided Logger) By default four `Logger` implementations are given. The `FileLogger` logs data to files. It can also be used to log to `stdout` and `stderr` diff --git a/libphobos/src/std/file.d b/libphobos/src/std/file.d index c974ada..b8b4a8c 100644 --- a/libphobos/src/std/file.d +++ b/libphobos/src/std/file.d @@ -176,9 +176,9 @@ class FileException : Exception private this(scope const(char)[] name, scope const(char)[] msg, string file, size_t line, uint errno) @safe pure { if (msg.empty) - super(name.idup, file, line); + super(name is null ? "(null)" : name.idup, file, line); else - super(text(name, ": ", msg), file, line); + super(text(name is null ? "(null)" : name, ": ", msg), file, line); this.errno = errno; } @@ -214,7 +214,7 @@ class FileException : Exception string file = __FILE__, size_t line = __LINE__) @safe { - this(name, sysErrorString(errno), file, line, errno); + this(name, generateSysErrorMsg(errno), file, line, errno); } else version (Posix) this(scope const(char)[] name, uint errno = .errno, @@ -425,10 +425,10 @@ version (Windows) private void[] readImpl(scope const(char)[] name, scope const( fileSize = makeUlong(sizeLow, sizeHigh); return result; } - static trustedReadFile(HANDLE hFile, void *lpBuffer, ulong nNumberOfBytesToRead) + static trustedReadFile(HANDLE hFile, void *lpBuffer, size_t nNumberOfBytesToRead) { // Read by chunks of size < 4GB (Windows API limit) - ulong totalNumRead = 0; + size_t totalNumRead = 0; while (totalNumRead != nNumberOfBytesToRead) { const uint chunkSize = min(nNumberOfBytesToRead - totalNumRead, 0xffff_0000); @@ -1067,11 +1067,38 @@ private void removeImpl(scope const(char)[] name, scope const(FSChar)* namez) @t if (!name) { import core.stdc.string : strlen; - auto len = strlen(namez); + + auto len = namez ? strlen(namez) : 0; name = namez[0 .. len]; } cenforce(core.stdc.stdio.remove(namez) == 0, - "Failed to remove file " ~ name); + "Failed to remove file " ~ (name is null ? "(null)" : name)); + } +} + +@safe unittest +{ + import std.exception : collectExceptionMsg, assertThrown; + + string filename = null; // e.g. as returned by File.tmpfile.name + + version (linux) + { + // exact exception message is OS-dependent + auto msg = filename.remove.collectExceptionMsg!FileException; + assert("Failed to remove file (null): Bad address" == msg, msg); + } + else version (Windows) + { + import std.algorithm.searching : startsWith; + + // don't test exact message on windows, it's language dependent + auto msg = filename.remove.collectExceptionMsg!FileException; + assert(msg.startsWith("(null):"), msg); + } + else + { + assertThrown!FileException(filename.remove); } } @@ -3471,7 +3498,7 @@ else version (Posix) string getcwd() @trusted while (true) { auto len = GetModuleFileNameW(null, buffer.ptr, cast(DWORD) buffer.length); - enforce(len, sysErrorString(GetLastError())); + wenforce(len); if (len != buffer.length) return to!(string)(buffer[0 .. len]); buffer.length *= 2; @@ -3574,6 +3601,10 @@ else version (Posix) string getcwd() @trusted // Only Solaris 10 and later return readLink(format("/proc/%d/path/a.out", getpid())); } + else version (Hurd) + { + return readLink("/proc/self/exe"); + } else static assert(0, "thisExePath is not supported on this platform"); } @@ -3606,7 +3637,7 @@ version (StdDdoc) Throws: $(LREF FileException) if the file does not exist. +/ - this(string path); + this(return scope string path); version (Windows) { @@ -3768,7 +3799,7 @@ else version (Windows) public: alias name this; - this(string path) + this(return scope string path) { import std.datetime.systime : FILETIMEToSysTime; @@ -3877,7 +3908,7 @@ else version (Posix) public: alias name this; - this(string path) + this(return scope string path) { if (!path.exists) throw new FileException(path, "File does not exist"); @@ -4420,7 +4451,7 @@ void rmdirRecurse(scope const(char)[] pathname) @safe } /// ditto -void rmdirRecurse(ref DirEntry de) @safe +void rmdirRecurse(ref scope DirEntry de) @safe { if (!de.isDir) throw new FileException(de.name, "Not a directory"); @@ -4455,7 +4486,7 @@ void rmdirRecurse(ref DirEntry de) @safe //"rmdirRecurse(in char[] pathname)" implementation. That is needlessly //expensive. //A DirEntry is a bit big (72B), so keeping the "by ref" signature is desirable. -void rmdirRecurse(DirEntry de) @safe +void rmdirRecurse(scope DirEntry de) @safe { rmdirRecurse(de); } @@ -4507,22 +4538,20 @@ version (Posix) @system unittest enforce(!exists(deleteme)); } -@system unittest +@safe unittest { - void[] buf; - - buf = new void[10]; - (cast(byte[]) buf)[] = 3; + ubyte[] buf = new ubyte[10]; + buf[] = 3; string unit_file = deleteme ~ "-unittest_write.tmp"; if (exists(unit_file)) remove(unit_file); - write(unit_file, buf); + write(unit_file, cast(void[]) buf); void[] buf2 = read(unit_file); - assert(buf == buf2); + assert(cast(void[]) buf == buf2); string unit2_file = deleteme ~ "-unittest_write2.tmp"; copy(unit_file, unit2_file); buf2 = read(unit2_file); - assert(buf == buf2); + assert(cast(void[]) buf == buf2); remove(unit_file); assert(!exists(unit_file)); @@ -4635,7 +4664,7 @@ private struct DirIteratorImpl import std.path : chainPath; auto searchPattern = chainPath(directory, "*.*"); - static auto trustedFindFirstFileW(typeof(searchPattern) pattern, WIN32_FIND_DATAW* findinfo) @trusted + static auto trustedFindFirstFileW(typeof(searchPattern) pattern, scope WIN32_FIND_DATAW* findinfo) @trusted { return FindFirstFileW(pattern.tempCString!FSChar(), findinfo); } @@ -4653,7 +4682,7 @@ private struct DirIteratorImpl return toNext(true, &_findinfo); } - bool toNext(bool fetch, WIN32_FIND_DATAW* findinfo) @trusted + bool toNext(bool fetch, scope WIN32_FIND_DATAW* findinfo) @trusted { import core.stdc.wchar_ : wcscmp; @@ -5038,7 +5067,7 @@ auto dirEntries(string path, string pattern, SpanMode mode, return filter!f(DirIterator(path, mode, followSymlink)); } -@system unittest +@safe unittest { import std.stdio : writefln; immutable dpath = deleteme ~ "_dir"; @@ -5055,11 +5084,11 @@ auto dirEntries(string path, string pattern, SpanMode mode, mkdir(dpath); write(fpath, "hello world"); - version (Posix) + version (Posix) () @trusted { core.sys.posix.unistd.symlink((dpath ~ '\0').ptr, (sdpath ~ '\0').ptr); core.sys.posix.unistd.symlink((fpath ~ '\0').ptr, (sfpath ~ '\0').ptr); - } + } (); static struct Flags { bool dir, file, link; } auto tests = [dpath : Flags(true), fpath : Flags(false, true)]; @@ -5274,7 +5303,21 @@ Returns: */ string tempDir() @trusted { - import std.path : dirSeparator; + // We must check that the end of a path is not a separator, before adding another + // If we don't we end up with https://issues.dlang.org/show_bug.cgi?id=22738 + static string addSeparator(string input) + { + import std.path : dirSeparator; + import std.algorithm.searching : endsWith; + + // It is very rare a directory path will reach this point with a directory separator at the end + // However on OSX this can happen, so we must verify lest we break user code i.e. https://github.com/dlang/dub/pull/2208 + if (!input.endsWith(dirSeparator)) + return input ~ dirSeparator; + else + return input; + } + static string cache; if (cache is null) { @@ -5294,7 +5337,7 @@ string tempDir() @trusted static string findExistingDir(T...)(lazy T alternatives) { foreach (dir; alternatives) - if (!dir.empty && exists(dir)) return dir ~ dirSeparator; + if (!dir.empty && exists(dir)) return addSeparator(dir); return null; } @@ -5309,7 +5352,7 @@ string tempDir() @trusted if (cache is null) { - cache = getcwd() ~ dirSeparator; + cache = addSeparator(getcwd()); } } return cache; @@ -5338,6 +5381,9 @@ string tempDir() @trusted import std.algorithm.searching : endsWith; import std.path : dirSeparator; assert(tempDir.endsWith(dirSeparator)); + + // https://issues.dlang.org/show_bug.cgi?id=22738 + assert(!tempDir.endsWith(dirSeparator ~ dirSeparator)); } /** diff --git a/libphobos/src/std/format/internal/write.d b/libphobos/src/std/format/internal/write.d index 68b9e4d..f1d6964 100644 --- a/libphobos/src/std/format/internal/write.d +++ b/libphobos/src/std/format/internal/write.d @@ -2000,8 +2000,7 @@ template hasToString(T, Char) enum hasToString = HasToStringResult.none; } else static if (is(typeof( - { - T val = void; + (T val) { const FormatSpec!Char f; static struct S {void put(scope Char s){}} S s; @@ -2015,8 +2014,7 @@ template hasToString(T, Char) enum hasToString = HasToStringResult.customPutWriterFormatSpec; } else static if (is(typeof( - { - T val = void; + (T val) { static struct S {void put(scope Char s){}} S s; val.toString(s); @@ -2026,36 +2024,36 @@ template hasToString(T, Char) { enum hasToString = HasToStringResult.customPutWriter; } - else static if (is(typeof({ T val = void; FormatSpec!Char f; val.toString((scope const(char)[] s){}, f); }))) + else static if (is(typeof((T val) { FormatSpec!Char f; val.toString((scope const(char)[] s){}, f); }))) { enum hasToString = HasToStringResult.constCharSinkFormatSpec; } - else static if (is(typeof({ T val = void; val.toString((scope const(char)[] s){}, "%s"); }))) + else static if (is(typeof((T val) { val.toString((scope const(char)[] s){}, "%s"); }))) { enum hasToString = HasToStringResult.constCharSinkFormatString; } - else static if (is(typeof({ T val = void; val.toString((scope const(char)[] s){}); }))) + else static if (is(typeof((T val) { val.toString((scope const(char)[] s){}); }))) { enum hasToString = HasToStringResult.constCharSink; } else static if (hasPreviewIn && - is(typeof({ T val = void; FormatSpec!Char f; val.toString((in char[] s){}, f); }))) + is(typeof((T val) { FormatSpec!Char f; val.toString((in char[] s){}, f); }))) { enum hasToString = HasToStringResult.inCharSinkFormatSpec; } else static if (hasPreviewIn && - is(typeof({ T val = void; val.toString((in char[] s){}, "%s"); }))) + is(typeof((T val) { val.toString((in char[] s){}, "%s"); }))) { enum hasToString = HasToStringResult.inCharSinkFormatString; } else static if (hasPreviewIn && - is(typeof({ T val = void; val.toString((in char[] s){}); }))) + is(typeof((T val) { val.toString((in char[] s){}); }))) { enum hasToString = HasToStringResult.inCharSink; } - else static if (is(typeof({ T val = void; return val.toString(); }()) S) && isSomeString!S) + else static if (is(ReturnType!((T val) { return val.toString(); }) S) && isSomeString!S) { enum hasToString = HasToStringResult.hasSomeToString; } @@ -2171,6 +2169,133 @@ template hasToString(T, Char) } } +// const toString methods +@safe unittest +{ + import std.range.primitives : isOutputRange; + + static struct A + { + void toString(Writer)(ref Writer w) const + if (isOutputRange!(Writer, string)) + {} + } + static struct B + { + void toString(scope void delegate(scope const(char)[]) sink, scope FormatSpec!char fmt) const {} + } + static struct C + { + void toString(scope void delegate(scope const(char)[]) sink, string fmt) const {} + } + static struct D + { + void toString(scope void delegate(scope const(char)[]) sink) const {} + } + static struct E + { + string toString() const {return "";} + } + static struct F + { + void toString(Writer)(ref Writer w, scope const ref FormatSpec!char fmt) const + if (isOutputRange!(Writer, string)) + {} + } + static struct G + { + string toString() const {return "";} + void toString(Writer)(ref Writer w) const if (isOutputRange!(Writer, string)) {} + } + static struct H + { + string toString() const {return "";} + void toString(Writer)(ref Writer w, scope const ref FormatSpec!char fmt) const + if (isOutputRange!(Writer, string)) + {} + } + static struct I + { + void toString(Writer)(ref Writer w) const if (isOutputRange!(Writer, string)) {} + void toString(Writer)(ref Writer w, scope const ref FormatSpec!char fmt) const + if (isOutputRange!(Writer, string)) + {} + } + static struct J + { + string toString() const {return "";} + void toString(Writer)(ref Writer w, scope ref FormatSpec!char fmt) const + if (isOutputRange!(Writer, string)) + {} + } + static struct K + { + void toString(Writer)(Writer w, scope const ref FormatSpec!char fmt) const + if (isOutputRange!(Writer, string)) + {} + } + static struct L + { + void toString(Writer)(ref Writer w, scope const FormatSpec!char fmt) const + if (isOutputRange!(Writer, string)) + {} + } + static struct M + { + void toString(scope void delegate(in char[]) sink, in FormatSpec!char fmt) const {} + } + static struct N + { + void toString(scope void delegate(in char[]) sink, string fmt) const {} + } + static struct O + { + void toString(scope void delegate(in char[]) sink) const {} + } + + with(HasToStringResult) + { + static assert(hasToString!(A, char) == customPutWriter); + static assert(hasToString!(B, char) == constCharSinkFormatSpec); + static assert(hasToString!(C, char) == constCharSinkFormatString); + static assert(hasToString!(D, char) == constCharSink); + static assert(hasToString!(E, char) == hasSomeToString); + static assert(hasToString!(F, char) == customPutWriterFormatSpec); + static assert(hasToString!(G, char) == customPutWriter); + static assert(hasToString!(H, char) == customPutWriterFormatSpec); + static assert(hasToString!(I, char) == customPutWriterFormatSpec); + static assert(hasToString!(J, char) == hasSomeToString); + static assert(hasToString!(K, char) == constCharSinkFormatSpec); + static assert(hasToString!(L, char) == none); + static if (hasPreviewIn) + { + static assert(hasToString!(M, char) == inCharSinkFormatSpec); + static assert(hasToString!(N, char) == inCharSinkFormatString); + static assert(hasToString!(O, char) == inCharSink); + } + + // https://issues.dlang.org/show_bug.cgi?id=22873 + static assert(hasToString!(inout(A), char) == customPutWriter); + static assert(hasToString!(inout(B), char) == constCharSinkFormatSpec); + static assert(hasToString!(inout(C), char) == constCharSinkFormatString); + static assert(hasToString!(inout(D), char) == constCharSink); + static assert(hasToString!(inout(E), char) == hasSomeToString); + static assert(hasToString!(inout(F), char) == customPutWriterFormatSpec); + static assert(hasToString!(inout(G), char) == customPutWriter); + static assert(hasToString!(inout(H), char) == customPutWriterFormatSpec); + static assert(hasToString!(inout(I), char) == customPutWriterFormatSpec); + static assert(hasToString!(inout(J), char) == hasSomeToString); + static assert(hasToString!(inout(K), char) == constCharSinkFormatSpec); + static assert(hasToString!(inout(L), char) == none); + static if (hasPreviewIn) + { + static assert(hasToString!(inout(M), char) == inCharSinkFormatSpec); + static assert(hasToString!(inout(N), char) == inCharSinkFormatString); + static assert(hasToString!(inout(O), char) == inCharSink); + } + } +} + // object formatting with toString private void formatObject(Writer, T, Char)(ref Writer w, ref T val, scope const ref FormatSpec!Char f) if (hasToString!(T, Char)) diff --git a/libphobos/src/std/format/package.d b/libphobos/src/std/format/package.d index 6c9e9ae..76d68f6 100644 --- a/libphobos/src/std/format/package.d +++ b/libphobos/src/std/format/package.d @@ -1589,7 +1589,7 @@ char[] sformat(alias fmt, Args...)(char[] buf, Args args) if (isSomeString!(typeof(fmt))) { alias e = checkFormatException!(fmt, Args); - static assert(!e, e.msg); + static assert(!e, e); return .sformat(buf, fmt, args); } diff --git a/libphobos/src/std/format/read.d b/libphobos/src/std/format/read.d index b3d8d1f..144fa8c 100644 --- a/libphobos/src/std/format/read.d +++ b/libphobos/src/std/format/read.d @@ -305,7 +305,7 @@ if (isSomeString!(typeof(fmt))) import std.format : checkFormatException; alias e = checkFormatException!(fmt, Args); - static assert(!e, e.msg); + static assert(!e, e); return .formattedRead(r, fmt, args); } diff --git a/libphobos/src/std/format/write.d b/libphobos/src/std/format/write.d index e67d95c..cbab512 100644 --- a/libphobos/src/std/format/write.d +++ b/libphobos/src/std/format/write.d @@ -677,7 +677,7 @@ if (isSomeString!(typeof(fmt))) import std.format : checkFormatException; alias e = checkFormatException!(fmt, Args); - static assert(!e, e.msg); + static assert(!e, e); return .formattedWrite(w, fmt, args); } diff --git a/libphobos/src/std/functional.d b/libphobos/src/std/functional.d index bc8d368..70aaee3 100644 --- a/libphobos/src/std/functional.d +++ b/libphobos/src/std/functional.d @@ -65,9 +65,12 @@ module std.functional; import std.meta : AliasSeq, Reverse; import std.traits : isCallable, Parameters; +import std.conv : toCtString; import std.internal.attributes : betterC; +public import core.lifetime : forward; + private template needOpCallAlias(alias fun) { /* Determine whether or not unaryFun and binaryFun need to alias to fun or @@ -1846,9 +1849,156 @@ if (isCallable!(F)) } } -// forward used to be here but was moved to druntime -template forward(args...) +/** + * Passes the fields of a struct as arguments to a function. + * + * Can be used with a $(LINK2 https://dlang.org/spec/expression.html#function_literals, + * function literal) to give temporary names to the fields of a struct or + * tuple. + * + * Params: + * fun = Callable that the struct's fields will be passed to. + * + * Returns: + * A function that accepts a single struct as an argument and passes its + * fields to `fun` when called. + */ +template bind(alias fun) +{ + /** + * Params: + * args = The struct or tuple whose fields will be used as arguments. + * + * Returns: `fun(args.tupleof)` + */ + auto ref bind(T)(auto ref T args) + if (is(T == struct)) + { + import std.meta : Map = staticMap; + import core.lifetime : move; + + // Forwards the i'th member of `args` + // Needed because core.lifetime.forward doesn't work on struct members + template forwardArg(size_t i) + { + static if (__traits(isRef, args) || !is(typeof(move(args.tupleof[i])))) + enum forwardArg = "args.tupleof[" ~ toCtString!i ~ "], "; + else + enum forwardArg = "move(args.tupleof[" ~ toCtString!i ~ "]), "; + } + + static if (args.tupleof.length == 0) + enum argList = ""; + else + alias argList = Map!(forwardArg, Iota!(args.tupleof.length)); + + return mixin("fun(", argList, ")"); + } +} + +/// Giving names to tuple elements +@safe unittest +{ + import std.typecons : tuple; + + auto name = tuple("John", "Doe"); + string full = name.bind!((first, last) => first ~ " " ~ last); + assert(full == "John Doe"); +} + +/// Passing struct fields to a function +@safe unittest { - import core.lifetime : fun = forward; - alias forward = fun!args; + import std.algorithm.comparison : min, max; + + struct Pair + { + int a; + int b; + } + + auto p = Pair(123, 456); + assert(p.bind!min == 123); // min(p.a, p.b) + assert(p.bind!max == 456); // max(p.a, p.b) +} + +/// In a range pipeline +@safe unittest +{ + import std.algorithm.iteration : map, filter; + import std.algorithm.comparison : equal; + import std.typecons : tuple; + + auto ages = [ + tuple("Alice", 35), + tuple("Bob", 64), + tuple("Carol", 21), + tuple("David", 39), + tuple("Eve", 50) + ]; + + auto overForty = ages + .filter!(bind!((name, age) => age > 40)) + .map!(bind!((name, age) => name)); + + assert(overForty.equal(["Bob", "Eve"])); +} + +// Zero arguments +@safe unittest +{ + struct Empty {} + + assert(Empty().bind!(() => 123) == 123); +} + +// Non-copyable arguments +@safe unittest +{ + import std.typecons : tuple; + + static struct NoCopy + { + int n; + @disable this(this); + } + + static struct Pair + { + NoCopy a, b; + } + + static auto fun(NoCopy a, NoCopy b) + { + return tuple(a.n, b.n); + } + + auto expected = fun(NoCopy(1), NoCopy(2)); + assert(Pair(NoCopy(1), NoCopy(2)).bind!fun == expected); +} + +// ref arguments +@safe unittest +{ + import std.typecons : tuple; + + auto t = tuple(123, 456); + t.bind!((ref int a, int b) { a = 789; b = 1011; }); + + assert(t[0] == 789); + assert(t[1] == 456); +} + +// auto ref arguments +@safe unittest +{ + import std.typecons : tuple; + + auto t = tuple(123); + t.bind!((auto ref x) { + static assert(__traits(isRef, x)); + }); + tuple(123).bind!((auto ref x) { + static assert(!__traits(isRef, x)); + }); } diff --git a/libphobos/src/std/getopt.d b/libphobos/src/std/getopt.d index 482aae6..c1c5cd2 100644 --- a/libphobos/src/std/getopt.d +++ b/libphobos/src/std/getopt.d @@ -438,7 +438,7 @@ GetoptResult getopt(T...)(ref string[] args, T opts) } /// -@system unittest +@safe unittest { auto args = ["prog", "--foo", "-b"]; @@ -1646,11 +1646,13 @@ Params: text = The text to printed at the beginning of the help output. opt = The `Option` extracted from the `getopt` parameter. */ -void defaultGetoptPrinter(string text, Option[] opt) +void defaultGetoptPrinter(string text, Option[] opt) @safe { import std.stdio : stdout; + // stdout global __gshared is trusted with a locked text writer + auto w = (() @trusted => stdout.lockingTextWriter())(); - defaultGetoptFormatter(stdout.lockingTextWriter(), text, opt); + defaultGetoptFormatter(w, text, opt); } /** This function writes the passed text and `Option` into an output range diff --git a/libphobos/src/std/int128.d b/libphobos/src/std/int128.d new file mode 100644 index 0000000..fc992f8 --- /dev/null +++ b/libphobos/src/std/int128.d @@ -0,0 +1,374 @@ +// Written in the D programming language +/** + * Implements a signed 128 bit integer type. + * + Author: Walter Bright + Copyright: Copyright (c) 2022, D Language Foundation + License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0) + Source: $(PHOBOSSRC std/int128.d) + */ +module std.int128; + +private import core.int128; + + +/*********************************** + * 128 bit signed integer type. + */ + +public struct Int128 +{ + @safe pure nothrow @nogc: + + Cent data; /// core.int128.Cent + + /**************** + * Construct an `Int128` from a `long` value. + * The upper 64 bits are formed by sign extension. + * Params: + * lo = signed lower 64 bits + */ + this(long lo) + { + data.lo = lo; + data.hi = lo < 0 ? ~0L : 0; + } + + /**************** + * Construct an `Int128` from a `ulong` value. + * The upper 64 bits are set to zero. + * Params: + * lo = unsigned lower 64 bits + */ + this(ulong lo) + { + data.lo = lo; + data.hi = 0; + } + + /**************** + * Construct an `Int128` from a `long` value. + * Params: + * hi = upper 64 bits + * lo = lower 64 bits + */ + this(long hi, long lo) + { + data.hi = hi; + data.lo = lo; + } + + /******************** + * Construct an `Int128` from a `Cent`. + * Params: + * data = Cent data + */ + this(Cent data) + { + this.data = data; + } + + /******************** + * Returns: hash value for Int128 + */ + size_t toHash() const + { + return cast(size_t)((data.lo & 0xFFFF_FFFF) + (data.hi & 0xFFFF_FFFF) + (data.lo >> 32) + (data.hi >> 32)); + } + + /************************ + * Compare for equality + * Params: lo = signed value to compare with + * Returns: true if Int128 equals value + */ + bool opEquals(long lo) const + { + return data.lo == lo && data.hi == (lo >> 63); + } + + /************************ + * Compare for equality + * Params: lo = unsigned value to compare with + * Returns: true if Int128 equals value + */ + bool opEquals(ulong lo) const + { + return data.hi == 0 && data.lo == lo; + } + + /************************ + * Compare for equality + * Params: op2 = value to compare with + * Returns: true if Int128 equals value + */ + bool opEquals(Int128 op2) const + { + return data.hi == op2.data.hi && data.lo == op2.data.lo; + } + + /** Support unary arithmentic operator + + * Params: op = "+" + * Returns: lvalue of result + */ + Int128 opUnary(string op)() const + if (op == "+") + { + return this; + } + + /** Support unary arithmentic operator - ~ + * Params: op = "-", "~" + * Returns: lvalue of result + */ + Int128 opUnary(string op)() const + if (op == "-" || op == "~") + { + static if (op == "-") + return Int128(neg(this.data)); + else static if (op == "~") + return Int128(com(this.data)); + } + + /** Support unary arithmentic operator ++ -- + * Params: op = "++", "--" + * Returns: lvalue of result + */ + Int128 opUnary(string op)() + if (op == "++" || op == "--") + { + static if (op == "++") + this.data = inc(this.data); + else static if (op == "--") + this.data = dec(this.data); + else + static assert(0, op); + return this; + } + + /** Support casting to a bool + * Params: T = bool + * Returns: boolean result + */ + bool opCast(T : bool)() const + { + return tst(this.data); + } + + /** Support binary arithmetic operators + - * / % & | ^ << >> >>> + * Params: + * op = one of the arithmetic binary operators + * op2 = second operand + * Returns: value after the operation is applied + */ + Int128 opBinary(string op)(Int128 op2) const + if (op == "+" || op == "-" || + op == "*" || op == "/" || op == "%" || + op == "&" || op == "|" || op == "^") + { + static if (op == "+") + return Int128(add(this.data, op2.data)); + else static if (op == "-") + return Int128(sub(this.data, op2.data)); + else static if (op == "*") + return Int128(mul(this.data, op2.data)); + else static if (op == "/") + return Int128(div(this.data, op2.data)); + else static if (op == "%") + { + Cent modulus; + divmod(this.data, op2.data, modulus); + return Int128(modulus); + } + else static if (op == "&") + return Int128(and(this.data, op2.data)); + else static if (op == "|") + return Int128(or(this.data, op2.data)); + else static if (op == "^") + return Int128(xor(this.data, op2.data)); + else + static assert(0, "wrong op value"); + } + + /// ditto + Int128 opBinary(string op)(long op2) const + if (op == "+" || op == "-" || + op == "*" || op == "/" || op == "%" || + op == "&" || op == "|" || op == "^") + { + return mixin("this " ~ op ~ " Int128(0, op2)"); + } + + /// ditto + Int128 opBinaryRight(string op)(long op2) const + if (op == "+" || op == "-" || + op == "*" || op == "/" || op == "%" || + op == "&" || op == "|" || op == "^") + { + mixin("return Int128(0, op2) " ~ op ~ " this;"); + } + + /// ditto + Int128 opBinary(string op)(long op2) const + if (op == "<<") + { + return Int128(shl(this.data, cast(uint) op2)); + } + + /// ditto + Int128 opBinary(string op)(long op2) const + if (op == ">>") + { + return Int128(sar(this.data, cast(uint) op2)); + } + + /// ditto + Int128 opBinary(string op)(long op2) const + if (op == ">>>") + { + return Int128(shr(this.data, cast(uint) op2)); + } + + /** arithmetic assignment operators += -= *= /= %= &= |= ^= <<= >>= >>>= + * Params: op = one of +, -, etc. + * op2 = second operand + * Returns: lvalue of updated left operand + */ + ref Int128 opOpAssign(string op)(Int128 op2) + if (op == "+" || op == "-" || + op == "*" || op == "/" || op == "%" || + op == "&" || op == "|" || op == "^" || + op == "<<" || op == ">>" || op == ">>>") + { + mixin("this = this " ~ op ~ " op2;"); + return this; + } + + /// ditto + ref Int128 opOpAssign(string op)(long op2) + if (op == "+" || op == "-" || + op == "*" || op == "/" || op == "%" || + op == "&" || op == "|" || op == "^" || + op == "<<" || op == ">>" || op == ">>>") + { + mixin("this = this " ~ op ~ " op2;"); + return this; + } + + /** support signed arithmentic comparison operators < <= > >= + * Params: op2 = right hand operand + * Returns: -1 for less than, 0 for equals, 1 for greater than + */ + int opCmp(Int128 op2) const + { + return this == op2 ? 0 : gt(this.data, op2.data) * 2 - 1; + } + + /** support signed arithmentic comparison operators < <= > >= + * Params: op2 = right hand operand + * Returns: -1 for less than, 0 for equals, 1 for greater than + */ + int opCmp(long op2) const + { + return opCmp(Int128(0, op2)); + } + + enum min = Int128(long.min, 0); /// minimum value + enum max = Int128(long.max, ulong.max); /// maximum value +} + +/********************************************* Tests ************************************/ + +version (unittest) +{ +import core.stdc.stdio; + +@trusted void print(Int128 c) +{ + printf("%lld, %lld\n", c.data.hi, c.data.lo); +} + +@trusted void printx(Int128 c) +{ + printf("%llx, %llx\n", c.data.hi, c.data.lo); +} +} + +/// Int128 tests +@safe pure nothrow @nogc +unittest +{ + Int128 c = Int128(5, 6); + assert(c == c); + assert(c == +c); + assert(c == - -c); + assert(~c == Int128(~5, ~6)); + ++c; + assert(c == Int128(5, 7)); + assert(--c == Int128(5, 6)); + assert(!!c); + assert(!Int128()); + + assert(c + Int128(10, 20) == Int128(15, 26)); + assert(c - Int128(1, 2) == Int128(4, 4)); + assert(c * Int128(100, 2) == Int128(610, 12)); + assert(c / Int128(3, 2) == Int128(0, 1)); + assert(c % Int128(3, 2) == Int128(2, 4)); + assert((c & Int128(3, 2)) == Int128(1, 2)); + assert((c | Int128(3, 2)) == Int128(7, 6)); + assert((c ^ Int128(3, 2)) == Int128(6, 4)); + + assert(c + 15 == Int128(5, 21)); + assert(c - 15 == Int128(4, -9)); + assert(c * 15 == Int128(75, 90)); + assert(c / 15 == Int128(0, 6148914691236517205)); + assert(c % 15 == Int128(0, 11)); + assert((c & 15) == Int128(0, 6)); + assert((c | 15) == Int128(5, 15)); + assert((c ^ 15) == Int128(5, 9)); + + assert(15 + c == Int128(5, 21)); + assert(15 - c == Int128(-5, 9)); + assert(15 * c == Int128(75, 90)); + assert(15 / c == Int128(0, 0)); + assert(15 % c == Int128(0, 15)); + assert((15 & c) == Int128(0, 6)); + assert((15 | c) == Int128(5, 15)); + assert((15 ^ c) == Int128(5, 9)); + + assert(c << 1 == Int128(10, 12)); + assert(-c >> 1 == Int128(-3, 9223372036854775805)); + assert(-c >>> 1 == Int128(9223372036854775805, 9223372036854775805)); + + assert((c += 1) == Int128(5, 7)); + assert((c -= 1) == Int128(5, 6)); + assert((c += Int128(0, 1)) == Int128(5, 7)); + assert((c -= Int128(0, 1)) == Int128(5, 6)); + assert((c *= 2) == Int128(10, 12)); + assert((c /= 2) == Int128(5, 6)); + assert((c %= 2) == Int128()); + c += Int128(5, 6); + assert((c *= Int128(10, 20)) == Int128(160, 120)); + assert((c /= Int128(10, 20)) == Int128(0, 15)); + c += Int128(72, 0); + assert((c %= Int128(10, 20)) == Int128(1, -125)); + assert((c &= Int128(3, 20)) == Int128(1, 0)); + assert((c |= Int128(8, 2)) == Int128(9, 2)); + assert((c ^= Int128(8, 2)) == Int128(1, 0)); + c |= Int128(10, 5); + assert((c <<= 1) == Int128(11 * 2, 5 * 2)); + assert((c >>>= 1) == Int128(11, 5)); + c = Int128(long.min, long.min); + assert((c >>= 1) == Int128(long.min >> 1, cast(ulong) long.min >> 1)); + + assert(-Int128.min == Int128.min); + assert(Int128.max + 1 == Int128.min); + + c = Int128(5, 6); + assert(c < Int128(6, 5)); + assert(c > 10); + + c = Int128(-1UL); + assert(c == -1UL); + c = Int128(-1L); + assert(c == -1L); +} diff --git a/libphobos/src/std/internal/math/biguintcore.d b/libphobos/src/std/internal/math/biguintcore.d index 6a93e0a..d5c4768 100644 --- a/libphobos/src/std/internal/math/biguintcore.d +++ b/libphobos/src/std/internal/math/biguintcore.d @@ -813,7 +813,7 @@ public: // If wantSub is false, return x + y, leaving sign unchanged. // If wantSub is true, return abs(x - y), negating sign if x<y - static BigUint addOrSub(scope BigUint x, scope BigUint y, bool wantSub, bool *sign) + static BigUint addOrSub(scope BigUint x, scope BigUint y, bool wantSub, ref bool sign) pure nothrow @safe { BigUint r; @@ -822,10 +822,10 @@ public: bool negative; // sub returns GC allocated array, can be safely cast to immutable r.data = (() @trusted => cast(immutable) sub(x.data, y.data, &negative))(); - *sign ^= negative; + sign ^= negative; if (r.isZero()) { - *sign = false; + sign = false; } } else diff --git a/libphobos/src/std/json.d b/libphobos/src/std/json.d index 89def0f..c6e746a 100644 --- a/libphobos/src/std/json.d +++ b/libphobos/src/std/json.d @@ -321,7 +321,7 @@ struct JSONValue (*a)[0] = "world"; // segmentation fault --- */ - @property ref inout(JSONValue[]) array() return scope inout pure @system + @property ref inout(JSONValue[]) array() scope return inout pure @system { enforce!JSONException(type == JSONType.array, "JSONValue is not an array"); diff --git a/libphobos/src/std/math/algebraic.d b/libphobos/src/std/math/algebraic.d index db70b7a..4791766 100644 --- a/libphobos/src/std/math/algebraic.d +++ b/libphobos/src/std/math/algebraic.d @@ -496,9 +496,9 @@ if (isFloatingPoint!T) [ 1.0L, 4.0L, 8.0L, 9.0L ], [ 4.0L, 4.0L, 7.0L, 9.0L ], [ 12.0L, 16.0L, 21.0L, 29.0L ], - [ 1e+8L, 1.0L, 1e-8L, 1e+8L ], - [ 1.0L, 1e+8L, 1e-8L, 1e+8L ], - [ 1e-8L, 1.0L, 1e+8L, 1e+8L ], + [ 1e+8L, 1.0L, 1e-8L, 1e+8L+5e-9L ], + [ 1.0L, 1e+8L, 1e-8L, 1e+8L+5e-9L ], + [ 1e-8L, 1.0L, 1e+8L, 1e+8L+5e-9L ], [ 1e-2L, 1e-4L, 1e-4L, 0.010000999950004999375L ], [ 2147483647.0L, 2147483647.0L, 2147483647.0L, 3719550785.027307813987L ] ]; diff --git a/libphobos/src/std/math/exponential.d b/libphobos/src/std/math/exponential.d index a9ec930..e32330f 100644 --- a/libphobos/src/std/math/exponential.d +++ b/libphobos/src/std/math/exponential.d @@ -968,10 +968,10 @@ if (isUnsigned!F && isUnsigned!G && isUnsigned!H) pragma(inline, true) real exp(real x) @trusted pure nothrow @nogc // TODO: @safe { - import std.math.constants : LOG2E; - version (InlineAsm_X87) { + import std.math.constants : LOG2E; + // e^^x = 2^^(LOG2E*x) // (This is valid because the overflow & underflow limits for exp // and exp2 are so similar). @@ -2862,14 +2862,16 @@ float ldexp(float n, int exp) @safe pure nothrow @nogc { return core.math.ldex private { - import std.math : floatTraits, RealFormat; - - version (INLINE_YL2X) {} else + // Coefficients shared across log(), log2(), log10(). + template LogCoeffs(T) { - static if (floatTraits!real.realFormat == RealFormat.ieeeQuadruple) + import std.math : floatTraits, RealFormat; + + static if (floatTraits!T.realFormat == RealFormat.ieeeQuadruple) { - // Coefficients for log(1 + x) = x - x**2/2 + x**3 P(x)/Q(x) - static immutable real[13] logCoeffsP = [ + // Coefficients for log(1 + x) = x - x^^2/2 + x^^3 P(x)/Q(x) + // Theoretical peak relative error = 5.3e-37 + static immutable real[13] logP = [ 1.313572404063446165910279910527789794488E4L, 7.771154681358524243729929227226708890930E4L, 2.014652742082537582487669938141683759923E5L, @@ -2884,7 +2886,7 @@ private 4.998469661968096229986658302195402690910E-1L, 1.538612243596254322971797716843006400388E-6L ]; - static immutable real[13] logCoeffsQ = [ + static immutable real[13] logQ = [ 3.940717212190338497730839731583397586124E4L, 2.626900195321832660448791748036714883242E5L, 7.777690340007566932935753241556479363645E5L, @@ -2900,9 +2902,18 @@ private 1.0 ]; - // Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2) + // log2 uses the same coefficients as log. + alias log2P = logP; + alias log2Q = logQ; + + // log10 uses the same coefficients as log. + alias log10P = logP; + alias log10Q = logQ; + + // Coefficients for log(x) = z + z^^3 P(z^^2)/Q(z^^2) // where z = 2(x-1)/(x+1) - static immutable real[6] logCoeffsR = [ + // Theoretical peak relative error = 1.1e-35 + static immutable real[6] logR = [ 1.418134209872192732479751274970992665513E5L, -8.977257995689735303686582344659576526998E4L, 2.048819892795278657810231591630928516206E4L, @@ -2910,7 +2921,7 @@ private 8.057002716646055371965756206836056074715E1L, -8.828896441624934385266096344596648080902E-1L ]; - static immutable real[7] logCoeffsS = [ + static immutable real[7] logS = [ 1.701761051846631278975701529965589676574E6L, -1.332535117259762928288745111081235577029E6L, 4.001557694070773974936904547424676279307E5L, @@ -2922,8 +2933,9 @@ private } else { - // Coefficients for log(1 + x) = x - x**2/2 + x**3 P(x)/Q(x) - static immutable real[7] logCoeffsP = [ + // Coefficients for log(1 + x) = x - x^^2/2 + x^^3 P(x)/Q(x) + // Theoretical peak relative error = 2.32e-20 + static immutable real[7] logP = [ 2.0039553499201281259648E1L, 5.7112963590585538103336E1L, 6.0949667980987787057556E1L, @@ -2932,7 +2944,7 @@ private 4.9854102823193375972212E-1L, 4.5270000862445199635215E-5L, ]; - static immutable real[7] logCoeffsQ = [ + static immutable real[7] logQ = [ 6.0118660497603843919306E1L, 2.1642788614495947685003E2L, 3.0909872225312059774938E2L, @@ -2942,15 +2954,42 @@ private 1.0000000000000000000000E0L, ]; - // Coefficients for log(x) = z + z^3 P(z^2)/Q(z^2) + // Coefficients for log(1 + x) = x - x^^2/2 + x^^3 P(x)/Q(x) + // Theoretical peak relative error = 6.2e-22 + static immutable real[7] log2P = [ + 1.0747524399916215149070E2L, + 3.4258224542413922935104E2L, + 4.2401812743503691187826E2L, + 2.5620629828144409632571E2L, + 7.7671073698359539859595E1L, + 1.0767376367209449010438E1L, + 4.9962495940332550844739E-1L, + ]; + static immutable real[8] log2Q = [ + 3.2242573199748645407652E2L, + 1.2695660352705325274404E3L, + 2.0307734695595183428202E3L, + 1.6911722418503949084863E3L, + 7.7952888181207260646090E2L, + 1.9444210022760132894510E2L, + 2.3479774160285863271658E1L, + 1.0000000000000000000000E0, + ]; + + // log10 uses the same coefficients as log2. + alias log10P = log2P; + alias log10Q = log2Q; + + // Coefficients for log(x) = z + z^^3 P(z^^2)/Q(z^^2) // where z = 2(x-1)/(x+1) - static immutable real[4] logCoeffsR = [ + // Theoretical peak relative error = 6.16e-22 + static immutable real[4] logR = [ -3.5717684488096787370998E1L, 1.0777257190312272158094E1L, -7.1990767473014147232598E-1L, 1.9757429581415468984296E-3L, ]; - static immutable real[4] logCoeffsS = [ + static immutable real[4] logS = [ -4.2861221385716144629696E2L, 1.9361891836232102174846E2L, -2.6201045551331104417768E1L, @@ -2972,92 +3011,100 @@ private */ real log(real x) @safe pure nothrow @nogc { - import std.math.constants : LN2, LOG2, SQRT1_2; - import std.math.traits : isInfinity, isNaN, signbit; - import std.math.algebraic : poly; - version (INLINE_YL2X) + { + import std.math.constants : LN2; return core.math.yl2x(x, LN2); + } else - { - // C1 + C2 = LN2. - enum real C1 = 6.93145751953125E-1L; - enum real C2 = 1.428606820309417232121458176568075500134E-6L; + return logImpl(x); +} - // Special cases. - if (isNaN(x)) - return x; - if (isInfinity(x) && !signbit(x)) - return x; - if (x == 0.0) - return -real.infinity; - if (x < 0.0) - return real.nan; +/// +@safe pure nothrow @nogc unittest +{ + import std.math.operations : feqrel; + import std.math.constants : E; - // Separate mantissa from exponent. - // Note, frexp is used so that denormal numbers will be handled properly. - real y, z; - int exp; + assert(feqrel(log(E), 1) >= real.mant_dig - 1); +} - x = frexp(x, exp); +private T logImpl(T)(T x) @safe pure nothrow @nogc +{ + import std.math.constants : SQRT1_2; + import std.math.algebraic : poly; + import std.math.traits : isInfinity, isNaN, signbit; - // Logarithm using log(x) = z + z^^3 R(z) / S(z), - // where z = 2(x - 1)/(x + 1) - if ((exp > 2) || (exp < -2)) - { - if (x < SQRT1_2) - { // 2(2x - 1)/(2x + 1) - exp -= 1; - z = x - 0.5; - y = 0.5 * z + 0.5; - } - else - { // 2(x - 1)/(x + 1) - z = x - 0.5; - z -= 0.5; - y = 0.5 * x + 0.5; - } - x = z / y; - z = x * x; - z = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); - z += exp * C2; - z += x; - z += exp * C1; + alias coeffs = LogCoeffs!T; - return z; - } + // C1 + C2 = LN2. + enum T C1 = 6.93145751953125E-1L; + enum T C2 = 1.428606820309417232121458176568075500134E-6L; + + // Special cases. + if (isNaN(x)) + return x; + if (isInfinity(x) && !signbit(x)) + return x; + if (x == 0.0) + return -T.infinity; + if (x < 0.0) + return T.nan; + + // Separate mantissa from exponent. + // Note, frexp is used so that denormal numbers will be handled properly. + T y, z; + int exp; - // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) + x = frexp(x, exp); + + // Logarithm using log(x) = z + z^^3 R(z) / S(z), + // where z = 2(x - 1)/(x + 1) + if ((exp > 2) || (exp < -2)) + { if (x < SQRT1_2) - { + { // 2(2x - 1)/(2x + 1) exp -= 1; - x = 2.0 * x - 1.0; + z = x - 0.5; + y = 0.5 * z + 0.5; } else - { - x = x - 1.0; + { // 2(x - 1)/(x + 1) + z = x - 0.5; + z -= 0.5; + y = 0.5 * x + 0.5; } + x = z / y; z = x * x; - y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); - y += exp * C2; - z = y - 0.5 * z; - - // Note, the sum of above terms does not exceed x/4, - // so it contributes at most about 1/4 lsb to the error. + z = x * (z * poly(z, coeffs.logR) / poly(z, coeffs.logS)); + z += exp * C2; z += x; z += exp * C1; return z; } -} -/// -@safe pure nothrow @nogc unittest -{ - import std.math.operations : feqrel; - import std.math.constants : E; + // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) + if (x < SQRT1_2) + { + exp -= 1; + x = 2.0 * x - 1.0; + } + else + { + x = x - 1.0; + } + z = x * x; + y = x * (z * poly(x, coeffs.logP) / poly(x, coeffs.logQ)); + y += exp * C2; + z = y - 0.5 * z; - assert(feqrel(log(E), 1) >= real.mant_dig - 1); + // Note, the sum of above terms does not exceed x/4, + // so it contributes at most about 1/4 lsb to the error. + z += x; + z += exp * C1; + + return z; } /************************************** @@ -3072,95 +3119,103 @@ real log(real x) @safe pure nothrow @nogc */ real log10(real x) @safe pure nothrow @nogc { - import std.math.constants : LOG2, LN2, SQRT1_2; - import std.math.algebraic : poly; - import std.math.traits : isNaN, isInfinity, signbit; - version (INLINE_YL2X) + { + import std.math.constants : LOG2; return core.math.yl2x(x, LOG2); + } else - { - // log10(2) split into two parts. - enum real L102A = 0.3125L; - enum real L102B = -1.14700043360188047862611052755069732318101185E-2L; + return log10Impl(x); +} - // log10(e) split into two parts. - enum real L10EA = 0.5L; - enum real L10EB = -6.570551809674817234887108108339491770560299E-2L; +/// +@safe pure nothrow @nogc unittest +{ + import std.math.algebraic : fabs; - // Special cases are the same as for log. - if (isNaN(x)) - return x; - if (isInfinity(x) && !signbit(x)) - return x; - if (x == 0.0) - return -real.infinity; - if (x < 0.0) - return real.nan; + assert(fabs(log10(1000) - 3) < .000001); +} - // Separate mantissa from exponent. - // Note, frexp is used so that denormal numbers will be handled properly. - real y, z; - int exp; +private T log10Impl(T)(T x) @safe pure nothrow @nogc +{ + import std.math.constants : SQRT1_2; + import std.math.algebraic : poly; + import std.math.traits : isNaN, isInfinity, signbit; - x = frexp(x, exp); + alias coeffs = LogCoeffs!T; - // Logarithm using log(x) = z + z^^3 R(z) / S(z), - // where z = 2(x - 1)/(x + 1) - if ((exp > 2) || (exp < -2)) - { - if (x < SQRT1_2) - { // 2(2x - 1)/(2x + 1) - exp -= 1; - z = x - 0.5; - y = 0.5 * z + 0.5; - } - else - { // 2(x - 1)/(x + 1) - z = x - 0.5; - z -= 0.5; - y = 0.5 * x + 0.5; - } - x = z / y; - z = x * x; - y = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); - goto Ldone; - } + // log10(2) split into two parts. + enum T L102A = 0.3125L; + enum T L102B = -1.14700043360188047862611052755069732318101185E-2L; - // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) + // log10(e) split into two parts. + enum T L10EA = 0.5L; + enum T L10EB = -6.570551809674817234887108108339491770560299E-2L; + + // Special cases are the same as for log. + if (isNaN(x)) + return x; + if (isInfinity(x) && !signbit(x)) + return x; + if (x == 0.0) + return -T.infinity; + if (x < 0.0) + return T.nan; + + // Separate mantissa from exponent. + // Note, frexp is used so that denormal numbers will be handled properly. + T y, z; + int exp; + + x = frexp(x, exp); + + // Logarithm using log(x) = z + z^^3 R(z) / S(z), + // where z = 2(x - 1)/(x + 1) + if ((exp > 2) || (exp < -2)) + { if (x < SQRT1_2) - { + { // 2(2x - 1)/(2x + 1) exp -= 1; - x = 2.0 * x - 1.0; + z = x - 0.5; + y = 0.5 * z + 0.5; } else - x = x - 1.0; - + { // 2(x - 1)/(x + 1) + z = x - 0.5; + z -= 0.5; + y = 0.5 * x + 0.5; + } + x = z / y; z = x * x; - y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); - y = y - 0.5 * z; - - // Multiply log of fraction by log10(e) and base 2 exponent by log10(2). - // This sequence of operations is critical and it may be horribly - // defeated by some compiler optimizers. - Ldone: - z = y * L10EB; - z += x * L10EB; - z += exp * L102B; - z += y * L10EA; - z += x * L10EA; - z += exp * L102A; + y = x * (z * poly(z, coeffs.logR) / poly(z, coeffs.logS)); + goto Ldone; + } - return z; + // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) + if (x < SQRT1_2) + { + exp -= 1; + x = 2.0 * x - 1.0; } -} + else + x = x - 1.0; -/// -@safe pure nothrow @nogc unittest -{ - import std.math.algebraic : fabs; + z = x * x; + y = x * (z * poly(x, coeffs.log10P) / poly(x, coeffs.log10Q)); + y = y - 0.5 * z; - assert(fabs(log10(1000) - 3) < .000001); + // Multiply log of fraction by log10(e) and base 2 exponent by log10(2). + // This sequence of operations is critical and it may be horribly + // defeated by some compiler optimizers. +Ldone: + z = y * L10EB; + z += x * L10EB; + z += exp * L102B; + z += y * L10EA; + z += x * L10EA; + z += exp * L102A; + + return z; } /** @@ -3179,29 +3234,15 @@ real log10(real x) @safe pure nothrow @nogc */ real log1p(real x) @safe pure nothrow @nogc { - import std.math.traits : isNaN, isInfinity, signbit; - import std.math.constants : LN2; - version (INLINE_YL2X) { // On x87, yl2xp1 is valid if and only if -0.5 <= lg(x) <= 0.5, // ie if -0.29 <= x <= 0.414 + import std.math.constants : LN2; return (core.math.fabs(x) <= 0.25) ? core.math.yl2xp1(x, LN2) : core.math.yl2x(x+1, LN2); } else - { - // Special cases. - if (isNaN(x) || x == 0.0) - return x; - if (isInfinity(x) && !signbit(x)) - return x; - if (x == -1.0) - return -real.infinity; - if (x < -1.0) - return real.nan; - - return log(x + 1.0); - } + return log1pImpl(x); } /// @@ -3220,6 +3261,23 @@ real log1p(real x) @safe pure nothrow @nogc assert(log1p(real.infinity) == real.infinity); } +private T log1pImpl(T)(T x) @safe pure nothrow @nogc +{ + import std.math.traits : isNaN, isInfinity, signbit; + + // Special cases. + if (isNaN(x) || x == 0.0) + return x; + if (isInfinity(x) && !signbit(x)) + return x; + if (x == -1.0) + return -T.infinity; + if (x < -1.0) + return T.nan; + + return logImpl(x + 1.0); +} + /*************************************** * Calculates the base-2 logarithm of x: * $(SUB log, 2)x @@ -3233,78 +3291,10 @@ real log1p(real x) @safe pure nothrow @nogc */ real log2(real x) @safe pure nothrow @nogc { - import std.math.traits : isNaN, isInfinity, signbit; - import std.math.constants : SQRT1_2, LOG2E; - import std.math.algebraic : poly; - version (INLINE_YL2X) return core.math.yl2x(x, 1.0L); else - { - // Special cases are the same as for log. - if (isNaN(x)) - return x; - if (isInfinity(x) && !signbit(x)) - return x; - if (x == 0.0) - return -real.infinity; - if (x < 0.0) - return real.nan; - - // Separate mantissa from exponent. - // Note, frexp is used so that denormal numbers will be handled properly. - real y, z; - int exp; - - x = frexp(x, exp); - - // Logarithm using log(x) = z + z^^3 R(z) / S(z), - // where z = 2(x - 1)/(x + 1) - if ((exp > 2) || (exp < -2)) - { - if (x < SQRT1_2) - { // 2(2x - 1)/(2x + 1) - exp -= 1; - z = x - 0.5; - y = 0.5 * z + 0.5; - } - else - { // 2(x - 1)/(x + 1) - z = x - 0.5; - z -= 0.5; - y = 0.5 * x + 0.5; - } - x = z / y; - z = x * x; - y = x * (z * poly(z, logCoeffsR) / poly(z, logCoeffsS)); - goto Ldone; - } - - // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) - if (x < SQRT1_2) - { - exp -= 1; - x = 2.0 * x - 1.0; - } - else - x = x - 1.0; - - z = x * x; - y = x * (z * poly(x, logCoeffsP) / poly(x, logCoeffsQ)); - y = y - 0.5 * z; - - // Multiply log of fraction by log10(e) and base 2 exponent by log10(2). - // This sequence of operations is critical and it may be horribly - // defeated by some compiler optimizers. - Ldone: - z = y * (LOG2E - 1.0); - z += x * (LOG2E - 1.0); - z += y; - z += x; - z += exp; - - return z; - } + return log2Impl(x); } /// @@ -3323,6 +3313,79 @@ real log2(real x) @safe pure nothrow @nogc assert(isClose(log2(1024.0L), 10, 1e-18)); } +private T log2Impl(T)(T x) @safe pure nothrow @nogc +{ + import std.math.traits : isNaN, isInfinity, signbit; + import std.math.constants : SQRT1_2, LOG2E; + import std.math.algebraic : poly; + + alias coeffs = LogCoeffs!T; + + // Special cases are the same as for log. + if (isNaN(x)) + return x; + if (isInfinity(x) && !signbit(x)) + return x; + if (x == 0.0) + return -T.infinity; + if (x < 0.0) + return T.nan; + + // Separate mantissa from exponent. + // Note, frexp is used so that denormal numbers will be handled properly. + T y, z; + int exp; + + x = frexp(x, exp); + + // Logarithm using log(x) = z + z^^3 R(z) / S(z), + // where z = 2(x - 1)/(x + 1) + if ((exp > 2) || (exp < -2)) + { + if (x < SQRT1_2) + { // 2(2x - 1)/(2x + 1) + exp -= 1; + z = x - 0.5; + y = 0.5 * z + 0.5; + } + else + { // 2(x - 1)/(x + 1) + z = x - 0.5; + z -= 0.5; + y = 0.5 * x + 0.5; + } + x = z / y; + z = x * x; + y = x * (z * poly(z, coeffs.logR) / poly(z, coeffs.logS)); + goto Ldone; + } + + // Logarithm using log(1 + x) = x - .5x^^2 + x^^3 P(x) / Q(x) + if (x < SQRT1_2) + { + exp -= 1; + x = 2.0 * x - 1.0; + } + else + x = x - 1.0; + + z = x * x; + y = x * (z * poly(x, coeffs.log2P) / poly(x, coeffs.log2Q)); + y = y - 0.5 * z; + + // Multiply log of fraction by log10(e) and base 2 exponent by log10(2). + // This sequence of operations is critical and it may be horribly + // defeated by some compiler optimizers. +Ldone: + z = y * (LOG2E - 1.0); + z += x * (LOG2E - 1.0); + z += y; + z += x; + z += exp; + + return z; +} + /***************************************** * Extracts the exponent of x as a signed integral value. * @@ -3337,35 +3400,23 @@ real log2(real x) @safe pure nothrow @nogc * $(TR $(TD $(PLUSMN)0.0) $(TD -$(INFIN)) $(TD yes) ) * ) */ -real logb(real x) @trusted nothrow @nogc +pragma(inline, true) +real logb(real x) @trusted pure nothrow @nogc { version (InlineAsm_X87_MSVC) - { - version (X86_64) - { - asm pure nothrow @nogc - { - naked ; - fld real ptr [RCX] ; - fxtract ; - fstp ST(0) ; - ret ; - } - } - else - { - asm pure nothrow @nogc - { - fld x ; - fxtract ; - fstp ST(0) ; - } - } - } + return logbAsm(x); else - return core.stdc.math.logbl(x); + return logbImpl(x); } +/// ditto +pragma(inline, true) +double logb(double x) @trusted pure nothrow @nogc { return logbImpl(x); } + +/// ditto +pragma(inline, true) +float logb(float x) @trusted pure nothrow @nogc { return logbImpl(x); } + /// @safe @nogc nothrow unittest { @@ -3377,6 +3428,83 @@ real logb(real x) @trusted nothrow @nogc assert(logb(-real.infinity) == real.infinity); } +@safe @nogc nothrow unittest +{ + import std.meta : AliasSeq; + import std.typecons : Tuple; + import std.math.traits : isNaN; + static foreach (F; AliasSeq!(float, double, real)) + {{ + alias T = Tuple!(F, F); + T[17] vals = // x, logb(x) + [ + T(1.0 , 0 ), + T(100.0 , 6 ), + T(0.0 , -F.infinity), + T(-0.0 , -F.infinity), + T(1024 , 10 ), + T(-2000 , 10 ), + T(0x0.1p-127 , -131 ), + T(0x0.01p-127 , -135 ), + T(0x0.011p-127 , -135 ), + T(F.nan , F.nan ), + T(-F.nan , F.nan ), + T(F.infinity , F.infinity ), + T(-F.infinity , F.infinity ), + T(F.min_normal , F.min_exp-1), + T(-F.min_normal, F.min_exp-1), + T(F.max , F.max_exp-1), + T(-F.max , F.max_exp-1), + ]; + + foreach (elem; vals) + { + if (isNaN(elem[1])) + assert(isNaN(logb(elem[1]))); + else + assert(logb(elem[0]) == elem[1]); + } + }} +} + +version (InlineAsm_X87_MSVC) +private T logbAsm(T)(T x) @trusted pure nothrow @nogc +{ + version (X86_64) + { + asm pure nothrow @nogc + { + naked ; + fld real ptr [RCX] ; + fxtract ; + fstp ST(0) ; + ret ; + } + } + else + { + asm pure nothrow @nogc + { + fld x ; + fxtract ; + fstp ST(0) ; + } + } +} + +private T logbImpl(T)(T x) @trusted pure nothrow @nogc +{ + import std.math.traits : isFinite; + + // Handle special cases. + if (!isFinite(x)) + return x * x; + if (x == 0) + return -1 / (x * x); + + return ilogb(x); +} + /************************************* * Efficiently calculates x * 2$(SUPERSCRIPT n). * diff --git a/libphobos/src/std/math/hardware.d b/libphobos/src/std/math/hardware.d index b768969..40e42da 100644 --- a/libphobos/src/std/math/hardware.d +++ b/libphobos/src/std/math/hardware.d @@ -214,12 +214,12 @@ private: } else version (SPARC) { - /* + /* int retval; asm pure nothrow @nogc { st %fsr, retval; } return retval; */ - assert(0, "Not yet supported"); + assert(0, "Not yet supported"); } else version (ARM) { @@ -674,9 +674,9 @@ nothrow @nogc: enum : ExceptionMask { inexactException = 0x01, - divByZeroException = 0x02, - underflowException = 0x04, - overflowException = 0x08, + divByZeroException = 0x08, + underflowException = 0x02, + overflowException = 0x04, invalidException = 0x10, severeExceptions = overflowException | divByZeroException | invalidException, diff --git a/libphobos/src/std/math/trigonometry.d b/libphobos/src/std/math/trigonometry.d index 06a7cb1..a3d04c6 100644 --- a/libphobos/src/std/math/trigonometry.d +++ b/libphobos/src/std/math/trigonometry.d @@ -467,20 +467,20 @@ private T tanImpl(T)(T x) @safe pure nothrow @nogc static immutable T[2][] vals = [ // angle, tan - [ .5, .54630248984], - [ 1, 1.5574077247], - [ 1.5, 14.101419947], - [ 2, -2.1850398633], - [ 2.5,-.74702229724], - [ 3, -.14254654307], - [ 3.5, .37458564016], - [ 4, 1.1578212823], - [ 4.5, 4.6373320546], - [ 5, -3.3805150062], - [ 5.5,-.99558405221], - [ 6, -.29100619138], - [ 6.5, .22027720035], - [ 10, .64836082746], + [ .5, .546302489843790513255L], + [ 1, 1.55740772465490223050L], + [ 1.5, 14.1014199471717193876L], + [ 2, -2.18503986326151899164L], + [ 2.5,-.747022297238660279355L], + [ 3, -.142546543074277805295L], + [ 3.5, .374585640158594666330L], + [ 4, 1.15782128234957758313L], + [ 4.5, 4.63733205455118446831L], + [ 5, -3.38051500624658563698L], + [ 5.5,-.995584052213885017701L], + [ 6, -.291006191384749157053L], + [ 6.5, .220277200345896811825L], + [ 10, .648360827459086671259L], // special angles [ PI_4, 1], @@ -857,11 +857,11 @@ private T atanImpl(T)(T x) @safe pure nothrow @nogc static immutable T[2][] vals = [ // x, atan(x) - [ 0.25, 0.24497866313 ], - [ 0.5, 0.46364760900 ], - [ 1, PI_4 ], - [ 1.5, 0.98279372325 ], - [ 10, 1.47112767430 ], + [ 0.25, 0.244978663126864154172L ], + [ 0.5, 0.463647609000806116214L ], + [ 1, PI_4 ], + [ 1.5, 0.982793723247329067985L ], + [ 10, 1.471127674303734591852L ], ]; foreach (ref val; vals) @@ -1075,10 +1075,10 @@ private T atan2Impl(T)(T y, T x) @safe pure nothrow @nogc [ 3.0, -3.0, 3 * PI_4 ], [ -4.0, -4.0, -3 * PI_4 ], - [ 0.75, 0.25, 1.249045772398 ], - [ -0.5, 0.375, -0.927295218002 ], - [ 0.5, -0.125, 1.815774989922 ], - [ -0.75, -0.5, -2.158798930342 ], + [ 0.75, 0.25, 1.2490457723982544258299L ], + [ -0.5, 0.375, -0.9272952180016122324285L ], + [ 0.5, -0.125, 1.8157749899217607734034L ], + [ -0.75, -0.5, -2.1587989303424641704769L ], ]; foreach (ref val; vals) diff --git a/libphobos/src/std/mmfile.d b/libphobos/src/std/mmfile.d index e4000d4..f8f8a90 100644 --- a/libphobos/src/std/mmfile.d +++ b/libphobos/src/std/mmfile.d @@ -71,13 +71,13 @@ class MmFile * - On POSIX, $(REF ErrnoException, std, exception). * - On Windows, $(REF WindowsException, std, windows, syserror). */ - this(string filename) + this(string filename) scope { this(filename, Mode.read, 0, null); } version (linux) this(File file, Mode mode = Mode.read, ulong size = 0, - void* address = null, size_t window = 0) + void* address = null, size_t window = 0) scope { // Save a copy of the File to make sure the fd stays open. this.file = file; @@ -85,7 +85,7 @@ class MmFile } version (linux) private this(int fildes, Mode mode, ulong size, - void* address, size_t window) + void* address, size_t window) scope { int oflag; int fmode; @@ -169,7 +169,7 @@ class MmFile * - On Windows, $(REF WindowsException, std, windows, syserror). */ this(string filename, Mode mode, ulong size, void* address, - size_t window = 0) + size_t window = 0) scope { this.filename = filename; this.mMode = mode; @@ -364,7 +364,7 @@ class MmFile /** * Flushes pending output and closes the memory mapped file. */ - ~this() + ~this() scope { debug (MMFILE) printf("MmFile.~this()\n"); unmap(); diff --git a/libphobos/src/std/numeric.d b/libphobos/src/std/numeric.d index fd532b2..96d20c2 100644 --- a/libphobos/src/std/numeric.d +++ b/libphobos/src/std/numeric.d @@ -79,10 +79,12 @@ public enum CustomFloatFlags none = 0 } +private enum isIEEEQuadruple = floatTraits!real.realFormat == RealFormat.ieeeQuadruple; + private template CustomFloatParams(uint bits) { enum CustomFloatFlags flags = CustomFloatFlags.ieee - ^ ((bits == 80) ? CustomFloatFlags.storeNormalized : CustomFloatFlags.none); + ^ ((bits == 80 && !isIEEEQuadruple) ? CustomFloatFlags.storeNormalized : CustomFloatFlags.none); static if (bits == 8) alias CustomFloatParams = CustomFloatParams!( 4, 3, flags); static if (bits == 16) alias CustomFloatParams = CustomFloatParams!(10, 5, flags); static if (bits == 32) alias CustomFloatParams = CustomFloatParams!(23, 8, flags); @@ -367,11 +369,36 @@ private: public: static if (precision == 64) // CustomFloat!80 support hack { - ulong significand; - enum ulong significand_max = ulong.max; - mixin(bitfields!( - T_exp , "exponent", exponentWidth, - bool , "sign" , flags & flags.signed )); + static if (isIEEEQuadruple) + { + // Only use highest 64 significand bits from 112 explicitly stored + align (1): + enum ulong significand_max = ulong.max; + version (LittleEndian) + { + private ubyte[6] _padding; // 48-bit of padding + ulong significand; + mixin(bitfields!( + T_exp , "exponent", exponentWidth, + bool , "sign" , flags & flags.signed )); + } + else + { + mixin(bitfields!( + T_exp , "exponent", exponentWidth, + bool , "sign" , flags & flags.signed )); + ulong significand; + private ubyte[6] _padding; // 48-bit of padding + } + } + else + { + ulong significand; + enum ulong significand_max = ulong.max; + mixin(bitfields!( + T_exp , "exponent", exponentWidth, + bool , "sign" , flags & flags.signed )); + } } else { @@ -631,23 +658,28 @@ public: auto x = F(0.125); assert(x.get!float == 0.125F); assert(x.get!double == 0.125); + assert(x.get!real == 0.125L); x -= 0.0625; assert(x.get!float == 0.0625F); assert(x.get!double == 0.0625); + assert(x.get!real == 0.0625L); x *= 2; assert(x.get!float == 0.125F); assert(x.get!double == 0.125); + assert(x.get!real == 0.125L); x /= 4; assert(x.get!float == 0.03125); assert(x.get!double == 0.03125); + assert(x.get!real == 0.03125L); x = 0.5; x ^^= 4; assert(x.get!float == 1 / 16.0F); assert(x.get!double == 1 / 16.0); + assert(x.get!real == 1 / 16.0L); } } diff --git a/libphobos/src/std/outbuffer.d b/libphobos/src/std/outbuffer.d index 9590238..92af9a9 100644 --- a/libphobos/src/std/outbuffer.d +++ b/libphobos/src/std/outbuffer.d @@ -173,21 +173,40 @@ class OutBuffer } /**************************************** - * Append nbytes of 0 to the internal buffer. + * Append nbytes of val to the internal buffer. + * Params: + * nbytes = Number of bytes to fill. + * val = Value to fill, defaults to 0. */ - void fill0(size_t nbytes) + void fill(size_t nbytes, ubyte val = 0) { reserve(nbytes); - data[offset .. offset + nbytes] = 0; + data[offset .. offset + nbytes] = val; offset += nbytes; } + /**************************************** + * Append nbytes of 0 to the internal buffer. + * Param: + * nbytes - number of bytes to fill. + */ + void fill0(size_t nbytes) + { + fill(nbytes); + } + /********************************** - * 0-fill to align on power of 2 boundary. + * Append bytes until the buffer aligns on a power of 2 boundary. + * + * By default fills with 0 bytes. + * + * Params: + * alignsize = Alignment value. Must be power of 2. + * val = Value to fill, defaults to 0. */ - void alignSize(size_t alignsize) + void alignSize(size_t alignsize, ubyte val = 0) in { assert(alignsize && (alignsize & (alignsize - 1)) == 0); @@ -200,7 +219,35 @@ class OutBuffer { auto nbytes = offset & (alignsize - 1); if (nbytes) - fill0(alignsize - nbytes); + fill(alignsize - nbytes, val); + } + /// + @safe unittest + { + OutBuffer buf = new OutBuffer(); + buf.write(cast(ubyte) 1); + buf.align2(); + assert(buf.toBytes() == "\x01\x00"); + buf.write(cast(ubyte) 2); + buf.align4(); + assert(buf.toBytes() == "\x01\x00\x02\x00"); + buf.write(cast(ubyte) 3); + buf.alignSize(8); + assert(buf.toBytes() == "\x01\x00\x02\x00\x03\x00\x00\x00"); + } + /// ditto + @safe unittest + { + OutBuffer buf = new OutBuffer(); + buf.write(cast(ubyte) 1); + buf.align2(0x55); + assert(buf.toBytes() == "\x01\x55"); + buf.write(cast(ubyte) 2); + buf.align4(0x55); + assert(buf.toBytes() == "\x01\x55\x02\x55"); + buf.write(cast(ubyte) 3); + buf.alignSize(8, 0x55); + assert(buf.toBytes() == "\x01\x55\x02\x55\x03\x55\x55\x55"); } /// Clear the data in the buffer @@ -211,23 +258,27 @@ class OutBuffer /**************************************** * Optimize common special case alignSize(2) + * Params: + * val = Value to fill, defaults to 0. */ - void align2() + void align2(ubyte val = 0) { if (offset & 1) - write(cast(byte) 0); + write(cast(byte) val); } /**************************************** * Optimize common special case alignSize(4) + * Params: + * val = Value to fill, defaults to 0. */ - void align4() + void align4(ubyte val = 0) { if (offset & 3) { auto nbytes = (4 - offset) & 3; - fill0(nbytes); + fill(nbytes, val); } } @@ -331,7 +382,7 @@ class OutBuffer import std.format : checkFormatException; alias e = checkFormatException!(fmt, A); - static assert(!e, e.msg); + static assert(!e, e); return this.writef(fmt, args); } @@ -377,7 +428,7 @@ class OutBuffer import std.format : checkFormatException; alias e = checkFormatException!(fmt, A); - static assert(!e, e.msg); + static assert(!e, e); return this.writefln(fmt, args); } diff --git a/libphobos/src/std/package.d b/libphobos/src/std/package.d index a1d0444..bfb135b 100644 --- a/libphobos/src/std/package.d +++ b/libphobos/src/std/package.d @@ -35,6 +35,7 @@ public import std.base64, std.bigint, std.bitmanip, + std.checkedint, std.compiler, std.complex, std.concurrency, @@ -50,6 +51,7 @@ public import std.format, std.functional, std.getopt, + std.int128, std.json, std.math, std.mathspecial, diff --git a/libphobos/src/std/parallelism.d b/libphobos/src/std/parallelism.d index 971cfa0..2c97638 100644 --- a/libphobos/src/std/parallelism.d +++ b/libphobos/src/std/parallelism.d @@ -1039,6 +1039,11 @@ uint totalCPUsImpl() @nogc nothrow @trusted import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf; return cast(uint) sysconf(_SC_NPROCESSORS_ONLN); } + else version (Hurd) + { + import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf; + return cast(uint) sysconf(_SC_NPROCESSORS_ONLN); + } else { static assert(0, "Don't know how to get N CPUs on this OS."); diff --git a/libphobos/src/std/path.d b/libphobos/src/std/path.d index 20518b8..de180fc 100644 --- a/libphobos/src/std/path.d +++ b/libphobos/src/std/path.d @@ -1519,7 +1519,7 @@ if (isSomeChar!C) import std.range; // ir() wraps an array in a plain (i.e. non-forward) input range, so that // we can test both code paths - InputRange!(C[]) ir(C)(C[][] p...) { return inputRangeObject(p); } + InputRange!(C[]) ir(C)(C[][] p...) { return inputRangeObject(p.dup); } version (Posix) { assert(buildPath("foo") == "foo"); diff --git a/libphobos/src/std/process.d b/libphobos/src/std/process.d index 2c68f36..d4fe8a1 100644 --- a/libphobos/src/std/process.d +++ b/libphobos/src/std/process.d @@ -299,10 +299,9 @@ static: } else version (Windows) { - import std.exception : enforce; - enforce( + import std.windows.syserror : wenforce; + wenforce( SetEnvironmentVariableW(name.tempCStringW(), value.tempCStringW()), - sysErrorString(GetLastError()) ); return value; } @@ -614,7 +613,7 @@ private: * writefln("Current process ID: %d", thisProcessID); * --- */ -@property int thisProcessID() @trusted nothrow //TODO: @safe +@property int thisProcessID() @trusted nothrow @nogc //TODO: @safe { version (Windows) return GetCurrentProcessId(); else version (Posix) return core.sys.posix.unistd.getpid(); @@ -633,7 +632,7 @@ private: * writefln("Current thread ID: %s", thisThreadID); * --- */ -@property ThreadID thisThreadID() @trusted nothrow //TODO: @safe +@property ThreadID thisThreadID() @trusted nothrow @nogc //TODO: @safe { version (Windows) return GetCurrentThreadId(); @@ -1330,7 +1329,7 @@ private Pid spawnProcessWin(scope const(char)[] commandLine, { throw new StdioException( "Failed to make "~which~" stream inheritable by child process (" - ~sysErrorString(GetLastError()) ~ ')', + ~generateSysErrorMsg() ~ ')', 0); } } @@ -2775,7 +2774,7 @@ Pipe pipe() @trusted //TODO: @safe if (!CreatePipe(&readHandle, &writeHandle, null, 0)) { throw new StdioException( - "Error creating pipe (" ~ sysErrorString(GetLastError()) ~ ')', + "Error creating pipe (" ~ generateSysErrorMsg() ~ ')', 0); } @@ -3475,7 +3474,7 @@ class ProcessException : Exception string file = __FILE__, size_t line = __LINE__) { - auto lastMsg = sysErrorString(GetLastError()); + auto lastMsg = generateSysErrorMsg(); auto msg = customMsg.empty ? lastMsg : customMsg ~ " (" ~ lastMsg ~ ')'; return new ProcessException(msg, file, line); diff --git a/libphobos/src/std/range/primitives.d b/libphobos/src/std/range/primitives.d index c092a9d..31f58fa 100644 --- a/libphobos/src/std/range/primitives.d +++ b/libphobos/src/std/range/primitives.d @@ -2055,9 +2055,14 @@ if (isBidirectionalRange!Range) } /** - Moves the front of `r` out and returns it. Leaves `r.front` in a - destroyable state that does not allocate any resources (usually equal - to its `.init` value). + Moves the front of `r` out and returns it. + + If `r.front` is a struct with a destructor or copy constructor defined, it + is reset to its `.init` value after its value is moved. Otherwise, it is + left unchanged. + + In either case, `r.front` is left in a destroyable state that does not + allocate any resources. */ ElementType!R moveFront(R)(R r) { diff --git a/libphobos/src/std/regex/internal/parser.d b/libphobos/src/std/regex/internal/parser.d index 41ca687..448bb99 100644 --- a/libphobos/src/std/regex/internal/parser.d +++ b/libphobos/src/std/regex/internal/parser.d @@ -841,7 +841,7 @@ if (isForwardRange!R && is(ElementType!R : dchar)) switch (front) { case '*', '?', '+', '|', '{', '}': - error("'*', '+', '?', '{', '}' not allowed in atom"); + return error("'*', '+', '?', '{', '}' not allowed in atom"); case '.': if (re_flags & RegexOption.singleline) g.put(Bytecode(IR.Any, 0)); diff --git a/libphobos/src/std/socket.d b/libphobos/src/std/socket.d index f8908cf..6ec7985 100644 --- a/libphobos/src/std/socket.d +++ b/libphobos/src/std/socket.d @@ -122,6 +122,12 @@ version (StdUnittest) writefln("Ignoring std.socket(%d) test failure (likely caused by flaky environment): %s", line, e.msg); } } + + // Without debug=std_socket, still compile the slow tests, just don't run them. + debug (std_socket) + private enum runSlowTests = true; + else + private enum runSlowTests = false; } /// Base exception thrown by `std.socket`. @@ -169,7 +175,7 @@ string formatSocketError(int err) @trusted else version (Windows) { - return sysErrorString(err); + return generateSysErrorMsg(err); } else return "Socket error " ~ to!string(err); @@ -787,13 +793,20 @@ class InternetHost assert(ih.name == "www.digitalmars.com" || ih.name == "digitalmars.com", ih.name); - assert(ih.getHostByAddr(ih.addrList[0])); - string getHostNameFromInt = ih.name.dup; + /* The following assert randomly fails in the test suite. + * https://issues.dlang.org/show_bug.cgi?id=22791 + * So just ignore it when it fails. + */ + //assert(ih.getHostByAddr(ih.addrList[0])); + if (ih.getHostByAddr(ih.addrList[0])) + { + string getHostNameFromInt = ih.name.dup; - assert(ih.getHostByAddr(ia.toAddrString())); - string getHostNameFromStr = ih.name.dup; + assert(ih.getHostByAddr(ia.toAddrString())); + string getHostNameFromStr = ih.name.dup; - assert(getHostNameFromInt == getHostNameFromStr); + assert(getHostNameFromInt == getHostNameFromStr); + } } @@ -835,7 +848,7 @@ private string formatGaiError(int err) @trusted { version (Windows) { - return sysErrorString(err); + return generateSysErrorMsg(err); } else { @@ -1691,7 +1704,7 @@ public: } }); - debug (std_socket) + if (runSlowTests) softUnittest({ // test failing reverse lookup const InternetAddress ia = new InternetAddress("255.255.255.255", 80); @@ -2626,7 +2639,7 @@ private: @safe unittest { - debug (std_socket) + if (runSlowTests) softUnittest({ import std.datetime.stopwatch; import std.typecons; @@ -2993,7 +3006,7 @@ public: * Returns: The number of bytes actually sent, or `Socket.ERROR` on * failure. */ - ptrdiff_t send(const(void)[] buf, SocketFlags flags) @trusted + ptrdiff_t send(scope const(void)[] buf, SocketFlags flags) @trusted { static if (is(typeof(MSG_NOSIGNAL))) { @@ -3007,7 +3020,7 @@ public: } /// ditto - ptrdiff_t send(const(void)[] buf) + ptrdiff_t send(scope const(void)[] buf) { return send(buf, SocketFlags.NONE); } @@ -3019,7 +3032,7 @@ public: * Returns: The number of bytes actually sent, or `Socket.ERROR` on * failure. */ - ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags, Address to) @trusted + ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags, Address to) @trusted { static if (is(typeof(MSG_NOSIGNAL))) { @@ -3035,7 +3048,7 @@ public: } /// ditto - ptrdiff_t sendTo(const(void)[] buf, Address to) + ptrdiff_t sendTo(scope const(void)[] buf, Address to) { return sendTo(buf, SocketFlags.NONE, to); } @@ -3043,7 +3056,7 @@ public: //assumes you connect()ed /// ditto - ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags) @trusted + ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags) @trusted { static if (is(typeof(MSG_NOSIGNAL))) { @@ -3058,7 +3071,7 @@ public: //assumes you connect()ed /// ditto - ptrdiff_t sendTo(const(void)[] buf) + ptrdiff_t sendTo(scope const(void)[] buf) { return sendTo(buf, SocketFlags.NONE); } @@ -3070,7 +3083,7 @@ public: * Returns: The number of bytes actually received, `0` if the remote side * has closed the connection, or `Socket.ERROR` on failure. */ - ptrdiff_t receive(void[] buf, SocketFlags flags) @trusted + ptrdiff_t receive(scope void[] buf, SocketFlags flags) @trusted { version (Windows) // Does not use size_t { @@ -3087,7 +3100,7 @@ public: } /// ditto - ptrdiff_t receive(void[] buf) + ptrdiff_t receive(scope void[] buf) { return receive(buf, SocketFlags.NONE); } @@ -3099,7 +3112,7 @@ public: * Returns: The number of bytes actually received, `0` if the remote side * has closed the connection, or `Socket.ERROR` on failure. */ - ptrdiff_t receiveFrom(void[] buf, SocketFlags flags, ref Address from) @trusted + ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags, ref Address from) @trusted { if (!buf.length) //return 0 and don't think the connection closed return 0; @@ -3122,7 +3135,7 @@ public: /// ditto - ptrdiff_t receiveFrom(void[] buf, ref Address from) + ptrdiff_t receiveFrom(scope void[] buf, ref Address from) { return receiveFrom(buf, SocketFlags.NONE, from); } @@ -3130,7 +3143,7 @@ public: //assumes you connect()ed /// ditto - ptrdiff_t receiveFrom(void[] buf, SocketFlags flags) @trusted + ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags) @trusted { if (!buf.length) //return 0 and don't think the connection closed return 0; @@ -3151,7 +3164,7 @@ public: //assumes you connect()ed /// ditto - ptrdiff_t receiveFrom(void[] buf) + ptrdiff_t receiveFrom(scope void[] buf) { return receiveFrom(buf, SocketFlags.NONE); } @@ -3162,7 +3175,7 @@ public: * Returns: The number of bytes written to `result`. * The length, in bytes, of the actual result - very different from getsockopt() */ - int getOption(SocketOptionLevel level, SocketOption option, void[] result) @trusted + int getOption(SocketOptionLevel level, SocketOption option, scope void[] result) @trusted { socklen_t len = cast(socklen_t) result.length; if (_SOCKET_ERROR == .getsockopt(sock, cast(int) level, cast(int) option, result.ptr, &len)) @@ -3210,7 +3223,7 @@ public: } /// Set a socket option. - void setOption(SocketOptionLevel level, SocketOption option, void[] value) @trusted + void setOption(SocketOptionLevel level, SocketOption option, scope void[] value) @trusted { if (_SOCKET_ERROR == .setsockopt(sock, cast(int) level, cast(int) option, value.ptr, cast(uint) value.length)) @@ -3640,55 +3653,55 @@ class UdpSocket: Socket { checkAttributes!q{@trusted}; assert(0); } - @trusted ptrdiff_t send(const(void)[] buf, SocketFlags flags) + @trusted ptrdiff_t send(scope const(void)[] buf, SocketFlags flags) { checkAttributes!q{@trusted}; assert(0); } - @safe ptrdiff_t send(const(void)[] buf) + @safe ptrdiff_t send(scope const(void)[] buf) { checkAttributes!q{@safe}; assert(0); } - @trusted ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags, Address to) + @trusted ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags, Address to) { checkAttributes!q{@trusted}; assert(0); } - @safe ptrdiff_t sendTo(const(void)[] buf, Address to) + @safe ptrdiff_t sendTo(scope const(void)[] buf, Address to) { checkAttributes!q{@safe}; assert(0); } - @trusted ptrdiff_t sendTo(const(void)[] buf, SocketFlags flags) + @trusted ptrdiff_t sendTo(scope const(void)[] buf, SocketFlags flags) { checkAttributes!q{@trusted}; assert(0); } - @safe ptrdiff_t sendTo(const(void)[] buf) + @safe ptrdiff_t sendTo(scope const(void)[] buf) { checkAttributes!q{@safe}; assert(0); } - @trusted ptrdiff_t receive(void[] buf, SocketFlags flags) + @trusted ptrdiff_t receive(scope void[] buf, SocketFlags flags) { checkAttributes!q{@trusted}; assert(0); } - @safe ptrdiff_t receive(void[] buf) + @safe ptrdiff_t receive(scope void[] buf) { checkAttributes!q{@safe}; assert(0); } - @trusted ptrdiff_t receiveFrom(void[] buf, SocketFlags flags, ref Address from) + @trusted ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags, ref Address from) { checkAttributes!q{@trusted}; assert(0); } - @safe ptrdiff_t receiveFrom(void[] buf, ref Address from) + @safe ptrdiff_t receiveFrom(scope void[] buf, ref Address from) { checkAttributes!q{@safe}; assert(0); } - @trusted ptrdiff_t receiveFrom(void[] buf, SocketFlags flags) + @trusted ptrdiff_t receiveFrom(scope void[] buf, SocketFlags flags) { checkAttributes!q{@trusted}; assert(0); } - @safe ptrdiff_t receiveFrom(void[] buf) + @safe ptrdiff_t receiveFrom(scope void[] buf) { checkAttributes!q{@safe}; assert(0); } - @trusted int getOption(SocketOptionLevel level, SocketOption option, void[] result) + @trusted int getOption(SocketOptionLevel level, SocketOption option, scope void[] result) { checkAttributes!q{@trusted}; assert(0); } @@ -3704,7 +3717,7 @@ class UdpSocket: Socket { checkAttributes!q{@trusted}; } - @trusted void setOption(SocketOptionLevel level, SocketOption option, void[] value) + @trusted void setOption(SocketOptionLevel level, SocketOption option, scope void[] value) { checkAttributes!q{@trusted}; } @@ -3786,11 +3799,11 @@ Socket[2] socketPair() @trusted /// @safe unittest { - immutable ubyte[] data = [1, 2, 3, 4]; + immutable ubyte[4] data = [1, 2, 3, 4]; auto pair = socketPair(); scope(exit) foreach (s; pair) s.close(); - pair[0].send(data); + pair[0].send(data[]); auto buf = new ubyte[data.length]; pair[1].receive(buf); diff --git a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d index bc2d3fe..8614dc9 100644 --- a/libphobos/src/std/stdio.d +++ b/libphobos/src/std/stdio.d @@ -498,17 +498,21 @@ struct File private Impl* _p; private string _name; - package this(FILE* handle, string name, uint refs = 1, bool isPopened = false) @trusted + package this(FILE* handle, string name, uint refs = 1, bool isPopened = false) @trusted @nogc nothrow { import core.stdc.stdlib : malloc; - import std.exception : enforce; assert(!_p); - _p = cast(Impl*) enforce(malloc(Impl.sizeof), "Out of memory"); + _p = cast(Impl*) malloc(Impl.sizeof); + if (!_p) + { + import core.exception : onOutOfMemoryError; + onOutOfMemoryError(); + } initImpl(handle, name, refs, isPopened); } - private void initImpl(FILE* handle, string name, uint refs = 1, bool isPopened = false) + private void initImpl(FILE* handle, string name, uint refs = 1, bool isPopened = false) @nogc nothrow pure @safe { assert(_p); _p.handle = handle; @@ -1458,6 +1462,7 @@ Throws: `Exception` if the file is not opened. { import core.sys.windows.winbase : OVERLAPPED; import core.sys.windows.winnt : BOOL, ULARGE_INTEGER; + import std.windows.syserror : wenforce; private BOOL lockImpl(alias F, Flags...)(ulong start, ulong length, Flags flags) @@ -1474,15 +1479,6 @@ Throws: `Exception` if the file is not opened. return F(windowsHandle, flags, 0, liLength.LowPart, liLength.HighPart, &overlapped); } - - private static T wenforce(T)(T cond, lazy string str) - { - import core.sys.windows.winbase : GetLastError; - import std.windows.syserror : sysErrorString; - - if (cond) return cond; - throw new Exception(str ~ ": " ~ sysErrorString(GetLastError())); - } } version (Posix) { @@ -1783,7 +1779,7 @@ Throws: `Exception` if the file is not opened. import std.format : checkFormatException; alias e = checkFormatException!(fmt, A); - static assert(!e, e.msg); + static assert(!e, e); return this.writef(fmt, args); } @@ -1802,7 +1798,7 @@ Throws: `Exception` if the file is not opened. import std.format : checkFormatException; alias e = checkFormatException!(fmt, A); - static assert(!e, e.msg); + static assert(!e, e); return this.writefln(fmt, args); } @@ -2151,7 +2147,7 @@ $(CONSOLE import std.format : checkFormatException; alias e = checkFormatException!(format, Data); - static assert(!e, e.msg); + static assert(!e, e); return this.readf(format, data); } @@ -4388,7 +4384,7 @@ if (isSomeString!(typeof(fmt))) import std.format : checkFormatException; alias e = checkFormatException!(fmt, A); - static assert(!e, e.msg); + static assert(!e, e); return .writef(fmt, args); } @@ -4429,7 +4425,7 @@ if (isSomeString!(typeof(fmt))) import std.format : checkFormatException; alias e = checkFormatException!(fmt, A); - static assert(!e, e.msg); + static assert(!e, e); return .writefln(fmt, args); } @@ -4510,7 +4506,7 @@ if (isSomeString!(typeof(format))) import std.format : checkFormatException; alias e = checkFormatException!(format, A); - static assert(!e, e.msg); + static assert(!e, e); return .readf(format, args); } diff --git a/libphobos/src/std/sumtype.d b/libphobos/src/std/sumtype.d index 658fd38..1d375ef 100644 --- a/libphobos/src/std/sumtype.d +++ b/libphobos/src/std/sumtype.d @@ -13,6 +13,7 @@ include: License: Boost License 1.0 Authors: Paul Backus +Source: $(PHOBOSSRC std/sumtype.d) +/ module std.sumtype; @@ -233,24 +234,14 @@ import std.meta : anySatisfy, allSatisfy; import std.traits : hasElaborateCopyConstructor, hasElaborateDestructor; import std.traits : isAssignable, isCopyable, isStaticArray, isRvalueAssignable; import std.traits : ConstOf, ImmutableOf, InoutOf, TemplateArgsOf; -import std.traits : CommonType; +import std.traits : CommonType, DeducedParameterType; import std.typecons : ReplaceTypeUnless; import std.typecons : Flag; +import std.conv : toCtString; /// Placeholder used to refer to the enclosing [SumType]. struct This {} -// Converts an unsigned integer to a compile-time string constant. -private enum toCtString(ulong n) = n.stringof[0 .. $ - "LU".length]; - -// Check that .stringof does what we expect, since it's not guaranteed by the -// language spec. -@safe unittest -{ - assert(toCtString!0 == "0"); - assert(toCtString!123456 == "123456"); -} - // True if a variable of type T can appear on the lhs of an assignment private enum isAssignableTo(T) = isAssignable!T || (!isCopyable!T && isRvalueAssignable!T); @@ -262,6 +253,8 @@ private enum isHashable(T) = __traits(compiles, private enum hasPostblit(T) = __traits(hasPostblit, T); +private enum isInout(T) = is(T == inout); + /** * A [tagged union](https://en.wikipedia.org/wiki/Tagged_union) that can hold a * single value from any of a specified set of types. @@ -356,6 +349,10 @@ public: /// ditto this(immutable(T) value) immutable; + + /// ditto + this(Value)(Value value) inout + if (is(Value == DeducedParameterType!(inout(T)))); } static foreach (tid, T; Types) @@ -411,6 +408,25 @@ public: { @disable this(immutable(T) value) immutable; } + + static if (isCopyable!(inout(T))) + { + static if (IndexOf!(inout(T), Map!(InoutOf, Types)) == tid) + { + /// ditto + this(Value)(Value value) inout + if (is(Value == DeducedParameterType!(inout(T)))) + { + __traits(getMember, storage, Storage.memberName!T) = value; + tag = tid; + } + } + } + else + { + @disable this(Value)(Value value) inout + if (is(Value == DeducedParameterType!(inout(T)))); + } } static if (anySatisfy!(hasElaborateCopyConstructor, Types)) @@ -419,6 +435,7 @@ public: ( allSatisfy!(isCopyable, Map!(InoutOf, Types)) && !anySatisfy!(hasPostblit, Map!(InoutOf, Types)) + && allSatisfy!(isInout, Map!(InoutOf, Types)) ) { /// Constructs a `SumType` that's a copy of another `SumType`. @@ -530,15 +547,35 @@ public: /** * Assigns a value to a `SumType`. * - * Assigning to a `SumType` is `@system` if any of the - * `SumType`'s members contain pointers or references, since - * those members may be reachable through external references, - * and overwriting them could therefore lead to memory - * corruption. + * If any of the `SumType`'s members other than the one being assigned + * to contain pointers or references, it is possible for the assignment + * to cause memory corruption (see the + * ["Memory corruption" example](#memory-corruption) below for an + * illustration of how). Therefore, such assignments are considered + * `@system`. * * An individual assignment can be `@trusted` if the caller can - * guarantee that there are no outstanding references to $(I any) - * of the `SumType`'s members when the assignment occurs. + * guarantee that there are no outstanding references to any `SumType` + * members that contain pointers or references at the time the + * assignment occurs. + * + * Examples: + * + * $(DIVID memory-corruption, $(H3 Memory corruption)) + * + * This example shows how assignment to a `SumType` can be used to + * cause memory corruption in `@system` code. In `@safe` code, the + * assignment `s = 123` would not be allowed. + * + * --- + * SumType!(int*, int) s = new int; + * s.tryMatch!( + * (ref int* p) { + * s = 123; // overwrites `p` + * return *p; // undefined behavior + * } + * ); + * --- */ ref SumType opAssign(T rhs); } @@ -550,14 +587,35 @@ public: /** * Assigns a value to a `SumType`. * - * Assigning to a `SumType` is `@system` if any of the `SumType`'s - * $(I other) members contain pointers or references, since those - * members may be reachable through external references, and - * overwriting them could therefore lead to memory corruption. + * If any of the `SumType`'s members other than the one being assigned + * to contain pointers or references, it is possible for the assignment + * to cause memory corruption (see the + * ["Memory corruption" example](#memory-corruption) below for an + * illustration of how). Therefore, such assignments are considered + * `@system`. * * An individual assignment can be `@trusted` if the caller can - * guarantee that, when the assignment occurs, there are no - * outstanding references to any such members. + * guarantee that there are no outstanding references to any `SumType` + * members that contain pointers or references at the time the + * assignment occurs. + * + * Examples: + * + * $(DIVID memory-corruption, $(H3 Memory corruption)) + * + * This example shows how assignment to a `SumType` can be used to + * cause memory corruption in `@system` code. In `@safe` code, the + * assignment `s = 123` would not be allowed. + * + * --- + * SumType!(int*, int) s = new int; + * s.tryMatch!( + * (ref int* p) { + * s = 123; // overwrites `p` + * return *p; // undefined behavior + * } + * ); + * --- */ ref SumType opAssign(T rhs) { @@ -577,9 +635,19 @@ public: this.match!destroyIfOwner; - mixin("Storage newStorage = { ", - Storage.memberName!T, ": forward!rhs", - " };"); + static if (isCopyable!T) + { + // Workaround for https://issues.dlang.org/show_bug.cgi?id=21542 + mixin("Storage newStorage = { ", + Storage.memberName!T, ": __ctfe ? rhs : forward!rhs", + " };"); + } + else + { + mixin("Storage newStorage = { ", + Storage.memberName!T, ": forward!rhs", + " };"); + } storage = newStorage; tag = tid; @@ -620,7 +688,17 @@ public: { import core.lifetime : move; - rhs.match!((ref value) { this = move(value); }); + rhs.match!((ref value) { + static if (isCopyable!(typeof(value))) + { + // Workaround for https://issues.dlang.org/show_bug.cgi?id=21542 + this = __ctfe ? value : move(value); + } + else + { + this = move(value); + } + }); return this; } } @@ -1255,6 +1333,7 @@ version (D_BetterC) {} else // Types with invariants // Disabled in BetterC due to use of exceptions version (D_BetterC) {} else +version (D_Invariants) @system unittest { import std.exception : assertThrown; @@ -1272,22 +1351,13 @@ version (D_BetterC) {} else invariant { assert(i >= 0); } } - // Only run test if contract checking is enabled - try - { - S probe = S(-1); - assert(&probe); - } - catch (AssertError _) - { - SumType!S x; - x.match!((ref v) { v.i = -1; }); - assertThrown!AssertError(assert(&x)); + SumType!S x; + x.match!((ref v) { v.i = -1; }); + assertThrown!AssertError(assert(&x)); - SumType!C y = new C(); - y.match!((ref v) { v.i = -1; }); - assertThrown!AssertError(assert(&y)); - } + SumType!C y = new C(); + y.match!((ref v) { v.i = -1; }); + assertThrown!AssertError(assert(&y)); } // Calls value postblit on self-assignment @@ -1492,6 +1562,55 @@ version (D_BetterC) {} else immutable SumType!(int*) si = ∋ } +// Immutable member type with copy constructor +// https://issues.dlang.org/show_bug.cgi?id=22572 +@safe unittest +{ + static struct CopyConstruct + { + this(ref inout CopyConstruct other) inout {} + } + + static immutable struct Value + { + CopyConstruct c; + } + + SumType!Value s; +} + +// Construction of inout-qualified SumTypes +// https://issues.dlang.org/show_bug.cgi?id=22901 +@safe unittest +{ + static inout(SumType!(int[])) example(inout(int[]) arr) + { + return inout(SumType!(int[]))(arr); + } +} + +// Assignment of struct with overloaded opAssign in CTFE +// https://issues.dlang.org/show_bug.cgi?id=23182 +@safe unittest +{ + static struct HasOpAssign + { + void opAssign(HasOpAssign rhs) {} + } + + static SumType!HasOpAssign test() + { + SumType!HasOpAssign s; + // Test both overloads + s = HasOpAssign(); + s = SumType!HasOpAssign(); + return s; + } + + // Force CTFE + enum result = test(); +} + /// True if `T` is an instance of the `SumType` template, otherwise false. private enum bool isSumTypeInstance(T) = is(T == SumType!Args, Args...); @@ -1745,7 +1864,7 @@ class MatchException : Exception template canMatch(alias handler, Ts...) if (Ts.length > 0) { - enum canMatch = is(typeof((Ts args) => handler(args))); + enum canMatch = is(typeof((ref Ts args) => handler(args))); } /// @@ -2490,6 +2609,27 @@ version (D_Exceptions) } } +// return ref +// issue: https://issues.dlang.org/show_bug.cgi?id=23101 +@safe unittest +{ + static assert(!__traits(compiles, () { + SumType!(int, string) st; + return st.match!( + function int* (string x) => assert(0), + function int* (return ref int i) => &i, + ); + })); + + SumType!(int, string) st; + static assert(__traits(compiles, () { + return st.match!( + function int* (string x) => null, + function int* (return ref int i) => &i, + ); + })); +} + private void destroyIfOwner(T)(ref T value) { static if (hasElaborateDestructor!T) diff --git a/libphobos/src/std/traits.d b/libphobos/src/std/traits.d index 596c11c..cc08ea6 100644 --- a/libphobos/src/std/traits.d +++ b/libphobos/src/std/traits.d @@ -788,7 +788,8 @@ private template fqnType(T, ~ (attrs & FA.trusted ? " @trusted" : "") ~ (attrs & FA.safe ? " @safe" : "") ~ (attrs & FA.nogc ? " @nogc" : "") - ~ (attrs & FA.return_ ? " return" : ""); + ~ (attrs & FA.return_ ? " return" : "") + ~ (attrs & FA.live ? " @live" : ""); } string addQualifiers(string typeString, @@ -1422,6 +1423,11 @@ if (isCallable!func) enum val = "val" ~ (name == "val" ? "_" : ""); enum ptr = "ptr" ~ (name == "ptr" ? "_" : ""); mixin(" + enum hasDefaultArg = (PT[i .. i+1] " ~ args ~ ") { return true; }; + "); + static if (is(typeof(hasDefaultArg()))) + { + mixin(" // workaround scope escape check, see // https://issues.dlang.org/show_bug.cgi?id=16582 // should use return scope once available @@ -1432,10 +1438,9 @@ if (isCallable!func) auto " ~ val ~ " = " ~ args ~ "[0]; auto " ~ ptr ~ " = &" ~ val ~ "; return *" ~ ptr ~ "; - }; - "); - static if (is(typeof(get()))) + };"); enum Get = get(); + } else alias Get = void; // If default arg doesn't exist, returns void instead. @@ -1483,6 +1488,17 @@ if (isCallable!func) static foreach (V; Voids) static assert(is(V == void)); } +// https://issues.dlang.org/show_bug.cgi?id=20182 +@safe pure nothrow @nogc unittest +{ + struct S + { + this(ref S) {} + } + + static assert(__traits(compiles, ParameterDefaults!(S.__ctor))); +} + /** * Alternate name for $(LREF ParameterDefaults), kept for legacy compatibility. */ @@ -4823,7 +4839,7 @@ Returns class instance alignment. template classInstanceAlignment(T) if (is(T == class)) { - alias classInstanceAlignment = maxAlignment!(void*, typeof(T.tupleof)); + enum classInstanceAlignment = __traits(classInstanceAlignment, T); } /// @@ -9080,3 +9096,43 @@ enum isCopyable(S) = __traits(isCopyable, S); static assert(isCopyable!int); static assert(isCopyable!(int[])); } + +/** + * The parameter type deduced by IFTI when an expression of type T is passed as + * an argument to a template function. + * + * For all types other than pointer and slice types, `DeducedParameterType!T` + * is the same as `T`. For pointer and slice types, it is `T` with the + * outer-most layer of qualifiers dropped. + */ +package(std) template DeducedParameterType(T) +{ + static if (is(T == U*, U) || is(T == U[], U)) + alias DeducedParameterType = Unqual!T; + else + alias DeducedParameterType = T; +} + +@safe unittest +{ + static assert(is(DeducedParameterType!(const(int)) == const(int))); + static assert(is(DeducedParameterType!(const(int[2])) == const(int[2]))); + + static assert(is(DeducedParameterType!(const(int*)) == const(int)*)); + static assert(is(DeducedParameterType!(const(int[])) == const(int)[])); +} + +@safe unittest +{ + static struct NoCopy + { + @disable this(this); + } + + static assert(is(DeducedParameterType!NoCopy == NoCopy)); +} + +@safe unittest +{ + static assert(is(DeducedParameterType!(inout(int[])) == inout(int)[])); +} diff --git a/libphobos/src/std/typecons.d b/libphobos/src/std/typecons.d index 28edb9b..8a3e22f 100644 --- a/libphobos/src/std/typecons.d +++ b/libphobos/src/std/typecons.d @@ -2798,13 +2798,24 @@ struct Nullable(T) } } - this (ref return scope inout Nullable!T rhs) inout + static if (__traits(hasPostblit, T)) { - _isNull = rhs._isNull; - if (!_isNull) - _value.payload = rhs._value.payload; - else - _value = DontCallDestructorT.init; + this(this) + { + if (!_isNull) + _value.payload.__xpostblit(); + } + } + else static if (__traits(hasCopyConstructor, T)) + { + this(ref return scope inout Nullable!T rhs) inout + { + _isNull = rhs._isNull; + if (!_isNull) + _value.payload = rhs._value.payload; + else + _value = DontCallDestructorT.init; + } } /** @@ -3098,6 +3109,64 @@ struct Nullable(T) { return isNull ? fallback : _value.payload; } + + /// $(MREF_ALTTEXT Range interface, std, range, primitives) functions. + alias empty = isNull; + + /// ditto + alias popFront = nullify; + + /// ditto + alias popBack = nullify; + + /// ditto + @property ref inout(T) front() inout @safe pure nothrow + { + return get(); + } + + /// ditto + alias back = front; + + /// ditto + @property inout(typeof(this)) save() inout + { + return this; + } + + /// ditto + inout(typeof(this)) opIndex() inout + { + return this; + } + + /// ditto + inout(typeof(this)) opIndex(size_t[2] dim) inout + in (dim[0] <= length && dim[1] <= length && dim[1] >= dim[0]) + { + return (dim[0] == 0 && dim[1] == 1) ? this : this.init; + } + /// ditto + size_t[2] opSlice(size_t dim : 0)(size_t from, size_t to) const + { + return [from, to]; + } + + /// ditto + @property size_t length() const @safe pure nothrow + { + return !empty; + } + + /// ditto + alias opDollar(size_t dim : 0) = length; + + /// ditto + ref inout(T) opIndex(size_t index) inout @safe pure nothrow + in (index < length) + { + return get(); + } } /// ditto @@ -3151,6 +3220,23 @@ auto nullable(T)(T t) assert(a.isNull); assertThrown!Throwable(a.get); } +/// +@safe unittest +{ + import std.algorithm.iteration : each, joiner; + Nullable!int a = 42; + Nullable!int b; + // Add each value to an array + int[] arr; + a.each!((n) => arr ~= n); + assert(arr == [42]); + b.each!((n) => arr ~= n); + assert(arr == [42]); + // Take first value from an array of Nullables + Nullable!int[] c = new Nullable!int[](10); + c[7] = Nullable!int(42); + assert(c.joiner.front == 42); +} @safe unittest { auto k = Nullable!int(74); @@ -3627,6 +3713,42 @@ auto nullable(T)(T t) a = b = c = nullable(5); } +// https://issues.dlang.org/show_bug.cgi?id=18374 +@safe pure nothrow unittest +{ + import std.algorithm.comparison : equal; + import std.range : only, takeNone; + import std.range.primitives : hasAssignableElements, hasLength, + hasLvalueElements, hasSlicing, hasSwappableElements, + isRandomAccessRange; + Nullable!int a = 42; + assert(!a.empty); + assert(a.front == 42); + assert(a.back == 42); + assert(a[0] == 42); + assert(a.equal(only(42))); + assert(a[0 .. $].equal(only(42))); + a[0] = 43; + assert(a.equal(only(43))); + --a[0]; + assert(a.equal(only(42))); + Nullable!int b; + assert(b.empty); + assert(b.equal(takeNone(b))); + Nullable!int c = a.save(); + assert(!c.empty); + c.popFront(); + assert(!a.empty); + assert(c.empty); + + assert(isRandomAccessRange!(Nullable!int)); + assert(hasLength!(Nullable!int)); + assert(hasSlicing!(Nullable!int)); + assert(hasAssignableElements!(Nullable!int)); + assert(hasSwappableElements!(Nullable!int)); + assert(hasLvalueElements!(Nullable!int)); +} + /** Just like `Nullable!T`, except that the null state is defined as a particular value. For example, $(D Nullable!(uint, uint.max)) is an @@ -8145,7 +8267,7 @@ if (is(T == class)) { // _d_newclass now use default GC alignment (looks like (void*).sizeof * 2 for // small objects). We will just use the maximum of filed alignments. - alias alignment = classInstanceAlignment!T; + enum alignment = __traits(classInstanceAlignment, T); alias aligned = _alignUp!alignment; static struct Scoped @@ -8782,19 +8904,6 @@ private: enum isBaseEnumType(T) = is(E == T); alias Base = OriginalType!E; Base mValue; - static struct Negation - { - @safe @nogc pure nothrow: - private: - Base mValue; - - // Prevent non-copy construction outside the module. - @disable this(); - this(Base value) - { - mValue = value; - } - } public: this(E flag) @@ -8819,10 +8928,10 @@ public: return mValue; } - Negation opUnary(string op)() const + auto opUnary(string op)() const if (op == "~") { - return Negation(~mValue); + return BitFlags(cast(E) cast(Base) ~mValue); } auto ref opAssign(T...)(T flags) @@ -8866,12 +8975,6 @@ public: return this; } - auto ref opOpAssign(string op: "&")(Negation negatedFlags) - { - mValue &= negatedFlags.mValue; - return this; - } - auto opBinary(string op)(BitFlags flags) const if (op == "|" || op == "&") { @@ -8888,13 +8991,6 @@ public: return result; } - auto opBinary(string op: "&")(Negation negatedFlags) const - { - BitFlags result = this; - result.opOpAssign!op(negatedFlags); - return result; - } - auto opBinaryRight(string op)(E flag) const if (op == "|" || op == "&") { @@ -9093,6 +9189,34 @@ public: assert(flags.A && !flags.B && !flags.C); } +// Negation of BitFlags should work with any base type. +// Double-negation of BitFlags should work. +@safe @nogc pure nothrow unittest +{ + static foreach (alias Base; AliasSeq!( + byte, + ubyte, + short, + ushort, + int, + uint, + long, + ulong, + )) + {{ + enum Enum : Base + { + A = 1 << 0, + B = 1 << 1, + C = 1 << 2, + } + + auto flags = BitFlags!Enum(Enum.A); + + assert(flags == ~~flags); + }} +} + private enum false_(T) = false; // ReplaceType @@ -9294,6 +9418,8 @@ private template replaceTypeInFunctionTypeUnless(alias pred, From, To, fun) result ~= " shared"; static if (attributes & FunctionAttribute.return_) result ~= " return"; + static if (attributes & FunctionAttribute.live) + result ~= " @live"; return result; } @@ -9630,13 +9756,28 @@ unittest { int b; @disable this(this); - this (ref return scope inout S rhs) inout + this(ref return scope inout S rhs) inout { this.b = rhs.b + 1; } } Nullable!S s1 = S(1); + assert(s1.get().b == 2); + Nullable!S s2 = s1; + assert(s2.get().b == 3); +} + +@safe unittest +{ + static struct S + { + int b; + this(this) { ++b; } + } + + Nullable!S s1 = S(1); + assert(s1.get().b == 2); Nullable!S s2 = s1; - assert(s2.get().b > s1.get().b); + assert(s2.get().b == 3); } diff --git a/libphobos/src/std/uni/package.d b/libphobos/src/std/uni/package.d index 192b6fd..98735ac 100644 --- a/libphobos/src/std/uni/package.d +++ b/libphobos/src/std/uni/package.d @@ -5363,7 +5363,7 @@ pure @safe unittest pure @safe unittest { import std.range : stride; - static bool testAll(Matcher, Range)(scope ref Matcher m, ref Range r) + static bool testAll(Matcher, Range)(ref Matcher m, ref Range r) @safe { bool t = m.test(r); auto save = r.idx; @@ -9824,7 +9824,7 @@ dchar toLower(dchar c) /++ Creates a new array which is identical to `s` except that all of its - characters are converted to lowercase (by preforming Unicode lowercase mapping). + characters are converted to lowercase (by performing Unicode lowercase mapping). If none of `s` characters were affected, then `s` itself is returned if `s` is a `string`-like type. @@ -9834,25 +9834,29 @@ dchar toLower(dchar c) Returns: An array with the same element type as `s`. +/ -ElementEncodingType!S[] toLower(S)(S s) -if (isSomeString!S || (isRandomAccessRange!S && hasLength!S && hasSlicing!S && isSomeChar!(ElementType!S))) +ElementEncodingType!S[] toLower(S)(return scope S s) @trusted +if (isSomeString!S) { static import std.ascii; + return toCase!(LowerTriple, std.ascii.toLower)(s); +} - static if (isSomeString!S) - return () @trusted { return toCase!(LowerTriple, std.ascii.toLower)(s); } (); - else - return toCase!(LowerTriple, std.ascii.toLower)(s); +/// ditto +ElementEncodingType!S[] toLower(S)(S s) +if (!isSomeString!S && (isRandomAccessRange!S && hasLength!S && hasSlicing!S && isSomeChar!(ElementType!S))) +{ + static import std.ascii; + return toCase!(LowerTriple, std.ascii.toLower)(s); } // overloads for the most common cases to reduce compile time @safe pure /*TODO nothrow*/ { - string toLower(string s) + string toLower(return scope string s) { return toLower!string(s); } - wstring toLower(wstring s) + wstring toLower(return scope wstring s) { return toLower!wstring(s); } - dstring toLower(dstring s) + dstring toLower(return scope dstring s) { return toLower!dstring(s); } @safe unittest @@ -10028,7 +10032,7 @@ dchar toUpper(dchar c) /++ Allocates a new array which is identical to `s` except that all of its - characters are converted to uppercase (by preforming Unicode uppercase mapping). + characters are converted to uppercase (by performing Unicode uppercase mapping). If none of `s` characters were affected, then `s` itself is returned if `s` is a `string`-like type. @@ -10038,25 +10042,29 @@ dchar toUpper(dchar c) Returns: An new array with the same element type as `s`. +/ -ElementEncodingType!S[] toUpper(S)(S s) -if (isSomeString!S || (isRandomAccessRange!S && hasLength!S && hasSlicing!S && isSomeChar!(ElementType!S))) +ElementEncodingType!S[] toUpper(S)(return scope S s) @trusted +if (isSomeString!S) { static import std.ascii; + return toCase!(UpperTriple, std.ascii.toUpper)(s); +} - static if (isSomeString!S) - return () @trusted { return toCase!(UpperTriple, std.ascii.toUpper)(s); } (); - else - return toCase!(UpperTriple, std.ascii.toUpper)(s); +/// ditto +ElementEncodingType!S[] toUpper(S)(S s) +if (!isSomeString!S && (isRandomAccessRange!S && hasLength!S && hasSlicing!S && isSomeChar!(ElementType!S))) +{ + static import std.ascii; + return toCase!(UpperTriple, std.ascii.toUpper)(s); } // overloads for the most common cases to reduce compile time @safe pure /*TODO nothrow*/ { - string toUpper(string s) + string toUpper(return scope string s) { return toUpper!string(s); } - wstring toUpper(wstring s) + wstring toUpper(return scope wstring s) { return toUpper!wstring(s); } - dstring toUpper(dstring s) + dstring toUpper(return scope dstring s) { return toUpper!dstring(s); } @safe unittest diff --git a/libphobos/src/std/utf.d b/libphobos/src/std/utf.d index 5c23684..d22dac8 100644 --- a/libphobos/src/std/utf.d +++ b/libphobos/src/std/utf.d @@ -1209,6 +1209,15 @@ do assert("ë"w.decode(i) == 'ë' && i == 1); } +@safe pure unittest // https://issues.dlang.org/show_bug.cgi?id=22867 +{ + import std.conv : hexString; + string data = hexString!"f787a598"; + size_t offset = 0; + try data.decode(offset); + catch (UTFException ex) assert(offset == 0); +} + /++ `decodeFront` is a variant of $(LREF decode) which specifically decodes the first code point. Unlike $(LREF decode), `decodeFront` accepts any @@ -1671,7 +1680,6 @@ if ( } } - index += i + 1; static if (i == 3) { if (d > dchar.max) @@ -1682,6 +1690,8 @@ if ( throw invalidUTF(); } } + + index += i + 1; return d; } } @@ -4265,10 +4275,10 @@ private int impureVariable; * UseReplacementDchar.no means throw `UTFException` for invalid UTF * * Throws: - * `UTFException` if invalid UTF sequence and `useReplacementDchar` is set to `UseReplacementDchar.yes` + * `UTFException` if invalid UTF sequence and `useReplacementDchar` is set to `UseReplacementDchar.no` * * GC: - * Does not use GC if `useReplacementDchar` is set to `UseReplacementDchar.no` + * Does not use GC if `useReplacementDchar` is set to `UseReplacementDchar.yes` * * Returns: * A bidirectional range if `R` is a bidirectional range and not auto-decodable, diff --git a/libphobos/src/std/windows/charset.d b/libphobos/src/std/windows/charset.d index 69626b5..ce33616 100644 --- a/libphobos/src/std/windows/charset.d +++ b/libphobos/src/std/windows/charset.d @@ -76,12 +76,7 @@ const(char)* toMBSz(scope const(char)[] s, uint codePage = 0) to!int(result.length), null, null); } - if (!readLen || readLen != result.length) - { - throw new Exception("Couldn't convert string: " ~ - sysErrorString(GetLastError())); - } - + wenforce(readLen && readLen == result.length, "Couldn't convert string"); return result.ptr; } } @@ -107,16 +102,10 @@ string fromMBSz(return scope immutable(char)* s, int codePage = 0) to!int(result.length)); } - if (!readLen || readLen != result.length) - { - throw new Exception("Couldn't convert string: " ~ - sysErrorString(GetLastError())); - } + wenforce(readLen && readLen == result.length, "Couldn't convert string"); return result[0 .. result.length-1].to!string; // omit trailing null } } return s[0 .. c-s]; // string is ASCII, no conversion necessary } - - diff --git a/libphobos/src/std/windows/syserror.d b/libphobos/src/std/windows/syserror.d index 94f8ee5..3d8c5e7 100644 --- a/libphobos/src/std/windows/syserror.d +++ b/libphobos/src/std/windows/syserror.d @@ -43,7 +43,7 @@ version (StdDdoc) { private alias DWORD = int; final @property DWORD code(); /// `GetLastError`'s return value. - this(DWORD code, string str=null, string file = null, size_t line = 0) @trusted; + this(DWORD code, string str=null, string file = null, size_t line = 0) nothrow @trusted; } /++ @@ -66,9 +66,9 @@ else: version (Windows): import core.sys.windows.winbase, core.sys.windows.winnt; -import std.array : appender; -import std.conv : to; -import std.format.write : formattedWrite; +import std.array : appender, Appender; +import std.conv : to, toTextRange, text; +import std.exception; import std.windows.charset; string sysErrorString( @@ -79,16 +79,25 @@ string sysErrorString( { auto buf = appender!string(); - if (!putSysError(errCode, buf, MAKELANGID(langId, subLangId))) - { - throw new Exception( - "failed getting error string for WinAPI error code: " ~ - sysErrorString(GetLastError())); - } + wenforce( + // Ignore unlikely UTF decoding errors, always report the actual error (`errCode`) + putSysError(errCode, buf, MAKELANGID(langId, subLangId)).ifThrown(false), + text("Could not fetch error string for WinAPI code ", errCode) + ); return buf.data; } +@safe unittest +{ + import std.algorithm.searching; + + assert(sysErrorString(ERROR_PATH_NOT_FOUND) !is null); + + const msg = collectExceptionMsg!WindowsException(sysErrorString(DWORD.max)); + assert(msg.startsWith(`Could not fetch error string for WinAPI code 4294967295: `)); +} + bool putSysError(Writer)(DWORD code, Writer w, /*WORD*/int langId = 0) { wchar *lpMsgBuf = null; @@ -114,7 +123,6 @@ bool putSysError(Writer)(DWORD code, Writer w, /*WORD*/int langId = 0) return false; } - class WindowsException : Exception { import core.sys.windows.windef : DWORD; @@ -122,11 +130,11 @@ class WindowsException : Exception final @property DWORD code() { return _code; } /// `GetLastError`'s return value. private DWORD _code; - this(DWORD code, string str=null, string file = null, size_t line = 0) @trusted + this(DWORD code, string str=null, string file = null, size_t line = 0) nothrow @trusted { _code = code; - auto buf = appender!string(); + auto buf = appender!(char[]); if (str != null) { @@ -135,18 +143,43 @@ class WindowsException : Exception buf.put(": "); } - if (code) + if (code && writeErrorMessage(code, buf)) { - auto success = putSysError(code, buf); - formattedWrite(buf, success ? " (error %d)" : "Error %d", code); + buf.put(" (error "); + toTextRange(code, buf); + buf.put(')'); } - super(buf.data, file, line); + super(cast(immutable) buf.data, file, line); } } +/// Writes the error string associated to `code` into `buf`. +/// Writes `Error <code>` when the error message lookup fails +private bool writeErrorMessage(DWORD code, ref Appender!(char[]) buf) nothrow +{ + bool success; + try + { + // Reset the buffer to undo partial changes + const len = buf[].length; + scope (failure) buf.shrinkTo(len); -T wenforce(T, S)(T value, lazy S msg = null, + success = putSysError(code, buf); + } + catch (Exception) {} + + // Write the error code instead if we couldn't find the string + if (!success) + { + buf.put("Error "); + toTextRange(code, buf); + } + + return success; +} + +T wenforce(T, S = string)(T value, lazy S msg = null, string file = __FILE__, size_t line = __LINE__) if (isSomeString!S) { @@ -177,11 +210,9 @@ T wenforce(T)(T condition, const(char)[] name, const(wchar)* namez, string file throw new WindowsException(GetLastError(), names, file, line); } -version (Windows) @system unittest { import std.algorithm.searching : startsWith, endsWith; - import std.exception; import std.string; auto e = collectException!WindowsException( @@ -199,3 +230,29 @@ version (Windows) e = new WindowsException(0, "Test"); assert(e.msg == "Test"); } + +@safe nothrow unittest +{ + import std.algorithm.searching : endsWith; + + auto e = new WindowsException(ERROR_FILE_NOT_FOUND); + assert(e.msg.endsWith("(error 2)")); + + e = new WindowsException(DWORD.max); + assert(e.msg == "Error 4294967295"); +} + +/// Tries to translate an error code from the Windows API to the corresponding +/// error message. Returns `Error <code>` on failure +package (std) string generateSysErrorMsg(DWORD errCode = GetLastError()) nothrow @trusted +{ + auto buf = appender!(char[]); + cast(void) writeErrorMessage(errCode, buf); + return cast(immutable) buf[]; +} + +nothrow @safe unittest +{ + assert(generateSysErrorMsg(ERROR_PATH_NOT_FOUND) !is null); + assert(generateSysErrorMsg(DWORD.max) == "Error 4294967295"); +} diff --git a/libphobos/src/std/zip.d b/libphobos/src/std/zip.d index 4d7422b..72d1287 100644 --- a/libphobos/src/std/zip.d +++ b/libphobos/src/std/zip.d @@ -222,14 +222,6 @@ final class ArchiveMember @property @safe pure nothrow @nogc uint expandedSize() const { return _expandedSize; } /** - * Should be 0. - * - * Returns: The number of the disk where this member can be found. - */ - deprecated("Multidisk not supported; will be removed in 2.099.0") - @property @safe pure nothrow @nogc ushort diskNumber() const { return 0; } - - /** * Data of member in compressed form. * * Returns: The file data in compressed form. @@ -452,13 +444,6 @@ public: private bool _isZip64; static const ushort zip64ExtractVersion = 45; - deprecated("Use digitalSignatureLength instead; will be removed in 2.098.0") - static const int digiSignLength = 6; - deprecated("Use zip64EndOfCentralDirLocatorLength instead; will be removed in 2.098.0") - static const int eocd64LocLength = 20; - deprecated("Use zip64EndOfCentralDirLength instead; will be removed in 2.098.0") - static const int eocd64Length = 56; - private Segment[] _segs; /** @@ -469,29 +454,11 @@ public: @property @safe @nogc pure nothrow ubyte[] data() { return _data; } /** - * 0 since multi-disk zip archives are not supported. - * - * Returns: Number of this disk. - */ - deprecated("Multidisk not supported; will be removed in 2.099.0") - @property @safe @nogc pure nothrow uint diskNumber() const { return 0; } - - /** - * 0 since multi-disk zip archives are not supported. - * - * Returns: Number of the disk, where the central directory starts. - */ - deprecated("Multidisk not supported; will be removed in 2.099.0") - @property @safe @nogc pure nothrow uint diskStartDir() const { return 0; } - - /** * Number of ArchiveMembers in the directory. * * Returns: The number of files in this archive. */ - deprecated("Use totalEntries instead; will be removed in 2.099.0") - @property @safe @nogc pure nothrow uint numEntries() const { return cast(uint) _directory.length; } - @property @safe @nogc pure nothrow uint totalEntries() const { return cast(uint) _directory.length; } /// ditto + @property @safe @nogc pure nothrow uint totalEntries() const { return cast(uint) _directory.length; } /** * True when the archive is in Zip64 format. Set this to true to force building a Zip64 archive. diff --git a/libphobos/testsuite/lib/libphobos-dg.exp b/libphobos/testsuite/lib/libphobos-dg.exp index 522778e..37b5456 100644 --- a/libphobos/testsuite/lib/libphobos-dg.exp +++ b/libphobos/testsuite/lib/libphobos-dg.exp @@ -23,6 +23,7 @@ load_gcc_lib file-format.exp load_gcc_lib scanasm.exp load_gcc_lib scanlang.exp load_gcc_lib scanrtl.exp +load_gcc_lib scansarif.exp load_gcc_lib scantree.exp load_gcc_lib scanipa.exp load_gcc_lib torture-options.exp diff --git a/libphobos/testsuite/libphobos.betterc/test19933.d b/libphobos/testsuite/libphobos.betterc/test19933.d new file mode 100644 index 0000000..a0faadd --- /dev/null +++ b/libphobos/testsuite/libphobos.betterc/test19933.d @@ -0,0 +1,11 @@ +/*******************************************/ +// https://issues.dlang.org/show_bug.cgi?id=19933 +// https://issues.dlang.org/show_bug.cgi?id=18816 + +import core.stdc.stdio; + +extern(C) int main() +{ + fprintf(stderr, "Hello\n"); + return 0; +} diff --git a/libphobos/testsuite/libphobos.cycles/cycles.exp b/libphobos/testsuite/libphobos.cycles/cycles.exp index 80bdf0e..fa3dfd4 100644 --- a/libphobos/testsuite/libphobos.cycles/cycles.exp +++ b/libphobos/testsuite/libphobos.cycles/cycles.exp @@ -23,7 +23,7 @@ set cycle_test_list [list \ { ignore "" 0 } \ { abort "object.Error@.*: Cyclic dependency between module mod. and mod." 1 } \ { print "Cyclic dependency between module mod. and mod." 0 } \ - { deprecate "Deprecation 16211 warning:" 0 } \ + { deprecate "deprecate is no longer supported, using abort instead" 1 } \ ] # Initialize dg. diff --git a/libphobos/testsuite/libphobos.exceptions/message_with_null.d b/libphobos/testsuite/libphobos.exceptions/message_with_null.d new file mode 100644 index 0000000..64092f0 --- /dev/null +++ b/libphobos/testsuite/libphobos.exceptions/message_with_null.d @@ -0,0 +1,8 @@ +// { dg-shouldfail " world!" } +// { dg-output "object.Exception@.*: hello.*world!" } +module message_with_null; + +void main() +{ + throw new Exception("hello\0 world!"); +} diff --git a/libphobos/testsuite/libphobos.hash/test_hash.d b/libphobos/testsuite/libphobos.hash/test_hash.d index d0a8e5fb..0ad2443 100644 --- a/libphobos/testsuite/libphobos.hash/test_hash.d +++ b/libphobos/testsuite/libphobos.hash/test_hash.d @@ -277,7 +277,7 @@ void issue22076() static struct S1 { S0 a; - inout(S0)* b() inout nothrow { return &a; } + inout(S0)* b() inout return nothrow { return &a; } alias b this; } diff --git a/libphobos/testsuite/libphobos.init_fini/custom_gc.d b/libphobos/testsuite/libphobos.init_fini/custom_gc.d index a5e2bf4..ee2dcee 100644 --- a/libphobos/testsuite/libphobos.init_fini/custom_gc.d +++ b/libphobos/testsuite/libphobos.init_fini/custom_gc.d @@ -26,7 +26,8 @@ nothrow @nogc: { import core.stdc.string : memcpy; - __gshared ubyte[__traits(classInstanceSize, MallocGC)] buf; + __gshared align(__traits(classInstanceAlignment, MallocGC)) + ubyte[__traits(classInstanceSize, MallocGC)] buf; auto init = typeid(MallocGC).initializer(); assert(init.length == buf.length); |