diff options
| author | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-12-15 19:47:02 +0100 |
|---|---|---|
| committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2021-12-15 19:51:30 +0100 |
| commit | fd43568cc54e17c8b4a845677872c6282bc6dbb7 (patch) | |
| tree | 24f591392a2978706aef4d58e377b8b42b5ba418 /libphobos/libdruntime/core/sys | |
| parent | 639ece7abfa3688008cb791aec4c7a1a4f76e59f (diff) | |
d: Merge upstream dmd 93108bb9e, druntime 6364e010, phobos 575b67a9b.
D front-end changes:
- Import dmd v2.098.1-beta.1.
- Default extern(C++) compatibility to C++17.
Druntime changes:
- Import druntime v2.098.1-beta.1.
- Fix definition of stat_t on MIPS64 (PR103604)
Phobos changes:
- Import phobos v2.098.1-beta.1.
gcc/d/ChangeLog:
* d-lang.cc (d_init_options): Set default -fextern-std= to C++17.
* dmd/MERGE: Merge upstream dmd 93108bb9e.
* gdc.texi (Runtime Options): Document the default for -fextern-std=.
libphobos/ChangeLog:
PR d/103604
* configure: Regenerate.
* configure.ac (libtool_VERSION): Update to 3:0:0.
* libdruntime/MERGE: Merge upstream druntime 6364e010.
* src/MERGE: Merge upstream phobos 575b67a9b.
* testsuite/libphobos.traits/all_satisfy.d: New test.
* testsuite/libphobos.traits/traits.exp: New test.
Diffstat (limited to 'libphobos/libdruntime/core/sys')
| -rw-r--r-- | libphobos/libdruntime/core/sys/openbsd/execinfo.d | 139 | ||||
| -rw-r--r-- | libphobos/libdruntime/core/sys/posix/sys/stat.d | 46 |
2 files changed, 33 insertions, 152 deletions
diff --git a/libphobos/libdruntime/core/sys/openbsd/execinfo.d b/libphobos/libdruntime/core/sys/openbsd/execinfo.d index f5b317f2bfc..cd9cd166e57 100644 --- a/libphobos/libdruntime/core/sys/openbsd/execinfo.d +++ b/libphobos/libdruntime/core/sys/openbsd/execinfo.d @@ -11,137 +11,10 @@ module core.sys.openbsd.execinfo; version (OpenBSD): extern (C): nothrow: +@nogc: -version (GNU) - version = BacktraceExternal; - -version (BacktraceExternal) -{ - size_t backtrace(void**, size_t); - char** backtrace_symbols(const(void*)*, size_t); - void backtrace_symbols_fd(const(void*)*, size_t, int); - char** backtrace_symbols_fmt(const(void*)*, size_t, const char*); - int backtrace_symbols_fd_fmt(const(void*)*, size_t, int, const char*); -} -else -{ - import core.sys.openbsd.dlfcn; - - // Use extern (D) so that these functions don't collide with libexecinfo. - - extern (D) int backtrace(void** buffer, int size) - { - import core.thread : thread_stackBottom; - - void** p, pend=cast(void**)thread_stackBottom(); - version (D_InlineAsm_X86) - asm nothrow @trusted { mov p[EBP], EBP; } - else version (D_InlineAsm_X86_64) - asm nothrow @trusted { mov p[RBP], RBP; } - else - static assert(false, "Architecture not supported."); - - int i; - for (; i < size && p < pend; ++i) - { - buffer[i] = *(p + 1); - auto pnext = cast(void**)*p; - if (pnext <= p) break; - p = pnext; - } - return i; - } - - - extern (D) char** backtrace_symbols(const(void*)* buffer, int size) - { - static void* realloc(void* p, size_t len) nothrow - { - static import cstdlib=core.stdc.stdlib; - auto res = cstdlib.realloc(p, len); - if (res is null) cstdlib.free(p); - return res; - } - - if (size <= 0) return null; - - size_t pos = size * (char*).sizeof; - char** p = cast(char**)realloc(null, pos); - if (p is null) return null; - - Dl_info info; - foreach (i, addr; buffer[0 .. size]) - { - if (dladdr(addr, &info) == 0) - (cast(ubyte*)&info)[0 .. info.sizeof] = 0; - fixupDLInfo(addr, info); - - immutable len = formatStackFrame(null, 0, addr, info); - assert(len > 0); - - p = cast(char**)realloc(p, pos + len); - if (p is null) return null; - - formatStackFrame(cast(char*)p + pos, len, addr, info) == len || assert(0); - - p[i] = cast(char*)pos; - pos += len; - } - foreach (i; 0 .. size) - { - pos = cast(size_t)p[i]; - p[i] = cast(char*)p + pos; - } - return p; - } - - - extern (D) void backtrace_symbols_fd(const(void*)* buffer, int size, int fd) - { - import core.sys.posix.unistd : write; - import core.stdc.stdlib : alloca; - - if (size <= 0) return; - - Dl_info info; - foreach (i, addr; buffer[0 .. size]) - { - if (dladdr(addr, &info) == 0) - (cast(ubyte*)&info)[0 .. info.sizeof] = 0; - fixupDLInfo(addr, info); - - enum maxAlloca = 1024; - enum min = (size_t a, size_t b) => a <= b ? a : b; - immutable len = min(formatStackFrame(null, 0, addr, info), maxAlloca); - assert(len > 0); - - auto p = cast(char*)alloca(len); - if (p is null) return; - - formatStackFrame(p, len, addr, info) >= len || assert(0); - p[len - 1] = '\n'; - write(fd, p, len); - } - } - - - private void fixupDLInfo(const(void)* addr, ref Dl_info info) - { - if (info.dli_fname is null) info.dli_fname = "???"; - if (info.dli_fbase is null) info.dli_fbase = null; - if (info.dli_sname is null) info.dli_sname = "???"; - if (info.dli_saddr is null) info.dli_saddr = cast(void*)addr; - } - - - private size_t formatStackFrame(char* p, size_t plen, const(void)* addr, const ref Dl_info info) - { - import core.stdc.stdio : snprintf; - - immutable off = addr - info.dli_saddr; - immutable len = snprintf(p, plen, "%p <%s+%zd> at %s", - addr, info.dli_sname, off, info.dli_fname); - assert(len > 0); - return cast(size_t)len + 1; // + '\0' - } -} +size_t backtrace(void**, size_t); +char** backtrace_symbols(const(void*)*, size_t); +void backtrace_symbols_fd(const(void*)*, size_t, int); +char** backtrace_symbols_fmt(const(void*)*, size_t, const char*); +int backtrace_symbols_fd_fmt(const(void*)*, size_t, int, const char*); diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d index 6b4d022b825..7d0b1708e2d 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/stat.d +++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d @@ -340,26 +340,23 @@ version (CRuntime_Glibc) } c_long[14] st_pad5; } + static if (!__USE_FILE_OFFSET64) + static assert(stat_t.sizeof == 144); + else + static assert(stat_t.sizeof == 160); } else version (MIPS64) { struct stat_t { - c_ulong st_dev; + dev_t st_dev; int[3] st_pad1; - static if (!__USE_FILE_OFFSET64) - { - ino_t st_ino; - } - else - { - c_ulong st_ino; - } + 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; static if (!__USE_FILE_OFFSET64) { uint[2] st_pad2; @@ -368,8 +365,8 @@ version (CRuntime_Glibc) } else { - c_long[3] st_pad2; - c_long st_size; + uint[3] st_pad2; + off_t st_size; } static if (__USE_MISC || __USE_XOPEN2K8) { @@ -394,15 +391,26 @@ version (CRuntime_Glibc) } blksize_t st_blksize; uint st_pad4; + blkcnt_t st_blocks; + int[14] st_pad5; + } + version (MIPS_N32) + { static if (!__USE_FILE_OFFSET64) - { - blkcnt_t st_blocks; - } + static assert(stat_t.sizeof == 160); else - { - c_long st_blocks; - } - c_long[14] st_pad5; + static assert(stat_t.sizeof == 176); + } + else version (MIPS_O64) + { + static if (!__USE_FILE_OFFSET64) + static assert(stat_t.sizeof == 160); + else + static assert(stat_t.sizeof == 176); + } + else + { + static assert(stat_t.sizeof == 216); } } else version (PPC) |
