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/libdruntime | |
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/libdruntime')
105 files changed, 5990 insertions, 8866 deletions
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); } } |