├── .circleci ├── config.yml └── run.sh ├── .cirrus.yml ├── .codecov.yml ├── .editorconfig ├── .github └── workflows │ └── cxx.yml ├── .gitignore ├── CODEOWNERS ├── CONTRIBUTING.md ├── Jenkinsfile ├── LICENSE.txt ├── README.md ├── appveyor.yml ├── azure-pipelines.yml ├── benchmark ├── .gitignore ├── aabench │ ├── bigval.d │ ├── bulk.d │ ├── int.d │ ├── l3cache.d │ ├── obj.d │ ├── ptr.d │ ├── resize.d │ ├── stomper.d │ └── string.d ├── arrayops │ ├── arrayops.d │ ├── arrayops.ignore │ └── plot.R ├── extra-files │ └── dante.txt ├── gcbench │ ├── conalloc.d │ ├── conappend.d │ ├── concpu.d │ ├── conmsg.d │ ├── dlist.d │ ├── huge_single.d │ ├── rand_large.d │ ├── rand_small.d │ ├── slist.d │ ├── testgc3.d │ ├── tree1.d │ ├── tree2.d │ ├── vdparser.d │ ├── vdparser.extra │ │ ├── stdext │ │ │ ├── array.d │ │ │ ├── path.d │ │ │ ├── string.d │ │ │ └── util.d │ │ └── vdc │ │ │ ├── ast │ │ │ ├── aggr.d │ │ │ ├── all.d │ │ │ ├── decl.d │ │ │ ├── expr.d │ │ │ ├── iasm.d │ │ │ ├── misc.d │ │ │ ├── mod.d │ │ │ ├── node.d │ │ │ ├── stmt.d │ │ │ ├── tmpl.d │ │ │ ├── type.d │ │ │ └── writer.d │ │ │ ├── interpret.d │ │ │ ├── lexer.d │ │ │ ├── logger.d │ │ │ ├── parser │ │ │ ├── aggr.d │ │ │ ├── decl.d │ │ │ ├── engine.d │ │ │ ├── expr.d │ │ │ ├── iasm.d │ │ │ ├── misc.d │ │ │ ├── mod.d │ │ │ ├── stmt.d │ │ │ └── tmpl.d │ │ │ ├── semantic.d │ │ │ ├── util.d │ │ │ └── versions.d │ └── words.d ├── plot.R └── runbench.d ├── changelog ├── README.md ├── drt-oncycle-deprecate.dd └── posix_gc_signals.dd ├── def ├── glu32.def ├── odbc32.def ├── opengl32.def ├── rpcrt4.def ├── shell32.def ├── version.def ├── wininet.def └── winspool.def ├── dub.sdl ├── mak ├── COPY ├── DOCS ├── SRCS ├── WINDOWS └── copyimports.d ├── posix.mak ├── project.ddoc ├── setmscver.bat ├── src ├── __builtins.di ├── core │ ├── atomic.d │ ├── attribute.d │ ├── bitop.d │ ├── builtins.d │ ├── checkedint.d │ ├── cpuid.d │ ├── demangle.d │ ├── exception.d │ ├── gc │ │ ├── config.d │ │ ├── gcinterface.d │ │ └── registry.d │ ├── int128.d │ ├── internal │ │ ├── abort.d │ │ ├── array │ │ │ ├── appending.d │ │ │ ├── capacity.d │ │ │ ├── casting.d │ │ │ ├── comparison.d │ │ │ ├── concatenation.d │ │ │ ├── construction.d │ │ │ ├── duplication.d │ │ │ ├── equality.d │ │ │ ├── operations.d │ │ │ └── utils.d │ │ ├── atomic.d │ │ ├── attributes.d │ │ ├── backtrace │ │ │ ├── dwarf.d │ │ │ ├── elf.d │ │ │ ├── handler.d │ │ │ ├── libunwind.d │ │ │ ├── macho.d │ │ │ └── unwind.d │ │ ├── container │ │ │ ├── array.d │ │ │ ├── common.d │ │ │ ├── hashtab.d │ │ │ └── treap.d │ │ ├── convert.d │ │ ├── dassert.d │ │ ├── destruction.d │ │ ├── elf │ │ │ ├── dl.d │ │ │ └── io.d │ │ ├── entrypoint.d │ │ ├── execinfo.d │ │ ├── gc │ │ │ ├── bits.d │ │ │ ├── impl │ │ │ │ ├── conservative │ │ │ │ │ └── gc.d │ │ │ │ ├── manual │ │ │ │ │ └── gc.d │ │ │ │ └── proto │ │ │ │ │ └── gc.d │ │ │ ├── os.d │ │ │ ├── pooltable.d │ │ │ └── proxy.d │ │ ├── hash.d │ │ ├── lifetime.d │ │ ├── moving.d │ │ ├── parseoptions.d │ │ ├── postblit.d │ │ ├── qsort.d │ │ ├── spinlock.d │ │ ├── string.d │ │ ├── switch_.d │ │ ├── traits.d │ │ ├── utf.d │ │ ├── util │ │ │ ├── array.d │ │ │ └── math.d │ │ └── vararg │ │ │ ├── aarch64.d │ │ │ └── sysv_x64.d │ ├── lifetime.d │ ├── math.d │ ├── memory.d │ ├── runtime.d │ ├── simd.d │ ├── stdc │ │ ├── assert_.d │ │ ├── complex.d │ │ ├── config.d │ │ ├── ctype.d │ │ ├── errno.c │ │ ├── errno.d │ │ ├── fenv.d │ │ ├── float_.d │ │ ├── inttypes.d │ │ ├── limits.d │ │ ├── locale.d │ │ ├── math.d │ │ ├── signal.d │ │ ├── stdarg.d │ │ ├── stddef.d │ │ ├── stdint.d │ │ ├── stdio.d │ │ ├── stdlib.d │ │ ├── string.d │ │ ├── tgmath.d │ │ ├── time.d │ │ ├── wchar_.d │ │ └── wctype.d │ ├── stdcpp │ │ ├── allocator.d │ │ ├── array.d │ │ ├── exception.d │ │ ├── memory.d │ │ ├── new_.d │ │ ├── string.d │ │ ├── string_view.d │ │ ├── type_traits.d │ │ ├── typeinfo.d │ │ ├── utility.d │ │ ├── vector.d │ │ └── xutility.d │ ├── sync │ │ ├── barrier.d │ │ ├── condition.d │ │ ├── config.d │ │ ├── event.d │ │ ├── exception.d │ │ ├── mutex.d │ │ ├── package.d │ │ ├── rwmutex.d │ │ └── semaphore.d │ ├── sys │ │ ├── bionic │ │ │ ├── err.d │ │ │ ├── fcntl.d │ │ │ ├── stdlib.d │ │ │ ├── string.d │ │ │ └── unistd.d │ │ ├── darwin │ │ │ ├── crt_externs.d │ │ │ ├── dlfcn.d │ │ │ ├── err.d │ │ │ ├── execinfo.d │ │ │ ├── fcntl.d │ │ │ ├── ifaddrs.d │ │ │ ├── mach │ │ │ │ ├── dyld.d │ │ │ │ ├── getsect.d │ │ │ │ ├── kern_return.d │ │ │ │ ├── loader.d │ │ │ │ ├── nlist.d │ │ │ │ ├── port.d │ │ │ │ ├── semaphore.d │ │ │ │ ├── stab.d │ │ │ │ └── thread_act.d │ │ │ ├── netinet │ │ │ │ └── in_.d │ │ │ ├── pthread.d │ │ │ ├── stdlib.d │ │ │ ├── string.d │ │ │ └── sys │ │ │ │ ├── attr.d │ │ │ │ ├── cdefs.d │ │ │ │ ├── event.d │ │ │ │ ├── mman.d │ │ │ │ └── sysctl.d │ │ ├── dragonflybsd │ │ │ ├── dlfcn.d │ │ │ ├── err.d │ │ │ ├── execinfo.d │ │ │ ├── netinet │ │ │ │ └── in_.d │ │ │ ├── pthread_np.d │ │ │ ├── stdlib.d │ │ │ ├── string.d │ │ │ ├── sys │ │ │ │ ├── _bitset.d │ │ │ │ ├── _cpuset.d │ │ │ │ ├── cdefs.d │ │ │ │ ├── elf.d │ │ │ │ ├── elf32.d │ │ │ │ ├── elf64.d │ │ │ │ ├── elf_common.d │ │ │ │ ├── event.d │ │ │ │ ├── link_elf.d │ │ │ │ ├── mman.d │ │ │ │ ├── socket.d │ │ │ │ └── sysctl.d │ │ │ └── time.d │ │ ├── elf │ │ │ └── package.d │ │ ├── freebsd │ │ │ ├── config.d │ │ │ ├── dlfcn.d │ │ │ ├── err.d │ │ │ ├── execinfo.d │ │ │ ├── netinet │ │ │ │ └── in_.d │ │ │ ├── pthread_np.d │ │ │ ├── stdlib.d │ │ │ ├── string.d │ │ │ ├── sys │ │ │ │ ├── _bitset.d │ │ │ │ ├── _cpuset.d │ │ │ │ ├── cdefs.d │ │ │ │ ├── elf.d │ │ │ │ ├── elf32.d │ │ │ │ ├── elf64.d │ │ │ │ ├── elf_common.d │ │ │ │ ├── event.d │ │ │ │ ├── link_elf.d │ │ │ │ ├── mman.d │ │ │ │ ├── mount.d │ │ │ │ └── sysctl.d │ │ │ ├── time.d │ │ │ └── unistd.d │ │ ├── linux │ │ │ ├── config.d │ │ │ ├── dlfcn.d │ │ │ ├── elf.d │ │ │ ├── epoll.d │ │ │ ├── err.d │ │ │ ├── errno.d │ │ │ ├── execinfo.d │ │ │ ├── fcntl.d │ │ │ ├── fs.d │ │ │ ├── ifaddrs.d │ │ │ ├── io_uring.d │ │ │ ├── link.d │ │ │ ├── netinet │ │ │ │ ├── in_.d │ │ │ │ └── tcp.d │ │ │ ├── perf_event.d │ │ │ ├── sched.d │ │ │ ├── stdio.d │ │ │ ├── string.d │ │ │ ├── sys │ │ │ │ ├── auxv.d │ │ │ │ ├── eventfd.d │ │ │ │ ├── file.d │ │ │ │ ├── inotify.d │ │ │ │ ├── mman.d │ │ │ │ ├── prctl.d │ │ │ │ ├── procfs.d │ │ │ │ ├── signalfd.d │ │ │ │ ├── socket.d │ │ │ │ ├── sysinfo.d │ │ │ │ ├── time.d │ │ │ │ └── xattr.d │ │ │ ├── termios.d │ │ │ ├── time.d │ │ │ ├── timerfd.d │ │ │ ├── tipc.d │ │ │ └── unistd.d │ │ ├── netbsd │ │ │ ├── dlfcn.d │ │ │ ├── err.d │ │ │ ├── execinfo.d │ │ │ ├── stdlib.d │ │ │ ├── string.d │ │ │ ├── sys │ │ │ │ ├── elf.d │ │ │ │ ├── elf32.d │ │ │ │ ├── elf64.d │ │ │ │ ├── elf_common.d │ │ │ │ ├── event.d │ │ │ │ ├── featuretest.d │ │ │ │ ├── link_elf.d │ │ │ │ ├── mman.d │ │ │ │ └── sysctl.d │ │ │ └── time.d │ │ ├── openbsd │ │ │ ├── dlfcn.d │ │ │ ├── err.d │ │ │ ├── execinfo.d │ │ │ ├── pthread_np.d │ │ │ ├── pwd.d │ │ │ ├── stdlib.d │ │ │ ├── string.d │ │ │ ├── sys │ │ │ │ ├── cdefs.d │ │ │ │ ├── elf.d │ │ │ │ ├── elf32.d │ │ │ │ ├── elf64.d │ │ │ │ ├── elf_common.d │ │ │ │ ├── link_elf.d │ │ │ │ ├── mman.d │ │ │ │ └── sysctl.d │ │ │ ├── time.d │ │ │ └── unistd.d │ │ ├── posix │ │ │ ├── aio.d │ │ │ ├── arpa │ │ │ │ └── inet.d │ │ │ ├── config.d │ │ │ ├── dirent.d │ │ │ ├── dlfcn.d │ │ │ ├── fcntl.d │ │ │ ├── grp.d │ │ │ ├── iconv.d │ │ │ ├── inttypes.d │ │ │ ├── libgen.d │ │ │ ├── locale.d │ │ │ ├── mqueue.d │ │ │ ├── net │ │ │ │ └── if_.d │ │ │ ├── netdb.d │ │ │ ├── netinet │ │ │ │ ├── in_.d │ │ │ │ └── tcp.d │ │ │ ├── poll.d │ │ │ ├── pthread.d │ │ │ ├── pwd.d │ │ │ ├── sched.d │ │ │ ├── semaphore.d │ │ │ ├── setjmp.d │ │ │ ├── signal.d │ │ │ ├── spawn.d │ │ │ ├── stdc │ │ │ │ └── time.d │ │ │ ├── stdio.d │ │ │ ├── stdlib.d │ │ │ ├── string.d │ │ │ ├── strings.d │ │ │ ├── sys │ │ │ │ ├── filio.d │ │ │ │ ├── ioccom.d │ │ │ │ ├── ioctl.d │ │ │ │ ├── ipc.d │ │ │ │ ├── mman.d │ │ │ │ ├── msg.d │ │ │ │ ├── resource.d │ │ │ │ ├── select.d │ │ │ │ ├── shm.d │ │ │ │ ├── socket.d │ │ │ │ ├── stat.d │ │ │ │ ├── statvfs.d │ │ │ │ ├── time.d │ │ │ │ ├── ttycom.d │ │ │ │ ├── types.d │ │ │ │ ├── uio.d │ │ │ │ ├── un.d │ │ │ │ ├── utsname.d │ │ │ │ └── wait.d │ │ │ ├── syslog.d │ │ │ ├── termios.d │ │ │ ├── time.d │ │ │ ├── ucontext.d │ │ │ ├── unistd.d │ │ │ └── utime.d │ │ ├── solaris │ │ │ ├── dlfcn.d │ │ │ ├── elf.d │ │ │ ├── err.d │ │ │ ├── execinfo.d │ │ │ ├── libelf.d │ │ │ ├── link.d │ │ │ ├── stdlib.d │ │ │ ├── sys │ │ │ │ ├── elf.d │ │ │ │ ├── elf_386.d │ │ │ │ ├── elf_SPARC.d │ │ │ │ ├── elf_amd64.d │ │ │ │ ├── elf_notes.d │ │ │ │ ├── elftypes.d │ │ │ │ ├── link.d │ │ │ │ ├── priocntl.d │ │ │ │ ├── procset.d │ │ │ │ └── types.d │ │ │ └── time.d │ │ └── windows │ │ │ ├── accctrl.d │ │ │ ├── aclapi.d │ │ │ ├── aclui.d │ │ │ ├── basetsd.d │ │ │ ├── basetyps.d │ │ │ ├── cderr.d │ │ │ ├── cguid.d │ │ │ ├── com.d │ │ │ ├── comcat.d │ │ │ ├── commctrl.d │ │ │ ├── commdlg.d │ │ │ ├── core.d │ │ │ ├── cpl.d │ │ │ ├── cplext.d │ │ │ ├── custcntl.d │ │ │ ├── dbghelp.d │ │ │ ├── dbghelp_types.d │ │ │ ├── dbt.d │ │ │ ├── dde.d │ │ │ ├── ddeml.d │ │ │ ├── dhcpcsdk.d │ │ │ ├── dlgs.d │ │ │ ├── dll.d │ │ │ ├── docobj.d │ │ │ ├── errorrep.d │ │ │ ├── exdisp.d │ │ │ ├── exdispid.d │ │ │ ├── httpext.d │ │ │ ├── idispids.d │ │ │ ├── imagehlp.d │ │ │ ├── imm.d │ │ │ ├── intshcut.d │ │ │ ├── ipexport.d │ │ │ ├── iphlpapi.d │ │ │ ├── ipifcons.d │ │ │ ├── iprtrmib.d │ │ │ ├── iptypes.d │ │ │ ├── isguids.d │ │ │ ├── lm.d │ │ │ ├── lmaccess.d │ │ │ ├── lmalert.d │ │ │ ├── lmapibuf.d │ │ │ ├── lmat.d │ │ │ ├── lmaudit.d │ │ │ ├── lmbrowsr.d │ │ │ ├── lmchdev.d │ │ │ ├── lmconfig.d │ │ │ ├── lmcons.d │ │ │ ├── lmerr.d │ │ │ ├── lmerrlog.d │ │ │ ├── lmmsg.d │ │ │ ├── lmremutl.d │ │ │ ├── lmrepl.d │ │ │ ├── lmserver.d │ │ │ ├── lmshare.d │ │ │ ├── lmsname.d │ │ │ ├── lmstats.d │ │ │ ├── lmsvc.d │ │ │ ├── lmuse.d │ │ │ ├── lmuseflg.d │ │ │ ├── lmwksta.d │ │ │ ├── lzexpand.d │ │ │ ├── mapi.d │ │ │ ├── mciavi.d │ │ │ ├── mcx.d │ │ │ ├── mgmtapi.d │ │ │ ├── mmsystem.d │ │ │ ├── msacm.d │ │ │ ├── mshtml.d │ │ │ ├── mswsock.d │ │ │ ├── nb30.d │ │ │ ├── nddeapi.d │ │ │ ├── nspapi.d │ │ │ ├── ntdef.d │ │ │ ├── ntdll.d │ │ │ ├── ntldap.d │ │ │ ├── ntsecapi.d │ │ │ ├── ntsecpkg.d │ │ │ ├── oaidl.d │ │ │ ├── objbase.d │ │ │ ├── objfwd.d │ │ │ ├── objidl.d │ │ │ ├── objsafe.d │ │ │ ├── ocidl.d │ │ │ ├── odbcinst.d │ │ │ ├── ole.d │ │ │ ├── ole2.d │ │ │ ├── ole2ver.d │ │ │ ├── oleacc.d │ │ │ ├── oleauto.d │ │ │ ├── olectl.d │ │ │ ├── olectlid.d │ │ │ ├── oledlg.d │ │ │ ├── oleidl.d │ │ │ ├── pbt.d │ │ │ ├── powrprof.d │ │ │ ├── prsht.d │ │ │ ├── psapi.d │ │ │ ├── rapi.d │ │ │ ├── ras.d │ │ │ ├── rasdlg.d │ │ │ ├── raserror.d │ │ │ ├── rassapi.d │ │ │ ├── reason.d │ │ │ ├── regstr.d │ │ │ ├── richedit.d │ │ │ ├── richole.d │ │ │ ├── rpc.d │ │ │ ├── rpcdce.d │ │ │ ├── rpcdce2.d │ │ │ ├── rpcdcep.d │ │ │ ├── rpcndr.d │ │ │ ├── rpcnsi.d │ │ │ ├── rpcnsip.d │ │ │ ├── rpcnterr.d │ │ │ ├── schannel.d │ │ │ ├── sdkddkver.d │ │ │ ├── secext.d │ │ │ ├── security.d │ │ │ ├── servprov.d │ │ │ ├── setupapi.d │ │ │ ├── shellapi.d │ │ │ ├── shldisp.d │ │ │ ├── shlguid.d │ │ │ ├── shlobj.d │ │ │ ├── shlwapi.d │ │ │ ├── snmp.d │ │ │ ├── sql.d │ │ │ ├── sqlext.d │ │ │ ├── sqltypes.d │ │ │ ├── sqlucode.d │ │ │ ├── sspi.d │ │ │ ├── stacktrace.d │ │ │ ├── stat.d │ │ │ ├── stdc │ │ │ ├── malloc.d │ │ │ └── time.d │ │ │ ├── subauth.d │ │ │ ├── threadaux.d │ │ │ ├── tlhelp32.d │ │ │ ├── tmschema.d │ │ │ ├── unknwn.d │ │ │ ├── uuid.d │ │ │ ├── vfw.d │ │ │ ├── w32api.d │ │ │ ├── winbase.d │ │ │ ├── winber.d │ │ │ ├── wincon.d │ │ │ ├── wincrypt.d │ │ │ ├── windef.d │ │ │ ├── windows.d │ │ │ ├── winerror.d │ │ │ ├── wingdi.d │ │ │ ├── winhttp.d │ │ │ ├── wininet.d │ │ │ ├── winioctl.d │ │ │ ├── winldap.d │ │ │ ├── winnetwk.d │ │ │ ├── winnls.d │ │ │ ├── winnt.d │ │ │ ├── winperf.d │ │ │ ├── winreg.d │ │ │ ├── winsock2.d │ │ │ ├── winspool.d │ │ │ ├── winsvc.d │ │ │ ├── winuser.d │ │ │ ├── winver.d │ │ │ ├── wtsapi32.d │ │ │ └── wtypes.d │ ├── thread │ │ ├── context.d │ │ ├── fiber.d │ │ ├── osthread.d │ │ ├── package.d │ │ ├── threadbase.d │ │ ├── threadgroup.d │ │ └── types.d │ ├── threadasm.S │ ├── time.d │ ├── vararg.d │ └── volatile.d ├── etc │ └── linux │ │ └── memoryerror.d ├── importc.h ├── ldc │ ├── arm_unwind.c │ ├── asan.d │ ├── attributes.d │ ├── dcompute.d │ ├── eh_asm.S │ ├── eh_msvc.d │ ├── intrinsics.di │ ├── libfuzzer.di │ ├── llvmasm.di │ ├── msvc.c │ ├── opencl.di │ ├── profile.di │ ├── sanitizer_common.d │ ├── sanitizers_optionally_linked.d │ └── simd.di ├── object.d ├── rt │ ├── aApply.d │ ├── aApplyR.d │ ├── aaA.d │ ├── adi.d │ ├── alloca.d │ ├── arrayassign.d │ ├── arraycat.d │ ├── cast_.d │ ├── cmath2.d │ ├── config.d │ ├── cover.d │ ├── critical_.d │ ├── deh.d │ ├── deh_win32.d │ ├── deh_win64_posix.d │ ├── dmain2.d │ ├── dso.d │ ├── dwarfeh.d │ ├── dylib_fixes.c │ ├── ehalloc.d │ ├── invariant.d │ ├── lifetime.d │ ├── llmath.d │ ├── memory.d │ ├── memset.d │ ├── minfo.d │ ├── minit.asm │ ├── minit.obj │ ├── monitor_.d │ ├── msvc.d │ ├── msvc_math.d │ ├── profilegc.d │ ├── sections.d │ ├── sections_android.d │ ├── sections_darwin_64.d │ ├── sections_elf_shared.d │ ├── sections_ldc.d │ ├── sections_osx_x86.d │ ├── sections_osx_x86_64.d │ ├── sections_solaris.d │ ├── sections_win32.d │ ├── sections_win64.d │ ├── tlsgc.d │ ├── trace.d │ ├── tracegc.d │ └── util │ │ ├── typeinfo.d │ │ └── utility.d └── test_runner.d ├── test ├── .gitignore ├── aa │ ├── Makefile │ └── src │ │ └── test_aa.d ├── allocations │ ├── Makefile │ └── src │ │ ├── alloc_from_assert.d │ │ ├── overflow_from_existing.d │ │ └── overflow_from_zero.d ├── betterc │ ├── Makefile │ ├── src │ │ ├── test18828.d │ │ ├── test19416.d │ │ ├── test19421.d │ │ ├── test19561.d │ │ ├── test19924.d │ │ ├── test19933.d │ │ ├── test20088.d │ │ ├── test20613.d │ │ └── test22336.d │ └── win64.mak ├── common.mak ├── config │ ├── Makefile │ └── src │ │ ├── test19433.d │ │ ├── test20459.d │ │ └── test22523.d ├── coverage │ ├── Makefile │ ├── src-basic.lst.exp │ ├── src-merge.lst.exp │ ├── src-merge_override.lst_1.exp │ ├── src-merge_override.lst_2.exp │ ├── src-merge_true.lst.exp │ ├── src-no_code.lst.exp │ ├── src-no_code_imp.lst.exp │ └── src │ │ ├── basic.d │ │ ├── merge.d │ │ ├── merge_override.d │ │ ├── merge_true.d │ │ ├── no_code.d │ │ └── no_code_imp.d ├── cpuid │ ├── Makefile │ ├── src │ │ └── cpuid.d │ └── win64.mak ├── cycles │ ├── Makefile │ └── src │ │ ├── mod1.d │ │ ├── mod2.d │ │ └── mod3.d ├── exceptions │ ├── Makefile │ ├── chain.exp │ ├── line_trace.exp │ ├── long_backtrace_trunc.exp │ ├── src │ │ ├── assert_fail.d │ │ ├── catch_in_finally.d │ │ ├── chain.d │ │ ├── future_message.d │ │ ├── invalid_memory_operation.d │ │ ├── line_trace.d │ │ ├── long_backtrace_trunc.d │ │ ├── message_with_null.d │ │ ├── refcounted.d │ │ ├── rt_trap_exceptions.d │ │ ├── rt_trap_exceptions_drt.d │ │ ├── static_dtor.d │ │ ├── stderr_msg.d │ │ ├── unittest_assert.d │ │ ├── unknown_gc.d │ │ └── winstack.d │ └── win64.mak ├── gc │ ├── Makefile │ ├── attributes.d │ ├── forkgc.d │ ├── forkgc2.d │ ├── hospital.d │ ├── issue22843.d │ ├── nocollect.d │ ├── precisegc.d │ ├── recoverfree.d │ ├── sentinel1.d │ ├── sentinel2.d │ ├── sigmaskgc.d │ ├── startbackgc.d │ └── win64.mak ├── hash │ ├── Makefile │ └── src │ │ └── test_hash.d ├── imports │ ├── Makefile │ └── src │ │ └── bug18193.d ├── init_fini │ ├── Makefile │ ├── src │ │ ├── custom_gc.d │ │ ├── runtime_args.d │ │ ├── test18996.d │ │ └── thread_join.d │ └── win64.mak ├── lifetime │ ├── Makefile │ └── src │ │ └── large_aggregate_destroy_21097.d ├── nogc.d ├── profile │ ├── Makefile │ ├── bothgc.log.exp │ ├── bothnew.def.exp │ ├── myprofilegc.log.freebsd.32.exp │ ├── myprofilegc.log.freebsd.64.exp │ ├── myprofilegc.log.linux.32.exp │ ├── myprofilegc.log.linux.64.exp │ ├── myprofilegc.log.osx.32.exp │ ├── myprofilegc.log.osx.64.exp │ ├── mytrace.def.exp │ ├── mytrace.releaseopt.def.exp │ └── src │ │ ├── both.d │ │ ├── profile.d │ │ └── profilegc.d ├── shared │ ├── .gitignore │ ├── Makefile │ ├── src │ │ ├── dll_gc_proxy_teardown.d │ │ ├── dllgc.d │ │ ├── dllrefcount.d │ │ ├── dynamiccast.d │ │ ├── finalize.d │ │ ├── host.c │ │ ├── lib.d │ │ ├── lib_13414.d │ │ ├── liblinkdep.d │ │ ├── libloaddep.d │ │ ├── link.d │ │ ├── linkD.c │ │ ├── linkDR.c │ │ ├── link_linkdep.d │ │ ├── link_loaddep.d │ │ ├── load.d │ │ ├── loadDR.c │ │ ├── load_13414.d │ │ ├── load_linkdep.d │ │ ├── load_loaddep.d │ │ ├── loadlibwin.d │ │ ├── plugin.d │ │ ├── utils.di │ │ └── utils.h │ └── win64.mak ├── stdcpp │ ├── Makefile │ ├── src │ │ ├── allocator.cpp │ │ ├── allocator_test.d │ │ ├── array.cpp │ │ ├── array_test.d │ │ ├── exception.cpp │ │ ├── exception_test.d │ │ ├── memory.cpp │ │ ├── memory_test.d │ │ ├── new.cpp │ │ ├── new_test.d │ │ ├── string.cpp │ │ ├── string_test.d │ │ ├── string_view.cpp │ │ ├── string_view_test.d │ │ ├── typeinfo.cpp │ │ ├── typeinfo_test.d │ │ ├── utility.cpp │ │ ├── utility_test.d │ │ ├── vector.cpp │ │ └── vector_test.d │ └── win64.mak ├── thread │ ├── Makefile │ └── src │ │ ├── external_threads.d │ │ ├── fiber_guard_page.d │ │ ├── join_detach.d │ │ ├── test_import.d │ │ ├── tlsgc_sections.d │ │ └── tlsstack.d ├── traits │ ├── Makefile │ └── src │ │ └── all_satisfy.d ├── typeinfo │ ├── Makefile │ └── src │ │ ├── comparison.d │ │ ├── enum_.d │ │ └── isbaseof.d ├── unittest │ ├── Makefile │ └── customhandler.d └── uuid │ ├── test.d │ └── win64.mak ├── win32.mak └── win64.mak /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | working_directory: ~/druntime 5 | docker: 6 | - image: circleci/buildpack-deps:18.04 7 | parallelism: 1 8 | steps: 9 | - checkout 10 | - run: 11 | command: ./.circleci/run.sh setup-repos 12 | name: Clone DMD 13 | - run: 14 | command: ./.circleci/run.sh install-deps 15 | name: Install DMD 16 | - run: 17 | command: ./.circleci/run.sh style 18 | name: Check code style 19 | - run: 20 | command: ./.circleci/run.sh coverage 21 | name: Run DRuntime testsuite with -cov 22 | - run: 23 | command: ./.circleci/run.sh codecov 24 | name: Upload coverage files to CodeCov 25 | - run: 26 | command: ./.circleci/run.sh betterc 27 | name: Run @betterC tests 28 | - run: 29 | command: ./.circleci/run.sh publictests 30 | name: Run public unittests 31 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | # Documentation: https://docs.codecov.io/docs/codecov-yaml 2 | 3 | codecov: 4 | notify: 5 | # We don't want to wait for the CodeCov report 6 | # See https://github.com/codecov/support/issues/312 7 | require_ci_to_pass: false 8 | after_n_builds: 1 # send notifications after the first upload 9 | wait_for_ci: false 10 | 11 | bot: dlang-bot 12 | ci: 13 | # https://docs.codecov.io/docs/detecting-ci-services 14 | # Only CircleCi generates coverages files atm. 15 | # Don't wait for the other CIs 16 | - circleci.com 17 | - !dtest.dlang.io 18 | - !auto-tester.puremagic.com 19 | - !appveyor.com 20 | - !ci.dlang.io 21 | - !travis-ci.org 22 | 23 | # At CircleCi, the PR is merged into `master` before the testsuite is run. 24 | # This allows CodeCov to adjust the resulting coverage diff, s.t. it matches 25 | # with the GitHub diff. 26 | # https://github.com/codecov/support/issues/363 27 | # https://docs.codecov.io/v4.3.6/docs/comparing-commits 28 | allow_coverage_offsets: true 29 | 30 | coverage: 31 | precision: 3 32 | round: down 33 | range: "70...100" 34 | 35 | # Learn more at https://docs.codecov.io/docs/commit-status 36 | status: 37 | project: off 38 | patch: 39 | default: 40 | informational: true 41 | changes: off 42 | 43 | notify: 44 | webhook: 45 | default: 46 | url: "https://dlang-bot.herokuapp.com/codecov_hook" 47 | 48 | comment: false 49 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.{c,cpp,h,d,di,dd}] 4 | insert_final_newline = true 5 | indent_style = space 6 | indent_size = 4 7 | trim_trailing_whitespace = true 8 | charset = utf-8 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | doc/* 2 | lib/* 3 | obj/* 4 | import/* 5 | generated/* 6 | druntime.json 7 | .DS_Store 8 | trace.def 9 | trace.log 10 | /Makefile 11 | /errno_c*.obj 12 | /msvc*.obj 13 | make 14 | *.lst 15 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | #!/bin/env groovy 2 | library 'dlang' 3 | runPipeline() 4 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /benchmark/.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | obj/* 3 | runbench 4 | runbench.o 5 | runbench.d.deps 6 | -------------------------------------------------------------------------------- /benchmark/aabench/bigval.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark AA with big values. 3 | * 4 | * Copyright: Copyright Martin Nowak 2011 - 2015. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | void main(string[] args) 9 | { 10 | static struct V { ubyte[1024] data; } 11 | V[int] aa; 12 | V v; 13 | foreach (_; 0 .. 10) 14 | foreach (i; 0 .. 100_000) 15 | aa[i] = v; 16 | } 17 | -------------------------------------------------------------------------------- /benchmark/aabench/int.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark int hashing. 3 | * 4 | * Copyright: Copyright Martin Nowak 2011 - 2015. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | import std.random; 9 | 10 | void main(string[] args) 11 | { 12 | auto rnd = Xorshift32(33); 13 | 14 | int[int] aa; 15 | foreach (_; 0 .. 10) 16 | foreach (__; 0 .. 100_000) 17 | ++aa[uniform(0, 100_000, rnd)]; 18 | 19 | if (aa.length != 99998) 20 | assert(0); 21 | } 22 | -------------------------------------------------------------------------------- /benchmark/aabench/l3cache.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark with big bucket array (> L3 cache). 3 | * 4 | * Copyright: Copyright Martin Nowak 2011 - 2015. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | void main(string[] args) 9 | { 10 | int[int] aa; 11 | foreach (_; 0 .. 5) 12 | { 13 | foreach (i; 0 .. 1_000_000) 14 | { 15 | ++aa[i]; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /benchmark/aabench/obj.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark class hashing. 3 | * 4 | * Copyright: Copyright Martin Nowak 2011 - 2015. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | import std.random; 9 | 10 | void main(string[] args) 11 | { 12 | auto rnd = Xorshift32(33); 13 | 14 | Object[Object] aa; 15 | auto objs = new Object[](32768); 16 | foreach (ref o; objs) 17 | o = new Object; 18 | 19 | foreach (_; 0 .. 10) 20 | { 21 | foreach (__; 0 .. 100_000) 22 | { 23 | auto k = objs[uniform(0, objs.length, rnd)]; 24 | auto v = objs[uniform(0, objs.length, rnd)]; 25 | aa[k] = v; 26 | } 27 | } 28 | if (aa.length != objs.length) 29 | assert(0); 30 | } 31 | -------------------------------------------------------------------------------- /benchmark/aabench/ptr.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark ptr hashing. 3 | * 4 | * Copyright: Copyright Martin Nowak 2011 - 2015. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | import std.random; 9 | 10 | void main(string[] args) 11 | { 12 | auto rnd = Xorshift32(33); 13 | 14 | int[int* ] aa; 15 | auto keys = new int*[](32768); 16 | foreach (ref k; keys) 17 | k = new int; 18 | 19 | foreach (_; 0 .. 10) 20 | foreach (__; 0 .. 100_000) 21 | ++aa[keys[uniform(0, keys.length, rnd)]]; 22 | 23 | if (aa.length != keys.length) 24 | assert(0); 25 | } 26 | -------------------------------------------------------------------------------- /benchmark/aabench/resize.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark increasing/decreasing AA size. 3 | * 4 | * Copyright: Copyright Martin Nowak 2011 - 2011. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | 9 | import std.random; 10 | 11 | enum Count = 256; 12 | enum MinSize = 512; 13 | enum MaxSize = 16_384; 14 | 15 | void runTest(RNG)(RNG gen) 16 | { 17 | bool[uint] aa; 18 | 19 | sizediff_t diff = MinSize; 20 | size_t cnt = Count; 21 | 22 | do 23 | { 24 | while (diff > 0) 25 | { 26 | auto key = uniform(0, MaxSize, gen); 27 | if (!(key in aa)) 28 | { 29 | aa[key] = true; 30 | --diff; 31 | } 32 | } 33 | 34 | while (diff < 0) 35 | { 36 | auto key = uniform(0, MaxSize, gen); 37 | if (!!(key in aa)) 38 | { 39 | aa.remove(key); 40 | ++diff; 41 | } 42 | } 43 | 44 | auto nsize = uniform(MinSize, MaxSize, gen); 45 | diff = nsize - aa.length; 46 | } while (--cnt); 47 | } 48 | 49 | void main() 50 | { 51 | version (RANDOMIZE) 52 | auto gen = Xorshift32(unpredictableSeed); 53 | else 54 | auto gen = Xorshift32(33); 55 | runTest(gen); 56 | } 57 | -------------------------------------------------------------------------------- /benchmark/aabench/string.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark string hashing. 3 | * 4 | * Copyright: Copyright Martin Nowak 2011 - 2015. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | module aabench.string; 9 | 10 | import std.algorithm, std.file; 11 | 12 | void runTest(R)(R words) 13 | { 14 | size_t[string] aa; 15 | 16 | foreach (_; 0 .. 10) 17 | foreach (word; words) 18 | ++aa[word]; 19 | 20 | if (aa.length != 24900) 21 | assert(0); 22 | } 23 | 24 | void main(string[] args) 25 | { 26 | auto path = args.length > 1 ? args[1] : "extra-files/dante.txt"; 27 | auto words = splitter(cast(string) read(path), ' '); 28 | runTest(words); 29 | } 30 | -------------------------------------------------------------------------------- /benchmark/arrayops/arrayops.ignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldc-developers/druntime/6cb44f57ac9ba66a26df93739b9f8c9918fdfad3/benchmark/arrayops/arrayops.ignore -------------------------------------------------------------------------------- /benchmark/gcbench/huge_single.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark on one huge allocation. 3 | * 4 | * Copyright: Copyright David Simcha 2011 - 2011. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: David Simcha 7 | */ 8 | 9 | /* Copyright David Simcha 2011 - 2011. 10 | * Distributed under the Boost Software License, Version 1.0. 11 | * (See accompanying file LICENSE or copy at 12 | * http://www.boost.org/LICENSE_1_0.txt) 13 | */ 14 | import std.stdio, core.memory; 15 | 16 | void main(string[] args) { 17 | enum mul = 1000; 18 | auto ptr = GC.malloc(mul * 1_048_576, GC.BlkAttr.NO_SCAN); 19 | 20 | GC.collect(); 21 | } 22 | -------------------------------------------------------------------------------- /benchmark/gcbench/rand_large.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark on uniformly distributed, random large allocations. 3 | * 4 | * Copyright: Copyright David Simcha 2011 - 2011. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: David Simcha 7 | */ 8 | 9 | /* Copyright David Simcha 2011 - 2011. 10 | * Distributed under the Boost Software License, Version 1.0. 11 | * (See accompanying file LICENSE or copy at 12 | * http://www.boost.org/LICENSE_1_0.txt) 13 | */ 14 | import std.random, core.memory, std.stdio; 15 | 16 | enum nIter = 10000; 17 | 18 | void main() 19 | { 20 | version (RANDOMIZE) 21 | auto rnd = Random(unpredictableSeed); 22 | else 23 | auto rnd = Random(1202387523); 24 | 25 | auto ptrs = new void*[1024]; 26 | 27 | // Allocate 1024 large blocks with size uniformly distributed between 1 28 | // and 128 kilobytes. 29 | foreach(i; 0..nIter) 30 | { 31 | foreach(ref ptr; ptrs) 32 | { 33 | immutable sz = uniform(1024, 128 * 1024 + 1, rnd); 34 | ptr = GC.malloc(sz, GC.BlkAttr.NO_SCAN); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /benchmark/gcbench/rand_small.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Benchmark on uniformly distributed, random small allocations. 3 | * 4 | * Copyright: Copyright David Simcha 2011 - 2011. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: David Simcha 7 | */ 8 | 9 | /* Copyright David Simcha 2011 - 2011. 10 | * Distributed under the Boost Software License, Version 1.0. 11 | * (See accompanying file LICENSE or copy at 12 | * http://www.boost.org/LICENSE_1_0.txt) 13 | */ 14 | import std.random, core.memory, std.stdio, std.conv; 15 | 16 | void main(string[] args) 17 | { 18 | size_t nIter = 10000; 19 | if(args.length > 1) 20 | nIter = to!size_t(args[1]); 21 | 22 | version (RANDOMIZE) 23 | auto rnd = Random(unpredictableSeed); 24 | else 25 | auto rnd = Random(2929088778); 26 | 27 | auto ptrs = new void*[4096]; 28 | 29 | // Allocate large blocks with size uniformly distributed between 8 30 | // and 2048 bytes. 31 | foreach(i; 0..nIter) 32 | { 33 | foreach(ref ptr; ptrs) 34 | { 35 | immutable sz = uniform(8, 2048, rnd); 36 | ptr = GC.malloc(sz, GC.BlkAttr.NO_SCAN); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /benchmark/gcbench/slist.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright: Copyright Rainer Schuetze 2014. 3 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 4 | * Authors: Rainer Schuetze 5 | * 6 | * This test reads a text file, then splits the result into white space delimited words. 7 | * The result is a single linked list of strings referencing the full text. 8 | * Regarding GC activity, this test probes collection of linked lists. 9 | */ 10 | import std.stdio; 11 | import std.conv; 12 | import std.file; 13 | import std.string; 14 | import std.exception; 15 | 16 | struct Node 17 | { 18 | string token; 19 | Node* next; 20 | } 21 | 22 | void main(string[] args) 23 | { 24 | string txt = cast(string) std.file.read(args.length > 1 ? args[1] : "extra-files/dante.txt"); 25 | uint cnt = args.length > 2 ? to!uint(args[2]) : 100; 26 | uint allwords = 0; 27 | for(uint i = 0; i < cnt; i++) 28 | { 29 | Node* firstNode; 30 | auto words = txt.split(); 31 | foreach(w; words) 32 | { 33 | Node* n = new Node; 34 | n.token = w; 35 | n.next = firstNode; 36 | firstNode = n; 37 | } 38 | 39 | for(Node* p = firstNode; p; p = p.next) 40 | allwords++; 41 | } 42 | enforce(allwords == (args.length > 3 ? to!size_t(args[3]) : 9767600)); 43 | } 44 | -------------------------------------------------------------------------------- /benchmark/gcbench/testgc3.d: -------------------------------------------------------------------------------- 1 | /** 2 | * taken from the dmd test suite, added options to run multiple times 3 | * 4 | * This test creates 10000 associative arrays uint[uint] multiple times 5 | * collecting arrays created in previous iterations. 6 | * A 32-bit process can be sensitive to false pointers as hash values 7 | * in the AAs can reference arbitrary addresses. 8 | */ 9 | import std.conv; 10 | import std.exception; 11 | 12 | int main(string[] args) 13 | { 14 | int cnt = 4; 15 | int num = 200; 16 | if (args.length > 1) 17 | cnt = to!int(args[1]); 18 | if (args.length > 2) 19 | num = to!int(args[2]); 20 | ulong sum; 21 | for(int n = 0; n < cnt; n++) 22 | { 23 | uint[uint][] aa; 24 | aa.length = 10000; 25 | int aacnt = num * 10000; 26 | for(int i = 0; i < aacnt; i++) 27 | { 28 | size_t j = i % aa.length; 29 | uint k = i; 30 | uint l = i; 31 | aa[j][k] = l; 32 | } 33 | sum = 0; 34 | foreach(s; aa[4711]) 35 | sum += s; 36 | enforce(sum == 4711 * num + 10000 * num * (num - 1) / 2); 37 | aa[] = null; 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /benchmark/gcbench/tree2.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Another tree building benchmark. Thanks again to Bearophile. 3 | * 4 | * Copyright: Copyright David Simcha 2011 - 2011. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: David Simcha 7 | */ 8 | 9 | /* Copyright David Simcha 2011 - 2011. 10 | * Distributed under the Boost Software License, Version 1.0. 11 | * (See accompanying file LICENSE or copy at 12 | * http://www.boost.org/LICENSE_1_0.txt) 13 | */ 14 | import std.stdio, std.container, std.range, std.conv, std.exception; 15 | 16 | void main(string[] args) 17 | { 18 | int n = args.length > 1 ? to!int(args[1]) : 7000000; 19 | int range = args.length > 2 ? to!int(args[2]) : 100; 20 | 21 | auto t = redBlackTree!int(); 22 | 23 | for (int i = 0; i < n; i++) { 24 | if (i > range) 25 | t.removeFront(); 26 | t.insert(i); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /benchmark/gcbench/vdparser.d: -------------------------------------------------------------------------------- 1 | import vdc.semantic; 2 | import std.random, std.conv, std.file, std.path; 3 | 4 | struct FalsePointers 5 | { 6 | string s; 7 | ubyte[40960] data; 8 | } 9 | 10 | FalsePointers* ptrs; 11 | 12 | void main(string[] argv) 13 | { 14 | version(EXTENDED) 15 | size_t nIter = 100; 16 | else 17 | size_t nIter = 20; 18 | if(argv.length > 2) 19 | nIter = to!size_t(argv[2]); 20 | 21 | version(EXTENDED) 22 | { 23 | Project[] prjs; 24 | } 25 | else 26 | { 27 | // create some random data as false pointer simulation 28 | version (RANDOMIZE) 29 | auto rnd = Random(unpredictableSeed); 30 | else 31 | auto rnd = Random(2929088778); 32 | 33 | ptrs = new FalsePointers; 34 | foreach(ref b; ptrs.data) 35 | b = cast(ubyte) uniform(0, 255, rnd); 36 | } 37 | 38 | Project prj = new Project; 39 | foreach(i; 0..nIter) 40 | { 41 | foreach(string name; dirEntries(buildPath("gcbench", "vdparser.extra"), "*.d", SpanMode.depth)) 42 | prj.addAndParseFile(name); 43 | 44 | version(EXTENDED) if (i & 1) 45 | { 46 | prjs ~= prj; 47 | prj = new Project; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /benchmark/gcbench/vdparser.extra/stdext/util.d: -------------------------------------------------------------------------------- 1 | // This file is part of Visual D 2 | // 3 | // Visual D integrates the D programming language into Visual Studio 4 | // Copyright (c) 2010-2011 by Rainer Schuetze, All Rights Reserved 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 8 | 9 | module stdext.util; 10 | 11 | //////////////////////////////////////////////////////////////// 12 | inout(T) static_cast(T, S = Object)(inout(S) p) 13 | { 14 | if(!p) 15 | return null; 16 | if(__ctfe) 17 | return cast(inout(T)) p; 18 | assert(cast(inout(T)) p); 19 | void* vp = cast(void*)p; 20 | return cast(inout(T)) vp; 21 | } 22 | 23 | //////////////////////////////////////////////////////////////// 24 | bool isIn(T...)(T values) 25 | { 26 | T[0] needle = values[0]; 27 | foreach(v; values[1..$]) 28 | if(v == needle) 29 | return true; 30 | return false; 31 | } 32 | -------------------------------------------------------------------------------- /benchmark/gcbench/vdparser.extra/vdc/ast/all.d: -------------------------------------------------------------------------------- 1 | // This file is part of Visual D 2 | // 3 | // Visual D integrates the D programming language into Visual Studio 4 | // Copyright (c) 2010-2011 by Rainer Schuetze, All Rights Reserved 5 | // 6 | // Distributed under the Boost Software License, Version 1.0. 7 | // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 8 | 9 | module vdc.ast.all; 10 | 11 | public import vdc.ast.aggr; 12 | public import vdc.ast.decl; 13 | public import vdc.ast.expr; 14 | public import vdc.ast.iasm; 15 | public import vdc.ast.misc; 16 | public import vdc.ast.mod; 17 | public import vdc.ast.node; 18 | public import vdc.ast.stmt; 19 | public import vdc.ast.tmpl; 20 | public import vdc.ast.type; 21 | public import vdc.ast.writer; 22 | -------------------------------------------------------------------------------- /benchmark/gcbench/words.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright: Copyright Rainer Schuetze 2014. 3 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 4 | * Authors: Rainer Schuetze 5 | * 6 | * This test reads a text file, duplicates it in memory the given number of times, 7 | * then splits the result into white space delimited words. The result is an array 8 | * of strings referencing the full text. 9 | * Regarding GC activity, this test probes concatenation of long strings and appending 10 | * to a large array of strings. 11 | */ 12 | import std.stdio; 13 | import std.conv; 14 | import std.file; 15 | import std.string; 16 | import std.exception; 17 | 18 | void main(string[] args) 19 | { 20 | string txt = cast(string)std.file.read(args.length > 1 ? args[1] : "extra-files/dante.txt"); 21 | uint cnt = args.length > 2 ? to!uint(args[2]) : 100; 22 | 23 | string data; 24 | for(int b = 31; b >= 0; b--) 25 | { 26 | data ~= data; 27 | if(cnt & (1 << b)) 28 | data ~= txt; 29 | } 30 | 31 | auto words = data.split().length; 32 | enforce(words == (args.length > 3 ? to!size_t(args[3]) : 9767600)); 33 | } 34 | -------------------------------------------------------------------------------- /changelog/drt-oncycle-deprecate.dd: -------------------------------------------------------------------------------- 1 | `--DRT-oncycle=deprecate` is removed 2 | 3 | The option was [introduced in 2.072.2](https://dlang.org/changelog/2.072.2.html#drt-cycle-deprecated) to help transition code that relied on the old faulty cycle checker for module constructors. 4 | It now prints a warning and does the same as the default, `--DRT-oncycle=abort`. 5 | See also: $(DDSUBLINK spec/module, order_of_static_ctor, Order of Static Construction) in the specification. 6 | -------------------------------------------------------------------------------- /changelog/posix_gc_signals.dd: -------------------------------------------------------------------------------- 1 | Posix (excl. Darwin): Switch default GC signals from SIGUSR1/2 to SIGRTMIN/SIGRTMIN+1 2 | 3 | As the SIGUSR ones might be used by 'system' libraries (e.g., Android 4 | Dalvik VM or LLVM libFuzzer), while the SIGRT ones are reserved for 5 | user-defined purposes and less likely to collide. 6 | 7 | The used signals can still be customized with an early call to 8 | `core.thread.osthread.thread_setGCSignals()`. 9 | -------------------------------------------------------------------------------- /def/version.def: -------------------------------------------------------------------------------- 1 | LIBRARY version 2 | EXETYPE NT 3 | SUBSYSTEM WINDOWS 4 | EXPORTS 5 | _GetFileVersionInfoA@16 = GetFileVersionInfoA 6 | _GetFileVersionInfoSizeA@8 = GetFileVersionInfoSizeA 7 | _GetFileVersionInfoSizeW@8 = GetFileVersionInfoSizeW 8 | _GetFileVersionInfoW@16 = GetFileVersionInfoW 9 | _VerFindFileA@32 = VerFindFileA 10 | _VerFindFileW@32 = VerFindFileW 11 | _VerInstallFileA@32 = VerInstallFileA 12 | _VerInstallFileW@32 = VerInstallFileW 13 | _VerLanguageNameA@12 = VerLanguageNameA 14 | _VerLanguageNameW@12 = VerLanguageNameW 15 | _VerQueryValueA@16 = VerQueryValueA 16 | _VerQueryValueW@16 = VerQueryValueW 17 | -------------------------------------------------------------------------------- /dub.sdl: -------------------------------------------------------------------------------- 1 | name "druntime" 2 | license "BSL-1.0" 3 | description "D Runtime Library" 4 | authors "DLang Community" 5 | copyright "Copyright © 1999-2018, The D Language Foundation" 6 | 7 | targetType "library" 8 | targetPath "generated" 9 | -------------------------------------------------------------------------------- /mak/WINDOWS: -------------------------------------------------------------------------------- 1 | $(mak\COPY) 2 | 3 | ######################## Header file copy ############################## 4 | 5 | import: copy 6 | 7 | copydir: $(IMPDIR) 8 | 9 | copy: generated\windows\copyimports.exe 10 | @~generated\windows\copyimports.exe $(COPY) 11 | 12 | generated\windows\copyimports.exe: mak\copyimports.d generated\windows\host_dmd.bat 13 | generated\windows\host_dmd.bat -of=$@ -m$(MODEL) mak\copyimports.d 14 | 15 | # find a host dmd on the different CI systems 16 | # - auto-tester: 2.079 installed, but not exposed to the druntime build 17 | # - appveyor: found through PATH 18 | # - azure-make: set as $(HOST_DC) 19 | # - azure-vs: $(DMD_DIR)\dmd2\Windows\bin\dmd.exe 20 | ATCLIENT_DMD = ../../release-build/dmd-2.079.0/windows/bin/dmd.exe 21 | 22 | generated\windows\host_dmd.bat: 23 | +if not exist generated md generated 24 | +if not exist generated\windows md generated\windows 25 | -+if exist "$(ATCLIENT_DMD)" (echo @"$(ATCLIENT_DMD)" %* >$@) 26 | -+if not "$(DMD_DIR)" == "" ("$(DMD_DIR)\dmd2\Windows\bin\dmd.exe" --version >nul 2>&1 && echo @"$(DMD_DIR)\dmd2\Windows\bin\dmd.exe" %* >$@) 27 | -+if not "$(HOST_DC)" == "" ("$(HOST_DC)" --version >nul 2>&1 && echo @"$(HOST_DC)" %* >$@) 28 | -+if not "$(HOST_DMD)" == "" ("$(HOST_DMD)" --version >nul 2>&1 && echo @"$(HOST_DMD)" %* >$@) 29 | -------------------------------------------------------------------------------- /project.ddoc: -------------------------------------------------------------------------------- 1 | PROJECT=druntime 2 | -------------------------------------------------------------------------------- /setmscver.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo _MSC_VER > ver.c 3 | cl /nologo /EP ver.c > ver_raw.txt 4 | findstr /v /r /c:"^$" "ver_raw.txt" > "ver.txt" 5 | set /P _MSC_VER=< ver.txt 6 | echo set _MSC_VER=%_MSC_VER% 7 | if exist cflags.txt del /q cflags.txt 8 | if exist dflags.txt del /q dflags.txt 9 | if exist add_tests.txt del /q add_tests.txt 10 | if %_MSC_VER% GTR 1900 echo /std:c++17 > cflags.txt 11 | if %_MSC_VER% GTR 1900 echo -extern-std=c++17 > dflags.txt 12 | if %_MSC_VER% GTR 1900 echo string_view > add_tests.txt 13 | del ver.c ver_raw.txt 14 | -------------------------------------------------------------------------------- /src/core/internal/attributes.d: -------------------------------------------------------------------------------- 1 | module core.internal.attributes; 2 | 3 | /** 4 | Used to annotate `unittest`s which need to be tested in a `-betterC` environment. 5 | 6 | Such `unittest`s will be compiled and executed without linking druntime in, with 7 | a `__traits(getUnitTests, mixin(__MODULE__))` style test runner. 8 | Note that just like any other `unittest` in druntime, they will also be compiled 9 | and executed without `-betterC`. 10 | */ 11 | package(core) enum betterC = 1; 12 | -------------------------------------------------------------------------------- /src/core/internal/backtrace/macho.d: -------------------------------------------------------------------------------- 1 | /** 2 | * This module extracts debug info from the currently running Mach-O executable. 3 | * 4 | * Copyright: Copyright Jacob Carlborg 2018. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Jacob Carlborg 7 | * Source: $(DRUNTIMESRC rt/backtrace/macho.d) 8 | */ 9 | module core.internal.backtrace.macho; 10 | 11 | version (OSX) 12 | version = Darwin; 13 | else version (iOS) 14 | version = Darwin; 15 | else version (TVOS) 16 | version = Darwin; 17 | else version (WatchOS) 18 | version = Darwin; 19 | 20 | version (Darwin): 21 | 22 | import core.stdc.config : c_ulong; 23 | import core.sys.darwin.crt_externs; 24 | import core.sys.darwin.mach.getsect; 25 | import core.sys.darwin.mach.loader; 26 | 27 | struct Image 28 | { 29 | private mach_header_64* self; 30 | 31 | static Image openSelf() 32 | { 33 | return Image(_NSGetMachExecuteHeader()); 34 | } 35 | 36 | @property bool isValid() 37 | { 38 | return self !is null; 39 | } 40 | 41 | T processDebugLineSectionData(T)(scope T delegate(const(ubyte)[]) processor) 42 | { 43 | c_ulong size; 44 | auto data = getsectiondata(self, "__DWARF", "__debug_line", &size); 45 | return processor(data[0 .. size]); 46 | } 47 | 48 | @property size_t baseAddress() 49 | { 50 | return 0; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/core/internal/destruction.d: -------------------------------------------------------------------------------- 1 | /** 2 | This module contains implementations for destroying instances of types 3 | 4 | Copyright: Copyright Digital Mars 2000 - 2019. 5 | License: Distributed under the 6 | $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 7 | (See accompanying file LICENSE) 8 | Source: $(DRUNTIMESRC core/_internal/_destruction.d) 9 | */ 10 | module core.internal.destruction; 11 | 12 | // compiler frontend lowers dynamic array deconstruction to this 13 | void __ArrayDtor(T)(scope T[] a) 14 | { 15 | foreach_reverse (ref T e; a) 16 | e.__xdtor(); 17 | } 18 | 19 | public void destructRecurse(E, size_t n)(ref E[n] arr) 20 | { 21 | import core.internal.traits : hasElaborateDestructor; 22 | 23 | static if (hasElaborateDestructor!E) 24 | { 25 | foreach_reverse (ref elem; arr) 26 | destructRecurse(elem); 27 | } 28 | } 29 | 30 | public void destructRecurse(S)(ref S s) 31 | if (is(S == struct)) 32 | { 33 | static if (__traits(hasMember, S, "__xdtor") && 34 | // Bugzilla 14746: Check that it's the exact member of S. 35 | __traits(isSame, S, __traits(parent, s.__xdtor))) 36 | s.__xdtor(); 37 | } 38 | 39 | // Test static struct 40 | nothrow @safe @nogc unittest 41 | { 42 | static int i = 0; 43 | static struct S { ~this() nothrow @safe @nogc { i = 42; } } 44 | S s; 45 | destructRecurse(s); 46 | assert(i == 42); 47 | } 48 | -------------------------------------------------------------------------------- /src/core/internal/util/math.d: -------------------------------------------------------------------------------- 1 | // Written in the D programming language 2 | 3 | /** 4 | * Internal math utilities. 5 | * 6 | * Copyright: The D Language Foundation 2021. 7 | * License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0). 8 | * Authors: Luís Ferreira 9 | * Source: $(DRUNTIMESRC core/internal/util/_math.d) 10 | */ 11 | module core.internal.util.math; 12 | 13 | /** 14 | * Calculates the maximum of the passed arguments 15 | * Params: 16 | * a = first value to select the maximum from 17 | * b = second value to select the maximum from 18 | * Returns: The maximum of the passed-in values. 19 | */ 20 | T max(T)(T a, T b) pure nothrow @nogc @safe 21 | { 22 | return b > a ? b : a; 23 | } 24 | 25 | /** 26 | * Calculates the minimum of the passed arguments 27 | * Params: 28 | * a = first value to select the minimum from 29 | * b = second value to select the minimum from 30 | * Returns: The minimum of the passed-in values. 31 | */ 32 | T min(T)(T a, T b) pure nothrow @nogc @safe 33 | { 34 | return b < a ? b : a; 35 | } 36 | 37 | /// 38 | @safe pure @nogc nothrow 39 | unittest 40 | { 41 | assert(max(1,3) == 3); 42 | assert(max(3,1) == 3); 43 | assert(max(1,1) == 1); 44 | } 45 | 46 | /// 47 | @safe pure @nogc nothrow 48 | unittest 49 | { 50 | assert(min(1,3) == 1); 51 | assert(min(3,1) == 1); 52 | assert(min(1,1) == 1); 53 | } 54 | -------------------------------------------------------------------------------- /src/core/stdc/ctype.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for C99. 3 | * 4 | * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_ctype.h.html, _ctype.h) 5 | * 6 | * Copyright: Copyright Sean Kelly 2005 - 2009. 7 | * License: Distributed under the 8 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 9 | * (See accompanying file LICENSE) 10 | * Authors: Sean Kelly 11 | * Source: $(DRUNTIMESRC core/stdc/_ctype.d) 12 | * Standards: ISO/IEC 9899:1999 (E) 13 | */ 14 | 15 | module core.stdc.ctype; 16 | 17 | extern (C): 18 | @trusted: // All of these operate on integers only. 19 | nothrow: 20 | @nogc: 21 | 22 | /// 23 | pure int isalnum(int c); 24 | /// 25 | pure int isalpha(int c); 26 | /// 27 | pure int isblank(int c); 28 | /// 29 | pure int iscntrl(int c); 30 | /// 31 | pure int isdigit(int c); 32 | /// 33 | pure int isgraph(int c); 34 | /// 35 | pure int islower(int c); 36 | /// 37 | pure int isprint(int c); 38 | /// 39 | pure int ispunct(int c); 40 | /// 41 | pure int isspace(int c); 42 | /// 43 | pure int isupper(int c); 44 | /// 45 | pure int isxdigit(int c); 46 | /// 47 | pure int tolower(int c); 48 | /// 49 | pure int toupper(int c); 50 | -------------------------------------------------------------------------------- /src/core/stdc/errno.c: -------------------------------------------------------------------------------- 1 | /** 2 | * This file contains wrapper functions for macro-defined C routines. 3 | * 4 | * Copyright: Copyright Sean Kelly 2005 - 2009. 5 | * License: Distributed under the 6 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 7 | * (See accompanying file LICENSE) 8 | * Authors: Sean Kelly 9 | * Source: $(DRUNTIMESRC core/stdc/errno.c) 10 | */ 11 | 12 | #include 13 | 14 | 15 | int getErrno() 16 | { 17 | return errno; 18 | } 19 | 20 | 21 | int setErrno( int val ) 22 | { 23 | errno = val; 24 | return val; 25 | } 26 | -------------------------------------------------------------------------------- /src/core/stdc/stddef.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for C99. 3 | * 4 | * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_stddef.h.html, _stddef.h) 5 | * 6 | * Copyright: Copyright Sean Kelly 2005 - 2009. 7 | * License: Distributed under the 8 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 9 | * (See accompanying file LICENSE) 10 | * Authors: Sean Kelly 11 | * Source: $(DRUNTIMESRC core/stdc/_stddef.d) 12 | * Standards: ISO/IEC 9899:1999 (E) 13 | */ 14 | 15 | module core.stdc.stddef; 16 | 17 | extern (C): 18 | @trusted: // Types only. 19 | nothrow: 20 | @nogc: 21 | 22 | /// 23 | alias nullptr_t = typeof(null); 24 | 25 | // size_t and ptrdiff_t are defined in the object module. 26 | 27 | version (Windows) 28 | { 29 | /// 30 | alias wchar wchar_t; 31 | } 32 | else version (Posix) 33 | { 34 | /// 35 | alias dchar wchar_t; 36 | } 37 | else version (WASI) 38 | { 39 | /// 40 | alias dchar wchar_t; 41 | } 42 | -------------------------------------------------------------------------------- /src/core/stdcpp/type_traits.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for interaction with C++ std::type_traits. 3 | * 4 | * Copyright: Copyright Digital Mars 2018. 5 | * License: Distributed under the 6 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 7 | * (See accompanying file LICENSE) 8 | * Authors: Manu Evans 9 | * Source: $(DRUNTIMESRC core/stdcpp/type_traits.d) 10 | */ 11 | 12 | module core.stdcpp.type_traits; 13 | 14 | extern(C++, "std"): 15 | 16 | /// 17 | struct integral_constant(T, T Val) 18 | { 19 | /// 20 | enum T value = Val; 21 | /// 22 | alias value_type = T; 23 | /// 24 | alias type = typeof(this); 25 | } 26 | 27 | /// 28 | alias bool_constant(bool b) = integral_constant!(bool, b); 29 | 30 | // Useful for dealing with enable_if constraints. 31 | /// 32 | alias true_type = bool_constant!true; 33 | /// 34 | alias false_type = bool_constant!false; 35 | 36 | /// 37 | struct is_empty(T) 38 | { 39 | static if (is(T == struct)) 40 | private enum __is_empty = T.tupleof.length == 0; 41 | else 42 | private enum __is_empty = false; 43 | 44 | /// 45 | enum bool value = __is_empty; 46 | /// 47 | alias value_type = bool; 48 | /// 49 | alias type = integral_constant!(bool, value); 50 | } 51 | -------------------------------------------------------------------------------- /src/core/stdcpp/utility.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for interaction with Microsoft C++ 3 | * 4 | * Copyright: Copyright (c) 2018 D Language Foundation 5 | * License: Distributed under the 6 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 7 | * (See accompanying file LICENSE) 8 | * Authors: Manu Evans 9 | * Source: $(DRUNTIMESRC core/stdcpp/utility.d) 10 | */ 11 | 12 | module core.stdcpp.utility; 13 | 14 | import core.stdcpp.xutility : StdNamespace; 15 | 16 | extern(C++, (StdNamespace)): 17 | @nogc: 18 | 19 | /** 20 | * D language counterpart to C++ std::pair. 21 | * 22 | * C++ reference: $(LINK2 https://en.cppreference.com/w/cpp/utility/pair) 23 | */ 24 | struct pair(T1, T2) 25 | { 26 | /// 27 | alias first_type = T1; 28 | /// 29 | alias second_type = T2; 30 | 31 | /// 32 | T1 first; 33 | /// 34 | T2 second; 35 | 36 | // FreeBSD has pair as non-POD so add a contructor 37 | version (FreeBSD) 38 | { 39 | this(T1 t1, T2 t2) inout 40 | { 41 | first = t1; 42 | second = t2; 43 | } 44 | this(ref return scope inout pair!(T1, T2) src) inout 45 | { 46 | first = src.first; 47 | second = src.second; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/core/sync/exception.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Define base class for synchronization exceptions. 3 | * 4 | * Copyright: Copyright Sean Kelly 2005 - 2009. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Sean Kelly 7 | * Source: $(DRUNTIMESRC core/sync/_exception.d) 8 | */ 9 | 10 | /* Copyright Sean Kelly 2005 - 2009. 11 | * Distributed under the Boost Software License, Version 1.0. 12 | * (See accompanying file LICENSE or copy at 13 | * http://www.boost.org/LICENSE_1_0.txt) 14 | */ 15 | module core.sync.exception; 16 | 17 | 18 | /** 19 | * Base class for synchronization errors. 20 | */ 21 | class SyncError : Error 22 | { 23 | @safe pure nothrow this(string msg, string file = __FILE__, size_t line = __LINE__, Throwable next = null) 24 | { 25 | super(msg, file, line, next); 26 | } 27 | 28 | @safe pure nothrow this(string msg, Throwable next, string file = __FILE__, size_t line = __LINE__) 29 | { 30 | super(msg, file, line, next); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/core/sync/package.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Provides thread synchronization tools such as mutexes, semaphores and barriers. 3 | * 4 | * License: Distributed under the 5 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 6 | * (See accompanying file LICENSE) 7 | * Authors: Sean Kelly, Rainer Schuetze 8 | * Source: $(DRUNTIMESRC core/sync/package.d) 9 | */ 10 | 11 | module core.sync; 12 | 13 | public import core.sync.barrier; 14 | public import core.sync.condition; 15 | public import core.sync.config; 16 | public import core.sync.event; 17 | public import core.sync.exception; 18 | public import core.sync.mutex; 19 | public import core.sync.rwmutex; 20 | public import core.sync.semaphore; 21 | -------------------------------------------------------------------------------- /src/core/sys/bionic/err.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Bionic err.h. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.bionic.err; 9 | import core.stdc.stdarg : va_list; 10 | 11 | version (CRuntime_Bionic): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | void err(int eval, scope const char* fmt, ...); 17 | void errx(int eval, scope const char* fmt, ...); 18 | void warn(scope const char* fmt, ...); 19 | void warnx(scope const char* fmt, ...); 20 | void verr(int eval, scope const char* fmt, va_list args); 21 | void verrx(int eval, scope const char* fmt, va_list args); 22 | void vwarn(scope const char* fmt, va_list args); 23 | void vwarnx(scope const char* fmt, va_list args); 24 | -------------------------------------------------------------------------------- /src/core/sys/bionic/fcntl.d: -------------------------------------------------------------------------------- 1 | module core.sys.bionic.fcntl; 2 | 3 | version (CRuntime_Bionic) extern(C) nothrow @nogc: 4 | 5 | enum LOCK_EX = 2; 6 | -------------------------------------------------------------------------------- /src/core/sys/bionic/stdlib.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Bionic stdlib.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Iain Buclaw 7 | */ 8 | module core.sys.bionic.stdlib; 9 | public import core.sys.posix.stdlib; 10 | 11 | version (CRuntime_Bionic): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | const(char)* getprogname(); 17 | void setprogname(scope const char* name); 18 | -------------------------------------------------------------------------------- /src/core/sys/bionic/string.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Bionic string. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.bionic.string; 9 | 10 | public import core.stdc.string; 11 | 12 | version (CRuntime_Bionic): 13 | extern (C): 14 | nothrow: 15 | @nogc: 16 | 17 | pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 18 | -------------------------------------------------------------------------------- /src/core/sys/bionic/unistd.d: -------------------------------------------------------------------------------- 1 | module core.sys.bionic.unistd; 2 | 3 | version (CRuntime_Bionic) extern(C) nothrow @nogc: 4 | 5 | int flock(int, int) @trusted; 6 | -------------------------------------------------------------------------------- /src/core/sys/darwin/dlfcn.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Darwin. 3 | * 4 | * $(LINK2 https://opensource.apple.com/source/dyld/dyld-360.22/include/dlfcn.h, Apple dyld/dlfcn.h) 5 | * 6 | * Copyright: Copyright David Nadlinger 2016. 7 | * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 8 | * Authors: David Nadlinger 9 | */ 10 | module core.sys.darwin.dlfcn; 11 | 12 | version (OSX) 13 | version = Darwin; 14 | else version (iOS) 15 | version = Darwin; 16 | else version (TVOS) 17 | version = Darwin; 18 | else version (WatchOS) 19 | version = Darwin; 20 | 21 | version (Darwin): 22 | extern(C): 23 | nothrow: 24 | @nogc: 25 | 26 | public import core.sys.posix.dlfcn; 27 | 28 | enum RTLD_NEXT = cast(void*) -1; 29 | enum RTLD_DEFAULT = cast(void*) -2; 30 | enum RTLD_SELF = cast(void*) -3; 31 | enum RTLD_MAIN_ONLY = cast(void*) -5; 32 | -------------------------------------------------------------------------------- /src/core/sys/darwin/err.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Darwin err.h. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.darwin.err; 9 | import core.stdc.stdarg : va_list; 10 | 11 | version (OSX) 12 | version = Darwin; 13 | else version (iOS) 14 | version = Darwin; 15 | else version (TVOS) 16 | version = Darwin; 17 | else version (WatchOS) 18 | version = Darwin; 19 | 20 | 21 | version (Darwin): 22 | extern (C): 23 | nothrow: 24 | @nogc: 25 | 26 | alias ExitFunction = void function(int); 27 | 28 | void err(int eval, scope const char* fmt, ...); 29 | void errc(int eval, int code, scope const char* fmt, ...); 30 | void errx(int eval, scope const char* fmt, ...); 31 | void warn(scope const char* fmt, ...); 32 | void warnc(int code, scope const char* fmt, ...); 33 | void warnx(scope const char* fmt, ...); 34 | void verr(int eval, scope const char* fmt, va_list args); 35 | void verrc(int eval, int code, scope const char* fmt, va_list args); 36 | void verrx(int eval, scope const char* fmt, va_list args); 37 | void vwarn(scope const char* fmt, va_list args); 38 | void vwarnc(int code, scope const char* fmt, va_list args); 39 | void vwarnx(scope const char* fmt, va_list args); 40 | void err_set_file(void* vfp); 41 | void err_set_exit(ExitFunction exitf); 42 | -------------------------------------------------------------------------------- /src/core/sys/darwin/execinfo.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Darwin. 3 | * 4 | * Copyright: Copyright Martin Nowak 2012. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | module core.sys.darwin.execinfo; 9 | 10 | version (OSX) 11 | version = Darwin; 12 | else version (iOS) 13 | version = Darwin; 14 | else version (TVOS) 15 | version = Darwin; 16 | else version (WatchOS) 17 | version = Darwin; 18 | 19 | version (Darwin): 20 | extern (C): 21 | nothrow: 22 | @nogc: 23 | 24 | int backtrace(void** buffer, int size); 25 | char** backtrace_symbols(const(void*)* buffer, int size); 26 | void backtrace_symbols_fd(const(void*)* buffer, int size, int fd); 27 | -------------------------------------------------------------------------------- /src/core/sys/darwin/fcntl.d: -------------------------------------------------------------------------------- 1 | module core.sys.darwin.fcntl; 2 | 3 | public import core.sys.posix.fcntl; 4 | 5 | version (OSX) 6 | version = Darwin; 7 | else version (iOS) 8 | version = Darwin; 9 | else version (TVOS) 10 | version = Darwin; 11 | else version (WatchOS) 12 | version = Darwin; 13 | 14 | version (Darwin): 15 | extern (C): 16 | nothrow: 17 | @nogc: 18 | @system: 19 | 20 | enum F_FULLFSYNC = 51; 21 | -------------------------------------------------------------------------------- /src/core/sys/darwin/mach/port.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Darwin. 3 | * 4 | * Copyright: Copyright Sean Kelly 2008 - 2009. 5 | * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 | * Authors: Sean Kelly 7 | */ 8 | 9 | /* Copyright Sean Kelly 2008 - 2009. 10 | * Distributed under the Boost Software License, Version 1.0. 11 | * (See accompanying file LICENSE or copy at 12 | * http://www.boost.org/LICENSE_1_0.txt) 13 | */ 14 | module core.sys.darwin.mach.port; 15 | 16 | version (OSX) 17 | version = Darwin; 18 | else version (iOS) 19 | version = Darwin; 20 | else version (TVOS) 21 | version = Darwin; 22 | else version (WatchOS) 23 | version = Darwin; 24 | 25 | version (Darwin): 26 | extern (C): 27 | 28 | alias natural_t = uint; 29 | alias mach_port_t = natural_t; 30 | -------------------------------------------------------------------------------- /src/core/sys/darwin/stdlib.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Darwin stdlib.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Iain Buclaw 7 | */ 8 | module core.sys.darwin.stdlib; 9 | public import core.sys.posix.stdlib; 10 | 11 | version (OSX) 12 | version = Darwin; 13 | else version (iOS) 14 | version = Darwin; 15 | else version (TVOS) 16 | version = Darwin; 17 | else version (WatchOS) 18 | version = Darwin; 19 | 20 | version (Darwin): 21 | extern (C): 22 | nothrow: 23 | @nogc: 24 | 25 | const(char)* getprogname(); 26 | void setprogname(scope const char* name); 27 | -------------------------------------------------------------------------------- /src/core/sys/darwin/string.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Darwin string. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.darwin.string; 9 | 10 | public import core.stdc.string; 11 | import core.sys.darwin.sys.cdefs; 12 | 13 | version (OSX) 14 | version = Darwin; 15 | else version (iOS) 16 | version = Darwin; 17 | else version (TVOS) 18 | version = Darwin; 19 | else version (WatchOS) 20 | version = Darwin; 21 | 22 | version (Darwin): 23 | extern (C): 24 | nothrow: 25 | @nogc: 26 | 27 | static if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) 28 | { 29 | // ^ __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); 30 | pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 31 | } 32 | -------------------------------------------------------------------------------- /src/core/sys/darwin/sys/cdefs.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Darwin 3 | * 4 | * Authors: Martin Nowak 5 | */ 6 | module core.sys.darwin.sys.cdefs; 7 | 8 | version (OSX) 9 | version = Darwin; 10 | else version (iOS) 11 | version = Darwin; 12 | else version (TVOS) 13 | version = Darwin; 14 | else version (WatchOS) 15 | version = Darwin; 16 | 17 | version (Darwin): 18 | 19 | public import core.sys.posix.config; 20 | 21 | // http://www.opensource.apple.com/source/xnu/xnu-2422.115.4/bsd/sys/cdefs.h 22 | enum _DARWIN_C_SOURCE = true; 23 | 24 | enum __DARWIN_C_FULL = 900_000L; 25 | enum __DARWIN_C_LEVEL = __DARWIN_C_FULL; 26 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/err.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD err.h. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.dragonflybsd.err; 9 | import core.stdc.stdarg : va_list; 10 | 11 | version (DragonFlyBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | alias ExitFunction = void function(int); 17 | 18 | void err(int eval, scope const char* fmt, ...); 19 | void errc(int eval, int code, scope const char* fmt, ...); 20 | void errx(int eval, scope const char* fmt, ...); 21 | void warn(scope const char* fmt, ...); 22 | void warnc(int code, scope const char* fmt, ...); 23 | void warnx(scope const char* fmt, ...); 24 | void verr(int eval, scope const char* fmt, va_list args); 25 | void verrc(int eval, int code, scope const char* fmt, va_list args); 26 | void verrx(int eval, scope const char* fmt, va_list args); 27 | void vwarn(scope const char* fmt, va_list args); 28 | void vwarnc(int code, scope const char* fmt, va_list args); 29 | void vwarnx(scope const char* fmt, va_list args); 30 | void err_set_file(void* vfp); 31 | void err_set_exit(ExitFunction exitf); 32 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/stdlib.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD stdlib.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Iain Buclaw 7 | */ 8 | module core.sys.dragonflybsd.stdlib; 9 | public import core.sys.posix.stdlib; 10 | 11 | version (DragonFlyBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | const(char)* getprogname(); 17 | void setprogname(scope const char* name); 18 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/string.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD string. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.dragonflybsd.string; 9 | 10 | public import core.stdc.string; 11 | import core.sys.dragonflybsd.sys.cdefs; 12 | 13 | version (DragonFlyBSD): 14 | extern (C): 15 | nothrow: 16 | @nogc: 17 | 18 | static if (__BSD_VISIBLE) 19 | { 20 | pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/sys/_bitset.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD. 3 | * 4 | * Authors: Martin Nowak, Diederik de Groot(port:DragonFlyBSD) 5 | * Copied: From core/sys/freebsd/sys 6 | */ 7 | module core.sys.dragonflybsd.sys._bitset; 8 | 9 | version (DragonFlyBSD): 10 | extern (C) pure nothrow @nogc @system: 11 | 12 | import core.stdc.config : c_long; 13 | 14 | enum NBBY = 8; // number of bits per byte 15 | 16 | enum _BITSET_BITS = c_long.sizeof * NBBY; 17 | 18 | enum __bitset_words(size_t s) = (s + _BITSET_BITS - 1) / _BITSET_BITS; 19 | 20 | c_long __bitset_mask(size_t s)(size_t n) 21 | { 22 | static if (__bitset_words!s == 1) 23 | return (cast(c_long)1) << n; 24 | else 25 | return (cast(c_long)1) << n % _BITSET_BITS; 26 | } 27 | 28 | size_t __bitset_word(size_t s)(size_t n) 29 | { 30 | static if (__bitset_words!s == 1) 31 | return 0; 32 | else 33 | return n / _BITSET_BITS; 34 | } 35 | 36 | struct BITSET_DEFINE(size_t s) 37 | { 38 | c_long[__bitset_words!s] __bits; 39 | } 40 | 41 | // no idea how to translate those 42 | //#define BITSET_T_INITIALIZER(x) \ 43 | // { .__bits = { x } } 44 | // 45 | //#define BITSET_FSET(n) \ 46 | // [ 0 ... ((n) - 1) ] = (-1L) 47 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/sys/_cpuset.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD. 3 | * 4 | * Authors: Martin Nowak, Diederik de Groot(port:DragonFlyBSD) 5 | * Copied: From core/sys/freebsd/sys 6 | */ 7 | module core.sys.dragonflybsd.sys._cpuset; 8 | 9 | version (DragonFlyBSD): 10 | 11 | public import core.sys.dragonflybsd.sys._bitset; 12 | 13 | static if (is(typeof(_KERNEL))) 14 | alias CPU_SETSIZE = MAXCPU; 15 | 16 | enum CPU_MAXSIZE = 256; 17 | 18 | static if (!is(typeof(CPU_SETSIZE))) 19 | alias CPU_SETSIZE = CPU_MAXSIZE; 20 | 21 | enum _NCPUBITS = _BITSET_BITS; 22 | enum _NCPUWORDS = __bitset_words!CPU_SETSIZE; 23 | 24 | alias _cpuset = BITSET_DEFINE!(CPU_SETSIZE); 25 | alias cpuset_t = _cpuset; 26 | 27 | // no idea how to translate those 28 | //#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) 29 | //#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER 30 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/sys/cdefs.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD 3 | * 4 | * Authors: Martin Nowak,Diederik de Groot(port:DragonFlyBSD) 5 | * Copied: From core/sys/freebsd/sys 6 | */ 7 | module core.sys.dragonflybsd.sys.cdefs; 8 | 9 | version (DragonFlyBSD): 10 | 11 | public import core.sys.posix.config; 12 | 13 | enum __POSIX_VISIBLE = 200112; 14 | enum __XSI_VISIBLE = 700; 15 | enum __BSD_VISIBLE = true; 16 | enum __ISO_C_VISIBLE = 1999; 17 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/sys/elf.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD. 3 | * 4 | * Authors: Diederik de Groot(port:DragonFlyBSD) 5 | * Copied: From core/sys/freebsd/sys 6 | */ 7 | module core.sys.dragonflybsd.sys.elf; 8 | 9 | version (DragonFlyBSD): 10 | 11 | public import core.sys.dragonflybsd.sys.elf32; 12 | public import core.sys.dragonflybsd.sys.elf64; 13 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/sys/elf32.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD. 3 | * 4 | * Authors: Diederik de Groot(port:DragonFlyBSD) 5 | * Copied: From core/sys/freebsd/sys 6 | */ 7 | module core.sys.dragonflybsd.sys.elf32; 8 | 9 | version (DragonFlyBSD): 10 | 11 | extern (C): 12 | 13 | import core.stdc.stdint; 14 | public import core.sys.dragonflybsd.sys.elf_common; 15 | 16 | alias uint64_t Elf32_Lword; 17 | alias Elf32_Word Elf32_Hashelt; 18 | alias Elf32_Word Elf32_Size; 19 | alias Elf32_Sword Elf32_Ssize; 20 | 21 | struct Elf32_Dyn 22 | { 23 | Elf32_Sword d_tag; 24 | union _d_un 25 | { 26 | Elf32_Word d_val; 27 | Elf32_Addr d_ptr; 28 | } _d_un d_un; 29 | } 30 | 31 | alias Elf_Note Elf32_Nhdr; 32 | 33 | struct Elf32_Cap 34 | { 35 | Elf32_Word c_tag; 36 | union _c_un 37 | { 38 | Elf32_Word c_val; 39 | Elf32_Addr c_ptr; 40 | } _c_un c_un; 41 | } 42 | 43 | extern (D) 44 | { 45 | auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } 46 | } 47 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/sys/elf64.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for DragonFlyBSD. 3 | * 4 | * Authors: Diederik de Groot(port:DragonFlyBSD) 5 | * Copied: From core/sys/freebsd/sys 6 | */ 7 | module core.sys.dragonflybsd.sys.elf64; 8 | 9 | version (DragonFlyBSD): 10 | 11 | extern (C): 12 | 13 | import core.stdc.stdint; 14 | public import core.sys.dragonflybsd.sys.elf_common; 15 | 16 | alias uint64_t Elf64_Lword; 17 | alias Elf64_Word Elf64_Hashelt; 18 | alias Elf64_Xword Elf64_Size; 19 | alias Elf64_Sxword Elf64_Ssize; 20 | 21 | struct Elf64_Dyn 22 | { 23 | Elf64_Sxword d_tag; 24 | union _d_un 25 | { 26 | Elf64_Xword d_val; 27 | Elf64_Addr d_ptr; 28 | } _d_un d_un; 29 | } 30 | 31 | extern (D) pure 32 | { 33 | auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; } 34 | auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; } 35 | auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } 36 | } 37 | 38 | alias Elf_Note Elf64_Nhdr; 39 | 40 | struct Elf64_Cap 41 | { 42 | Elf64_Xword c_tag; 43 | union _c_un 44 | { 45 | Elf64_Xword c_val; 46 | Elf64_Addr c_ptr; 47 | } _c_un c_un; 48 | } 49 | 50 | extern (D) 51 | { 52 | auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; } 53 | } 54 | -------------------------------------------------------------------------------- /src/core/sys/dragonflybsd/time.d: -------------------------------------------------------------------------------- 1 | /** 2 | D header file for DragonFlyBSD's extensions to POSIX's time.h. 3 | 4 | Copyright: Copyright 2014 5 | License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 | Authors: $(HTTP jmdavisprog.com, Jonathan M Davis) and Diederik de Groot 7 | */ 8 | module core.sys.dragonflybsd.time; 9 | 10 | version (DragonFlyBSD): 11 | 12 | public import core.sys.posix.time; 13 | 14 | import core.sys.dragonflybsd.sys.cdefs; 15 | 16 | enum CLOCK_REALTIME = 0; 17 | enum CLOCK_VIRTUAL = 1; 18 | enum CLOCK_PROF = 2; 19 | enum CLOCK_MONOTONIC = 4; 20 | enum CLOCK_UPTIME = 5; 21 | enum CLOCK_UPTIME_PRECISE = 7; 22 | enum CLOCK_UPTIME_FAST = 8; 23 | enum CLOCK_REALTIME_PRECISE = 9; 24 | enum CLOCK_REALTIME_FAST = 10; 25 | enum CLOCK_MONOTONIC_PRECISE = 11; 26 | enum CLOCK_MONOTONIC_FAST = 12; 27 | enum CLOCK_SECOND = 13; 28 | enum CLOCK_THREAD_CPUTIME_ID = 14; 29 | enum CLOCK_PROCESS_CPUTIME_ID= 15; 30 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/config.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD 3 | * 4 | * Authors: Iain Buclaw 5 | */ 6 | module core.sys.freebsd.config; 7 | 8 | version (FreeBSD): 9 | 10 | public import core.sys.posix.config; 11 | 12 | // https://svnweb.freebsd.org/base/head/sys/sys/param.h?view=markup 13 | // __FreeBSD_version numbers are documented in the Porter's Handbook. 14 | // NOTE: When adding newer versions of FreeBSD, verify all current versioned 15 | // bindings are still compatible with the release. 16 | 17 | version (FreeBSD_13) enum __FreeBSD_version = 1300000; 18 | else version (FreeBSD_12) enum __FreeBSD_version = 1202000; 19 | else version (FreeBSD_11) enum __FreeBSD_version = 1104000; 20 | else version (FreeBSD_10) enum __FreeBSD_version = 1004000; 21 | else version (FreeBSD_9) enum __FreeBSD_version = 903000; 22 | else version (FreeBSD_8) enum __FreeBSD_version = 804000; 23 | else static assert(false, "Unsupported version of FreeBSD"); 24 | 25 | // First version of FreeBSD to support 64-bit stat buffer. 26 | enum INO64_FIRST = 1200031; 27 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/err.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD err.h. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.freebsd.err; 9 | import core.stdc.stdarg : va_list; 10 | 11 | version (FreeBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | alias ExitFunction = void function(int); 17 | 18 | void err(int eval, scope const char* fmt, ...); 19 | void errc(int eval, int code, scope const char* fmt, ...); 20 | void errx(int eval, scope const char* fmt, ...); 21 | void warn(scope const char* fmt, ...); 22 | void warnc(int code, scope const char* fmt, ...); 23 | void warnx(scope const char* fmt, ...); 24 | void verr(int eval, scope const char* fmt, va_list args); 25 | void verrc(int eval, int code, scope const char* fmt, va_list args); 26 | void verrx(int eval, scope const char* fmt, va_list args); 27 | void vwarn(scope const char* fmt, va_list args); 28 | void vwarnc(int code, scope const char* fmt, va_list args); 29 | void vwarnx(scope const char* fmt, va_list args); 30 | void err_set_file(void* vfp); 31 | void err_set_exit(ExitFunction exitf); 32 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/stdlib.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD stdlib.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Iain Buclaw 7 | */ 8 | module core.sys.freebsd.stdlib; 9 | public import core.sys.posix.stdlib; 10 | 11 | version (FreeBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | const(char)* getprogname(); 17 | void setprogname(scope const char* name); 18 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/string.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD string. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.freebsd.string; 9 | 10 | public import core.stdc.string; 11 | import core.sys.freebsd.sys.cdefs; 12 | 13 | version (FreeBSD): 14 | extern (C): 15 | nothrow: 16 | @nogc: 17 | 18 | static if (__BSD_VISIBLE) 19 | { 20 | pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 21 | } 22 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/sys/_bitset.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD. 3 | * 4 | * Authors: Martin Nowak 5 | */ 6 | module core.sys.freebsd.sys._bitset; 7 | 8 | version (FreeBSD): 9 | extern (C) pure nothrow @nogc: 10 | 11 | import core.stdc.config : c_long; 12 | 13 | enum NBBY = 8; // number of bits per byte 14 | 15 | enum _BITSET_BITS = c_long.sizeof * NBBY; 16 | 17 | enum __bitset_words(size_t s) = (s + _BITSET_BITS - 1) / _BITSET_BITS; 18 | 19 | c_long __bitset_mask(size_t s)(size_t n) 20 | { 21 | static if (__bitset_words!s == 1) 22 | return (cast(c_long)1) << n; 23 | else 24 | return (cast(c_long)1) << n % _BITSET_BITS; 25 | } 26 | 27 | size_t __bitset_word(size_t s)(size_t n) 28 | { 29 | static if (__bitset_words!s == 1) 30 | return 0; 31 | else 32 | return n / _BITSET_BITS; 33 | } 34 | 35 | struct BITSET_DEFINE(size_t s) 36 | { 37 | c_long[__bitset_words!s] __bits; 38 | } 39 | 40 | // no idea how to translate those 41 | //#define BITSET_T_INITIALIZER(x) \ 42 | // { .__bits = { x } } 43 | // 44 | //#define BITSET_FSET(n) \ 45 | // [ 0 ... ((n) - 1) ] = (-1L) 46 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/sys/_cpuset.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD. 3 | * 4 | * Authors: Martin Nowak 5 | */ 6 | module core.sys.freebsd.sys._cpuset; 7 | 8 | version (FreeBSD): 9 | extern (C) pure nothrow @nogc: 10 | 11 | public import core.sys.freebsd.sys._bitset; 12 | 13 | static if (is(typeof(_KERNEL))) 14 | alias CPU_SETSIZE = MAXCPU; 15 | 16 | enum CPU_MAXSIZE = 256; 17 | 18 | static if (!is(typeof(CPU_SETSIZE))) 19 | alias CPU_SETSIZE = CPU_MAXSIZE; 20 | 21 | enum _NCPUBITS = _BITSET_BITS; 22 | enum _NCPUWORDS = __bitset_words!CPU_SETSIZE; 23 | 24 | alias _cpuset = BITSET_DEFINE!(CPU_SETSIZE); 25 | alias cpuset_t = _cpuset; 26 | 27 | // no idea how to translate those 28 | //#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) 29 | //#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER 30 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/sys/cdefs.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD 3 | * 4 | * Authors: Martin Nowak 5 | */ 6 | module core.sys.freebsd.sys.cdefs; 7 | 8 | version (FreeBSD): 9 | 10 | public import core.sys.posix.config; 11 | 12 | // https://svnweb.freebsd.org/base/head/sys/sys/cdefs.h?revision=271155&view=markup 13 | enum __POSIX_VISIBLE = 200112; 14 | enum __XSI_VISIBLE = 700; 15 | enum __BSD_VISIBLE = true; 16 | enum __ISO_C_VISIBLE = 1999; 17 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/sys/elf.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD. 3 | * 4 | * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf.h?view=markup, sys/elf.h) 5 | */ 6 | module core.sys.freebsd.sys.elf; 7 | 8 | version (FreeBSD): 9 | 10 | public import core.sys.freebsd.sys.elf32; 11 | public import core.sys.freebsd.sys.elf64; 12 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/sys/elf32.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD. 3 | * 4 | * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf32.h?view=markup, sys/elf32.h) 5 | */ 6 | module core.sys.freebsd.sys.elf32; 7 | 8 | version (FreeBSD): 9 | extern (C): 10 | pure: 11 | nothrow: 12 | 13 | import core.stdc.stdint; 14 | public import core.sys.freebsd.sys.elf_common; 15 | 16 | alias uint64_t Elf32_Lword; 17 | alias Elf32_Word Elf32_Hashelt; 18 | alias Elf32_Word Elf32_Size; 19 | alias Elf32_Sword Elf32_Ssize; 20 | 21 | struct Elf32_Dyn 22 | { 23 | Elf32_Sword d_tag; 24 | union _d_un 25 | { 26 | Elf32_Word d_val; 27 | Elf32_Addr d_ptr; 28 | } _d_un d_un; 29 | } 30 | 31 | alias Elf_Note Elf32_Nhdr; 32 | 33 | struct Elf32_Cap 34 | { 35 | Elf32_Word c_tag; 36 | union _c_un 37 | { 38 | Elf32_Word c_val; 39 | Elf32_Addr c_ptr; 40 | } _c_un c_un; 41 | } 42 | 43 | extern (D) 44 | { 45 | auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } 46 | } 47 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/sys/elf64.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for FreeBSD. 3 | * 4 | * $(LINK2 http://svnweb.freebsd.org/base/head/sys/sys/elf64.h?view=markup, sys/elf64.h) 5 | */ 6 | module core.sys.freebsd.sys.elf64; 7 | 8 | version (FreeBSD): 9 | extern (C): 10 | pure: 11 | nothrow: 12 | 13 | import core.stdc.stdint; 14 | public import core.sys.freebsd.sys.elf_common; 15 | 16 | alias uint64_t Elf64_Lword; 17 | alias Elf64_Word Elf64_Hashelt; 18 | alias Elf64_Xword Elf64_Size; 19 | alias Elf64_Sxword Elf64_Ssize; 20 | 21 | struct Elf64_Dyn 22 | { 23 | Elf64_Sxword d_tag; 24 | union _d_un 25 | { 26 | Elf64_Xword d_val; 27 | Elf64_Addr d_ptr; 28 | } _d_un d_un; 29 | } 30 | 31 | extern (D) 32 | { 33 | auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; } 34 | auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; } 35 | auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } 36 | } 37 | 38 | alias Elf_Note Elf64_Nhdr; 39 | 40 | struct Elf64_Cap 41 | { 42 | Elf64_Xword c_tag; 43 | union _c_un 44 | { 45 | Elf64_Xword c_val; 46 | Elf64_Addr c_ptr; 47 | } _c_un c_un; 48 | } 49 | 50 | extern (D) 51 | { 52 | auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; } 53 | } 54 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/time.d: -------------------------------------------------------------------------------- 1 | //Written in the D programming language 2 | 3 | /++ 4 | D header file for FreeBSD's extensions to POSIX's time.h. 5 | 6 | Copyright: Copyright 2014 7 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 8 | Authors: $(HTTP jmdavisprog.com, Jonathan M Davis) 9 | +/ 10 | module core.sys.freebsd.time; 11 | 12 | public import core.sys.posix.time; 13 | 14 | version (FreeBSD): 15 | 16 | enum CLOCK_VIRTUAL = 1; 17 | enum CLOCK_PROF = 2; 18 | enum CLOCK_UPTIME = 5; 19 | enum CLOCK_UPTIME_PRECISE = 7; 20 | enum CLOCK_UPTIME_FAST = 8; 21 | enum CLOCK_REALTIME_PRECISE = 9; 22 | enum CLOCK_REALTIME_FAST = 10; 23 | enum CLOCK_MONOTONIC_PRECISE = 11; 24 | enum CLOCK_MONOTONIC_FAST = 12; 25 | enum CLOCK_SECOND = 13; 26 | -------------------------------------------------------------------------------- /src/core/sys/freebsd/unistd.d: -------------------------------------------------------------------------------- 1 | //Written in the D programming language 2 | 3 | /++ 4 | D header file for FreeBSD's extensions to POSIX's unistd.h. 5 | 6 | Copyright: Copyright 2018 7 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 8 | Authors: $(HTTP jmdavisprog.com, Jonathan M Davis) 9 | +/ 10 | module core.sys.freebsd.unistd; 11 | 12 | public import core.sys.posix.unistd; 13 | 14 | version (FreeBSD): 15 | extern(C): 16 | @nogc: 17 | nothrow: 18 | 19 | int getosreldate() pure @trusted; 20 | -------------------------------------------------------------------------------- /src/core/sys/linux/config.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for GNU/Linux 3 | * 4 | * Authors: Martin Nowak 5 | */ 6 | module core.sys.linux.config; 7 | 8 | version (linux): 9 | 10 | public import core.sys.posix.config; 11 | 12 | // man 7 feature_test_macros 13 | // http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html 14 | enum _GNU_SOURCE = true; 15 | // deduced 16 | // http://sourceware.org/git/?p=glibc.git;a=blob;f=include/features.h 17 | enum _DEFAULT_SOURCE = true; 18 | enum _ATFILE_SOURCE = true; 19 | 20 | // _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for _DEFAULT_SOURCE. 21 | deprecated("use _DEFAULT_SOURCE") 22 | { 23 | enum _BSD_SOURCE = true; 24 | enum _SVID_SOURCE = true; 25 | } 26 | 27 | deprecated("use _DEFAULT_SOURCE") 28 | enum __USE_MISC = _DEFAULT_SOURCE; 29 | deprecated("use _ATFILE_SOURCE") 30 | enum __USE_ATFILE = _ATFILE_SOURCE; 31 | deprecated("use _GNU_SOURCE") 32 | enum __USE_GNU = _GNU_SOURCE; 33 | -------------------------------------------------------------------------------- /src/core/sys/linux/err.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Linux err.h. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.linux.err; 9 | import core.stdc.stdarg : va_list; 10 | 11 | version (linux): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | @system: 16 | 17 | void err(int eval, scope const char* fmt, ...); 18 | void errx(int eval, scope const char* fmt, ...); 19 | void warn(scope const char* fmt, ...); 20 | void warnx(scope const char* fmt, ...); 21 | void verr(int eval, scope const char* fmt, va_list args); 22 | void verrx(int eval, scope const char* fmt, va_list args); 23 | void vwarn(scope const char* fmt, va_list args); 24 | void vwarnx(scope const char* fmt, va_list args); 25 | -------------------------------------------------------------------------------- /src/core/sys/linux/errno.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for GNU/Linux 3 | * 4 | * $(LINK2 http://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/errno.h, glibc stdlib/errno.h) 5 | */ 6 | module core.sys.linux.errno; 7 | 8 | version (linux): 9 | extern (C): 10 | nothrow: 11 | @system: 12 | 13 | public import core.stdc.errno; 14 | import core.sys.linux.config; 15 | 16 | static if (_GNU_SOURCE) 17 | { 18 | extern __gshared char* program_invocation_name, program_invocation_short_name; 19 | alias error_t = int; 20 | } 21 | -------------------------------------------------------------------------------- /src/core/sys/linux/execinfo.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for GNU/Linux. 3 | * 4 | * Copyright: Copyright Martin Nowak 2012. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | module core.sys.linux.execinfo; 9 | 10 | version (linux): 11 | extern (C): 12 | nothrow: 13 | @system: 14 | @nogc: 15 | 16 | int backtrace(void** buffer, int size); 17 | char** backtrace_symbols(const(void*)* buffer, int size); 18 | void backtrace_symbols_fd(const(void*)* buffer, int size, int fd); 19 | -------------------------------------------------------------------------------- /src/core/sys/linux/string.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Linux string. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.linux.string; 9 | 10 | public import core.stdc.string; 11 | import core.sys.linux.config; 12 | 13 | version (linux): 14 | extern (C): 15 | nothrow: 16 | @nogc: 17 | @system: 18 | 19 | static if (_GNU_SOURCE) 20 | { 21 | pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 22 | } 23 | -------------------------------------------------------------------------------- /src/core/sys/linux/sys/file.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Linux file ops. 3 | * 4 | * Copyright: Copyright Nemanja Boric 2016. 5 | * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 | * Authors: Nemanja Boric 7 | */ 8 | module core.sys.linux.sys.file; 9 | 10 | version (linux): 11 | extern (C): 12 | nothrow: 13 | @nogc: 14 | 15 | /* Operations for the `flock' call. */ 16 | /// Shared lock 17 | enum LOCK_SH = 0x01; 18 | /// Exclusive lock 19 | enum LOCK_EX = 0x02; 20 | /// Unlock 21 | enum LOCK_UN = 0x08; 22 | 23 | /// Don't block when locking. 24 | /// Can be OR'd into one of the above. 25 | enum LOCK_NB = 0x04; 26 | 27 | /// Apply or remove an advisory lock on an open file 28 | /// Params: 29 | /// fd = file to apply or remove lock from 30 | /// operation = lock operation to perform 31 | /// Returns: 32 | /// 0 on success, -1 on failure, with .errno 33 | /// set appropriately. 34 | int flock(int fd, int operation) @trusted; 35 | -------------------------------------------------------------------------------- /src/core/sys/linux/sys/procfs.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for GNU/Linux. 3 | * 4 | * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 5 | * Authors: Teodor Dutu 6 | */ 7 | 8 | module core.sys.linux.sys.procfs; 9 | 10 | import core.sys.posix.sys.types : pid_t; 11 | 12 | version (linux) 13 | { 14 | alias lwpid_t = pid_t; 15 | } 16 | -------------------------------------------------------------------------------- /src/core/sys/linux/sys/signalfd.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Linux. 3 | * 4 | * Copyright: Copyright Alex Rønne Petersen 2012. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Alex Rønne Petersen 7 | */ 8 | module core.sys.linux.sys.signalfd; 9 | 10 | import core.sys.posix.signal; 11 | 12 | version (linux): 13 | 14 | extern (C): 15 | @system: 16 | nothrow: 17 | @nogc: 18 | 19 | struct signalfd_siginfo 20 | { 21 | uint ssi_signo; 22 | int ssi_errno; 23 | int ssi_code; 24 | uint ssi_pid; 25 | uint ssi_uid; 26 | int ssi_fd; 27 | uint ssi_tid; 28 | uint ssi_band; 29 | uint ssi_overrun; 30 | uint ssi_trapno; 31 | int ssi_status; 32 | int ssi_int; 33 | ulong ssi_ptr; 34 | ulong ssi_utime; 35 | ulong ssi_stime; 36 | ulong ssi_addr; 37 | ubyte[48] __pad; 38 | } 39 | 40 | enum SFD_CLOEXEC = 0x80000; // 02000000 41 | enum SFD_NONBLOCK = 0x800; // 04000 42 | 43 | int signalfd (int __fd, const(sigset_t)* __mask, int __flags); 44 | -------------------------------------------------------------------------------- /src/core/sys/linux/sys/sysinfo.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for GNU/Linux. 3 | * 4 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 5 | * Authors: Martin Nowak 6 | */ 7 | module core.sys.linux.sys.sysinfo; 8 | 9 | version (linux) extern(C) @nogc nothrow: 10 | @system: 11 | 12 | import core.sys.linux.config; 13 | 14 | // linux/sysinfo.h 15 | enum SI_LOAD_SHIFT = 16; 16 | 17 | struct sysinfo_ 18 | { 19 | c_long uptime; /* Seconds since boot */ 20 | c_ulong[3] loads; /* 1, 5, and 15 minute load averages */ 21 | c_ulong totalram; /* Total usable main memory size */ 22 | c_ulong freeram; /* Available memory size */ 23 | c_ulong sharedram; /* Amount of shared memory */ 24 | c_ulong bufferram; /* Memory used by buffers */ 25 | c_ulong totalswap; /* Total swap space size */ 26 | c_ulong freeswap; /* swap space still available */ 27 | ushort procs; /* Number of current processes */ 28 | ushort pad; /* Explicit padding for m68k */ 29 | c_ulong totalhigh; /* Total high memory size */ 30 | c_ulong freehigh; /* Available high memory size */ 31 | uint mem_unit; /* Memory unit size in bytes */ 32 | ubyte[20-2 * c_ulong.sizeof - uint.sizeof] _f; /* Padding: libc5 uses this.. */ 33 | } 34 | 35 | 36 | int sysinfo(sysinfo_ *info); 37 | int get_nprocs_conf(); 38 | int get_nprocs(); 39 | c_long get_phys_pages(); 40 | c_long get_avphys_pages(); 41 | -------------------------------------------------------------------------------- /src/core/sys/linux/termios.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for GNU/Linux 3 | */ 4 | /* Distributed under the Boost Software License, Version 1.0. 5 | * (See accompanying file LICENSE or copy at 6 | * http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | module core.sys.linux.termios; 10 | 11 | version (linux): 12 | public import core.sys.posix.termios; 13 | 14 | enum B57600 = 0x1001; // 0010001 15 | enum B115200 = 0x1002; // 0010002 16 | enum B230400 = 0x1003; // 0010003 17 | enum B460800 = 0x1004; // 0010004 18 | enum B500000 = 0x1005; // 0010005 19 | enum B576000 = 0x1006; // 0010006 20 | enum B921600 = 0x1007; // 0010007 21 | enum B1000000 = 0x1008; // 0010010 22 | enum B1152000 = 0x1009; // 0010011 23 | enum B1500000 = 0x100A; // 0010012 24 | enum B2000000 = 0x100B; // 0010013 25 | enum B2500000 = 0x100C; // 0010014 26 | enum B3000000 = 0x100D; // 0010015 27 | enum B3500000 = 0x100E; // 0010016 28 | enum B4000000 = 0x100F; // 0010017 29 | 30 | enum CRTSCTS = 0x80000000; // 020000000000 31 | -------------------------------------------------------------------------------- /src/core/sys/linux/time.d: -------------------------------------------------------------------------------- 1 | //Written in the D programming language 2 | 3 | /++ 4 | D header file for Linux extensions to POSIX's time.h. 5 | 6 | Copyright: Copyright 2014 7 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 8 | Authors: $(HTTP jmdavisprog.com, Jonathan M Davis) 9 | +/ 10 | module core.sys.linux.time; 11 | 12 | public import core.sys.posix.time; 13 | 14 | version (linux): 15 | 16 | enum CLOCK_MONOTONIC_RAW = 4; 17 | enum CLOCK_REALTIME_COARSE = 5; 18 | enum CLOCK_MONOTONIC_COARSE = 6; 19 | enum CLOCK_BOOTTIME = 7; 20 | enum CLOCK_REALTIME_ALARM = 8; 21 | enum CLOCK_BOOTTIME_ALARM = 9; 22 | enum CLOCK_SGI_CYCLE = 10; 23 | enum CLOCK_TAI = 11; 24 | -------------------------------------------------------------------------------- /src/core/sys/linux/timerfd.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file to interface with the Linux timefd API 3 | * Available since Linux 2.6 4 | * 5 | * License : $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | */ 7 | module core.sys.linux.timerfd; 8 | 9 | version (linux): 10 | 11 | public import core.sys.posix.time; 12 | 13 | extern (C): 14 | @system: 15 | @nogc: 16 | nothrow: 17 | 18 | int timerfd_create(int clockid, int flags); 19 | int timerfd_settime(int fd, int flags, const itimerspec* new_value, itimerspec* old_value); 20 | int timerfd_gettime(int fd, itimerspec* curr_value); 21 | 22 | enum TFD_TIMER_ABSTIME = 1 << 0; 23 | enum TFD_TIMER_CANCEL_ON_SET = 1 << 1; 24 | enum TFD_CLOEXEC = 0x80000; 25 | enum TFD_NONBLOCK = 0x800; 26 | -------------------------------------------------------------------------------- /src/core/sys/linux/unistd.d: -------------------------------------------------------------------------------- 1 | module core.sys.linux.unistd; 2 | 3 | public import core.sys.posix.unistd; 4 | 5 | version (linux): 6 | extern(C): 7 | nothrow: 8 | @system: 9 | 10 | // Additional seek constants for sparse file handling 11 | // from Linux's unistd.h, stdio.h, and linux/fs.h 12 | // (see http://man7.org/linux/man-pages/man2/lseek.2.html) 13 | enum { 14 | /// Offset is relative to the next location containing data 15 | SEEK_DATA = 3, 16 | /// Offset is relative to the next hole (or EOF if file is not sparse) 17 | SEEK_HOLE = 4 18 | } 19 | 20 | /// Prompt for a password without echoing it. 21 | char* getpass(const(char)* prompt); 22 | 23 | // Exit all threads in a process 24 | void exit_group(int status); 25 | -------------------------------------------------------------------------------- /src/core/sys/netbsd/err.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for NetBSD err.h. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.netbsd.err; 9 | import core.stdc.stdarg : va_list; 10 | 11 | version (NetBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | void err(int eval, scope const char* fmt, ...); 17 | void errc(int eval, int code, scope const char* fmt, ...); 18 | void errx(int eval, scope const char* fmt, ...); 19 | void warn(scope const char* fmt, ...); 20 | void warnc(int code, scope const char* fmt, ...); 21 | void warnx(scope const char* fmt, ...); 22 | void verr(int eval, scope const char* fmt, va_list args); 23 | void verrc(int eval, int code, scope const char* fmt, va_list args); 24 | void verrx(int eval, scope const char* fmt, va_list args); 25 | void vwarn(scope const char* fmt, va_list args); 26 | void vwarnc(int code, scope const char* fmt, va_list args); 27 | void vwarnx(scope const char* fmt, va_list args); 28 | -------------------------------------------------------------------------------- /src/core/sys/netbsd/stdlib.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for NetBSD stdlib.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Iain Buclaw 7 | */ 8 | module core.sys.netbsd.stdlib; 9 | public import core.sys.posix.stdlib; 10 | 11 | version (NetBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | const(char)* getprogname(); 17 | void setprogname(scope const char* name); 18 | -------------------------------------------------------------------------------- /src/core/sys/netbsd/string.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for NetBSD string. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.netbsd.string; 9 | 10 | public import core.stdc.string; 11 | import core.sys.netbsd.sys.featuretest; 12 | 13 | version (NetBSD): 14 | extern (C): 15 | nothrow: 16 | @nogc: 17 | 18 | static if (_NETBSD_SOURCE) 19 | { 20 | pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 21 | } 22 | -------------------------------------------------------------------------------- /src/core/sys/netbsd/sys/elf.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for NetBSD. 3 | * 4 | */ 5 | module core.sys.netbsd.sys.elf; 6 | 7 | version (NetBSD): 8 | 9 | public import core.sys.netbsd.sys.elf32; 10 | public import core.sys.netbsd.sys.elf64; 11 | -------------------------------------------------------------------------------- /src/core/sys/netbsd/sys/elf32.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for NetBSD. 3 | * 4 | * http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/sys/exec_elf.h 5 | */ 6 | module core.sys.netbsd.sys.elf32; 7 | 8 | version (NetBSD): 9 | extern (C): 10 | pure: 11 | nothrow: 12 | 13 | import core.stdc.stdint; 14 | public import core.sys.netbsd.sys.elf_common; 15 | 16 | alias uint64_t Elf32_Lword; 17 | alias Elf32_Word Elf32_Hashelt; 18 | alias Elf32_Word Elf32_Size; 19 | alias Elf32_Sword Elf32_Ssize; 20 | 21 | struct Elf32_Dyn 22 | { 23 | Elf32_Sword d_tag; 24 | union _d_un 25 | { 26 | Elf32_Word d_val; 27 | Elf32_Addr d_ptr; 28 | } _d_un d_un; 29 | } 30 | 31 | alias Elf_Note Elf32_Nhdr; 32 | 33 | struct Elf32_Cap 34 | { 35 | Elf32_Word c_tag; 36 | union _c_un 37 | { 38 | Elf32_Word c_val; 39 | Elf32_Addr c_ptr; 40 | } _c_un c_un; 41 | } 42 | 43 | extern (D) 44 | { 45 | auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } 46 | } 47 | -------------------------------------------------------------------------------- /src/core/sys/netbsd/sys/elf64.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for NetBSD. 3 | * 4 | * http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/sys/exec_elf.h 5 | */ 6 | module core.sys.netbsd.sys.elf64; 7 | 8 | version (NetBSD): 9 | extern (C): 10 | pure: 11 | nothrow: 12 | 13 | import core.stdc.stdint; 14 | public import core.sys.netbsd.sys.elf_common; 15 | 16 | alias uint64_t Elf64_Lword; 17 | alias Elf64_Word Elf64_Hashelt; 18 | alias Elf64_Xword Elf64_Size; 19 | alias Elf64_Sxword Elf64_Ssize; 20 | 21 | struct Elf64_Dyn 22 | { 23 | Elf64_Sxword d_tag; 24 | union _d_un 25 | { 26 | Elf64_Xword d_val; 27 | Elf64_Addr d_ptr; 28 | } _d_un d_un; 29 | } 30 | 31 | extern (D) 32 | { 33 | auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; } 34 | auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; } 35 | auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } 36 | } 37 | 38 | alias Elf_Note Elf64_Nhdr; 39 | 40 | struct Elf64_Cap 41 | { 42 | Elf64_Xword c_tag; 43 | union _c_un 44 | { 45 | Elf64_Xword c_val; 46 | Elf64_Addr c_ptr; 47 | } _c_un c_un; 48 | } 49 | 50 | extern (D) 51 | { 52 | auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; } 53 | } 54 | -------------------------------------------------------------------------------- /src/core/sys/netbsd/sys/featuretest.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for NetBSD featuretest;. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.netbsd.sys.featuretest; 9 | 10 | version (NetBSD): 11 | 12 | enum _NETBSD_SOURCE = true; 13 | -------------------------------------------------------------------------------- /src/core/sys/netbsd/time.d: -------------------------------------------------------------------------------- 1 | //Written in the D programming language 2 | 3 | /++ 4 | D header file for NetBSD's extensions to POSIX's time.h. 5 | 6 | Copyright: Copyright 2014 7 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 8 | Authors: $(HTTP jmdavisprog.com, Jonathan M Davis) 9 | 10 | http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/sys/time.h 11 | +/ 12 | module core.sys.netbsd.time; 13 | 14 | public import core.sys.posix.time; 15 | 16 | version (NetBSD): 17 | 18 | enum CLOCK_REALTIME = 0; 19 | enum CLOCK_VIRTUAL = 1; 20 | enum CLOCK_PROF = 2; 21 | enum CLOCK_MONOTONIC = 3; 22 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/dlfcn.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD. 3 | * 4 | * $(LINK2 https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/include/dlfcn.h?rev=1.15&content-type=text/plain, dlfcn.h) 5 | */ 6 | module core.sys.openbsd.dlfcn; 7 | 8 | public import core.sys.posix.dlfcn; 9 | 10 | version (OpenBSD): 11 | extern (C): 12 | nothrow: 13 | 14 | enum RTLD_NEXT = cast(void *)-1; 15 | enum RTLD_DEFAULT = cast(void *)-2; 16 | enum RTLD_SELF = cast(void *)-3; 17 | 18 | enum DL_GETERRNO = 1; 19 | enum DL_SETTHREADLCK = 2; 20 | enum DL_SETBINDLCK = 3; 21 | enum DL_REFERENCE = 4; 22 | 23 | enum DL_LAZY = RTLD_LAZY; 24 | 25 | int dlctl(void *, int, void *); 26 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/err.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD err.h. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.openbsd.err; 9 | import core.stdc.stdarg : va_list; 10 | 11 | version (OpenBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | void err(int eval, scope const char* fmt, ...); 17 | void errc(int eval, int code, scope const char* fmt, ...); 18 | void errx(int eval, scope const char* fmt, ...); 19 | void warn(scope const char* fmt, ...); 20 | void warnc(int code, scope const char* fmt, ...); 21 | void warnx(scope const char* fmt, ...); 22 | void verr(int eval, scope const char* fmt, va_list args); 23 | void verrc(int eval, int code, scope const char* fmt, va_list args); 24 | void verrx(int eval, scope const char* fmt, va_list args); 25 | void vwarn(scope const char* fmt, va_list args); 26 | void vwarnc(int code, scope const char* fmt, va_list args); 27 | void vwarnx(scope const char* fmt, va_list args); 28 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/execinfo.d: -------------------------------------------------------------------------------- 1 | /** 2 | * OpenBSD implementation of glibc's $(LINK2 http://www.gnu.org/software/libc/manual/html_node/Backtraces.html backtrace) facility. 3 | * 4 | * Copyright: Copyright Martin Nowak 2012. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | * Source: $(DRUNTIMESRC core/sys/openbsd/_execinfo.d) 8 | */ 9 | module core.sys.openbsd.execinfo; 10 | 11 | version (OpenBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | size_t backtrace(void**, size_t); 17 | char** backtrace_symbols(const(void*)*, size_t); 18 | void backtrace_symbols_fd(const(void*)*, size_t, int); 19 | char** backtrace_symbols_fmt(const(void*)*, size_t, const char*); 20 | int backtrace_symbols_fd_fmt(const(void*)*, size_t, int, const char*); 21 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/pthread_np.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD pthread_np.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Brian Callahan 7 | */ 8 | module core.sys.openbsd.pthread_np; 9 | 10 | version (OpenBSD): 11 | extern (C): 12 | nothrow: 13 | @nogc: 14 | 15 | public import core.sys.posix.sys.types; 16 | import core.sys.posix.signal : stack_t; 17 | 18 | int pthread_mutexattr_getkind_np(pthread_mutexattr_t); 19 | int pthread_mutexattr_setkind_np(pthread_mutexattr_t*, int); 20 | void pthread_get_name_np(pthread_t, char*, size_t); 21 | void pthread_set_name_np(pthread_t, const(char)*); 22 | int pthread_stackseg_np(pthread_t, stack_t*); 23 | int pthread_main_np(); 24 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/pwd.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD pwd.h. 3 | * 4 | * Copyright: Copyright © 2022, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Brian Callahan 7 | */ 8 | module core.sys.openbsd.pwd; 9 | 10 | version (OpenBSD): 11 | extern (C): 12 | nothrow: 13 | @nogc: 14 | 15 | public import core.sys.posix.pwd; 16 | import core.sys.posix.sys.types : uid_t; 17 | 18 | passwd* getpwnam_shadow(scope const char*); 19 | passwd* getpwuid_shadow(uid_t); 20 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/stdlib.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD stdlib.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Iain Buclaw 7 | */ 8 | module core.sys.openbsd.stdlib; 9 | public import core.sys.posix.stdlib; 10 | 11 | version (OpenBSD): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | void freezero(void*, size_t); 17 | void* calloc_conceal(size_t, size_t); 18 | void* malloc_conceal(size_t); 19 | void* reallocarray(void*, size_t, size_t); 20 | void* recallocarray(void*, size_t, size_t, size_t); 21 | 22 | const(char)* getprogname(); 23 | void setprogname(scope const char*); 24 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/string.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD string. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.openbsd.string; 9 | 10 | public import core.stdc.string; 11 | import core.sys.openbsd.sys.cdefs; 12 | 13 | version (OpenBSD): 14 | extern (C): 15 | nothrow: 16 | @nogc: 17 | 18 | static if (__BSD_VISIBLE) 19 | { 20 | void explicit_bzero(void*, size_t); 21 | pure void* memmem(return scope const void* haystack, size_t haystacklen, scope const void* needle, size_t needlelen); 22 | void* memrchr(scope const void*, int, size_t); 23 | size_t strlcat(char*, scope const char*, size_t); 24 | size_t strlcpy(char*, scope const char*, size_t); 25 | void strmode(int, char*); 26 | char* strsep(char**, scope const char*); 27 | pure int timingsafe_bcmp(scope const void*, scope const void*, size_t); 28 | pure int timingsafe_memcmp(scope const void*, scope const void*, size_t); 29 | } 30 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/sys/cdefs.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD 3 | * 4 | * Authors: Iain Buclaw 5 | */ 6 | module core.sys.openbsd.sys.cdefs; 7 | 8 | version (OpenBSD): 9 | 10 | public import core.sys.posix.config; 11 | 12 | enum __XPG_VISIBLE = 700; 13 | enum __POSIX_VISIBLE = 200809; 14 | enum __ISO_C_VISIBLE = 1999; 15 | enum __BSD_VISIBLE = true; 16 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/sys/elf.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD. 3 | * 4 | * Authors: Iain Buclaw 5 | * Based-on: core/sys/freebsd/sys 6 | */ 7 | module core.sys.openbsd.sys.elf; 8 | 9 | version (OpenBSD): 10 | 11 | public import core.sys.openbsd.sys.elf32; 12 | public import core.sys.openbsd.sys.elf64; 13 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/sys/elf32.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD. 3 | * 4 | * Authors: Iain Buclaw 5 | * Based-on: core/sys/freebsd/sys 6 | */ 7 | module core.sys.openbsd.sys.elf32; 8 | 9 | version (OpenBSD): 10 | extern (C): 11 | pure: 12 | nothrow: 13 | 14 | import core.stdc.stdint; 15 | public import core.sys.openbsd.sys.elf_common; 16 | 17 | alias uint64_t Elf32_Lword; 18 | alias Elf32_Word Elf32_Hashelt; 19 | alias Elf32_Word Elf32_Size; 20 | alias Elf32_Sword Elf32_Ssize; 21 | 22 | struct Elf32_Dyn 23 | { 24 | Elf32_Sword d_tag; 25 | union _d_un 26 | { 27 | Elf32_Word d_val; 28 | Elf32_Addr d_ptr; 29 | } _d_un d_un; 30 | } 31 | 32 | alias Elf_Note Elf32_Nhdr; 33 | 34 | struct Elf32_Cap 35 | { 36 | Elf32_Word c_tag; 37 | union _c_un 38 | { 39 | Elf32_Word c_val; 40 | Elf32_Addr c_ptr; 41 | } _c_un c_un; 42 | } 43 | 44 | extern (D) 45 | { 46 | auto ELF32_ST_VISIBILITY(O)(O o) { return o & 0x03; } 47 | } 48 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/sys/elf64.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD. 3 | * 4 | * Authors: Iain Buclaw 5 | * Based-on: core/sys/freebsd/sys 6 | */ 7 | module core.sys.openbsd.sys.elf64; 8 | 9 | version (OpenBSD): 10 | extern (C): 11 | pure: 12 | nothrow: 13 | 14 | import core.stdc.stdint; 15 | public import core.sys.openbsd.sys.elf_common; 16 | 17 | alias uint64_t Elf64_Lword; 18 | alias Elf64_Word Elf64_Hashelt; 19 | alias Elf64_Xword Elf64_Size; 20 | alias Elf64_Sxword Elf64_Ssize; 21 | 22 | struct Elf64_Dyn 23 | { 24 | Elf64_Sxword d_tag; 25 | union _d_un 26 | { 27 | Elf64_Xword d_val; 28 | Elf64_Addr d_ptr; 29 | } _d_un d_un; 30 | } 31 | 32 | extern (D) pure 33 | { 34 | auto ELF64_R_TYPE_DATA(I)(I i) { return (cast(Elf64_Xword) i << 32) >> 40; } 35 | auto ELF64_R_TYPE_ID(I)(I i) { return (cast(Elf64_Xword) i << 56 ) >> 56; } 36 | auto ELF64_R_TYPE_INFO(D, T)(D d, T t) { return cast(Elf64_Xword) d << 8 + cast(Elf64_Xword) t; } 37 | } 38 | 39 | alias Elf_Note Elf64_Nhdr; 40 | 41 | struct Elf64_Cap 42 | { 43 | Elf64_Xword c_tag; 44 | union _c_un 45 | { 46 | Elf64_Xword c_val; 47 | Elf64_Addr c_ptr; 48 | } _c_un c_un; 49 | } 50 | 51 | extern (D) 52 | { 53 | auto ELF64_ST_VISIBILITY(O)(O o) { return o & 0x03; } 54 | } 55 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/sys/mman.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD 3 | * 4 | * Authors: Iain Buclaw 5 | * Based-on: core/sys/freebsd/sys 6 | */ 7 | module core.sys.openbsd.sys.mman; 8 | 9 | version (OpenBSD): 10 | extern (C): 11 | nothrow: 12 | 13 | public import core.sys.posix.sys.mman; 14 | import core.sys.openbsd.sys.cdefs; 15 | import core.sys.posix.sys.types; 16 | 17 | // already in core.sys.posix.sys.mman 18 | // enum MAP_SHARED = 0x0001; 19 | // enum MAP_PRIVATE = 0x0002; 20 | // enum MAP_FIXED = 0x0010; 21 | // enum MAP_ANON = 0x1000; 22 | // enum MAP_STACK = 0x4000; 23 | 24 | alias MAP_ANONYMOUS = MAP_ANON; 25 | enum MAP_CONCEAL = 0x8000; 26 | 27 | enum MAP_FLAGMASK = 0xfff7; 28 | 29 | alias MAP_COPY = MAP_PRIVATE; 30 | enum MAP_FILE = 0; 31 | enum MAP_HASSEMAPHORE = 0; 32 | enum MAP_INHERIT = 0; 33 | enum MAP_NOEXTEND = 0; 34 | enum MAP_NORESERVE = 0; 35 | enum MAP_RENAME = 0; 36 | enum MAP_TRYFIXED = 0; 37 | 38 | static if (__BSD_VISIBLE) 39 | { 40 | alias MADV_NORMAL = POSIX_MADV_NORMAL; 41 | alias MADV_RANDOM = POSIX_MADV_RANDOM; 42 | alias MADV_SEQUENTIAL = POSIX_MADV_SEQUENTIAL; 43 | alias MADV_WILLNEED = POSIX_MADV_WILLNEED; 44 | alias MADV_DONTNEED = POSIX_MADV_DONTNEED; 45 | enum MADV_SPACEAVAIL = 5; 46 | enum MADV_FREE = 6; 47 | 48 | int madvise(void *, size_t, int); 49 | int minherit(void *, size_t, int); 50 | void* mquery(void *, size_t, int, int, int, off_t); 51 | } 52 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/time.d: -------------------------------------------------------------------------------- 1 | //Written in the D programming language 2 | 3 | /++ 4 | D header file for OpenBSD's extensions to POSIX's time.h. 5 | 6 | Copyright: Copyright 2019 7 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 8 | Authors: Iain Buclaw 9 | +/ 10 | module core.sys.openbsd.time; 11 | 12 | public import core.sys.posix.time; 13 | 14 | version (OpenBSD): 15 | 16 | enum CLOCK_REALTIME = 0; 17 | enum CLOCK_PROCESS_CPUTIME_ID = 2; 18 | enum CLOCK_MONOTONIC = 3; 19 | enum CLOCK_THREAD_CPUTIME_ID = 4; 20 | enum CLOCK_UPTIME = 5; 21 | enum CLOCK_BOOTTIME = 6; 22 | -------------------------------------------------------------------------------- /src/core/sys/openbsd/unistd.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for OpenBSD unistd.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Brian Callahan 7 | */ 8 | module core.sys.openbsd.unistd; 9 | 10 | version (OpenBSD): 11 | extern (C): 12 | nothrow: 13 | @nogc: 14 | 15 | int getentropy(void*, size_t); 16 | int pledge(const scope char*, const scope char*); 17 | int unveil(const scope char*, const scope char*); 18 | -------------------------------------------------------------------------------- /src/core/sys/posix/inttypes.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for POSIX. 3 | * 4 | * Copyright: Copyright Sean Kelly 2005 - 2009. 5 | * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 | * Authors: Sean Kelly 7 | * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 8 | */ 9 | 10 | /* Copyright Sean Kelly 2005 - 2009. 11 | * Distributed under the Boost Software License, Version 1.0. 12 | * (See accompanying file LICENSE or copy at 13 | * http://www.boost.org/LICENSE_1_0.txt) 14 | */ 15 | module core.sys.posix.inttypes; 16 | 17 | import core.sys.posix.config; 18 | public import core.stdc.inttypes; 19 | 20 | version (Posix): 21 | extern (C) nothrow @nogc: 22 | @system: 23 | 24 | // 25 | // Required 26 | // 27 | /* 28 | intmax_t imaxabs(intmax_t); 29 | imaxdiv_t imaxdiv(intmax_t, intmax_t); 30 | intmax_t strtoimax(const scope char*, char**, int); 31 | uintmax_t strtoumax(const scope char*, char**, int); 32 | intmax_t wcstoimax(const scope wchar_t*, wchar_t**, int); 33 | uintmax_t wcstoumax(const scope wchar_t*, wchar_t**, int); 34 | */ 35 | 36 | intmax_t imaxabs(intmax_t); 37 | imaxdiv_t imaxdiv(intmax_t, intmax_t); 38 | intmax_t strtoimax(const scope char*, char**, int); 39 | uintmax_t strtoumax(const scope char*, char**, int); 40 | intmax_t wcstoimax(const scope wchar_t*, wchar_t**, int); 41 | uintmax_t wcstoumax(const scope wchar_t*, wchar_t**, int); 42 | -------------------------------------------------------------------------------- /src/core/sys/posix/libgen.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for POSIX. 3 | * 4 | * Copyright: 2016 Sociomantic Labs GmbH 5 | * License: Boost License 1.0. 6 | * Authors: Leandro Lucarella 7 | * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 8 | */ 9 | 10 | /* Copyright Sociomantic Labs GmbH 2016. 11 | * Distributed under the Boost Software License, Version 1.0. 12 | * (See accompanying file LICENSE or copy at 13 | * http://www.boost.org/LICENSE_1_0.txt) 14 | */ 15 | module core.sys.posix.libgen; 16 | 17 | @nogc nothrow: 18 | @system: 19 | extern (C): 20 | version (Posix): 21 | 22 | char* basename(char*); 23 | char* dirname(char*); 24 | -------------------------------------------------------------------------------- /src/core/sys/posix/strings.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for POSIX's . 3 | * 4 | * Note: Do not mistake this module for (singular), 5 | * available at `core.sys.posix.string`. 6 | * 7 | * See_Also: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/strings.h.html 8 | * Copyright: D Language Foundation, 2019 9 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 10 | * Authors: Mathias 'Geod24' Lang 11 | * Standards: The Open Group Base Specifications Issue 7, 2018 edition 12 | * Source: $(DRUNTIMESRC core/sys/posix/_strings.d) 13 | */ 14 | module core.sys.posix.strings; 15 | 16 | version (Posix): 17 | extern(C): 18 | @system: 19 | nothrow: 20 | @nogc: 21 | 22 | /// 23 | public import core.sys.posix.locale : locale_t; 24 | 25 | /// Find first bit set in a word 26 | int ffs(int i) @safe pure; 27 | /// Compare two strings ignoring case 28 | int strcasecmp(scope const char* s1, scope const char* s2); 29 | /// Compare two strings ignoring case, with the specified locale 30 | int strcasecmp_l(scope const char* s1, scope const char* s2, scope locale_t locale); 31 | /// Compare two strings ignoring case, up to n characters 32 | int strncasecmp(scope const char* s1, scope const char* s2, size_t n); 33 | /// Compare two strings ignoring case, with the specified locale, up to n characters 34 | int strncasecmp_l(scope const char* s1, const char* s2, size_t n, locale_t locale); 35 | -------------------------------------------------------------------------------- /src/core/sys/solaris/elf.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Solaris. 3 | * 4 | * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/head/elf.h, illumos elf.h) 5 | */ 6 | module core.sys.solaris.elf; 7 | 8 | version (Solaris): 9 | extern (C): 10 | nothrow: 11 | 12 | public import core.sys.solaris.sys.elf; 13 | -------------------------------------------------------------------------------- /src/core/sys/solaris/err.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Solaris err.h. 3 | * 4 | * Copyright: Copyright © 2019, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Ernesto Castellotti 7 | */ 8 | module core.sys.solaris.err; 9 | import core.stdc.stdarg : va_list; 10 | 11 | version (Solaris): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | void err(int eval, scope const char* fmt, ...); 17 | void errx(int eval, scope const char* fmt, ...); 18 | void warn(scope const char* fmt, ...); 19 | void warnx(scope const char* fmt, ...); 20 | void verr(int eval, scope const char* fmt, va_list args); 21 | void verrx(int eval, scope const char* fmt, va_list args); 22 | void vwarn(scope const char* fmt, va_list args); 23 | void vwarnx(scope const char* fmt, va_list args); 24 | -------------------------------------------------------------------------------- /src/core/sys/solaris/execinfo.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Solaris. 3 | * 4 | * Copyright: Copyright Martin Nowak 2012. 5 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 6 | * Authors: Martin Nowak 7 | */ 8 | module core.sys.solaris.execinfo; 9 | 10 | // The interface is exactly the same as linux, so copied from linux's execinfo.d 11 | 12 | version (Solaris): 13 | extern (C): 14 | nothrow: 15 | 16 | int backtrace(void** buffer, int size); 17 | char** backtrace_symbols(const(void*)* buffer, int size); 18 | void backtrace_symbols_fd(const(void*)* buffer, int size, int fd); 19 | -------------------------------------------------------------------------------- /src/core/sys/solaris/stdlib.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Solaris stdlib.h. 3 | * 4 | * Copyright: Copyright © 2021, The D Language Foundation 5 | * License: Boost License 1.0. 6 | * Authors: Iain Buclaw 7 | */ 8 | module core.sys.solaris.stdlib; 9 | public import core.sys.posix.stdlib; 10 | 11 | version (Solaris): 12 | extern (C): 13 | nothrow: 14 | @nogc: 15 | 16 | const(char)* getprogname(); 17 | void setprogname(scope const char* name); 18 | -------------------------------------------------------------------------------- /src/core/sys/solaris/sys/elf_notes.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Solaris. 3 | * 4 | * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/elf_notes.h, illumos sys/elf_notes.h) 5 | */ 6 | module core.sys.solaris.sys.elf_notes; 7 | 8 | version (Solaris): 9 | extern (C): 10 | nothrow: 11 | 12 | enum ELF_NOTE_SOLARIS = "SUNW Solaris"; 13 | 14 | enum ELF_NOTE_PAGESIZE_HINT = 1; 15 | -------------------------------------------------------------------------------- /src/core/sys/solaris/sys/elftypes.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Solaris. 3 | * 4 | * $(LINK2 http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/elftypes.h, illumos sys/elftypes.h) 5 | */ 6 | module core.sys.solaris.sys.elftypes; 7 | 8 | version (Solaris): 9 | extern (C): 10 | nothrow: 11 | 12 | import core.stdc.stdint; 13 | 14 | public import core.sys.elf : 15 | Elf32_Addr, Elf32_Half, Elf32_Off, 16 | Elf32_Sword, Elf32_Word, 17 | Elf64_Addr, Elf64_Half, Elf64_Off, 18 | Elf64_Sword, Elf64_Sxword, 19 | Elf64_Word, Elf64_Xword; 20 | 21 | alias uint64_t Elf64_Lword; 22 | alias uint64_t Elf32_Lword; 23 | -------------------------------------------------------------------------------- /src/core/sys/solaris/sys/procset.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file defining a process set. 3 | * 4 | * Copyright: Copyright 2014 Jason King. 5 | * License: $(HTTP www.boost.org/LICENSE_1.0.txt, Boost License 1.0). 6 | * Authors: Jason King 7 | */ 8 | 9 | /* 10 | * Copyright 2014 Jason King. 11 | * Distributed under the Boost Software License, Version 1.0. 12 | * See accompanying file LICENSE or copy at 13 | * http://www.boost.org/LICENSE_1_0.txt 14 | */ 15 | module core.sys.solaris.sys.procset; 16 | 17 | version (Solaris): 18 | nothrow: 19 | @nogc: 20 | 21 | import core.sys.posix.sys.types : id_t; 22 | import core.sys.posix.sys.wait : idtype_t; 23 | 24 | enum P_INITPID = 1; 25 | enum P_INITUID = 0; 26 | enum P_INITPGID = 0; 27 | 28 | enum idop_t 29 | { 30 | POP_DIFF, 31 | POP_AND, 32 | POP_OR, 33 | POP_XOR 34 | } 35 | 36 | struct procset_t 37 | { 38 | idop_t p_op; 39 | idtype_t p_lidtype; 40 | id_t p_lid; 41 | idtype_t p_ridtype; 42 | id_t p_rid; 43 | } 44 | 45 | void setprocset(ref procset_t psp, idop_t op, idtype_t ltype, id_t lid, idtype_t rtype, id_t rid) 46 | { 47 | psp.p_op = op; 48 | psp.p_lidtype = ltype; 49 | psp.p_lid = lid; 50 | psp.p_ridtype = rtype; 51 | psp.p_rid = rid; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/core/sys/solaris/sys/types.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file that defines Solaris-specific types. 3 | * 4 | * Copyright: Copyright 2014 Jason King. 5 | * License: $(HTTP www.boost.org/LICENSE_1.0.txt, Boost License 1.0). 6 | * Authors: Jason King 7 | */ 8 | 9 | /* 10 | * Copyright 2014 Jason King. 11 | * Distributed under the Boost Software License, Version 1.0. 12 | * See accompanying file LICENSE or copy at 13 | * http://www.boost.org/LICENSE_1_0.txt 14 | */ 15 | 16 | module core.sys.solaris.sys.types; 17 | 18 | version (Solaris): 19 | nothrow: 20 | @nogc: 21 | 22 | alias short pri_t; 23 | 24 | enum P_MYID = -1; 25 | -------------------------------------------------------------------------------- /src/core/sys/solaris/time.d: -------------------------------------------------------------------------------- 1 | //Written in the D programming language 2 | 3 | /++ 4 | D header file for Solaris's extensions to POSIX's time.h. 5 | 6 | Copyright: Copyright 2014 7 | License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 8 | Authors: Kai Nacke 9 | +/ 10 | module core.sys.solaris.time; 11 | 12 | public import core.sys.posix.time; 13 | 14 | version (Solaris): 15 | 16 | enum CLOCK_VIRTUAL = 1; 17 | enum CLOCK_HIGHRES = CLOCK_MONOTONIC; 18 | enum CLOCK_PROF = CLOCK_THREAD_CPUTIME_ID; 19 | -------------------------------------------------------------------------------- /src/core/sys/windows/basetyps.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_basetyps.d) 8 | */ 9 | module core.sys.windows.basetyps; 10 | version (Windows): 11 | @system: 12 | 13 | import core.sys.windows.windef, core.sys.windows.basetsd; 14 | 15 | align(1) struct GUID { // size is 16 16 | align(1): 17 | DWORD Data1; 18 | WORD Data2; 19 | WORD Data3; 20 | BYTE[8] Data4; 21 | } 22 | alias GUID UUID, /*IID, CLSID, */FMTID, uuid_t; 23 | alias IID = const(GUID); 24 | alias CLSID = const(GUID); 25 | 26 | alias GUID* LPGUID, LPCLSID, LPIID; 27 | alias const(GUID)* LPCGUID, REFGUID, REFIID, REFCLSID, REFFMTID; 28 | alias uint error_status_t, PROPID; 29 | -------------------------------------------------------------------------------- /src/core/sys/windows/cguid.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_cguid.d) 8 | */ 9 | module core.sys.windows.cguid; 10 | version (Windows): 11 | 12 | import core.sys.windows.basetyps; 13 | 14 | -------------------------------------------------------------------------------- /src/core/sys/windows/core.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Helper module for the Windows API 3 | * 4 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 5 | * Source: $(DRUNTIMESRC core/sys/windows/_core.d) 6 | */ 7 | module core.sys.windows.core; 8 | version (Windows): 9 | 10 | /** 11 | The core Windows API functions. 12 | 13 | Importing this file is equivalent to the C code: 14 | --- 15 | #define WIN32_LEAN_AND_MEAN 16 | #include "windows.h" 17 | --- 18 | 19 | */ 20 | 21 | public import core.sys.windows.windef; 22 | public import core.sys.windows.winnt; 23 | public import core.sys.windows.wincon; 24 | public import core.sys.windows.winbase; 25 | public import core.sys.windows.wingdi; 26 | public import core.sys.windows.winuser; 27 | public import core.sys.windows.winnls; 28 | public import core.sys.windows.winver; 29 | public import core.sys.windows.winnetwk; 30 | public import core.sys.windows.winsvc; 31 | -------------------------------------------------------------------------------- /src/core/sys/windows/cplext.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_cplext.d) 9 | */ 10 | module core.sys.windows.cplext; 11 | version (Windows): 12 | @system: 13 | 14 | enum : uint { 15 | CPLPAGE_MOUSE_BUTTONS = 1, 16 | CPLPAGE_MOUSE_PTRMOTION = 2, 17 | CPLPAGE_MOUSE_WHEEL = 3, 18 | CPLPAGE_KEYBOARD_SPEED = 1, 19 | CPLPAGE_DISPLAY_BACKGROUND = 1 20 | } 21 | -------------------------------------------------------------------------------- /src/core/sys/windows/errorrep.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_errorrep.d) 9 | */ 10 | module core.sys.windows.errorrep; 11 | version (Windows): 12 | @system: 13 | 14 | version (ANSI) {} else version = Unicode; 15 | 16 | import core.sys.windows.w32api, core.sys.windows.windef; 17 | 18 | static assert (_WIN32_WINNT >= 0x501, 19 | "core.sys.windows.errorrep is available only if version WindowsXP, Windows2003 " 20 | ~ "or WindowsVista is set"); 21 | 22 | enum EFaultRepRetVal { 23 | frrvOk, 24 | frrvOkManifest, 25 | frrvOkQueued, 26 | frrvErr, 27 | frrvErrNoDW, 28 | frrvErrTimeout, 29 | frrvLaunchDebugger, 30 | frrvOkHeadless // = 7 31 | } 32 | 33 | extern (Windows) { 34 | BOOL AddERExcludedApplicationA(LPCSTR); 35 | BOOL AddERExcludedApplicationW(LPCWSTR); 36 | EFaultRepRetVal ReportFault(LPEXCEPTION_POINTERS, DWORD); 37 | } 38 | 39 | version (Unicode) { 40 | alias AddERExcludedApplicationW AddERExcludedApplication; 41 | } else { 42 | alias AddERExcludedApplicationA AddERExcludedApplication; 43 | } 44 | -------------------------------------------------------------------------------- /src/core/sys/windows/exdispid.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_exdispid.d) 9 | */ 10 | module core.sys.windows.exdispid; 11 | version (Windows): 12 | 13 | enum : int { 14 | DISPID_STATUSTEXTCHANGE = 102, 15 | DISPID_PROGRESSCHANGE = 108, 16 | DISPID_TITLECHANGE = 113, 17 | DISPID_BEFORENAVIGATE2 = 250, 18 | DISPID_NEWWINDOW2 = 251, 19 | DISPID_DOCUMENTCOMPLETE = 259 20 | } 21 | -------------------------------------------------------------------------------- /src/core/sys/windows/idispids.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_idispids.d) 9 | */ 10 | module core.sys.windows.idispids; 11 | version (Windows): 12 | 13 | enum : int { 14 | DISPID_AMBIENT_OFFLINEIFNOTCONNECTED = -5501, 15 | DISPID_AMBIENT_SILENT = -5502 16 | } 17 | -------------------------------------------------------------------------------- /src/core/sys/windows/ipifcons.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_ipifcons.d) 9 | */ 10 | module core.sys.windows.ipifcons; 11 | version (Windows): 12 | 13 | // FIXME: check types of constants 14 | 15 | enum { 16 | MIB_IF_ADMIN_STATUS_UP = 1, 17 | MIB_IF_ADMIN_STATUS_DOWN, 18 | MIB_IF_ADMIN_STATUS_TESTING, 19 | } 20 | 21 | enum { 22 | MIB_IF_OPER_STATUS_NON_OPERATIONAL, 23 | MIB_IF_OPER_STATUS_UNREACHABLE, 24 | MIB_IF_OPER_STATUS_DISCONNECTED, 25 | MIB_IF_OPER_STATUS_CONNECTING, 26 | MIB_IF_OPER_STATUS_CONNECTED, 27 | MIB_IF_OPER_STATUS_OPERATIONAL // = 5 28 | } 29 | 30 | enum { 31 | MIB_IF_TYPE_OTHER = 1, 32 | MIB_IF_TYPE_ETHERNET = 6, 33 | MIB_IF_TYPE_TOKENRING = 9, 34 | MIB_IF_TYPE_FDDI = 15, 35 | MIB_IF_TYPE_PPP = 23, 36 | MIB_IF_TYPE_LOOPBACK = 24, 37 | MIB_IF_TYPE_SLIP = 28 38 | } 39 | -------------------------------------------------------------------------------- /src/core/sys/windows/isguids.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_isguids.d) 9 | */ 10 | module core.sys.windows.isguids; 11 | version (Windows): 12 | 13 | import core.sys.windows.basetyps; 14 | 15 | extern (C) extern const GUID 16 | CLSID_InternetShortcut, 17 | IID_IUniformResourceLocator; 18 | -------------------------------------------------------------------------------- /src/core/sys/windows/lmapibuf.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_lmapibuf.d) 8 | */ 9 | module core.sys.windows.lmapibuf; 10 | version (Windows): 11 | pragma(lib, "netapi32"); 12 | 13 | import core.sys.windows.lmcons, core.sys.windows.windef; 14 | 15 | extern (Windows) { 16 | NET_API_STATUS NetApiBufferAllocate(DWORD, PVOID*); 17 | NET_API_STATUS NetApiBufferFree(PVOID); 18 | NET_API_STATUS NetApiBufferReallocate(PVOID, DWORD, PVOID*); 19 | NET_API_STATUS NetApiBufferSize(PVOID, PDWORD); 20 | NET_API_STATUS NetapipBufferAllocate(DWORD, PVOID*); 21 | } 22 | -------------------------------------------------------------------------------- /src/core/sys/windows/lmconfig.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_lmconfig.d) 8 | */ 9 | module core.sys.windows.lmconfig; 10 | version (Windows): 11 | @system: 12 | 13 | // All functions in this file are deprecated! 14 | 15 | import core.sys.windows.lmcons, core.sys.windows.windef; 16 | 17 | deprecated { 18 | struct CONFIG_INFO_0 { 19 | LPWSTR cfgi0_key; 20 | LPWSTR cfgi0_data; 21 | } 22 | 23 | alias CONFIG_INFO_0* PCONFIG_INFO_0, LPCONFIG_INFO_0; 24 | 25 | extern (Windows) { 26 | NET_API_STATUS NetConfigGet(LPCWSTR, LPCWSTR, LPCWSTR, PBYTE*); 27 | NET_API_STATUS NetConfigGetAll(LPCWSTR, LPCWSTR, PBYTE*); 28 | NET_API_STATUS NetConfigSet(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, DWORD, 29 | PBYTE, DWORD); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/core/sys/windows/lmuseflg.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_lmuseflg.d) 8 | */ 9 | module core.sys.windows.lmuseflg; 10 | version (Windows): 11 | 12 | enum : uint { 13 | USE_NOFORCE = 0, 14 | USE_FORCE, 15 | USE_LOTS_OF_FORCE // = 2 16 | } 17 | -------------------------------------------------------------------------------- /src/core/sys/windows/mciavi.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_mciavi.d) 9 | */ 10 | module core.sys.windows.mciavi; 11 | version (Windows): 12 | @system: 13 | 14 | import core.sys.windows.mmsystem; 15 | 16 | // FIXME: check types and grouping of constants 17 | 18 | enum MCI_MCIAVI_PLAY_WINDOW = 0x01000000; 19 | enum MCI_MCIAVI_PLAY_FULLSCREEN = 0x02000000; 20 | enum MCI_MCIAVI_PLAY_FULLBY2 = 0x04000000; 21 | 22 | enum { 23 | MCI_AVI_STATUS_FRAMES_SKIPPED = 0x00008001, 24 | MCI_AVI_STATUS_LAST_PLAY_SPEED = 0x00008002, 25 | MCI_AVI_STATUS_AUDIO_BREAKS = 0x00008003, 26 | MCI_AVI_SETVIDEO_DRAW_PROCEDURE = 0x00008000, 27 | MCI_AVI_SETVIDEO_PALETTE_COLOR = 0x00008100, 28 | MCI_AVI_SETVIDEO_PALETTE_HALFTONE = 0x0000FFFF 29 | } 30 | 31 | enum { 32 | MCIERR_AVI_OLDAVIFORMAT = MCIERR_CUSTOM_DRIVER_BASE + 100, 33 | MCIERR_AVI_NOTINTERLEAVED, 34 | MCIERR_AVI_NODISPDIB, 35 | MCIERR_AVI_CANTPLAYFULLSCREEN, 36 | MCIERR_AVI_TOOBIGFORVGA, 37 | MCIERR_AVI_NOCOMPRESSOR, 38 | MCIERR_AVI_DISPLAYERROR, 39 | MCIERR_AVI_AUDIOERROR, 40 | MCIERR_AVI_BADPALETTE // = MCIERR_CUSTOM_DRIVER_BASE + 108 41 | } 42 | -------------------------------------------------------------------------------- /src/core/sys/windows/ntdll.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_ntdll.d) 9 | */ 10 | module core.sys.windows.ntdll; 11 | version (Windows): 12 | @system: 13 | 14 | import core.sys.windows.w32api; 15 | 16 | 17 | enum SHUTDOWN_ACTION { 18 | ShutdownNoReboot, 19 | ShutdownReboot, 20 | ShutdownPowerOff 21 | } 22 | 23 | extern (Windows) uint NtShutdownSystem(SHUTDOWN_ACTION Action); 24 | -------------------------------------------------------------------------------- /src/core/sys/windows/objsafe.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_objsafe.d) 9 | */ 10 | module core.sys.windows.objsafe; 11 | version (Windows): 12 | @system: 13 | 14 | import core.sys.windows.basetyps, core.sys.windows.unknwn, core.sys.windows.windef; 15 | 16 | enum { 17 | INTERFACESAFE_FOR_UNTRUSTED_CALLER = 1, 18 | INTERFACESAFE_FOR_UNTRUSTED_DATA 19 | } 20 | 21 | interface IObjectSafety : IUnknown { 22 | HRESULT GetInterfaceSafetyOptions(REFIID, DWORD*, DWORD*); 23 | HRESULT SetInterfaceSafetyOptions(REFIID, DWORD, DWORD); 24 | } 25 | -------------------------------------------------------------------------------- /src/core/sys/windows/ole2ver.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_ole2ver.d) 8 | */ 9 | module core.sys.windows.ole2ver; 10 | version (Windows): 11 | 12 | // These are apparently not documented on the MSDN site 13 | enum rmm = 23; 14 | enum rup = 639; 15 | -------------------------------------------------------------------------------- /src/core/sys/windows/olectlid.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_olectlid.d) 8 | */ 9 | module core.sys.windows.olectlid; 10 | version (Windows): 11 | 12 | import core.sys.windows.basetyps; 13 | 14 | -------------------------------------------------------------------------------- /src/core/sys/windows/pbt.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * Authors: Stewart Gordon 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/_pbt.d) 9 | */ 10 | module core.sys.windows.pbt; 11 | version (Windows): 12 | @system: 13 | 14 | import core.sys.windows.windef; 15 | 16 | enum : WPARAM { 17 | PBT_APMQUERYSUSPEND, 18 | PBT_APMQUERYSTANDBY, 19 | PBT_APMQUERYSUSPENDFAILED, 20 | PBT_APMQUERYSTANDBYFAILED, 21 | PBT_APMSUSPEND, 22 | PBT_APMSTANDBY, 23 | PBT_APMRESUMECRITICAL, 24 | PBT_APMRESUMESUSPEND, 25 | PBT_APMRESUMESTANDBY, 26 | PBT_APMBATTERYLOW, 27 | PBT_APMPOWERSTATUSCHANGE, 28 | PBT_APMOEMEVENT // = 11 29 | } 30 | 31 | enum LPARAM PBTF_APMRESUMEFROMFAILURE = 1; 32 | -------------------------------------------------------------------------------- /src/core/sys/windows/rpc.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_rpc.d) 8 | */ 9 | module core.sys.windows.rpc; 10 | version (Windows): 11 | @system: 12 | 13 | /* Moved to rpcdecp (duplicate definition). 14 | typedef void *I_RPC_HANDLE; 15 | alias long RPC_STATUS; 16 | // Moved to rpcdce: 17 | RpcImpersonateClient 18 | RpcRevertToSelf 19 | */ 20 | 21 | public import core.sys.windows.unknwn; 22 | public import core.sys.windows.rpcdce; // also pulls in rpcdcep 23 | public import core.sys.windows.rpcnsi; 24 | public import core.sys.windows.rpcnterr; 25 | public import core.sys.windows.winerror; 26 | 27 | alias MIDL_user_allocate midl_user_allocate; 28 | alias MIDL_user_free midl_user_free; 29 | 30 | extern (Windows) { 31 | int I_RpcMapWin32Status(RPC_STATUS); 32 | } 33 | -------------------------------------------------------------------------------- /src/core/sys/windows/rpcnsip.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_rpcnsip.d) 8 | */ 9 | module core.sys.windows.rpcnsip; 10 | version (Windows): 11 | @system: 12 | 13 | import core.sys.windows.rpcdce, core.sys.windows.rpcdcep, core.sys.windows.rpcnsi; 14 | 15 | struct RPC_IMPORT_CONTEXT_P { 16 | RPC_NS_HANDLE LookupContext; 17 | RPC_BINDING_HANDLE ProposedHandle; 18 | RPC_BINDING_VECTOR* Bindings; 19 | } 20 | alias RPC_IMPORT_CONTEXT_P* PRPC_IMPORT_CONTEXT_P; 21 | 22 | extern(Windows) { 23 | RPC_STATUS I_RpcNsGetBuffer(PRPC_MESSAGE); 24 | RPC_STATUS I_RpcNsSendReceive(PRPC_MESSAGE, RPC_BINDING_HANDLE*); 25 | void I_RpcNsRaiseException(PRPC_MESSAGE, RPC_STATUS); 26 | RPC_STATUS I_RpcReBindBuffer(PRPC_MESSAGE); 27 | RPC_STATUS I_NsServerBindSearch(); 28 | RPC_STATUS I_NsClientBindSearch(); 29 | void I_NsClientBindDone(); 30 | } 31 | -------------------------------------------------------------------------------- /src/core/sys/windows/rpcnterr.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_rpcnterr.d) 8 | */ 9 | module core.sys.windows.rpcnterr; 10 | version (Windows): 11 | @system: 12 | 13 | import core.sys.windows.winerror; 14 | 15 | enum : uint { 16 | RPC_S_OK = ERROR_SUCCESS, 17 | RPC_S_INVALID_ARG = ERROR_INVALID_PARAMETER, 18 | RPC_S_OUT_OF_MEMORY = ERROR_OUTOFMEMORY, 19 | RPC_S_OUT_OF_THREADS = ERROR_MAX_THRDS_REACHED, 20 | RPC_S_INVALID_LEVEL = ERROR_INVALID_PARAMETER, 21 | RPC_S_BUFFER_TOO_SMALL = ERROR_INSUFFICIENT_BUFFER, 22 | RPC_S_INVALID_SECURITY_DESC = ERROR_INVALID_SECURITY_DESCR, 23 | RPC_S_ACCESS_DENIED = ERROR_ACCESS_DENIED, 24 | RPC_S_SERVER_OUT_OF_MEMORY = ERROR_NOT_ENOUGH_SERVER_MEMORY, 25 | RPC_X_NO_MEMORY = RPC_S_OUT_OF_MEMORY, 26 | RPC_X_INVALID_BOUND = RPC_S_INVALID_BOUND, 27 | RPC_X_INVALID_TAG = RPC_S_INVALID_TAG, 28 | RPC_X_ENUM_VALUE_TOO_LARGE = RPC_X_ENUM_VALUE_OUT_OF_RANGE, 29 | RPC_X_SS_CONTEXT_MISMATCH = ERROR_INVALID_HANDLE, 30 | RPC_X_INVALID_BUFFER = ERROR_INVALID_USER_BUFFER, 31 | RPC_X_INVALID_PIPE_OPERATION = RPC_X_WRONG_PIPE_ORDER 32 | } 33 | -------------------------------------------------------------------------------- /src/core/sys/windows/servprov.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW API for MS-Windows 3.10 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_servprov.d) 8 | */ 9 | module core.sys.windows.servprov; 10 | version (Windows): 11 | @system: 12 | 13 | import core.sys.windows.basetyps, core.sys.windows.unknwn, core.sys.windows.windef, core.sys.windows.wtypes; 14 | 15 | interface IServiceProvider : IUnknown { 16 | HRESULT QueryService(REFGUID, REFIID, void**); 17 | } 18 | -------------------------------------------------------------------------------- /src/core/sys/windows/shldisp.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_shldisp.d) 8 | */ 9 | module core.sys.windows.shldisp; 10 | version (Windows): 11 | @system: 12 | 13 | import core.sys.windows.unknwn, core.sys.windows.windef, core.sys.windows.wtypes; 14 | 15 | // options for IAutoComplete2 16 | enum DWORD ACO_AUTOSUGGEST = 0x01; 17 | 18 | interface IAutoComplete : IUnknown { 19 | HRESULT Init(HWND, IUnknown, LPCOLESTR, LPCOLESTR); 20 | HRESULT Enable(BOOL); 21 | } 22 | alias IAutoComplete LPAUTOCOMPLETE; 23 | 24 | interface IAutoComplete2 : IAutoComplete { 25 | HRESULT SetOptions(DWORD); 26 | HRESULT GetOptions(DWORD*); 27 | } 28 | alias IAutoComplete2 LPAUTOCOMPLETE2; 29 | -------------------------------------------------------------------------------- /src/core/sys/windows/shlguid.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API header module 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Source: $(DRUNTIMESRC core/sys/windows/_shlguid.d) 8 | */ 9 | module core.sys.windows.shlguid; 10 | version (Windows): 11 | @system: 12 | 13 | import core.sys.windows.basetyps, core.sys.windows.w32api; 14 | 15 | // FIXME: clean up Windows version support 16 | 17 | // I think this is just a helper macro for other win32 headers? 18 | //MACRO #define DEFINE_SHLGUID(n,l,w1,w2) DEFINE_GUID(n,l,w1,w2,0xC0,0,0,0,0,0,0,0x46) 19 | 20 | -------------------------------------------------------------------------------- /src/core/sys/windows/stdc/malloc.d: -------------------------------------------------------------------------------- 1 | /** 2 | * D header file for Windows malloc.h. 3 | * 4 | * Translated from MinGW Windows headers 5 | * 6 | * Authors: Iain Buclaw 7 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 8 | * Source: $(DRUNTIMESRC core/sys/windows/stdc/_malloc.d) 9 | */ 10 | module core.sys.windows.stdc.malloc; 11 | version (CRuntime_Microsoft): 12 | extern (C): 13 | @system: 14 | nothrow: 15 | @nogc: 16 | 17 | export void* _recalloc(void*, size_t, size_t); 18 | 19 | export void _aligned_free(void*); 20 | export void* _aligned_malloc(size_t, size_t); 21 | 22 | export void* _aligned_offset_malloc(size_t, size_t, size_t); 23 | export void* _aligned_realloc(void*, size_t, size_t); 24 | export void* _aligned_recalloc(void*, size_t, size_t, size_t); 25 | export void* _aligned_offset_realloc(void*, size_t, size_t, size_t); 26 | export void* _aligned_offset_recalloc(void*, size_t, size_t, size_t, size_t); 27 | -------------------------------------------------------------------------------- /src/core/thread/package.d: -------------------------------------------------------------------------------- 1 | /** 2 | * The thread module provides support for thread creation and management. 3 | * 4 | * Copyright: Copyright Sean Kelly 2005 - 2012. 5 | * License: Distributed under the 6 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 7 | * (See accompanying file LICENSE) 8 | * Authors: Sean Kelly, Walter Bright, Alex Rønne Petersen, Martin Nowak 9 | * Source: $(DRUNTIMESRC core/thread/package.d) 10 | */ 11 | 12 | module core.thread; 13 | 14 | public import core.time; 15 | public import core.thread.fiber; 16 | public import core.thread.osthread; 17 | public import core.thread.threadbase; 18 | public import core.thread.threadgroup; 19 | public import core.thread.types; 20 | public import core.thread.context; 21 | -------------------------------------------------------------------------------- /src/ldc/arm_unwind.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Shims for libunwind macros on ARM. 3 | * 4 | * It would be possible to reimplement those entirely in D, but to avoid 5 | * an unmaintainable amount of dependencies on internal implementation details, 6 | * we use the C versions instead. 7 | * 8 | * Copyright: David Nadlinger, 2012. 9 | * License: Boost License 1.0. 10 | * Authors: David Nadlinger 11 | */ 12 | 13 | #ifdef __ARM_EABI__ 14 | 15 | #include // for __GLIBC__ 16 | #include 17 | 18 | // clang's unwind.h doesn't have this 19 | typedef struct _Unwind_Context _Unwind_Context; 20 | 21 | _Unwind_Ptr _d_eh_GetIP(_Unwind_Context *context) 22 | { 23 | return _Unwind_GetIP(context); 24 | } 25 | 26 | #ifdef __GLIBC__ 27 | _Unwind_Ptr _d_eh_GetIPInfo(_Unwind_Context *context, int *ptr) 28 | { 29 | return _Unwind_GetIPInfo(context, ptr); 30 | } 31 | #endif 32 | 33 | void _d_eh_SetIP(_Unwind_Context *context, _Unwind_Ptr new_value) 34 | { 35 | _Unwind_SetIP(context, new_value); 36 | } 37 | 38 | _Unwind_Word _d_eh_GetGR(_Unwind_Context *context, int index) 39 | { 40 | return _Unwind_GetGR(context, index); 41 | } 42 | 43 | void _d_eh_SetGR(_Unwind_Context *context, int index, _Unwind_Word new_value) 44 | { 45 | _Unwind_SetGR(context, index, new_value); 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/ldc/asan.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains forward references to the AddressSanitizer interface. 3 | * See compiler-rt/include/sanitizer/asan_interface.h 4 | * 5 | * Copyright: Authors 2017-2017 6 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 7 | * Authors: LDC Developers 8 | */ 9 | module ldc.asan; 10 | 11 | @system: 12 | @nogc: 13 | nothrow: 14 | extern (C): 15 | 16 | // Poisons memory region [addr, addr+size) for AddressSanitizer. 17 | // Method is NOT thread-safe in the sense that no two threads can 18 | // (un)poison memory in the same memory region simultaneously. 19 | void __asan_poison_memory_region(const(void*) addr, size_t size); 20 | 21 | // Unpoisons memory region [addr, addr+size) for AddressSanitizer. 22 | // Method is NOT thread-safe in the sense that no two threads can 23 | // (un)poison memory in the same memory region simultaneously. 24 | void __asan_unpoison_memory_region(const(void*) addr, size_t size); 25 | 26 | // Returns 1 if the byte at addr is poisoned for AddressSanitizer. 27 | // Otherwise returns 0. 28 | int __asan_address_is_poisoned(const(void*) addr); 29 | -------------------------------------------------------------------------------- /src/rt/arraycat.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of array copy support routines. 3 | * 4 | * Copyright: Copyright Digital Mars 2004 - 2016. 5 | * License: Distributed under the 6 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 7 | * Authors: Walter Bright, Sean Kelly 8 | * Source: $(DRUNTIMESRC rt/_arraycat.d) 9 | */ 10 | 11 | module rt.arraycat; 12 | 13 | private 14 | { 15 | import core.stdc.string; 16 | import core.internal.util.array; 17 | debug(PRINTF) import core.stdc.stdio; 18 | } 19 | 20 | extern (C) @trusted nothrow: 21 | 22 | version (LDC) 23 | { 24 | void _d_array_slice_copy(void* dst, size_t dstlen, void* src, size_t srclen, size_t elemsz) 25 | { 26 | import ldc.intrinsics : llvm_memcpy; 27 | 28 | enforceRawArraysConformable("copy", elemsz, src[0..srclen], dst[0..dstlen]); 29 | llvm_memcpy!size_t(dst, src, dstlen * elemsz, 0); 30 | } 31 | } 32 | else 33 | { 34 | void[] _d_arraycopy(size_t size, void[] from, void[] to) 35 | { 36 | debug(PRINTF) printf("f = %p,%d, t = %p,%d, size = %d\n", 37 | from.ptr, from.length, to.ptr, to.length, size); 38 | 39 | enforceRawArraysConformable("copy", size, from, to); 40 | memcpy(to.ptr, from.ptr, to.length * size); 41 | return to; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/rt/dylib_fixes.c: -------------------------------------------------------------------------------- 1 | /** 2 | * OS X support for dynamic libraries. 3 | * 4 | * Copyright: Copyright Digital Mars 2010 - 2010. 5 | * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 | * Authors: Walter Bright 7 | */ 8 | 9 | /* Copyright Digital Mars 2010 - 2010. 10 | * Distributed under the Boost Software License, Version 1.0. 11 | * (See accompanying file LICENSE or copy at 12 | * http://www.boost.org/LICENSE_1_0.txt) 13 | */ 14 | void* _Dmain __attribute__((weak)); 15 | 16 | char rt_init (); 17 | char rt_term (); 18 | 19 | __attribute__((constructor)) static void initializer () 20 | { 21 | rt_init(); 22 | } 23 | 24 | __attribute__((destructor)) static void finalizer () 25 | { 26 | rt_term(); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/rt/invariant.d: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of invariant support routines. 3 | * 4 | * Copyright: Copyright Digital Mars 2007 - 2010. 5 | * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 | * Authors: Walter Bright 7 | * Source: $(DRUNTIMESRC rt/_invariant.d) 8 | */ 9 | 10 | /* Copyright Digital Mars 2007 - 2010. 11 | * Distributed under the Boost Software License, Version 1.0. 12 | * (See accompanying file LICENSE or copy at 13 | * http://www.boost.org/LICENSE_1_0.txt) 14 | */ 15 | 16 | 17 | /** 18 | * 19 | */ 20 | void _d_invariant(Object o) 21 | { ClassInfo c; 22 | 23 | //printf("__d_invariant(%p)\n", o); 24 | 25 | // BUG: needs to be filename/line of caller, not library routine 26 | assert(o !is null); // just do null check, not invariant check 27 | 28 | c = typeid(o); 29 | do 30 | { 31 | if (c.classInvariant) 32 | { 33 | (*c.classInvariant)(o); 34 | } 35 | c = c.base; 36 | } while (c); 37 | } 38 | -------------------------------------------------------------------------------- /src/rt/memory.d: -------------------------------------------------------------------------------- 1 | /** 2 | * This module tells the garbage collector about the static data and bss segments, 3 | * so the GC can scan them for roots. It does not deal with thread local static data. 4 | * 5 | * Copyright: Copyright Digital Mars 2000 - 2012. 6 | * License: Distributed under the 7 | * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). 8 | * (See accompanying file LICENSE) 9 | * Authors: Walter Bright, Sean Kelly 10 | * Source: $(DRUNTIMESRC rt/_memory.d) 11 | */ 12 | 13 | module rt.memory; 14 | 15 | 16 | import core.memory; 17 | import rt.sections; 18 | 19 | void initStaticDataGC() 20 | { 21 | foreach (ref sg; SectionGroup) 22 | { 23 | foreach (rng; sg.gcRanges) 24 | GC.addRange(rng.ptr, rng.length); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/rt/minit.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ldc-developers/druntime/6cb44f57ac9ba66a26df93739b9f8c9918fdfad3/src/rt/minit.obj -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | **/generated/ 2 | **/obj/ 3 | **/*.log 4 | **/*.output 5 | -------------------------------------------------------------------------------- /test/aa/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=test_aa 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/test_aa.done: $(ROOT)/%.done : $(ROOT)/% 9 | @echo Testing $* 10 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 11 | @touch $@ 12 | 13 | $(ROOT)/%: $(SRC)/%.d 14 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 15 | 16 | clean: 17 | rm -rf $(GENERATED) 18 | -------------------------------------------------------------------------------- /test/allocations/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=overflow_from_zero overflow_from_existing alloc_from_assert 4 | 5 | DIFF:=diff 6 | SED:=sed 7 | 8 | .PHONY: all clean 9 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 10 | 11 | $(ROOT)/alloc_from_assert.done: $(ROOT)/alloc_from_assert 12 | @echo Testing $* 13 | $(QUIET)$(TIMELIMIT)$(ROOT)/alloc_from_assert $(RUN_ARGS) 14 | @touch $@ 15 | 16 | $(ROOT)/overflow_from_zero.done: STDERR_EXP="Memory allocation failed" 17 | $(ROOT)/overflow_from_existing.done: STDERR_EXP="Memory allocation failed" 18 | $(ROOT)/%.done: $(ROOT)/% 19 | @echo Testing $* 20 | $(NEGATE) $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 2>&1 1>/dev/null | head -n 2 | grep -qF $(STDERR_EXP) 21 | @touch $@ 22 | 23 | $(ROOT)/unittest_assert: DFLAGS+=-unittest -version=CoreUnittest 24 | $(ROOT)/%: $(SRC)/%.d 25 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 26 | 27 | clean: 28 | rm -rf $(GENERATED) 29 | -------------------------------------------------------------------------------- /test/allocations/src/alloc_from_assert.d: -------------------------------------------------------------------------------- 1 | import core.exception; 2 | import core.memory; 3 | 4 | class FailFinalization 5 | { 6 | int magic; 7 | 8 | ~this () @nogc nothrow 9 | { 10 | try 11 | assert(this.magic == 42); 12 | catch (AssertError) {} 13 | } 14 | } 15 | 16 | void foo () 17 | { 18 | auto dangling = new FailFinalization(); 19 | } 20 | 21 | void main() 22 | { 23 | foo(); 24 | GC.collect(); 25 | } 26 | -------------------------------------------------------------------------------- /test/allocations/src/overflow_from_existing.d: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | void[] buffer; 4 | buffer.length = 1; 5 | buffer.length = size_t.max; 6 | } 7 | -------------------------------------------------------------------------------- /test/allocations/src/overflow_from_zero.d: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | void[] buffer; 4 | buffer.length = 0; 5 | buffer.length = size_t.max; 6 | } 7 | -------------------------------------------------------------------------------- /test/betterc/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=test18828 test19416 test19421 test19561 test20088 test20613 test19924 test22336 test19933 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix ,$(TESTS))) $(addprefix $(ROOT)/,test19924.done) 7 | 8 | $(ROOT)/test19924.done: $(ROOT)/%.done : $(ROOT)/% 9 | @echo Running $* 10 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 11 | @touch $@ 12 | 13 | $(ROOT)/%: $(SRC)/%.d 14 | $(QUIET)$(DMD) -betterC -of$@ $< 15 | 16 | clean: 17 | rm -rf $(ROOT) 18 | -------------------------------------------------------------------------------- /test/betterc/src/test18828.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=18828 3 | 4 | struct S18828 { } 5 | 6 | extern(C) void main() 7 | { 8 | S18828 s; 9 | destroy(s); 10 | } 11 | -------------------------------------------------------------------------------- /test/betterc/src/test19416.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=19416 3 | 4 | import core.stdc.stdlib : malloc, free; 5 | import core.exception : onOutOfMemoryError; 6 | 7 | extern(C) void main() 8 | { 9 | auto m = malloc(1); 10 | if (!m) 11 | onOutOfMemoryError(); 12 | else 13 | free(m); 14 | } 15 | -------------------------------------------------------------------------------- /test/betterc/src/test19421.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=19421 3 | 4 | import core.memory; 5 | 6 | extern(C) void main() @nogc nothrow pure 7 | { 8 | auto p = pureMalloc(1); 9 | p = pureRealloc(p, 2); 10 | if (p) pureFree(p); 11 | p = pureCalloc(1, 1); 12 | if (p) pureFree(p); 13 | } 14 | -------------------------------------------------------------------------------- /test/betterc/src/test19561.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=19561 3 | 4 | import core.memory; 5 | 6 | extern(C) void main() @nogc nothrow pure 7 | { 8 | int[3] a, b; 9 | a[] = 0; 10 | a[] = b[]; 11 | //FIXME: Next line requires compiler change. 12 | //a[] = 1; // error: undefined reference to '_memset32' 13 | a[] += 1; 14 | a[] += b[]; 15 | int[3] c = a[] + b[]; 16 | } 17 | -------------------------------------------------------------------------------- /test/betterc/src/test19924.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=19924 3 | 4 | import core.bitop; 5 | 6 | extern(C) void main() 7 | { 8 | uint a = 0x01_23_45_67; 9 | a = bswap(a); 10 | assert(a == 0x67_45_23_01); 11 | 12 | ulong b = 0x01_23_45_67_89_ab_cd_ef; 13 | b = bswap(b); 14 | assert(b == 0xef_cd_ab_89_67_45_23_01); 15 | } 16 | -------------------------------------------------------------------------------- /test/betterc/src/test19933.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=19933 3 | // https://issues.dlang.org/show_bug.cgi?id=18816 4 | 5 | import core.stdc.stdio; 6 | 7 | extern(C) int main() 8 | { 9 | fprintf(stderr, "Hello\n"); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /test/betterc/src/test20088.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=20088 3 | 4 | struct S { 5 | int i; 6 | } 7 | 8 | extern(C) int main() @nogc nothrow pure 9 | { 10 | S[2] s = [S(1),S(2)]; 11 | void[] v = cast(void[])s; 12 | S[] p = cast(S[])v; // cast of void[] to S[] triggers __ArrayCast template function 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/betterc/src/test20613.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=20613 3 | 4 | extern(C) int main() @nogc nothrow pure 5 | { 6 | auto s = "F"; 7 | final switch(s) 8 | { 9 | case "A": break; 10 | case "B": break; 11 | case "C": break; 12 | case "D": break; 13 | case "E": break; 14 | case "F": break; 15 | case "G": break; 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /test/betterc/src/test22336.d: -------------------------------------------------------------------------------- 1 | /*******************************************/ 2 | // https://issues.dlang.org/show_bug.cgi?id=22336 3 | 4 | import core.lifetime; 5 | 6 | struct Foo { 7 | int f = -1; 8 | @disable this(this); 9 | this(int x) { f = x; } 10 | @disable this(); 11 | } 12 | 13 | extern(C) int main() { 14 | Foo a = Foo(42); 15 | Foo b = move(a); 16 | assert(a.f == -1); 17 | assert(b.f == 42); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /test/common.mak: -------------------------------------------------------------------------------- 1 | # set from top makefile 2 | # LDC: we have no top makefile, include osmodel.mak for OS 3 | include ../../../../dmd/osmodel.mak 4 | #OS:= 5 | MODEL:= 6 | BUILD:= 7 | DMD:= 8 | DRUNTIME:= 9 | DRUNTIMESO:= 10 | LINKDL:= 11 | QUIET:= 12 | TIMELIMIT:= 13 | LDL:=$(subst -L,,$(LINKDL)) # -ldl 14 | 15 | SRC:=src 16 | GENERATED:=./generated 17 | ROOT:=$(GENERATED)/$(OS)/$(BUILD)/$(MODEL) 18 | 19 | ifneq (default,$(MODEL)) 20 | MODEL_FLAG:=-m$(MODEL) 21 | endif 22 | CFLAGS_BASE:= $(MODEL_FLAG) $(PIC) -Wall 23 | # LDC: use -defaultlib=druntime-ldc instead of `-defaultlib= -L$(DRUNTIME[SO])` 24 | DFLAGS:=$(MODEL_FLAG) $(PIC) -w -I../../src -I../../import -I$(SRC) -defaultlib=druntime-ldc -preview=dip1000 25 | ifeq (,$(findstring win,$(OS))) 26 | DFLAGS += -L-lpthread -L-lm 27 | endif 28 | # LINK_SHARED may be set by importing makefile 29 | # LDC: -link-defaultlib-shared takes care of rpath, linking ldc_rt.dso.o etc. 30 | DFLAGS+=$(if $(LINK_SHARED),-link-defaultlib-shared,) 31 | ifeq ($(BUILD),debug) 32 | # LDC: link against debug druntime 33 | DFLAGS += -g -debug -link-defaultlib-debug 34 | ifeq (,$(findstring win,$(OS))) 35 | CFLAGS := $(CFLAGS_BASE) -g 36 | else 37 | CFLAGS := $(CFLAGS_BASE) /Zi 38 | endif 39 | else 40 | DFLAGS += -O -release 41 | ifeq (,$(findstring win,$(OS))) 42 | CFLAGS := $(CFLAGS_BASE) -O3 43 | else 44 | CFLAGS := $(CFLAGS_BASE) /O2 45 | endif 46 | endif 47 | CXXFLAGS_BASE := $(CFLAGS_BASE) 48 | CXXFLAGS:=$(CFLAGS) 49 | -------------------------------------------------------------------------------- /test/config/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=test19433 test20459 test22523 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/%: $(SRC)/%.d 9 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 10 | 11 | $(ROOT)/test19433.done: $(ROOT)/test19433 12 | @echo Testing test19433 13 | $(QUIET)$(ROOT)/test19433 --DRT-dont-eat-me 14 | @touch $@ 15 | 16 | $(ROOT)/test20459.done: $(ROOT)/test20459 17 | @echo Testing test20459 18 | $(QUIET)$(ROOT)/test20459 foo bar -- --DRT-gcopts=profile:1 19 | @touch $@ 20 | 21 | 22 | $(ROOT)/test22523.done: $(SRC)/test22523.d 23 | @echo Testing $< 24 | $(QUIET)$(DMD) $(DFLAGS) -unittest -of$(ROOT)/test22523 $< 25 | $(QUIET) $(ROOT)/test22523 -- --DRT-testmode=run-main 26 | @touch $@ 27 | 28 | clean: 29 | rm -rf $(ROOT) 30 | -------------------------------------------------------------------------------- /test/config/src/test19433.d: -------------------------------------------------------------------------------- 1 | extern(C) __gshared bool rt_cmdline_enabled = false; 2 | 3 | void main(string[] args) 4 | { 5 | assert(args.length == 2); 6 | assert(args[1] == "--DRT-dont-eat-me"); 7 | } 8 | -------------------------------------------------------------------------------- /test/config/src/test20459.d: -------------------------------------------------------------------------------- 1 | void main (string[] args) 2 | { 3 | assert(args.length == 5); 4 | assert(args[1 .. $] == [ "foo", "bar", "--", "--DRT-gcopts=profile:1" ]); 5 | } 6 | -------------------------------------------------------------------------------- /test/config/src/test22523.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=22523 2 | 3 | import core.stdc.stdio; 4 | 5 | int main() 6 | { 7 | puts("Executed main although it should be skipped!"); 8 | return 1; 9 | } 10 | 11 | unittest {} 12 | -------------------------------------------------------------------------------- /test/coverage/src-basic.lst.exp: -------------------------------------------------------------------------------- 1 | |import core.runtime; 2 | | 3 | |void main(string[] args) 4 | |{ 5 | 1| dmd_coverDestPath(args[1]); 6 | |} 7 | src/basic.d is 100% covered 8 | -------------------------------------------------------------------------------- /test/coverage/src-merge.lst.exp: -------------------------------------------------------------------------------- 1 | |import core.runtime; 2 | | 3 | |int main(string[] args) 4 | |{ 5 | 1| dmd_coverDestPath(args[1]); 6 | 1| return 0; 7 | |} 8 | src/merge.d is 100% covered 9 | -------------------------------------------------------------------------------- /test/coverage/src-merge_override.lst_1.exp: -------------------------------------------------------------------------------- 1 | |import core.runtime; 2 | | 3 | |void main(string[] args) 4 | |{ 5 | 1| dmd_coverDestPath(args[1]); 6 | | enum CHANGE_VAR = 0; 7 | 1| dmd_coverSetMerge(true); 8 | |} 9 | src/merge_override.d is 100% covered 10 | -------------------------------------------------------------------------------- /test/coverage/src-merge_override.lst_2.exp: -------------------------------------------------------------------------------- 1 | |import core.runtime; 2 | | 3 | |void main(string[] args) 4 | |{ 5 | 1| dmd_coverDestPath(args[1]); 6 | | enum CHANGEVAR = 0; 7 | 1| dmd_coverSetMerge(true); 8 | |} 9 | src/merge_override.d is 100% covered 10 | -------------------------------------------------------------------------------- /test/coverage/src-merge_true.lst.exp: -------------------------------------------------------------------------------- 1 | |import core.runtime; 2 | | 3 | |void main(string[] args) 4 | |{ 5 | 2| dmd_coverDestPath(args[1]); 6 | 2| dmd_coverSetMerge(true); 7 | |} 8 | src/merge_true.d is 100% covered 9 | -------------------------------------------------------------------------------- /test/coverage/src-no_code.lst.exp: -------------------------------------------------------------------------------- 1 | |import core.runtime; 2 | | 3 | |void main(string[] args) 4 | |{ 5 | 1| dmd_coverDestPath(args[1]); 6 | |} 7 | src/no_code.d is 100% covered 8 | -------------------------------------------------------------------------------- /test/coverage/src-no_code_imp.lst.exp: -------------------------------------------------------------------------------- 1 | |enum NO_CODE_IMP = 0; 2 | src/no_code_imp.d has no code 3 | -------------------------------------------------------------------------------- /test/coverage/src/basic.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | void main(string[] args) 4 | { 5 | dmd_coverDestPath(args[1]); 6 | } 7 | -------------------------------------------------------------------------------- /test/coverage/src/merge.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | int main(string[] args) 4 | { 5 | dmd_coverDestPath(args[1]); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /test/coverage/src/merge_override.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | void main(string[] args) 4 | { 5 | dmd_coverDestPath(args[1]); 6 | enum CHANGE_VAR = 0; 7 | dmd_coverSetMerge(true); 8 | } 9 | -------------------------------------------------------------------------------- /test/coverage/src/merge_true.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | void main(string[] args) 4 | { 5 | dmd_coverDestPath(args[1]); 6 | dmd_coverSetMerge(true); 7 | } 8 | -------------------------------------------------------------------------------- /test/coverage/src/no_code.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | void main(string[] args) 4 | { 5 | dmd_coverDestPath(args[1]); 6 | } 7 | -------------------------------------------------------------------------------- /test/coverage/src/no_code_imp.d: -------------------------------------------------------------------------------- 1 | enum NO_CODE_IMP = 0; 2 | -------------------------------------------------------------------------------- /test/cpuid/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=cpuid 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/%.done: $(ROOT)/% 9 | @echo Testing $* 10 | $(QUIET)$(TIMELIMIT)$< $(RUN_ARGS) 11 | @touch $@ 12 | 13 | $(ROOT)/cpuid: $(SRC)/cpuid.d 14 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 15 | 16 | clean: 17 | rm -rf $(GENERATED) 18 | -------------------------------------------------------------------------------- /test/cpuid/win64.mak: -------------------------------------------------------------------------------- 1 | # built from the druntime top-level folder 2 | # to be overwritten by caller 3 | DMD=dmd 4 | MODEL=64 5 | DRUNTIMELIB=druntime64.lib 6 | 7 | test: cpuid 8 | 9 | cpuid: 10 | $(DMD) -g -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) test\cpuid\src\cpuid.d 11 | cpuid.exe 12 | del cpuid.exe cpuid.obj 13 | -------------------------------------------------------------------------------- /test/cycles/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=cycle_ignore cycle_abort cycle_print cycle_deprecate 4 | 5 | DIFF:=diff 6 | SED:=sed 7 | 8 | .PHONY: all clean 9 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 10 | 11 | $(ROOT)/cycle_ignore.done: RETCODE=0 12 | $(ROOT)/cycle_ignore.done: LINES=0 13 | $(ROOT)/cycle_abort.done: RETCODE=1 14 | ifneq (,$(findstring win,$(OS))) 15 | $(ROOT)/cycle_abort.done: LINES=8 16 | else 17 | $(ROOT)/cycle_abort.done: LINES=7 18 | endif 19 | $(ROOT)/cycle_print.done: RETCODE=0 20 | $(ROOT)/cycle_print.done: LINES=6 21 | $(ROOT)/cycle_deprecate.done: RETCODE=1 22 | ifneq (,$(findstring win,$(OS))) 23 | $(ROOT)/cycle_deprecate.done: LINES=9 24 | else 25 | $(ROOT)/cycle_deprecate.done: LINES=8 26 | endif 27 | $(ROOT)/%.done: $(ROOT)/test_cycles 28 | @echo Testing $* 29 | $(QUIET)$(TIMELIMIT)$(ROOT)/test_cycles --DRT-oncycle=$(patsubst cycle_%.done,%, $(notdir $@)) > $@ 2>&1; test $$? -eq $(RETCODE) 30 | test `cat $@ | wc -l` -eq $(LINES) 31 | 32 | $(ROOT)/test_cycles: $(SRC)/*.d 33 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $^ 34 | 35 | clean: 36 | rm -rf $(GENERATED) 37 | -------------------------------------------------------------------------------- /test/cycles/src/mod1.d: -------------------------------------------------------------------------------- 1 | module mod1; 2 | import mod2; 3 | 4 | shared int x; 5 | shared static this() 6 | { 7 | x = 1; 8 | } 9 | -------------------------------------------------------------------------------- /test/cycles/src/mod2.d: -------------------------------------------------------------------------------- 1 | module mod2; 2 | import mod1; 3 | import mod3; 4 | 5 | void main() 6 | { 7 | // do nothing 8 | } 9 | -------------------------------------------------------------------------------- /test/cycles/src/mod3.d: -------------------------------------------------------------------------------- 1 | module mod3; 2 | import mod2; 3 | 4 | shared int x; 5 | shared static this() 6 | { 7 | x = 3; 8 | } 9 | -------------------------------------------------------------------------------- /test/exceptions/chain.exp: -------------------------------------------------------------------------------- 1 | Caught 2 | TestError: d 3 | TestException: e 4 | Bypassed chain was: 5 | TestException: a 6 | TestException: b 7 | TestException: c 8 | -------------------------------------------------------------------------------- /test/exceptions/line_trace.exp: -------------------------------------------------------------------------------- 1 | object.Exception@src/line_trace.d(17): exception 2 | ---------------- 3 | src/line_trace.d:17 void line_trace.f1() [ADDR] 4 | src/line_trace.d:5 _Dmain [ADDR] 5 | -------------------------------------------------------------------------------- /test/exceptions/src/invalid_memory_operation.d: -------------------------------------------------------------------------------- 1 | struct S 2 | { 3 | ~this() 4 | { 5 | new int; 6 | } 7 | } 8 | 9 | void main() 10 | { 11 | new S; 12 | } 13 | -------------------------------------------------------------------------------- /test/exceptions/src/line_trace.d: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | try 4 | { 5 | f1(); 6 | } 7 | catch (Exception e) 8 | { 9 | import core.stdc.stdio; 10 | auto str = e.toString(); 11 | printf("%.*s\n", cast(int)str.length, str.ptr); 12 | } 13 | } 14 | 15 | void f1() 16 | { 17 | throw new Exception("exception"); 18 | } 19 | -------------------------------------------------------------------------------- /test/exceptions/src/message_with_null.d: -------------------------------------------------------------------------------- 1 | module message_with_null; 2 | 3 | void main() 4 | { 5 | throw new Exception("hello\0 world!"); 6 | } 7 | -------------------------------------------------------------------------------- /test/exceptions/src/rt_trap_exceptions.d: -------------------------------------------------------------------------------- 1 | // Code adapted from 2 | // http://arsdnet.net/this-week-in-d/2016-aug-07.html 3 | extern extern(C) __gshared bool rt_trapExceptions; 4 | extern extern(C) int _d_run_main(int, char**, void*) @system; 5 | 6 | extern(C) int main(int argc, char** argv) { 7 | rt_trapExceptions = false; 8 | return _d_run_main(argc, argv, &_main); 9 | } 10 | 11 | int _main() { 12 | throw new Exception("this will abort"); 13 | } 14 | -------------------------------------------------------------------------------- /test/exceptions/src/rt_trap_exceptions_drt.d: -------------------------------------------------------------------------------- 1 | void test() 2 | { 3 | int innerLocal = 20; 4 | throw new Exception("foo"); 5 | } 6 | void main(string[] args) 7 | { 8 | string myLocal = "bar"; 9 | test(); 10 | } 11 | -------------------------------------------------------------------------------- /test/exceptions/src/static_dtor.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=16594 2 | import core.stdc.stdio; 3 | 4 | shared static ~this() 5 | { 6 | __gshared int count; 7 | 8 | if (count++) fprintf(stderr, "dtor_called_more_than_once"); 9 | else throw new Exception("static_dtor_exception"); 10 | } 11 | 12 | void main() 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /test/exceptions/src/stderr_msg.d: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | throw new Exception("stderr_msg msg"); 4 | } 5 | -------------------------------------------------------------------------------- /test/exceptions/src/unittest_assert.d: -------------------------------------------------------------------------------- 1 | unittest 2 | { 3 | assert(0, "unittest_assert msg"); 4 | } 5 | 6 | void main() 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /test/exceptions/src/unknown_gc.d: -------------------------------------------------------------------------------- 1 | import core.memory; 2 | 3 | extern(C) __gshared string[] rt_options = [ "gcopt=gc:unknowngc" ]; 4 | 5 | void main() 6 | { 7 | // GC initialized upon first call -> Unknown GC error is thrown 8 | GC.enable(); 9 | } 10 | -------------------------------------------------------------------------------- /test/exceptions/win64.mak: -------------------------------------------------------------------------------- 1 | # built from the druntime top-level folder 2 | # to be overwritten by caller 3 | DMD=dmd 4 | MODEL=64 5 | DRUNTIMELIB=druntime64.lib 6 | 7 | test: 8 | $(DMD) -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -g test\exceptions\src\winstack.d 9 | winstack.exe 10 | del winstack.* 11 | -------------------------------------------------------------------------------- /test/gc/attributes.d: -------------------------------------------------------------------------------- 1 | import core.memory; 2 | 3 | // TODO: The following should work, but L10 (second assert) fails. 4 | version(none) void dotest(T) (T* ptr) 5 | { 6 | GC.clrAttr(ptr, uint.max); 7 | assert(GC.getAttr(ptr) == 0); 8 | 9 | GC.setAttr(ptr, GC.BlkAttr.NO_MOVE); 10 | assert(GC.getAttr(ptr) == GC.BlkAttr.NO_MOVE); 11 | 12 | GC.clrAttr(ptr, GC.BlkAttr.NO_MOVE); 13 | assert(GC.getAttr(ptr) == 0); 14 | GC.clrAttr(ptr, GC.BlkAttr.NO_MOVE); 15 | assert(GC.getAttr(ptr) == 0); 16 | } 17 | else void dotest(T) (T* ptr) 18 | { 19 | // https://issues.dlang.org/show_bug.cgi?id=21484 20 | GC.clrAttr(ptr, uint.max); 21 | GC.setAttr(ptr, GC.BlkAttr.NO_MOVE); 22 | GC.getAttr(ptr); 23 | } 24 | 25 | void main () 26 | { 27 | auto ptr = new int; 28 | dotest!(const(int))(ptr); 29 | dotest!(int)(ptr); 30 | } 31 | -------------------------------------------------------------------------------- /test/gc/forkgc.d: -------------------------------------------------------------------------------- 1 | import core.memory; 2 | import core.stdc.stdio; 3 | import core.sys.posix.sys.wait; 4 | import core.sys.posix.unistd; 5 | 6 | void main() 7 | { 8 | printf("[parent] Creating garbage...\n"); 9 | foreach (n; 0 .. 1_000) 10 | new uint[10_000]; 11 | printf("[parent] Collecting garbage...\n"); 12 | GC.collect(); 13 | printf("[parent] Forking...\n"); 14 | auto i = fork(); 15 | if (i < 0) 16 | assert(false, "Fork failed"); 17 | if (i == 0) 18 | { 19 | printf("[child] In fork.\n"); 20 | printf("[child] Creating garbage...\n"); 21 | foreach (n; 0 .. 1_000) 22 | new uint[10_000]; 23 | printf("[child] Collecting garbage...\n"); 24 | GC.collect(); 25 | printf("[child] Exiting fork.\n"); 26 | } 27 | else 28 | { 29 | printf("[parent] Waiting for fork (PID %d).\n", i); 30 | int status; 31 | i = waitpid(i, &status, 0); 32 | printf("[parent] Fork %d exited (%d).\n", i, status); 33 | if (status != 0) 34 | assert(false, "child had errors"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/gc/forkgc2.d: -------------------------------------------------------------------------------- 1 | import core.stdc.stdlib : exit; 2 | import core.sys.posix.sys.wait : waitpid; 3 | import core.sys.posix.unistd : fork; 4 | import core.thread : Thread; 5 | 6 | void main() 7 | { 8 | foreach (t; 0 .. 10) 9 | new Thread({ 10 | foreach (n; 0 .. 100) 11 | { 12 | foreach (x; 0 .. 100) 13 | new ubyte[x]; 14 | auto f = fork(); 15 | assert(f >= 0); 16 | if (f == 0) 17 | exit(0); 18 | else 19 | waitpid(f, null, 0); 20 | } 21 | }).start(); 22 | } 23 | -------------------------------------------------------------------------------- /test/gc/issue22843.d: -------------------------------------------------------------------------------- 1 | import core.memory; 2 | void main() 3 | { 4 | auto collections = GC.profileStats().numCollections; 5 | // loop until we trigger a collection 6 | for (;;) 7 | { 8 | cast(void)GC.malloc(100_000, GC.BlkAttr.NO_SCAN); 9 | if (GC.profileStats().numCollections == collections+1) 10 | break; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/gc/nocollect.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=20567 2 | 3 | import core.memory; 4 | 5 | void main() 6 | { 7 | auto stats = GC.profileStats(); 8 | assert(stats.numCollections == 0); 9 | 10 | char[] sbuf = new char[256]; // small pool 11 | char[] lbuf = new char[2049]; // large pool 12 | 13 | stats = GC.profileStats(); 14 | assert(stats.numCollections == 0); 15 | } -------------------------------------------------------------------------------- /test/gc/recoverfree.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=20438 2 | import core.stdc.stdio; 3 | import core.memory; 4 | 5 | void main() 6 | { 7 | auto used0 = GC.stats.usedSize; 8 | void* z = GC.malloc(100); 9 | GC.free(z); 10 | GC.collect(); 11 | auto used1 = GC.stats.usedSize; 12 | used1 <= used0 || assert(false); 13 | } 14 | -------------------------------------------------------------------------------- /test/gc/sentinel1.d: -------------------------------------------------------------------------------- 1 | debug (SENTINEL) 2 | void main() 3 | { 4 | import core.stdc.stdio : printf; 5 | import core.sys.posix.unistd : _exit; 6 | import core.memory : GC; 7 | 8 | auto p = cast(ubyte*)GC.malloc(1); 9 | assert(p[ 1] == 0xF5); 10 | 11 | p[1] = 0; 12 | try 13 | { 14 | GC.free(p); 15 | 16 | printf("Clobbered sentinel not detected by GC.free!\n"); 17 | _exit(1); 18 | } 19 | catch (Error e) 20 | { 21 | printf("Clobbered sentinel successfully detected by GC.free.\n"); 22 | _exit(0); 23 | } 24 | } 25 | else 26 | static assert(false); 27 | -------------------------------------------------------------------------------- /test/gc/sentinel2.d: -------------------------------------------------------------------------------- 1 | debug (SENTINEL) 2 | void main() 3 | { 4 | import core.stdc.stdio : printf; 5 | import core.sys.posix.unistd : _exit; 6 | import core.thread : Thread, thread_detachThis; 7 | import core.memory : GC; 8 | 9 | // Create a new thread and immediately detach it from the runtime, 10 | // so that the pointer p will not be visible to the GC. 11 | auto t = new Thread({ 12 | thread_detachThis(); 13 | 14 | auto p = cast(ubyte*)GC.malloc(1); 15 | assert(p[-1] == 0xF4); 16 | assert(p[ 1] == 0xF5); 17 | 18 | p[1] = 0; 19 | try 20 | { 21 | GC.collect(); 22 | 23 | printf("Clobbered sentinel not detected by GC.collect!\n"); 24 | _exit(1); 25 | } 26 | catch (Error e) 27 | { 28 | printf("Clobbered sentinel successfully detected by GC.collect.\n"); 29 | _exit(0); 30 | } 31 | }); 32 | t.start(); 33 | t.join(); 34 | assert(false, "Unreachable"); 35 | } 36 | else 37 | static assert(false); 38 | -------------------------------------------------------------------------------- /test/gc/sigmaskgc.d: -------------------------------------------------------------------------------- 1 | 2 | // https://issues.dlang.org/show_bug.cgi?id=20256 3 | 4 | extern(C) __gshared string[] rt_options = [ "gcopt=parallel:1" ]; 5 | 6 | void main() 7 | { 8 | version (Posix) 9 | { 10 | import core.sys.posix.signal; 11 | import core.sys.posix.unistd; 12 | import core.thread; 13 | import core.memory; 14 | 15 | sigset_t m; 16 | sigemptyset(&m); 17 | sigaddset(&m, SIGHUP); 18 | 19 | auto x = new int[](10000); 20 | foreach (i; 0 .. 10000) 21 | { 22 | x ~= i; 23 | } 24 | GC.collect(); // GC create thread 25 | 26 | sigprocmask(SIG_BLOCK, &m, null); // block SIGHUP from delivery to main thread 27 | 28 | auto parent_pid = getpid(); 29 | auto child_pid = fork(); 30 | assert(child_pid >= 0); 31 | if (child_pid == 0) 32 | { 33 | kill(parent_pid, SIGHUP); // send signal to parent 34 | _exit(0); 35 | } 36 | // parent 37 | Thread.sleep(100.msecs); 38 | // if we are here, then GC threads didn't receive SIGHUP, 39 | // otherwise whole process killed 40 | _exit(0); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/gc/startbackgc.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=20270 2 | import core.sys.posix.sys.wait : waitpid; 3 | import core.sys.posix.unistd : fork, _exit; 4 | import core.thread : Thread; 5 | 6 | void main() 7 | { 8 | foreach (t; 0 .. 10) 9 | new Thread({ 10 | foreach (n; 0 .. 100) 11 | { 12 | foreach (x; 0 .. 100) 13 | new ubyte[x]; 14 | auto f = fork(); 15 | assert(f >= 0); 16 | if (f == 0) 17 | _exit(0); 18 | else 19 | waitpid(f, null, 0); 20 | } 21 | }).start(); 22 | } 23 | -------------------------------------------------------------------------------- /test/hash/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=test_hash 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/test_hash.done: $(ROOT)/%.done : $(ROOT)/% 9 | @echo Testing $* 10 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 11 | @touch $@ 12 | 13 | $(ROOT)/%: $(SRC)/%.d 14 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 15 | 16 | clean: 17 | rm -rf $(GENERATED) 18 | -------------------------------------------------------------------------------- /test/imports/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=bug18193 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/%.done: 9 | @echo Testing $* 10 | @mkdir -p $(basename $@) 11 | $(QUIET)$(DMD) -version=Shared -o- -deps=$@ -Isrc -I../../import src/$* 12 | 13 | clean: 14 | rm -rf $(GENERATED) 15 | -------------------------------------------------------------------------------- /test/imports/src/bug18193.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | import core.thread; 3 | -------------------------------------------------------------------------------- /test/init_fini/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=thread_join runtime_args test18996 custom_gc 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/%.done: $(ROOT)/% 9 | @echo Testing $* 10 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 11 | @touch $@ 12 | 13 | $(ROOT)/%: $(SRC)/%.d 14 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 15 | 16 | clean: 17 | rm -rf $(ROOT) 18 | -------------------------------------------------------------------------------- /test/init_fini/src/runtime_args.d: -------------------------------------------------------------------------------- 1 | // Bugzilla 11149 - Runtime.args no longer available in static constructors 2 | import core.runtime; 3 | 4 | shared static this() 5 | { 6 | assert(Runtime.cArgs.argc > 0); 7 | assert(Runtime.cArgs.argv !is null); 8 | assert(Runtime.args.length > 0); 9 | } 10 | 11 | void main() 12 | { 13 | } 14 | -------------------------------------------------------------------------------- /test/init_fini/src/test18996.d: -------------------------------------------------------------------------------- 1 | // Issue https://issues.dlang.org/show_bug.cgi?id=18996 2 | // Array!string calls removeRange without first adding the range, but never 3 | // initializes the GC. The behavior of the default GC is to ignore removing 4 | // ranges when the range wasn't added. The ProtoGC originally would crash when 5 | // this happened. 6 | 7 | import core.memory; 8 | 9 | void main() 10 | { 11 | GC.removeRange(null); 12 | GC.removeRoot(null); 13 | } 14 | -------------------------------------------------------------------------------- /test/init_fini/src/thread_join.d: -------------------------------------------------------------------------------- 1 | // Bugzilla 11309 - std.concurrency: OwnerTerminated message doesn't work 2 | // We need to assure that the thread dtors of parent threads run before the thread dtors of the child threads. 3 | import core.thread, core.sync.semaphore; 4 | import core.stdc.stdio; 5 | 6 | __gshared Semaphore sem; 7 | 8 | static ~this() 9 | { 10 | if (sem !is null) sem.notify(); 11 | } 12 | 13 | void main() 14 | { 15 | sem = new Semaphore; 16 | auto thr = new Thread({assert(sem.wait(1.seconds));}); 17 | thr.start(); 18 | } 19 | -------------------------------------------------------------------------------- /test/init_fini/win64.mak: -------------------------------------------------------------------------------- 1 | # built from the druntime top-level folder 2 | # to be overwritten by caller 3 | DMD=dmd 4 | MODEL=64 5 | DRUNTIMELIB=druntime64.lib 6 | 7 | test: custom_gc 8 | 9 | custom_gc: 10 | $(DMD) -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) test\init_fini\src\custom_gc.d 11 | custom_gc.exe 12 | del custom_gc.exe custom_gc.obj 13 | 14 | -------------------------------------------------------------------------------- /test/lifetime/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=large_aggregate_destroy_21097 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/%.done: $(ROOT)/% 9 | @echo Testing $* 10 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 11 | @touch $@ 12 | 13 | $(ROOT)/%: $(SRC)/%.d 14 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 15 | 16 | clean: 17 | rm -rf $(ROOT) 18 | -------------------------------------------------------------------------------- /test/nogc.d: -------------------------------------------------------------------------------- 1 | extern(C) __gshared string[] rt_options = [ "gcopt=gc:non-existing" ]; 2 | 3 | void main() @nogc 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /test/profile/bothgc.log.exp: -------------------------------------------------------------------------------- 1 | bytes allocated, allocations, type, function, file:line 2 | 16000 1000 both.Num both.foo src/both.d:15 3 | -------------------------------------------------------------------------------- /test/profile/bothnew.def.exp: -------------------------------------------------------------------------------- 1 | 2 | FUNCTIONS 3 | _Dmain 4 | _D4both3fooFkZPSQo3Num 5 | _D4both3Num6__ctorMFNckZSQxQu 6 | -------------------------------------------------------------------------------- /test/profile/myprofilegc.log.freebsd.32.exp: -------------------------------------------------------------------------------- 1 | bytes allocated, allocations, type, function, file:line 2 | 256 1 immutable(char)[][int] D main src/profilegc.d:23 3 | 128 1 float[][] D main src/profilegc.d:18 4 | 128 1 int[][] D main src/profilegc.d:15 5 | 64 1 double[] profilegc.main src/profilegc.d:56 6 | 48 1 float[] D main src/profilegc.d:42 7 | 48 1 int[] D main src/profilegc.d:41 8 | 32 1 void[] profilegc.main src/profilegc.d:55 9 | 16 1 char[] D main src/profilegc.d:34 10 | 16 1 char[] D main src/profilegc.d:36 11 | 16 1 closure profilegc.main.foo src/profilegc.d:45 12 | 16 1 float D main src/profilegc.d:16 13 | 16 1 float[] D main src/profilegc.d:17 14 | 16 1 int D main src/profilegc.d:13 15 | 16 1 int[] D main src/profilegc.d:14 16 | 16 1 int[] D main src/profilegc.d:22 17 | 16 1 int[] D main src/profilegc.d:37 18 | 16 1 profilegc.main.C D main src/profilegc.d:12 19 | 16 1 wchar[] D main src/profilegc.d:35 20 | -------------------------------------------------------------------------------- /test/profile/myprofilegc.log.freebsd.64.exp: -------------------------------------------------------------------------------- 1 | bytes allocated, allocations, type, function, file:line 2 | 464 1 immutable(char)[][int] D main src/profilegc.d:23 3 | 160 1 float[][] D main src/profilegc.d:18 4 | 160 1 int[][] D main src/profilegc.d:15 5 | 64 1 double[] profilegc.main src/profilegc.d:56 6 | 48 1 float[] D main src/profilegc.d:42 7 | 48 1 int[] D main src/profilegc.d:41 8 | 32 1 profilegc.main.C D main src/profilegc.d:12 9 | 32 1 void[] profilegc.main src/profilegc.d:55 10 | 16 1 char[] D main src/profilegc.d:34 11 | 16 1 char[] D main src/profilegc.d:36 12 | 16 1 closure profilegc.main.foo src/profilegc.d:45 13 | 16 1 float D main src/profilegc.d:16 14 | 16 1 float[] D main src/profilegc.d:17 15 | 16 1 int D main src/profilegc.d:13 16 | 16 1 int[] D main src/profilegc.d:14 17 | 16 1 int[] D main src/profilegc.d:22 18 | 16 1 int[] D main src/profilegc.d:37 19 | 16 1 wchar[] D main src/profilegc.d:35 20 | -------------------------------------------------------------------------------- /test/profile/myprofilegc.log.linux.32.exp: -------------------------------------------------------------------------------- 1 | bytes allocated, allocations, type, function, file:line 2 | 256 1 immutable(char)[][int] D main src/profilegc.d:23 3 | 128 1 float[][] D main src/profilegc.d:18 4 | 128 1 int[][] D main src/profilegc.d:15 5 | 64 1 double[] profilegc.main src/profilegc.d:56 6 | 48 1 float[] D main src/profilegc.d:42 7 | 48 1 int[] D main src/profilegc.d:41 8 | 32 1 void[] profilegc.main src/profilegc.d:55 9 | 16 1 char[] D main src/profilegc.d:34 10 | 16 1 char[] D main src/profilegc.d:36 11 | 16 1 closure profilegc.main.foo src/profilegc.d:45 12 | 16 1 float D main src/profilegc.d:16 13 | 16 1 float[] D main src/profilegc.d:17 14 | 16 1 int D main src/profilegc.d:13 15 | 16 1 int[] D main src/profilegc.d:14 16 | 16 1 int[] D main src/profilegc.d:22 17 | 16 1 int[] D main src/profilegc.d:37 18 | 16 1 profilegc.main.C D main src/profilegc.d:12 19 | 16 1 wchar[] D main src/profilegc.d:35 20 | -------------------------------------------------------------------------------- /test/profile/myprofilegc.log.linux.64.exp: -------------------------------------------------------------------------------- 1 | bytes allocated, allocations, type, function, file:line 2 | 464 1 immutable(char)[][int] D main src/profilegc.d:23 3 | 160 1 float[][] D main src/profilegc.d:18 4 | 160 1 int[][] D main src/profilegc.d:15 5 | 64 1 double[] profilegc.main src/profilegc.d:56 6 | 48 1 float[] D main src/profilegc.d:42 7 | 48 1 int[] D main src/profilegc.d:41 8 | 32 1 profilegc.main.C D main src/profilegc.d:12 9 | 32 1 void[] profilegc.main src/profilegc.d:55 10 | 16 1 char[] D main src/profilegc.d:34 11 | 16 1 char[] D main src/profilegc.d:36 12 | 16 1 closure profilegc.main.foo src/profilegc.d:45 13 | 16 1 float D main src/profilegc.d:16 14 | 16 1 float[] D main src/profilegc.d:17 15 | 16 1 int D main src/profilegc.d:13 16 | 16 1 int[] D main src/profilegc.d:14 17 | 16 1 int[] D main src/profilegc.d:22 18 | 16 1 int[] D main src/profilegc.d:37 19 | 16 1 wchar[] D main src/profilegc.d:35 20 | -------------------------------------------------------------------------------- /test/profile/myprofilegc.log.osx.32.exp: -------------------------------------------------------------------------------- 1 | bytes allocated, allocations, type, function, file:line 2 | 176 1 immutable(char)[][int] D main src/profilegc.d:23 3 | 128 1 float[][] D main src/profilegc.d:18 4 | 128 1 int[][] D main src/profilegc.d:15 5 | 64 1 float[] D main src/profilegc.d:42 6 | 64 1 int[] D main src/profilegc.d:41 7 | 64 1 double[] profilegc.main src/profilegc.d:56 8 | 32 1 void[] profilegc.main src/profilegc.d:55 9 | 16 1 char[] D main src/profilegc.d:34 10 | 16 1 char[] D main src/profilegc.d:36 11 | 16 1 closure profilegc.main.foo src/profilegc.d:45 12 | 16 1 float D main src/profilegc.d:16 13 | 16 1 float[] D main src/profilegc.d:17 14 | 16 1 int D main src/profilegc.d:13 15 | 16 1 int[] D main src/profilegc.d:14 16 | 16 1 int[] D main src/profilegc.d:22 17 | 16 1 int[] D main src/profilegc.d:37 18 | 16 1 profilegc.main.C D main src/profilegc.d:12 19 | 16 1 wchar[] D main src/profilegc.d:35 20 | -------------------------------------------------------------------------------- /test/profile/myprofilegc.log.osx.64.exp: -------------------------------------------------------------------------------- 1 | bytes allocated, allocations, type, function, file:line 2 | 464 1 immutable(char)[][int] D main src/profilegc.d:23 3 | 160 1 float[][] D main src/profilegc.d:18 4 | 160 1 int[][] D main src/profilegc.d:15 5 | 64 1 double[] profilegc.main src/profilegc.d:56 6 | 48 1 float[] D main src/profilegc.d:42 7 | 48 1 int[] D main src/profilegc.d:41 8 | 32 1 profilegc.main.C D main src/profilegc.d:12 9 | 32 1 void[] profilegc.main src/profilegc.d:55 10 | 16 1 char[] D main src/profilegc.d:34 11 | 16 1 char[] D main src/profilegc.d:36 12 | 16 1 closure profilegc.main.foo src/profilegc.d:45 13 | 16 1 float D main src/profilegc.d:16 14 | 16 1 float[] D main src/profilegc.d:17 15 | 16 1 int D main src/profilegc.d:13 16 | 16 1 int[] D main src/profilegc.d:14 17 | 16 1 int[] D main src/profilegc.d:22 18 | 16 1 int[] D main src/profilegc.d:37 19 | 16 1 wchar[] D main src/profilegc.d:35 20 | -------------------------------------------------------------------------------- /test/profile/mytrace.def.exp: -------------------------------------------------------------------------------- 1 | 2 | FUNCTIONS 3 | _D4core8internal5array10comparison__T5__cmpTaZQjFNaNbNiNeMxAaMxQeZi 4 | _Dmain 5 | _D4core8internal6string__T7dstrcmpZQjFNaNbNiNeMxAaMxQeZi 6 | _D7profile3fooFkZk 7 | -------------------------------------------------------------------------------- /test/profile/mytrace.releaseopt.def.exp: -------------------------------------------------------------------------------- 1 | 2 | FUNCTIONS 3 | _D4core8internal5array10comparison__T5__cmpTaZQjFNaNbNiNeMxAaMxQeZi 4 | _D4core8internal6string__T7dstrcmpZQjFNaNbNiNeMxAaMxQeZi 5 | _Dmain 6 | _D7profile3fooFkZk 7 | -------------------------------------------------------------------------------- /test/profile/src/both.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | struct Num 4 | { 5 | pragma(inline, false) this(uint val) 6 | { 7 | this.val = val; 8 | } 9 | 10 | uint val; 11 | } 12 | 13 | pragma(inline, false) Num* foo(uint val) 14 | { 15 | return new Num(val); 16 | } 17 | 18 | __gshared uint sum; 19 | 20 | void main(string[] args) 21 | { 22 | trace_setlogfilename(args[1]); 23 | trace_setdeffilename(args[2]); 24 | profilegc_setlogfilename(args[3]); 25 | foreach (uint i; 0 .. 1_000) 26 | sum += foo(i).val; 27 | } 28 | -------------------------------------------------------------------------------- /test/profile/src/profile.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | pragma(inline, false) uint foo(uint val) 4 | { 5 | return val * 2; 6 | } 7 | 8 | __gshared uint sum; 9 | 10 | void main(string[] args) 11 | { 12 | trace_setlogfilename(args[1]); 13 | trace_setdeffilename(args[2]); 14 | foreach (uint i; 0 .. 1_000) 15 | sum += foo(i); 16 | 17 | // Issue 19593 18 | assert(!("aaa" >= "bbb")); 19 | assert("aaa" <= "bbb"); 20 | } 21 | -------------------------------------------------------------------------------- /test/profile/src/profilegc.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | void main(string[] args) 4 | { 5 | profilegc_setlogfilename(args[1]); 6 | 7 | struct S { ~this() { } } 8 | class C { } 9 | interface I { } 10 | 11 | { 12 | auto a = new C(); 13 | auto b = new int; 14 | auto c = new int[3]; 15 | auto d = new int[][](3,4); 16 | auto e = new float; 17 | auto f = new float[3]; 18 | auto g = new float[][](3,4); 19 | } 20 | 21 | { 22 | int[] a = [1, 2, 3]; 23 | string[int] aa = [1:"one", 2:"two", 3:"three"]; 24 | } 25 | 26 | { 27 | int[] a, b, c; 28 | c = a ~ b; 29 | c = a ~ b ~ c; 30 | } 31 | 32 | { 33 | dchar dc = 'a'; 34 | char[] ac; ac ~= dc; 35 | wchar[] aw; aw ~= dc; 36 | char[] ac2; ac2 ~= ac; 37 | int[] ai; ai ~= 3; 38 | } 39 | 40 | { 41 | int[] ai; ai.length = 10; 42 | float[] af; af.length = 10; 43 | } 44 | 45 | auto foo ( ) 46 | { 47 | int v = 42; 48 | return { return v; }; 49 | } 50 | 51 | auto x = foo()(); 52 | 53 | { 54 | import core.memory : GC; 55 | void* p = GC.malloc(32); 56 | p = GC.realloc(p, 64, 0, typeid(double[])); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /test/shared/.gitignore: -------------------------------------------------------------------------------- 1 | obj 2 | -------------------------------------------------------------------------------- /test/shared/src/dllrefcount.d: -------------------------------------------------------------------------------- 1 | 2 | import core.sys.windows.dll; 3 | import core.runtime; 4 | 5 | void main() 6 | { 7 | auto kernel32 = Runtime.loadLibrary("kernel32.dll"); 8 | assert(kernel32); 9 | int refcnt = dll_getRefCount(kernel32); 10 | assert(refcnt == -1); 11 | 12 | auto imagehlp = Runtime.loadLibrary("imagehlp.dll"); 13 | assert(imagehlp); 14 | refcnt = dll_getRefCount(imagehlp); 15 | assert(refcnt == 1); 16 | 17 | Runtime.unloadLibrary(imagehlp); 18 | refcnt = dll_getRefCount(imagehlp); 19 | assert(refcnt == -2); 20 | } 21 | -------------------------------------------------------------------------------- /test/shared/src/lib_13414.d: -------------------------------------------------------------------------------- 1 | shared void function() sharedStaticDtorHook; 2 | shared void function() staticDtorHook; 3 | shared static ~this() { sharedStaticDtorHook(); } 4 | static ~this() { staticDtorHook(); } 5 | -------------------------------------------------------------------------------- /test/shared/src/liblinkdep.d: -------------------------------------------------------------------------------- 1 | import lib; 2 | 3 | extern(C) int runDepTests() 4 | { 5 | return runTests(); 6 | } 7 | -------------------------------------------------------------------------------- /test/shared/src/libloaddep.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | extern(C) alias RunTests = int function(); 4 | 5 | extern(C) int runDepTests(const char* name) 6 | { 7 | import utils : loadSym; 8 | 9 | auto h = rt_loadLibrary(name); 10 | if (h is null) return false; 11 | RunTests runTests; 12 | loadSym(h, runTests, "runTests"); 13 | assert(runTests !is null); 14 | if (!runTests()) return false; 15 | return rt_unloadLibrary(h); 16 | } 17 | -------------------------------------------------------------------------------- /test/shared/src/linkD.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern int runTests(void); 5 | extern int lib_init(void); 6 | extern int lib_term(void); 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | if (!lib_init()) return EXIT_SUCCESS; 11 | const int res = runTests() ? EXIT_SUCCESS : EXIT_FAILURE; 12 | if (!lib_term()) return EXIT_FAILURE; 13 | return res; 14 | } 15 | -------------------------------------------------------------------------------- /test/shared/src/linkDR.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "utils.h" 5 | 6 | extern void* rt_loadLibrary(const char*); 7 | extern int rt_unloadLibrary(void*); 8 | extern int rt_init(void); 9 | extern int rt_term(void); 10 | 11 | int main(int argc, char* argv[]) 12 | { 13 | if (!rt_init()) return EXIT_FAILURE; 14 | const size_t pathlen = strrchr(argv[0], '/') - argv[0] + 1; 15 | char *name = malloc(pathlen + sizeof(LIB_SO)); 16 | memcpy(name, argv[0], pathlen); 17 | memcpy(name+pathlen, LIB_SO, sizeof(LIB_SO)); 18 | 19 | void *dlib = rt_loadLibrary(name); 20 | free(name); 21 | assert(dlib); 22 | 23 | int (*runTests)(void) = loadSym(dlib, "runTests"); 24 | assert(runTests()); 25 | assert(rt_unloadLibrary(dlib)); 26 | if (!rt_term()) return EXIT_FAILURE; 27 | return EXIT_SUCCESS; 28 | } 29 | -------------------------------------------------------------------------------- /test/shared/src/link_linkdep.d: -------------------------------------------------------------------------------- 1 | import liblinkdep; 2 | 3 | void main() 4 | { 5 | runDepTests(); 6 | } 7 | -------------------------------------------------------------------------------- /test/shared/src/link_loaddep.d: -------------------------------------------------------------------------------- 1 | import libloaddep; 2 | 3 | void main(string[] args) 4 | { 5 | import utils : dllExt; 6 | auto libname = args[0][0..$-"link_loaddep".length] ~ "lib." ~ dllExt ~ "\0"; 7 | runDepTests(libname.ptr); 8 | } 9 | -------------------------------------------------------------------------------- /test/shared/src/loadDR.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "utils.h" 5 | 6 | int main(int argc, char* argv[]) 7 | { 8 | if (argc != 2) 9 | return EXIT_FAILURE; 10 | void *h = loadLib(argv[1]); // load druntime 11 | assert(h != NULL); 12 | 13 | int (*rt_init)(void) = loadSym(h, "rt_init"); 14 | int (*rt_term)(void) = loadSym(h, "rt_term"); 15 | void* (*rt_loadLibrary)(const char*) = loadSym(h, "rt_loadLibrary"); 16 | int (*rt_unloadLibrary)(void*) = loadSym(h, "rt_unloadLibrary"); 17 | 18 | int res = EXIT_FAILURE; 19 | if (!rt_init()) goto Lexit; 20 | 21 | const size_t pathlen = strrchr(argv[0], '/') - argv[0] + 1; 22 | char *name = malloc(pathlen + sizeof(LIB_SO)); 23 | memcpy(name, argv[0], pathlen); 24 | memcpy(name+pathlen, LIB_SO, sizeof(LIB_SO)); 25 | 26 | void *dlib = rt_loadLibrary(name); 27 | free(name); 28 | assert(dlib); 29 | 30 | int (*runTests)(void) = loadSym(dlib, "runTests"); 31 | assert(runTests()); 32 | assert(rt_unloadLibrary(dlib)); 33 | 34 | if (rt_term()) res = EXIT_SUCCESS; 35 | 36 | Lexit: 37 | assert(closeLib(h)); 38 | return res; 39 | } 40 | -------------------------------------------------------------------------------- /test/shared/src/load_linkdep.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | import core.stdc.string; 3 | 4 | extern(C) alias RunDepTests = int function(); 5 | 6 | void main(string[] args) 7 | { 8 | import utils : dllExt, loadSym; 9 | 10 | auto name = args[0] ~ '\0'; 11 | const pathlen = strrchr(name.ptr, '/') - name.ptr + 1; 12 | name = name[0 .. pathlen] ~ "liblinkdep." ~ dllExt; 13 | 14 | auto h = Runtime.loadLibrary(name); 15 | assert(h); 16 | RunDepTests runDepTests; 17 | loadSym(h, runDepTests, "runDepTests"); 18 | assert(runDepTests()); 19 | assert(Runtime.unloadLibrary(h)); 20 | } 21 | -------------------------------------------------------------------------------- /test/shared/src/load_loaddep.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | import core.stdc.string; 3 | 4 | extern(C) alias RunDepTests = int function(const char*); 5 | 6 | void main(string[] args) 7 | { 8 | import utils : dllExt, loadSym; 9 | 10 | auto name = args[0] ~ '\0'; 11 | const pathlen = strrchr(name.ptr, '/') - name.ptr + 1; 12 | auto root = name[0 .. pathlen]; 13 | auto libloaddep = root ~ "libloaddep." ~ dllExt; 14 | auto h = Runtime.loadLibrary(libloaddep); 15 | RunDepTests runDepTests; 16 | loadSym(h, runDepTests, "runDepTests"); 17 | assert(runDepTests((root ~ "lib." ~ dllExt ~ "\0").ptr)); 18 | assert(Runtime.unloadLibrary(h)); 19 | } 20 | -------------------------------------------------------------------------------- /test/shared/src/loadlibwin.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=19498 2 | void main() 3 | { 4 | import core.runtime; 5 | auto kernel32 = Runtime.loadLibrary("kernel32.dll"); 6 | assert(kernel32); 7 | Runtime.unloadLibrary(kernel32); 8 | } 9 | -------------------------------------------------------------------------------- /test/shared/src/utils.di: -------------------------------------------------------------------------------- 1 | module utils; 2 | 3 | version (Windows) 4 | enum dllExt = "dll"; 5 | else 6 | enum dllExt = "so"; 7 | 8 | void loadSym(T)(void* handle, ref T val, const char* mangle) 9 | { 10 | version (Windows) 11 | { 12 | import core.sys.windows.winbase : GetProcAddress; 13 | val = cast(T) GetProcAddress(handle, mangle); 14 | } 15 | else 16 | { 17 | import core.sys.posix.dlfcn : dlsym; 18 | val = cast(T) dlsym(handle, mangle); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/shared/src/utils.h: -------------------------------------------------------------------------------- 1 | #ifdef _WIN32 2 | 3 | #include 4 | 5 | #define LIB_SO "lib.dll" 6 | 7 | void *loadLib(const char *name) { return LoadLibraryA(name); } 8 | int closeLib(void *handle) { return FreeLibrary(handle); } 9 | void *loadSym(void *handle, const char *name) { return GetProcAddress(handle, name); } 10 | 11 | #else 12 | 13 | #include 14 | 15 | #define LIB_SO "lib.so" 16 | 17 | void *loadLib(const char *name) { return dlopen(name, RTLD_LAZY); } 18 | int closeLib(void *handle) { return dlclose(handle) == 0 ? 1 : 0; } 19 | void *loadSym(void *handle, const char *name) { return dlsym(handle, name); } 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /test/shared/win64.mak: -------------------------------------------------------------------------------- 1 | # built from the druntime top-level folder 2 | # to be overwritten by caller 3 | DMD=dmd 4 | MODEL=64 5 | DRUNTIMELIB=druntime64.lib 6 | 7 | test: loadlibwin dllrefcount dllgc dynamiccast 8 | 9 | dllrefcount: 10 | $(DMD) -g -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) test\shared\src\dllrefcount.d 11 | dllrefcount.exe 12 | del dllrefcount.exe dllrefcount.obj 13 | 14 | loadlibwin: 15 | $(DMD) -g -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) test\shared\src\loadlibwin.d 16 | loadlibwin.exe 17 | del loadlibwin.exe loadlibwin.obj 18 | 19 | dllgc: 20 | $(DMD) -g -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -version=DLL -shared -ofdllgc.dll test\shared\src\dllgc.d 21 | $(DMD) -g -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -ofloaddllgc.exe test\shared\src\dllgc.d 22 | loaddllgc.exe 23 | del loaddllgc.exe loaddllgc.obj dllgc.dll dllgc.obj 24 | 25 | dynamiccast: 26 | $(DMD) -g -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -version=DLL -shared -ofdynamiccast.dll test\shared\src\dynamiccast.d 27 | $(DMD) -g -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -ofdynamiccast.exe test\shared\src\dynamiccast.d 28 | dynamiccast.exe 29 | cmd /c "if not exist dynamiccast_endbar exit 1" 30 | cmd /c "if not exist dynamiccast_endmain exit 1" 31 | del dynamiccast.exe dynamiccast.dll dynamiccast.obj dynamiccast_endbar dynamiccast_endmain 32 | -------------------------------------------------------------------------------- /test/stdcpp/src/allocator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct MyStruct 4 | { 5 | int *a; 6 | double *b; 7 | MyStruct *c; 8 | }; 9 | 10 | MyStruct cpp_alloc(int sz) 11 | { 12 | MyStruct r; 13 | r.a = std::allocator().allocate(sz); 14 | r.b = std::allocator().allocate(sz); 15 | r.c = std::allocator().allocate(sz); 16 | return r; 17 | } 18 | 19 | void cpp_free(MyStruct& s, int sz) 20 | { 21 | std::allocator().deallocate(s.a, sz); 22 | std::allocator().deallocate(s.b, sz); 23 | std::allocator().deallocate(s.c, sz); 24 | } 25 | -------------------------------------------------------------------------------- /test/stdcpp/src/allocator_test.d: -------------------------------------------------------------------------------- 1 | import core.stdcpp.allocator; 2 | 3 | extern(C++) struct MyStruct 4 | { 5 | int* a; 6 | double* b; 7 | MyStruct* c; 8 | } 9 | 10 | extern(C++) MyStruct cpp_alloc(int sz); 11 | extern(C++) void cpp_free(ref MyStruct s, int sz); 12 | 13 | unittest 14 | { 15 | // alloc in C++, delete in D (small) 16 | MyStruct s = cpp_alloc(42); 17 | allocator!int().deallocate(s.a, 42); 18 | allocator!double().deallocate(s.b, 42); 19 | allocator!MyStruct().deallocate(s.c, 42); 20 | 21 | // alloc in C++, delete in D (big) 22 | s = cpp_alloc(8193); 23 | allocator!int().deallocate(s.a, 8193); 24 | allocator!double().deallocate(s.b, 8193); 25 | allocator!MyStruct().deallocate(s.c, 8193); 26 | 27 | // alloc in D, delete in C++ (small) 28 | s.a = allocator!int().allocate(43); 29 | s.b = allocator!double().allocate(43); 30 | s.c = allocator!MyStruct().allocate(43); 31 | cpp_free(s, 43); 32 | 33 | // alloc in D, delete in C++ (big) 34 | s.a = allocator!int().allocate(8194); 35 | s.b = allocator!double().allocate(8194); 36 | s.c = allocator!MyStruct().allocate(8194); 37 | cpp_free(s, 8194); 38 | } 39 | -------------------------------------------------------------------------------- /test/stdcpp/src/array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::array fromC_val(std::array); 4 | std::array& fromC_ref(std::array&); 5 | 6 | std::array& sumOfElements_ref(std::array& arr) 7 | { 8 | int r = 0; 9 | for (std::size_t i = 0; i < arr.size(); ++i) 10 | r += arr[i]; 11 | arr.fill(r); 12 | return arr; 13 | } 14 | 15 | std::array sumOfElements_val(std::array arr) 16 | { 17 | int r = sumOfElements_ref(arr)[0] + fromC_ref(arr)[0] + fromC_val(arr)[0]; 18 | arr.fill(r); 19 | return arr; 20 | } 21 | -------------------------------------------------------------------------------- /test/stdcpp/src/exception.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void throw_exception() 4 | { 5 | throw std::exception(); 6 | } 7 | 8 | void throw_bad_exception() 9 | { 10 | throw std::bad_exception(); 11 | } 12 | 13 | class custom_exception : public std::exception 14 | { 15 | const char* what() const noexcept { return "custom_exception"; } 16 | }; 17 | 18 | void throw_custom_exception() 19 | { 20 | throw custom_exception(); 21 | } 22 | -------------------------------------------------------------------------------- /test/stdcpp/src/exception_test.d: -------------------------------------------------------------------------------- 1 | import core.stdc.string; 2 | import core.stdcpp.exception; 3 | 4 | unittest 5 | { 6 | try 7 | { 8 | throw_exception(); 9 | } 10 | catch (exception e) 11 | { 12 | const what = e.what(); 13 | assert(!strcmp(what, "unknown") || // druntime override 14 | !strcmp(what, "std::exception")); 15 | } 16 | try 17 | { 18 | throw_bad_exception(); 19 | } 20 | catch (exception e) 21 | { 22 | const what = e.what(); 23 | assert(!strcmp(what, "bad exception") || // druntime override 24 | !strcmp(what, "std::bad_exception")); 25 | } 26 | try 27 | { 28 | throw_custom_exception(); 29 | } 30 | catch (exception e) 31 | { 32 | assert(!strcmp(e.what(), "custom_exception")); 33 | } 34 | } 35 | 36 | extern(C++): 37 | void throw_exception(); 38 | void throw_bad_exception(); 39 | void throw_custom_exception(); 40 | -------------------------------------------------------------------------------- /test/stdcpp/src/memory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::unique_ptr passThrough(std::unique_ptr x) 4 | { 5 | return std::move(x); 6 | } 7 | std::unique_ptr changeIt(std::unique_ptr x) 8 | { 9 | auto p = new int(20); // ensure new pointer is different from released pointer 10 | x.reset(); 11 | return std::unique_ptr(p); 12 | } 13 | -------------------------------------------------------------------------------- /test/stdcpp/src/memory_test.d: -------------------------------------------------------------------------------- 1 | import core.stdcpp.memory; 2 | 3 | unittest 4 | { 5 | import core.lifetime : move; 6 | 7 | unique_ptr!int up; 8 | assert(!up); 9 | assert(up.get == null); 10 | 11 | auto up2 = make_unique!int(10); 12 | assert(!!up2); 13 | assert(up2.get != null); 14 | assert(*up2.get == 10); 15 | 16 | static assert(!__traits(compiles, up = up2)); 17 | static assert(!__traits(compiles, unique_ptr!int(up))); 18 | 19 | unique_ptr!int x = up2.move; 20 | assert(!!x && !up2); 21 | 22 | up = x.move; 23 | assert(!!up && !x); 24 | 25 | int* p = up.get; 26 | up = passThrough(up.move); 27 | assert(up.get == p); 28 | up = changeIt(up.move); 29 | assert(up.get != p); 30 | assert(*up.get == 20); 31 | 32 | up.reset(); 33 | assert(!up); 34 | } 35 | 36 | extern(C++): 37 | 38 | unique_ptr!int passThrough(unique_ptr!int x); 39 | unique_ptr!int changeIt(unique_ptr!int x); 40 | -------------------------------------------------------------------------------- /test/stdcpp/src/new.cpp: -------------------------------------------------------------------------------- 1 | #include // for size_t? 2 | #include 3 | 4 | struct MyStruct 5 | { 6 | int *a; 7 | double *b; 8 | MyStruct *c; 9 | }; 10 | 11 | MyStruct cpp_new() 12 | { 13 | MyStruct r; 14 | r.a = (int*)::operator new(sizeof(int)); 15 | r.b = (double*)::operator new(sizeof(double)); 16 | r.c = (MyStruct*)::operator new(sizeof(MyStruct)); 17 | return r; 18 | } 19 | 20 | void cpp_delete(MyStruct& s) 21 | { 22 | ::operator delete(s.a); 23 | ::operator delete(s.b); 24 | ::operator delete(s.c); 25 | } 26 | 27 | size_t defaultAlignment() 28 | { 29 | #if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__) 30 | return __STDCPP_DEFAULT_NEW_ALIGNMENT__; 31 | #else 32 | return 0; 33 | #endif 34 | } 35 | 36 | bool hasAlignedNew() 37 | { 38 | #if defined(__cpp_aligned_new) 39 | return !!__cpp_aligned_new; 40 | #else 41 | return false; 42 | #endif 43 | } 44 | -------------------------------------------------------------------------------- /test/stdcpp/src/string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fromC_val(std::string); 4 | int fromC_ref(const std::string&); 5 | 6 | int sumOfElements_ref(const std::string& str) 7 | { 8 | int r = 0; 9 | for (size_t i = 0; i < str.size(); ++i) 10 | r += str[i]; 11 | return r; 12 | } 13 | 14 | int sumOfElements_val(std::string str) 15 | { 16 | return sumOfElements_ref(str) + fromC_ref(str) + fromC_val(str); 17 | } 18 | -------------------------------------------------------------------------------- /test/stdcpp/src/string_view.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fromC_val(std::string_view); 4 | int fromC_ref(const std::string_view&); 5 | 6 | int sumOfElements_ref(const std::string_view& str) 7 | { 8 | int r = 0; 9 | for (std::size_t i = 0; i < str.size(); ++i) 10 | r += str[i]; 11 | return r; 12 | } 13 | 14 | int sumOfElements_val(std::string_view str) 15 | { 16 | return sumOfElements_ref(str) + fromC_ref(str) + fromC_val(str); 17 | } 18 | -------------------------------------------------------------------------------- /test/stdcpp/src/string_view_test.d: -------------------------------------------------------------------------------- 1 | import core.stdcpp.string_view; 2 | 3 | unittest 4 | { 5 | string_view str = string_view("Hello"); 6 | 7 | assert(str.size == 5); 8 | assert(str.length == 5); 9 | assert(str.empty == false); 10 | 11 | assert(sumOfElements_val(str) == 1500); 12 | assert(sumOfElements_ref(str) == 500); 13 | 14 | string_view str2 = string_view(); 15 | assert(str2.size == 0); 16 | assert(str2.length == 0); 17 | assert(str2.empty == true); 18 | assert(str2[] == []); 19 | } 20 | 21 | 22 | extern(C++): 23 | 24 | // test the ABI for calls to C++ 25 | int sumOfElements_val(string_view); 26 | int sumOfElements_ref(ref const(string_view)); 27 | 28 | // test the ABI for calls from C++ 29 | int fromC_val(string_view str) 30 | { 31 | assert(str[] == "Hello"); 32 | assert(str.front == 'H'); 33 | assert(str.back == 'o'); 34 | assert(str.at(2) == 'l'); 35 | 36 | int r; 37 | foreach (e; str) 38 | r += e; 39 | 40 | assert(r == 500); 41 | return r; 42 | } 43 | 44 | int fromC_ref(ref const(string_view) str) 45 | { 46 | int r; 47 | foreach (e; str) 48 | r += e; 49 | return r; 50 | } 51 | -------------------------------------------------------------------------------- /test/stdcpp/src/typeinfo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void throw_bad_cast() 4 | { 5 | throw std::bad_cast(); 6 | } 7 | 8 | void throw_bad_typeid() 9 | { 10 | throw std::bad_typeid(); 11 | } 12 | 13 | const std::type_info& typeid_int() 14 | { 15 | return typeid(int); 16 | } 17 | 18 | const std::type_info& typeid_double() 19 | { 20 | return typeid(double); 21 | } 22 | 23 | class Toil { }; 24 | 25 | const std::type_info& typeid_toil() 26 | { 27 | return typeid(Toil); 28 | } 29 | 30 | const std::type_info& typeid_const_toil() 31 | { 32 | return typeid(const Toil&); 33 | } 34 | 35 | class Trouble { }; 36 | 37 | const std::type_info& typeid_trouble() 38 | { 39 | return typeid(Trouble); 40 | } 41 | -------------------------------------------------------------------------------- /test/stdcpp/src/utility.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern int opt_pairRefCount; 5 | 6 | struct Elaborate 7 | { 8 | bool valid; 9 | int buffer[16]; 10 | 11 | Elaborate(const Elaborate& rh) 12 | { 13 | valid = rh.valid; 14 | if (rh.valid) 15 | { 16 | ++opt_pairRefCount; 17 | for (size_t i = 0; i < 16; ++i) 18 | buffer[i] = rh.buffer[i]; 19 | } 20 | } 21 | ~Elaborate() 22 | { 23 | if (valid) 24 | --opt_pairRefCount; 25 | } 26 | }; 27 | 28 | typedef std::pair SimplePair; 29 | typedef std::pair ElaboratePair; 30 | 31 | 32 | int fromC_val(SimplePair, SimplePair&, ElaboratePair, ElaboratePair&); 33 | 34 | int callC_val(SimplePair a1, SimplePair& a2, ElaboratePair a3, ElaboratePair& a4) 35 | { 36 | return fromC_val(a1, a2, a3, a4); 37 | } 38 | -------------------------------------------------------------------------------- /test/thread/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=tlsgc_sections test_import tlsstack join_detach 4 | # LDC: disable POSIX-specific tests on Windows 5 | ifeq (,$(findstring win,$(OS))) 6 | TESTS+=fiber_guard_page external_threads 7 | endif 8 | 9 | .PHONY: all clean 10 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 11 | 12 | # segfault || bus error (OSX) 13 | $(ROOT)/fiber_guard_page.done: $(ROOT)/%.done : $(ROOT)/% 14 | @echo Testing $* 15 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS); rc=$$?; [ $$rc -eq 139 ] || [ $$rc -eq 138 ] 16 | @touch $@ 17 | 18 | $(ROOT)/external_threads.done: $(ROOT)/%.done : $(ROOT)/% 19 | @echo Testing $* 20 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* 21 | @touch $@ 22 | 23 | $(ROOT)/tlsgc_sections.done: $(ROOT)/%.done : $(ROOT)/% 24 | @echo Testing $* 25 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* 26 | @touch $@ 27 | 28 | $(ROOT)/test_import.done: $(ROOT)/%.done : $(ROOT)/% 29 | @echo Testing $* 30 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* 31 | @touch $@ 32 | 33 | $(ROOT)/tlsstack.done: $(ROOT)/%.done : $(ROOT)/% 34 | @echo Testing $* 35 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* 36 | @touch $@ 37 | 38 | $(ROOT)/join_detach.done: $(ROOT)/%.done : $(ROOT)/% 39 | @echo Testing $* is currently disabled! 40 | 41 | $(ROOT)/%: $(SRC)/%.d 42 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 43 | 44 | clean: 45 | rm -rf $(GENERATED) 46 | -------------------------------------------------------------------------------- /test/thread/src/external_threads.d: -------------------------------------------------------------------------------- 1 | import core.sys.posix.pthread; 2 | import core.memory; 3 | import core.thread; 4 | 5 | extern (C) void rt_moduleTlsCtor(); 6 | extern (C) void rt_moduleTlsDtor(); 7 | 8 | extern(C) 9 | void* entry_point1(void*) 10 | { 11 | // try collecting - GC must ignore this call because this thread 12 | // is not registered in runtime 13 | GC.collect(); 14 | return null; 15 | } 16 | 17 | extern(C) 18 | void* entry_point2(void*) 19 | { 20 | // This thread gets registered in druntime, does some work and gets 21 | // unregistered to be cleaned up manually 22 | thread_attachThis(); 23 | rt_moduleTlsCtor(); 24 | 25 | auto x = new int[10]; 26 | 27 | rt_moduleTlsDtor(); 28 | thread_detachThis(); 29 | return null; 30 | } 31 | 32 | void main() 33 | { 34 | // allocate some garbage 35 | auto x = new int[1000]; 36 | 37 | { 38 | pthread_t thread; 39 | auto status = pthread_create(&thread, null, &entry_point1, null); 40 | assert(status == 0); 41 | pthread_join(thread, null); 42 | } 43 | 44 | { 45 | pthread_t thread; 46 | auto status = pthread_create(&thread, null, &entry_point2, null); 47 | assert(status == 0); 48 | pthread_join(thread, null); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/thread/src/join_detach.d: -------------------------------------------------------------------------------- 1 | import core.thread; 2 | import core.sync.semaphore; 3 | 4 | __gshared Semaphore sem; 5 | 6 | void thread_main () 7 | { 8 | sem.notify(); 9 | } 10 | 11 | void main() 12 | { 13 | auto th = new Thread(&thread_main); 14 | sem = new Semaphore(); 15 | th.start(); 16 | sem.wait(); 17 | while (th.isRunning()) {} 18 | destroy(th); // force detach 19 | th.join(); 20 | } 21 | -------------------------------------------------------------------------------- /test/thread/src/test_import.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=20447 2 | void main() 3 | { 4 | import core.thread; 5 | int[] x; 6 | auto b = x.dup; 7 | } 8 | -------------------------------------------------------------------------------- /test/thread/src/tlsstack.d: -------------------------------------------------------------------------------- 1 | module core.thread.test; // needs access to getStackTop()/getStackBottom() 2 | 3 | import core.stdc.stdio; 4 | import core.thread; 5 | 6 | ubyte[16384] data; 7 | 8 | void showThreadInfo() nothrow 9 | { 10 | try 11 | { 12 | auto top = getStackTop(); 13 | auto bottom = getStackBottom(); 14 | printf("tlsdata: %p\n", data.ptr); 15 | printf("stack top: %p\n", getStackTop()); 16 | printf("stack bottom:%p\n", getStackBottom()); 17 | printf("used stack: %lld\n", cast(ulong)(bottom - top)); 18 | } 19 | catch(Exception e) 20 | { 21 | assert(false, e.msg); 22 | } 23 | } 24 | 25 | void main() 26 | { 27 | printf("### main\n"); 28 | showThreadInfo(); 29 | 30 | printf("### thread\n"); 31 | auto th = new Thread(&showThreadInfo, 16384); 32 | th.start(); 33 | th.join(); 34 | 35 | printf("### lowlevel thread\n"); 36 | auto llth = createLowLevelThread(() { showThreadInfo(); }); 37 | joinLowLevelThread(llth); 38 | } 39 | -------------------------------------------------------------------------------- /test/traits/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=all_satisfy 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/%.done: $(ROOT)/% 9 | @echo Testing $* 10 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 11 | @touch $@ 12 | 13 | $(ROOT)/%: $(SRC)/%.d 14 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 15 | 16 | clean: 17 | rm -rf $(ROOT) 18 | -------------------------------------------------------------------------------- /test/traits/src/all_satisfy.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=22210 2 | 3 | import core.internal.traits : allSatisfy; 4 | 5 | enum isHashable(T) = __traits(compiles, 6 | () { T.init; } 7 | ); 8 | 9 | class A 10 | { 11 | static if (isHashable!B) {} 12 | } 13 | 14 | class B 15 | { 16 | static if (isHashable!C) {} 17 | } 18 | 19 | class C 20 | { 21 | static if (allSatisfy!(isHashable, int, B)) {} 22 | } 23 | 24 | void main() {} 25 | -------------------------------------------------------------------------------- /test/typeinfo/Makefile: -------------------------------------------------------------------------------- 1 | include ../common.mak 2 | 3 | TESTS:=comparison isbaseof enum_ 4 | 5 | .PHONY: all clean 6 | all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) 7 | 8 | $(ROOT)/%.done: $(ROOT)/% 9 | @echo Testing $* 10 | $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 11 | @touch $@ 12 | 13 | $(ROOT)/%: $(SRC)/%.d 14 | $(QUIET)$(DMD) $(DFLAGS) -of$@ $< 15 | 16 | clean: 17 | rm -rf $(ROOT) 18 | -------------------------------------------------------------------------------- /test/typeinfo/src/enum_.d: -------------------------------------------------------------------------------- 1 | // https://issues.dlang.org/show_bug.cgi?id=21441 2 | 3 | int dtorCount; 4 | int postblitCount; 5 | 6 | struct S 7 | { 8 | this(this) { ++postblitCount; } 9 | ~this() { ++dtorCount; } 10 | } 11 | 12 | enum E : S { _ = S.init } 13 | 14 | void main() 15 | { 16 | E e; 17 | typeid(e).destroy(&e); 18 | assert(dtorCount == 1); 19 | typeid(e).postblit(&e); 20 | assert(postblitCount == 1); 21 | } 22 | -------------------------------------------------------------------------------- /test/unittest/customhandler.d: -------------------------------------------------------------------------------- 1 | import core.runtime; 2 | 3 | UnitTestResult customModuleUnitTester() 4 | { 5 | version(GoodTests) return UnitTestResult(100, 100, false, true); 6 | version(FailedTests) return UnitTestResult(100, 0, false, true); 7 | version(NoTests) return UnitTestResult(0, 0, true, false); 8 | version(FailNoPrintout) return UnitTestResult(100, 0, false, false); 9 | version(PassNoPrintout) return UnitTestResult(100, 100, false, false); 10 | } 11 | 12 | shared static this() 13 | { 14 | Runtime.extendedModuleUnitTester = &customModuleUnitTester; 15 | } 16 | 17 | void main() 18 | { 19 | import core.stdc.stdio; 20 | fprintf(stderr, "main\n"); 21 | } 22 | -------------------------------------------------------------------------------- /test/uuid/test.d: -------------------------------------------------------------------------------- 1 | // test for duplicate symbols in druntime and uuid.lib 2 | module test; 3 | 4 | version(CRuntime_Microsoft) {} else static assert(false, "Windows/COFF only"); 5 | 6 | import core.sys.windows.basetyps; 7 | import core.sys.windows.uuid; 8 | 9 | extern extern(C) IID IID_IDelayedPropertyStoreFactory; // from uuid.lib 10 | 11 | void main() 12 | { 13 | assert(IID_IDirect3DNullDevice != IID_IDelayedPropertyStoreFactory); 14 | } 15 | -------------------------------------------------------------------------------- /test/uuid/win64.mak: -------------------------------------------------------------------------------- 1 | # built from the druntime top-level folder 2 | # to be overwritten by caller 3 | DMD=dmd 4 | MODEL=64 5 | DRUNTIMELIB=druntime64.lib 6 | 7 | test: 8 | $(DMD) -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) test\uuid\test.d uuid.lib 9 | del test.exe test.obj 10 | 11 | --------------------------------------------------------------------------------