public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/ibuclaw/heads/darwin)] libphobos: Synchronize libdruntime bindings with upstream druntime
@ 2021-01-28 17:31 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-01-28 17:31 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a5fd86abded7e4f94fefc5b142f5dc281c4604b0

commit a5fd86abded7e4f94fefc5b142f5dc281c4604b0
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Thu Jan 28 11:18:42 2021 +0100

    libphobos: Synchronize libdruntime bindings with upstream druntime
    
    Reviewed-on: https://github.com/dlang/druntime/pull/3348
    
    gcc/d/ChangeLog:
    
            * typeinfo.cc (TypeInfoVisitor::visit (TypeInfoDeclaration *)): Don't
            layout m_arg1 and m_arg2 fields.
    
    libphobos/ChangeLog:
    
            * Makefile.in: Regenerate.
            * configure: Regenerate.
            * libdruntime/MERGE: Merge upstream druntime e4aae28e.
            * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Refresh module list.
            (DRUNTIME_DSOURCES_BIONIC): Add core/sys/bionic/err.d.
            (DRUNTIME_DSOURCES_DARWIN): Add core/sys/darwin/err.d,
            core/sys/darwin/ifaddrs.d, core/sys/darwin/mach/nlist.d,
            core/sys/darwin/mach/stab.d, and core/sys/darwin/sys/attr.d.
            (DRUNTIME_DSOURCES_DRAGONFLYBSD): Add core/sys/dragonflybsd/err.d.
            (DRUNTIME_DSOURCES_FREEBSD): Add core/sys/freebsd/err.d.
            (DRUNTIME_DSOURCES_LINUX): Add core/sys/linux/err.d.
            (DRUNTIME_DSOURCES_NETBSD): Add core/sys/netbsd/err.d.
            (DRUNTIME_DSOURCES_OPENBSD): Add core/sys/openbsd/err.d.
            (DRUNTIME_DSOURCES_POSIX): Add core/sys/posix/locale.d,
            core/sys/posix/stdc/time.d, core/sys/posix/string.d, and
            core/sys/posix/strings.d.
            (DRUNTIME_DSOURCES_SOLARIS): Add core/sys/solaris/err.d.
            (DRUNTIME_DSOURCES_WINDOWS): Add core/sys/windows/sdkddkver.d,
            and core/sys/windows/stdc/time.d
            * libdruntime/Makefile.in: Regenerate.
            * libdruntime/gcc/sections/elf_shared.d (sizeofTLS): New function.
            * testsuite/libphobos.thread/fiber_guard_page.d: Use
            __traits(getMember) to get internal fields.

Diff:
---
 gcc/d/typeinfo.cc                                  |   16 -
 libphobos/Makefile.in                              |    2 +-
 libphobos/configure                                |    4 +-
 libphobos/libdruntime/MERGE                        |    2 +-
 libphobos/libdruntime/Makefile.am                  |  157 +-
 libphobos/libdruntime/Makefile.in                  |  393 +-
 libphobos/libdruntime/core/internal/abort.d        |    2 +-
 libphobos/libdruntime/core/stdc/complex.d          |   26 +-
 libphobos/libdruntime/core/stdc/errno.d            |  244 +-
 libphobos/libdruntime/core/stdc/fenv.d             |   22 +-
 libphobos/libdruntime/core/stdc/inttypes.d         |    8 +-
 libphobos/libdruntime/core/stdc/limits.d           |    2 +-
 libphobos/libdruntime/core/stdc/locale.d           |    2 +-
 libphobos/libdruntime/core/stdc/math.d             |  291 +-
 libphobos/libdruntime/core/stdc/stdarg.d           |  713 +--
 libphobos/libdruntime/core/stdc/stdint.d           |    8 +-
 libphobos/libdruntime/core/stdc/stdio.d            |   64 +-
 libphobos/libdruntime/core/stdc/stdlib.d           |    2 +-
 libphobos/libdruntime/core/stdc/string.d           |   58 +-
 libphobos/libdruntime/core/stdc/tgmath.d           |  550 +-
 libphobos/libdruntime/core/stdc/time.d             |  221 +-
 libphobos/libdruntime/core/stdc/wchar_.d           |   86 +-
 libphobos/libdruntime/core/stdc/wctype.d           |    4 +-
 libphobos/libdruntime/core/sys/bionic/err.d        |   23 +
 libphobos/libdruntime/core/sys/darwin/dlfcn.d      |    2 +-
 libphobos/libdruntime/core/sys/darwin/err.d        |   41 +
 libphobos/libdruntime/core/sys/darwin/ifaddrs.d    |   77 +
 libphobos/libdruntime/core/sys/darwin/mach/dyld.d  |    4 +-
 .../libdruntime/core/sys/darwin/mach/getsect.d     |  172 +-
 .../libdruntime/core/sys/darwin/mach/loader.d      |   41 +-
 libphobos/libdruntime/core/sys/darwin/mach/nlist.d |  317 ++
 libphobos/libdruntime/core/sys/darwin/mach/stab.d  |   90 +
 .../libdruntime/core/sys/darwin/netinet/in_.d      |   18 +-
 libphobos/libdruntime/core/sys/darwin/pthread.d    |    8 +-
 libphobos/libdruntime/core/sys/darwin/sys/attr.d   |  338 ++
 .../libdruntime/core/sys/dragonflybsd/dlfcn.d      |    8 +-
 libphobos/libdruntime/core/sys/dragonflybsd/err.d  |   31 +
 .../core/sys/dragonflybsd/netinet/in_.d            |   14 +-
 .../core/sys/dragonflybsd/sys/link_elf.d           |    4 +-
 libphobos/libdruntime/core/sys/freebsd/dlfcn.d     |    8 +-
 libphobos/libdruntime/core/sys/freebsd/err.d       |   31 +
 libphobos/libdruntime/core/sys/freebsd/execinfo.d  |    2 +
 .../libdruntime/core/sys/freebsd/netinet/in_.d     |   14 +-
 libphobos/libdruntime/core/sys/freebsd/sys/event.d |   23 +-
 .../libdruntime/core/sys/freebsd/sys/link_elf.d    |    4 +-
 libphobos/libdruntime/core/sys/freebsd/sys/mount.d |   58 +-
 libphobos/libdruntime/core/sys/linux/dlfcn.d       |   11 +-
 libphobos/libdruntime/core/sys/linux/elf.d         |    2 +-
 libphobos/libdruntime/core/sys/linux/epoll.d       |    1 +
 libphobos/libdruntime/core/sys/linux/err.d         |   24 +
 libphobos/libdruntime/core/sys/linux/errno.d       |    1 +
 libphobos/libdruntime/core/sys/linux/execinfo.d    |    2 +
 libphobos/libdruntime/core/sys/linux/fcntl.d       |    1 +
 libphobos/libdruntime/core/sys/linux/ifaddrs.d     |    3 +-
 libphobos/libdruntime/core/sys/linux/link.d        |    1 +
 libphobos/libdruntime/core/sys/linux/netinet/in_.d |   22 +-
 libphobos/libdruntime/core/sys/linux/sched.d       |   44 +
 libphobos/libdruntime/core/sys/linux/stdio.d       |    2 +
 libphobos/libdruntime/core/sys/linux/string.d      |    1 +
 libphobos/libdruntime/core/sys/linux/sys/inotify.d |    1 +
 libphobos/libdruntime/core/sys/linux/sys/mman.d    |    2 +
 libphobos/libdruntime/core/sys/linux/sys/prctl.d   |    2 +-
 .../libdruntime/core/sys/linux/sys/signalfd.d      |    1 +
 libphobos/libdruntime/core/sys/linux/sys/sysinfo.d |    1 +
 libphobos/libdruntime/core/sys/linux/sys/time.d    |    2 +-
 libphobos/libdruntime/core/sys/linux/sys/xattr.d   |   23 +-
 libphobos/libdruntime/core/sys/linux/tipc.d        |    1 +
 libphobos/libdruntime/core/sys/linux/unistd.d      |    4 +
 libphobos/libdruntime/core/sys/netbsd/dlfcn.d      |    8 +-
 libphobos/libdruntime/core/sys/netbsd/err.d        |   27 +
 .../libdruntime/core/sys/netbsd/sys/link_elf.d     |    4 +-
 libphobos/libdruntime/core/sys/openbsd/err.d       |   27 +
 .../libdruntime/core/sys/openbsd/sys/link_elf.d    |    2 +-
 libphobos/libdruntime/core/sys/posix/aio.d         |    4 +-
 libphobos/libdruntime/core/sys/posix/arpa/inet.d   |   68 +-
 libphobos/libdruntime/core/sys/posix/config.d      |    1 +
 libphobos/libdruntime/core/sys/posix/dirent.d      |   64 +-
 libphobos/libdruntime/core/sys/posix/dlfcn.d       |   45 +-
 libphobos/libdruntime/core/sys/posix/fcntl.d       |   71 +-
 libphobos/libdruntime/core/sys/posix/grp.d         |   27 +-
 libphobos/libdruntime/core/sys/posix/iconv.d       |    5 +-
 libphobos/libdruntime/core/sys/posix/inttypes.d    |   19 +-
 libphobos/libdruntime/core/sys/posix/libgen.d      |    1 +
 libphobos/libdruntime/core/sys/posix/locale.d      |  175 +
 libphobos/libdruntime/core/sys/posix/mqueue.d      |    1 +
 libphobos/libdruntime/core/sys/posix/net/if_.d     |   20 +-
 libphobos/libdruntime/core/sys/posix/netdb.d       |    3 +-
 libphobos/libdruntime/core/sys/posix/netinet/in_.d |  158 +-
 libphobos/libdruntime/core/sys/posix/netinet/tcp.d |    2 +-
 libphobos/libdruntime/core/sys/posix/poll.d        |   13 +-
 libphobos/libdruntime/core/sys/posix/pthread.d     |  389 +-
 libphobos/libdruntime/core/sys/posix/pwd.d         |   27 +-
 libphobos/libdruntime/core/sys/posix/sched.d       |   11 +-
 libphobos/libdruntime/core/sys/posix/semaphore.d   |   35 +-
 libphobos/libdruntime/core/sys/posix/setjmp.d      |   14 +-
 libphobos/libdruntime/core/sys/posix/signal.d      |  245 +-
 libphobos/libdruntime/core/sys/posix/spawn.d       |    1 +
 libphobos/libdruntime/core/sys/posix/stdc/time.d   |  191 +
 libphobos/libdruntime/core/sys/posix/stdio.d       |  305 +-
 libphobos/libdruntime/core/sys/posix/stdlib.d      |  189 +-
 libphobos/libdruntime/core/sys/posix/string.d      |   52 +
 libphobos/libdruntime/core/sys/posix/strings.d     |   34 +
 libphobos/libdruntime/core/sys/posix/sys/filio.d   |    1 +
 libphobos/libdruntime/core/sys/posix/sys/ioccom.d  |    1 +
 libphobos/libdruntime/core/sys/posix/sys/ioctl.d   |    5 +-
 libphobos/libdruntime/core/sys/posix/sys/ipc.d     |   19 +-
 libphobos/libdruntime/core/sys/posix/sys/mman.d    |   95 +-
 libphobos/libdruntime/core/sys/posix/sys/msg.d     |    1 +
 .../libdruntime/core/sys/posix/sys/resource.d      |   25 +-
 libphobos/libdruntime/core/sys/posix/sys/select.d  |   25 +-
 libphobos/libdruntime/core/sys/posix/sys/shm.d     |   31 +-
 libphobos/libdruntime/core/sys/posix/sys/socket.d  |  141 +-
 libphobos/libdruntime/core/sys/posix/sys/stat.d    |  279 +-
 libphobos/libdruntime/core/sys/posix/sys/statvfs.d |   35 +-
 libphobos/libdruntime/core/sys/posix/sys/time.d    |   45 +-
 libphobos/libdruntime/core/sys/posix/sys/ttycom.d  |    1 +
 libphobos/libdruntime/core/sys/posix/sys/types.d   |   42 +-
 libphobos/libdruntime/core/sys/posix/sys/uio.d     |   47 +-
 libphobos/libdruntime/core/sys/posix/sys/un.d      |    1 +
 libphobos/libdruntime/core/sys/posix/sys/utsname.d |    1 +
 libphobos/libdruntime/core/sys/posix/sys/wait.d    |   47 +-
 libphobos/libdruntime/core/sys/posix/syslog.d      |   49 +-
 libphobos/libdruntime/core/sys/posix/termios.d     |   57 +-
 libphobos/libdruntime/core/sys/posix/time.d        |  209 +-
 libphobos/libdruntime/core/sys/posix/ucontext.d    |  104 +-
 libphobos/libdruntime/core/sys/posix/unistd.d      |  157 +-
 libphobos/libdruntime/core/sys/posix/utime.d       |   25 +-
 libphobos/libdruntime/core/sys/solaris/dlfcn.d     |    4 +-
 libphobos/libdruntime/core/sys/solaris/err.d       |   23 +
 libphobos/libdruntime/core/sys/solaris/libelf.d    |   12 +-
 libphobos/libdruntime/core/sys/solaris/link.d      |   34 +-
 .../libdruntime/core/sys/solaris/sys/elf_SPARC.d   |    2 +-
 libphobos/libdruntime/core/sys/windows/accctrl.d   |    2 +-
 libphobos/libdruntime/core/sys/windows/aclapi.d    |    1 +
 libphobos/libdruntime/core/sys/windows/aclui.d     |    5 +-
 libphobos/libdruntime/core/sys/windows/basetsd.d   |    1 +
 libphobos/libdruntime/core/sys/windows/basetyps.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/cguid.d     |    2 +-
 libphobos/libdruntime/core/sys/windows/com.d       |    1 +
 libphobos/libdruntime/core/sys/windows/comcat.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/commctrl.d  |    9 +-
 libphobos/libdruntime/core/sys/windows/commdlg.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/cpl.d       |    3 +-
 libphobos/libdruntime/core/sys/windows/cplext.d    |    1 +
 libphobos/libdruntime/core/sys/windows/custcntl.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/dbghelp.d   |    8 +-
 .../libdruntime/core/sys/windows/dbghelp_types.d   |    1 +
 libphobos/libdruntime/core/sys/windows/dbt.d       |    1 +
 libphobos/libdruntime/core/sys/windows/dde.d       |    3 +-
 libphobos/libdruntime/core/sys/windows/ddeml.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/dhcpcsdk.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/dlgs.d      |    3 +-
 libphobos/libdruntime/core/sys/windows/dll.d       |  121 +-
 libphobos/libdruntime/core/sys/windows/docobj.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/errorrep.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/exdisp.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/httpext.d   |    7 +-
 libphobos/libdruntime/core/sys/windows/imagehlp.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/imm.d       |    3 +-
 libphobos/libdruntime/core/sys/windows/intshcut.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/ipexport.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/iphlpapi.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/iprtrmib.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/iptypes.d   |    1 +
 libphobos/libdruntime/core/sys/windows/isguids.d   |    2 +-
 libphobos/libdruntime/core/sys/windows/lm.d        |    2 +
 libphobos/libdruntime/core/sys/windows/lmaccess.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/lmalert.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/lmapibuf.d  |    2 +-
 libphobos/libdruntime/core/sys/windows/lmat.d      |    3 +-
 libphobos/libdruntime/core/sys/windows/lmaudit.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/lmbrowsr.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/lmchdev.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/lmconfig.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/lmcons.d    |    5 +-
 libphobos/libdruntime/core/sys/windows/lmerr.d     |    1 +
 libphobos/libdruntime/core/sys/windows/lmerrlog.d  |    5 +-
 libphobos/libdruntime/core/sys/windows/lmmsg.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/lmremutl.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/lmrepl.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/lmserver.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/lmshare.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/lmsname.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/lmstats.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/lmsvc.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/lmuse.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/lmwksta.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/lzexpand.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/mapi.d      |    3 +-
 libphobos/libdruntime/core/sys/windows/mciavi.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/mcx.d       |    3 +-
 libphobos/libdruntime/core/sys/windows/mgmtapi.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/mmsystem.d  |    5 +-
 libphobos/libdruntime/core/sys/windows/msacm.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/mshtml.d    |   27 +-
 libphobos/libdruntime/core/sys/windows/mswsock.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/nb30.d      |    3 +-
 libphobos/libdruntime/core/sys/windows/nddeapi.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/nspapi.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/ntdef.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/ntdll.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/ntldap.d    |    1 +
 libphobos/libdruntime/core/sys/windows/ntsecapi.d  |    1 +
 libphobos/libdruntime/core/sys/windows/ntsecpkg.d  |    1 +
 libphobos/libdruntime/core/sys/windows/oaidl.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/objbase.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/objfwd.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/objidl.d    |   13 +-
 libphobos/libdruntime/core/sys/windows/objsafe.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/ocidl.d     |   13 +-
 libphobos/libdruntime/core/sys/windows/odbcinst.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/ole.d       |    3 +-
 libphobos/libdruntime/core/sys/windows/ole2.d      |    5 +-
 libphobos/libdruntime/core/sys/windows/oleacc.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/oleauto.d   |   13 +-
 libphobos/libdruntime/core/sys/windows/olectl.d    |    9 +-
 libphobos/libdruntime/core/sys/windows/olectlid.d  |    2 +-
 libphobos/libdruntime/core/sys/windows/oledlg.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/oleidl.d    |    7 +-
 libphobos/libdruntime/core/sys/windows/pbt.d       |    3 +-
 libphobos/libdruntime/core/sys/windows/powrprof.d  |    5 +-
 libphobos/libdruntime/core/sys/windows/prsht.d     |    3 +-
 libphobos/libdruntime/core/sys/windows/psapi.d     |   25 +-
 libphobos/libdruntime/core/sys/windows/rapi.d      |    3 +-
 libphobos/libdruntime/core/sys/windows/ras.d       |    3 +-
 libphobos/libdruntime/core/sys/windows/rasdlg.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/raserror.d  |    1 +
 libphobos/libdruntime/core/sys/windows/rassapi.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/reason.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/regstr.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/richedit.d  |    5 +-
 libphobos/libdruntime/core/sys/windows/richole.d   |    9 +-
 libphobos/libdruntime/core/sys/windows/rpc.d       |    1 +
 libphobos/libdruntime/core/sys/windows/rpcdce.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/rpcdce2.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/rpcdcep.d   |    7 +-
 libphobos/libdruntime/core/sys/windows/rpcndr.d    |    7 +-
 libphobos/libdruntime/core/sys/windows/rpcnsi.d    |    5 +-
 libphobos/libdruntime/core/sys/windows/rpcnsip.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/rpcnterr.d  |    1 +
 libphobos/libdruntime/core/sys/windows/schannel.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/sdkddkver.d |  118 +
 libphobos/libdruntime/core/sys/windows/secext.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/security.d  |  134 +-
 libphobos/libdruntime/core/sys/windows/servprov.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/setupapi.d  |    5 +-
 libphobos/libdruntime/core/sys/windows/shellapi.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/shldisp.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/shlguid.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/shlobj.d    |   21 +-
 libphobos/libdruntime/core/sys/windows/shlwapi.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/snmp.d      |    7 +-
 libphobos/libdruntime/core/sys/windows/sql.d       |    3 +-
 libphobos/libdruntime/core/sys/windows/sqlext.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/sqltypes.d  |    5 +-
 libphobos/libdruntime/core/sys/windows/sqlucode.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/sspi.d      |    1 +
 .../libdruntime/core/sys/windows/stacktrace.d      |   40 +-
 libphobos/libdruntime/core/sys/windows/stat.d      |    1 +
 libphobos/libdruntime/core/sys/windows/stdc/time.d |   59 +
 libphobos/libdruntime/core/sys/windows/subauth.d   |    3 +-
 libphobos/libdruntime/core/sys/windows/threadaux.d |    1 +
 libphobos/libdruntime/core/sys/windows/tlhelp32.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/tmschema.d  |    1 +
 libphobos/libdruntime/core/sys/windows/unknwn.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/uuid.d      |    1 +
 libphobos/libdruntime/core/sys/windows/vfw.d       |    1 +
 libphobos/libdruntime/core/sys/windows/w32api.d    |   11 +-
 libphobos/libdruntime/core/sys/windows/winbase.d   |   39 +-
 libphobos/libdruntime/core/sys/windows/winber.d    |    1 +
 libphobos/libdruntime/core/sys/windows/wincon.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/wincrypt.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/windef.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/windows.d   |    1 +
 libphobos/libdruntime/core/sys/windows/winerror.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/wingdi.d    |    7 +-
 libphobos/libdruntime/core/sys/windows/winhttp.d   |    1 +
 libphobos/libdruntime/core/sys/windows/wininet.d   |  236 +-
 libphobos/libdruntime/core/sys/windows/winioctl.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/winldap.d   |  213 +-
 libphobos/libdruntime/core/sys/windows/winnetwk.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/winnls.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/winnt.d     |  149 +-
 libphobos/libdruntime/core/sys/windows/winperf.d   |    1 +
 libphobos/libdruntime/core/sys/windows/winreg.d    |  103 +-
 libphobos/libdruntime/core/sys/windows/winsock2.d  |    1 +
 libphobos/libdruntime/core/sys/windows/winspool.d  |    5 +-
 libphobos/libdruntime/core/sys/windows/winsvc.d    |    3 +-
 libphobos/libdruntime/core/sys/windows/winuser.d   |    7 +-
 libphobos/libdruntime/core/sys/windows/winver.d    |   92 +-
 libphobos/libdruntime/core/sys/windows/wtsapi32.d  |    3 +-
 libphobos/libdruntime/core/sys/windows/wtypes.d    |    7 +-
 libphobos/libdruntime/core/thread.d                | 5732 --------------------
 libphobos/libdruntime/core/thread/context.d        |   65 +
 libphobos/libdruntime/core/thread/fiber.d          | 2097 +++++++
 libphobos/libdruntime/core/thread/osthread.d       | 2811 ++++++++++
 libphobos/libdruntime/core/thread/package.d        |   20 +
 libphobos/libdruntime/core/thread/threadbase.d     | 1382 +++++
 libphobos/libdruntime/core/thread/threadgroup.d    |  162 +
 libphobos/libdruntime/core/thread/types.d          |   77 +
 libphobos/libdruntime/gcc/sections/elf_shared.d    |   18 +
 libphobos/libdruntime/object.d                     |   95 +-
 libphobos/libdruntime/rt/aaA.d                     |    2 +-
 libphobos/libdruntime/rt/critical_.d               |    7 +-
 libphobos/libdruntime/rt/monitor_.d                |   28 +-
 libphobos/libdruntime/rt/typeinfo/ti_Acdouble.d    |   47 -
 libphobos/libdruntime/rt/typeinfo/ti_Acfloat.d     |   47 -
 libphobos/libdruntime/rt/typeinfo/ti_Acreal.d      |   47 -
 libphobos/libdruntime/rt/typeinfo/ti_Adouble.d     |   61 -
 libphobos/libdruntime/rt/typeinfo/ti_Afloat.d      |   61 -
 libphobos/libdruntime/rt/typeinfo/ti_Ag.d          |  154 -
 libphobos/libdruntime/rt/typeinfo/ti_Aint.d        |  151 -
 libphobos/libdruntime/rt/typeinfo/ti_Along.d       |  103 -
 libphobos/libdruntime/rt/typeinfo/ti_Areal.d       |   61 -
 libphobos/libdruntime/rt/typeinfo/ti_Ashort.d      |  113 -
 libphobos/libdruntime/rt/typeinfo/ti_C.d           |   75 -
 libphobos/libdruntime/rt/typeinfo/ti_byte.d        |   60 -
 libphobos/libdruntime/rt/typeinfo/ti_cdouble.d     |   74 -
 libphobos/libdruntime/rt/typeinfo/ti_cent.d        |   72 -
 libphobos/libdruntime/rt/typeinfo/ti_cfloat.d      |   73 -
 libphobos/libdruntime/rt/typeinfo/ti_char.d        |   62 -
 libphobos/libdruntime/rt/typeinfo/ti_creal.d       |   74 -
 libphobos/libdruntime/rt/typeinfo/ti_dchar.d       |   62 -
 libphobos/libdruntime/rt/typeinfo/ti_delegate.d    |   63 -
 libphobos/libdruntime/rt/typeinfo/ti_double.d      |   76 -
 libphobos/libdruntime/rt/typeinfo/ti_float.d       |   71 -
 libphobos/libdruntime/rt/typeinfo/ti_idouble.d     |   27 -
 libphobos/libdruntime/rt/typeinfo/ti_ifloat.d      |   27 -
 libphobos/libdruntime/rt/typeinfo/ti_int.d         |   64 -
 libphobos/libdruntime/rt/typeinfo/ti_ireal.d       |   27 -
 libphobos/libdruntime/rt/typeinfo/ti_long.d        |   73 -
 libphobos/libdruntime/rt/typeinfo/ti_n.d           |   58 -
 libphobos/libdruntime/rt/typeinfo/ti_ptr.d         |   65 -
 libphobos/libdruntime/rt/typeinfo/ti_real.d        |   67 -
 libphobos/libdruntime/rt/typeinfo/ti_short.d       |   60 -
 libphobos/libdruntime/rt/typeinfo/ti_ubyte.d       |   70 -
 libphobos/libdruntime/rt/typeinfo/ti_ucent.d       |   71 -
 libphobos/libdruntime/rt/typeinfo/ti_uint.d        |   64 -
 libphobos/libdruntime/rt/typeinfo/ti_ulong.d       |   73 -
 libphobos/libdruntime/rt/typeinfo/ti_ushort.d      |   60 -
 libphobos/libdruntime/rt/typeinfo/ti_void.d        |   65 -
 libphobos/libdruntime/rt/typeinfo/ti_wchar.d       |   62 -
 libphobos/libdruntime/rt/util/typeinfo.d           |  517 ++
 .../testsuite/libphobos.thread/fiber_guard_page.d  |    9 +-
 344 files changed, 13179 insertions(+), 12370 deletions(-)

diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
index 4e31127b1a1..ec8539deb45 100644
--- a/gcc/d/typeinfo.cc
+++ b/gcc/d/typeinfo.cc
@@ -1013,9 +1013,6 @@ public:
 	void function(void*) xdtor;
 	void function(void*) xpostblit;
 	uint m_align;
-	version (X86_64)
-	    TypeInfo m_arg1;
-	    TypeInfo m_arg2;
 	immutable(void)* xgetRTInfo;  */
 
   void visit (TypeInfoStructDeclaration *d)
@@ -1091,19 +1088,6 @@ public:
     /* uint m_align;  */
     this->layout_field (build_integer_cst (ti->alignsize (), d_uint_type));
 
-    if (global.params.is64bit)
-      {
-	/* TypeInfo m_arg1;  */
-	tree arg1type = (sd->arg1type) ? build_typeinfo (d->loc, sd->arg1type)
-	  : null_pointer_node;
-	this->layout_field (arg1type);
-
-	/* TypeInfo m_arg2;  */
-	tree arg2type = (sd->arg2type) ? build_typeinfo (d->loc, sd->arg2type)
-	  : null_pointer_node;
-	this->layout_field (arg2type);
-      }
-
     /* immutable(void)* xgetRTInfo;  */
     if (sd->getRTInfo)
       this->layout_field (build_expr (sd->getRTInfo, true));
diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in
index a1395929819..d42248405a2 100644
--- a/libphobos/Makefile.in
+++ b/libphobos/Makefile.in
@@ -15,7 +15,7 @@
 @SET_MAKE@
 
 # Makefile for the toplevel directory of the D Standard library.
-# Copyright (C) 2006-2020 Free Software Foundation, Inc.
+# Copyright (C) 2006-2021 Free Software Foundation, Inc.
 #
 # GCC is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/libphobos/configure b/libphobos/configure
index 1c32a552d40..c940a404be4 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -11746,7 +11746,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11759 "configure"
+#line 11749 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11852,7 +11852,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11865 "configure"
+#line 11855 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 7162844b9b6..4654e58e2d9 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-0fe7974cf53b75db59461de2a3d6e53ce933d297
+e4aae28e36c118f13e346a61af6c413aadd8e838
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am
index 34d3b41df82..57de872862b 100644
--- a/libphobos/libdruntime/Makefile.am
+++ b/libphobos/libdruntime/Makefile.am
@@ -178,8 +178,10 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
 	core/stdc/tgmath.d core/stdc/time.d core/stdc/wchar_.d \
 	core/stdc/wctype.d core/sync/barrier.d core/sync/condition.d \
 	core/sync/config.d core/sync/exception.d core/sync/mutex.d \
-	core/sync/rwmutex.d core/sync/semaphore.d core/thread.d core/time.d \
-	core/vararg.d gc/bits.d gc/config.d gc/gcinterface.d \
+	core/sync/rwmutex.d core/sync/semaphore.d core/thread/context.d \
+	core/thread/fiber.d core/thread/osthread.d core/thread/package.d \
+	core/thread/threadbase.d core/thread/threadgroup.d core/thread/types.d \
+	core/time.d core/vararg.d gc/bits.d gc/config.d gc/gcinterface.d \
 	gc/impl/conservative/gc.d gc/impl/manual/gc.d gc/os.d gc/pooltable.d \
 	gc/proxy.d gcc/attribute.d gcc/backtrace.d gcc/builtins.d gcc/deh.d \
 	gcc/emutls.d gcc/gthread.d gcc/sections/android.d \
@@ -191,20 +193,6 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
 	rt/cast_.d rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d \
 	rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \
 	rt/obj.d rt/qsort.d rt/sections.d rt/switch_.d rt/tlsgc.d \
-	rt/typeinfo/ti_Acdouble.d rt/typeinfo/ti_Acfloat.d \
-	rt/typeinfo/ti_Acreal.d rt/typeinfo/ti_Adouble.d \
-	rt/typeinfo/ti_Afloat.d rt/typeinfo/ti_Ag.d rt/typeinfo/ti_Aint.d \
-	rt/typeinfo/ti_Along.d rt/typeinfo/ti_Areal.d rt/typeinfo/ti_Ashort.d \
-	rt/typeinfo/ti_C.d rt/typeinfo/ti_byte.d rt/typeinfo/ti_cdouble.d \
-	rt/typeinfo/ti_cent.d rt/typeinfo/ti_cfloat.d rt/typeinfo/ti_char.d \
-	rt/typeinfo/ti_creal.d rt/typeinfo/ti_dchar.d \
-	rt/typeinfo/ti_delegate.d rt/typeinfo/ti_double.d \
-	rt/typeinfo/ti_float.d rt/typeinfo/ti_idouble.d \
-	rt/typeinfo/ti_ifloat.d rt/typeinfo/ti_int.d rt/typeinfo/ti_ireal.d \
-	rt/typeinfo/ti_long.d rt/typeinfo/ti_n.d rt/typeinfo/ti_ptr.d \
-	rt/typeinfo/ti_real.d rt/typeinfo/ti_short.d rt/typeinfo/ti_ubyte.d \
-	rt/typeinfo/ti_ucent.d rt/typeinfo/ti_uint.d rt/typeinfo/ti_ulong.d \
-	rt/typeinfo/ti_ushort.d rt/typeinfo/ti_void.d rt/typeinfo/ti_wchar.d \
 	rt/util/array.d rt/util/container/array.d rt/util/container/common.d \
 	rt/util/container/hashtab.d rt/util/container/treap.d rt/util/random.d \
 	rt/util/typeinfo.d rt/util/utf.d
@@ -212,23 +200,26 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
 DRUNTIME_DSOURCES_STDCXX = core/stdcpp/exception.d \
 	core/stdcpp/typeinfo.d
 
-DRUNTIME_DSOURCES_BIONIC = core/sys/bionic/fcntl.d \
-	core/sys/bionic/string.d core/sys/bionic/unistd.d
+DRUNTIME_DSOURCES_BIONIC = core/sys/bionic/err.d \
+	core/sys/bionic/fcntl.d core/sys/bionic/string.d \
+	core/sys/bionic/unistd.d
 
 DRUNTIME_DSOURCES_DARWIN = core/sys/darwin/crt_externs.d \
-	core/sys/darwin/dlfcn.d core/sys/darwin/execinfo.d \
+	core/sys/darwin/dlfcn.d core/sys/darwin/err.d \
+	core/sys/darwin/execinfo.d core/sys/darwin/ifaddrs.d \
 	core/sys/darwin/mach/dyld.d core/sys/darwin/mach/getsect.d \
 	core/sys/darwin/mach/kern_return.d core/sys/darwin/mach/loader.d \
-	core/sys/darwin/mach/port.d core/sys/darwin/mach/semaphore.d \
+	core/sys/darwin/mach/nlist.d core/sys/darwin/mach/port.d \
+	core/sys/darwin/mach/semaphore.d core/sys/darwin/mach/stab.d \
 	core/sys/darwin/mach/thread_act.d core/sys/darwin/netinet/in_.d \
 	core/sys/darwin/pthread.d core/sys/darwin/string.d \
-	core/sys/darwin/sys/cdefs.d core/sys/darwin/sys/event.d \
-	core/sys/darwin/sys/mman.d
+	core/sys/darwin/sys/attr.d core/sys/darwin/sys/cdefs.d \
+	core/sys/darwin/sys/event.d core/sys/darwin/sys/mman.d
 
 DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \
-	core/sys/dragonflybsd/execinfo.d core/sys/dragonflybsd/netinet/in_.d \
-	core/sys/dragonflybsd/pthread_np.d core/sys/dragonflybsd/string.d \
-	core/sys/dragonflybsd/sys/_bitset.d \
+	core/sys/dragonflybsd/err.d core/sys/dragonflybsd/execinfo.d \
+	core/sys/dragonflybsd/netinet/in_.d core/sys/dragonflybsd/pthread_np.d \
+	core/sys/dragonflybsd/string.d core/sys/dragonflybsd/sys/_bitset.d \
 	core/sys/dragonflybsd/sys/_cpuset.d core/sys/dragonflybsd/sys/cdefs.d \
 	core/sys/dragonflybsd/sys/elf.d core/sys/dragonflybsd/sys/elf32.d \
 	core/sys/dragonflybsd/sys/elf64.d \
@@ -238,19 +229,20 @@ DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \
 	core/sys/dragonflybsd/time.d
 
 DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/config.d \
-	core/sys/freebsd/dlfcn.d core/sys/freebsd/execinfo.d \
-	core/sys/freebsd/netinet/in_.d core/sys/freebsd/pthread_np.d \
-	core/sys/freebsd/string.d core/sys/freebsd/sys/_bitset.d \
-	core/sys/freebsd/sys/_cpuset.d core/sys/freebsd/sys/cdefs.d \
-	core/sys/freebsd/sys/elf.d core/sys/freebsd/sys/elf32.d \
-	core/sys/freebsd/sys/elf64.d core/sys/freebsd/sys/elf_common.d \
-	core/sys/freebsd/sys/event.d core/sys/freebsd/sys/link_elf.d \
-	core/sys/freebsd/sys/mman.d core/sys/freebsd/sys/mount.d \
-	core/sys/freebsd/time.d core/sys/freebsd/unistd.d
+	core/sys/freebsd/dlfcn.d core/sys/freebsd/err.d \
+	core/sys/freebsd/execinfo.d core/sys/freebsd/netinet/in_.d \
+	core/sys/freebsd/pthread_np.d core/sys/freebsd/string.d \
+	core/sys/freebsd/sys/_bitset.d core/sys/freebsd/sys/_cpuset.d \
+	core/sys/freebsd/sys/cdefs.d core/sys/freebsd/sys/elf.d \
+	core/sys/freebsd/sys/elf32.d core/sys/freebsd/sys/elf64.d \
+	core/sys/freebsd/sys/elf_common.d core/sys/freebsd/sys/event.d \
+	core/sys/freebsd/sys/link_elf.d core/sys/freebsd/sys/mman.d \
+	core/sys/freebsd/sys/mount.d core/sys/freebsd/time.d \
+	core/sys/freebsd/unistd.d
 
 DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \
 	core/sys/linux/dlfcn.d core/sys/linux/elf.d core/sys/linux/epoll.d \
-	core/sys/linux/errno.d core/sys/linux/execinfo.d \
+	core/sys/linux/err.d core/sys/linux/errno.d core/sys/linux/execinfo.d \
 	core/sys/linux/fcntl.d core/sys/linux/ifaddrs.d core/sys/linux/link.d \
 	core/sys/linux/netinet/in_.d core/sys/linux/netinet/tcp.d \
 	core/sys/linux/sched.d core/sys/linux/stdio.d core/sys/linux/string.d \
@@ -264,54 +256,56 @@ DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \
 	core/sys/linux/unistd.d
 
 DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \
-	core/sys/netbsd/execinfo.d core/sys/netbsd/string.d \
-	core/sys/netbsd/sys/elf.d core/sys/netbsd/sys/elf32.d \
-	core/sys/netbsd/sys/elf64.d core/sys/netbsd/sys/elf_common.d \
-	core/sys/netbsd/sys/event.d core/sys/netbsd/sys/featuretest.d \
-	core/sys/netbsd/sys/link_elf.d core/sys/netbsd/sys/mman.d \
-	core/sys/netbsd/time.d
+	core/sys/netbsd/err.d core/sys/netbsd/execinfo.d \
+	core/sys/netbsd/string.d core/sys/netbsd/sys/elf.d \
+	core/sys/netbsd/sys/elf32.d core/sys/netbsd/sys/elf64.d \
+	core/sys/netbsd/sys/elf_common.d core/sys/netbsd/sys/event.d \
+	core/sys/netbsd/sys/featuretest.d core/sys/netbsd/sys/link_elf.d \
+	core/sys/netbsd/sys/mman.d core/sys/netbsd/time.d
 
 DRUNTIME_DSOURCES_OPENBSD = core/sys/openbsd/dlfcn.d \
-	core/sys/openbsd/string.d core/sys/openbsd/sys/cdefs.d \
-	core/sys/openbsd/sys/elf.d core/sys/openbsd/sys/elf32.d \
-	core/sys/openbsd/sys/elf64.d core/sys/openbsd/sys/elf_common.d \
-	core/sys/openbsd/sys/link_elf.d core/sys/openbsd/sys/mman.d \
-	core/sys/openbsd/time.d
+	core/sys/openbsd/err.d core/sys/openbsd/string.d \
+	core/sys/openbsd/sys/cdefs.d core/sys/openbsd/sys/elf.d \
+	core/sys/openbsd/sys/elf32.d core/sys/openbsd/sys/elf64.d \
+	core/sys/openbsd/sys/elf_common.d core/sys/openbsd/sys/link_elf.d \
+	core/sys/openbsd/sys/mman.d core/sys/openbsd/time.d
 
 DRUNTIME_DSOURCES_POSIX = core/sys/posix/aio.d \
 	core/sys/posix/arpa/inet.d core/sys/posix/config.d \
 	core/sys/posix/dirent.d core/sys/posix/dlfcn.d core/sys/posix/fcntl.d \
 	core/sys/posix/grp.d core/sys/posix/iconv.d core/sys/posix/inttypes.d \
-	core/sys/posix/libgen.d core/sys/posix/mqueue.d \
-	core/sys/posix/net/if_.d core/sys/posix/netdb.d \
-	core/sys/posix/netinet/in_.d core/sys/posix/netinet/tcp.d \
-	core/sys/posix/poll.d core/sys/posix/pthread.d core/sys/posix/pwd.d \
-	core/sys/posix/sched.d core/sys/posix/semaphore.d \
-	core/sys/posix/setjmp.d core/sys/posix/signal.d core/sys/posix/spawn.d \
-	core/sys/posix/stdio.d core/sys/posix/stdlib.d \
-	core/sys/posix/sys/filio.d core/sys/posix/sys/ioccom.d \
-	core/sys/posix/sys/ioctl.d core/sys/posix/sys/ipc.d \
-	core/sys/posix/sys/mman.d core/sys/posix/sys/msg.d \
-	core/sys/posix/sys/resource.d core/sys/posix/sys/select.d \
-	core/sys/posix/sys/shm.d core/sys/posix/sys/socket.d \
-	core/sys/posix/sys/stat.d core/sys/posix/sys/statvfs.d \
-	core/sys/posix/sys/time.d core/sys/posix/sys/ttycom.d \
-	core/sys/posix/sys/types.d core/sys/posix/sys/uio.d \
-	core/sys/posix/sys/un.d core/sys/posix/sys/utsname.d \
-	core/sys/posix/sys/wait.d core/sys/posix/syslog.d \
-	core/sys/posix/termios.d core/sys/posix/time.d \
+	core/sys/posix/libgen.d core/sys/posix/locale.d \
+	core/sys/posix/mqueue.d core/sys/posix/net/if_.d \
+	core/sys/posix/netdb.d core/sys/posix/netinet/in_.d \
+	core/sys/posix/netinet/tcp.d core/sys/posix/poll.d \
+	core/sys/posix/pthread.d core/sys/posix/pwd.d core/sys/posix/sched.d \
+	core/sys/posix/semaphore.d core/sys/posix/setjmp.d \
+	core/sys/posix/signal.d core/sys/posix/spawn.d \
+	core/sys/posix/stdc/time.d core/sys/posix/stdio.d \
+	core/sys/posix/stdlib.d core/sys/posix/string.d \
+	core/sys/posix/strings.d core/sys/posix/sys/filio.d \
+	core/sys/posix/sys/ioccom.d core/sys/posix/sys/ioctl.d \
+	core/sys/posix/sys/ipc.d core/sys/posix/sys/mman.d \
+	core/sys/posix/sys/msg.d core/sys/posix/sys/resource.d \
+	core/sys/posix/sys/select.d core/sys/posix/sys/shm.d \
+	core/sys/posix/sys/socket.d core/sys/posix/sys/stat.d \
+	core/sys/posix/sys/statvfs.d core/sys/posix/sys/time.d \
+	core/sys/posix/sys/ttycom.d core/sys/posix/sys/types.d \
+	core/sys/posix/sys/uio.d core/sys/posix/sys/un.d \
+	core/sys/posix/sys/utsname.d core/sys/posix/sys/wait.d \
+	core/sys/posix/syslog.d core/sys/posix/termios.d core/sys/posix/time.d \
 	core/sys/posix/ucontext.d core/sys/posix/unistd.d \
 	core/sys/posix/utime.d
 
 DRUNTIME_DSOURCES_SOLARIS = core/sys/solaris/dlfcn.d \
-	core/sys/solaris/elf.d core/sys/solaris/execinfo.d \
-	core/sys/solaris/libelf.d core/sys/solaris/link.d \
-	core/sys/solaris/sys/elf.d core/sys/solaris/sys/elf_386.d \
-	core/sys/solaris/sys/elf_SPARC.d core/sys/solaris/sys/elf_amd64.d \
-	core/sys/solaris/sys/elf_notes.d core/sys/solaris/sys/elftypes.d \
-	core/sys/solaris/sys/link.d core/sys/solaris/sys/priocntl.d \
-	core/sys/solaris/sys/procset.d core/sys/solaris/sys/types.d \
-	core/sys/solaris/time.d
+	core/sys/solaris/elf.d core/sys/solaris/err.d \
+	core/sys/solaris/execinfo.d core/sys/solaris/libelf.d \
+	core/sys/solaris/link.d core/sys/solaris/sys/elf.d \
+	core/sys/solaris/sys/elf_386.d core/sys/solaris/sys/elf_SPARC.d \
+	core/sys/solaris/sys/elf_amd64.d core/sys/solaris/sys/elf_notes.d \
+	core/sys/solaris/sys/elftypes.d core/sys/solaris/sys/link.d \
+	core/sys/solaris/sys/priocntl.d core/sys/solaris/sys/procset.d \
+	core/sys/solaris/sys/types.d core/sys/solaris/time.d
 
 DRUNTIME_DSOURCES_WINDOWS = core/sys/windows/accctrl.d \
 	core/sys/windows/aclapi.d core/sys/windows/aclui.d \
@@ -371,15 +365,16 @@ DRUNTIME_DSOURCES_WINDOWS = core/sys/windows/accctrl.d \
 	core/sys/windows/rpcdcep.d core/sys/windows/rpcndr.d \
 	core/sys/windows/rpcnsi.d core/sys/windows/rpcnsip.d \
 	core/sys/windows/rpcnterr.d core/sys/windows/schannel.d \
-	core/sys/windows/secext.d core/sys/windows/security.d \
-	core/sys/windows/servprov.d core/sys/windows/setupapi.d \
-	core/sys/windows/shellapi.d core/sys/windows/shldisp.d \
-	core/sys/windows/shlguid.d core/sys/windows/shlobj.d \
-	core/sys/windows/shlwapi.d core/sys/windows/snmp.d \
-	core/sys/windows/sql.d core/sys/windows/sqlext.d \
-	core/sys/windows/sqltypes.d core/sys/windows/sqlucode.d \
-	core/sys/windows/sspi.d core/sys/windows/stacktrace.d \
-	core/sys/windows/stat.d core/sys/windows/subauth.d \
+	core/sys/windows/sdkddkver.d core/sys/windows/secext.d \
+	core/sys/windows/security.d core/sys/windows/servprov.d \
+	core/sys/windows/setupapi.d core/sys/windows/shellapi.d \
+	core/sys/windows/shldisp.d core/sys/windows/shlguid.d \
+	core/sys/windows/shlobj.d core/sys/windows/shlwapi.d \
+	core/sys/windows/snmp.d core/sys/windows/sql.d \
+	core/sys/windows/sqlext.d core/sys/windows/sqltypes.d \
+	core/sys/windows/sqlucode.d core/sys/windows/sspi.d \
+	core/sys/windows/stacktrace.d core/sys/windows/stat.d \
+	core/sys/windows/stdc/time.d core/sys/windows/subauth.d \
 	core/sys/windows/threadaux.d core/sys/windows/tlhelp32.d \
 	core/sys/windows/tmschema.d core/sys/windows/unknwn.d \
 	core/sys/windows/uuid.d core/sys/windows/vfw.d \
diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in
index 99ee8b92afa..e1b0a851b67 100644
--- a/libphobos/libdruntime/Makefile.in
+++ b/libphobos/libdruntime/Makefile.in
@@ -15,7 +15,7 @@
 @SET_MAKE@
 
 # Makefile for the D runtime library.
-# Copyright (C) 2012-2020 Free Software Foundation, Inc.
+# Copyright (C) 2012-2021 Free Software Foundation, Inc.
 #
 # GCC is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -202,7 +202,10 @@ am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \
 	core/stdc/wctype.lo core/sync/barrier.lo \
 	core/sync/condition.lo core/sync/config.lo \
 	core/sync/exception.lo core/sync/mutex.lo core/sync/rwmutex.lo \
-	core/sync/semaphore.lo core/thread.lo core/time.lo \
+	core/sync/semaphore.lo core/thread/context.lo \
+	core/thread/fiber.lo core/thread/osthread.lo \
+	core/thread/package.lo core/thread/threadbase.lo \
+	core/thread/threadgroup.lo core/thread/types.lo core/time.lo \
 	core/vararg.lo gc/bits.lo gc/config.lo gc/gcinterface.lo \
 	gc/impl/conservative/gc.lo gc/impl/manual/gc.lo gc/os.lo \
 	gc/pooltable.lo gc/proxy.lo gcc/attribute.lo gcc/backtrace.lo \
@@ -217,43 +220,26 @@ am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \
 	rt/config.lo rt/critical_.lo rt/deh.lo rt/dmain2.lo \
 	rt/invariant.lo rt/lifetime.lo rt/memory.lo rt/minfo.lo \
 	rt/monitor_.lo rt/obj.lo rt/qsort.lo rt/sections.lo \
-	rt/switch_.lo rt/tlsgc.lo rt/typeinfo/ti_Acdouble.lo \
-	rt/typeinfo/ti_Acfloat.lo rt/typeinfo/ti_Acreal.lo \
-	rt/typeinfo/ti_Adouble.lo rt/typeinfo/ti_Afloat.lo \
-	rt/typeinfo/ti_Ag.lo rt/typeinfo/ti_Aint.lo \
-	rt/typeinfo/ti_Along.lo rt/typeinfo/ti_Areal.lo \
-	rt/typeinfo/ti_Ashort.lo rt/typeinfo/ti_C.lo \
-	rt/typeinfo/ti_byte.lo rt/typeinfo/ti_cdouble.lo \
-	rt/typeinfo/ti_cent.lo rt/typeinfo/ti_cfloat.lo \
-	rt/typeinfo/ti_char.lo rt/typeinfo/ti_creal.lo \
-	rt/typeinfo/ti_dchar.lo rt/typeinfo/ti_delegate.lo \
-	rt/typeinfo/ti_double.lo rt/typeinfo/ti_float.lo \
-	rt/typeinfo/ti_idouble.lo rt/typeinfo/ti_ifloat.lo \
-	rt/typeinfo/ti_int.lo rt/typeinfo/ti_ireal.lo \
-	rt/typeinfo/ti_long.lo rt/typeinfo/ti_n.lo \
-	rt/typeinfo/ti_ptr.lo rt/typeinfo/ti_real.lo \
-	rt/typeinfo/ti_short.lo rt/typeinfo/ti_ubyte.lo \
-	rt/typeinfo/ti_ucent.lo rt/typeinfo/ti_uint.lo \
-	rt/typeinfo/ti_ulong.lo rt/typeinfo/ti_ushort.lo \
-	rt/typeinfo/ti_void.lo rt/typeinfo/ti_wchar.lo \
-	rt/util/array.lo rt/util/container/array.lo \
-	rt/util/container/common.lo rt/util/container/hashtab.lo \
-	rt/util/container/treap.lo rt/util/random.lo \
-	rt/util/typeinfo.lo rt/util/utf.lo
+	rt/switch_.lo rt/tlsgc.lo rt/util/array.lo \
+	rt/util/container/array.lo rt/util/container/common.lo \
+	rt/util/container/hashtab.lo rt/util/container/treap.lo \
+	rt/util/random.lo rt/util/typeinfo.lo rt/util/utf.lo
 am__objects_2 = core/stdc/libgdruntime_la-errno_.lo
 am__objects_3 = core/sys/posix/aio.lo core/sys/posix/arpa/inet.lo \
 	core/sys/posix/config.lo core/sys/posix/dirent.lo \
 	core/sys/posix/dlfcn.lo core/sys/posix/fcntl.lo \
 	core/sys/posix/grp.lo core/sys/posix/iconv.lo \
 	core/sys/posix/inttypes.lo core/sys/posix/libgen.lo \
-	core/sys/posix/mqueue.lo core/sys/posix/net/if_.lo \
-	core/sys/posix/netdb.lo core/sys/posix/netinet/in_.lo \
-	core/sys/posix/netinet/tcp.lo core/sys/posix/poll.lo \
-	core/sys/posix/pthread.lo core/sys/posix/pwd.lo \
-	core/sys/posix/sched.lo core/sys/posix/semaphore.lo \
-	core/sys/posix/setjmp.lo core/sys/posix/signal.lo \
-	core/sys/posix/spawn.lo core/sys/posix/stdio.lo \
-	core/sys/posix/stdlib.lo core/sys/posix/sys/filio.lo \
+	core/sys/posix/locale.lo core/sys/posix/mqueue.lo \
+	core/sys/posix/net/if_.lo core/sys/posix/netdb.lo \
+	core/sys/posix/netinet/in_.lo core/sys/posix/netinet/tcp.lo \
+	core/sys/posix/poll.lo core/sys/posix/pthread.lo \
+	core/sys/posix/pwd.lo core/sys/posix/sched.lo \
+	core/sys/posix/semaphore.lo core/sys/posix/setjmp.lo \
+	core/sys/posix/signal.lo core/sys/posix/spawn.lo \
+	core/sys/posix/stdc/time.lo core/sys/posix/stdio.lo \
+	core/sys/posix/stdlib.lo core/sys/posix/string.lo \
+	core/sys/posix/strings.lo core/sys/posix/sys/filio.lo \
 	core/sys/posix/sys/ioccom.lo core/sys/posix/sys/ioctl.lo \
 	core/sys/posix/sys/ipc.lo core/sys/posix/sys/mman.lo \
 	core/sys/posix/sys/msg.lo core/sys/posix/sys/resource.lo \
@@ -268,18 +254,21 @@ am__objects_3 = core/sys/posix/aio.lo core/sys/posix/arpa/inet.lo \
 	core/sys/posix/unistd.lo core/sys/posix/utime.lo
 @DRUNTIME_OS_POSIX_TRUE@am__objects_4 = $(am__objects_3)
 am__objects_5 = core/sys/darwin/crt_externs.lo \
-	core/sys/darwin/dlfcn.lo core/sys/darwin/execinfo.lo \
+	core/sys/darwin/dlfcn.lo core/sys/darwin/err.lo \
+	core/sys/darwin/execinfo.lo core/sys/darwin/ifaddrs.lo \
 	core/sys/darwin/mach/dyld.lo core/sys/darwin/mach/getsect.lo \
 	core/sys/darwin/mach/kern_return.lo \
-	core/sys/darwin/mach/loader.lo core/sys/darwin/mach/port.lo \
-	core/sys/darwin/mach/semaphore.lo \
+	core/sys/darwin/mach/loader.lo core/sys/darwin/mach/nlist.lo \
+	core/sys/darwin/mach/port.lo core/sys/darwin/mach/semaphore.lo \
+	core/sys/darwin/mach/stab.lo \
 	core/sys/darwin/mach/thread_act.lo \
 	core/sys/darwin/netinet/in_.lo core/sys/darwin/pthread.lo \
-	core/sys/darwin/string.lo core/sys/darwin/sys/cdefs.lo \
-	core/sys/darwin/sys/event.lo core/sys/darwin/sys/mman.lo
+	core/sys/darwin/string.lo core/sys/darwin/sys/attr.lo \
+	core/sys/darwin/sys/cdefs.lo core/sys/darwin/sys/event.lo \
+	core/sys/darwin/sys/mman.lo
 @DRUNTIME_OS_DARWIN_TRUE@am__objects_6 = $(am__objects_5)
 am__objects_7 = core/sys/dragonflybsd/dlfcn.lo \
-	core/sys/dragonflybsd/execinfo.lo \
+	core/sys/dragonflybsd/err.lo core/sys/dragonflybsd/execinfo.lo \
 	core/sys/dragonflybsd/netinet/in_.lo \
 	core/sys/dragonflybsd/pthread_np.lo \
 	core/sys/dragonflybsd/string.lo \
@@ -296,13 +285,13 @@ am__objects_7 = core/sys/dragonflybsd/dlfcn.lo \
 	core/sys/dragonflybsd/sys/socket.lo \
 	core/sys/dragonflybsd/time.lo
 @DRUNTIME_OS_DRAGONFLYBSD_TRUE@am__objects_8 = $(am__objects_7)
-am__objects_9 = core/sys/bionic/fcntl.lo core/sys/bionic/string.lo \
-	core/sys/bionic/unistd.lo
+am__objects_9 = core/sys/bionic/err.lo core/sys/bionic/fcntl.lo \
+	core/sys/bionic/string.lo core/sys/bionic/unistd.lo
 @DRUNTIME_OS_ANDROID_TRUE@am__objects_10 = $(am__objects_9)
 am__objects_11 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \
-	core/sys/freebsd/execinfo.lo core/sys/freebsd/netinet/in_.lo \
-	core/sys/freebsd/pthread_np.lo core/sys/freebsd/string.lo \
-	core/sys/freebsd/sys/_bitset.lo \
+	core/sys/freebsd/err.lo core/sys/freebsd/execinfo.lo \
+	core/sys/freebsd/netinet/in_.lo core/sys/freebsd/pthread_np.lo \
+	core/sys/freebsd/string.lo core/sys/freebsd/sys/_bitset.lo \
 	core/sys/freebsd/sys/_cpuset.lo core/sys/freebsd/sys/cdefs.lo \
 	core/sys/freebsd/sys/elf.lo core/sys/freebsd/sys/elf32.lo \
 	core/sys/freebsd/sys/elf64.lo \
@@ -311,36 +300,39 @@ am__objects_11 = core/sys/freebsd/config.lo core/sys/freebsd/dlfcn.lo \
 	core/sys/freebsd/sys/mman.lo core/sys/freebsd/sys/mount.lo \
 	core/sys/freebsd/time.lo core/sys/freebsd/unistd.lo
 @DRUNTIME_OS_FREEBSD_TRUE@am__objects_12 = $(am__objects_11)
-am__objects_13 = core/sys/netbsd/dlfcn.lo core/sys/netbsd/execinfo.lo \
-	core/sys/netbsd/string.lo core/sys/netbsd/sys/elf.lo \
-	core/sys/netbsd/sys/elf32.lo core/sys/netbsd/sys/elf64.lo \
-	core/sys/netbsd/sys/elf_common.lo core/sys/netbsd/sys/event.lo \
+am__objects_13 = core/sys/netbsd/dlfcn.lo core/sys/netbsd/err.lo \
+	core/sys/netbsd/execinfo.lo core/sys/netbsd/string.lo \
+	core/sys/netbsd/sys/elf.lo core/sys/netbsd/sys/elf32.lo \
+	core/sys/netbsd/sys/elf64.lo core/sys/netbsd/sys/elf_common.lo \
+	core/sys/netbsd/sys/event.lo \
 	core/sys/netbsd/sys/featuretest.lo \
 	core/sys/netbsd/sys/link_elf.lo core/sys/netbsd/sys/mman.lo \
 	core/sys/netbsd/time.lo
 @DRUNTIME_OS_NETBSD_TRUE@am__objects_14 = $(am__objects_13)
-am__objects_15 = core/sys/openbsd/dlfcn.lo core/sys/openbsd/string.lo \
-	core/sys/openbsd/sys/cdefs.lo core/sys/openbsd/sys/elf.lo \
-	core/sys/openbsd/sys/elf32.lo core/sys/openbsd/sys/elf64.lo \
+am__objects_15 = core/sys/openbsd/dlfcn.lo core/sys/openbsd/err.lo \
+	core/sys/openbsd/string.lo core/sys/openbsd/sys/cdefs.lo \
+	core/sys/openbsd/sys/elf.lo core/sys/openbsd/sys/elf32.lo \
+	core/sys/openbsd/sys/elf64.lo \
 	core/sys/openbsd/sys/elf_common.lo \
 	core/sys/openbsd/sys/link_elf.lo core/sys/openbsd/sys/mman.lo \
 	core/sys/openbsd/time.lo
 @DRUNTIME_OS_OPENBSD_TRUE@am__objects_16 = $(am__objects_15)
 am__objects_17 = core/sys/linux/config.lo core/sys/linux/dlfcn.lo \
 	core/sys/linux/elf.lo core/sys/linux/epoll.lo \
-	core/sys/linux/errno.lo core/sys/linux/execinfo.lo \
-	core/sys/linux/fcntl.lo core/sys/linux/ifaddrs.lo \
-	core/sys/linux/link.lo core/sys/linux/netinet/in_.lo \
-	core/sys/linux/netinet/tcp.lo core/sys/linux/sched.lo \
-	core/sys/linux/stdio.lo core/sys/linux/string.lo \
-	core/sys/linux/sys/auxv.lo core/sys/linux/sys/eventfd.lo \
-	core/sys/linux/sys/file.lo core/sys/linux/sys/inotify.lo \
-	core/sys/linux/sys/mman.lo core/sys/linux/sys/prctl.lo \
-	core/sys/linux/sys/signalfd.lo core/sys/linux/sys/socket.lo \
-	core/sys/linux/sys/sysinfo.lo core/sys/linux/sys/time.lo \
-	core/sys/linux/sys/xattr.lo core/sys/linux/termios.lo \
-	core/sys/linux/time.lo core/sys/linux/timerfd.lo \
-	core/sys/linux/tipc.lo core/sys/linux/unistd.lo
+	core/sys/linux/err.lo core/sys/linux/errno.lo \
+	core/sys/linux/execinfo.lo core/sys/linux/fcntl.lo \
+	core/sys/linux/ifaddrs.lo core/sys/linux/link.lo \
+	core/sys/linux/netinet/in_.lo core/sys/linux/netinet/tcp.lo \
+	core/sys/linux/sched.lo core/sys/linux/stdio.lo \
+	core/sys/linux/string.lo core/sys/linux/sys/auxv.lo \
+	core/sys/linux/sys/eventfd.lo core/sys/linux/sys/file.lo \
+	core/sys/linux/sys/inotify.lo core/sys/linux/sys/mman.lo \
+	core/sys/linux/sys/prctl.lo core/sys/linux/sys/signalfd.lo \
+	core/sys/linux/sys/socket.lo core/sys/linux/sys/sysinfo.lo \
+	core/sys/linux/sys/time.lo core/sys/linux/sys/xattr.lo \
+	core/sys/linux/termios.lo core/sys/linux/time.lo \
+	core/sys/linux/timerfd.lo core/sys/linux/tipc.lo \
+	core/sys/linux/unistd.lo
 @DRUNTIME_OS_LINUX_TRUE@am__objects_18 = $(am__objects_17)
 am__objects_19 = core/sys/windows/accctrl.lo \
 	core/sys/windows/aclapi.lo core/sys/windows/aclui.lo \
@@ -400,15 +392,16 @@ am__objects_19 = core/sys/windows/accctrl.lo \
 	core/sys/windows/rpcdce2.lo core/sys/windows/rpcdcep.lo \
 	core/sys/windows/rpcndr.lo core/sys/windows/rpcnsi.lo \
 	core/sys/windows/rpcnsip.lo core/sys/windows/rpcnterr.lo \
-	core/sys/windows/schannel.lo core/sys/windows/secext.lo \
-	core/sys/windows/security.lo core/sys/windows/servprov.lo \
-	core/sys/windows/setupapi.lo core/sys/windows/shellapi.lo \
-	core/sys/windows/shldisp.lo core/sys/windows/shlguid.lo \
-	core/sys/windows/shlobj.lo core/sys/windows/shlwapi.lo \
-	core/sys/windows/snmp.lo core/sys/windows/sql.lo \
-	core/sys/windows/sqlext.lo core/sys/windows/sqltypes.lo \
-	core/sys/windows/sqlucode.lo core/sys/windows/sspi.lo \
-	core/sys/windows/stacktrace.lo core/sys/windows/stat.lo \
+	core/sys/windows/schannel.lo core/sys/windows/sdkddkver.lo \
+	core/sys/windows/secext.lo core/sys/windows/security.lo \
+	core/sys/windows/servprov.lo core/sys/windows/setupapi.lo \
+	core/sys/windows/shellapi.lo core/sys/windows/shldisp.lo \
+	core/sys/windows/shlguid.lo core/sys/windows/shlobj.lo \
+	core/sys/windows/shlwapi.lo core/sys/windows/snmp.lo \
+	core/sys/windows/sql.lo core/sys/windows/sqlext.lo \
+	core/sys/windows/sqltypes.lo core/sys/windows/sqlucode.lo \
+	core/sys/windows/sspi.lo core/sys/windows/stacktrace.lo \
+	core/sys/windows/stat.lo core/sys/windows/stdc/time.lo \
 	core/sys/windows/subauth.lo core/sys/windows/threadaux.lo \
 	core/sys/windows/tlhelp32.lo core/sys/windows/tmschema.lo \
 	core/sys/windows/unknwn.lo core/sys/windows/uuid.lo \
@@ -427,9 +420,9 @@ am__objects_19 = core/sys/windows/accctrl.lo \
 	core/sys/windows/wtsapi32.lo core/sys/windows/wtypes.lo
 @DRUNTIME_OS_MINGW_TRUE@am__objects_20 = $(am__objects_19)
 am__objects_21 = core/sys/solaris/dlfcn.lo core/sys/solaris/elf.lo \
-	core/sys/solaris/execinfo.lo core/sys/solaris/libelf.lo \
-	core/sys/solaris/link.lo core/sys/solaris/sys/elf.lo \
-	core/sys/solaris/sys/elf_386.lo \
+	core/sys/solaris/err.lo core/sys/solaris/execinfo.lo \
+	core/sys/solaris/libelf.lo core/sys/solaris/link.lo \
+	core/sys/solaris/sys/elf.lo core/sys/solaris/sys/elf_386.lo \
 	core/sys/solaris/sys/elf_SPARC.lo \
 	core/sys/solaris/sys/elf_amd64.lo \
 	core/sys/solaris/sys/elf_notes.lo \
@@ -803,8 +796,10 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
 	core/stdc/tgmath.d core/stdc/time.d core/stdc/wchar_.d \
 	core/stdc/wctype.d core/sync/barrier.d core/sync/condition.d \
 	core/sync/config.d core/sync/exception.d core/sync/mutex.d \
-	core/sync/rwmutex.d core/sync/semaphore.d core/thread.d core/time.d \
-	core/vararg.d gc/bits.d gc/config.d gc/gcinterface.d \
+	core/sync/rwmutex.d core/sync/semaphore.d core/thread/context.d \
+	core/thread/fiber.d core/thread/osthread.d core/thread/package.d \
+	core/thread/threadbase.d core/thread/threadgroup.d core/thread/types.d \
+	core/time.d core/vararg.d gc/bits.d gc/config.d gc/gcinterface.d \
 	gc/impl/conservative/gc.d gc/impl/manual/gc.d gc/os.d gc/pooltable.d \
 	gc/proxy.d gcc/attribute.d gcc/backtrace.d gcc/builtins.d gcc/deh.d \
 	gcc/emutls.d gcc/gthread.d gcc/sections/android.d \
@@ -816,20 +811,6 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
 	rt/cast_.d rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d \
 	rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \
 	rt/obj.d rt/qsort.d rt/sections.d rt/switch_.d rt/tlsgc.d \
-	rt/typeinfo/ti_Acdouble.d rt/typeinfo/ti_Acfloat.d \
-	rt/typeinfo/ti_Acreal.d rt/typeinfo/ti_Adouble.d \
-	rt/typeinfo/ti_Afloat.d rt/typeinfo/ti_Ag.d rt/typeinfo/ti_Aint.d \
-	rt/typeinfo/ti_Along.d rt/typeinfo/ti_Areal.d rt/typeinfo/ti_Ashort.d \
-	rt/typeinfo/ti_C.d rt/typeinfo/ti_byte.d rt/typeinfo/ti_cdouble.d \
-	rt/typeinfo/ti_cent.d rt/typeinfo/ti_cfloat.d rt/typeinfo/ti_char.d \
-	rt/typeinfo/ti_creal.d rt/typeinfo/ti_dchar.d \
-	rt/typeinfo/ti_delegate.d rt/typeinfo/ti_double.d \
-	rt/typeinfo/ti_float.d rt/typeinfo/ti_idouble.d \
-	rt/typeinfo/ti_ifloat.d rt/typeinfo/ti_int.d rt/typeinfo/ti_ireal.d \
-	rt/typeinfo/ti_long.d rt/typeinfo/ti_n.d rt/typeinfo/ti_ptr.d \
-	rt/typeinfo/ti_real.d rt/typeinfo/ti_short.d rt/typeinfo/ti_ubyte.d \
-	rt/typeinfo/ti_ucent.d rt/typeinfo/ti_uint.d rt/typeinfo/ti_ulong.d \
-	rt/typeinfo/ti_ushort.d rt/typeinfo/ti_void.d rt/typeinfo/ti_wchar.d \
 	rt/util/array.d rt/util/container/array.d rt/util/container/common.d \
 	rt/util/container/hashtab.d rt/util/container/treap.d rt/util/random.d \
 	rt/util/typeinfo.d rt/util/utf.d
@@ -837,23 +818,26 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \
 DRUNTIME_DSOURCES_STDCXX = core/stdcpp/exception.d \
 	core/stdcpp/typeinfo.d
 
-DRUNTIME_DSOURCES_BIONIC = core/sys/bionic/fcntl.d \
-	core/sys/bionic/string.d core/sys/bionic/unistd.d
+DRUNTIME_DSOURCES_BIONIC = core/sys/bionic/err.d \
+	core/sys/bionic/fcntl.d core/sys/bionic/string.d \
+	core/sys/bionic/unistd.d
 
 DRUNTIME_DSOURCES_DARWIN = core/sys/darwin/crt_externs.d \
-	core/sys/darwin/dlfcn.d core/sys/darwin/execinfo.d \
+	core/sys/darwin/dlfcn.d core/sys/darwin/err.d \
+	core/sys/darwin/execinfo.d core/sys/darwin/ifaddrs.d \
 	core/sys/darwin/mach/dyld.d core/sys/darwin/mach/getsect.d \
 	core/sys/darwin/mach/kern_return.d core/sys/darwin/mach/loader.d \
-	core/sys/darwin/mach/port.d core/sys/darwin/mach/semaphore.d \
+	core/sys/darwin/mach/nlist.d core/sys/darwin/mach/port.d \
+	core/sys/darwin/mach/semaphore.d core/sys/darwin/mach/stab.d \
 	core/sys/darwin/mach/thread_act.d core/sys/darwin/netinet/in_.d \
 	core/sys/darwin/pthread.d core/sys/darwin/string.d \
-	core/sys/darwin/sys/cdefs.d core/sys/darwin/sys/event.d \
-	core/sys/darwin/sys/mman.d
+	core/sys/darwin/sys/attr.d core/sys/darwin/sys/cdefs.d \
+	core/sys/darwin/sys/event.d core/sys/darwin/sys/mman.d
 
 DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \
-	core/sys/dragonflybsd/execinfo.d core/sys/dragonflybsd/netinet/in_.d \
-	core/sys/dragonflybsd/pthread_np.d core/sys/dragonflybsd/string.d \
-	core/sys/dragonflybsd/sys/_bitset.d \
+	core/sys/dragonflybsd/err.d core/sys/dragonflybsd/execinfo.d \
+	core/sys/dragonflybsd/netinet/in_.d core/sys/dragonflybsd/pthread_np.d \
+	core/sys/dragonflybsd/string.d core/sys/dragonflybsd/sys/_bitset.d \
 	core/sys/dragonflybsd/sys/_cpuset.d core/sys/dragonflybsd/sys/cdefs.d \
 	core/sys/dragonflybsd/sys/elf.d core/sys/dragonflybsd/sys/elf32.d \
 	core/sys/dragonflybsd/sys/elf64.d \
@@ -863,19 +847,20 @@ DRUNTIME_DSOURCES_DRAGONFLYBSD = core/sys/dragonflybsd/dlfcn.d \
 	core/sys/dragonflybsd/time.d
 
 DRUNTIME_DSOURCES_FREEBSD = core/sys/freebsd/config.d \
-	core/sys/freebsd/dlfcn.d core/sys/freebsd/execinfo.d \
-	core/sys/freebsd/netinet/in_.d core/sys/freebsd/pthread_np.d \
-	core/sys/freebsd/string.d core/sys/freebsd/sys/_bitset.d \
-	core/sys/freebsd/sys/_cpuset.d core/sys/freebsd/sys/cdefs.d \
-	core/sys/freebsd/sys/elf.d core/sys/freebsd/sys/elf32.d \
-	core/sys/freebsd/sys/elf64.d core/sys/freebsd/sys/elf_common.d \
-	core/sys/freebsd/sys/event.d core/sys/freebsd/sys/link_elf.d \
-	core/sys/freebsd/sys/mman.d core/sys/freebsd/sys/mount.d \
-	core/sys/freebsd/time.d core/sys/freebsd/unistd.d
+	core/sys/freebsd/dlfcn.d core/sys/freebsd/err.d \
+	core/sys/freebsd/execinfo.d core/sys/freebsd/netinet/in_.d \
+	core/sys/freebsd/pthread_np.d core/sys/freebsd/string.d \
+	core/sys/freebsd/sys/_bitset.d core/sys/freebsd/sys/_cpuset.d \
+	core/sys/freebsd/sys/cdefs.d core/sys/freebsd/sys/elf.d \
+	core/sys/freebsd/sys/elf32.d core/sys/freebsd/sys/elf64.d \
+	core/sys/freebsd/sys/elf_common.d core/sys/freebsd/sys/event.d \
+	core/sys/freebsd/sys/link_elf.d core/sys/freebsd/sys/mman.d \
+	core/sys/freebsd/sys/mount.d core/sys/freebsd/time.d \
+	core/sys/freebsd/unistd.d
 
 DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \
 	core/sys/linux/dlfcn.d core/sys/linux/elf.d core/sys/linux/epoll.d \
-	core/sys/linux/errno.d core/sys/linux/execinfo.d \
+	core/sys/linux/err.d core/sys/linux/errno.d core/sys/linux/execinfo.d \
 	core/sys/linux/fcntl.d core/sys/linux/ifaddrs.d core/sys/linux/link.d \
 	core/sys/linux/netinet/in_.d core/sys/linux/netinet/tcp.d \
 	core/sys/linux/sched.d core/sys/linux/stdio.d core/sys/linux/string.d \
@@ -889,54 +874,56 @@ DRUNTIME_DSOURCES_LINUX = core/sys/linux/config.d \
 	core/sys/linux/unistd.d
 
 DRUNTIME_DSOURCES_NETBSD = core/sys/netbsd/dlfcn.d \
-	core/sys/netbsd/execinfo.d core/sys/netbsd/string.d \
-	core/sys/netbsd/sys/elf.d core/sys/netbsd/sys/elf32.d \
-	core/sys/netbsd/sys/elf64.d core/sys/netbsd/sys/elf_common.d \
-	core/sys/netbsd/sys/event.d core/sys/netbsd/sys/featuretest.d \
-	core/sys/netbsd/sys/link_elf.d core/sys/netbsd/sys/mman.d \
-	core/sys/netbsd/time.d
+	core/sys/netbsd/err.d core/sys/netbsd/execinfo.d \
+	core/sys/netbsd/string.d core/sys/netbsd/sys/elf.d \
+	core/sys/netbsd/sys/elf32.d core/sys/netbsd/sys/elf64.d \
+	core/sys/netbsd/sys/elf_common.d core/sys/netbsd/sys/event.d \
+	core/sys/netbsd/sys/featuretest.d core/sys/netbsd/sys/link_elf.d \
+	core/sys/netbsd/sys/mman.d core/sys/netbsd/time.d
 
 DRUNTIME_DSOURCES_OPENBSD = core/sys/openbsd/dlfcn.d \
-	core/sys/openbsd/string.d core/sys/openbsd/sys/cdefs.d \
-	core/sys/openbsd/sys/elf.d core/sys/openbsd/sys/elf32.d \
-	core/sys/openbsd/sys/elf64.d core/sys/openbsd/sys/elf_common.d \
-	core/sys/openbsd/sys/link_elf.d core/sys/openbsd/sys/mman.d \
-	core/sys/openbsd/time.d
+	core/sys/openbsd/err.d core/sys/openbsd/string.d \
+	core/sys/openbsd/sys/cdefs.d core/sys/openbsd/sys/elf.d \
+	core/sys/openbsd/sys/elf32.d core/sys/openbsd/sys/elf64.d \
+	core/sys/openbsd/sys/elf_common.d core/sys/openbsd/sys/link_elf.d \
+	core/sys/openbsd/sys/mman.d core/sys/openbsd/time.d
 
 DRUNTIME_DSOURCES_POSIX = core/sys/posix/aio.d \
 	core/sys/posix/arpa/inet.d core/sys/posix/config.d \
 	core/sys/posix/dirent.d core/sys/posix/dlfcn.d core/sys/posix/fcntl.d \
 	core/sys/posix/grp.d core/sys/posix/iconv.d core/sys/posix/inttypes.d \
-	core/sys/posix/libgen.d core/sys/posix/mqueue.d \
-	core/sys/posix/net/if_.d core/sys/posix/netdb.d \
-	core/sys/posix/netinet/in_.d core/sys/posix/netinet/tcp.d \
-	core/sys/posix/poll.d core/sys/posix/pthread.d core/sys/posix/pwd.d \
-	core/sys/posix/sched.d core/sys/posix/semaphore.d \
-	core/sys/posix/setjmp.d core/sys/posix/signal.d core/sys/posix/spawn.d \
-	core/sys/posix/stdio.d core/sys/posix/stdlib.d \
-	core/sys/posix/sys/filio.d core/sys/posix/sys/ioccom.d \
-	core/sys/posix/sys/ioctl.d core/sys/posix/sys/ipc.d \
-	core/sys/posix/sys/mman.d core/sys/posix/sys/msg.d \
-	core/sys/posix/sys/resource.d core/sys/posix/sys/select.d \
-	core/sys/posix/sys/shm.d core/sys/posix/sys/socket.d \
-	core/sys/posix/sys/stat.d core/sys/posix/sys/statvfs.d \
-	core/sys/posix/sys/time.d core/sys/posix/sys/ttycom.d \
-	core/sys/posix/sys/types.d core/sys/posix/sys/uio.d \
-	core/sys/posix/sys/un.d core/sys/posix/sys/utsname.d \
-	core/sys/posix/sys/wait.d core/sys/posix/syslog.d \
-	core/sys/posix/termios.d core/sys/posix/time.d \
+	core/sys/posix/libgen.d core/sys/posix/locale.d \
+	core/sys/posix/mqueue.d core/sys/posix/net/if_.d \
+	core/sys/posix/netdb.d core/sys/posix/netinet/in_.d \
+	core/sys/posix/netinet/tcp.d core/sys/posix/poll.d \
+	core/sys/posix/pthread.d core/sys/posix/pwd.d core/sys/posix/sched.d \
+	core/sys/posix/semaphore.d core/sys/posix/setjmp.d \
+	core/sys/posix/signal.d core/sys/posix/spawn.d \
+	core/sys/posix/stdc/time.d core/sys/posix/stdio.d \
+	core/sys/posix/stdlib.d core/sys/posix/string.d \
+	core/sys/posix/strings.d core/sys/posix/sys/filio.d \
+	core/sys/posix/sys/ioccom.d core/sys/posix/sys/ioctl.d \
+	core/sys/posix/sys/ipc.d core/sys/posix/sys/mman.d \
+	core/sys/posix/sys/msg.d core/sys/posix/sys/resource.d \
+	core/sys/posix/sys/select.d core/sys/posix/sys/shm.d \
+	core/sys/posix/sys/socket.d core/sys/posix/sys/stat.d \
+	core/sys/posix/sys/statvfs.d core/sys/posix/sys/time.d \
+	core/sys/posix/sys/ttycom.d core/sys/posix/sys/types.d \
+	core/sys/posix/sys/uio.d core/sys/posix/sys/un.d \
+	core/sys/posix/sys/utsname.d core/sys/posix/sys/wait.d \
+	core/sys/posix/syslog.d core/sys/posix/termios.d core/sys/posix/time.d \
 	core/sys/posix/ucontext.d core/sys/posix/unistd.d \
 	core/sys/posix/utime.d
 
 DRUNTIME_DSOURCES_SOLARIS = core/sys/solaris/dlfcn.d \
-	core/sys/solaris/elf.d core/sys/solaris/execinfo.d \
-	core/sys/solaris/libelf.d core/sys/solaris/link.d \
-	core/sys/solaris/sys/elf.d core/sys/solaris/sys/elf_386.d \
-	core/sys/solaris/sys/elf_SPARC.d core/sys/solaris/sys/elf_amd64.d \
-	core/sys/solaris/sys/elf_notes.d core/sys/solaris/sys/elftypes.d \
-	core/sys/solaris/sys/link.d core/sys/solaris/sys/priocntl.d \
-	core/sys/solaris/sys/procset.d core/sys/solaris/sys/types.d \
-	core/sys/solaris/time.d
+	core/sys/solaris/elf.d core/sys/solaris/err.d \
+	core/sys/solaris/execinfo.d core/sys/solaris/libelf.d \
+	core/sys/solaris/link.d core/sys/solaris/sys/elf.d \
+	core/sys/solaris/sys/elf_386.d core/sys/solaris/sys/elf_SPARC.d \
+	core/sys/solaris/sys/elf_amd64.d core/sys/solaris/sys/elf_notes.d \
+	core/sys/solaris/sys/elftypes.d core/sys/solaris/sys/link.d \
+	core/sys/solaris/sys/priocntl.d core/sys/solaris/sys/procset.d \
+	core/sys/solaris/sys/types.d core/sys/solaris/time.d
 
 DRUNTIME_DSOURCES_WINDOWS = core/sys/windows/accctrl.d \
 	core/sys/windows/aclapi.d core/sys/windows/aclui.d \
@@ -996,15 +983,16 @@ DRUNTIME_DSOURCES_WINDOWS = core/sys/windows/accctrl.d \
 	core/sys/windows/rpcdcep.d core/sys/windows/rpcndr.d \
 	core/sys/windows/rpcnsi.d core/sys/windows/rpcnsip.d \
 	core/sys/windows/rpcnterr.d core/sys/windows/schannel.d \
-	core/sys/windows/secext.d core/sys/windows/security.d \
-	core/sys/windows/servprov.d core/sys/windows/setupapi.d \
-	core/sys/windows/shellapi.d core/sys/windows/shldisp.d \
-	core/sys/windows/shlguid.d core/sys/windows/shlobj.d \
-	core/sys/windows/shlwapi.d core/sys/windows/snmp.d \
-	core/sys/windows/sql.d core/sys/windows/sqlext.d \
-	core/sys/windows/sqltypes.d core/sys/windows/sqlucode.d \
-	core/sys/windows/sspi.d core/sys/windows/stacktrace.d \
-	core/sys/windows/stat.d core/sys/windows/subauth.d \
+	core/sys/windows/sdkddkver.d core/sys/windows/secext.d \
+	core/sys/windows/security.d core/sys/windows/servprov.d \
+	core/sys/windows/setupapi.d core/sys/windows/shellapi.d \
+	core/sys/windows/shldisp.d core/sys/windows/shlguid.d \
+	core/sys/windows/shlobj.d core/sys/windows/shlwapi.d \
+	core/sys/windows/snmp.d core/sys/windows/sql.d \
+	core/sys/windows/sqlext.d core/sys/windows/sqltypes.d \
+	core/sys/windows/sqlucode.d core/sys/windows/sspi.d \
+	core/sys/windows/stacktrace.d core/sys/windows/stat.d \
+	core/sys/windows/stdc/time.d core/sys/windows/subauth.d \
 	core/sys/windows/threadaux.d core/sys/windows/tlhelp32.d \
 	core/sys/windows/tmschema.d core/sys/windows/unknwn.d \
 	core/sys/windows/uuid.d core/sys/windows/vfw.d \
@@ -1162,7 +1150,16 @@ core/sync/exception.lo: core/sync/$(am__dirstamp)
 core/sync/mutex.lo: core/sync/$(am__dirstamp)
 core/sync/rwmutex.lo: core/sync/$(am__dirstamp)
 core/sync/semaphore.lo: core/sync/$(am__dirstamp)
-core/thread.lo: core/$(am__dirstamp)
+core/thread/$(am__dirstamp):
+	@$(MKDIR_P) core/thread
+	@: > core/thread/$(am__dirstamp)
+core/thread/context.lo: core/thread/$(am__dirstamp)
+core/thread/fiber.lo: core/thread/$(am__dirstamp)
+core/thread/osthread.lo: core/thread/$(am__dirstamp)
+core/thread/package.lo: core/thread/$(am__dirstamp)
+core/thread/threadbase.lo: core/thread/$(am__dirstamp)
+core/thread/threadgroup.lo: core/thread/$(am__dirstamp)
+core/thread/types.lo: core/thread/$(am__dirstamp)
 core/time.lo: core/$(am__dirstamp)
 core/vararg.lo: core/$(am__dirstamp)
 gc/$(am__dirstamp):
@@ -1234,46 +1231,6 @@ rt/qsort.lo: rt/$(am__dirstamp)
 rt/sections.lo: rt/$(am__dirstamp)
 rt/switch_.lo: rt/$(am__dirstamp)
 rt/tlsgc.lo: rt/$(am__dirstamp)
-rt/typeinfo/$(am__dirstamp):
-	@$(MKDIR_P) rt/typeinfo
-	@: > rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Acdouble.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Acfloat.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Acreal.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Adouble.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Afloat.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Ag.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Aint.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Along.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Areal.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_Ashort.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_C.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_byte.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_cdouble.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_cent.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_cfloat.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_char.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_creal.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_dchar.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_delegate.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_double.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_float.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_idouble.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_ifloat.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_int.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_ireal.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_long.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_n.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_ptr.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_real.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_short.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_ubyte.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_ucent.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_uint.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_ulong.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_ushort.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_void.lo: rt/typeinfo/$(am__dirstamp)
-rt/typeinfo/ti_wchar.lo: rt/typeinfo/$(am__dirstamp)
 rt/util/$(am__dirstamp):
 	@$(MKDIR_P) rt/util
 	@: > rt/util/$(am__dirstamp)
@@ -1305,6 +1262,7 @@ core/sys/posix/grp.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/iconv.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/inttypes.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/libgen.lo: core/sys/posix/$(am__dirstamp)
+core/sys/posix/locale.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/mqueue.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/net/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/posix/net
@@ -1324,8 +1282,14 @@ core/sys/posix/semaphore.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/setjmp.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/signal.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/spawn.lo: core/sys/posix/$(am__dirstamp)
+core/sys/posix/stdc/$(am__dirstamp):
+	@$(MKDIR_P) core/sys/posix/stdc
+	@: > core/sys/posix/stdc/$(am__dirstamp)
+core/sys/posix/stdc/time.lo: core/sys/posix/stdc/$(am__dirstamp)
 core/sys/posix/stdio.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/stdlib.lo: core/sys/posix/$(am__dirstamp)
+core/sys/posix/string.lo: core/sys/posix/$(am__dirstamp)
+core/sys/posix/strings.lo: core/sys/posix/$(am__dirstamp)
 core/sys/posix/sys/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/posix/sys
 	@: > core/sys/posix/sys/$(am__dirstamp)
@@ -1359,7 +1323,9 @@ core/sys/darwin/$(am__dirstamp):
 	@: > core/sys/darwin/$(am__dirstamp)
 core/sys/darwin/crt_externs.lo: core/sys/darwin/$(am__dirstamp)
 core/sys/darwin/dlfcn.lo: core/sys/darwin/$(am__dirstamp)
+core/sys/darwin/err.lo: core/sys/darwin/$(am__dirstamp)
 core/sys/darwin/execinfo.lo: core/sys/darwin/$(am__dirstamp)
+core/sys/darwin/ifaddrs.lo: core/sys/darwin/$(am__dirstamp)
 core/sys/darwin/mach/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/darwin/mach
 	@: > core/sys/darwin/mach/$(am__dirstamp)
@@ -1368,9 +1334,11 @@ core/sys/darwin/mach/getsect.lo: core/sys/darwin/mach/$(am__dirstamp)
 core/sys/darwin/mach/kern_return.lo:  \
 	core/sys/darwin/mach/$(am__dirstamp)
 core/sys/darwin/mach/loader.lo: core/sys/darwin/mach/$(am__dirstamp)
+core/sys/darwin/mach/nlist.lo: core/sys/darwin/mach/$(am__dirstamp)
 core/sys/darwin/mach/port.lo: core/sys/darwin/mach/$(am__dirstamp)
 core/sys/darwin/mach/semaphore.lo:  \
 	core/sys/darwin/mach/$(am__dirstamp)
+core/sys/darwin/mach/stab.lo: core/sys/darwin/mach/$(am__dirstamp)
 core/sys/darwin/mach/thread_act.lo:  \
 	core/sys/darwin/mach/$(am__dirstamp)
 core/sys/darwin/netinet/$(am__dirstamp):
@@ -1383,6 +1351,7 @@ core/sys/darwin/string.lo: core/sys/darwin/$(am__dirstamp)
 core/sys/darwin/sys/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/darwin/sys
 	@: > core/sys/darwin/sys/$(am__dirstamp)
+core/sys/darwin/sys/attr.lo: core/sys/darwin/sys/$(am__dirstamp)
 core/sys/darwin/sys/cdefs.lo: core/sys/darwin/sys/$(am__dirstamp)
 core/sys/darwin/sys/event.lo: core/sys/darwin/sys/$(am__dirstamp)
 core/sys/darwin/sys/mman.lo: core/sys/darwin/sys/$(am__dirstamp)
@@ -1390,6 +1359,7 @@ core/sys/dragonflybsd/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/dragonflybsd
 	@: > core/sys/dragonflybsd/$(am__dirstamp)
 core/sys/dragonflybsd/dlfcn.lo: core/sys/dragonflybsd/$(am__dirstamp)
+core/sys/dragonflybsd/err.lo: core/sys/dragonflybsd/$(am__dirstamp)
 core/sys/dragonflybsd/execinfo.lo:  \
 	core/sys/dragonflybsd/$(am__dirstamp)
 core/sys/dragonflybsd/netinet/$(am__dirstamp):
@@ -1430,6 +1400,7 @@ core/sys/dragonflybsd/time.lo: core/sys/dragonflybsd/$(am__dirstamp)
 core/sys/bionic/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/bionic
 	@: > core/sys/bionic/$(am__dirstamp)
+core/sys/bionic/err.lo: core/sys/bionic/$(am__dirstamp)
 core/sys/bionic/fcntl.lo: core/sys/bionic/$(am__dirstamp)
 core/sys/bionic/string.lo: core/sys/bionic/$(am__dirstamp)
 core/sys/bionic/unistd.lo: core/sys/bionic/$(am__dirstamp)
@@ -1438,6 +1409,7 @@ core/sys/freebsd/$(am__dirstamp):
 	@: > core/sys/freebsd/$(am__dirstamp)
 core/sys/freebsd/config.lo: core/sys/freebsd/$(am__dirstamp)
 core/sys/freebsd/dlfcn.lo: core/sys/freebsd/$(am__dirstamp)
+core/sys/freebsd/err.lo: core/sys/freebsd/$(am__dirstamp)
 core/sys/freebsd/execinfo.lo: core/sys/freebsd/$(am__dirstamp)
 core/sys/freebsd/netinet/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/freebsd/netinet
@@ -1468,6 +1440,7 @@ core/sys/netbsd/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/netbsd
 	@: > core/sys/netbsd/$(am__dirstamp)
 core/sys/netbsd/dlfcn.lo: core/sys/netbsd/$(am__dirstamp)
+core/sys/netbsd/err.lo: core/sys/netbsd/$(am__dirstamp)
 core/sys/netbsd/execinfo.lo: core/sys/netbsd/$(am__dirstamp)
 core/sys/netbsd/string.lo: core/sys/netbsd/$(am__dirstamp)
 core/sys/netbsd/sys/$(am__dirstamp):
@@ -1488,6 +1461,7 @@ core/sys/openbsd/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/openbsd
 	@: > core/sys/openbsd/$(am__dirstamp)
 core/sys/openbsd/dlfcn.lo: core/sys/openbsd/$(am__dirstamp)
+core/sys/openbsd/err.lo: core/sys/openbsd/$(am__dirstamp)
 core/sys/openbsd/string.lo: core/sys/openbsd/$(am__dirstamp)
 core/sys/openbsd/sys/$(am__dirstamp):
 	@$(MKDIR_P) core/sys/openbsd/sys
@@ -1509,6 +1483,7 @@ core/sys/linux/config.lo: core/sys/linux/$(am__dirstamp)
 core/sys/linux/dlfcn.lo: core/sys/linux/$(am__dirstamp)
 core/sys/linux/elf.lo: core/sys/linux/$(am__dirstamp)
 core/sys/linux/epoll.lo: core/sys/linux/$(am__dirstamp)
+core/sys/linux/err.lo: core/sys/linux/$(am__dirstamp)
 core/sys/linux/errno.lo: core/sys/linux/$(am__dirstamp)
 core/sys/linux/execinfo.lo: core/sys/linux/$(am__dirstamp)
 core/sys/linux/fcntl.lo: core/sys/linux/$(am__dirstamp)
@@ -1660,6 +1635,7 @@ core/sys/windows/rpcnsi.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/rpcnsip.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/rpcnterr.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/schannel.lo: core/sys/windows/$(am__dirstamp)
+core/sys/windows/sdkddkver.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/secext.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/security.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/servprov.lo: core/sys/windows/$(am__dirstamp)
@@ -1677,6 +1653,10 @@ core/sys/windows/sqlucode.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/sspi.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/stacktrace.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/stat.lo: core/sys/windows/$(am__dirstamp)
+core/sys/windows/stdc/$(am__dirstamp):
+	@$(MKDIR_P) core/sys/windows/stdc
+	@: > core/sys/windows/stdc/$(am__dirstamp)
+core/sys/windows/stdc/time.lo: core/sys/windows/stdc/$(am__dirstamp)
 core/sys/windows/subauth.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/threadaux.lo: core/sys/windows/$(am__dirstamp)
 core/sys/windows/tlhelp32.lo: core/sys/windows/$(am__dirstamp)
@@ -1714,6 +1694,7 @@ core/sys/solaris/$(am__dirstamp):
 	@: > core/sys/solaris/$(am__dirstamp)
 core/sys/solaris/dlfcn.lo: core/sys/solaris/$(am__dirstamp)
 core/sys/solaris/elf.lo: core/sys/solaris/$(am__dirstamp)
+core/sys/solaris/err.lo: core/sys/solaris/$(am__dirstamp)
 core/sys/solaris/execinfo.lo: core/sys/solaris/$(am__dirstamp)
 core/sys/solaris/libelf.lo: core/sys/solaris/$(am__dirstamp)
 core/sys/solaris/link.lo: core/sys/solaris/$(am__dirstamp)
@@ -1873,6 +1854,8 @@ mostlyclean-compile:
 	-rm -f core/sys/posix/net/*.lo
 	-rm -f core/sys/posix/netinet/*.$(OBJEXT)
 	-rm -f core/sys/posix/netinet/*.lo
+	-rm -f core/sys/posix/stdc/*.$(OBJEXT)
+	-rm -f core/sys/posix/stdc/*.lo
 	-rm -f core/sys/posix/sys/*.$(OBJEXT)
 	-rm -f core/sys/posix/sys/*.lo
 	-rm -f core/sys/solaris/*.$(OBJEXT)
@@ -1881,6 +1864,10 @@ mostlyclean-compile:
 	-rm -f core/sys/solaris/sys/*.lo
 	-rm -f core/sys/windows/*.$(OBJEXT)
 	-rm -f core/sys/windows/*.lo
+	-rm -f core/sys/windows/stdc/*.$(OBJEXT)
+	-rm -f core/sys/windows/stdc/*.lo
+	-rm -f core/thread/*.$(OBJEXT)
+	-rm -f core/thread/*.lo
 	-rm -f gc/*.$(OBJEXT)
 	-rm -f gc/*.lo
 	-rm -f gc/impl/conservative/*.$(OBJEXT)
@@ -1895,8 +1882,6 @@ mostlyclean-compile:
 	-rm -f gcc/unwind/*.lo
 	-rm -f rt/*.$(OBJEXT)
 	-rm -f rt/*.lo
-	-rm -f rt/typeinfo/*.$(OBJEXT)
-	-rm -f rt/typeinfo/*.lo
 	-rm -f rt/util/*.$(OBJEXT)
 	-rm -f rt/util/*.lo
 	-rm -f rt/util/container/*.$(OBJEXT)
@@ -2016,10 +2001,13 @@ clean-libtool:
 	-rm -rf core/sys/posix/arpa/.libs core/sys/posix/arpa/_libs
 	-rm -rf core/sys/posix/net/.libs core/sys/posix/net/_libs
 	-rm -rf core/sys/posix/netinet/.libs core/sys/posix/netinet/_libs
+	-rm -rf core/sys/posix/stdc/.libs core/sys/posix/stdc/_libs
 	-rm -rf core/sys/posix/sys/.libs core/sys/posix/sys/_libs
 	-rm -rf core/sys/solaris/.libs core/sys/solaris/_libs
 	-rm -rf core/sys/solaris/sys/.libs core/sys/solaris/sys/_libs
 	-rm -rf core/sys/windows/.libs core/sys/windows/_libs
+	-rm -rf core/sys/windows/stdc/.libs core/sys/windows/stdc/_libs
+	-rm -rf core/thread/.libs core/thread/_libs
 	-rm -rf gc/.libs gc/_libs
 	-rm -rf gc/impl/conservative/.libs gc/impl/conservative/_libs
 	-rm -rf gc/impl/manual/.libs gc/impl/manual/_libs
@@ -2027,7 +2015,6 @@ clean-libtool:
 	-rm -rf gcc/sections/.libs gcc/sections/_libs
 	-rm -rf gcc/unwind/.libs gcc/unwind/_libs
 	-rm -rf rt/.libs rt/_libs
-	-rm -rf rt/typeinfo/.libs rt/typeinfo/_libs
 	-rm -rf rt/util/.libs rt/util/_libs
 	-rm -rf rt/util/container/.libs rt/util/container/_libs
 install-toolexeclibDATA: $(toolexeclib_DATA)
@@ -2170,10 +2157,13 @@ distclean-generic:
 	-rm -f core/sys/posix/arpa/$(am__dirstamp)
 	-rm -f core/sys/posix/net/$(am__dirstamp)
 	-rm -f core/sys/posix/netinet/$(am__dirstamp)
+	-rm -f core/sys/posix/stdc/$(am__dirstamp)
 	-rm -f core/sys/posix/sys/$(am__dirstamp)
 	-rm -f core/sys/solaris/$(am__dirstamp)
 	-rm -f core/sys/solaris/sys/$(am__dirstamp)
 	-rm -f core/sys/windows/$(am__dirstamp)
+	-rm -f core/sys/windows/stdc/$(am__dirstamp)
+	-rm -f core/thread/$(am__dirstamp)
 	-rm -f gc/$(am__dirstamp)
 	-rm -f gc/impl/conservative/$(am__dirstamp)
 	-rm -f gc/impl/manual/$(am__dirstamp)
@@ -2181,7 +2171,6 @@ distclean-generic:
 	-rm -f gcc/sections/$(am__dirstamp)
 	-rm -f gcc/unwind/$(am__dirstamp)
 	-rm -f rt/$(am__dirstamp)
-	-rm -f rt/typeinfo/$(am__dirstamp)
 	-rm -f rt/util/$(am__dirstamp)
 	-rm -f rt/util/container/$(am__dirstamp)
 
diff --git a/libphobos/libdruntime/core/internal/abort.d b/libphobos/libdruntime/core/internal/abort.d
index dfa3496c92c..8ee1684d146 100644
--- a/libphobos/libdruntime/core/internal/abort.d
+++ b/libphobos/libdruntime/core/internal/abort.d
@@ -4,7 +4,7 @@ module core.internal.abort;
  * Use instead of assert(0, msg), since this does not print a message for -release compiled
  * code, and druntime is -release compiled.
  */
-void abort(string msg, string filename = __FILE__, size_t line = __LINE__) @nogc nothrow @safe
+void abort(scope string msg, scope string filename = __FILE__, size_t line = __LINE__) @nogc nothrow @safe
 {
     import core.stdc.stdlib: c_abort = abort;
     // use available OS system calls to print the message to stderr
diff --git a/libphobos/libdruntime/core/stdc/complex.d b/libphobos/libdruntime/core/stdc/complex.d
index dae35f2725c..d878366b3bd 100644
--- a/libphobos/libdruntime/core/stdc/complex.d
+++ b/libphobos/libdruntime/core/stdc/complex.d
@@ -149,14 +149,14 @@ creal   csqrtl(creal z);
  ///
  real   cargl(creal z);
 
- ///
- double cimag(cdouble z);
- ///
- float  cimagf(cfloat z);
- ///
- real   cimagl(creal z);
+///
+pragma(inline, true) double cimag(cdouble z) { return z.im; }
+///
+pragma(inline, true) float  cimagf(cfloat z) { return z.im; }
+///
+pragma(inline, true) real   cimagl(creal z)  { return z.im; }
 
- ///
+///
 cdouble conj(cdouble z);
 ///
 cfloat  conjf(cfloat z);
@@ -170,8 +170,12 @@ cfloat  cprojf(cfloat z);
 ///
 creal   cprojl(creal z);
 
-// double creal(cdouble z);
+// Note: `creal` is a keyword in D and so this function is inaccessible, use `creald` instead
+//pragma(inline, true) double creal(cdouble z) { return z.re; }
+
 ///
- float  crealf(cfloat z);
- ///
- real   creall(creal z);
+pragma(inline, true) double creald(cdouble z) { return z.re; }
+///
+pragma(inline, true) float  crealf(cfloat z) { return z.re; }
+///
+pragma(inline, true) real   creall(creal z)  { return z.re; }
diff --git a/libphobos/libdruntime/core/stdc/errno.d b/libphobos/libdruntime/core/stdc/errno.d
index 767ed242472..31f7d11c762 100644
--- a/libphobos/libdruntime/core/stdc/errno.d
+++ b/libphobos/libdruntime/core/stdc/errno.d
@@ -1639,128 +1639,128 @@ else version (DragonFlyBSD)
 }
 else version (Solaris)
 {
-    enum EPERM =  1       /** Not super-user                       */;
-    enum ENOENT = 2       /** No such file or directory            */;
-    enum ESRCH =  3       /** No such process                      */;
-    enum EINTR =  4       /** interrupted system call              */;
-    enum EIO =    5       /** I/O error                            */;
-    enum ENXIO =  6       /** No such device or address            */;
-    enum E2BIG =  7       /** Arg list too long                    */;
-    enum ENOEXEC = 8       /** Exec format error                    */;
-    enum EBADF =  9       /** Bad file number                      */;
-    enum ECHILD = 10      /** No children                          */;
-    enum EAGAIN = 11      /** Resource temporarily unavailable     */;
-    enum ENOMEM = 12      /** Not enough core                      */;
-    enum EACCES = 13      /** Permission denied                    */;
-    enum EFAULT = 14      /** Bad address                          */;
-    enum ENOTBLK = 15      /** Block device required                */;
-    enum EBUSY =  16      /** Mount device busy                    */;
-    enum EEXIST = 17      /** File exists                          */;
-    enum EXDEV =  18      /** Cross-device link                    */;
-    enum ENODEV = 19      /** No such device                       */;
-    enum ENOTDIR = 20      /** Not a directory                      */;
-    enum EISDIR = 21      /** Is a directory                       */;
-    enum EINVAL = 22      /** Invalid argument                     */;
-    enum ENFILE = 23      /** File table overflow                  */;
-    enum EMFILE = 24      /** Too many open files                  */;
-    enum ENOTTY = 25      /** Inappropriate ioctl for device       */;
-    enum ETXTBSY = 26      /** Text file busy                       */;
-    enum EFBIG =  27      /** File too large                       */;
-    enum ENOSPC = 28      /** No space left on device              */;
-    enum ESPIPE = 29      /** Illegal seek                         */;
-    enum EROFS =  30      /** Read only file system                */;
-    enum EMLINK = 31      /** Too many links                       */;
-    enum EPIPE =  32      /** Broken pipe                          */;
-    enum EDOM =   33      /** Math arg out of domain of func       */;
-    enum ERANGE = 34      /** Math result not representable        */;
-    enum ENOMSG = 35      /** No message of desired type           */;
-    enum EIDRM =  36      /** Identifier removed                   */;
-    enum ECHRNG = 37      /** Channel number out of range          */;
-    enum EL2NSYNC = 38     /** Level 2 not synchronized             */;
-    enum EL3HLT = 39      /** Level 3 halted                       */;
-    enum EL3RST = 40      /** Level 3 reset                        */;
-    enum ELNRNG = 41      /** Link number out of range             */;
-    enum EUNATCH = 42      /** Protocol driver not attached         */;
-    enum ENOCSI = 43      /** No CSI structure available           */;
-    enum EL2HLT = 44      /** Level 2 halted                       */;
-    enum EDEADLK = 45      /** Deadlock condition.                  */;
-    enum ENOLCK = 46      /** No record locks available.           */;
-    enum ECANCELED = 47    /** Operation canceled                   */;
-    enum ENOTSUP = 48      /** Operation not supported              */;
-    enum EDQUOT = 49      /** Disc quota exceeded                  */;
-    enum EBADE =  50      /** invalid exchange                     */;
-    enum EBADR =  51      /** invalid request descriptor           */;
-    enum EXFULL = 52      /** exchange full                        */;
-    enum ENOANO = 53      /** no anode                             */;
-    enum EBADRQC = 54      /** invalid request code                 */;
-    enum EBADSLT = 55      /** invalid slot                         */;
-    enum EDEADLOCK = 56    /** file locking deadlock error          */;
-    enum EBFONT = 57      /** bad font file fmt                    */;
-    enum EOWNERDEAD =     58      /** process died with the lock */;
-    enum ENOTRECOVERABLE = 59      /** lock is not recoverable */;
-    enum ENOSTR = 60      /** Device not a stream                  */;
-    enum ENODATA = 61      /** no data (for no delay io)            */;
-    enum ETIME =  62      /** timer expired                        */;
-    enum ENOSR =  63      /** out of streams resources             */;
-    enum ENONET = 64      /** Machine is not on the network        */;
-    enum ENOPKG = 65      /** Package not installed                */;
-    enum EREMOTE = 66      /** The object is remote                 */;
-    enum ENOLINK = 67      /** the link has been severed            */;
-    enum EADV =   68      /** advertise error                      */;
-    enum ESRMNT = 69      /** srmount error                        */;
-    enum ECOMM =  70      /** Communication error on send          */;
-    enum EPROTO = 71      /** Protocol error                       */;
-    enum ELOCKUNMAPPED =  72      /** locked lock was unmapped */;
-    enum ENOTACTIVE = 73   /** Facility is not active               */;
-    enum EMULTIHOP = 74    /** multihop attempted                   */;
-    enum EBADMSG = 77      /** trying to read unreadable message    */;
-    enum ENAMETOOLONG = 78 /** path name is too long                */;
-    enum EOVERFLOW = 79    /** value too large to be stored in data type */;
-    enum ENOTUNIQ = 80     /** given log. name not unique           */;
-    enum EBADFD =  81      /** f.d. invalid for this operation      */;
-    enum EREMCHG = 82      /** Remote address changed               */;
-    enum ELIBACC = 83      /** Can't access a needed shared lib.    */;
-    enum ELIBBAD = 84      /** Accessing a corrupted shared lib.    */;
-    enum ELIBSCN = 85      /** .lib section in a.out corrupted.     */;
-    enum ELIBMAX = 86      /** Attempting to link in too many libs. */;
-    enum ELIBEXEC = 87     /** Attempting to exec a shared library. */;
-    enum EILSEQ = 88      /** Illegal byte sequence.               */;
-    enum ENOSYS = 89      /** Unsupported file system operation    */;
-    enum ELOOP =  90      /** Symbolic link loop                   */;
-    enum ERESTART = 91     /** Restartable system call              */;
-    enum ESTRPIPE = 92     /** if pipe/FIFO, don't sleep in stream head */;
-    enum ENOTEMPTY = 93    /** directory not empty                  */;
-    enum EUSERS = 94      /** Too many users (for UFS)             */;
-    enum ENOTSOCK =       95      /** Socket operation on non-socket */;
-    enum EDESTADDRREQ =   96      /** Destination address required */;
-    enum EMSGSIZE =       97      /** Message too long */;
-    enum EPROTOTYPE =     98      /** Protocol wrong type for socket */;
-    enum ENOPROTOOPT =    99      /** Protocol not available */;
-    enum EPROTONOSUPPORT = 120     /** Protocol not supported */;
-    enum ESOCKTNOSUPPORT = 121     /** Socket type not supported */;
-    enum EOPNOTSUPP =     122     /** Operation not supported on socket */;
-    enum EPFNOSUPPORT =   123     /** Protocol family not supported */;
-    enum EAFNOSUPPORT =   124     /** Address family not supported by the protocol family */;
-    enum EADDRINUSE =     125     /** Address already in use */;
-    enum EADDRNOTAVAIL =   126     /** Can't assign requested address */;
-    enum ENETDOWN =       127     /** Network is down */;
-    enum ENETUNREACH =    128     /** Network is unreachable */;
-    enum ENETRESET =      129     /** Network dropped connection because of reset */;
-    enum ECONNABORTED =   130     /** Software caused connection abort */;
-    enum ECONNRESET =     131     /** Connection reset by peer */;
-    enum ENOBUFS =        132     /** No buffer space available */;
-    enum EISCONN =        133     /** Socket is already connected */;
-    enum ENOTCONN =       134     /** Socket is not connected */;
-    enum ESHUTDOWN =      143     /** Can't send after socket shutdown */;
-    enum ETOOMANYREFS =   144     /** Too many references: can't splice */;
-    enum ETIMEDOUT =      145     /** Connection timed out */;
-    enum ECONNREFUSED =   146     /** Connection refused */;
-    enum EHOSTDOWN =      147     /** Host is down */;
-    enum EHOSTUNREACH =   148     /** No route to host */;
-    enum EWOULDBLOCK =    EAGAIN;      /** Resource temporarily unavailable     */;
-    enum EALREADY =       149     /** operation already in progress */;
-    enum EINPROGRESS =    150     /** operation now in progress */;
-    enum ESTALE =         151     /** Stale NFS file handle */;
+    enum EPERM =  1;              ///  Not super-user
+    enum ENOENT = 2;              ///  No such file or directory
+    enum ESRCH =  3;              ///  No such process
+    enum EINTR =  4;              ///  interrupted system call
+    enum EIO =    5;              ///  I/O error
+    enum ENXIO =  6;              ///  No such device or address
+    enum E2BIG =  7;              ///  Arg list too long
+    enum ENOEXEC = 8;             ///  Exec format error
+    enum EBADF =  9;              ///  Bad file number
+    enum ECHILD = 10;             ///  No children
+    enum EAGAIN = 11;             ///  Resource temporarily unavailable
+    enum ENOMEM = 12;             ///  Not enough core
+    enum EACCES = 13;             ///  Permission denied
+    enum EFAULT = 14;             ///  Bad address
+    enum ENOTBLK = 15;            ///  Block device required
+    enum EBUSY =  16;             ///  Mount device busy
+    enum EEXIST = 17;             ///  File exists
+    enum EXDEV =  18;             ///  Cross-device link
+    enum ENODEV = 19;             ///  No such device
+    enum ENOTDIR = 20;            ///  Not a directory
+    enum EISDIR = 21;             ///  Is a directory
+    enum EINVAL = 22;             ///  Invalid argument
+    enum ENFILE = 23;             ///  File table overflow
+    enum EMFILE = 24;             ///  Too many open files
+    enum ENOTTY = 25;             ///  Inappropriate ioctl for device
+    enum ETXTBSY = 26;            ///  Text file busy
+    enum EFBIG =  27;             ///  File too large
+    enum ENOSPC = 28;             ///  No space left on device
+    enum ESPIPE = 29;             ///  Illegal seek
+    enum EROFS =  30;             ///  Read only file system
+    enum EMLINK = 31;             ///  Too many links
+    enum EPIPE =  32;             ///  Broken pipe
+    enum EDOM =   33;             ///  Math arg out of domain of func
+    enum ERANGE = 34;             ///  Math result not representable
+    enum ENOMSG = 35;             ///  No message of desired type
+    enum EIDRM =  36;             ///  Identifier removed
+    enum ECHRNG = 37;             ///  Channel number out of range
+    enum EL2NSYNC = 38;           ///  Level 2 not synchronized
+    enum EL3HLT = 39;             ///  Level 3 halted
+    enum EL3RST = 40;             ///  Level 3 reset
+    enum ELNRNG = 41;             ///  Link number out of range
+    enum EUNATCH = 42;            ///  Protocol driver not attached
+    enum ENOCSI = 43;             ///  No CSI structure available
+    enum EL2HLT = 44;             ///  Level 2 halted
+    enum EDEADLK = 45;            ///  Deadlock condition.
+    enum ENOLCK = 46;             ///  No record locks available.
+    enum ECANCELED = 47;          ///  Operation canceled
+    enum ENOTSUP = 48;            ///  Operation not supported
+    enum EDQUOT = 49;             ///  Disc quota exceeded
+    enum EBADE =  50;             ///  invalid exchange
+    enum EBADR =  51;             ///  invalid request descriptor
+    enum EXFULL = 52;             ///  exchange full
+    enum ENOANO = 53;             ///  no anode
+    enum EBADRQC = 54;            ///  invalid request code
+    enum EBADSLT = 55;            ///  invalid slot
+    enum EDEADLOCK = 56;          ///  file locking deadlock error
+    enum EBFONT = 57;             ///  bad font file fmt
+    enum EOWNERDEAD =     58;     ///  process died with the lock
+    enum ENOTRECOVERABLE = 59;    ///  lock is not recoverable
+    enum ENOSTR = 60;             ///  Device not a stream
+    enum ENODATA = 61;            ///  no data (for no delay io)
+    enum ETIME =  62;             ///  timer expired
+    enum ENOSR =  63;             ///  out of streams resources
+    enum ENONET = 64;             ///  Machine is not on the network
+    enum ENOPKG = 65;             ///  Package not installed
+    enum EREMOTE = 66;            ///  The object is remote
+    enum ENOLINK = 67;            ///  the link has been severed
+    enum EADV =   68;             ///  advertise error
+    enum ESRMNT = 69;             ///  srmount error
+    enum ECOMM =  70;             ///  Communication error on send
+    enum EPROTO = 71;             ///  Protocol error
+    enum ELOCKUNMAPPED =  72;     ///  locked lock was unmapped
+    enum ENOTACTIVE = 73;         ///  Facility is not active
+    enum EMULTIHOP = 74;          ///  multihop attempted
+    enum EBADMSG = 77;            ///  trying to read unreadable message
+    enum ENAMETOOLONG = 78;       ///  path name is too long
+    enum EOVERFLOW = 79;          ///  value too large to be stored in data type
+    enum ENOTUNIQ = 80;           ///  given log. name not unique
+    enum EBADFD =  81;            ///  f.d. invalid for this operation
+    enum EREMCHG = 82;            ///  Remote address changed
+    enum ELIBACC = 83;            ///  Can't access a needed shared lib.
+    enum ELIBBAD = 84;            ///  Accessing a corrupted shared lib.
+    enum ELIBSCN = 85;            ///  .lib section in a.out corrupted.
+    enum ELIBMAX = 86;            ///  Attempting to link in too many libs.
+    enum ELIBEXEC = 87;           ///  Attempting to exec a shared library.
+    enum EILSEQ = 88;             ///  Illegal byte sequence.
+    enum ENOSYS = 89;             ///  Unsupported file system operation
+    enum ELOOP =  90;             ///  Symbolic link loop
+    enum ERESTART = 91;           ///  Restartable system call
+    enum ESTRPIPE = 92;           ///  if pipe/FIFO, don't sleep in stream head
+    enum ENOTEMPTY = 93;          ///  directory not empty
+    enum EUSERS = 94;             ///  Too many users (for UFS)
+    enum ENOTSOCK =       95;     ///  Socket operation on non-socket
+    enum EDESTADDRREQ =   96;     ///  Destination address required
+    enum EMSGSIZE =       97;     ///  Message too long
+    enum EPROTOTYPE =     98;     ///  Protocol wrong type for socket
+    enum ENOPROTOOPT =    99;     ///  Protocol not available
+    enum EPROTONOSUPPORT = 120;   ///  Protocol not supported
+    enum ESOCKTNOSUPPORT = 121;   ///  Socket type not supported
+    enum EOPNOTSUPP =     122;    ///  Operation not supported on socket
+    enum EPFNOSUPPORT =   123;    ///  Protocol family not supported
+    enum EAFNOSUPPORT =   124;    ///  Address family not supported by the protocol family
+    enum EADDRINUSE =     125;    ///  Address already in use
+    enum EADDRNOTAVAIL =   126;   ///  Can't assign requested address
+    enum ENETDOWN =       127;    ///  Network is down
+    enum ENETUNREACH =    128;    ///  Network is unreachable
+    enum ENETRESET =      129;    ///  Network dropped connection because of reset
+    enum ECONNABORTED =   130;    ///  Software caused connection abort
+    enum ECONNRESET =     131;    ///  Connection reset by peer
+    enum ENOBUFS =        132;    ///  No buffer space available
+    enum EISCONN =        133;    ///  Socket is already connected
+    enum ENOTCONN =       134;    ///  Socket is not connected
+    enum ESHUTDOWN =      143;    ///  Can't send after socket shutdown
+    enum ETOOMANYREFS =   144;    ///  Too many references: can't splice
+    enum ETIMEDOUT =      145;    ///  Connection timed out
+    enum ECONNREFUSED =   146;    ///  Connection refused
+    enum EHOSTDOWN =      147;    ///  Host is down
+    enum EHOSTUNREACH =   148;    ///  No route to host
+    enum EWOULDBLOCK =    EAGAIN; ///  Resource temporarily unavailable
+    enum EALREADY =       149;    ///  operation already in progress
+    enum EINPROGRESS =    150;    ///  operation now in progress
+    enum ESTALE =         151;    ///  Stale NFS file handle
 }
 else version (Haiku)
 {
diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d
index e5d2519a00d..3002c022613 100644
--- a/libphobos/libdruntime/core/stdc/fenv.d
+++ b/libphobos/libdruntime/core/stdc/fenv.d
@@ -149,10 +149,10 @@ version (GNUFP)
         alias fexcept_t = uint;
     }
     // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/sparc/fpu/bits/fenv.h
-    else version (SPARC64)
+    else version (SPARC_Any)
     {
-        alias fenv_t = ulong;
-        alias fexcept_t = ulong;
+        alias fenv_t = c_ulong;
+        alias fexcept_t = c_ulong;
     }
     // https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/s390/fpu/bits/fenv.h
     else version (IBMZ_Any)
@@ -237,7 +237,7 @@ else version (NetBSD)
                     uint status;        /* Status word register */
                     uint tag;           /* Tag word register */
                     uint[4] others;     /* EIP, Pointer Selector, etc */
-            };
+            }
             _x87 x87;
 
             uint mxcsr;                 /* Control and status register */
@@ -256,10 +256,10 @@ else version (NetBSD)
                     ushort tag;         /* Tag word register */
                     ushort unused3;
                     uint[4] others;     /* EIP, Pointer Selector, etc */
-            };
+            }
             _x87 x87;
             uint mxcsr;                 /* Control and status register */
-        };
+        }
 
     }
 
@@ -291,7 +291,7 @@ else version (DragonFlyBSD)
                 uint status;
                 uint tag;
                 uint[4] others;
-        };
+        }
         _x87 x87;
 
         uint mxcsr;
@@ -877,7 +877,7 @@ int feholdexcept(fenv_t* envp);
 ///
 int fegetexceptflag(fexcept_t* flagp, int excepts);
 ///
-int fesetexceptflag(in fexcept_t* flagp, int excepts);
+int fesetexceptflag(const scope fexcept_t* flagp, int excepts);
 
 ///
 int fegetround();
@@ -887,7 +887,7 @@ int fesetround(int round);
 ///
 int fegetenv(fenv_t* envp);
 ///
-int fesetenv(in fenv_t* envp);
+int fesetenv(const scope fenv_t* envp);
 
 // MS define feraiseexcept() and feupdateenv() inline.
 version (CRuntime_Microsoft) // supported since MSVCRT 12 (VS 2013) only
@@ -925,7 +925,7 @@ version (CRuntime_Microsoft) // supported since MSVCRT 12 (VS 2013) only
     }
 
     ///
-    int feupdateenv()(in fenv_t* envp)
+    int feupdateenv()(const scope fenv_t* envp)
     {
         int excepts = fetestexcept(FE_ALL_EXCEPT);
         return (fesetenv(envp) != 0 || feraiseexcept(excepts) != 0 ? 1 : 0);
@@ -936,5 +936,5 @@ else
     ///
     int feraiseexcept(int excepts);
     ///
-    int feupdateenv(in fenv_t* envp);
+    int feupdateenv(const scope fenv_t* envp);
 }
diff --git a/libphobos/libdruntime/core/stdc/inttypes.d b/libphobos/libdruntime/core/stdc/inttypes.d
index d74ee7998ab..7f30e38ab92 100644
--- a/libphobos/libdruntime/core/stdc/inttypes.d
+++ b/libphobos/libdruntime/core/stdc/inttypes.d
@@ -434,10 +434,10 @@ intmax_t  imaxabs(intmax_t j);
 ///
 imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
 ///
-intmax_t  strtoimax(in char* nptr, char** endptr, int base);
+intmax_t  strtoimax(const scope char* nptr, char** endptr, int base);
 ///
-uintmax_t strtoumax(in char* nptr, char** endptr, int base);
+uintmax_t strtoumax(const scope char* nptr, char** endptr, int base);
 ///
-intmax_t  wcstoimax(in wchar_t* nptr, wchar_t** endptr, int base);
+intmax_t  wcstoimax(const scope wchar_t* nptr, wchar_t** endptr, int base);
 ///
-uintmax_t wcstoumax(in wchar_t* nptr, wchar_t** endptr, int base);
+uintmax_t wcstoumax(const scope wchar_t* nptr, wchar_t** endptr, int base);
diff --git a/libphobos/libdruntime/core/stdc/limits.d b/libphobos/libdruntime/core/stdc/limits.d
index 3ab7ed1e4f7..f3f88006a12 100644
--- a/libphobos/libdruntime/core/stdc/limits.d
+++ b/libphobos/libdruntime/core/stdc/limits.d
@@ -23,7 +23,7 @@ else version (TVOS)
 else version (WatchOS)
     version = Darwin;
 
-private import core.stdc.config;
+import core.stdc.config;
 
 extern (C):
 @trusted: // Constants only.
diff --git a/libphobos/libdruntime/core/stdc/locale.d b/libphobos/libdruntime/core/stdc/locale.d
index 3ba348adbf0..4b8d5c82e02 100644
--- a/libphobos/libdruntime/core/stdc/locale.d
+++ b/libphobos/libdruntime/core/stdc/locale.d
@@ -287,6 +287,6 @@ else
 }
 
 ///
-@system char*  setlocale(int category, in char* locale);
+@system char*  setlocale(int category, const scope char* locale);
 ///
 lconv* localeconv();
diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d
index 492978939d8..e8d1fa8e7b5 100644
--- a/libphobos/libdruntime/core/stdc/math.d
+++ b/libphobos/libdruntime/core/stdc/math.d
@@ -13,7 +13,7 @@
 
 module core.stdc.math;
 
-private import core.stdc.config;
+import core.stdc.config;
 
 version (OSX)
     version = Darwin;
@@ -1037,14 +1037,25 @@ else version (Darwin)
     // other Darwins
     version (OSX)
     {
-        pure int __fpclassify(real x);
-        pure int __isfinite(real x);
-        pure int __isinf(real x);
-        pure int __isnan(real x);
-        alias __fpclassifyl = __fpclassify;
-        alias __isfinitel = __isfinite;
-        alias __isinfl = __isinf;
-        alias __isnanl = __isnan;
+        version (AArch64)
+        {
+            // Available in macOS ARM
+            pure int __fpclassifyl(real x);
+            pure int __isfinitel(real x);
+            pure int __isinfl(real x);
+            pure int __isnanl(real x);
+        }
+        else
+        {
+            pure int __fpclassify(real x);
+            pure int __isfinite(real x);
+            pure int __isinf(real x);
+            pure int __isnan(real x);
+            alias __fpclassifyl = __fpclassify;
+            alias __isfinitel = __isfinite;
+            alias __isinfl = __isinf;
+            alias __isnanl = __isnan;
+        }
     }
     else
     {
@@ -2028,464 +2039,406 @@ version (CRuntime_Microsoft) // fully supported since MSVCRT 12 (VS 2013) only
     ///
     extern(D) pure real fmal()(real x, real y, real z) { return fma(cast(double) x, cast(double) y, cast(double) z); }
 }
-/* NOTE: freebsd < 8-CURRENT doesn't appear to support *l, but we can
- *       approximate.
- * A lot of them were added in 8.0-RELEASE, and so a lot of these workarounds
- * should then be removed.
- */
-// NOTE: FreeBSD 8.0-RELEASE doesn't support log2* nor these *l functions:
-//         acoshl, asinhl, atanhl, coshl, sinhl, tanhl, cbrtl, powl, expl,
-//         expm1l, logl, log1pl, log10l, erfcl, erfl, lgammal, tgammal;
-//       but we can approximate.
 else version (FreeBSD)
 {
-  version (none) // < 8-CURRENT
-  {
-    extern (D)
-    {
-        real    acosl(real x) { return acos(x); }
-        real    asinl(real x) { return asin(x); }
-        pure real    atanl(real x) { return atan(x); }
-        real    atan2l(real y, real x) { return atan2(y, x); }
-        pure real    cosl(real x) { return cos(x); }
-        pure real    sinl(real x) { return sin(x); }
-        pure real    tanl(real x) { return tan(x); }
-        real    exp2l(real x) { return exp2(x); }
-        pure real    frexpl(real value, int* exp) { return frexp(value, exp); }
-        int     ilogbl(real x) { return ilogb(x); }
-        real    ldexpl(real x, int exp) { return ldexp(x, exp); }
-        real    logbl(real x) { return logb(x); }
-        //real    modfl(real value, real *iptr); // nontrivial conversion
-        real    scalbnl(real x, int n) { return scalbn(x, n); }
-        real    scalblnl(real x, c_long n) { return scalbln(x, n); }
-        pure real    fabsl(real x) { return fabs(x); }
-        real    hypotl(real x, real y) { return hypot(x, y); }
-        real    sqrtl(real x) { return sqrt(x); }
-        pure real    ceill(real x) { return ceil(x); }
-        pure real    floorl(real x) { return floor(x); }
-        pure real    nearbyintl(real x) { return nearbyint(x); }
-        pure real    rintl(real x) { return rint(x); }
-        c_long  lrintl(real x) { return lrint(x); }
-        pure real    roundl(real x) { return round(x); }
-        c_long  lroundl(real x) { return lround(x); }
-        long    llroundl(real x) { return llround(x); }
-        pure real    truncl(real x) { return trunc(x); }
-        real    fmodl(real x, real y) { return fmod(x, y); }
-        real    remainderl(real x, real y) { return remainder(x, y); }
-        real    remquol(real x, real y, int* quo) { return remquo(x, y, quo); }
-        pure real    copysignl(real x, real y) { return copysign(x, y); }
-        //pure double  nan(char* tagp);
-        //pure float   nanf(char* tagp);
-        //pure real    nanl(char* tagp);
-        real    nextafterl(real x, real y) { return nextafter(x, y); }
-        real    nexttowardl(real x, real y) { return nexttoward(x, y); }
-        real    fdiml(real x, real y) { return fdim(x, y); }
-        pure real    fmaxl(real x, real y) { return fmax(x, y); }
-        pure real    fminl(real x, real y) { return fmin(x, y); }
-        pure real    fmal(real x, real y, real z) { return fma(x, y, z); }
-    }
-  }
-  else
-  {
-    ///
-    real    acosl(real x);
-    ///
-    real    asinl(real x);
-    ///
-    pure real    atanl(real x);
-    ///
-    real    atan2l(real y, real x);
-    ///
-    pure real    cosl(real x);
-    ///
-    pure real    sinl(real x);
-    ///
-    pure real    tanl(real x);
-    ///
-    real    exp2l(real x);
-    ///
-    pure real    frexpl(real value, int* exp);
-    ///
-    int     ilogbl(real x);
-    ///
-    real    ldexpl(real x, int exp);
-    ///
-    real    logbl(real x);
-    ///
-    pure real    modfl(real value, real *iptr);
-    ///
-    real    scalbnl(real x, int n);
-    ///
-    real    scalblnl(real x, c_long n);
-    ///
-    pure real    fabsl(real x);
-    ///
-    real    hypotl(real x, real y);
-    ///
-    real    sqrtl(real x);
-    ///
-    pure real    ceill(real x);
-    ///
-    pure real    floorl(real x);
-    ///
-    pure real    nearbyintl(real x);
-    ///
-    pure real    rintl(real x);
-    ///
-    c_long  lrintl(real x);
-    ///
-    pure real    roundl(real x);
-    ///
-    c_long  lroundl(real x);
-    ///
-    long    llroundl(real x);
-    ///
-    pure real    truncl(real x);
-    ///
-    real    fmodl(real x, real y);
     ///
-    real    remainderl(real x, real y);
-    ///
-    real    remquol(real x, real y, int* quo);
-    ///
-    pure real    copysignl(real x, real y);
-    ///
-    pure double  nan(char* tagp);
-    ///
-    pure float   nanf(char* tagp);
-    ///
-    pure real    nanl(char* tagp);
-    ///
-    real    nextafterl(real x, real y);
-    ///
-    real    nexttowardl(real x, real y);
-    ///
-    real    fdiml(real x, real y);
-    ///
-    pure real    fmaxl(real x, real y);
-    ///
-    pure real    fminl(real x, real y);
-    ///
-    pure real    fmal(real x, real y, real z);
-  }
-  ///
     double  acos(double x);
     ///
     float   acosf(float x);
+    ///
+    real    acosl(real x); // since 8.0
 
     ///
     double  asin(double x);
     ///
     float   asinf(float x);
+    ///
+    real    asinl(real x); // since 8.0
 
     ///
     pure double  atan(double x);
     ///
     pure float   atanf(float x);
+    ///
+    pure real    atanl(real x); // since 8.0
 
     ///
     double  atan2(double y, double x);
     ///
     float   atan2f(float y, float x);
+    ///
+    real    atan2l(real y, real x); // since 8.0
 
     ///
     pure double  cos(double x);
     ///
     pure float   cosf(float x);
+    ///
+    pure real    cosl(real x); // since 8.0
 
     ///
     pure double  sin(double x);
     ///
     pure float   sinf(float x);
+    ///
+    pure real    sinl(real x); // since 8.0
 
     ///
     pure double  tan(double x);
     ///
     pure float   tanf(float x);
+    ///
+    pure real    tanl(real x); // since 8.0
 
     ///
     double  acosh(double x);
     ///
     float   acoshf(float x);
     ///
-    extern(D) real acoshl(real x) { return acosh(x); }
+    real    acoshl(real x); // since 10.0
 
     ///
     pure double  asinh(double x);
     ///
     pure float   asinhf(float x);
     ///
-    extern(D) pure real asinhl(real x) { return asinh(x); }
+    pure real    asinhl(real x); // since 10.0
 
     ///
     double  atanh(double x);
     ///
     float   atanhf(float x);
     ///
-    extern(D) real atanhl(real x) { return atanh(x); }
+    real    atanhl(real x); // since 10.0
 
     ///
     double  cosh(double x);
     ///
     float   coshf(float x);
     ///
-    extern(D) real coshl(real x) { return cosh(x); }
+    real    coshl(real x); // since 10.1
 
     ///
     double  sinh(double x);
     ///
     float   sinhf(float x);
     ///
-    extern(D) real sinhl(real x) { return sinh(x); }
+    real    sinhl(real x); // since 10.1
 
     ///
     pure double  tanh(double x);
     ///
     pure float   tanhf(float x);
     ///
-    extern(D) pure real tanhl(real x) { return tanh(x); }
+    pure real    tanhl(real x); // since 10.1
 
     ///
     double  exp(double x);
     ///
     float   expf(float x);
     ///
-    extern(D) real expl(real x) { return exp(x); }
+    real    expl(real x); // since 10.0
 
     ///
     double  exp2(double x);
     ///
     float   exp2f(float x);
+    ///
+    real    exp2l(real x); // since 8.0
 
     ///
     double  expm1(double x);
     ///
     float   expm1f(float x);
     ///
-    extern(D) real expm1l(real x) { return expm1(x); }
+    real    expm1l(real x); // since 10.0
 
     ///
     pure double  frexp(double value, int* exp);
     ///
     pure float   frexpf(float value, int* exp);
+    ///
+    pure real    frexpl(real value, int* exp); // since 6.0
 
     ///
     int     ilogb(double x);
     ///
     int     ilogbf(float x);
+    ///
+    int     ilogbl(real x); // since 5.4
 
     ///
     double  ldexp(double x, int exp);
     ///
     float   ldexpf(float x, int exp);
+    ///
+    real    ldexpl(real x, int exp); // since 6.0
 
     ///
     double  log(double x);
     ///
     float   logf(float x);
     ///
-    extern(D) real logl(real x) { return log(x); }
+    real    logl(real x); // since 10.0
 
     ///
     double  log10(double x);
     ///
     float   log10f(float x);
     ///
-    extern(D) real log10l(real x) { return log10(x); }
+    real    log10l(real x); // since 10.0
 
     ///
     double  log1p(double x);
     ///
     float   log1pf(float x);
     ///
-    extern(D) real log1pl(real x) { return log1p(x); }
+    real    log1pl(real x); // since 10.0
 
-    private enum real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L;
     ///
-    extern(D) double log2(double x) { return log(x) * ONE_LN2; }
+    double log2(double x); // since 8.3
     ///
-    extern(D) float  log2f(float x) { return logf(x) * ONE_LN2; }
+    float  log2f(float x); // since 8.3
     ///
-    extern(D) real   log2l(real x)  { return logl(x) * ONE_LN2; }
+    real   log2l(real x); // since 10.0
 
     ///
     double  logb(double x);
     ///
     float   logbf(float x);
+    ///
+    real    logbl(real x); // since 8.0
 
     ///
     pure double  modf(double value, double* iptr);
     ///
     pure float   modff(float value, float* iptr);
+    ///
+    pure real    modfl(real value, real *iptr); // since 8.0
 
     ///
     double  scalbn(double x, int n);
     ///
     float   scalbnf(float x, int n);
+    ///
+    real    scalbnl(real x, int n); // since 6.0
 
     ///
     double  scalbln(double x, c_long n);
     ///
     float   scalblnf(float x, c_long n);
+    ///
+    real    scalblnl(real x, c_long n); // since 6.0
 
     ///
     pure double  cbrt(double x);
     ///
     pure float   cbrtf(float x);
     ///
-    extern(D) pure real cbrtl(real x) { return cbrt(x); }
+    pure real    cbrtl(real x); // since 9.0
 
     ///
     pure double  fabs(double x);
     ///
     pure float   fabsf(float x);
+    ///
+    pure real    fabsl(real x); // since 5.3
 
     ///
     double  hypot(double x, double y);
     ///
     float   hypotf(float x, float y);
+    ///
+    real    hypotl(real x, real y); // since 8.0
 
     ///
     double  pow(double x, double y);
     ///
     float   powf(float x, float y);
     ///
-    extern(D) real powl(real x, real y) { return pow(x, y); }
+    real    powl(real x, real y); // since 10.4
 
     ///
     double  sqrt(double x);
     ///
     float   sqrtf(float x);
+    ///
+    real    sqrtl(real x); // since 8.0
 
     ///
     pure double  erf(double x);
     ///
     pure float   erff(float x);
     ///
-    extern(D) pure real erfl(real x) { return erf(x); }
+    pure real    erfl(real x); // since 10.1
 
     ///
     double  erfc(double x);
     ///
     float   erfcf(float x);
     ///
-    extern(D) real erfcl(real x) { return erfc(x); }
+    real    erfcl(real x); // since 10.1
 
     ///
     double  lgamma(double x);
     ///
     float   lgammaf(float x);
     ///
-    extern(D) real lgammal(real x) { return lgamma(x); }
+    real    lgammal(real x); // since 10.2
 
     ///
     double  tgamma(double x);
     ///
     float   tgammaf(float x);
     ///
-    extern(D) real tgammal(real x) { return tgamma(x); }
+    real    tgammal(real x); // since 11.2
 
     ///
     pure double  ceil(double x);
     ///
     pure float   ceilf(float x);
+    ///
+    pure real    ceill(real x); // since 5.4
 
     ///
     pure double  floor(double x);
     ///
     pure float   floorf(float x);
+    ///
+    pure real    floorl(real x); // since 5.4
 
     ///
     pure double  nearbyint(double x);
     ///
     pure float   nearbyintf(float x);
+    ///
+    pure real    nearbyintl(real x); // since 8.0
 
     ///
     pure double  rint(double x);
     ///
     pure float   rintf(float x);
+    ///
+    pure real    rintl(real x); // since 8.0
 
     ///
     c_long  lrint(double x);
     ///
     c_long  lrintf(float x);
+    ///
+    c_long  lrintl(real x); // since 8.0
 
     ///
     long    llrint(double x);
     ///
     long    llrintf(float x);
     ///
-    extern(D) long llrintl(real x) { return llrint(x); }
+    long    llrintl(real x); // since 8.0
 
     ///
     pure double  round(double x);
     ///
     pure float   roundf(float x);
+    ///
+    pure real    roundl(real x); // since 6.0
 
     ///
     c_long  lround(double x);
     ///
     c_long  lroundf(float x);
+    ///
+    c_long  lroundl(real x); // since 6.0
 
     ///
     long    llround(double x);
     ///
     long    llroundf(float x);
+    ///
+    long    llroundl(real x); // since 6.0
 
     ///
     pure double  trunc(double x);
     ///
     pure float   truncf(float x);
+    ///
+    pure real    truncl(real x); // since 6.0
 
     ///
     double  fmod(double x, double y);
     ///
     float   fmodf(float x, float y);
+    ///
+    real    fmodl(real x, real y); // since 8.0
 
     ///
     double  remainder(double x, double y);
     ///
     float   remainderf(float x, float y);
+    ///
+    real    remainderl(real x, real y); // since 8.0
 
     ///
     double  remquo(double x, double y, int* quo);
     ///
     float   remquof(float x, float y, int* quo);
+    ///
+    real    remquol(real x, real y, int* quo); // since 8.0
 
     ///
     pure double  copysign(double x, double y);
     ///
     pure float   copysignf(float x, float y);
+    ///
+    pure real    copysignl(real x, real y); // since 5.3
+
+    ///
+    pure double  nan(const char*); // since 8.0
+    ///
+    pure float   nanf(const char*); // since 8.0
+    ///
+    pure real    nanl(const char*); // since 8.0
 
     ///
     double  nextafter(double x, double y);
     ///
     float   nextafterf(float x, float y);
+    ///
+    real    nextafterl(real x, real y); // since 6.0
 
     ///
     double  nexttoward(double x, real y);
     ///
     float   nexttowardf(float x, real y);
+    ///
+    real    nexttowardl(real x, real y); // since 6.0
 
     ///
     double  fdim(double x, double y);
     ///
     float   fdimf(float x, float y);
+    ///
+    real    fdiml(real x, real y); // since 5.3
 
     ///
     pure double  fmax(double x, double y);
     ///
     pure float   fmaxf(float x, float y);
+    ///
+    pure real    fmaxl(real x, real y); // since 5.3
 
     ///
     pure double  fmin(double x, double y);
     ///
     pure float   fminf(float x, float y);
+    ///
+    pure real    fminl(real x, real y); // since 5.3
 
     ///
     pure double  fma(double x, double y, double z);
     ///
     pure float   fmaf(float x, float y, float z);
+    ///
+    pure real    fmal(real x, real y, real z); // since 6.0
 }
 else version (NetBSD)
 {
diff --git a/libphobos/libdruntime/core/stdc/stdarg.d b/libphobos/libdruntime/core/stdc/stdarg.d
index 586fe20d991..9a67f2e8e4d 100644
--- a/libphobos/libdruntime/core/stdc/stdarg.d
+++ b/libphobos/libdruntime/core/stdc/stdarg.d
@@ -3,525 +3,332 @@
  *
  * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_stdarg.h.html, _stdarg.h)
  *
- * Copyright: Copyright Digital Mars 2000 - 2009.
+ * Copyright: Copyright Digital Mars 2000 - 2020.
  * License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
  * Authors:   Walter Bright, Hauke Duden
  * Standards: ISO/IEC 9899:1999 (E)
  * Source: $(DRUNTIMESRC core/stdc/_stdarg.d)
  */
 
-/* NOTE: This file has been patched from the original DMD distribution to
- * work with the GDC compiler.
- */
 module core.stdc.stdarg;
 
 @system:
-//@nogc:    // Not yet, need to make TypeInfo's member functions @nogc first
+@nogc:
 nothrow:
 
+version (X86_64)
+{
+    version (Windows) { /* different ABI */ }
+    else version = SysV_x64;
+}
+
 version (GNU)
 {
     import gcc.builtins;
-    alias __builtin_va_list __gnuc_va_list;
-
-
-    /*********************
-     * The argument pointer type.
-     */
-    alias __gnuc_va_list va_list;
-
-
-    /**********
-     * Initialize ap.
-     * parmn should be the last named parameter.
-     */
-    void va_start(T)(out va_list ap, ref T parmn);
-
+}
+else version (SysV_x64)
+{
+    static import core.internal.vararg.sysv_x64;
 
-    /************
-     * Retrieve and return the next value that is type T.
-     */
-    T va_arg(T)(ref va_list ap);
+    version (DigitalMars)
+    {
+        align(16) struct __va_argsave_t
+        {
+            size_t[6] regs;   // RDI,RSI,RDX,RCX,R8,R9
+            real[8] fpregs;   // XMM0..XMM7
+            __va_list va;
+        }
+    }
+}
 
+version (ARM)     version = ARM_Any;
+version (AArch64) version = ARM_Any;
+version (MIPS32)  version = MIPS_Any;
+version (MIPS64)  version = MIPS_Any;
+version (PPC)     version = PPC_Any;
+version (PPC64)   version = PPC_Any;
 
-    /*************
-     * Retrieve and store through parmn the next value that is of type T.
-     */
-    void va_arg(T)(ref va_list ap, ref T parmn);
+version (GNU)
+{
+    // Uses gcc.builtins
+}
+else version (ARM_Any)
+{
+    // Darwin uses a simpler varargs implementation
+    version (OSX) {}
+    else version (iOS) {}
+    else version (TVOS) {}
+    else version (WatchOS) {}
+    else:
+
+    version (ARM)
+    {
+        version = AAPCS32;
+    }
+    else version (AArch64)
+    {
+        version = AAPCS64;
+        static import core.internal.vararg.aarch64;
+    }
+}
 
 
-    /***********************
-     * End use of ap.
-     */
-    alias __builtin_va_end va_end;
+T alignUp(size_t alignment = size_t.sizeof, T)(T base) pure
+{
+    enum mask = alignment - 1;
+    static assert(alignment > 0 && (alignment & mask) == 0, "alignment must be a power of 2");
+    auto b = cast(size_t) base;
+    b = (b + mask) & ~mask;
+    return cast(T) b;
+}
 
+unittest
+{
+    assert(1.alignUp == size_t.sizeof);
+    assert(31.alignUp!16 == 32);
+    assert(32.alignUp!16 == 32);
+    assert(33.alignUp!16 == 48);
+    assert((-9).alignUp!8 == -8);
+}
 
-    /***********************
-     * Make a copy of ap.
-     */
-    alias __builtin_va_copy va_copy;
 
-}
-else version (X86)
+version (BigEndian)
 {
-    /*********************
-     * The argument pointer type.
-     */
-    alias char* va_list;
-
-    /**********
-     * Initialize ap.
-     * For 32 bit code, parmn should be the last named parameter.
-     * For 64 bit code, parmn should be __va_argsave.
-     */
-    void va_start(T)(out va_list ap, ref T parmn)
+    // Adjusts a size_t-aligned pointer for types smaller than size_t.
+    T* adjustForBigEndian(T)(T* p, size_t size) pure
     {
-        ap = cast(va_list)( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
+        return size >= size_t.sizeof ? p :
+            cast(T*) ((cast(void*) p) + (size_t.sizeof - size));
     }
+}
 
-    /************
-     * Retrieve and return the next value that is type T.
-     * Should use the other va_arg instead, as this won't work for 64 bit code.
-     */
-    T va_arg(T)(ref va_list ap)
-    {
-        T arg = *cast(T*) ap;
-        ap = cast(va_list)( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
-        return arg;
-    }
 
-    /************
-     * Retrieve and return the next value that is type T.
-     * This is the preferred version.
-     */
-    void va_arg(T)(ref va_list ap, ref T parmn)
-    {
-        parmn = *cast(T*)ap;
-        ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)));
-    }
+/**
+ * The argument pointer type.
+ */
+version (GNU)
+{
+    alias va_list = __gnuc_va_list;
+    alias __gnuc_va_list = __builtin_va_list;
+}
+else version (SysV_x64)
+{
+    alias va_list = core.internal.vararg.sysv_x64.va_list;
+    public import core.internal.vararg.sysv_x64 : __va_list, __va_list_tag;
+}
+else version (AAPCS32)
+{
+    alias va_list = __va_list;
 
-    /*************
-     * Retrieve and store through parmn the next value that is of TypeInfo ti.
-     * Used when the static type is not known.
-     */
-    void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
+    // need std::__va_list for C++ mangling compatibility (AAPCS32 section 8.1.4)
+    extern (C++, std) struct __va_list
     {
-        // Wait until everyone updates to get TypeInfo.talign
-        //auto talign = ti.talign;
-        //auto p = cast(void*)(cast(size_t)ap + talign - 1) & ~(talign - 1);
-        auto p = ap;
-        auto tsize = ti.tsize;
-        ap = cast(va_list)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
-        parmn[0..tsize] = p[0..tsize];
+        void* __ap;
     }
+}
+else version (AAPCS64)
+{
+    alias va_list = core.internal.vararg.aarch64.va_list;
+}
+else
+{
+    alias va_list = char*; // incl. unknown platforms
+}
 
-    /***********************
-     * End use of ap.
-     */
-    void va_end(va_list ap)
+
+/**
+ * Initialize ap.
+ * parmn should be the last named parameter.
+ */
+version (GNU)
+{
+    void va_start(T)(out va_list ap, ref T parmn);
+}
+else version (LDC)
+{
+    pragma(LDC_va_start)
+    void va_start(T)(out va_list ap, ref T parmn) @nogc;
+}
+else version (DigitalMars)
+{
+    version (X86)
     {
+        void va_start(T)(out va_list ap, ref T parmn)
+        {
+            ap = cast(va_list) ((cast(void*) &parmn) + T.sizeof.alignUp);
+        }
     }
-
-    ///
-    void va_copy(out va_list dest, va_list src)
+    else
     {
-        dest = src;
+        void va_start(T)(out va_list ap, ref T parmn); // intrinsic; parmn should be __va_argsave for non-Windows x86_64 targets
     }
 }
-else version (Windows) // Win64
-{   /* Win64 is characterized by all arguments fitting into a register size.
-     * Smaller ones are padded out to register size, and larger ones are passed by
-     * reference.
-     */
 
-    /*********************
-     * The argument pointer type.
-     */
-    alias char* va_list;
 
-    /**********
-     * Initialize ap.
-     * parmn should be the last named parameter.
-     */
-    void va_start(T)(out va_list ap, ref T parmn); // Compiler intrinsic
-
-    /************
-     * Retrieve and return the next value that is type T.
-     */
-    T va_arg(T)(ref va_list ap)
+/**
+ * Retrieve and return the next value that is of type T.
+ */
+version (GNU)
+    T va_arg(T)(ref va_list ap); // intrinsic
+else
+T va_arg(T)(ref va_list ap)
+{
+    version (X86)
     {
-        static if (T.sizeof > size_t.sizeof)
-            T arg = **cast(T**)ap;
-        else
-            T arg = *cast(T*)ap;
-        ap = cast(va_list)(cast(void*)ap + ((size_t.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
-        return arg;
+        auto p = cast(T*) ap;
+        ap += T.sizeof.alignUp;
+        return *p;
     }
-
-    /************
-     * Retrieve and return the next value that is type T.
-     * This is the preferred version.
-     */
-    void va_arg(T)(ref va_list ap, ref T parmn)
+    else version (Win64)
     {
-        static if (T.sizeof > size_t.sizeof)
-            parmn = **cast(T**)ap;
+        // LDC passes slices as 2 separate 64-bit values, not as 128-bit struct
+        version (LDC) enum isLDC = true;
+        else          enum isLDC = false;
+        static if (isLDC && is(T == E[], E))
+        {
+            auto p = cast(T*) ap;
+            ap += T.sizeof;
+            return *p;
+        }
         else
-            parmn = *cast(T*)ap;
-        ap = cast(va_list)(cast(void*)ap + ((size_t.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
-    }
-
-    /*************
-     * Retrieve and store through parmn the next value that is of TypeInfo ti.
-     * Used when the static type is not known.
-     */
-    void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
-    {
-        // Wait until everyone updates to get TypeInfo.talign
-        //auto talign = ti.talign;
-        //auto p = cast(void*)(cast(size_t)ap + talign - 1) & ~(talign - 1);
-        auto p = ap;
-        auto tsize = ti.tsize;
-        ap = cast(va_list)(cast(size_t)p + ((size_t.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
-        void* q = (tsize > size_t.sizeof) ? *cast(void**)p : p;
-        parmn[0..tsize] = q[0..tsize];
+        {
+            // passed indirectly by value if > 64 bits or of a size that is not a power of 2
+            static if (T.sizeof > size_t.sizeof || (T.sizeof & (T.sizeof - 1)) != 0)
+                auto p = *cast(T**) ap;
+            else
+                auto p = cast(T*) ap;
+            ap += size_t.sizeof;
+            return *p;
+        }
     }
-
-    /***********************
-     * End use of ap.
-     */
-    void va_end(va_list ap)
+    else version (SysV_x64)
     {
+        return core.internal.vararg.sysv_x64.va_arg!T(ap);
     }
-
-    ///
-    void va_copy(out va_list dest, va_list src)
+    else version (AAPCS32)
     {
-        dest = src;
+        // AAPCS32 section 6.5 B.5: type with alignment >= 8 is 8-byte aligned
+        // instead of normal 4-byte alignment (APCS doesn't do this).
+        if (T.alignof >= 8)
+            ap.__ap = ap.__ap.alignUp!8;
+        auto p = cast(T*) ap.__ap;
+        version (BigEndian)
+            static if (T.sizeof < size_t.sizeof)
+                p = adjustForBigEndian(p, T.sizeof);
+        ap.__ap += T.sizeof.alignUp;
+        return *p;
     }
-}
-else version (X86_64)
-{
-    // Determine if type is a vector type
-    template isVectorType(T)
+    else version (AAPCS64)
     {
-        enum isVectorType = false;
+        return core.internal.vararg.aarch64.va_arg!T(ap);
     }
-
-    template isVectorType(T : __vector(T[N]), size_t N)
+    else version (ARM_Any)
     {
-        enum isVectorType = true;
+        auto p = cast(T*) ap;
+        version (BigEndian)
+            static if (T.sizeof < size_t.sizeof)
+                p = adjustForBigEndian(p, T.sizeof);
+        ap += T.sizeof.alignUp;
+        return *p;
     }
-
-    // Layout of this struct must match __gnuc_va_list for C ABI compatibility
-    struct __va_list_tag
+    else version (PPC_Any)
     {
-        uint offset_regs = 6 * 8;            // no regs
-        uint offset_fpregs = 6 * 8 + 8 * 16; // no fp regs
-        void* stack_args;
-        void* reg_args;
+        /*
+         * The rules are described in the 64bit PowerPC ELF ABI Supplement 1.9,
+         * available here:
+         * http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html#PARAM-PASS
+         */
+
+        // Chapter 3.1.4 and 3.2.3: alignment may require the va_list pointer to first
+        // be aligned before accessing a value
+        if (T.alignof >= 8)
+            ap = ap.alignUp!8;
+        auto p = cast(T*) ap;
+        version (BigEndian)
+            static if (T.sizeof < size_t.sizeof)
+                p = adjustForBigEndian(p, T.sizeof);
+        ap += T.sizeof.alignUp;
+        return *p;
     }
-    alias __va_list = __va_list_tag;
-
-    align(16) struct __va_argsave_t
+    else version (MIPS_Any)
     {
-        size_t[6] regs;   // RDI,RSI,RDX,RCX,R8,R9
-        real[8] fpregs;   // XMM0..XMM7
-        __va_list va;
+        auto p = cast(T*) ap;
+        version (BigEndian)
+            static if (T.sizeof < size_t.sizeof)
+                p = adjustForBigEndian(p, T.sizeof);
+        ap += T.sizeof.alignUp;
+        return *p;
     }
+    else
+        static assert(0, "Unsupported platform");
+}
 
-    /*
-     * Making it an array of 1 causes va_list to be passed as a pointer in
-     * function argument lists
-     */
-    alias va_list = __va_list*;
-
-    ///
-    void va_start(T)(out va_list ap, ref T parmn); // Compiler intrinsic
 
-    ///
-    T va_arg(T)(va_list ap)
-    {   T a;
-        va_arg(ap, a);
-        return a;
-    }
+/**
+ * Retrieve and store in parmn the next value that is of type T.
+ */
+version (GNU)
+    void va_arg(T)(ref va_list ap, ref T parmn); // intrinsic
+else
+void va_arg(T)(ref va_list ap, ref T parmn)
+{
+    parmn = va_arg!T(ap);
+}
 
-    ///
-    void va_arg(T)(va_list apx, ref T parmn)
-    {
-        __va_list* ap = cast(__va_list*)apx;
-        static if (is(T U == __argTypes))
-        {
-            static if (U.length == 0 || T.sizeof > 16 || (U[0].sizeof > 8 && !isVectorType!(U[0])))
-            {   // Always passed in memory
-                // The arg may have more strict alignment than the stack
-                auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1);
-                ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
-                parmn = *cast(T*)p;
-            }
-            else static if (U.length == 1)
-            {   // Arg is passed in one register
-                alias U[0] T1;
-                static if (is(T1 == double) || is(T1 == float) || isVectorType!(T1))
-                {   // Passed in XMM register
-                    if (ap.offset_fpregs < (6 * 8 + 16 * 8))
-                    {
-                        parmn = *cast(T*)(ap.reg_args + ap.offset_fpregs);
-                        ap.offset_fpregs += 16;
-                    }
-                    else
-                    {
-                        parmn = *cast(T*)ap.stack_args;
-                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
-                    }
-                }
-                else
-                {   // Passed in regular register
-                    if (ap.offset_regs < 6 * 8 && T.sizeof <= 8)
-                    {
-                        parmn = *cast(T*)(ap.reg_args + ap.offset_regs);
-                        ap.offset_regs += 8;
-                    }
-                    else
-                    {
-                        auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1);
-                        ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
-                        parmn = *cast(T*)p;
-                    }
-                }
-            }
-            else static if (U.length == 2)
-            {   // Arg is passed in two registers
-                alias U[0] T1;
-                alias U[1] T2;
-                auto p = cast(void*)&parmn + 8;
 
-                // Both must be in registers, or both on stack, hence 4 cases
+/**
+ * End use of ap.
+ */
+version (GNU)
+{
+    alias va_end = __builtin_va_end;
+}
+else version (LDC)
+{
+    pragma(LDC_va_end)
+    void va_end(va_list ap);
+}
+else version (DigitalMars)
+{
+    void va_end(va_list ap) {}
+}
 
-                static if ((is(T1 == double) || is(T1 == float)) &&
-                           (is(T2 == double) || is(T2 == float)))
-                {
-                    if (ap.offset_fpregs < (6 * 8 + 16 * 8) - 16)
-                    {
-                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_fpregs);
-                        *cast(T2*)p = *cast(T2*)(ap.reg_args + ap.offset_fpregs + 16);
-                        ap.offset_fpregs += 32;
-                    }
-                    else
-                    {
-                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
-                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
-                        *cast(T2*)p = *cast(T2*)ap.stack_args;
-                        ap.stack_args += (T2.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
-                    }
-                }
-                else static if (is(T1 == double) || is(T1 == float))
-                {
-                    void* a = void;
-                    if (ap.offset_fpregs < (6 * 8 + 16 * 8) &&
-                        ap.offset_regs < 6 * 8 && T2.sizeof <= 8)
-                    {
-                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_fpregs);
-                        ap.offset_fpregs += 16;
-                        a = ap.reg_args + ap.offset_regs;
-                        ap.offset_regs += 8;
-                    }
-                    else
-                    {
-                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
-                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
-                        a = ap.stack_args;
-                        ap.stack_args += 8;
-                    }
-                    // Be careful not to go past the size of the actual argument
-                    const sz2 = T.sizeof - 8;
-                    p[0..sz2] = a[0..sz2];
-                }
-                else static if (is(T2 == double) || is(T2 == float))
-                {
-                    if (ap.offset_regs < 6 * 8 && T1.sizeof <= 8 &&
-                        ap.offset_fpregs < (6 * 8 + 16 * 8))
-                    {
-                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_regs);
-                        ap.offset_regs += 8;
-                        *cast(T2*)p = *cast(T2*)(ap.reg_args + ap.offset_fpregs);
-                        ap.offset_fpregs += 16;
-                    }
-                    else
-                    {
-                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
-                        ap.stack_args += 8;
-                        *cast(T2*)p = *cast(T2*)ap.stack_args;
-                        ap.stack_args += (T2.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
-                    }
-                }
-                else // both in regular registers
-                {
-                    void* a = void;
-                    if (ap.offset_regs < 5 * 8 && T1.sizeof <= 8 && T2.sizeof <= 8)
-                    {
-                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_regs);
-                        ap.offset_regs += 8;
-                        a = ap.reg_args + ap.offset_regs;
-                        ap.offset_regs += 8;
-                    }
-                    else
-                    {
-                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args;
-                        ap.stack_args += 8;
-                        a = ap.stack_args;
-                        ap.stack_args += 8;
-                    }
-                    // Be careful not to go past the size of the actual argument
-                    const sz2 = T.sizeof - 8;
-                    p[0..sz2] = a[0..sz2];
-                }
-            }
-            else
-            {
-                static assert(false);
-            }
-        }
-        else
-        {
-            static assert(false, "not a valid argument type for va_arg");
-        }
-    }
 
-    ///
-    void va_arg()(va_list apx, TypeInfo ti, void* parmn)
+/**
+ * Make a copy of ap.
+ */
+version (GNU)
+{
+    alias va_copy = __builtin_va_copy;
+}
+else version (LDC)
+{
+    pragma(LDC_va_copy)
+    void va_copy(out va_list dest, va_list src);
+}
+else version (DigitalMars)
+{
+    version (SysV_x64)
     {
-        __va_list* ap = cast(__va_list*)apx;
-        TypeInfo arg1, arg2;
-        if (!ti.argTypes(arg1, arg2))
+        void va_copy(out va_list dest, va_list src, void* storage = alloca(__va_list_tag.sizeof))
         {
-            bool inXMMregister(TypeInfo arg) pure nothrow @safe
-            {
-                return (arg.flags & 2) != 0;
-            }
-
-            TypeInfo_Vector v1 = arg1 ? cast(TypeInfo_Vector)arg1 : null;
-            if (arg1 && (arg1.tsize <= 8 || v1))
-            {   // Arg is passed in one register
-                auto tsize = arg1.tsize;
-                void* p;
-                bool stack = false;
-                auto offset_fpregs_save = ap.offset_fpregs;
-                auto offset_regs_save = ap.offset_regs;
-            L1:
-                if (inXMMregister(arg1) || v1)
-                {   // Passed in XMM register
-                    if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
-                    {
-                        p = ap.reg_args + ap.offset_fpregs;
-                        ap.offset_fpregs += 16;
-                    }
-                    else
-                    {
-                        p = ap.stack_args;
-                        ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
-                        stack = true;
-                    }
-                }
-                else
-                {   // Passed in regular register
-                    if (ap.offset_regs < 6 * 8 && !stack)
-                    {
-                        p = ap.reg_args + ap.offset_regs;
-                        ap.offset_regs += 8;
-                    }
-                    else
-                    {
-                        p = ap.stack_args;
-                        ap.stack_args += 8;
-                        stack = true;
-                    }
-                }
-                parmn[0..tsize] = p[0..tsize];
-
-                if (arg2)
-                {
-                    if (inXMMregister(arg2))
-                    {   // Passed in XMM register
-                        if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
-                        {
-                            p = ap.reg_args + ap.offset_fpregs;
-                            ap.offset_fpregs += 16;
-                        }
-                        else
-                        {
-                            if (!stack)
-                            {   // arg1 is really on the stack, so rewind and redo
-                                ap.offset_fpregs = offset_fpregs_save;
-                                ap.offset_regs = offset_regs_save;
-                                stack = true;
-                                goto L1;
-                            }
-                            p = ap.stack_args;
-                            ap.stack_args += (arg2.tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
-                        }
-                    }
-                    else
-                    {   // Passed in regular register
-                        if (ap.offset_regs < 6 * 8 && !stack)
-                        {
-                            p = ap.reg_args + ap.offset_regs;
-                            ap.offset_regs += 8;
-                        }
-                        else
-                        {
-                            if (!stack)
-                            {   // arg1 is really on the stack, so rewind and redo
-                                ap.offset_fpregs = offset_fpregs_save;
-                                ap.offset_regs = offset_regs_save;
-                                stack = true;
-                                goto L1;
-                            }
-                            p = ap.stack_args;
-                            ap.stack_args += 8;
-                        }
-                    }
-                    auto sz = ti.tsize - 8;
-                    (parmn + 8)[0..sz] = p[0..sz];
-                }
-            }
-            else
-            {   // Always passed in memory
-                // The arg may have more strict alignment than the stack
-                auto talign = ti.talign;
-                auto tsize = ti.tsize;
-                auto p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1));
-                ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
-                parmn[0..tsize] = p[0..tsize];
-            }
+            // Instead of copying the pointers, and aliasing the source va_list,
+            // the default argument alloca will allocate storage in the caller's
+            // stack frame.  This is still not correct (it should be allocated in
+            // the place where the va_list variable is declared) but most of the
+            // time the caller's stack frame _is_ the place where the va_list is
+            // allocated, so in most cases this will now work.
+            dest = cast(va_list) storage;
+            *dest = *src;
         }
-        else
-        {
-            assert(false, "not a valid argument type for va_arg");
-        }
-    }
 
-    ///
-    void va_end(va_list ap)
-    {
+        import core.stdc.stdlib : alloca;
     }
-
-    import core.stdc.stdlib : alloca;
-
-    ///
-    void va_copy(out va_list dest, va_list src, void* storage = alloca(__va_list_tag.sizeof))
+    else
     {
-        // Instead of copying the pointers, and aliasing the source va_list,
-        // the default argument alloca will allocate storage in the caller's
-        // stack frame.  This is still not correct (it should be allocated in
-        // the place where the va_list variable is declared) but most of the
-        // time the caller's stack frame _is_ the place where the va_list is
-        // allocated, so in most cases this will now work.
-        dest = cast(va_list)storage;
-        *dest = *src;
+        void va_copy(out va_list dest, va_list src)
+        {
+            dest = src;
+        }
     }
 }
-else
-{
-    static assert(false, "Unsupported platform");
-}
diff --git a/libphobos/libdruntime/core/stdc/stdint.d b/libphobos/libdruntime/core/stdc/stdint.d
index 0e310521e0e..ac71b1d09d5 100644
--- a/libphobos/libdruntime/core/stdc/stdint.d
+++ b/libphobos/libdruntime/core/stdc/stdint.d
@@ -14,10 +14,10 @@
 
 module core.stdc.stdint;
 
-private import core.stdc.config;
-private import core.stdc.stddef; // for wchar_t
-private import core.stdc.signal; // for sig_atomic_t
-private import core.stdc.wchar_; // for wint_t
+import core.stdc.config;
+import core.stdc.stddef; // for wchar_t
+import core.stdc.signal; // for sig_atomic_t
+import core.stdc.wchar_; // for wint_t
 
 version (OSX)
     version = Darwin;
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index e68f393e3e6..00efe885289 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -268,7 +268,7 @@ else version (DragonFlyBSD)
         ssize_t          s_len;         // current length of string
         int              s_flags;       // flags
         ssize_t          s_sect_len;    // current length of section
-    };
+    }
 
     enum {
         SBUF_FIXEDLEN   = 0x00000000,   // fixed length buffer (default)
@@ -526,7 +526,7 @@ else version (FreeBSD)
         int     function(void*)                 _close;
         int     function(void*, char*, int)     _read;
         fpos_t  function(void*, fpos_t, int)    _seek;
-        int     function(void*, in char*, int)  _write;
+        int     function(void*, const scope char*, int)  _write;
 
         __sbuf          _ub;
         ubyte*          _up;
@@ -572,7 +572,7 @@ else version (NetBSD)
         int     function(void*)                 _close;
         ssize_t     function(void*, char*, size_t)     _read;
         fpos_t  function(void*, fpos_t, int)    _seek;
-        ssize_t     function(void*, in char*, size_t)  _write;
+        ssize_t     function(void*, const scope char*, size_t)  _write;
 
         __sbuf          _ub;
         ubyte*          _up;
@@ -1166,22 +1166,22 @@ version (MinGW)
     // Prefer the MinGW versions over the MSVC ones, as the latter don't handle
     // reals at all.
     ///
-    int __mingw_fprintf(FILE* stream, scope const char* format, ...);
+    int __mingw_fprintf(FILE* stream, scope const char* format, scope const ...);
     ///
     alias __mingw_fprintf fprintf;
 
     ///
-    int __mingw_fscanf(FILE* stream, scope const char* format, ...);
+    int __mingw_fscanf(FILE* stream, scope const char* format, scope ...);
     ///
     alias __mingw_fscanf fscanf;
 
     ///
-    int __mingw_sprintf(scope char* s, scope const char* format, ...);
+    int __mingw_sprintf(scope char* s, scope const char* format, scope const ...);
     ///
     alias __mingw_sprintf sprintf;
 
     ///
-    int __mingw_sscanf(scope const char* s, scope const char* format, ...);
+    int __mingw_sscanf(scope const char* s, scope const char* format, scope ...);
     ///
     alias __mingw_sscanf sscanf;
 
@@ -1216,25 +1216,25 @@ version (MinGW)
     alias __mingw_vscanf vscanf;
 
     ///
-    int __mingw_printf(scope const char* format, ...);
+    int __mingw_printf(scope const char* format, scope const ...);
     ///
     alias __mingw_printf printf;
 
     ///
-    int __mingw_scanf(scope const char* format, ...);
+    int __mingw_scanf(scope const char* format, scope ...);
     ///
     alias __mingw_scanf scanf;
 }
 else
 {
     ///
-    int fprintf(FILE* stream, scope const char* format, ...);
+    int fprintf(FILE* stream, scope const char* format, scope const ...);
     ///
-    int fscanf(FILE* stream, scope const char* format, ...);
+    int fscanf(FILE* stream, scope const char* format, scope ...);
     ///
-    int sprintf(scope char* s, scope const char* format, ...);
+    int sprintf(scope char* s, scope const char* format, scope const ...);
     ///
-    int sscanf(scope const char* s, scope const char* format, ...);
+    int sscanf(scope const char* s, scope const char* format, scope ...);
     ///
     int vfprintf(FILE* stream, scope const char* format, va_list arg);
     ///
@@ -1248,9 +1248,9 @@ else
     ///
     int vscanf(scope const char* format, va_list arg);
     ///
-    int printf(scope const char* format, ...);
+    int printf(scope const char* format, scope const ...);
     ///
-    int scanf(scope const char* format, ...);
+    int scanf(scope const char* format, scope ...);
 }
 
 // No unsafe pointer manipulation.
@@ -1323,7 +1323,7 @@ version (CRuntime_DigitalMars)
     pure int  fileno()(FILE* stream)   { return stream._file; }
   }
   ///
-    int   _snprintf(scope char* s, size_t n, scope const char* fmt, ...);
+    int   _snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...);
     ///
     alias _snprintf snprintf;
 
@@ -1351,7 +1351,7 @@ else version (CRuntime_Microsoft)
 
   version (MinGW)
   {
-    int   __mingw_snprintf(scope char* s, size_t n, scope const char* fmt, ...);
+    int   __mingw_snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...);
     ///
     alias __mingw_snprintf _snprintf;
     ///
@@ -1367,9 +1367,9 @@ else version (CRuntime_Microsoft)
   else
   {
     ///
-    int _snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int _snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
-    int  snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
 
     ///
     int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
@@ -1410,7 +1410,7 @@ else version (CRuntime_Glibc)
   }
 
     ///
-    int  snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
     int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
@@ -1432,7 +1432,7 @@ else version (Darwin)
   }
 
     ///
-    int  snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
     int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
@@ -1454,7 +1454,7 @@ else version (FreeBSD)
   }
 
     ///
-    int  snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
     int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
@@ -1476,9 +1476,9 @@ else version (NetBSD)
   }
 
     ///
-    int  snprintf(char* s, size_t n, in char* format, ...);
+    int  snprintf(char* s, size_t n, const scope char* format, scope const ...);
     ///
-    int  vsnprintf(char* s, size_t n, in char* format, va_list arg);
+    int  vsnprintf(char* s, size_t n, const scope char* format, va_list arg);
 }
 else version (OpenBSD)
 {
@@ -1567,7 +1567,7 @@ else version (OpenBSD)
     }
 
     ///
-    int  snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
     int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
@@ -1599,8 +1599,8 @@ else version (DragonFlyBSD)
   enum __SALC = 0x4000;
   enum __SIGN = 0x8000;
 
-  int  snprintf(scope char* s, size_t n, scope const char* format, ...);
-  int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
+    int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
 else version (Solaris)
 {
@@ -1620,7 +1620,7 @@ else version (Solaris)
   }
 
     ///
-    int  snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
     int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
@@ -1641,8 +1641,8 @@ else version (CRuntime_Bionic)
     int  fileno(FILE*);
   }
 
-  ///
-    int  snprintf(scope char* s, size_t n, scope const char* format, ...);
+    ///
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
     int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
@@ -1663,7 +1663,7 @@ else version (CRuntime_Musl)
     }
 
     ///
-    int snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
     int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
@@ -1685,7 +1685,7 @@ else version (CRuntime_UClibc)
   }
 
     ///
-    int  snprintf(scope char* s, size_t n, scope const char* format, ...);
+    int  snprintf(scope char* s, size_t n, scope const char* format, scope const ...);
     ///
     int  vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
 }
diff --git a/libphobos/libdruntime/core/stdc/stdlib.d b/libphobos/libdruntime/core/stdc/stdlib.d
index 7c0b7b6bc9b..7caef4c1339 100644
--- a/libphobos/libdruntime/core/stdc/stdlib.d
+++ b/libphobos/libdruntime/core/stdc/stdlib.d
@@ -14,7 +14,7 @@
 
 module core.stdc.stdlib;
 
-private import core.stdc.config;
+import core.stdc.config;
 public import core.stdc.stddef; // for wchar_t
 
 version (OSX)
diff --git a/libphobos/libdruntime/core/stdc/string.d b/libphobos/libdruntime/core/stdc/string.d
index 0929a4eab53..a26811ca623 100644
--- a/libphobos/libdruntime/core/stdc/string.d
+++ b/libphobos/libdruntime/core/stdc/string.d
@@ -35,51 +35,35 @@ nothrow:
 @nogc:
 
 ///
-pure void* memchr(return const void* s, int c, size_t n);
+inout(void)* memchr(return inout void* s, int c, size_t n) pure;
 ///
-pure int   memcmp(scope const void* s1, scope const void* s2, size_t n);
+int   memcmp(scope const void* s1, scope const void* s2, size_t n) pure;
 ///
-pure void* memcpy(return void* s1, scope const void* s2, size_t n);
+void* memcpy(return void* s1, scope const void* s2, size_t n) pure;
 version (Windows)
 {
     ///
     int memicmp(scope const char* s1, scope const char* s2, size_t n);
 }
 ///
-pure void* memmove(return void* s1, scope const void* s2, size_t n);
+void* memmove(return void* s1, scope const void* s2, size_t n) pure;
 ///
-pure void* memset(return void* s, int c, size_t n);
+void* memset(return void* s, int c, size_t n) pure;
 
 ///
-pure char*  strcpy(return char* s1, scope const char* s2);
+char*  strcat(return char* s1, scope const char* s2) pure;
 ///
-pure char*  strncpy(return char* s1, scope const char* s2, size_t n);
+inout(char)*  strchr(return inout(char)* s, int c) pure;
 ///
-pure char*  strcat(return char* s1, scope const char* s2);
-///
-pure char*  strncat(return char* s1, scope const char* s2, size_t n);
-///
-pure int    strcmp(scope const char* s1, scope const char* s2);
+int    strcmp(scope const char* s1, scope const char* s2) pure;
 ///
 int    strcoll(scope const char* s1, scope const char* s2);
 ///
-pure int    strncmp(scope const char* s1, scope const char* s2, size_t n);
-///
-size_t strxfrm(scope char* s1, scope const char* s2, size_t n);
-///
-pure inout(char)*  strchr(return inout(char)* s, int c);
-///
-pure size_t strcspn(scope const char* s1, scope const char* s2);
+char*  strcpy(return char* s1, scope const char* s2) pure;
 ///
-pure inout(char)*  strpbrk(return inout(char)* s1, scope const char* s2);
+size_t strcspn(scope const char* s1, scope const char* s2) pure;
 ///
-pure inout(char)*  strrchr(return inout(char)* s, int c);
-///
-pure size_t strspn(scope const char* s1, scope const char* s2);
-///
-pure inout(char)*  strstr(return inout(char)* s1, scope const char* s2);
-///
-char*  strtok(return char* s1, scope const char* s2);
+char*  strdup(scope const char *s);
 ///
 char*  strerror(int errnum);
 // This `strerror_r` definition is not following the POSIX standard
@@ -94,6 +78,22 @@ else
     int strerror_r(int errnum, scope char* buf, size_t buflen);
 }
 ///
-pure size_t strlen(scope const char* s);
+size_t strlen(scope const char* s) pure;
 ///
-char*  strdup(scope const char *s);
+char*  strncat(return char* s1, scope const char* s2, size_t n) pure;
+///
+int    strncmp(scope const char* s1, scope const char* s2, size_t n) pure;
+///
+char*  strncpy(return char* s1, scope const char* s2, size_t n) pure;
+///
+inout(char)*  strpbrk(return inout(char)* s1, scope const char* s2) pure;
+///
+inout(char)*  strrchr(return inout(char)* s, int c) pure;
+///
+size_t strspn(scope const char* s1, scope const char* s2) pure;
+///
+inout(char)*  strstr(return inout(char)* s1, scope const char* s2) pure;
+///
+char*  strtok(return char* s1, scope const char* s2);
+///
+size_t strxfrm(scope char* s1, scope const char* s2, size_t n);
diff --git a/libphobos/libdruntime/core/stdc/tgmath.d b/libphobos/libdruntime/core/stdc/tgmath.d
index 16184e29845..4dd1b3ccc66 100644
--- a/libphobos/libdruntime/core/stdc/tgmath.d
+++ b/libphobos/libdruntime/core/stdc/tgmath.d
@@ -14,7 +14,7 @@
 
 module core.stdc.tgmath;
 
-private import core.stdc.config;
+import core.stdc.config;
 private static import core.stdc.math;
 private static import core.stdc.complex;
 
@@ -23,554 +23,6 @@ extern (C):
 nothrow:
 @nogc:
 
-version (FreeBSD)
-{
-    ///
-    alias core.stdc.math.acos          acos;
-    ///
-    alias core.stdc.math.acosf         acos;
-    ///
-    alias core.stdc.math.acosl         acos;
-
-    ///
-    alias core.stdc.complex.cacos      acos;
-    ///
-    alias core.stdc.complex.cacosf     acos;
-    ///
-    alias core.stdc.complex.cacosl     acos;
-
-    ///
-    alias core.stdc.math.asin          asin;
-    ///
-    alias core.stdc.math.asinf         asin;
-    ///
-    alias core.stdc.math.asinl         asin;
-
-    ///
-    alias core.stdc.complex.casin      asin;
-    ///
-    alias core.stdc.complex.casinf     asin;
-    ///
-    alias core.stdc.complex.casinl     asin;
-
-    ///
-    alias core.stdc.math.atan          atan;
-    ///
-    alias core.stdc.math.atanf         atan;
-    ///
-    alias core.stdc.math.atanl         atan;
-
-    ///
-    alias core.stdc.complex.catan      atan;
-    ///
-    alias core.stdc.complex.catanf     atan;
-    ///
-    alias core.stdc.complex.catanl     atan;
-
-    ///
-    alias core.stdc.math.atan2         atan2;
-    ///
-    alias core.stdc.math.atan2f        atan2;
-    ///
-    alias core.stdc.math.atan2l        atan2;
-
-    ///
-    alias core.stdc.math.cos           cos;
-    ///
-    alias core.stdc.math.cosf          cos;
-    ///
-    alias core.stdc.math.cosl          cos;
-
-    ///
-    alias core.stdc.complex.ccos       cos;
-    ///
-    alias core.stdc.complex.ccosf      cos;
-    ///
-    alias core.stdc.complex.ccosl      cos;
-
-    ///
-    alias core.stdc.math.sin           sin;
-    ///
-    alias core.stdc.math.sinf          sin;
-    ///
-    alias core.stdc.math.sinl          sin;
-
-    ///
-    alias core.stdc.complex.csin       csin;
-    ///
-    alias core.stdc.complex.csinf      csin;
-    ///
-    alias core.stdc.complex.csinl      csin;
-
-    ///
-    alias core.stdc.math.tan           tan;
-    ///
-    alias core.stdc.math.tanf          tan;
-    ///
-    alias core.stdc.math.tanl          tan;
-
-    ///
-    alias core.stdc.complex.ctan       tan;
-    ///
-    alias core.stdc.complex.ctanf      tan;
-    ///
-    alias core.stdc.complex.ctanl      tan;
-
-    ///
-    alias core.stdc.math.acosh         acosh;
-    ///
-    alias core.stdc.math.acoshf        acosh;
-    ///
-    alias core.stdc.math.acoshl        acosh;
-
-    ///
-    alias core.stdc.complex.cacosh     acosh;
-    ///
-    alias core.stdc.complex.cacoshf    acosh;
-    ///
-    alias core.stdc.complex.cacoshl    acosh;
-
-    ///
-    alias core.stdc.math.asinh         asinh;
-    ///
-    alias core.stdc.math.asinhf        asinh;
-    ///
-    alias core.stdc.math.asinhl        asinh;
-
-    ///
-    alias core.stdc.complex.casinh     asinh;
-    ///
-    alias core.stdc.complex.casinhf    asinh;
-    ///
-    alias core.stdc.complex.casinhl    asinh;
-
-    ///
-    alias core.stdc.math.atanh         atanh;
-    ///
-    alias core.stdc.math.atanhf        atanh;
-    ///
-    alias core.stdc.math.atanhl        atanh;
-
-    ///
-    alias core.stdc.complex.catanh     atanh;
-    ///
-    alias core.stdc.complex.catanhf    atanh;
-    ///
-    alias core.stdc.complex.catanhl    atanh;
-
-    ///
-    alias core.stdc.math.cosh          cosh;
-    ///
-    alias core.stdc.math.coshf         cosh;
-    ///
-    alias core.stdc.math.coshl         cosh;
-
-    ///
-    alias core.stdc.complex.ccosh      cosh;
-    ///
-    alias core.stdc.complex.ccoshf     cosh;
-    ///
-    alias core.stdc.complex.ccoshl     cosh;
-
-    ///
-    alias core.stdc.math.sinh          sinh;
-    ///
-    alias core.stdc.math.sinhf         sinh;
-    ///
-    alias core.stdc.math.sinhl         sinh;
-
-    ///
-    alias core.stdc.complex.csinh      sinh;
-    ///
-    alias core.stdc.complex.csinhf     sinh;
-    ///
-    alias core.stdc.complex.csinhl     sinh;
-
-    ///
-    alias core.stdc.math.tanh          tanh;
-    ///
-    alias core.stdc.math.tanhf         tanh;
-    ///
-    alias core.stdc.math.tanhl         tanh;
-
-    ///
-    alias core.stdc.complex.ctanh      tanh;
-    ///
-    alias core.stdc.complex.ctanhf     tanh;
-    ///
-    alias core.stdc.complex.ctanhl     tanh;
-
-    ///
-    alias core.stdc.math.exp           exp;
-    ///
-    alias core.stdc.math.expf          exp;
-    ///
-    alias core.stdc.math.expl          exp;
-
-    ///
-    alias core.stdc.complex.cexp       exp;
-    ///
-    alias core.stdc.complex.cexpf      exp;
-    ///
-    alias core.stdc.complex.cexpl      exp;
-
-    ///
-    alias core.stdc.math.exp2          exp2;
-    ///
-    alias core.stdc.math.exp2f         exp2;
-    ///
-    alias core.stdc.math.exp2l         exp2;
-
-    ///
-    alias core.stdc.math.expm1         expm1;
-    ///
-    alias core.stdc.math.expm1f        expm1;
-    ///
-    alias core.stdc.math.expm1l        expm1;
-
-    ///
-    alias core.stdc.math.frexp         frexp;
-    ///
-    alias core.stdc.math.frexpf        frexp;
-    ///
-    alias core.stdc.math.frexpl        frexp;
-
-    ///
-    alias core.stdc.math.ilogb         ilogb;
-    ///
-    alias core.stdc.math.ilogbf        ilogb;
-    ///
-    alias core.stdc.math.ilogbl        ilogb;
-
-    ///
-    alias core.stdc.math.ldexp         ldexp;
-    ///
-    alias core.stdc.math.ldexpf        ldexp;
-    ///
-    alias core.stdc.math.ldexpl        ldexp;
-
-    ///
-    alias core.stdc.math.log           log;
-    ///
-    alias core.stdc.math.logf          log;
-    ///
-    alias core.stdc.math.logl          log;
-
-    ///
-    alias core.stdc.complex.clog       log;
-    ///
-    alias core.stdc.complex.clogf      log;
-    ///
-    alias core.stdc.complex.clogl      log;
-
-    ///
-    alias core.stdc.math.log10         log10;
-    ///
-    alias core.stdc.math.log10f        log10;
-    ///
-    alias core.stdc.math.log10l        log10;
-
-    ///
-    alias core.stdc.math.log1p         log1p;
-    ///
-    alias core.stdc.math.log1pf        log1p;
-    ///
-    alias core.stdc.math.log1pl        log1p;
-
-    ///
-    alias core.stdc.math.log2          log2;
-    ///
-    alias core.stdc.math.log2f         log2;
-    ///
-    alias core.stdc.math.log2l         log2;
-
-    ///
-    alias core.stdc.math.logb          logb;
-    ///
-    alias core.stdc.math.logbf         logb;
-    ///
-    alias core.stdc.math.logbl         logb;
-
-    ///
-    alias core.stdc.math.modf          modf;
-    ///
-    alias core.stdc.math.modff         modf;
-//  alias core.stdc.math.modfl         modf;
-
-    ///
-    alias core.stdc.math.scalbn        scalbn;
-    ///
-    alias core.stdc.math.scalbnf       scalbn;
-    ///
-    alias core.stdc.math.scalbnl       scalbn;
-
-    ///
-    alias core.stdc.math.scalbln       scalbln;
-    ///
-    alias core.stdc.math.scalblnf      scalbln;
-    ///
-    alias core.stdc.math.scalblnl      scalbln;
-
-    ///
-    alias core.stdc.math.cbrt          cbrt;
-    ///
-    alias core.stdc.math.cbrtf         cbrt;
-    ///
-    alias core.stdc.math.cbrtl         cbrt;
-
-    ///
-    alias core.stdc.math.fabs          fabs;
-    ///
-    alias core.stdc.math.fabsf         fabs;
-    ///
-    alias core.stdc.math.fabsl         fabs;
-
-    ///
-    alias core.stdc.complex.cabs       fabs;
-    ///
-    alias core.stdc.complex.cabsf      fabs;
-    ///
-    alias core.stdc.complex.cabsl      fabs;
-
-    ///
-    alias core.stdc.math.hypot         hypot;
-    ///
-    alias core.stdc.math.hypotf        hypot;
-    ///
-    alias core.stdc.math.hypotl        hypot;
-
-    ///
-    alias core.stdc.math.pow           pow;
-    ///
-    alias core.stdc.math.powf          pow;
-    ///
-    alias core.stdc.math.powl          pow;
-
-    ///
-    alias core.stdc.complex.cpow       pow;
-    ///
-    alias core.stdc.complex.cpowf      pow;
-    ///
-    alias core.stdc.complex.cpowl      pow;
-
-    ///
-    alias core.stdc.math.sqrt          sqrt;
-    ///
-    alias core.stdc.math.sqrtf         sqrt;
-    ///
-    alias core.stdc.math.sqrtl         sqrt;
-
-    ///
-    alias core.stdc.complex.csqrt      sqrt;
-    ///
-    alias core.stdc.complex.csqrtf     sqrt;
-    ///
-    alias core.stdc.complex.csqrtl     sqrt;
-
-    ///
-    alias core.stdc.math.erf           erf;
-    ///
-    alias core.stdc.math.erff          erf;
-    ///
-    alias core.stdc.math.erfl          erf;
-
-    ///
-    alias core.stdc.math.erfc          erfc;
-    ///
-    alias core.stdc.math.erfcf         erfc;
-    ///
-    alias core.stdc.math.erfcl         erfc;
-
-    ///
-    alias core.stdc.math.lgamma        lgamma;
-    ///
-    alias core.stdc.math.lgammaf       lgamma;
-    ///
-    alias core.stdc.math.lgammal       lgamma;
-
-    ///
-    alias core.stdc.math.tgamma        tgamma;
-    ///
-    alias core.stdc.math.tgammaf       tgamma;
-    ///
-    alias core.stdc.math.tgammal       tgamma;
-
-    ///
-    alias core.stdc.math.ceil          ceil;
-    ///
-    alias core.stdc.math.ceilf         ceil;
-    ///
-    alias core.stdc.math.ceill         ceil;
-
-    ///
-    alias core.stdc.math.floor         floor;
-    ///
-    alias core.stdc.math.floorf        floor;
-    ///
-    alias core.stdc.math.floorl        floor;
-
-    ///
-    alias core.stdc.math.nearbyint     nearbyint;
-    ///
-    alias core.stdc.math.nearbyintf    nearbyint;
-    ///
-    alias core.stdc.math.nearbyintl    nearbyint;
-
-    ///
-    alias core.stdc.math.rint          rint;
-    ///
-    alias core.stdc.math.rintf         rint;
-    ///
-    alias core.stdc.math.rintl         rint;
-
-    ///
-    alias core.stdc.math.lrint         lrint;
-    ///
-    alias core.stdc.math.lrintf        lrint;
-    ///
-    alias core.stdc.math.lrintl        lrint;
-
-    ///
-    alias core.stdc.math.llrint        llrint;
-    ///
-    alias core.stdc.math.llrintf       llrint;
-    ///
-    alias core.stdc.math.llrintl       llrint;
-
-    ///
-    alias core.stdc.math.round         round;
-    ///
-    alias core.stdc.math.roundf        round;
-    ///
-    alias core.stdc.math.roundl        round;
-
-    ///
-    alias core.stdc.math.lround        lround;
-    ///
-    alias core.stdc.math.lroundf       lround;
-    ///
-    alias core.stdc.math.lroundl       lround;
-
-    ///
-    alias core.stdc.math.llround       llround;
-    ///
-    alias core.stdc.math.llroundf      llround;
-    ///
-    alias core.stdc.math.llroundl      llround;
-
-    ///
-    alias core.stdc.math.trunc         trunc;
-    ///
-    alias core.stdc.math.truncf        trunc;
-    ///
-    alias core.stdc.math.truncl        trunc;
-
-    ///
-    alias core.stdc.math.fmod          fmod;
-    ///
-    alias core.stdc.math.fmodf         fmod;
-    ///
-    alias core.stdc.math.fmodl         fmod;
-
-    ///
-    alias core.stdc.math.remainder     remainder;
-    ///
-    alias core.stdc.math.remainderf    remainder;
-    ///
-    alias core.stdc.math.remainderl    remainder;
-
-    ///
-    alias core.stdc.math.remquo        remquo;
-    ///
-    alias core.stdc.math.remquof       remquo;
-    ///
-    alias core.stdc.math.remquol       remquo;
-
-    ///
-    alias core.stdc.math.copysign      copysign;
-    ///
-    alias core.stdc.math.copysignf     copysign;
-    ///
-    alias core.stdc.math.copysignl     copysign;
-
-//  alias core.stdc.math.nan           nan;
-//  alias core.stdc.math.nanf          nan;
-//  alias core.stdc.math.nanl          nan;
-
-    ///
-    alias core.stdc.math.nextafter     nextafter;
-    ///
-    alias core.stdc.math.nextafterf    nextafter;
-    ///
-    alias core.stdc.math.nextafterl    nextafter;
-
-    ///
-    alias core.stdc.math.nexttoward    nexttoward;
-    ///
-    alias core.stdc.math.nexttowardf   nexttoward;
-    ///
-    alias core.stdc.math.nexttowardl   nexttoward;
-
-    ///
-    alias core.stdc.math.fdim          fdim;
-    ///
-    alias core.stdc.math.fdimf         fdim;
-    ///
-    alias core.stdc.math.fdiml         fdim;
-
-    ///
-    alias core.stdc.math.fmax          fmax;
-    ///
-    alias core.stdc.math.fmaxf         fmax;
-    ///
-    alias core.stdc.math.fmaxl         fmax;
-
-    ///
-    alias core.stdc.math.fmin          fmin;
-    ///
-    alias core.stdc.math.fmin          fmin;
-    ///
-    alias core.stdc.math.fminl         fmin;
-
-    ///
-    alias core.stdc.math.fma           fma;
-    ///
-    alias core.stdc.math.fmaf          fma;
-    ///
-    alias core.stdc.math.fmal          fma;
-
-    ///
-    alias core.stdc.complex.carg       carg;
-    ///
-    alias core.stdc.complex.cargf      carg;
-    ///
-    alias core.stdc.complex.cargl      carg;
-
-    ///
-    alias core.stdc.complex.cimag      cimag;
-    ///
-    alias core.stdc.complex.cimagf     cimag;
-    ///
-    alias core.stdc.complex.cimagl     cimag;
-
-    ///
-    alias core.stdc.complex.conj       conj;
-    ///
-    alias core.stdc.complex.conjf      conj;
-    ///
-    alias core.stdc.complex.conjl      conj;
-
-    ///
-    alias core.stdc.complex.cproj      cproj;
-    ///
-    alias core.stdc.complex.cprojf     cproj;
-    ///
-    alias core.stdc.complex.cprojl     cproj;
-
-//  alias core.stdc.complex.creal      creal;
-//  alias core.stdc.complex.crealf     creal;
-//  alias core.stdc.complex.creall     creal;
-}
 version (NetBSD)
 {
     ///
diff --git a/libphobos/libdruntime/core/stdc/time.d b/libphobos/libdruntime/core/stdc/time.d
index 4a571e153bf..b19c3c7a899 100644
--- a/libphobos/libdruntime/core/stdc/time.d
+++ b/libphobos/libdruntime/core/stdc/time.d
@@ -15,138 +15,20 @@
 
 module core.stdc.time;
 
-private import core.stdc.config;
+version (Posix)
+    public import core.sys.posix.stdc.time;
+else version (Windows)
+    public import core.sys.windows.stdc.time;
+else
+    static assert(0, "unsupported system");
 
-version (OSX)
-    version = Darwin;
-else version (iOS)
-    version = Darwin;
-else version (TVOS)
-    version = Darwin;
-else version (WatchOS)
-    version = Darwin;
+import core.stdc.config;
 
 extern (C):
 @trusted: // There are only a few functions here that use unsafe C strings.
 nothrow:
 @nogc:
 
-version (Windows)
-{
-    ///
-    struct tm
-    {
-        int     tm_sec;     /// seconds after the minute - [0, 60]
-        int     tm_min;     /// minutes after the hour - [0, 59]
-        int     tm_hour;    /// hours since midnight - [0, 23]
-        int     tm_mday;    /// day of the month - [1, 31]
-        int     tm_mon;     /// months since January - [0, 11]
-        int     tm_year;    /// years since 1900
-        int     tm_wday;    /// days since Sunday - [0, 6]
-        int     tm_yday;    /// days since January 1 - [0, 365]
-        int     tm_isdst;   /// Daylight Saving Time flag
-    }
-}
-else version (Posix)
-{
-    ///
-    struct tm
-    {
-        int     tm_sec;     /// seconds after the minute [0-60]
-        int     tm_min;     /// minutes after the hour [0-59]
-        int     tm_hour;    /// hours since midnight [0-23]
-        int     tm_mday;    /// day of the month [1-31]
-        int     tm_mon;     /// months since January [0-11]
-        int     tm_year;    /// years since 1900
-        int     tm_wday;    /// days since Sunday [0-6]
-        int     tm_yday;    /// days since January 1 [0-365]
-        int     tm_isdst;   /// Daylight Savings Time flag
-        c_long  tm_gmtoff;  /// offset from CUT in seconds
-        char*   tm_zone;    /// timezone abbreviation
-    }
-}
-
-version (Posix)
-{
-    public import core.sys.posix.sys.types : time_t, clock_t;
-}
-else version (Windows)
-{
-    ///
-    alias c_long time_t;
-    ///
-    alias c_long clock_t;
-}
-
-///
-version (Windows)
-{
-    enum clock_t CLOCKS_PER_SEC = 1000;
-    clock_t clock();
-}
-else version (OSX)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000; // was 100 until OSX 10.4/10.5
-    version (X86)
-        extern (C) pragma(mangle, "clock$UNIX2003") clock_t clock();
-    else
-        clock_t clock();
-}
-else version (Darwin) // other Darwins (iOS, TVOS, WatchOS)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else version (FreeBSD)
-{
-    enum clock_t CLOCKS_PER_SEC = 128;
-    clock_t clock();
-}
-else version (NetBSD)
-{
-    enum clock_t CLOCKS_PER_SEC = 100;
-    clock_t clock();
-}
-else version (OpenBSD)
-{
-    enum clock_t CLOCKS_PER_SEC = 100;
-    clock_t clock();
-}
-else version (DragonFlyBSD)
-{
-    enum clock_t CLOCKS_PER_SEC = 128;
-    clock_t clock();
-}
-else version (Solaris)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else version (CRuntime_Glibc)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else version (CRuntime_Musl)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else version (CRuntime_Bionic)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else version (CRuntime_UClibc)
-{
-    enum clock_t CLOCKS_PER_SEC = 1_000_000;
-    clock_t clock();
-}
-else
-{
-    static assert(0, "unsupported system");
-}
-
 ///
 pure double  difftime(time_t time1, time_t time0); // MT-Safe
 ///
@@ -164,92 +46,3 @@ time_t  time(scope time_t* timer);
 @system tm*     localtime(const scope time_t* timer); // @system: MT-Unsafe race:tmbuf env locale
 ///
 @system size_t  strftime(scope char* s, size_t maxsize, const scope char* format, const scope tm* timeptr); // @system: MT-Safe env locale
-
-version (Windows)
-{
-    ///
-    void  tzset();                           // non-standard
-    ///
-    void  _tzset();                          // non-standard
-    ///
-    @system char* _strdate(return scope char* s);                 // non-standard
-    ///
-    @system char* _strtime(return scope char* s);                 // non-standard
-
-    ///
-    extern __gshared const(char)*[2] tzname; // non-standard
-}
-else version (Darwin)
-{
-    ///
-    void tzset();                            // non-standard
-    ///
-    extern __gshared const(char)*[2] tzname; // non-standard
-}
-else version (CRuntime_Glibc)
-{
-    ///
-    void tzset();                            // non-standard
-    ///
-    extern __gshared const(char)*[2] tzname; // non-standard
-}
-else version (FreeBSD)
-{
-    ///
-    void tzset();                            // non-standard
-    ///
-    extern __gshared const(char)*[2] tzname; // non-standard
-}
-else version (NetBSD)
-{
-    ///
-    void tzset();                            // non-standard
-    ///
-    extern __gshared const(char)*[2] tzname; // non-standard
-}
-else version (OpenBSD)
-{
-    ///
-    void tzset();                            // non-standard
-    ///
-    extern __gshared const(char)*[2] tzname; // non-standard
-}
-else version (DragonFlyBSD)
-{
-    ///
-    void tzset();                            // non-standard
-    ///
-    extern __gshared const(char)*[2] tzname; // non-standard
-}
-else version (Solaris)
-{
-    ///
-    void tzset();
-    ///
-    extern __gshared const(char)*[2] tzname;
-}
-else version (CRuntime_Bionic)
-{
-    ///
-    void tzset();
-    ///
-    extern __gshared const(char)*[2] tzname;
-}
-else version (CRuntime_Musl)
-{
-    ///
-    void tzset();                            // non-standard
-    ///
-    extern __gshared const(char)*[2] tzname; // non-standard
-}
-else version (CRuntime_UClibc)
-{
-    ///
-    void tzset();
-    ///
-    extern __gshared const(char)*[2] tzname;
-}
-else
-{
-    static assert(false, "Unsupported platform");
-}
diff --git a/libphobos/libdruntime/core/stdc/wchar_.d b/libphobos/libdruntime/core/stdc/wchar_.d
index 1cf8678f4cc..eecc8ef918e 100644
--- a/libphobos/libdruntime/core/stdc/wchar_.d
+++ b/libphobos/libdruntime/core/stdc/wchar_.d
@@ -12,14 +12,11 @@
  * Standards: ISO/IEC 9899:1999 (E)
  */
 
-/* NOTE: This file has been patched from the original DMD distribution to
- * work with the GDC compiler.
- */
 module core.stdc.wchar_;
 
-private import core.stdc.config;
-private import core.stdc.stdarg; // for va_list
-private import core.stdc.stdio;  // for FILE, not exposed per spec
+import core.stdc.config;
+import core.stdc.stdarg; // for va_list
+import core.stdc.stdio;  // for FILE, not exposed per spec
 public import core.stdc.stddef;  // for wchar_t
 public import core.stdc.time;    // for tm
 public import core.stdc.stdint;  // for WCHAR_MIN, WCHAR_MAX
@@ -131,44 +128,29 @@ alias wchar_t wint_t;
 enum wchar_t WEOF = 0xFFFF;
 
 ///
-int fwprintf(FILE* stream, in wchar_t* format, ...);
+int fwprintf(FILE* stream, const scope wchar_t* format, scope const ...);
 ///
-int fwscanf(FILE* stream, in wchar_t* format, ...);
-int swscanf(in wchar_t* s, in wchar_t* format, ...);
+int fwscanf(FILE* stream, const scope wchar_t* format, scope ...);
 ///
-int vfwprintf(FILE* stream, in wchar_t* format, va_list arg);
+int swprintf(wchar_t* s, size_t n, const scope wchar_t* format, scope const ...);
 ///
-int vfwscanf(FILE* stream, in wchar_t* format, va_list arg);
-int vswscanf(in wchar_t* s, in wchar_t* format, va_list arg);
+int swscanf(const scope wchar_t* s, const scope wchar_t* format, scope ...);
 ///
-int vwprintf(in wchar_t* format, va_list arg);
+int vfwprintf(FILE* stream, const scope wchar_t* format, va_list arg);
 ///
-int vwscanf(in wchar_t* format, va_list arg);
+int vfwscanf(FILE* stream, const scope wchar_t* format, va_list arg);
 ///
-int wprintf(in wchar_t* format, ...);
+int vswprintf(wchar_t* s, size_t n, const scope wchar_t* format, va_list arg);
 ///
-int wscanf(in wchar_t* format, ...);
-
-/*
- * Windows has 2 versions of swprintf and vswprintf.  MinGW defaults to the
- * Microsoft signature.  Alias to match DMD/ANSI signature.
- */
-version (MinGW)
-{
-    ///
-    int _snwprintf(wchar_t* s, size_t n, in wchar_t* format, ...);
-    alias _snwprintf swprintf;
-    ///
-    int _vsnwprintf(wchar_t* s, size_t n, in wchar_t* format, va_list arg);
-    alias _vsnwprintf vswprintf;	
-}
-else
-{
-    ///
-    int swprintf(wchar_t* s, size_t n, in wchar_t* format, ...);
-    ///
-    int vswprintf(wchar_t* s, size_t n, in wchar_t* format, va_list arg);
-}
+int vswscanf(const scope wchar_t* s, const scope wchar_t* format, va_list arg);
+///
+int vwprintf(const scope wchar_t* format, va_list arg);
+///
+int vwscanf(const scope wchar_t* format, va_list arg);
+///
+int wprintf(const scope wchar_t* format, scope const ...);
+///
+int wscanf(const scope wchar_t* format, scope ...);
 
 // No unsafe pointer manipulation.
 @trusted
@@ -182,7 +164,7 @@ else
 ///
 wchar_t* fgetws(wchar_t* s, int n, FILE* stream);
 ///
-int      fputws(in wchar_t* s, FILE* stream);
+int      fputws(const scope wchar_t* s, FILE* stream);
 
 // No unsafe pointer manipulation.
 extern (D) @trusted
@@ -215,19 +197,19 @@ extern (D) @trusted
 }
 
 ///
-double  wcstod(in wchar_t* nptr, wchar_t** endptr);
+double  wcstod(const scope wchar_t* nptr, wchar_t** endptr);
 ///
-float   wcstof(in wchar_t* nptr, wchar_t** endptr);
+float   wcstof(const scope wchar_t* nptr, wchar_t** endptr);
 ///
-real    wcstold(in wchar_t* nptr, wchar_t** endptr);
+real    wcstold(const scope wchar_t* nptr, wchar_t** endptr);
 ///
-c_long  wcstol(in wchar_t* nptr, wchar_t** endptr, int base);
+c_long  wcstol(const scope wchar_t* nptr, wchar_t** endptr, int base);
 ///
-long    wcstoll(in wchar_t* nptr, wchar_t** endptr, int base);
+long    wcstoll(const scope wchar_t* nptr, wchar_t** endptr, int base);
 ///
-c_ulong wcstoul(in wchar_t* nptr, wchar_t** endptr, int base);
+c_ulong wcstoul(const scope wchar_t* nptr, wchar_t** endptr, int base);
 ///
-ulong   wcstoull(in wchar_t* nptr, wchar_t** endptr, int base);
+ulong   wcstoull(const scope wchar_t* nptr, wchar_t** endptr, int base);
 
 ///
 pure wchar_t* wcscpy(return wchar_t* s1, scope const wchar_t* s2);
@@ -263,7 +245,7 @@ wchar_t* wcstok(return wchar_t* s1, scope const wchar_t* s2, wchar_t** ptr);
 pure size_t wcslen(scope const wchar_t* s);
 
 ///
-pure wchar_t* wmemchr(return const wchar_t* s, wchar_t c, size_t n);
+pure inout(wchar_t)* wmemchr(return inout wchar_t* s, wchar_t c, size_t n);
 ///
 pure int      wmemcmp(scope const wchar_t* s1, scope const wchar_t* s2, size_t n);
 ///
@@ -274,7 +256,7 @@ pure wchar_t* wmemmove(return wchar_t* s1, scope const wchar_t* s2, size_t n);
 pure wchar_t* wmemset(return wchar_t* s, wchar_t c, size_t n);
 
 ///
-size_t wcsftime(wchar_t* s, size_t maxsize, in wchar_t* format, in tm* timeptr);
+size_t wcsftime(wchar_t* s, size_t maxsize, const scope wchar_t* format, const scope tm* timeptr);
 
 version (Windows)
 {
@@ -298,14 +280,14 @@ version (Windows)
 }
 
 ///
-int    mbsinit(in mbstate_t* ps);
+int    mbsinit(const scope mbstate_t* ps);
 ///
-size_t mbrlen(in char* s, size_t n, mbstate_t* ps);
+size_t mbrlen(const scope char* s, size_t n, mbstate_t* ps);
 ///
-size_t mbrtowc(wchar_t* pwc, in char* s, size_t n, mbstate_t* ps);
+size_t mbrtowc(wchar_t* pwc, const scope char* s, size_t n, mbstate_t* ps);
 ///
 size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps);
 ///
-size_t mbsrtowcs(wchar_t* dst, in char** src, size_t len, mbstate_t* ps);
+size_t mbsrtowcs(wchar_t* dst, const scope char** src, size_t len, mbstate_t* ps);
 ///
-size_t wcsrtombs(char* dst, in wchar_t** src, size_t len, mbstate_t* ps);
+size_t wcsrtombs(char* dst, const scope wchar_t** src, size_t len, mbstate_t* ps);
diff --git a/libphobos/libdruntime/core/stdc/wctype.d b/libphobos/libdruntime/core/stdc/wctype.d
index b0c81079a7a..b37e8322dc3 100644
--- a/libphobos/libdruntime/core/stdc/wctype.d
+++ b/libphobos/libdruntime/core/stdc/wctype.d
@@ -54,7 +54,7 @@ pure int iswxdigit(wint_t wc);
 ///
 int       iswctype(wint_t wc, wctype_t desc);
 ///
-@system wctype_t  wctype(in char* property);
+@system wctype_t  wctype(const scope char* property);
 ///
 pure wint_t    towlower(wint_t wc);
 ///
@@ -62,4 +62,4 @@ pure wint_t    towupper(wint_t wc);
 ///
 wint_t    towctrans(wint_t wc, wctrans_t desc);
 ///
-@system wctrans_t wctrans(in char* property);
+@system wctrans_t wctrans(const scope char* property);
diff --git a/libphobos/libdruntime/core/sys/bionic/err.d b/libphobos/libdruntime/core/sys/bionic/err.d
new file mode 100644
index 00000000000..e2756e10c91
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/bionic/err.d
@@ -0,0 +1,23 @@
+/**
+  * D header file for Bionic err.h.
+  *
+  * Copyright: Copyright © 2019, The D Language Foundation
+  * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+  * Authors: Ernesto Castellotti
+  */
+module core.sys.bionic.err;
+import core.stdc.stdarg : va_list;
+
+version (CRuntime_Bionic):
+extern (C):
+nothrow:
+@nogc:
+
+void err(int eval, scope const char* fmt, ...);
+void errx(int eval, scope const char* fmt, ...);
+void warn(scope const char* fmt, ...);
+void warnx(scope const char* fmt, ...);
+void verr(int eval, scope const char* fmt, va_list args);
+void verrx(int eval, scope const char* fmt, va_list args);
+void vwarn(scope const char* fmt, va_list args);
+void vwarnx(scope const char* fmt, va_list args);
diff --git a/libphobos/libdruntime/core/sys/darwin/dlfcn.d b/libphobos/libdruntime/core/sys/darwin/dlfcn.d
index c22424f3b7b..a38d9009e9d 100644
--- a/libphobos/libdruntime/core/sys/darwin/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/darwin/dlfcn.d
@@ -33,7 +33,7 @@ struct Dl_info
     void*        dli_saddr;
 }
 
-int dladdr(in void* addr, Dl_info* info);
+int dladdr(const scope void* addr, Dl_info* info);
 
 enum RTLD_NOLOAD = 0x10;
 enum RTLD_NODELETE = 0x80;
diff --git a/libphobos/libdruntime/core/sys/darwin/err.d b/libphobos/libdruntime/core/sys/darwin/err.d
new file mode 100644
index 00000000000..d96c790f3b6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/darwin/err.d
@@ -0,0 +1,41 @@
+/**
+  * D header file for Darwin err.h.
+  *
+  * Copyright: Copyright © 2019, The D Language Foundation
+  * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+  * Authors: Ernesto Castellotti
+  */
+module core.sys.darwin.err;
+import core.stdc.stdarg : va_list;
+
+version (OSX)
+    version = Darwin;
+else version (iOS)
+    version = Darwin;
+else version (TVOS)
+    version = Darwin;
+else version (WatchOS)
+    version = Darwin;
+
+
+version (Darwin):
+extern (C):
+nothrow:
+@nogc:
+
+alias ExitFunction = void function(int);
+
+void err(int eval, scope const char* fmt, ...);
+void errc(int eval, int code, scope const char* fmt, ...);
+void errx(int eval, scope const char* fmt, ...);
+void warn(scope const char* fmt, ...);
+void warnc(int code, scope const char* fmt, ...);
+void warnx(scope const char* fmt, ...);
+void verr(int eval, scope const char* fmt, va_list args);
+void verrc(int eval, int code, scope const char* fmt, va_list args);
+void verrx(int eval, scope const char* fmt, va_list args);
+void vwarn(scope const char* fmt, va_list args);
+void vwarnc(int code, scope const char* fmt, va_list args);
+void vwarnx(scope const char* fmt, va_list args);
+void err_set_file(void* vfp);
+void err_set_exit(ExitFunction exitf);
diff --git a/libphobos/libdruntime/core/sys/darwin/ifaddrs.d b/libphobos/libdruntime/core/sys/darwin/ifaddrs.d
new file mode 100644
index 00000000000..a2540361d0f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/darwin/ifaddrs.d
@@ -0,0 +1,77 @@
+/*******************************************************************************
+
+    Binding for Mac OSX's <ifaddr.h>, expose network interface addresses
+
+    The following functions are present as of Mac OSX 10.15:
+    - getifaddrs(3):   get interface addresses
+    - freeifaddrs(3):  deallocates the return value of `getifaddrs`
+    - getifmaddrs(3):  get multicast group membership
+    - freeifmaddrs(3): deallocates the return value of `getifmaddrs`
+
+    Copyright:  Copyright © 2020, The D Language Foundation
+    License:    $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+    Authors:    Daniel Graczer
+
+*******************************************************************************/
+
+module core.sys.darwin.ifaddrs;
+
+version (OSX)
+    version = Darwin;
+else version (iOS)
+    version = Darwin;
+else version (TVOS)
+    version = Darwin;
+else version (WatchOS)
+    version = Darwin;
+
+version (Darwin):
+extern (C):
+nothrow:
+@nogc:
+@system:
+
+import core.sys.posix.sys.socket;
+
+///
+struct ifaddrs
+{
+    /// Next item in the list
+    ifaddrs* ifa_next;
+    /// Name of the interface
+    char* ifa_name;
+    /// Flags from SIOCGIFFLAGS
+    uint ifa_flags;
+    /// Address of interface
+    sockaddr* ifa_addr;
+    /// Netmask of interface
+    sockaddr* ifa_netmask;
+    /// Point-to-point destination addresss
+    sockaddr* if_dstaddr;
+    /// Address specific data
+    void* ifa_data;
+}
+
+/// Returns: linked list of ifaddrs structures describing interfaces
+int getifaddrs(ifaddrs**);
+/// Frees the linked list returned by getifaddrs
+void freeifaddrs(ifaddrs*);
+
+///
+struct ifmaddrs
+{
+    /// Pointer to next struct
+    ifmaddrs* ifma_next;
+    /// Interface name (AF_LINK)
+    sockaddr* ifma_name;
+    /// Multicast address
+    sockaddr* ifma_addr;
+    /// Link-layer translation, if any
+    sockaddr* ifma_lladdr;
+}
+
+/// Stores a reference to a linked list of the multicast memberships
+/// on the local machine in the memory referenced by ifmaddrs
+int getifmaddrs(ifmaddrs**);
+/// Frees the list allocated by getifmaddrs
+void freeifmaddrs(ifmaddrs*);
diff --git a/libphobos/libdruntime/core/sys/darwin/mach/dyld.d b/libphobos/libdruntime/core/sys/darwin/mach/dyld.d
index 5bf5609a203..62d1a779262 100644
--- a/libphobos/libdruntime/core/sys/darwin/mach/dyld.d
+++ b/libphobos/libdruntime/core/sys/darwin/mach/dyld.d
@@ -33,7 +33,7 @@ uint         _dyld_image_count();
 const(char)* _dyld_get_image_name(uint image_index);
 mach_header* _dyld_get_image_header(uint image_index);
 intptr_t     _dyld_get_image_vmaddr_slide(uint image_index);
-void         _dyld_register_func_for_add_image(void function(in mach_header* mh, intptr_t vmaddr_slide));
-void         _dyld_register_func_for_remove_image(void function(in mach_header* mh, intptr_t vmaddr_slide));
+void         _dyld_register_func_for_add_image(void function(const scope mach_header* mh, intptr_t vmaddr_slide));
+void         _dyld_register_func_for_remove_image(void function(const scope mach_header* mh, intptr_t vmaddr_slide));
 
 
diff --git a/libphobos/libdruntime/core/sys/darwin/mach/getsect.d b/libphobos/libdruntime/core/sys/darwin/mach/getsect.d
index cf89747d0f2..fd1a8e4ea36 100644
--- a/libphobos/libdruntime/core/sys/darwin/mach/getsect.d
+++ b/libphobos/libdruntime/core/sys/darwin/mach/getsect.d
@@ -44,7 +44,7 @@ version (CoreDdoc)
      * Returns the section data of the given section in the given segment in the
      * mach executable it is linked into.
      *
-     * ___
+     * ---
      * void main()
      * {
      *      import core.sys.darwin.mach.getsect;
@@ -52,7 +52,7 @@ version (CoreDdoc)
      *      assert(getsectdata("__TEXT", "__text", &size));
      *      assert(size > 0);
      * }
-     * ___
+     * ---
      *
      * Params:
      *  segname = the name of the segment
@@ -63,8 +63,8 @@ version (CoreDdoc)
      * Returns: a pointer to the section data or `null` if it doesn't exist
      */
     char* getsectdata(
-        in char* segname,
-        in char* sectname,
+        const scope char* segname,
+        const scope char* sectname,
         c_ulong *size
     );
 
@@ -74,7 +74,7 @@ version (CoreDdoc)
      * Returns the section data of the given section in the given segment in the
      * given framework.
      *
-     * ___
+     * ---
      * void main()
      * {
      *      import core.sys.darwin.mach.getsect;
@@ -82,7 +82,7 @@ version (CoreDdoc)
      *      assert(getsectdatafromFramework("Foundation", "__TEXT", "__text", &size));
      *      assert(size > 0);
      * }
-     * ___
+     * ---
      *
      * Params:
      *  FrameworkName = the name of the framework to get the section data from
@@ -94,9 +94,9 @@ version (CoreDdoc)
      * Returns: a pointer to the section data or `null` if it doesn't exist
      */
     char* getsectdatafromFramework(
-        in char* FrameworkName,
-        in char* segname,
-        in char* sectname,
+        const scope char* FrameworkName,
+        const scope char* segname,
+        const scope char* sectname,
         c_ulong* size
     );
 
@@ -115,13 +115,13 @@ version (CoreDdoc)
      * Returns the section structure of the given section in the given segment
      * in the mach executable it is linked into.
      *
-     * ___
+     * ---
      * void main()
      * {
      *      import core.sys.darwin.mach.getsect;
      *      assert(getsectbyname("__TEXT", "__text"));
      * }
-     * ___
+     * ---
      *
      * Params:
      *  segname = the name of the segment
@@ -130,8 +130,8 @@ version (CoreDdoc)
      * Returns: a pointer to the section structure or `null` if it doesn't exist
      */
     const(Section)* getsectbyname(
-        in char* segname,
-        in char* sectname
+        const scope char* segname,
+        const scope char* sectname
     );
 
     /**
@@ -140,7 +140,7 @@ version (CoreDdoc)
      * Returns the section data of the given section in the given segment in the
      * image pointed to by the given mach header.
      *
-     * ___
+     * ---
      * void main()
      * {
      *      import core.sys.darwin.mach.getsect;
@@ -151,7 +151,7 @@ version (CoreDdoc)
      *      assert(getsectdata(mph, "__TEXT", "__text", &size));
      *      assert(size > 0);
      * }
-     * ___
+     * ---
      *
      * Params:
      *  mhp = the mach header to get the section data from
@@ -163,9 +163,9 @@ version (CoreDdoc)
      * Returns: a pointer to the section data or `null` if it doesn't exist
      */
     ubyte* getsectiondata(
-        in MachHeader* mhp,
-        in char* segname,
-        in char* sectname,
+        const scope MachHeader* mhp,
+        const scope char* segname,
+        const scope char* sectname,
         c_ulong* size
     );
 
@@ -175,13 +175,13 @@ version (CoreDdoc)
      * Returns the segment structure of the given segment in the mach executable
      * it is linked into.
      *
-     * ___
+     * ---
      * void main()
      * {
      *      import core.sys.darwin.mach.getsect;
      *      assert(getsegbyname("__TEXT"));
      * }
-     * ___
+     * ---
      *
      * Params:
      *  segname = the name of the segment
@@ -189,7 +189,7 @@ version (CoreDdoc)
      * Returns: a pointer to the section structure or `null` if it doesn't exist
      */
     const(SegmentCommand)* getsegbyname(
-        in char* segname
+        const scope char* segname
     );
 
     /**
@@ -198,7 +198,7 @@ version (CoreDdoc)
      * Returns the segment data of the given segment in the image pointed to by
      * the given mach header.
      *
-     * ___
+     * ---
      * void main()
      * {
      *      import core.sys.darwin.mach.getsect;
@@ -209,7 +209,7 @@ version (CoreDdoc)
      *      assert(getsegmentdata(mph, "__TEXT", &size));
      *      assert(size > 0);
      * }
-     * ___
+     * ---
      *
      * Params:
      *  mhp = the mach header to get the section data from
@@ -220,8 +220,8 @@ version (CoreDdoc)
      * Returns: a pointer to the section data or `null` if it doesn't exist
      */
     ubyte* getsegmentdata(
-        in MachHeader* mhp,
-        in char* segname,
+        const scope MachHeader* mhp,
+        const scope char* segname,
         c_ulong* size
     );
 
@@ -236,7 +236,7 @@ version (CoreDdoc)
      * Returns the section data of the given section in the given segment in the
      * image pointed to by the given mach header.
      *
-     * ___
+     * ---
      * void main()
      * {
      *      import core.sys.darwin.mach.getsect;
@@ -247,7 +247,7 @@ version (CoreDdoc)
      *      assert(getsectdatafromheader(mph, "__TEXT", "__text", &size));
      *      assert(size > 0);
      * }
-     * ___
+     * ---
      *
      * Params:
      *  mhp = the mach header to get the section data from
@@ -259,17 +259,17 @@ version (CoreDdoc)
      * Returns: a pointer to the section data or `null` if it doesn't exist
      */
     ubyte* getsectdatafromheader(
-        in mach_header* mhp,
-        in char* segname,
-        in char* sectname,
+        const scope mach_header* mhp,
+        const scope char* segname,
+        const scope char* sectname,
         c_ulong* size
     );
 
     /// ditto
     ubyte* getsectdatafromheader_64(
-        in mach_header_64* mhp,
-        in char* segname,
-        in char* sectname,
+        const scope mach_header_64* mhp,
+        const scope char* segname,
+        const scope char* sectname,
         c_ulong* size
     );
 
@@ -280,7 +280,7 @@ version (CoreDdoc)
      * Returns the section structure of the given section in the given segment
      * in image pointed to by the given mach header.
      *
-     * ___
+     * ---
      * void main()
      * {
      *      import core.sys.darwin.mach.getsect;
@@ -289,7 +289,7 @@ version (CoreDdoc)
      *      auto mph = _NSGetMachExecuteHeader();
      *      assert(getsectbynamefromheader(mph, "__TEXT", "__text"));
      * }
-     * ___
+     * ---
      *
      * Params:
      *  mhp = the mach header to get the section from
@@ -299,16 +299,16 @@ version (CoreDdoc)
      * Returns: a pointer to the section structure or `null` if it doesn't exist
      */
     const(section)* getsectbynamefromheader(
-        in mach_header* mhp,
-        in char* segname,
-        in char* sectname
+        const scope mach_header* mhp,
+        const scope char* segname,
+        const scope char* sectname
     );
 
     /// ditto
     const(section_64)* getsectbynamefromheader_64(
-        in mach_header_64* mhp,
-        in char* segname,
-        in char* sectname
+        const scope mach_header_64* mhp,
+        const scope char* segname,
+        const scope char* sectname
     );
 
     /**
@@ -326,17 +326,17 @@ version (CoreDdoc)
      * Returns: a pointer to the section structure or `null` if it doesn't exist
      */
     const(section)* getsectbynamefromheaderwithswap(
-        in mach_header* mhp,
-        in char* segname,
-        in char* section,
+        const scope mach_header* mhp,
+        const scope char* segname,
+        const scope char* section,
         int fSwap
     );
 
     /// ditto
     const(section)* getsectbynamefromheaderwithswap_64(
-        in mach_header_64* mhp,
-        in char* segname,
-        in char* section,
+        const scope mach_header_64* mhp,
+        const scope char* segname,
+        const scope char* section,
         int fSwap
     );
 }
@@ -357,15 +357,15 @@ public import core.sys.darwin.mach.loader;
 import core.stdc.config : c_ulong;
 
 char* getsectdata(
-    in char* segname,
-    in char* sectname,
+    const scope char* segname,
+    const scope char* sectname,
     c_ulong *size
 );
 
 char* getsectdatafromFramework(
-    in char* FrameworkName,
-    in char* segname,
-    in char* sectname,
+    const scope char* FrameworkName,
+    const scope char* segname,
+    const scope char* sectname,
     c_ulong* size
 );
 
@@ -377,24 +377,24 @@ c_ulong get_edata();
 version (D_LP64)
 {
     const(section_64)* getsectbyname(
-        in char* segname,
-        in char* sectname
+        const scope char* segname,
+        const scope char* sectname
     );
 
     ubyte* getsectiondata(
-        in mach_header_64* mhp,
-        in char* segname,
-        in char* sectname,
+        const scope mach_header_64* mhp,
+        const scope char* segname,
+        const scope char* sectname,
         c_ulong* size
     );
 
     const(segment_command_64)* getsegbyname(
-        in char* segname
+        const scope char* segname
     );
 
     ubyte* getsegmentdata(
-        in mach_header_64* mhp,
-        in char* segname,
+        const scope mach_header_64* mhp,
+        const scope char* segname,
         c_ulong* size
     );
 }
@@ -403,24 +403,24 @@ version (D_LP64)
 else
 {
     const(section)* getsectbyname(
-        in char* segname,
-        in char* sectname
+        const scope char* segname,
+        const scope char* sectname
     );
 
     ubyte* getsectiondata(
-        in mach_header* mhp,
-        in char* segname,
-        in char* sectname,
+        const scope mach_header* mhp,
+        const scope char* segname,
+        const scope char* sectname,
         c_ulong* size
     );
 
     const(segment_command)* getsegbyname(
-        in char* segname
+        const scope char* segname
     );
 
     ubyte* getsegmentdata(
-        in mach_header* mhp,
-        in char* segname,
+        const scope mach_header* mhp,
+        const scope char* segname,
         c_ulong* size
     );
 }
@@ -428,44 +428,44 @@ else
 // Interfaces for tools working with 32-bit Mach-O files.
 
 ubyte* getsectdatafromheader(
-    in mach_header* mhp,
-    in char* segname,
-    in char* sectname,
+    const scope mach_header* mhp,
+    const scope char* segname,
+    const scope char* sectname,
     c_ulong* size
 );
 
 const(section)* getsectbynamefromheader(
-    in mach_header* mhp,
-    in char* segname,
-    in char* sectname
+    const scope mach_header* mhp,
+    const scope char* segname,
+    const scope char* sectname
 );
 
 const(section)* getsectbynamefromheaderwithswap(
-    in mach_header* mhp,
-    in char* segname,
-    in char* section,
+    const scope mach_header* mhp,
+    const scope char* segname,
+    const scope char* section,
     int fSwap
 );
 
 // Interfaces for tools working with 64-bit Mach-O files.
 
 ubyte* getsectdatafromheader_64(
-    in mach_header_64* mhp,
-    in char* segname,
-    in char* sectname,
+    const scope mach_header_64* mhp,
+    const scope char* segname,
+    const scope char* sectname,
     c_ulong* size
 );
 
 const(section_64)* getsectbynamefromheader_64(
-    in mach_header_64* mhp,
-    in char* segname,
-    in char* sectname
+    const scope mach_header_64* mhp,
+    const scope char* segname,
+    const scope char* sectname
 );
 
 const(section)* getsectbynamefromheaderwithswap_64(
-    in mach_header_64* mhp,
-    in char* segname,
-    in char* section,
+    const scope mach_header_64* mhp,
+    const scope char* segname,
+    const scope char* section,
     int fSwap
 );
 
diff --git a/libphobos/libdruntime/core/sys/darwin/mach/loader.d b/libphobos/libdruntime/core/sys/darwin/mach/loader.d
index af42485fd83..f46698c3b53 100644
--- a/libphobos/libdruntime/core/sys/darwin/mach/loader.d
+++ b/libphobos/libdruntime/core/sys/darwin/mach/loader.d
@@ -2568,14 +2568,7 @@ version (CoreDdoc)
         ulong size;
     }
 }
-
-else version (OSX)
-    version = Darwin;
-else version (iOS)
-    version = Darwin;
-else version (TVOS)
-    version = Darwin;
-else version (WatchOS)
+else
     version = Darwin;
 
 version (Darwin):
@@ -3116,12 +3109,8 @@ struct dylib_reference
     }
 
     @property void isym()(uint v) @safe pure nothrow @nogc
-    in
-    {
-        assert(v >= 0U, "Value is smaller than the minimum value of bitfield 'isym'");
-        assert(v <= 16777215U, "Value is greater than the maximum value of bitfield 'isym'");
-    }
-    body
+    in(v >= 0U, "Value is smaller than the minimum value of bitfield 'isym'")
+    in(v <= 16777215U, "Value is greater than the maximum value of bitfield 'isym'")
     {
         storage = cast(uint) ((storage & (-1 - cast(uint) 16777215U)) |
             ((cast(uint) v << 0U) & 16777215U));
@@ -3133,12 +3122,8 @@ struct dylib_reference
     }
 
     @property void flags()(uint v) pure nothrow @nogc @safe
-    in
-    {
-        assert(v >= 0U, "Value is smaller than the minimum value of bitfield 'flags'");
-        assert(v <= 255U, "Value is greater than the maximum value of bitfield 'flags'");
-    }
-    body
+    in(v >= 0U, "Value is smaller than the minimum value of bitfield 'flags'")
+    in(v <= 255U, "Value is greater than the maximum value of bitfield 'flags'")
     {
         storage = cast(uint) ((storage & (-1 - cast(uint) 4278190080U)) |
             ((cast(uint) v << 24U) & 4278190080U));
@@ -3163,12 +3148,8 @@ struct twolevel_hint
     }
 
     @property void isub_image()(uint v) pure nothrow @nogc @safe
-    in
-    {
-        assert(v >= 0U, "Value is smaller than the minimum value of bitfield 'isub_image'");
-        assert(v <= 255U, "Value is greater than the maximum value of bitfield 'isub_image'");
-    }
-    body
+    in(v >= 0U, "Value is smaller than the minimum value of bitfield 'isub_image'")
+    in(v <= 255U, "Value is greater than the maximum value of bitfield 'isub_image'")
     {
         storage = cast(uint) ((storage & (-1-cast(uint)255U)) |
             ((cast(uint) v << 0U) & 255U));
@@ -3180,12 +3161,8 @@ struct twolevel_hint
     }
 
     @property void itoc()(uint v) pure nothrow @nogc @safe
-    in
-    {
-        assert(v >= 0U, "Value is smaller than the minimum value of bitfield 'itoc'");
-        assert(v <= 16777215U, "Value is greater than the maximum value of bitfield 'itoc'");
-    }
-    body
+    in(v >= 0U, "Value is smaller than the minimum value of bitfield 'itoc'")
+    in(v <= 16777215U, "Value is greater than the maximum value of bitfield 'itoc'")
     {
         storage = cast(uint) ((storage & (-1-cast(uint)4294967040U)) |
             ((cast(uint) v << 8U) & 4294967040U));
diff --git a/libphobos/libdruntime/core/sys/darwin/mach/nlist.d b/libphobos/libdruntime/core/sys/darwin/mach/nlist.d
new file mode 100644
index 00000000000..11e5ced26b7
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/darwin/mach/nlist.d
@@ -0,0 +1,317 @@
+/**
+ * Bindings for symbols and defines in `mach-o/nlist.h`
+ *
+ * This file was created based on the MacOSX 10.15 SDK.
+ *
+ * Copyright:
+ * D Language Foundation 2020
+ * Some documentation was extracted from the C headers
+ * and is the property of Apple Inc.
+ *
+ * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors: Mathias 'Geod24' Lang
+ * Source: $(DRUNTIMESRC core/sys/darwin/mach/_nlist.d)
+ */
+module core.sys.darwin.mach.nlist;
+
+import core.stdc.config;
+
+extern(C):
+nothrow:
+@nogc:
+pure:
+
+/**
+ * An entry in a list of symbols for 64-bits architectures
+ *
+ * Said symbols can be used to describe many different type of data,
+ * including STABS debug infos. Introduced in MacOSX 10.8 SDK.
+ *
+ * See_Also:
+ * https://developer.apple.com/documentation/kernel/nlist_64
+ */
+struct nlist_64
+{
+    /// Compatibility alias, as `n_strx` is in an union in C code
+    alias n_un = n_strx;
+
+    /**
+     * Index of this symbol's name into the string table
+     *
+     * All names are stored as NUL-terminated strings into the string table.
+     * For historical reason, the very first entry into the string table is `0`,
+     * hence all non-NULL names have an index > 0.
+     */
+    uint n_strx;
+
+    /**
+     * A bitfield that describes the type of this symbol
+     *
+     * In reality, this describes 4 fields:
+     * - N_STAB (top 3 bits)
+     * - N_PEXT (next 1 bit)
+     * - N_TYPE (next 3 bits)
+     * - N_EXT (last 1 bit)
+     *
+     * The enum values `N_STAB`, `N_PEXT`, `N_TYPE`, and `N_EXT` should be used
+     * as masks to check which type this `nlist_64` actually is.
+     */
+    ubyte n_type;
+    /// Section number (note that `0` means `NO_SECT`)
+    ubyte n_sect;
+    /* see <mach-o/stab.h> */
+    ushort n_desc;
+    /* value of this symbol (or stab offset) */
+    ulong n_value;
+    // Note: `n_value` *is* `uint64_t`, not `c_ulong` !
+}
+
+/// Mask to use with `nlist_64.n_type` to check what the entry describes
+enum
+{
+    /**
+     * If any of these bits set, a symbolic debugging entry
+     *
+     * Only symbolic debugging entries have some of the N_STAB bits set and if any
+     * of these bits are set then it is a symbolic debugging entry (a stab).  In
+     * which case then the values of the n_type field (the entire field) are given
+     * in <mach-o/stab.h>
+     */
+    N_STAB = 0xe0,
+    /// Private external symbol bit
+    N_PEXT = 0x10,
+    /// Mask for the type bits
+    N_TYPE = 0x0e,  /* mask for the type bits */
+    /// External symbol bit, set for external symbols
+    N_EXT  = 0x01,
+}
+
+/// Values for `NTypeMask.N_TYPE` bits of the `nlist_64.n_type` field.
+enum
+{
+    /// Undefined (`n_sect == NO_SECT`)
+    N_UNDF = 0x0,
+    /// Absolute (`n_sect == NO_SECT`)
+    N_ABS  = 0x2,
+    /// Defined in section number `nlist_64.n_sect`
+    N_SECT = 0xe,
+    /// Prebound undefined (defined in a dylib)
+    N_PBUD = 0xc,
+    /**
+     * Indirect symbol
+     *
+     * If the type is `N_INDR` then the symbol is defined to be the same as
+     * another symbol. In this case the `n_value` field is an index into
+     * the string table of the other symbol's name. When the other symbol
+     * is defined then they both take on the defined type and value.
+     */
+    N_INDR = 0xa,
+}
+
+/**
+ * Symbol is not in any section
+ *
+ * If the type is N_SECT then the n_sect field contains an ordinal of the
+ * section the symbol is defined in.  The sections are numbered from 1 and
+ * refer to sections in order they appear in the load commands for the file
+ * they are in.  This means the same ordinal may very well refer to different
+ * sections in different files.
+ *
+ * The n_value field for all symbol table entries (including N_STAB's) gets
+ * updated by the link editor based on the value of it's n_sect field and where
+ * the section n_sect references gets relocated.  If the value of the n_sect
+ * field is NO_SECT then it's n_value field is not changed by the link editor.
+ */
+enum NO_SECT = 0;
+
+/// Maximum number of sections: 1 thru 255 inclusive
+enum MAX_SECT = 255;
+
+/**
+ * Common symbols are represented by undefined (N_UNDF) external (N_EXT) types
+ * who's values (n_value) are non-zero.  In which case the value of the n_value
+ * field is the size (in bytes) of the common symbol.  The n_sect field is set
+ * to NO_SECT.  The alignment of a common symbol may be set as a power of 2
+ * between 2^1 and 2^15 as part of the n_desc field using the macros below. If
+ * the alignment is not set (a value of zero) then natural alignment based on
+ * the size is used.
+ */
+extern(D) ubyte GET_COMM_ALIGN(uint n_desc) @safe
+{
+    return (((n_desc) >> 8) & 0x0f);
+}
+
+/// Ditto
+extern(D) ref ushort SET_COMM_ALIGN(return ref ushort n_desc, size_t wanted_align) @safe
+{
+    return n_desc = (((n_desc) & 0xf0ff) | (((wanted_align) & 0x0f) << 8));
+}
+
+/**
+ * To support the lazy binding of undefined symbols in the dynamic link-editor,
+ * the undefined symbols in the symbol table (the nlist structures) are marked
+ * with the indication if the undefined reference is a lazy reference or
+ * non-lazy reference.  If both a non-lazy reference and a lazy reference is
+ * made to the same symbol the non-lazy reference takes precedence.  A reference
+ * is lazy only when all references to that symbol are made through a symbol
+ * pointer in a lazy symbol pointer section.
+ *
+ * The implementation of marking nlist structures in the symbol table for
+ * undefined symbols will be to use some of the bits of the n_desc field as a
+ * reference type.  The mask REFERENCE_TYPE will be applied to the n_desc field
+ * of an nlist structure for an undefined symbol to determine the type of
+ * undefined reference (lazy or non-lazy).
+ *
+ * The constants for the REFERENCE FLAGS are propagated to the reference table
+ * in a shared library file.  In that case the constant for a defined symbol,
+ * REFERENCE_FLAG_DEFINED, is also used.
+ */
+enum
+{
+    /// Reference type bits of the n_desc field of undefined symbols
+    REFERENCE_TYPE = 0x7,
+
+    /// types of references
+    REFERENCE_FLAG_UNDEFINED_NON_LAZY = 0,
+    /// Ditto
+    REFERENCE_FLAG_UNDEFINED_LAZY     = 1,
+    /// Ditto
+    REFERENCE_FLAG_DEFINED            = 2,
+    /// Ditto
+    REFERENCE_FLAG_PRIVATE_DEFINED    = 3,
+    /// Ditto
+    REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY = 4,
+    /// Ditto
+    REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY     = 5,
+
+    /**
+     * To simplify stripping of objects that use are used with the dynamic link
+     * editor, the static link editor marks the symbols defined an object that are
+     * referenced by a dynamicly bound object (dynamic shared libraries, bundles).
+     * With this marking strip knows not to strip these symbols.
+     */
+    REFERENCED_DYNAMICALLY = 0x0010,
+}
+
+/**
+ * For images created by the static link editor with the -twolevel_namespace
+ * option in effect the flags field of the mach header is marked with
+ * MH_TWOLEVEL.  And the binding of the undefined references of the image are
+ * determined by the static link editor.  Which library an undefined symbol is
+ * bound to is recorded by the static linker in the high 8 bits of the n_desc
+ * field using the SET_LIBRARY_ORDINAL macro below.  The ordinal recorded
+ * references the libraries listed in the Mach-O's LC_LOAD_DYLIB,
+ * LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB, LC_LOAD_UPWARD_DYLIB, and
+ * LC_LAZY_LOAD_DYLIB, etc. load commands in the order they appear in the
+ * headers.   The library ordinals start from 1.
+ * For a dynamic library that is built as a two-level namespace image the
+ * undefined references from module defined in another use the same nlist struct
+ * an in that case SELF_LIBRARY_ORDINAL is used as the library ordinal.  For
+ * defined symbols in all images they also must have the library ordinal set to
+ * SELF_LIBRARY_ORDINAL.  The EXECUTABLE_ORDINAL refers to the executable
+ * image for references from plugins that refer to the executable that loads
+ * them.
+ *
+ * The DYNAMIC_LOOKUP_ORDINAL is for undefined symbols in a two-level namespace
+ * image that are looked up by the dynamic linker with flat namespace semantics.
+ * This ordinal was added as a feature in Mac OS X 10.3 by reducing the
+ * value of MAX_LIBRARY_ORDINAL by one.  So it is legal for existing binaries
+ * or binaries built with older tools to have 0xfe (254) dynamic libraries.  In
+ * this case the ordinal value 0xfe (254) must be treated as a library ordinal
+ * for compatibility.
+ */
+ubyte GET_LIBRARY_ORDINAL(uint n_desc) @safe { return ((n_desc) >> 8) & 0xff; }
+/// Ditto
+ref ushort SET_LIBRARY_ORDINAL(return scope ref ushort n_desc, uint ordinal) @safe
+{
+    return n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8));
+}
+
+/// Ditto
+enum
+{
+    SELF_LIBRARY_ORDINAL   = 0x00,
+    MAX_LIBRARY_ORDINAL    = 0xfd,
+    DYNAMIC_LOOKUP_ORDINAL = 0xfe,
+    EXECUTABLE_ORDINAL     = 0xff,
+}
+
+/**
+ * The bit 0x0020 of the n_desc field is used for two non-overlapping purposes
+ * and has two different symbolic names, N_NO_DEAD_STRIP and N_DESC_DISCARDED.
+ */
+enum
+{
+    /**
+     * Symbol is not to be dead stripped
+     *
+     * The N_NO_DEAD_STRIP bit of the n_desc field only ever appears in a
+     * relocatable .o file (MH_OBJECT filetype). And is used to indicate to the
+     * static link editor it is never to dead strip the symbol.
+     */
+    N_NO_DEAD_STRIP = 0x0020,
+
+    /**
+     * Symbol is discarded
+     *
+     * The N_DESC_DISCARDED bit of the n_desc field never appears in linked image.
+     * But is used in very rare cases by the dynamic link editor to mark an in
+     * memory symbol as discared and longer used for linking.
+     */
+    N_DESC_DISCARDED =0x0020,
+
+    /**
+     * Symbol is weak referenced
+     *
+     * The N_WEAK_REF bit of the n_desc field indicates to the dynamic linker that
+     * the undefined symbol is allowed to be missing and is to have the address of
+     * zero when missing.
+     */
+    N_WEAK_REF = 0x0040,
+
+    /**
+     * Coalesed symbol is a weak definition
+     *
+     * The N_WEAK_DEF bit of the n_desc field indicates to the static and dynamic
+     * linkers that the symbol definition is weak, allowing a non-weak symbol to
+     * also be used which causes the weak definition to be discared.  Currently this
+     * is only supported for symbols in coalesed sections.
+     */
+    N_WEAK_DEF = 0x0080,
+
+    /**
+     * Reference to a weak symbol
+     *
+     * The N_REF_TO_WEAK bit of the n_desc field indicates to the dynamic linker
+     * that the undefined symbol should be resolved using flat namespace searching.
+     */
+    N_REF_TO_WEAK = 0x0080,
+
+    /**
+     * Symbol is a Thumb function (ARM)
+     *
+     * The N_ARM_THUMB_DEF bit of the n_desc field indicates that the symbol is
+     * a defintion of a Thumb function.
+     */
+    N_ARM_THUMB_DEF = 0x0008,
+
+    /**
+     * The N_SYMBOL_RESOLVER bit of the n_desc field indicates that the
+     * that the function is actually a resolver function and should
+     * be called to get the address of the real function to use.
+     * This bit is only available in .o files (MH_OBJECT filetype)
+     */
+    N_SYMBOL_RESOLVER =  0x0100,
+
+    /**
+     * The N_ALT_ENTRY bit of the n_desc field indicates that the
+     * symbol is pinned to the previous content.
+     */
+    N_ALT_ENTRY = 0x0200,
+
+    /**
+     * The N_COLD_FUNC bit of the n_desc field indicates that the symbol is used
+     * infrequently and the linker should order it towards the end of the section.
+     */
+    N_COLD_FUNC = 0x0400,
+}
diff --git a/libphobos/libdruntime/core/sys/darwin/mach/stab.d b/libphobos/libdruntime/core/sys/darwin/mach/stab.d
new file mode 100644
index 00000000000..ecdb4560a68
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/darwin/mach/stab.d
@@ -0,0 +1,90 @@
+/**
+ * Bindings for symbols and defines in `mach-o/stab.h`
+ *
+ * This file gives definitions supplementing <nlist.h> for permanent symbol
+ * table entries of Mach-O files.  Modified from the BSD definitions.  The
+ * modifications from the original definitions were changing what the values of
+ * what was the n_other field (an unused field) which is now the n_sect field.
+ * These modifications are required to support symbols in an arbitrary number of
+ * sections not just the three sections (text, data and bss) in a BSD file.
+ * The values of the defined constants have NOT been changed.
+ *
+ * These must have one of the N_STAB bits on.  The n_value fields are subject
+ * to relocation according to the value of their n_sect field.  So for types
+ * that refer to things in sections the n_sect field must be filled in with the
+ * proper section ordinal.  For types that are not to have their n_value field
+ * relocatated the n_sect field must be NO_SECT.
+ *
+ * This file was created based on the MacOSX 10.15 SDK.
+ *
+ * Copyright:
+ * D Language Foundation 2020
+ * Some documentation was extracted from the C headers
+ * and is the property of Apple Inc.
+ *
+ * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
+ * Authors: Mathias 'Geod24' Lang
+ * Source: $(DRUNTIMESRC core/sys/darwin/mach/_nlist.d)
+ */
+module core.sys.darwin.mach.stab;
+
+extern(C):
+nothrow:
+@nogc:
+pure:
+
+/**
+ * Symbolic debugger symbols.
+ *
+ * The comments give the conventional use for
+ * ```
+ *  .stabs "n_name", n_type, n_sect, n_desc, n_value
+ * ```
+ *
+ * where n_type is the defined constant and not listed in the comment.  Other
+ * fields not listed are zero. n_sect is the section ordinal the entry is
+ * refering to.
+ */
+enum
+{
+    N_GSYM  = 0x20,    /// global symbol: name,,NO_SECT,type,0
+    N_FNAME = 0x22,    /// procedure name (f77 kludge): name,,NO_SECT,0,0
+    N_FUN   = 0x24,    /// procedure: name,,n_sect,linenumber,address
+    N_STSYM = 0x26,    /// static symbol: name,,n_sect,type,address
+    N_LCSYM = 0x28,    /// .lcomm symbol: name,,n_sect,type,address
+    N_BNSYM = 0x2e,    /// begin nsect sym: 0,,n_sect,0,address
+    N_AST   = 0x32,    /// AST file path: name,,NO_SECT,0,0
+    N_OPT   = 0x3c,    /// emitted with gcc2_compiled and in gcc source
+    N_RSYM  = 0x40,    /// register sym: name,,NO_SECT,type,register
+    N_SLINE = 0x44,    /// src line: 0,,n_sect,linenumber,address
+    N_ENSYM = 0x4e,    /// end nsect sym: 0,,n_sect,0,address
+    N_SSYM  = 0x60,    /// structure elt: name,,NO_SECT,type,struct_offset
+    N_SO    = 0x64,    /// source file name: name,,n_sect,0,address
+    /**
+     * Object file name: name,,(see below),0,st_mtime
+     *
+     * Historically N_OSO set n_sect to 0.
+     * The N_OSO n_sect may instead hold the low byte of the cpusubtype value
+     * from the Mach-O header.
+     */
+    N_OSO   = 0x66,
+    N_LSYM  = 0x80,    /// local sym: name,,NO_SECT,type,offset
+    N_BINCL = 0x82,    /// include file beginning: name,,NO_SECT,0,sum
+    N_SOL   = 0x84,    /// #included file name: name,,n_sect,0,address
+    N_PARAMS = 0x86,   /// compiler parameters: name,,NO_SECT,0,0
+    N_VERSION = 0x88,  /// compiler version: name,,NO_SECT,0,0
+    N_OLEVEL = 0x8A,   /// compiler -O level: name,,NO_SECT,0,0
+    N_PSYM  = 0xa0,    /// parameter: name,,NO_SECT,type,offset
+    N_EINCL = 0xa2,    /// include file end: name,,NO_SECT,0,0
+    N_ENTRY = 0xa4,    /// alternate entry: name,,n_sect,linenumber,address
+    N_LBRAC = 0xc0,    /// left bracket: 0,,NO_SECT,nesting level,address
+    N_EXCL =  0xc2,    /// deleted include file: name,,NO_SECT,0,sum
+    N_RBRAC = 0xe0,    /// right bracket: 0,,NO_SECT,nesting level,address
+    N_BCOMM = 0xe2,    /// begin common: name,,NO_SECT,0,0
+    N_ECOMM = 0xe4,    /// end common: name,,n_sect,0,0
+    N_ECOML = 0xe8,    /// end common (local name): 0,,n_sect,0,address
+    N_LENG =  0xfe,    /// second stab entry with length information
+
+    // For the berkeley pascal compiler, pc(1):
+    N_PC   = 0x30,    /// global pascal symbol: name,,NO_SECT,subtype,line
+}
diff --git a/libphobos/libdruntime/core/sys/darwin/netinet/in_.d b/libphobos/libdruntime/core/sys/darwin/netinet/in_.d
index 0653d3a4b59..b850e3c98cf 100644
--- a/libphobos/libdruntime/core/sys/darwin/netinet/in_.d
+++ b/libphobos/libdruntime/core/sys/darwin/netinet/in_.d
@@ -225,7 +225,7 @@ static if (_DARWIN_C_SOURCE)
     {
         in_addr  ip_dst;
         char[40] ip_opts = 0;
-    };
+    }
 
     enum IP_OPTIONS         = 1;
     enum IP_HDRINCL         = 2;
@@ -307,14 +307,14 @@ static if (_DARWIN_C_SOURCE)
     {
         in_addr imr_multiaddr;
         in_addr imr_interface;
-    };
+    }
 
     struct ip_mreqn
     {
         in_addr imr_multiaddr;
         in_addr imr_address;
         int     imr_ifindex;
-    };
+    }
 
     struct ip_mreq_source
     {
@@ -322,14 +322,14 @@ static if (_DARWIN_C_SOURCE)
         in_addr imr_multiaddr;
         in_addr imr_sourceaddr;
         in_addr imr_interface;
-    };
+    }
 
     struct group_req
     {
         align(4):
         uint             gr_interface;
         sockaddr_storage gr_group;
-    };
+    }
 
     struct group_source_req
     {
@@ -337,7 +337,7 @@ static if (_DARWIN_C_SOURCE)
         uint             gsr_interface;
         sockaddr_storage gsr_group;
         sockaddr_storage gsr_source;
-    };
+    }
 
     int setipv4sourcefilter(int, in_addr, in_addr, uint, uint, in_addr*);
     int getipv4sourcefilter(int, in_addr, in_addr, uint*, uint*, in_addr*);
@@ -357,7 +357,7 @@ static if (_DARWIN_C_SOURCE)
         uint     ipi_ifindex;
         in_addr  ipi_spec_dst;
         in_addr  ipi_addr;
-    };
+    }
 
     enum IPPROTO_MAXID = IPPROTO_AH + 1;
 
@@ -524,13 +524,13 @@ static if (_DARWIN_C_SOURCE)
     {
         in6_addr ipi6_addr;
         uint     ipi6_ifindex;
-    };
+    }
 
     struct ip6_mtuinfo
     {
         sockaddr_in6 ip6m_addr;
         uint         ip6m_mtu;
-    };
+    }
 
     enum IPV6_PORTRANGE_DEFAULT = 0;
     enum IPV6_PORTRANGE_HIGH    = 1;
diff --git a/libphobos/libdruntime/core/sys/darwin/pthread.d b/libphobos/libdruntime/core/sys/darwin/pthread.d
index 786d9f2833d..456cde96cbd 100644
--- a/libphobos/libdruntime/core/sys/darwin/pthread.d
+++ b/libphobos/libdruntime/core/sys/darwin/pthread.d
@@ -43,18 +43,18 @@ int pthread_rwlock_held_np(pthread_rwlock_t*);
 int pthread_rwlock_rdheld_np(pthread_rwlock_t*);
 int pthread_rwlock_wrheld_np(pthread_rwlock_t*);
 int pthread_getname_np(pthread_t, char*, size_t);
-int pthread_setname_np(in char*);
+int pthread_setname_np(const scope char*);
 // ^ __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2)
 int pthread_main_np();
 mach_port_t pthread_mach_thread_np(pthread_t);
 size_t pthread_get_stacksize_np(pthread_t);
 void* pthread_get_stackaddr_np(pthread_t);
 int pthread_cond_signal_thread_np(pthread_cond_t*, pthread_t);
-int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, in timespec*);
-int pthread_create_suspended_np(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
+int pthread_cond_timedwait_relative_np(pthread_cond_t*, pthread_mutex_t*, const scope timespec*);
+int pthread_create_suspended_np(pthread_t*, const scope pthread_attr_t*, void* function(void*), void*);
 int pthread_kill(pthread_t, int);
 pthread_t pthread_from_mach_thread_np(mach_port_t);
 // ^ __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0)
-int pthread_sigmask(int, in sigset_t*, sigset_t*);
+int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 // ^ __DARWIN_ALIAS(pthread_sigmask)
 void pthread_yield_np();
diff --git a/libphobos/libdruntime/core/sys/darwin/sys/attr.d b/libphobos/libdruntime/core/sys/darwin/sys/attr.d
new file mode 100644
index 00000000000..cb22b380ef6
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/darwin/sys/attr.d
@@ -0,0 +1,338 @@
+/**
+ * D header file for Darwin
+ *
+ * $(LINK2 https://opensource.apple.com/source/xnu/xnu-2422.115.4/bsd/sys/attr.h.auto.html, Apple sys/attr.h)
+ */
+module core.sys.darwin.sys.attr;
+
+version (OSX)
+    version = Darwin;
+else version (iOS)
+    version = Darwin;
+else version (TVOS)
+    version = Darwin;
+else version (WatchOS)
+    version = Darwin;
+
+version (Darwin):
+extern (C):
+nothrow:
+@nogc:
+
+import core.internal.attributes : betterC;
+import core.sys.darwin.sys.cdefs : c_ulong;
+import core.sys.posix.sys.time : timeval;
+
+// These functions aren't actually declared in attr.h but in unistd.h.
+@system
+{
+    void getattrlist(scope const char* path, scope attrlist* attrList, scope void* attrBuf,
+        size_t attrBufSize, c_ulong options);
+
+    void setattrlist(scope const char* path, scope attrlist* attrList, scope void* attrBuf,
+        size_t attrBufSize, c_ulong options);
+
+    version (TVOS) {}
+    else version (WatchOS) {}
+    else
+        int searchfs(scope const char* path, scope fssearchblock* searchBlock,
+            scope c_ulong* numMatches, uint scriptCode, uint options, scope searchstate* state);
+}
+
+enum
+{
+    FSOPT_NOFOLLOW                     = 0x00000001,
+    FSOPT_NOINMEMUPDATE                = 0x00000002,
+    FSOPT_REPORT_FULLSIZE              = 0x00000004,
+    FSOPT_PACK_INVAL_ATTRS             = 0x00000008,
+    FSOPT_ATTR_CMN_EXTENDED            = 0x00000020, // macOS 10.10
+}
+
+enum SEARCHFS_MAX_SEARCHPARMS = 4096;
+
+alias uint text_encoding_t, fsobj_type_t, fsobj_tag_t, fsfile_type_t, fsvolid_t, attrgroup_t;
+
+struct attrlist
+{
+    ushort bitmapcount, reserved;
+    attrgroup_t commonattr, volattr, dirattr, fileattr, forkattr;
+}
+enum ATTR_BIT_MAP_COUNT = 5;
+
+struct attribute_set_t
+{
+    attrgroup_t commonattr, volattr, dirattr, fileattr, forkattr;
+}
+
+struct attrreference_t
+{
+    int     attr_dataoffset;
+    uint    attr_length;
+}
+
+struct diskextent
+{
+    uint startblock, blockcount;
+}
+
+alias extentrecord = diskextent[8];
+
+alias vol_capabilities_set_t = uint[4];
+
+enum
+{
+    VOL_CAPABILITIES_FORMAT            = 0,
+    VOL_CAPABILITIES_INTERFACES        = 1,
+    VOL_CAPABILITIES_RESERVED1         = 2,
+    VOL_CAPABILITIES_RESERVED2         = 3,
+}
+
+struct vol_capabilities_attr_t
+{
+    vol_capabilities_set_t capabilities, valid;
+}
+
+enum ATTR_MAX_BUFFER = 8192;
+
+enum
+{
+    VOL_CAP_FMT_PERSISTENTOBJECTIDS    = 0x00000001,
+    VOL_CAP_FMT_SYMBOLICLINKS          = 0x00000002,
+    VOL_CAP_FMT_HARDLINKS              = 0x00000004,
+    VOL_CAP_FMT_JOURNAL                = 0x00000008,
+    VOL_CAP_FMT_JOURNAL_ACTIVE         = 0x00000010,
+    VOL_CAP_FMT_NO_ROOT_TIMES          = 0x00000020,
+    VOL_CAP_FMT_SPARSE_FILES           = 0x00000040,
+    VOL_CAP_FMT_ZERO_RUNS              = 0x00000080,
+    VOL_CAP_FMT_CASE_SENSITIVE         = 0x00000100,
+    VOL_CAP_FMT_CASE_PRESERVING        = 0x00000200,
+    VOL_CAP_FMT_FAST_STATFS            = 0x00000400,
+    VOL_CAP_FMT_2TB_FILESIZE           = 0x00000800,
+    VOL_CAP_FMT_OPENDENYMODES          = 0x00001000,
+    VOL_CAP_FMT_HIDDEN_FILES           = 0x00002000,
+    VOL_CAP_FMT_PATH_FROM_ID           = 0x00004000,
+    VOL_CAP_FMT_NO_VOLUME_SIZES        = 0x00008000,
+    VOL_CAP_FMT_DECMPFS_COMPRESSION    = 0x00010000,
+    VOL_CAP_FMT_64BIT_OBJECT_IDS       = 0x00020000,
+    VOL_CAP_FMT_DIR_HARDLINKS          = 0x00040000, // macOS 10.12
+    VOL_CAP_FMT_DOCUMENT_ID            = 0x00080000, // macOS 10.12
+    VOL_CAP_FMT_WRITE_GENERATION_COUNT = 0x00100000, // macOS 10.12
+    VOL_CAP_FMT_NO_IMMUTABLE_FILES     = 0x00200000, // macOS 10.12.4
+    VOL_CAP_FMT_NO_PERMISSIONS         = 0x00400000, // macOS 10.12.4
+    VOL_CAP_FMT_SHARED_SPACE           = 0x00800000, // macOS 10.15
+    VOL_CAP_FMT_VOL_GROUPS             = 0x01000000, // macOS 10.15
+}
+
+enum
+{
+    VOL_CAP_INT_SEARCHFS               = 0x00000001,
+    VOL_CAP_INT_ATTRLIST               = 0x00000002,
+    VOL_CAP_INT_NFSEXPORT              = 0x00000004,
+    VOL_CAP_INT_READDIRATTR            = 0x00000008,
+    VOL_CAP_INT_EXCHANGEDATA           = 0x00000010,
+    VOL_CAP_INT_COPYFILE               = 0x00000020,
+    VOL_CAP_INT_ALLOCATE               = 0x00000040,
+    VOL_CAP_INT_VOL_RENAME             = 0x00000080,
+    VOL_CAP_INT_ADVLOCK                = 0x00000100,
+    VOL_CAP_INT_FLOCK                  = 0x00000200,
+    VOL_CAP_INT_EXTENDED_SECURITY      = 0x00000400,
+    VOL_CAP_INT_USERACCESS             = 0x00000800,
+    VOL_CAP_INT_MANLOCK                = 0x00001000,
+    VOL_CAP_INT_NAMEDSTREAMS           = 0x00002000,
+    VOL_CAP_INT_EXTENDED_ATTR          = 0x00004000,
+    VOL_CAP_INT_CLONE                  = 0x00010000, // macOS 10.12
+    VOL_CAP_INT_SNAPSHOT               = 0x00020000, // macOS 10.12
+    VOL_CAP_INT_RENAME_SWAP            = 0x00040000, // macOS 10.12
+    VOL_CAP_INT_RENAME_EXCL            = 0x00080000, // macOS 10.12
+    VOL_CAP_INT_RENAME_OPENFAIL        = 0x00100000, // macOS 10.15
+}
+
+struct vol_attributes_attr_t
+{
+    attribute_set_t validattr, nativeattr;
+}
+
+enum
+{
+    ATTR_CMN_NAME                      = 0x00000001,
+    ATTR_CMN_DEVID                     = 0x00000002,
+    ATTR_CMN_FSID                      = 0x00000004,
+    ATTR_CMN_OBJTYPE                   = 0x00000008,
+    ATTR_CMN_OBJTAG                    = 0x00000010,
+    ATTR_CMN_OBJID                     = 0x00000020,
+    ATTR_CMN_OBJPERMANENTID            = 0x00000040,
+    ATTR_CMN_PAROBJID                  = 0x00000080,
+    ATTR_CMN_SCRIPT                    = 0x00000100,
+    ATTR_CMN_CRTIME                    = 0x00000200,
+    ATTR_CMN_MODTIME                   = 0x00000400,
+    ATTR_CMN_CHGTIME                   = 0x00000800,
+    ATTR_CMN_ACCTIME                   = 0x00001000,
+    ATTR_CMN_BKUPTIME                  = 0x00002000,
+    ATTR_CMN_FNDRINFO                  = 0x00004000,
+    ATTR_CMN_OWNERID                   = 0x00008000,
+    ATTR_CMN_GRPID                     = 0x00010000,
+    ATTR_CMN_ACCESSMASK                = 0x00020000,
+    ATTR_CMN_FLAGS                     = 0x00040000,
+
+    ATTR_CMN_GEN_COUNT                 = 0x00080000,
+    ATTR_CMN_DOCUMENT_ID               = 0x00100000,
+
+    ATTR_CMN_USERACCESS                = 0x00200000,
+    ATTR_CMN_EXTENDED_SECURITY         = 0x00400000,
+    ATTR_CMN_UUID                      = 0x00800000,
+    ATTR_CMN_GRPUUID                   = 0x01000000,
+    ATTR_CMN_FILEID                    = 0x02000000,
+    ATTR_CMN_PARENTID                  = 0x04000000,
+    ATTR_CMN_FULLPATH                  = 0x08000000,
+    ATTR_CMN_ADDEDTIME                 = 0x10000000,
+    ATTR_CMN_ERROR                     = 0x20000000, // macOS 10.10
+    ATTR_CMN_DATA_PROTECT_FLAGS        = 0x40000000, // macOS 10.10
+}
+
+enum ATTR_CMN_RETURNED_ATTRS           = 0x80000000;
+enum ATTR_CMN_VALIDMASK                = 0xFFFFFFFF;
+enum ATTR_CMN_SETMASK                  = 0x51C7FF00;
+enum ATTR_CMN_VOLSETMASK               = 0x00006700;
+
+enum
+{
+    ATTR_VOL_FSTYPE                    = 0x00000001,
+    ATTR_VOL_SIGNATURE                 = 0x00000002,
+    ATTR_VOL_SIZE                      = 0x00000004,
+    ATTR_VOL_SPACEFREE                 = 0x00000008,
+    ATTR_VOL_SPACEAVAIL                = 0x00000010,
+    ATTR_VOL_MINALLOCATION             = 0x00000020,
+    ATTR_VOL_ALLOCATIONCLUMP           = 0x00000040,
+    ATTR_VOL_IOBLOCKSIZE               = 0x00000080,
+    ATTR_VOL_OBJCOUNT                  = 0x00000100,
+    ATTR_VOL_FILECOUNT                 = 0x00000200,
+    ATTR_VOL_DIRCOUNT                  = 0x00000400,
+    ATTR_VOL_MAXOBJCOUNT               = 0x00000800,
+    ATTR_VOL_MOUNTPOINT                = 0x00001000,
+    ATTR_VOL_NAME                      = 0x00002000,
+    ATTR_VOL_MOUNTFLAGS                = 0x00004000,
+    ATTR_VOL_MOUNTEDDEVICE             = 0x00008000,
+    ATTR_VOL_ENCODINGSUSED             = 0x00010000,
+    ATTR_VOL_CAPABILITIES              = 0x00020000,
+    ATTR_VOL_UUID                      = 0x00040000,
+    ATTR_VOL_QUOTA_SIZE                = 0x10000000, // macOS 10.12.4
+    ATTR_VOL_RESERVED_SIZE             = 0x20000000, // macOS 10.12.4
+    ATTR_VOL_ATTRIBUTES                = 0x40000000,
+    ATTR_VOL_INFO                      = 0x80000000,
+}
+
+enum ATTR_VOL_VALIDMASK                = 0xF007FFFF;
+enum ATTR_VOL_SETMASK                  = 0x80002000;
+
+enum
+{
+    ATTR_DIR_LINKCOUNT                 = 0x00000001,
+    ATTR_DIR_ENTRYCOUNT                = 0x00000002,
+    ATTR_DIR_MOUNTSTATUS               = 0x00000004,
+    ATTR_DIR_ALLOCSIZE                 = 0x00000008, // macOS 10.12.4
+    ATTR_DIR_IOBLOCKSIZE               = 0x00000010, // macOS 10.12.4
+    ATTR_DIR_DATALENGTH                = 0x00000020, // macOS 10.12.4
+}
+
+enum
+{
+    DIR_MNTSTATUS_MNTPOINT             = 0x00000001,
+    DIR_MNTSTATUS_TRIGGER              = 0x00000002,
+}
+
+enum ATTR_DIR_VALIDMASK                = 0x0000003f;
+enum ATTR_DIR_SETMASK                  = 0x00000000;
+
+enum
+{
+    ATTR_FILE_LINKCOUNT                = 0x00000001,
+    ATTR_FILE_TOTALSIZE                = 0x00000002,
+    ATTR_FILE_ALLOCSIZE                = 0x00000004,
+    ATTR_FILE_IOBLOCKSIZE              = 0x00000008,
+    ATTR_FILE_DEVTYPE                  = 0x00000020,
+    ATTR_FILE_FORKCOUNT                = 0x00000080,
+    ATTR_FILE_FORKLIST                 = 0x00000100,
+    ATTR_FILE_DATALENGTH               = 0x00000200,
+    ATTR_FILE_DATAALLOCSIZE            = 0x00000400,
+    ATTR_FILE_RSRCLENGTH               = 0x00001000,
+    ATTR_FILE_RSRCALLOCSIZE            = 0x00002000,
+}
+
+enum ATTR_FILE_VALIDMASK               = 0x000037FF;
+enum ATTR_FILE_SETMASK                 = 0x00000020;
+
+enum
+{
+    ATTR_CMNEXT_RELPATH                = 0x00000004, // macOS 10.12.4
+    ATTR_CMNEXT_PRIVATESIZE            = 0x00000008, // macOS 10.12.4
+    ATTR_CMNEXT_NOFIRMLINKPATH         = 0x00000020, // macOS 10.15
+    ATTR_CMNEXT_REALDEVID              = 0x00000040, // macOS 10.15
+    ATTR_CMNEXT_REALFSID               = 0x00000080, // macOS 10.15
+}
+
+enum ATTR_CMNEXT_VALIDMASK             = 0x000000fc;
+enum ATTR_CMNEXT_SETMASK               = 0x00000000;
+
+enum ATTR_BULK_REQUIRED = ATTR_CMN_NAME | ATTR_CMN_RETURNED_ATTRS;
+
+enum
+{
+    SRCHFS_START                       = 0x00000001,
+    SRCHFS_MATCHPARTIALNAMES           = 0x00000002,
+    SRCHFS_MATCHDIRS                   = 0x00000004,
+    SRCHFS_MATCHFILES                  = 0x00000008,
+    SRCHFS_SKIPLINKS                   = 0x00000010,
+    SRCHFS_SKIPINVISIBLE               = 0x00000020,
+    SRCHFS_SKIPPACKAGES                = 0x00000040,
+    SRCHFS_SKIPINAPPROPRIATE           = 0x00000080,
+
+    SRCHFS_NEGATEPARAMS                = 0x80000000,
+    SRCHFS_VALIDOPTIONSMASK            = 0x800000FF,
+}
+
+struct fssearchblock
+{
+    attrlist*        returnattrs;
+    void*            returnbuffer;
+    size_t           returnbuffersize;
+    c_ulong          maxmatches;
+    timeval          timelimit;
+    void*            searchparams1;
+    size_t           sizeofsearchparams1;
+    void*            searchparams2;
+    size_t           sizeofsearchparams2;
+    attrlist         searchattrs;
+}
+
+struct searchstate
+{
+    uint                        ss_union_flags;
+    uint                        ss_union_layer;
+    ubyte[548]                  ss_fsstate;
+}
+static assert(searchstate.sizeof == uint.sizeof * 2 + searchstate.ss_fsstate.sizeof,
+    "searchstate struct must be packed");
+
+enum FST_EOF = -1;
+
+@betterC @nogc nothrow pure @safe unittest
+{
+    // Use an enum instead of `version (Darwin)` so it works with the betterc test extractor.
+    version (OSX) enum isDarwin = true;
+    else version (iOS) enum isDarwin = true;
+    else version (TVOS) enum isDarwin = true;
+    else version (WatchOS) enum isDarwin = true;
+    else enum isDarwin = false;
+    static if (isDarwin)
+    {
+        // Verify that these types don't need __initZ and so can be used in betterC.
+        attrlist al;
+        attribute_set_t as;
+        attrreference_t ar;
+        diskextent de;
+        vol_capabilities_attr_t vca;
+        vol_attributes_attr_t vaa;
+        fssearchblock fsb;
+        searchstate ss;
+    }
+}
diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/dlfcn.d b/libphobos/libdruntime/core/sys/dragonflybsd/dlfcn.d
index 3ffa1b93da0..1d3812fc55b 100644
--- a/libphobos/libdruntime/core/sys/dragonflybsd/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/dragonflybsd/dlfcn.d
@@ -50,7 +50,7 @@ struct Dl_info {
     void            *dli_fbase;     /* Base address of shared object. */
     const(char)     *dli_sname;     /* Name of nearest symbol. */
     void            *dli_saddr;     /* Address of nearest symbol. */
-};
+}
 
 
 /*
@@ -59,13 +59,13 @@ struct Dl_info {
 struct Dl_serpath {
     char *          dls_name;       /* single search path entry */
     uint            dls_flags;      /* path information */
-};
+}
 
 struct Dl_serinfo {
     size_t          dls_size;       /* total buffer size */
     uint            dls_cnt;        /* number of path entries */
     Dl_serpath[1]   dls_serpath;    /* there may be more than one */
-};
+}
 
 /*-
  * The actual type declared by this typedef is immaterial, provided that
@@ -78,7 +78,7 @@ struct Dl_serinfo {
  */
 struct __dlfunc_arg {
     int     __dlfunc_dummy;
-};
+}
 
 alias dlfunc_t = void function(__dlfunc_arg);
 
diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/err.d b/libphobos/libdruntime/core/sys/dragonflybsd/err.d
new file mode 100644
index 00000000000..c3693f85f5e
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/dragonflybsd/err.d
@@ -0,0 +1,31 @@
+/**
+  * D header file for DragonFlyBSD err.h.
+  *
+  * Copyright: Copyright © 2019, The D Language Foundation
+  * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+  * Authors: Ernesto Castellotti
+  */
+module core.sys.dragonflybsd.err;
+import core.stdc.stdarg : va_list;
+
+version (DragonFlyBSD):
+extern (C):
+nothrow:
+@nogc:
+
+alias ExitFunction = void function(int);
+
+void err(int eval, scope const char* fmt, ...);
+void errc(int eval, int code, scope const char* fmt, ...);
+void errx(int eval, scope const char* fmt, ...);
+void warn(scope const char* fmt, ...);
+void warnc(int code, scope const char* fmt, ...);
+void warnx(scope const char* fmt, ...);
+void verr(int eval, scope const char* fmt, va_list args);
+void verrc(int eval, int code, scope const char* fmt, va_list args);
+void verrx(int eval, scope const char* fmt, va_list args);
+void vwarn(scope const char* fmt, va_list args);
+void vwarnc(int code, scope const char* fmt, va_list args);
+void vwarnx(scope const char* fmt, va_list args);
+void err_set_file(void* vfp);
+void err_set_exit(ExitFunction exitf);
diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/netinet/in_.d b/libphobos/libdruntime/core/sys/dragonflybsd/netinet/in_.d
index c771dc13dba..b0528167c27 100644
--- a/libphobos/libdruntime/core/sys/dragonflybsd/netinet/in_.d
+++ b/libphobos/libdruntime/core/sys/dragonflybsd/netinet/in_.d
@@ -264,34 +264,34 @@ struct ip_mreq
 {
     in_addr imr_multiaddr;
     in_addr imr_interface;
-};
+}
 
 struct ip_mreqn
 {
     in_addr imr_multiaddr;
     in_addr imr_address;
     int     imr_ifindex;
-};
+}
 
 struct ip_mreq_source
 {
     in_addr imr_multiaddr;
     in_addr imr_sourceaddr;
     in_addr imr_interface;
-};
+}
 
 struct group_req
 {
     uint gr_interface;
     sockaddr_storage gr_group;
-};
+}
 
 struct group_source_req
 {
     uint gsr_interface;
     sockaddr_storage gsr_group;
     sockaddr_storage gsr_source;
-};
+}
 
 int setipv4sourcefilter(int, in_addr, in_addr, uint, uint, in_addr*);
 int getipv4sourcefilter(int, in_addr, in_addr, uint*, uint*, in_addr*);
@@ -450,13 +450,13 @@ struct in6_pktinfo
 {
     in6_addr ipi6_addr;
     uint     ipi6_ifindex;
-};
+}
 
 struct ip6_mtuinfo
 {
     sockaddr_in6 ip6m_addr;
     uint         ip6m_mtu;
-};
+}
 
 enum IPV6_PORTRANGE_DEFAULT = 0;
 enum IPV6_PORTRANGE_HIGH    = 1;
diff --git a/libphobos/libdruntime/core/sys/dragonflybsd/sys/link_elf.d b/libphobos/libdruntime/core/sys/dragonflybsd/sys/link_elf.d
index 88f7e06fb65..5dad964057c 100644
--- a/libphobos/libdruntime/core/sys/dragonflybsd/sys/link_elf.d
+++ b/libphobos/libdruntime/core/sys/dragonflybsd/sys/link_elf.d
@@ -58,7 +58,7 @@ struct r_debug
     int             r_version;
     link_map*       r_map;
     void function(r_debug*, link_map*) r_brk;
-};
+}
 
 struct dl_phdr_info
 {
@@ -70,7 +70,7 @@ struct dl_phdr_info
     uint64_t        dlpi_subs;
     size_t          dlpi_tls_modid;
     void*           dlpi_tls_data;
-};
+}
 
 
 private alias int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
diff --git a/libphobos/libdruntime/core/sys/freebsd/dlfcn.d b/libphobos/libdruntime/core/sys/freebsd/dlfcn.d
index 95b6c1dfbae..fad91418e6d 100644
--- a/libphobos/libdruntime/core/sys/freebsd/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/freebsd/dlfcn.d
@@ -54,7 +54,7 @@ static if (__BSD_VISIBLE)
         void            *dli_fbase;     /* Base address of shared object. */
         const(char)     *dli_sname;     /* Name of nearest symbol. */
         void            *dli_saddr;     /* Address of nearest symbol. */
-    };
+    }
 
     /*-
      * The actual type declared by this typedef is immaterial, provided that
@@ -67,7 +67,7 @@ static if (__BSD_VISIBLE)
      */
     struct __dlfunc_arg {
         int     __dlfunc_dummy;
-    };
+    }
 
     alias dlfunc_t = void function(__dlfunc_arg);
 
@@ -77,13 +77,13 @@ static if (__BSD_VISIBLE)
     struct Dl_serpath {
         char *          dls_name;       /* single search path entry */
         uint            dls_flags;      /* path information */
-    };
+    }
 
     struct Dl_serinfo {
         size_t          dls_size;       /* total buffer size */
         uint            dls_cnt;        /* number of path entries */
         Dl_serpath[1]   dls_serpath;    /* there may be more than one */
-    };
+    }
 }
 
 /* XSI functions first. */
diff --git a/libphobos/libdruntime/core/sys/freebsd/err.d b/libphobos/libdruntime/core/sys/freebsd/err.d
new file mode 100644
index 00000000000..8937e0ec705
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/freebsd/err.d
@@ -0,0 +1,31 @@
+/**
+  * D header file for FreeBSD err.h.
+  *
+  * Copyright: Copyright © 2019, The D Language Foundation
+  * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+  * Authors: Ernesto Castellotti
+  */
+module core.sys.freebsd.err;
+import core.stdc.stdarg : va_list;
+
+version (FreeBSD):
+extern (C):
+nothrow:
+@nogc:
+
+alias ExitFunction = void function(int);
+
+void err(int eval, scope const char* fmt, ...);
+void errc(int eval, int code, scope const char* fmt, ...);
+void errx(int eval, scope const char* fmt, ...);
+void warn(scope const char* fmt, ...);
+void warnc(int code, scope const char* fmt, ...);
+void warnx(scope const char* fmt, ...);
+void verr(int eval, scope const char* fmt, va_list args);
+void verrc(int eval, int code, scope const char* fmt, va_list args);
+void verrx(int eval, scope const char* fmt, va_list args);
+void vwarn(scope const char* fmt, va_list args);
+void vwarnc(int code, scope const char* fmt, va_list args);
+void vwarnx(scope const char* fmt, va_list args);
+void err_set_file(void* vfp);
+void err_set_exit(ExitFunction exitf);
diff --git a/libphobos/libdruntime/core/sys/freebsd/execinfo.d b/libphobos/libdruntime/core/sys/freebsd/execinfo.d
index 125ef097d27..d32408458d3 100644
--- a/libphobos/libdruntime/core/sys/freebsd/execinfo.d
+++ b/libphobos/libdruntime/core/sys/freebsd/execinfo.d
@@ -14,6 +14,8 @@ nothrow:
 
 version (GNU)
     version = BacktraceExternal;
+version (LDC)
+    version = BacktraceExternal;
 
 version (BacktraceExternal)
 {
diff --git a/libphobos/libdruntime/core/sys/freebsd/netinet/in_.d b/libphobos/libdruntime/core/sys/freebsd/netinet/in_.d
index af6a077ee8b..bce17919102 100644
--- a/libphobos/libdruntime/core/sys/freebsd/netinet/in_.d
+++ b/libphobos/libdruntime/core/sys/freebsd/netinet/in_.d
@@ -268,34 +268,34 @@ static if (__BSD_VISIBLE)
     {
         in_addr imr_multiaddr;
         in_addr imr_interface;
-    };
+    }
 
     struct ip_mreqn
     {
         in_addr imr_multiaddr;
         in_addr imr_address;
         int     imr_ifindex;
-    };
+    }
 
     struct ip_mreq_source
     {
         in_addr imr_multiaddr;
         in_addr imr_sourceaddr;
         in_addr imr_interface;
-    };
+    }
 
     struct group_req
     {
         uint gr_interface;
         sockaddr_storage gr_group;
-    };
+    }
 
     struct group_source_req
     {
         uint gsr_interface;
         sockaddr_storage gsr_group;
         sockaddr_storage gsr_source;
-    };
+    }
 
     int setipv4sourcefilter(int, in_addr, in_addr, uint, uint, in_addr*);
     int getipv4sourcefilter(int, in_addr, in_addr, uint*, uint*, in_addr*);
@@ -463,13 +463,13 @@ static if (__POSIX_VISIBLE)
     {
         in6_addr ipi6_addr;
         uint     ipi6_ifindex;
-    };
+    }
 
     struct ip6_mtuinfo
     {
         sockaddr_in6 ip6m_addr;
         uint         ip6m_mtu;
-    };
+    }
 
     enum IPV6_PORTRANGE_DEFAULT = 0;
     enum IPV6_PORTRANGE_HIGH    = 1;
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/event.d b/libphobos/libdruntime/core/sys/freebsd/sys/event.d
index 8ac7c3b4758..7f5786219b7 100644
--- a/libphobos/libdruntime/core/sys/freebsd/sys/event.d
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/event.d
@@ -161,6 +161,23 @@ enum
 }
 
 int kqueue();
-int kevent(int kq, const kevent_t *changelist, int nchanges,
-           kevent_t *eventlist, int nevents,
-           const timespec *timeout);
+
+version (GNU)
+{
+    int kevent(int kq, const kevent_t *changelist, int nchanges,
+               kevent_t *eventlist, int nevents,
+               const timespec *timeout);
+}
+else
+{
+    static if (__FreeBSD_version >= 1200000)
+        pragma(mangle, "kevent@@FBSD_1.5")
+        int kevent(int kq, const kevent_t *changelist, int nchanges,
+                   kevent_t *eventlist, int nevents,
+                   const timespec *timeout);
+    else
+        pragma(mangle, "kevent@FBSD_1.0")
+        int kevent(int kq, const kevent_t *changelist, int nchanges,
+                   kevent_t *eventlist, int nevents,
+                   const timespec *timeout);
+}
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/link_elf.d b/libphobos/libdruntime/core/sys/freebsd/sys/link_elf.d
index 97e7cfa7e18..d743d51a7b2 100644
--- a/libphobos/libdruntime/core/sys/freebsd/sys/link_elf.d
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/link_elf.d
@@ -56,7 +56,7 @@ struct r_debug
     int             r_version;
     link_map*       r_map;
     void function(r_debug*, link_map*) r_brk;
-};
+}
 
 struct dl_phdr_info
 {
@@ -68,7 +68,7 @@ struct dl_phdr_info
     uint64_t        dlpi_subs;
     size_t          dlpi_tls_modid;
     void*           dlpi_tls_data;
-};
+}
 
 
 private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
diff --git a/libphobos/libdruntime/core/sys/freebsd/sys/mount.d b/libphobos/libdruntime/core/sys/freebsd/sys/mount.d
index e45c4600661..1b0f0423001 100644
--- a/libphobos/libdruntime/core/sys/freebsd/sys/mount.d
+++ b/libphobos/libdruntime/core/sys/freebsd/sys/mount.d
@@ -298,17 +298,47 @@ enum uint VQ_FLAG2000 = 0x2000;
 enum uint VQ_FLAG4000 = 0x4000;
 enum uint VQ_FLAG8000 = 0x8000;
 
-int fhopen(const fhandle_t*, int);
-int fhstat(const fhandle_t*, stat_t*);
-int fhstatfs(const fhandle_t*, statfs_t*);
-int fstatfs(int, statfs_t*);
-int getfh(const char*, fhandle_t*);
-int getfsstat(statfs_t*, c_long, int);
-int getmntinfo(statfs_t**, int);
-int lgetfh(const char*, fhandle_t*);
-int mount(const char*, const char*, int, void*);
-//int nmount(iovec*, uint, int);
-int statfs(const char*, statfs_t*);
-int unmount(const char*, int);
-
-//int getvfsbyname(const char*, xvfsconf*);
+version (GNU)
+{
+    int fhopen(const fhandle_t*, int);
+    int fhstat(const fhandle_t*, stat_t*);
+    int fhstatfs(const fhandle_t*, statfs_t*);
+    int fstatfs(int, statfs_t*);
+    int getfh(const char*, fhandle_t*);
+    int getfsstat(statfs_t*, c_long, int);
+    int getmntinfo(statfs_t**, int);
+    int lgetfh(const char*, fhandle_t*);
+    int mount(const char*, const char*, int, void*);
+    //int nmount(iovec*, uint, int);
+    int statfs(const char*, statfs_t*);
+    int unmount(const char*, int);
+    //int getvfsbyname(const char*, xvfsconf*);
+}
+else
+{
+    static if (__FreeBSD_version >= 1200000)
+    {
+        pragma(mangle, "fhstat@FBSD_1.5")     int fhstat(const fhandle_t*, stat_t*);
+        pragma(mangle, "fhstatfs@FBSD_1.5")   int fhstatfs(const fhandle_t*, statfs_t*);
+        pragma(mangle, "fstatfs@FBSD_1.5")    int fstatfs(int, statfs_t*);
+        pragma(mangle, "getfsstat@FBSD_1.5")  int getfsstat(statfs_t*, c_long, int);
+        pragma(mangle, "getmntinfo@FBSD_1.5") int getmntinfo(statfs_t**, int);
+        pragma(mangle, "statfs@FBSD_1.5")     int statfs(const char*, statfs_t*);
+    }
+    else
+    {
+        pragma(mangle, "fhstat@FBSD_1.0")     int fhstat(const fhandle_t*, stat_t*);
+        pragma(mangle, "fhstatfs@FBSD_1.0")   int fhstatfs(const fhandle_t*, statfs_t*);
+        pragma(mangle, "fstatfs@FBSD_1.0")    int fstatfs(int, statfs_t*);
+        pragma(mangle, "getfsstat@FBSD_1.0")  int getfsstat(statfs_t*, c_long, int);
+        pragma(mangle, "getmntinfo@FBSD_1.0") int getmntinfo(statfs_t**, int);
+        pragma(mangle, "statfs@FBSD_1.0")     int statfs(const char*, statfs_t*);
+    }
+    pragma(mangle, "fhopen@@FBSD_1.0")        int fhopen(const fhandle_t*, int);
+    pragma(mangle, "getfh@@FBSD_1.0")         int getfh(const char*, fhandle_t*);
+    pragma(mangle, "lgetfh@@FBSD_1.0")        int lgetfh(const char*, fhandle_t*);
+    pragma(mangle, "mount@@FBSD_1.0")         int mount(const char*, const char*, int, void*);
+    //int nmount(iovec*, uint, int);
+    pragma(mangle, "unmount@@FBSD_1.0")       int unmount(const char*, int);
+    //int getvfsbyname(const char*, xvfsconf*);
+}
diff --git a/libphobos/libdruntime/core/sys/linux/dlfcn.d b/libphobos/libdruntime/core/sys/linux/dlfcn.d
index f2decc2b3ec..a815d0907fe 100644
--- a/libphobos/libdruntime/core/sys/linux/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/linux/dlfcn.d
@@ -9,6 +9,7 @@ version (linux):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 version (ARM)     version = ARM_Any;
 version (AArch64) version = ARM_Any;
@@ -236,14 +237,14 @@ static if (__USE_GNU)
     enum LM_ID_NEWLM = -1;
 }
 
-// void* dlopen(in char* __file, int __mode); // POSIX
+// void* dlopen(const scope char* __file, int __mode); // POSIX
 // int dlclose(void* __handle); // POSIX
-// void* dlsym(void* __handle, in char* __name); // POSIX
+// void* dlsym(void* __handle, const scope char* __name); // POSIX
 
 static if (__USE_GNU)
 {
-    void* dlmopen(Lmid_t __nsid, in char* __file, int __mode);
-    void* dlvsym(void* __handle, in char* __name, in char* __version);
+    void* dlmopen(Lmid_t __nsid, const scope char* __file, int __mode);
+    void* dlvsym(void* __handle, const scope char* __name, const scope char* __version);
 }
 
 // char* dlerror(); // POSIX
@@ -258,7 +259,7 @@ static if (__USE_GNU)
         void* dli_saddr;
     }
 
-    int dladdr(in void* __address, Dl_info* __info);
+    int dladdr(const scope void* __address, Dl_info* __info);
     int dladdr1(void* __address, Dl_info* __info, void** __extra_info, int __flags);
 
     enum
diff --git a/libphobos/libdruntime/core/sys/linux/elf.d b/libphobos/libdruntime/core/sys/linux/elf.d
index ab07ac94108..4d0b2273117 100644
--- a/libphobos/libdruntime/core/sys/linux/elf.d
+++ b/libphobos/libdruntime/core/sys/linux/elf.d
@@ -9,6 +9,7 @@ version (linux):
 extern (C):
 pure:
 nothrow:
+@system:
 
 import core.stdc.stdint;
 
@@ -831,7 +832,6 @@ enum AT_EXECFN =       31;
 enum AT_SYSINFO =      32;
 enum AT_SYSINFO_EHDR = 33;
 
-;
 enum AT_L1I_CACHESHAPE =       34;
 enum AT_L1D_CACHESHAPE =       35;
 enum AT_L2_CACHESHAPE =        36;
diff --git a/libphobos/libdruntime/core/sys/linux/epoll.d b/libphobos/libdruntime/core/sys/linux/epoll.d
index 4798967c79d..0c3aed98853 100644
--- a/libphobos/libdruntime/core/sys/linux/epoll.d
+++ b/libphobos/libdruntime/core/sys/linux/epoll.d
@@ -14,6 +14,7 @@ extern (C):
 @system:
 @nogc:
 nothrow:
+@system:
 
 version (ARM)     version = ARM_Any;
 version (AArch64) version = ARM_Any;
diff --git a/libphobos/libdruntime/core/sys/linux/err.d b/libphobos/libdruntime/core/sys/linux/err.d
new file mode 100644
index 00000000000..be5378d0618
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/linux/err.d
@@ -0,0 +1,24 @@
+/**
+  * D header file for Linux err.h.
+  *
+  * Copyright: Copyright © 2019, The D Language Foundation
+  * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+  * Authors: Ernesto Castellotti
+  */
+module core.sys.linux.err;
+import core.stdc.stdarg : va_list;
+
+version (linux):
+extern (C):
+nothrow:
+@nogc:
+@system:
+
+void err(int eval, scope const char* fmt, ...);
+void errx(int eval, scope const char* fmt, ...);
+void warn(scope const char* fmt, ...);
+void warnx(scope const char* fmt, ...);
+void verr(int eval, scope const char* fmt, va_list args);
+void verrx(int eval, scope const char* fmt, va_list args);
+void vwarn(scope const char* fmt, va_list args);
+void vwarnx(scope const char* fmt, va_list args);
diff --git a/libphobos/libdruntime/core/sys/linux/errno.d b/libphobos/libdruntime/core/sys/linux/errno.d
index bc93675c735..02ae151427e 100644
--- a/libphobos/libdruntime/core/sys/linux/errno.d
+++ b/libphobos/libdruntime/core/sys/linux/errno.d
@@ -8,6 +8,7 @@ module core.sys.linux.errno;
 version (linux):
 extern (C):
 nothrow:
+@system:
 
 public import core.stdc.errno;
 import core.sys.linux.config;
diff --git a/libphobos/libdruntime/core/sys/linux/execinfo.d b/libphobos/libdruntime/core/sys/linux/execinfo.d
index 3259443fe53..4169ca36c5b 100644
--- a/libphobos/libdruntime/core/sys/linux/execinfo.d
+++ b/libphobos/libdruntime/core/sys/linux/execinfo.d
@@ -10,6 +10,8 @@ module core.sys.linux.execinfo;
 version (linux):
 extern (C):
 nothrow:
+@system:
+@nogc:
 
 int backtrace(void** buffer, int size);
 char** backtrace_symbols(const(void*)* buffer, int size);
diff --git a/libphobos/libdruntime/core/sys/linux/fcntl.d b/libphobos/libdruntime/core/sys/linux/fcntl.d
index 974a5cc2a38..11c374530bf 100644
--- a/libphobos/libdruntime/core/sys/linux/fcntl.d
+++ b/libphobos/libdruntime/core/sys/linux/fcntl.d
@@ -5,6 +5,7 @@ public import core.sys.posix.fcntl;
 version (linux):
 extern(C):
 nothrow:
+@system:
 
 // From linux/falloc.h
 /// fallocate(2) params
diff --git a/libphobos/libdruntime/core/sys/linux/ifaddrs.d b/libphobos/libdruntime/core/sys/linux/ifaddrs.d
index d7b6d6de727..5490e97aa0f 100644
--- a/libphobos/libdruntime/core/sys/linux/ifaddrs.d
+++ b/libphobos/libdruntime/core/sys/linux/ifaddrs.d
@@ -22,6 +22,7 @@ version (linux):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 struct ifaddrs
 {
@@ -46,7 +47,7 @@ struct ifaddrs
 
     /// Address specific data
     void* ifa_data;
-};
+}
 
 /// Returns: linked list of ifaddrs structures describing interfaces
 int getifaddrs(ifaddrs** );
diff --git a/libphobos/libdruntime/core/sys/linux/link.d b/libphobos/libdruntime/core/sys/linux/link.d
index 4d7eb1eb7d3..b417ec8ec77 100644
--- a/libphobos/libdruntime/core/sys/linux/link.d
+++ b/libphobos/libdruntime/core/sys/linux/link.d
@@ -8,6 +8,7 @@ module core.sys.linux.link;
 version (linux):
 extern (C):
 nothrow:
+@system:
 
 version (ARM)     version = ARM_Any;
 version (AArch64) version = ARM_Any;
diff --git a/libphobos/libdruntime/core/sys/linux/netinet/in_.d b/libphobos/libdruntime/core/sys/linux/netinet/in_.d
index 47102e11eb8..67bf6545c8f 100644
--- a/libphobos/libdruntime/core/sys/linux/netinet/in_.d
+++ b/libphobos/libdruntime/core/sys/linux/netinet/in_.d
@@ -121,27 +121,27 @@ version (linux_libc)
         {
             in_addr imr_multiaddr;
             in_addr imr_interface;
-        };
+        }
 
         struct ip_mreq_source
         {
             in_addr imr_multiaddr;
             in_addr imr_interface;
             in_addr imr_sourceaddr;
-        };
+        }
 
         struct group_req
         {
             uint gr_interface;
             sockaddr_storage gr_group;
-        };
+        }
 
         struct group_source_req
         {
             uint gsr_interface;
             sockaddr_storage gsr_group;
             sockaddr_storage gsr_source;
-        };
+        }
 
         struct ip_msfilter
         {
@@ -150,7 +150,7 @@ version (linux_libc)
             uint imsf_fmode;
             uint imsf_numsrc;
             in_addr[1] imsf_slist;
-        };
+        }
 
         extern(D) size_t IP_MSFILTER_SIZE(int numsrc)
         {
@@ -164,7 +164,7 @@ version (linux_libc)
             uint gf_fmode;
             uint gf_numsrc;
             sockaddr_storage[1] gf_slist;
-        };
+        }
 
         extern(D) size_t GROUP_FILTER_SIZE(int numsrc) pure @safe
         {
@@ -186,13 +186,13 @@ version (linux_libc)
         {
             in6_addr ipi6_addr;
             uint ipi6_ifindex;
-        };
+        }
 
         struct ip6_mtuinfo
         {
             sockaddr_in6 ip6m_addr;
             uint ip6m_mtu;
-        };
+        }
 
         int inet6_opt_init(void* __extbuf, socklen_t __extlen);
         int inet6_opt_append(void* __extbuf, socklen_t __extlen, int __offset,
@@ -313,21 +313,21 @@ version (linux_libc)
         {
             in_addr ip_dst;
             char[40] ip_opts = 0;
-        };
+        }
 
         struct ip_mreqn
         {
             in_addr imr_multiaddr;
             in_addr imr_address;
             int imr_ifindex;
-        };
+        }
 
         struct in_pktinfo
         {
             int ipi_ifindex;
             in_addr ipi_spec_dst;
             in_addr ipi_addr;
-        };
+        }
     }
 
     enum IPV6_ADDRFORM       = 1;
diff --git a/libphobos/libdruntime/core/sys/linux/sched.d b/libphobos/libdruntime/core/sys/linux/sched.d
index 53cd0ef6822..dc815a0fc3c 100644
--- a/libphobos/libdruntime/core/sys/linux/sched.d
+++ b/libphobos/libdruntime/core/sys/linux/sched.d
@@ -17,6 +17,7 @@
 module core.sys.linux.sched;
 
 import core.bitop : popcnt;
+import core.stdc.stdlib : malloc, free;
 import core.sys.posix.sched;
 import core.sys.posix.config;
 import core.sys.posix.sys.types;
@@ -25,6 +26,7 @@ version (linux):
 extern (C):
 @nogc:
 nothrow:
+@system:
 
 
 private // helpers
@@ -49,6 +51,21 @@ private // helpers
         return 1UL << (cpu % __NCPUBITS);
     }
 
+    cpu_set_t* __CPU_ALLOC(size_t count)
+    {
+        return cast(cpu_set_t*) malloc(__CPU_ALLOC_SIZE(count));
+    }
+
+    size_t __CPU_ALLOC_SIZE(size_t count) pure
+    {
+        return ((count + __NCPUBITS - 1) / __NCPUBITS) * cpu_mask.sizeof;
+    }
+
+    void __CPU_FREE(cpu_set_t* set)
+    {
+        free(cast(void*) set);
+    }
+
     cpu_mask __CPU_SET_S(size_t cpu, size_t setsize, cpu_set_t* cpusetp) pure
     {
         if (cpu < 8 * setsize)
@@ -87,6 +104,21 @@ struct cpu_set_t
 
 /// Access macros for 'cpu_set' (missing a lot of them)
 
+cpu_set_t* CPU_ALLOC(size_t count)
+{
+    return __CPU_ALLOC(count);
+}
+
+size_t CPU_ALLOC_SIZE(size_t count) pure
+{
+    return __CPU_ALLOC_SIZE(count);
+}
+
+void CPU_FREE(cpu_set_t* set)
+{
+    __CPU_FREE(set);
+}
+
 cpu_mask CPU_SET(size_t cpu, cpu_set_t* cpusetp) pure
 {
      return __CPU_SET_S(cpu, cpu_set_t.sizeof, cpusetp);
@@ -102,6 +134,11 @@ int CPU_COUNT(cpu_set_t* cpusetp) pure
     return __CPU_COUNT_S(cpu_set_t.sizeof, cpusetp);
 }
 
+int CPU_COUNT_S(size_t setsize, cpu_set_t* cpusetp) pure
+{
+    return __CPU_COUNT_S(setsize, cpusetp);
+}
+
 /* Scheduler control functions */
 int sched_setaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
 int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
@@ -110,6 +147,12 @@ int sched_getaffinity(pid_t pid, size_t cpusetsize, cpu_set_t *mask);
 int clone(int function(void*), void* child_stack, int flags, void* arg, ...);
 int unshare(int flags) @trusted;
 
+version (CRuntime_Glibc)
+{
+    /* Determine CPU on which the calling thread is running */
+    int sched_getcpu();
+}
+
 enum CLONE_FILES = 0x400;
 enum CLONE_FS = 0x200;
 enum CLONE_NEWCGROUP = 0x2000000;
@@ -122,4 +165,5 @@ enum CLONE_NEWUTS = 0x4000000;
 enum CLONE_SIGHAND = 0x800;
 enum CLONE_SYSVSEM = 0x40000;
 enum CLONE_THREAD = 0x10000;
+enum CLONE_VFORK = 0x4000;
 enum CLONE_VM = 0x100;
diff --git a/libphobos/libdruntime/core/sys/linux/stdio.d b/libphobos/libdruntime/core/sys/linux/stdio.d
index 578b2152ce8..ab8971b482f 100644
--- a/libphobos/libdruntime/core/sys/linux/stdio.d
+++ b/libphobos/libdruntime/core/sys/linux/stdio.d
@@ -13,6 +13,8 @@ import core.sys.linux.config : __USE_FILE_OFFSET64;
 import core.stdc.stdio : FILE;
 import core.stdc.stddef : wchar_t;
 
+@system:
+
 extern(C) nothrow
 {
     alias ssize_t function(void *cookie, char *buf, size_t size) cookie_read_function_t;
diff --git a/libphobos/libdruntime/core/sys/linux/string.d b/libphobos/libdruntime/core/sys/linux/string.d
index a388c8ba1ae..1b2c8d86a4a 100644
--- a/libphobos/libdruntime/core/sys/linux/string.d
+++ b/libphobos/libdruntime/core/sys/linux/string.d
@@ -14,6 +14,7 @@ version (linux):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 static if (__USE_GNU)
 {
diff --git a/libphobos/libdruntime/core/sys/linux/sys/inotify.d b/libphobos/libdruntime/core/sys/linux/sys/inotify.d
index 67545a80cd6..e0acf33fa51 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/inotify.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/inotify.d
@@ -10,6 +10,7 @@ version (linux):
 extern (C):
 @system:
 nothrow:
+@nogc:
 
 version (ARM)     version = ARM_Any;
 version (AArch64) version = ARM_Any;
diff --git a/libphobos/libdruntime/core/sys/linux/sys/mman.d b/libphobos/libdruntime/core/sys/linux/sys/mman.d
index 212943bbb3a..20e8cf29f8d 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/mman.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/mman.d
@@ -8,6 +8,8 @@ module core.sys.linux.sys.mman;
 version (linux):
 extern (C):
 nothrow:
+@system:
+@nogc:
 
 version (ARM)     version = ARM_Any;
 version (AArch64) version = ARM_Any;
diff --git a/libphobos/libdruntime/core/sys/linux/sys/prctl.d b/libphobos/libdruntime/core/sys/linux/sys/prctl.d
index a5a4807f17a..a7322166a20 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/prctl.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/prctl.d
@@ -141,7 +141,7 @@ struct prctl_mm_map
     ulong*   auxv;
     uint     auxv_size;
     uint     exe_fd;
-};
+}
 
 int prctl(int option, size_t arg2, size_t arg3, size_t arg4, size_t arg5);
 
diff --git a/libphobos/libdruntime/core/sys/linux/sys/signalfd.d b/libphobos/libdruntime/core/sys/linux/sys/signalfd.d
index 5d4cb674955..736b1456169 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/signalfd.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/signalfd.d
@@ -14,6 +14,7 @@ version (linux):
 extern (C):
 @system:
 nothrow:
+@nogc:
 
 struct signalfd_siginfo
 {
diff --git a/libphobos/libdruntime/core/sys/linux/sys/sysinfo.d b/libphobos/libdruntime/core/sys/linux/sys/sysinfo.d
index 699cd3e67c4..0c9ed592c3b 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/sysinfo.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/sysinfo.d
@@ -7,6 +7,7 @@
 module core.sys.linux.sys.sysinfo;
 
 version (linux) extern(C) @nogc nothrow:
+@system:
 
 import core.sys.linux.config;
 
diff --git a/libphobos/libdruntime/core/sys/linux/sys/time.d b/libphobos/libdruntime/core/sys/linux/sys/time.d
index 4b55f708657..6ea626ed390 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/time.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/time.d
@@ -13,7 +13,7 @@
  */
 module core.sys.linux.sys.time;
 
-private import core.sys.linux.config;
+import core.sys.linux.config;
 public import core.sys.posix.sys.time;  // timeval
 
 version (linux):
diff --git a/libphobos/libdruntime/core/sys/linux/sys/xattr.d b/libphobos/libdruntime/core/sys/linux/sys/xattr.d
index a14c6c6174b..2f8d3f376f9 100644
--- a/libphobos/libdruntime/core/sys/linux/sys/xattr.d
+++ b/libphobos/libdruntime/core/sys/linux/sys/xattr.d
@@ -13,6 +13,7 @@ version (linux):
 extern (C):
 @system:
 nothrow:
+@nogc:
 
 enum {
     XATTR_CREATE = 1, /* set value, fail if attr already exists.  */
@@ -52,17 +53,17 @@ enum XATTR_CAPS_SUFFIX = "capability";
 enum XATTR_NAME_CAPS = XATTR_SECURITY_PREFIX ~ XATTR_CAPS_SUFFIX;
 
 
-int setxattr(in char* path, in char* name, in void* value, size_t size, int flags);
+int setxattr(const scope char* path, const scope char* name, const scope void* value, size_t size, int flags);
 
-int lsetxattr(in char* path, in char* name, in void* value, size_t size, int flags);
-int fsetxattr(int fd, in char* name, in void* value, size_t size, int flags);
-ssize_t getxattr(in char* path, in char* name, void* value, size_t size);
-ssize_t lgetxattr(in char* path, in char* name, void* value, size_t size);
-ssize_t fgetxattr(int fd, in char* name, void* value, size_t size);
-ssize_t listxattr(in char* path, char* list, size_t size);
-ssize_t llistxattr(in char* path, char* list, size_t size);
+int lsetxattr(const scope char* path, const scope char* name, const scope void* value, size_t size, int flags);
+int fsetxattr(int fd, const scope char* name, const scope void* value, size_t size, int flags);
+ssize_t getxattr(const scope char* path, const scope char* name, void* value, size_t size);
+ssize_t lgetxattr(const scope char* path, const scope char* name, void* value, size_t size);
+ssize_t fgetxattr(int fd, const scope char* name, void* value, size_t size);
+ssize_t listxattr(const scope char* path, char* list, size_t size);
+ssize_t llistxattr(const scope char* path, char* list, size_t size);
 ssize_t flistxattr (int __fd, char *list, size_t size);
-int removexattr (in char *path, in char *name);
-int lremovexattr (in char *path, in char *name);
-int fremovexattr (int fd, in char *name);
+int removexattr (const scope char *path, const scope char *name);
+int lremovexattr (const scope char *path, const scope char *name);
+int fremovexattr (int fd, const scope char *name);
 
diff --git a/libphobos/libdruntime/core/sys/linux/tipc.d b/libphobos/libdruntime/core/sys/linux/tipc.d
index 161a313d079..3246e62ec04 100644
--- a/libphobos/libdruntime/core/sys/linux/tipc.d
+++ b/libphobos/libdruntime/core/sys/linux/tipc.d
@@ -10,6 +10,7 @@ module core.sys.linux.tipc;
 
 version (linux):
 extern (C) nothrow @nogc:
+@system:
 
 struct tipc_portid
 {
diff --git a/libphobos/libdruntime/core/sys/linux/unistd.d b/libphobos/libdruntime/core/sys/linux/unistd.d
index 21fd96208e8..48457467005 100644
--- a/libphobos/libdruntime/core/sys/linux/unistd.d
+++ b/libphobos/libdruntime/core/sys/linux/unistd.d
@@ -5,6 +5,7 @@ public import core.sys.posix.unistd;
 version (linux):
 extern(C):
 nothrow:
+@system:
 
 // Additional seek constants for sparse file handling
 // from Linux's unistd.h, stdio.h, and linux/fs.h
@@ -18,3 +19,6 @@ enum {
 
 /// Prompt for a password without echoing it.
 char* getpass(const(char)* prompt);
+
+// Exit all threads in a process
+void exit_group(int status);
diff --git a/libphobos/libdruntime/core/sys/netbsd/dlfcn.d b/libphobos/libdruntime/core/sys/netbsd/dlfcn.d
index 88eb94bf20e..dbbcc7638fd 100644
--- a/libphobos/libdruntime/core/sys/netbsd/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/netbsd/dlfcn.d
@@ -55,7 +55,7 @@ static if (__BSD_VISIBLE)
         void            *dli_fbase;     /* Base address of shared object. */
         const(char)     *dli_sname;     /* Name of nearest symbol. */
         void            *dli_saddr;     /* Address of nearest symbol. */
-    };
+    }
 
     /*-
      * The actual type declared by this typedef is immaterial, provided that
@@ -68,7 +68,7 @@ static if (__BSD_VISIBLE)
      */
     struct __dlfunc_arg {
         int     __dlfunc_dummy;
-    };
+    }
 
     alias dlfunc_t = void function(__dlfunc_arg);
 
@@ -78,13 +78,13 @@ static if (__BSD_VISIBLE)
     struct Dl_serpath {
         char *          dls_name;       /* single search path entry */
         uint            dls_flags;      /* path information */
-    };
+    }
 
     struct Dl_serinfo {
         size_t          dls_size;       /* total buffer size */
         uint            dls_cnt;        /* number of path entries */
         Dl_serpath[1]   dls_serpath;    /* there may be more than one */
-    };
+    }
 }
 
 private template __externC(RT, P...)
diff --git a/libphobos/libdruntime/core/sys/netbsd/err.d b/libphobos/libdruntime/core/sys/netbsd/err.d
new file mode 100644
index 00000000000..44eb66adc2f
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/netbsd/err.d
@@ -0,0 +1,27 @@
+/**
+  * D header file for NetBSD err.h.
+  *
+  * Copyright: Copyright © 2019, The D Language Foundation
+  * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+  * Authors: Ernesto Castellotti
+  */
+module core.sys.netbsd.err;
+import core.stdc.stdarg : va_list;
+
+version (NetBSD):
+extern (C):
+nothrow:
+@nogc:
+
+void err(int eval, scope const char* fmt, ...);
+void errc(int eval, int code, scope const char* fmt, ...);
+void errx(int eval, scope const char* fmt, ...);
+void warn(scope const char* fmt, ...);
+void warnc(int code, scope const char* fmt, ...);
+void warnx(scope const char* fmt, ...);
+void verr(int eval, scope const char* fmt, va_list args);
+void verrc(int eval, int code, scope const char* fmt, va_list args);
+void verrx(int eval, scope const char* fmt, va_list args);
+void vwarn(scope const char* fmt, va_list args);
+void vwarnc(int code, scope const char* fmt, va_list args);
+void vwarnx(scope const char* fmt, va_list args);
diff --git a/libphobos/libdruntime/core/sys/netbsd/sys/link_elf.d b/libphobos/libdruntime/core/sys/netbsd/sys/link_elf.d
index cc24a776629..4caec61adc8 100644
--- a/libphobos/libdruntime/core/sys/netbsd/sys/link_elf.d
+++ b/libphobos/libdruntime/core/sys/netbsd/sys/link_elf.d
@@ -50,7 +50,7 @@ struct r_debug
     int             r_version;
     link_map*       r_map;
     void function(r_debug*, link_map*) r_brk;
-};
+}
 
 struct dl_phdr_info
 {
@@ -62,7 +62,7 @@ struct dl_phdr_info
     uint64_t        dlpi_subs;
     size_t          dlpi_tls_modid;
     void*           dlpi_tls_data;
-};
+}
 
 
 private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
diff --git a/libphobos/libdruntime/core/sys/openbsd/err.d b/libphobos/libdruntime/core/sys/openbsd/err.d
new file mode 100644
index 00000000000..b4676140e38
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/openbsd/err.d
@@ -0,0 +1,27 @@
+/**
+  * D header file for OpenBSD err.h.
+  *
+  * Copyright: Copyright © 2019, The D Language Foundation
+  * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
+  * Authors: Ernesto Castellotti
+  */
+module core.sys.openbsd.err;
+import core.stdc.stdarg : va_list;
+
+version (OpenBSD):
+extern (C):
+nothrow:
+@nogc:
+
+void err(int eval, scope const char* fmt, ...);
+void errc(int eval, int code, scope const char* fmt, ...);
+void errx(int eval, scope const char* fmt, ...);
+void warn(scope const char* fmt, ...);
+void warnc(int code, scope const char* fmt, ...);
+void warnx(scope const char* fmt, ...);
+void verr(int eval, scope const char* fmt, va_list args);
+void verrc(int eval, int code, scope const char* fmt, va_list args);
+void verrx(int eval, scope const char* fmt, va_list args);
+void vwarn(scope const char* fmt, va_list args);
+void vwarnc(int code, scope const char* fmt, va_list args);
+void vwarnx(scope const char* fmt, va_list args);
diff --git a/libphobos/libdruntime/core/sys/openbsd/sys/link_elf.d b/libphobos/libdruntime/core/sys/openbsd/sys/link_elf.d
index 3582b4c08c5..f88671a3160 100644
--- a/libphobos/libdruntime/core/sys/openbsd/sys/link_elf.d
+++ b/libphobos/libdruntime/core/sys/openbsd/sys/link_elf.d
@@ -55,7 +55,7 @@ struct dl_phdr_info
     char*           dlpi_name;
     ElfW!"Phdr"*    dlpi_phdr;
     ElfW!"Half"     dlpi_phnum;
-};
+}
 
 
 private alias int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb;
diff --git a/libphobos/libdruntime/core/sys/posix/aio.d b/libphobos/libdruntime/core/sys/posix/aio.d
index 1165446be5c..f4e0f122d30 100644
--- a/libphobos/libdruntime/core/sys/posix/aio.d
+++ b/libphobos/libdruntime/core/sys/posix/aio.d
@@ -8,8 +8,8 @@
  */
 module core.sys.posix.aio;
 
-private import core.sys.posix.signal;
-private import core.sys.posix.sys.types;
+import core.sys.posix.signal;
+import core.sys.posix.sys.types;
 
 version (OSX)
     version = Darwin;
diff --git a/libphobos/libdruntime/core/sys/posix/arpa/inet.d b/libphobos/libdruntime/core/sys/posix/arpa/inet.d
index ac8e3eb1c76..6881142a0fb 100644
--- a/libphobos/libdruntime/core/sys/posix/arpa/inet.d
+++ b/libphobos/libdruntime/core/sys/posix/arpa/inet.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.arpa.inet;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.stdc.inttypes; // for uint32_t, uint16_t
 public import core.sys.posix.sys.socket; // for socklen_t
 
@@ -51,11 +51,11 @@ uint16_t htons(uint16_t);
 uint32_t ntohl(uint32_t);
 uint16_t ntohs(uint16_t);
 
-in_addr_t inet_addr(in char*);
+in_addr_t inet_addr(const scope char*);
 char*     inet_ntoa(in_addr);
 // per spec: const char* inet_ntop(int, const void*, char*, socklen_t);
-char*     inet_ntop(int, in void*, char*, socklen_t);
-int       inet_pton(int, in char*, void*);
+char*     inet_ntop(int, const scope void*, char*, socklen_t);
+int       inet_pton(int, const scope char*, void*);
 */
 
 version (CRuntime_Glibc)
@@ -78,10 +78,10 @@ version (CRuntime_Glibc)
     uint16_t ntohs(uint16_t);
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (Darwin)
 {
@@ -103,10 +103,10 @@ else version (Darwin)
     uint16_t ntohs(uint16_t);
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (FreeBSD)
 {
@@ -128,10 +128,10 @@ else version (FreeBSD)
     uint16_t ntohs(uint16_t);
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (NetBSD)
 {
@@ -153,10 +153,10 @@ else version (NetBSD)
     uint16_t ntohs(uint16_t);
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (OpenBSD)
 {
@@ -194,10 +194,10 @@ else version (OpenBSD)
         uint16_t ntohs(uint16_t x) { return __swap16(x); }
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (DragonFlyBSD)
 {
@@ -219,10 +219,10 @@ else version (DragonFlyBSD)
     uint16_t ntohs(uint16_t);
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (Solaris)
 {
@@ -243,10 +243,10 @@ else version (Solaris)
     uint16_t ntohs(uint16_t);
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (CRuntime_Bionic)
 {
@@ -283,10 +283,10 @@ else version (CRuntime_Bionic)
         uint16_t ntohs(uint16_t x) { return __swap16(x); }
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, size_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, size_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (CRuntime_Musl)
 {
@@ -308,10 +308,10 @@ else version (CRuntime_Musl)
     uint16_t ntohs(uint16_t);
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 else version (CRuntime_UClibc)
 {
@@ -333,10 +333,10 @@ else version (CRuntime_UClibc)
     uint16_t ntohs(uint16_t);
     }
 
-    in_addr_t       inet_addr(in char*);
+    in_addr_t       inet_addr(const scope char*);
     char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    const(char)*    inet_ntop(int, const scope void*, char*, socklen_t);
+    int             inet_pton(int, const scope char*, void*);
 }
 
 //
diff --git a/libphobos/libdruntime/core/sys/posix/config.d b/libphobos/libdruntime/core/sys/posix/config.d
index 20e711cb72d..c02debffadd 100644
--- a/libphobos/libdruntime/core/sys/posix/config.d
+++ b/libphobos/libdruntime/core/sys/posix/config.d
@@ -19,6 +19,7 @@ public import core.stdc.config;
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 enum _XOPEN_SOURCE     = 600;
 enum _POSIX_SOURCE     = true;
diff --git a/libphobos/libdruntime/core/sys/posix/dirent.d b/libphobos/libdruntime/core/sys/posix/dirent.d
index b12d6b157d5..8a2440e1fa4 100644
--- a/libphobos/libdruntime/core/sys/posix/dirent.d
+++ b/libphobos/libdruntime/core/sys/posix/dirent.d
@@ -15,7 +15,7 @@
  */
 module core.sys.posix.dirent;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types; // for ino_t
 
 version (OSX)
@@ -31,6 +31,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // Required
@@ -44,7 +45,7 @@ struct dirent
 }
 
 int     closedir(DIR*);
-DIR*    opendir(in char*);
+DIR*    opendir(const scope char*);
 dirent* readdir(DIR*);
 void    rewinddir(DIR*);
 */
@@ -129,7 +130,12 @@ else version (Darwin)
     // Other Darwin variants (iOS, TVOS, WatchOS) only support 64-bit inodes,
     // no suffix needed
     version (OSX)
-        pragma(mangle, "readdir$INODE64") dirent* readdir(DIR*);
+    {
+        version (AArch64)
+            dirent* readdir(DIR*);
+        else
+            pragma(mangle, "readdir$INODE64") dirent* readdir(DIR*);
+    }
     else
         dirent* readdir(DIR*);
 }
@@ -180,7 +186,17 @@ else version (FreeBSD)
 
     alias void* DIR;
 
-    dirent* readdir(DIR*);
+    version (GNU)
+    {
+        dirent* readdir(DIR*);
+    }
+    else
+    {
+        static if (__FreeBSD_version >= 1200000)
+            pragma(mangle, "readdir@FBSD_1.5") dirent* readdir(DIR*);
+        else
+            pragma(mangle, "readdir@FBSD_1.0") dirent* readdir(DIR*);
+    }
 }
 else version (NetBSD)
 {
@@ -434,10 +450,16 @@ else
 // in else below.
 version (OSX)
 {
-    version (D_LP64)
+    version (AArch64)
+    {
+        int     closedir(DIR*);
+        DIR*    opendir(const scope char*);
+        void    rewinddir(DIR*);
+    }
+    else version (D_LP64)
     {
         int closedir(DIR*);
-        pragma(mangle, "opendir$INODE64")   DIR* opendir(in char*);
+        pragma(mangle, "opendir$INODE64")   DIR* opendir(const scope char*);
         pragma(mangle, "rewinddir$INODE64") void rewinddir(DIR*);
     }
     else
@@ -445,21 +467,21 @@ version (OSX)
         // 32-bit mangles __DARWIN_UNIX03 specific functions with $UNIX2003 to
         // maintain backward compatibility with binaries build pre 10.5
         pragma(mangle, "closedir$UNIX2003")          int closedir(DIR*);
-        pragma(mangle, "opendir$INODE64$UNIX2003")   DIR* opendir(in char*);
+        pragma(mangle, "opendir$INODE64$UNIX2003")   DIR* opendir(const scope char*);
         pragma(mangle, "rewinddir$INODE64$UNIX2003") void rewinddir(DIR*);
     }
 }
 else version (NetBSD)
 {
     int     closedir(DIR*);
-    DIR*    __opendir30(in char*);
+    DIR*    __opendir30(const scope char*);
     alias __opendir30 opendir;
     void    rewinddir(DIR*);
 }
 else
 {
     int     closedir(DIR*);
-    DIR*    opendir(in char*);
+    DIR*    opendir(const scope char*);
     //dirent* readdir(DIR*);
     void    rewinddir(DIR*);
 }
@@ -492,7 +514,17 @@ else version (Darwin)
 }
 else version (FreeBSD)
 {
-    int readdir_r(DIR*, dirent*, dirent**);
+    version (GNU)
+    {
+        int readdir_r(DIR*, dirent*, dirent**);
+    }
+    else
+    {
+        static if (__FreeBSD_version >= 1200000)
+            pragma(mangle, "readdir_r@FBSD_1.5") int readdir_r(DIR*, dirent*, dirent**);
+        else
+            pragma(mangle, "readdir_r@FBSD_1.0") int readdir_r(DIR*, dirent*, dirent**);
+    }
 }
 else version (DragonFlyBSD)
 {
@@ -559,8 +591,16 @@ version (CRuntime_Glibc)
 }
 else version (FreeBSD)
 {
-    void   seekdir(DIR*, c_long);
-    c_long telldir(DIR*);
+    version (GNU)
+    {
+        void seekdir(DIR*, c_long);
+        c_long telldir(DIR*);
+    }
+    else
+    {
+        pragma(mangle, "seekdir@@FBSD_1.0") void seekdir(DIR*, c_long);
+        pragma(mangle, "telldir@@FBSD_1.0") c_long telldir(DIR*);
+    }
 }
 else version (NetBSD)
 {
diff --git a/libphobos/libdruntime/core/sys/posix/dlfcn.d b/libphobos/libdruntime/core/sys/posix/dlfcn.d
index 11113d36269..e97c7ea3960 100644
--- a/libphobos/libdruntime/core/sys/posix/dlfcn.d
+++ b/libphobos/libdruntime/core/sys/posix/dlfcn.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.dlfcn;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 
 version (OSX)
     version = Darwin;
@@ -45,6 +45,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // XOpen (XSI)
@@ -57,8 +58,8 @@ RTLD_LOCAL
 
 int   dlclose(void*);
 char* dlerror();
-void* dlopen(in char*, int);
-void* dlsym(void*, in char*);
+void* dlopen(const scope char*, int);
+void* dlsym(void*, const scope char*);
 */
 
 version (CRuntime_Glibc)
@@ -124,8 +125,8 @@ version (CRuntime_Glibc)
 
     int   dlclose(void*);
     char* dlerror();
-    void* dlopen(in char*, int);
-    void* dlsym(void*, in char*);
+    void* dlopen(const scope char*, int);
+    void* dlsym(void*, const scope char*);
 }
 else version (Darwin)
 {
@@ -136,8 +137,8 @@ else version (Darwin)
 
     int   dlclose(void*);
     char* dlerror();
-    void* dlopen(in char*, int);
-    void* dlsym(void*, in char*);
+    void* dlopen(const scope char*, int);
+    void* dlsym(void*, const scope char*);
     int   dladdr(void* addr, Dl_info* info);
 
     struct Dl_info
@@ -180,8 +181,8 @@ else version (NetBSD)
 
     int   dlclose(void*);
     char* dlerror();
-    void* dlopen(in char*, int);
-    void* dlsym(void*, in char*);
+    void* dlopen(const scope char*, int);
+    void* dlsym(void*, const scope char*);
     int   dladdr(const(void)* addr, Dl_info* info);
 
     struct Dl_info
@@ -201,8 +202,8 @@ else version (OpenBSD)
 
     int   dlclose(void*);
     char* dlerror();
-    void* dlopen(in char*, int);
-    void* dlsym(void*, in char*);
+    void* dlopen(const scope char*, int);
+    void* dlsym(void*, const scope char*);
     int   dladdr(const(void)* addr, Dl_info* info);
 
     struct Dl_info
@@ -222,8 +223,8 @@ else version (DragonFlyBSD)
 
     int   dlclose(void*);
     char* dlerror();
-    void* dlopen(in char*, int);
-    void* dlsym(void*, in char*);
+    void* dlopen(const scope char*, int);
+    void* dlsym(void*, const scope char*);
     int   dladdr(const(void)* addr, Dl_info* info);
 
     struct Dl_info
@@ -243,8 +244,8 @@ else version (Solaris)
 
     int   dlclose(void*);
     char* dlerror();
-    void* dlopen(in char*, int);
-    void* dlsym(void*, in char*);
+    void* dlopen(const scope char*, int);
+    void* dlsym(void*, const scope char*);
     int   dladdr(const(void)* addr, Dl_info* info);
 
     struct Dl_info
@@ -265,11 +266,11 @@ else version (CRuntime_Bionic)
         RTLD_GLOBAL = 2
     }
 
-    int          dladdr(in void*, Dl_info*);
+    int          dladdr(const scope void*, Dl_info*);
     int          dlclose(void*);
     const(char)* dlerror();
-    void*        dlopen(in char*, int);
-    void*        dlsym(void*, in char*);
+    void*        dlopen(const scope char*, int);
+    void*        dlsym(void*, const scope char*);
 
     struct Dl_info
     {
@@ -291,8 +292,8 @@ else version (CRuntime_Musl)
     }
     int          dlclose(void*);
     const(char)* dlerror();
-    void*        dlopen(in char*, int);
-    void*        dlsym(void*, in char*);
+    void*        dlopen(const scope char*, int);
+    void*        dlsym(void*, const scope char*);
 }
 else version (CRuntime_UClibc)
 {
@@ -331,6 +332,6 @@ else version (CRuntime_UClibc)
 
     int   dlclose(void*);
     char* dlerror();
-    void* dlopen(in char*, int);
-    void* dlsym(void*, in char*);
+    void* dlopen(const scope char*, int);
+    void* dlsym(void*, const scope char*);
 }
diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d
index 9febcff849b..59df921ba41 100644
--- a/libphobos/libdruntime/core/sys/posix/fcntl.d
+++ b/libphobos/libdruntime/core/sys/posix/fcntl.d
@@ -14,8 +14,8 @@
  */
 module core.sys.posix.fcntl;
 
-private import core.sys.posix.config;
-private import core.stdc.stdint;
+import core.sys.posix.config;
+import core.stdc.stdint;
 public import core.sys.posix.sys.types; // for off_t, mode_t
 public import core.sys.posix.sys.stat;  // for S_IFMT, etc.
 
@@ -49,6 +49,7 @@ extern (C):
 
 nothrow:
 @nogc:
+@system:
 
 //
 // Required
@@ -96,9 +97,9 @@ struct flock
     pid_t   l_pid;
 }
 
-int creat(in char*, mode_t);
+int creat(const scope char*, mode_t);
 int fcntl(int, int, ...);
-int open(in char*, int, ...);
+int open(const scope char*, int, ...);
 */
 version (CRuntime_Glibc)
 {
@@ -272,16 +273,16 @@ version (CRuntime_Glibc)
 
     static if ( __USE_FILE_OFFSET64 )
     {
-        int   creat64(in char*, mode_t);
+        int   creat64(const scope char*, mode_t);
         alias creat64 creat;
 
-        int   open64(in char*, int, ...);
+        int   open64(const scope char*, int, ...);
         alias open64 open;
     }
     else
     {
-        int   creat(in char*, mode_t);
-        int   open(in char*, int, ...);
+        int   creat(const scope char*, mode_t);
+        int   open(const scope char*, int, ...);
     }
 
     enum AT_SYMLINK_NOFOLLOW = 0x100;
@@ -331,8 +332,8 @@ else version (Darwin)
         short   l_whence;
     }
 
-    int creat(in char*, mode_t);
-    int open(in char*, int, ...);
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
 }
 else version (FreeBSD)
 {
@@ -392,8 +393,8 @@ else version (FreeBSD)
         short   l_whence;
     }
 
-    int creat(in char*, mode_t);
-    int open(in char*, int, ...);
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
 
     enum AT_SYMLINK_NOFOLLOW = 0x200;
     enum AT_FDCWD = -100;
@@ -457,8 +458,8 @@ else version (OpenBSD)
         short   l_whence;
     }
 
-    int creat(in char*, mode_t);
-    int open(in char*, int, ...);
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
 
     enum AT_FDCWD            = -100;
 
@@ -517,8 +518,8 @@ else version (NetBSD)
     }
 
 
-    int creat(in char*, mode_t);
-    int open(in char*, int, ...);
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
 }
 else version (DragonFlyBSD)
 {
@@ -604,8 +605,8 @@ else version (DragonFlyBSD)
 
     alias oflock = flock;
 
-    int creat(in char*, mode_t);
-    int open(in char*, int, ...);
+    int creat(const scope char*, mode_t);
+    int open(const scope char*, int, ...);
     //int fcntl(int, int, ...);  /*defined below*/
     //int flock(int, int);
 }
@@ -694,8 +695,8 @@ else version (Solaris)
 
     version (D_LP64)
     {
-        int creat(in char*, mode_t);
-        int open(in char*, int, ...);
+        int creat(const scope char*, mode_t);
+        int open(const scope char*, int, ...);
 
         static if (__USE_LARGEFILE64)
         {
@@ -707,16 +708,16 @@ else version (Solaris)
     {
         static if (__USE_LARGEFILE64)
         {
-            int creat64(in char*, mode_t);
+            int creat64(const scope char*, mode_t);
             alias creat64 creat;
 
-            int open64(in char*, int, ...);
+            int open64(const scope char*, int, ...);
             alias open64 open;
         }
         else
         {
-            int creat(in char*, mode_t);
-            int open(in char*, int, ...);
+            int creat(const scope char*, mode_t);
+            int open(const scope char*, int, ...);
         }
     }
 }
@@ -772,8 +773,8 @@ else version (CRuntime_Bionic)
         pid_t   l_pid;
     }
 
-    int   creat(in char*, mode_t);
-    int   open(in char*, int, ...);
+    int   creat(const scope char*, mode_t);
+    int   open(const scope char*, int, ...);
 
     enum AT_FDCWD = -100;
 }
@@ -925,9 +926,13 @@ else version (CRuntime_Musl)
         pid_t   l_pid;
     }
     enum FD_CLOEXEC     = 1;
-    int open(in char*, int, ...);
+    int open(const scope char*, int, ...);
 
     enum AT_FDCWD = -100;
+    enum AT_SYMLINK_NOFOLLOW = 0x100;
+    enum AT_REMOVEDIR = 0x200;
+    enum AT_SYMLINK_FOLLOW = 0x400;
+    enum AT_EACCESS = 0x200;
 }
 else version (CRuntime_UClibc)
 {
@@ -1037,16 +1042,16 @@ else version (CRuntime_UClibc)
 
     static if ( __USE_FILE_OFFSET64 )
     {
-        int   creat64(in char*, mode_t);
+        int   creat64(const scope char*, mode_t);
         alias creat64 creat;
 
-        int   open64(in char*, int, ...);
+        int   open64(const scope char*, int, ...);
         alias open64 open;
     }
     else
     {
-        int   creat(in char*, mode_t);
-        int   open(in char*, int, ...);
+        int   creat(const scope char*, mode_t);
+        int   open(const scope char*, int, ...);
     }
 
     enum AT_SYMLINK_NOFOLLOW    = 0x100;
@@ -1057,9 +1062,9 @@ else
     static assert(false, "Unsupported platform");
 }
 
-//int creat(in char*, mode_t);
+//int creat(const scope char*, mode_t);
 int fcntl(int, int, ...);
-//int open(in char*, int, ...);
+//int open(const scope char*, int, ...);
 
 // Generic Posix fallocate
 int posix_fallocate(int, off_t, off_t);
diff --git a/libphobos/libdruntime/core/sys/posix/grp.d b/libphobos/libdruntime/core/sys/posix/grp.d
index 41afeebf28b..92dcf34ee31 100644
--- a/libphobos/libdruntime/core/sys/posix/grp.d
+++ b/libphobos/libdruntime/core/sys/posix/grp.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.grp;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types; // for gid_t, uid_t
 
 version (OSX)
@@ -30,6 +30,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // Required
@@ -43,7 +44,7 @@ struct group
     char**  gr_mem;
 }
 
-group* getgrnam(in char*);
+group* getgrnam(const scope char*);
 group* getgrgid(gid_t);
 */
 
@@ -152,50 +153,50 @@ else
     static assert(false, "Unsupported platform");
 }
 
-group* getgrnam(in char*);
+group* getgrnam(const scope char*);
 group* getgrgid(gid_t);
 
 //
 // Thread-Safe Functions (TSF)
 //
 /*
-int getgrnam_r(in char*, group*, char*, size_t, group**);
+int getgrnam_r(const scope char*, group*, char*, size_t, group**);
 int getgrgid_r(gid_t, group*, char*, size_t, group**);
 */
 
 version (CRuntime_Glibc)
 {
-    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrnam_r(const scope char*, group*, char*, size_t, group**);
     int getgrgid_r(gid_t, group*, char*, size_t, group**);
 }
 else version (Darwin)
 {
-    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrnam_r(const scope char*, group*, char*, size_t, group**);
     int getgrgid_r(gid_t, group*, char*, size_t, group**);
 }
 else version (FreeBSD)
 {
-    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrnam_r(const scope char*, group*, char*, size_t, group**);
     int getgrgid_r(gid_t, group*, char*, size_t, group**);
 }
 else version (NetBSD)
 {
-    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrnam_r(const scope char*, group*, char*, size_t, group**);
     int getgrgid_r(gid_t, group*, char*, size_t, group**);
 }
 else version (OpenBSD)
 {
-    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrnam_r(const scope char*, group*, char*, size_t, group**);
     int getgrgid_r(gid_t, group*, char*, size_t, group**);
 }
 else version (DragonFlyBSD)
 {
-    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrnam_r(const scope char*, group*, char*, size_t, group**);
     int getgrgid_r(gid_t, group*, char*, size_t, group**);
 }
 else version (Solaris)
 {
-    int getgrnam_r(in char*, group*, char*, int, group**);
+    int getgrnam_r(const scope char*, group*, char*, int, group**);
     int getgrgid_r(gid_t, group*, char*, int, group**);
 }
 else version (CRuntime_Bionic)
@@ -203,12 +204,12 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_UClibc)
 {
-    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrnam_r(const scope char*, group*, char*, size_t, group**);
     int getgrgid_r(gid_t, group*, char*, size_t, group**);
 }
 else version (CRuntime_Musl)
 {
-    int getgrnam_r(in char*, group*, char*, size_t, group**);
+    int getgrnam_r(const scope char*, group*, char*, size_t, group**);
     int getgrgid_r(gid_t, group*, char*, size_t, group**);
 }
 else
diff --git a/libphobos/libdruntime/core/sys/posix/iconv.d b/libphobos/libdruntime/core/sys/posix/iconv.d
index 9ba6fddee7e..cea89870eca 100644
--- a/libphobos/libdruntime/core/sys/posix/iconv.d
+++ b/libphobos/libdruntime/core/sys/posix/iconv.d
@@ -34,18 +34,19 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 
 alias void* iconv_t;
 
 /// Allocate descriptor for code conversion from codeset FROMCODE to
 /// codeset TOCODE.
-iconv_t iconv_open (in char* tocode, in char* fromcode);
+iconv_t iconv_open (const scope char* tocode, const scope char* fromcode);
 
 /// Convert at most *INBYTESLEFT bytes from *INBUF according to the
 /// code conversion algorithm specified by CD and place up to
 /// *OUTBYTESLEFT bytes in buffer at *OUTBUF.
-size_t iconv (iconv_t cd, in char** inbuf,
+size_t iconv (iconv_t cd, const scope char** inbuf,
          size_t* inbytesleft,
          char** outbuf,
          size_t* outbytesleft);
diff --git a/libphobos/libdruntime/core/sys/posix/inttypes.d b/libphobos/libdruntime/core/sys/posix/inttypes.d
index 15863b4f35e..4bde28f015d 100644
--- a/libphobos/libdruntime/core/sys/posix/inttypes.d
+++ b/libphobos/libdruntime/core/sys/posix/inttypes.d
@@ -14,11 +14,12 @@
  */
 module core.sys.posix.inttypes;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.stdc.inttypes;
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // Required
@@ -26,15 +27,15 @@ extern (C) nothrow @nogc:
 /*
 intmax_t  imaxabs(intmax_t);
 imaxdiv_t imaxdiv(intmax_t, intmax_t);
-intmax_t  strtoimax(in char*, char**, int);
-uintmax_t strtoumax(in char*, char**, int);
-intmax_t  wcstoimax(in wchar_t*, wchar_t**, int);
-uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);
+intmax_t  strtoimax(const scope char*, char**, int);
+uintmax_t strtoumax(const scope char*, char**, int);
+intmax_t  wcstoimax(const scope wchar_t*, wchar_t**, int);
+uintmax_t wcstoumax(const scope wchar_t*, wchar_t**, int);
 */
 
 intmax_t  imaxabs(intmax_t);
 imaxdiv_t imaxdiv(intmax_t, intmax_t);
-intmax_t  strtoimax(in char*, char**, int);
-uintmax_t strtoumax(in char*, char**, int);
-intmax_t  wcstoimax(in wchar_t*, wchar_t**, int);
-uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);
+intmax_t  strtoimax(const scope char*, char**, int);
+uintmax_t strtoumax(const scope char*, char**, int);
+intmax_t  wcstoimax(const scope wchar_t*, wchar_t**, int);
+uintmax_t wcstoumax(const scope wchar_t*, wchar_t**, int);
diff --git a/libphobos/libdruntime/core/sys/posix/libgen.d b/libphobos/libdruntime/core/sys/posix/libgen.d
index 6770cd828b3..b90765fcf80 100644
--- a/libphobos/libdruntime/core/sys/posix/libgen.d
+++ b/libphobos/libdruntime/core/sys/posix/libgen.d
@@ -15,6 +15,7 @@
 module core.sys.posix.libgen;
 
 @nogc nothrow:
+@system:
 extern (C):
 version (Posix):
 
diff --git a/libphobos/libdruntime/core/sys/posix/locale.d b/libphobos/libdruntime/core/sys/posix/locale.d
new file mode 100644
index 00000000000..172e9aa583c
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/locale.d
@@ -0,0 +1,175 @@
+/**
+ * D header file for POSIX's <locale.h>.
+ *
+ * See_Also:  https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/locale.h.html
+ * Copyright: D Language Foundation, 2019
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Mathias 'Geod24' Lang
+ * Standards: The Open Group Base Specifications Issue 7, 2018 edition
+ * Source:    $(DRUNTIMESRC core/sys/posix/_locale.d)
+ */
+module core.sys.posix.locale;
+
+version (Posix):
+extern(C):
+@system:
+nothrow:
+@nogc:
+
+version (OSX)
+    version = Darwin;
+else version (iOS)
+    version = Darwin;
+else version (TVOS)
+    version = Darwin;
+else version (WatchOS)
+    version = Darwin;
+
+version (Darwin)
+    version = DarwinBSDLocale;
+version (FreeBSD)
+    version = DarwinBSDLocale;
+version (NetBSD)
+    version = DarwinBSDLocale;
+version (DragonflyBSD)
+    version = DarwinBSDLocale;
+
+///
+struct lconv
+{
+    char*    currency_symbol;
+    char*    decimal_point;
+    char     frac_digits;
+    char*    grouping;
+    char*    int_curr_symbol;
+    char     int_frac_digits;
+    char     int_n_cs_precedes;
+    char     int_n_sep_by_space;
+    char     int_n_sign_posn;
+    char     int_p_cs_precedes;
+    char     int_p_sep_by_space;
+    char     int_p_sign_posn;
+    char*    mon_decimal_point;
+    char*    mon_grouping;
+    char*    mon_thousands_sep;
+    char*    negative_sign;
+    char     n_cs_precedes;
+    char     n_sep_by_space;
+    char     n_sign_posn;
+    char*    positive_sign;
+    char     p_cs_precedes;
+    char     p_sep_by_space;
+    char     p_sign_posn;
+    char*    thousands_sep;
+}
+
+/// Duplicate existing locale
+locale_t duplocale(locale_t locale);
+/// Free an allocated locale
+void     freelocale(locale_t locale);
+/// Natural language formatting for C
+lconv*   localeconv();
+/// Create a new locale
+locale_t newlocale(int mask, const char* locale, locale_t base);
+/// Set the C library's notion of natural language formatting style
+char*    setlocale(int category, const char* locale);
+/// Set the per-thread locale
+locale_t uselocale (locale_t locale);
+
+version (DarwinBSDLocale)
+{
+    ///
+    enum
+    {
+        LC_ALL      = 0,
+        LC_COLLATE  = 1,
+        LC_CTYPE    = 2,
+        LC_MESSAGES = 6,
+        LC_MONETARY = 3,
+        LC_NUMERIC  = 4,
+        LC_TIME     = 5,
+    }
+
+    private struct _xlocale;
+
+    ///
+    alias locale_t = _xlocale*;
+
+    version (NetBSD)
+        enum LC_ALL_MASK = (cast(int)~0);
+    else
+        enum LC_ALL_MASK = (
+            LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK |
+            LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK);
+
+
+    ///
+    enum
+    {
+        LC_COLLATE_MASK  = (1 << 0),
+        LC_CTYPE_MASK    = (1 << 1),
+        LC_MESSAGES_MASK = (1 << 2),
+        LC_MONETARY_MASK = (1 << 3),
+        LC_NUMERIC_MASK  = (1 << 4),
+        LC_TIME_MASK     = (1 << 5),
+    }
+
+    ///
+    enum LC_GLOBAL_LOCALE = (cast(locale_t)-1);
+}
+
+version (linux)
+{
+    ///
+    enum
+    {
+        LC_ALL      = 6,
+        LC_COLLATE  = 3,
+        LC_CTYPE    = 0,
+        LC_MESSAGES = 5,
+        LC_MONETARY = 4,
+        LC_NUMERIC  = 1,
+        LC_TIME     = 2,
+
+        // Linux-specific
+        LC_PAPER          =  7,
+        LC_NAME           =  8,
+        LC_ADDRESS        =  9,
+        LC_TELEPHONE      = 10,
+        LC_MEASUREMENT    = 11,
+        LC_IDENTIFICATION = 12,
+    }
+
+    ///
+    enum
+    {
+        LC_ALL_MASK = (LC_CTYPE_MASK | LC_NUMERIC_MASK | LC_TIME_MASK |
+                       LC_COLLATE_MASK | LC_MONETARY_MASK | LC_MESSAGES_MASK |
+                       LC_PAPER_MASK | LC_NAME_MASK | LC_ADDRESS_MASK |
+                       LC_TELEPHONE_MASK | LC_MEASUREMENT_MASK |
+                       LC_IDENTIFICATION_MASK),
+
+        LC_COLLATE_MASK  = (1 << LC_COLLATE),
+        LC_CTYPE_MASK    = (1 << LC_CTYPE),
+        LC_MESSAGES_MASK = (1 << LC_MESSAGES),
+        LC_MONETARY_MASK = (1 << LC_MONETARY),
+        LC_NUMERIC_MASK  = (1 << LC_NUMERIC),
+        LC_TIME_MASK     = (1 << LC_TIME),
+
+        // Linux specific
+        LC_PAPER_MASK          = (1 << LC_PAPER),
+        LC_NAME_MASK           = (1 << LC_NAME),
+        LC_ADDRESS_MASK        = (1 << LC_ADDRESS),
+        LC_TELEPHONE_MASK      = (1 << LC_TELEPHONE),
+        LC_MEASUREMENT_MASK    = (1 << LC_MEASUREMENT),
+        LC_IDENTIFICATION_MASK = (1 << LC_IDENTIFICATION),
+    }
+
+    private struct __locale_struct;
+
+    ///
+    alias locale_t = __locale_struct*;
+
+    ///
+    enum LC_GLOBAL_LOCALE = (cast(locale_t)-1);
+}
diff --git a/libphobos/libdruntime/core/sys/posix/mqueue.d b/libphobos/libdruntime/core/sys/posix/mqueue.d
index d5543768004..3b447a1a434 100644
--- a/libphobos/libdruntime/core/sys/posix/mqueue.d
+++ b/libphobos/libdruntime/core/sys/posix/mqueue.d
@@ -30,6 +30,7 @@ version (Posix):
 version (CRuntime_Glibc):
 extern (C):
 @nogc nothrow:
+@system:
 
 
 /// Message queue descriptor.
diff --git a/libphobos/libdruntime/core/sys/posix/net/if_.d b/libphobos/libdruntime/core/sys/posix/net/if_.d
index e6eb57b7b47..3713673e4bc 100644
--- a/libphobos/libdruntime/core/sys/posix/net/if_.d
+++ b/libphobos/libdruntime/core/sys/posix/net/if_.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.net.if_;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 
 version (OSX)
     version = Darwin;
@@ -40,7 +40,7 @@ struct if_nameindex // renamed to if_nameindex_t
 
 IF_NAMESIZE
 
-uint            if_nametoindex(in char*);
+uint            if_nametoindex(const scope char*);
 char*           if_indextoname(uint, char*);
 if_nameindex_t* if_nameindex();
 void            if_freenameindex(if_nameindex_t*);
@@ -56,7 +56,7 @@ version (CRuntime_Glibc)
 
     enum IF_NAMESIZE = 16;
 
-    uint            if_nametoindex(in char*);
+    uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
@@ -71,7 +71,7 @@ else version (Darwin)
 
     enum IF_NAMESIZE = 16;
 
-    uint            if_nametoindex(in char*);
+    uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
@@ -86,7 +86,7 @@ else version (FreeBSD)
 
     enum IF_NAMESIZE = 16;
 
-    uint            if_nametoindex(in char*);
+    uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
@@ -101,7 +101,7 @@ else version (NetBSD)
 
     enum IF_NAMESIZE = 16;
 
-    uint            if_nametoindex(in char*);
+    uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
@@ -116,7 +116,7 @@ else version (OpenBSD)
 
     enum IF_NAMESIZE = 16;
 
-    uint            if_nametoindex(in char*);
+    uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
@@ -131,7 +131,7 @@ else version (DragonFlyBSD)
 
     enum IF_NAMESIZE = 16;
 
-    uint            if_nametoindex(in char*);
+    uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
@@ -140,7 +140,7 @@ else version (CRuntime_Bionic)
 {
     enum IF_NAMESIZE = 16;
 
-    uint            if_nametoindex(in char*);
+    uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
 }
 else version (CRuntime_UClibc)
@@ -153,7 +153,7 @@ else version (CRuntime_UClibc)
 
     enum IF_NAMESIZE = 16;
 
-    uint            if_nametoindex(in char*);
+    uint            if_nametoindex(const scope char*);
     char*           if_indextoname(uint, char*);
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
diff --git a/libphobos/libdruntime/core/sys/posix/netdb.d b/libphobos/libdruntime/core/sys/posix/netdb.d
index f1251839b16..bede63843d8 100644
--- a/libphobos/libdruntime/core/sys/posix/netdb.d
+++ b/libphobos/libdruntime/core/sys/posix/netdb.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.netdb;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.stdc.inttypes;         // for uint32_t
 public import core.sys.posix.netinet.in_; // for in_port_t, in_addr_t
 public import core.sys.posix.sys.types;   // for ino_t
@@ -33,6 +33,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // Required
diff --git a/libphobos/libdruntime/core/sys/posix/netinet/in_.d b/libphobos/libdruntime/core/sys/posix/netinet/in_.d
index ef20a8f9453..a58fa850d5d 100644
--- a/libphobos/libdruntime/core/sys/posix/netinet/in_.d
+++ b/libphobos/libdruntime/core/sys/posix/netinet/in_.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.netinet.in_;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.stdc.inttypes; // for uint32_t, uint16_t, uint8_t
 public import core.sys.posix.arpa.inet;
 public import core.sys.posix.sys.socket; // for sa_family_t
@@ -804,7 +804,7 @@ else version (FreeBSD)
     }
 
     // macros
-    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -812,7 +812,7 @@ else version (FreeBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
     }
 
-    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LOOPBACK( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -820,7 +820,7 @@ else version (FreeBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4COMPAT( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -829,58 +829,58 @@ else version (FreeBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4MAPPED( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
     }
 
-    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
     }
 
-    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_SITELOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
     }
 
-    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MULTICAST( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xff;
     }
 
-    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( in in6_addr* a ) pure
+    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( const scope in6_addr* a ) pure
     {
         return a.s6_addr[1] & 0x0f;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL;
@@ -943,7 +943,7 @@ else version (NetBSD)
     }
 
     // macros
-    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -951,7 +951,7 @@ else version (NetBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
     }
 
-    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LOOPBACK( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -959,7 +959,7 @@ else version (NetBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4COMPAT( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -968,58 +968,58 @@ else version (NetBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4MAPPED( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
     }
 
-    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
     }
 
-    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_SITELOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
     }
 
-    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MULTICAST( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xff;
     }
 
-    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( in in6_addr* a ) pure
+    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( const scope in6_addr* a ) pure
     {
         return a.s6_addr[1] & 0x0f;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL;
@@ -1082,7 +1082,7 @@ else version (OpenBSD)
     }
 
     // macros
-    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1090,7 +1090,7 @@ else version (OpenBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
     }
 
-    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LOOPBACK( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1098,7 +1098,7 @@ else version (OpenBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4COMPAT( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1107,58 +1107,58 @@ else version (OpenBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4MAPPED( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
     }
 
-    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
     }
 
-    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_SITELOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
     }
 
-    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MULTICAST( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xff;
     }
 
-    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( in in6_addr* a ) pure
+    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( const scope in6_addr* a ) pure
     {
         return a.s6_addr[1] & 0x0f;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL;
@@ -1221,7 +1221,7 @@ else version (DragonFlyBSD)
     }
 
     // macros
-    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1229,7 +1229,7 @@ else version (DragonFlyBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
     }
 
-    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LOOPBACK( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1237,7 +1237,7 @@ else version (DragonFlyBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4COMPAT( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1246,58 +1246,58 @@ else version (DragonFlyBSD)
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4MAPPED( const scope in6_addr* a ) pure
     {
         return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
                (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
     }
 
-    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
     }
 
-    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_SITELOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
     }
 
-    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MULTICAST( const scope in6_addr* a ) pure
     {
         return a.s6_addr[0] == 0xff;
     }
 
-    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( in in6_addr* a ) pure
+    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( const scope in6_addr* a ) pure
     {
         return a.s6_addr[1] & 0x0f;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( const scope in6_addr* a ) pure
     {
         return IN6_IS_ADDR_MULTICAST(a) &&
                __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL;
@@ -1350,67 +1350,67 @@ else version (Solaris)
     }
 
     // macros
-    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_UNSPECIFIED( const scope in6_addr* a ) pure
     {
         return (a.s6_addr32[0] == 0) && (a.s6_addr32[1] == 0) &&
                (a.s6_addr32[2] == 0) && (a.s6_addr32[3] == 0);
     }
 
-    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LOOPBACK( const scope in6_addr* a ) pure
     {
         return (a.s6_addr32[0] == 0) && (a.s6_addr32[1] == 0) &&
                (a.s6_addr32[2] == 0) && (a.s6_addr32[3] == ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4COMPAT( const scope in6_addr* a ) pure
     {
         return (a.s6_addr32[0] == 0) && (a.s6_addr32[1] == 0) &&
                (a.s6_addr32[2] == 0) && (a.s6_addr32[3] != 0) &&
                (a.s6_addr32[3] != ntohl(1));
     }
 
-    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_V4MAPPED( const scope in6_addr* a ) pure
     {
         return (a.s6_addr32[0] == 0) && (a.s6_addr32[1] == 0) &&
                (a.s6_addr32[2] == ntohl(0x0000ffff));
     }
 
-    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr8[0] == 0xfe && (a.s6_addr8[1] & 0xc0) == 0x80;
     }
 
-    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_SITELOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr8[0] == 0xfe && (a.s6_addr8[1] & 0xc0) == 0xc0;
     }
 
-    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MULTICAST( const scope in6_addr* a ) pure
     {
         return a.s6_addr8[0] == 0xff;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x01;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x02;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x05;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x08;
     }
 
-    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a ) pure
+    extern (D) int IN6_IS_ADDR_MC_GLOBAL( const scope in6_addr* a ) pure
     {
         return a.s6_addr8[0] == 0xff && (a.s6_addr8[1] & 0x0f) == 0x0e;
     }
@@ -1470,7 +1470,7 @@ else version (CRuntime_Bionic)
 
     extern (D) pure
     {
-        bool IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a )
+        bool IN6_IS_ADDR_UNSPECIFIED( const scope in6_addr* a )
         {
             return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                    (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1478,7 +1478,7 @@ else version (CRuntime_Bionic)
                    (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
         }
 
-        bool IN6_IS_ADDR_LOOPBACK( in in6_addr* a )
+        bool IN6_IS_ADDR_LOOPBACK( const scope in6_addr* a )
         {
             return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                    (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1486,7 +1486,7 @@ else version (CRuntime_Bionic)
                    (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
         }
 
-        bool IN6_IS_ADDR_V4COMPAT( in in6_addr* a )
+        bool IN6_IS_ADDR_V4COMPAT( const scope in6_addr* a )
         {
             return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                    (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
@@ -1495,63 +1495,63 @@ else version (CRuntime_Bionic)
                    (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
         }
 
-        bool IN6_IS_ADDR_V4MAPPED( in in6_addr* a )
+        bool IN6_IS_ADDR_V4MAPPED( const scope in6_addr* a )
         {
             return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
                    (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
                    (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
         }
 
-        bool IN6_IS_ADDR_LINKLOCAL( in in6_addr* a )
+        bool IN6_IS_ADDR_LINKLOCAL( const scope in6_addr* a )
         {
             return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
         }
 
-        bool IN6_IS_ADDR_SITELOCAL( in in6_addr* a )
+        bool IN6_IS_ADDR_SITELOCAL( const scope in6_addr* a )
         {
             return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
         }
 
-        bool IN6_IS_ADDR_ULA( in in6_addr* a )
+        bool IN6_IS_ADDR_ULA( const scope in6_addr* a )
         {
             return (a.s6_addr[0] & 0xfe) == 0xfc;
         }
 
-        bool IN6_IS_ADDR_MULTICAST( in in6_addr* a )
+        bool IN6_IS_ADDR_MULTICAST( const scope in6_addr* a )
         {
             return a.s6_addr[0] == 0xff;
         }
 
-        uint8_t IPV6_ADDR_MC_SCOPE( in in6_addr* a )
+        uint8_t IPV6_ADDR_MC_SCOPE( const scope in6_addr* a )
         {
             return a.s6_addr[1] & 0x0f;
         }
 
-        bool IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a )
+        bool IN6_IS_ADDR_MC_NODELOCAL( const scope in6_addr* a )
         {
             return IN6_IS_ADDR_MULTICAST(a) &&
                    IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_NODELOCAL;
         }
 
-        bool IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a )
+        bool IN6_IS_ADDR_MC_LINKLOCAL( const scope in6_addr* a )
         {
             return IN6_IS_ADDR_MULTICAST(a) &&
                    IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL;
         }
 
-        bool IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a )
+        bool IN6_IS_ADDR_MC_SITELOCAL( const scope in6_addr* a )
         {
             return IN6_IS_ADDR_MULTICAST(a) &&
                    IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL;
         }
 
-        bool IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a )
+        bool IN6_IS_ADDR_MC_ORGLOCAL( const scope in6_addr* a )
         {
             return IN6_IS_ADDR_MULTICAST(a) &&
                    IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL;
         }
 
-        bool IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a )
+        bool IN6_IS_ADDR_MC_GLOBAL( const scope in6_addr* a )
         {
             return IN6_IS_ADDR_MULTICAST(a) &&
                    IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL;
diff --git a/libphobos/libdruntime/core/sys/posix/netinet/tcp.d b/libphobos/libdruntime/core/sys/posix/netinet/tcp.d
index 134e133d1eb..d400d2d9a86 100644
--- a/libphobos/libdruntime/core/sys/posix/netinet/tcp.d
+++ b/libphobos/libdruntime/core/sys/posix/netinet/tcp.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.netinet.tcp;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 
 version (OSX)
     version = Darwin;
diff --git a/libphobos/libdruntime/core/sys/posix/poll.d b/libphobos/libdruntime/core/sys/posix/poll.d
index 9070eeed573..fdc41764a78 100644
--- a/libphobos/libdruntime/core/sys/posix/poll.d
+++ b/libphobos/libdruntime/core/sys/posix/poll.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.poll;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 
 version (OSX)
     version = Darwin;
@@ -29,6 +29,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // XOpen (XSI)
@@ -91,7 +92,7 @@ else version (Darwin)
         int     fd;
         short   events;
         short   revents;
-    };
+    }
 
     alias uint nfds_t;
 
@@ -127,7 +128,7 @@ else version (FreeBSD)
         int     fd;
         short   events;
         short   revents;
-    };
+    }
 
     enum
     {
@@ -161,7 +162,7 @@ else version (NetBSD)
         int     fd;
         short   events;
         short   revents;
-    };
+    }
 
     enum
     {
@@ -195,7 +196,7 @@ else version (OpenBSD)
         int     fd;
         short   events;
         short   revents;
-    };
+    }
 
     enum
     {
@@ -226,7 +227,7 @@ else version (DragonFlyBSD)
         int     fd;
         short   events;
         short   revents;
-    };
+    }
 
     enum
     {
diff --git a/libphobos/libdruntime/core/sys/posix/pthread.d b/libphobos/libdruntime/core/sys/posix/pthread.d
index 1d0d294f251..577fb71ace1 100644
--- a/libphobos/libdruntime/core/sys/posix/pthread.d
+++ b/libphobos/libdruntime/core/sys/posix/pthread.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.pthread;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types;
 public import core.sys.posix.sched;
 public import core.sys.posix.time;
@@ -33,6 +33,7 @@ else version (WatchOS)
 version (Posix):
 extern (C)
 nothrow:
+@system:
 
 //
 // Required
@@ -55,23 +56,23 @@ PTHREAD_PROCESS_PRIVATE
 
 int pthread_atfork(void function(), void function(), void function());
 int pthread_attr_destroy(pthread_attr_t*);
-int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
-int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
+int pthread_attr_getdetachstate(const scope pthread_attr_t*, int*);
+int pthread_attr_getschedparam(const scope pthread_attr_t*, sched_param*);
 int pthread_attr_init(pthread_attr_t*);
 int pthread_attr_setdetachstate(pthread_attr_t*, int);
-int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
+int pthread_attr_setschedparam(const scope pthread_attr_t*, sched_param*);
 int pthread_cancel(pthread_t);
 void pthread_cleanup_push(void function(void*), void*);
 void pthread_cleanup_pop(int);
 int pthread_cond_broadcast(pthread_cond_t*);
 int pthread_cond_destroy(pthread_cond_t*);
-int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*);
+int pthread_cond_init(const scope pthread_cond_t*, pthread_condattr_t*);
 int pthread_cond_signal(pthread_cond_t*);
-int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, in timespec*);
+int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const scope timespec*);
 int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
 int pthread_condattr_destroy(pthread_condattr_t*);
 int pthread_condattr_init(pthread_condattr_t*);
-int pthread_create(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
+int pthread_create(pthread_t*, const scope pthread_attr_t*, void* function(void*), void*);
 int pthread_detach(pthread_t);
 int pthread_equal(pthread_t, pthread_t);
 void pthread_exit(void*);
@@ -88,7 +89,7 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t*);
 int pthread_mutexattr_init(pthread_mutexattr_t*);
 int pthread_once(pthread_once_t*, void function());
 int pthread_rwlock_destroy(pthread_rwlock_t*);
-int pthread_rwlock_init(pthread_rwlock_t*, in pthread_rwlockattr_t*);
+int pthread_rwlock_init(pthread_rwlock_t*, const scope pthread_rwlockattr_t*);
 int pthread_rwlock_rdlock(pthread_rwlock_t*);
 int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
 int pthread_rwlock_trywrlock(pthread_rwlock_t*);
@@ -99,7 +100,7 @@ int pthread_rwlockattr_init(pthread_rwlockattr_t*);
 pthread_t pthread_self();
 int pthread_setcancelstate(int, int*);
 int pthread_setcanceltype(int, int*);
-int pthread_setspecific(pthread_key_t, in void*);
+int pthread_setspecific(pthread_key_t, const scope void*);
 void pthread_testcancel();
 */
 version (CRuntime_Glibc)
@@ -330,7 +331,7 @@ else version (DragonFlyBSD)
 
     enum PTHREAD_MUTEX_INITIALIZER              = null;
     //enum PTHREAD_ONCE_INIT                      = { PTHREAD_NEEDS_INIT, NULL };
-    enum PTHREAD_ONCE_INIT                      = pthread_once_t.init;;
+    enum PTHREAD_ONCE_INIT                      = pthread_once_t.init;
     enum PTHREAD_COND_INITIALIZER               = null;
     enum PTHREAD_RWLOCK_INITIALIZER             = null;
 }
@@ -444,11 +445,11 @@ int pthread_atfork(void function(), void function(), void function());
 @nogc {
     int pthread_atfork(void function() @nogc, void function() @nogc, void function() @nogc);
     int pthread_attr_destroy(pthread_attr_t*);
-    int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
-    int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
+    int pthread_attr_getdetachstate(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedparam(const scope pthread_attr_t*, sched_param*);
     int pthread_attr_init(pthread_attr_t*);
     int pthread_attr_setdetachstate(pthread_attr_t*, int);
-    int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
+    int pthread_attr_setschedparam(const scope pthread_attr_t*, sched_param*);
     int pthread_cancel(pthread_t);
 }
 
@@ -716,13 +717,13 @@ else
 
 int pthread_cond_broadcast(pthread_cond_t*);
 int pthread_cond_destroy(pthread_cond_t*);
-int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*) @trusted;
+int pthread_cond_init(const scope pthread_cond_t*, pthread_condattr_t*) @trusted;
 int pthread_cond_signal(pthread_cond_t*);
-int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, in timespec*);
+int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, const scope timespec*);
 int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
 int pthread_condattr_destroy(pthread_condattr_t*);
 int pthread_condattr_init(pthread_condattr_t*);
-int pthread_create(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
+int pthread_create(pthread_t*, const scope pthread_attr_t*, void* function(void*), void*);
 int pthread_detach(pthread_t);
 int pthread_equal(pthread_t, pthread_t);
 void pthread_exit(void*);
@@ -742,7 +743,7 @@ int pthread_mutexattr_destroy(pthread_mutexattr_t*);
 int pthread_mutexattr_init(pthread_mutexattr_t*) @trusted;
 int pthread_once(pthread_once_t*, void function());
 int pthread_rwlock_destroy(pthread_rwlock_t*);
-int pthread_rwlock_init(pthread_rwlock_t*, in pthread_rwlockattr_t*);
+int pthread_rwlock_init(pthread_rwlock_t*, const scope pthread_rwlockattr_t*);
 int pthread_rwlock_rdlock(pthread_rwlock_t*);
 int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
 int pthread_rwlock_trywrlock(pthread_rwlock_t*);
@@ -753,7 +754,7 @@ int pthread_rwlockattr_init(pthread_rwlockattr_t*);
 pthread_t pthread_self();
 int pthread_setcancelstate(int, int*);
 int pthread_setcanceltype(int, int*);
-int pthread_setspecific(pthread_key_t, in void*);
+int pthread_setspecific(pthread_key_t, const scope void*);
 void pthread_testcancel();
 
 //
@@ -763,10 +764,10 @@ void pthread_testcancel();
 PTHREAD_BARRIER_SERIAL_THREAD
 
 int pthread_barrier_destroy(pthread_barrier_t*);
-int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
 int pthread_barrier_wait(pthread_barrier_t*);
 int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*); (BAR|TSH)
+int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*); (BAR|TSH)
 int pthread_barrierattr_init(pthread_barrierattr_t*);
 int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); (BAR|TSH)
 */
@@ -776,10 +777,10 @@ version (CRuntime_Glibc)
     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
 
     int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
     int pthread_barrier_wait(pthread_barrier_t*);
     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
@@ -788,10 +789,10 @@ else version (FreeBSD)
     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
 
     int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
     int pthread_barrier_wait(pthread_barrier_t*);
     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
@@ -803,10 +804,10 @@ else version (DragonFlyBSD)
     enum PTHREAD_THREADS_MAX           = c_ulong.max;
 
     int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
     int pthread_barrier_wait(pthread_barrier_t*);
     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
@@ -815,10 +816,10 @@ else version (NetBSD)
     enum PTHREAD_BARRIER_SERIAL_THREAD = 1234567;
 
     int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
     int pthread_barrier_wait(pthread_barrier_t*);
     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
@@ -827,10 +828,10 @@ else version (OpenBSD)
     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
 
     int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
     int pthread_barrier_wait(pthread_barrier_t*);
     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
@@ -842,10 +843,10 @@ else version (Solaris)
     enum PTHREAD_BARRIER_SERIAL_THREAD = -2;
 
     int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
     int pthread_barrier_wait(pthread_barrier_t*);
     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
@@ -857,10 +858,10 @@ else version (CRuntime_Musl)
     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
 
     int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
     int pthread_barrier_wait(pthread_barrier_t*);
     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
@@ -869,10 +870,10 @@ else version (CRuntime_UClibc)
     enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
 
     int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_init(pthread_barrier_t*, const scope pthread_barrierattr_t*, uint);
     int pthread_barrier_wait(pthread_barrier_t*);
     int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_getpshared(const scope pthread_barrierattr_t*, int*);
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
@@ -885,22 +886,22 @@ else
 // Clock (CS)
 //
 /*
-int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
 int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 */
 version (CRuntime_Glibc)
 {
-    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 }
 else version (FreeBSD)
 {
-    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 }
 else version (DragonFlyBSD)
 {
-    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 }
 else version (NetBSD)
@@ -909,7 +910,7 @@ else version (NetBSD)
 }
 else version (OpenBSD)
 {
-    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 }
 else version (Darwin)
@@ -917,7 +918,7 @@ else version (Darwin)
 }
 else version (Solaris)
 {
-    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 }
 else version (CRuntime_Bionic)
@@ -925,12 +926,12 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 }
 else version (CRuntime_UClibc)
 {
-    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_getclock(const scope pthread_condattr_t*, clockid_t*);
     int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 }
 else
@@ -1033,10 +1034,10 @@ PTHREAD_MUTEX_ERRORCHECK
 PTHREAD_MUTEX_NORMAL
 PTHREAD_MUTEX_RECURSIVE
 
-int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
 int pthread_attr_setguardsize(pthread_attr_t*, size_t);
 int pthread_getconcurrency();
-int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
 int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
 int pthread_setconcurrency(int);
 */
@@ -1048,10 +1049,10 @@ version (CRuntime_Glibc)
     enum PTHREAD_MUTEX_ERRORCHECK   = 2;
     enum PTHREAD_MUTEX_DEFAULT      = PTHREAD_MUTEX_NORMAL;
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
     int pthread_getconcurrency();
-    int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
     int pthread_setconcurrency(int);
 }
@@ -1062,10 +1063,10 @@ else version (Darwin)
     enum PTHREAD_MUTEX_RECURSIVE    = 2;
     enum PTHREAD_MUTEX_DEFAULT      = PTHREAD_MUTEX_NORMAL;
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
     int pthread_getconcurrency();
-    int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
     int pthread_setconcurrency(int);
 }
@@ -1081,7 +1082,7 @@ else version (FreeBSD)
     }
     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
     int pthread_getconcurrency();
     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
@@ -1099,7 +1100,7 @@ else version (NetBSD)
     }
     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
     int pthread_getconcurrency();
     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
@@ -1118,7 +1119,7 @@ else version (OpenBSD)
     }
     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
     int pthread_getconcurrency();
     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
@@ -1136,7 +1137,7 @@ else version (DragonFlyBSD)
     }
     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
     int pthread_getconcurrency();
     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
@@ -1154,7 +1155,7 @@ else version (Solaris)
 
     enum PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL;
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
     int pthread_getconcurrency();
     int pthread_mutexattr_gettype(pthread_mutexattr_t*, int*);
@@ -1168,9 +1169,9 @@ else version (CRuntime_Bionic)
     enum PTHREAD_MUTEX_ERRORCHECK = 2;
     enum PTHREAD_MUTEX_DEFAULT    = PTHREAD_MUTEX_NORMAL;
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
-    int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
 }
 else version (CRuntime_Musl)
@@ -1198,10 +1199,10 @@ else version (CRuntime_UClibc)
       PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
     }
 
-    int pthread_attr_getguardsize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getguardsize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setguardsize(pthread_attr_t*, size_t);
     int pthread_getconcurrency();
-    int pthread_mutexattr_gettype(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_gettype(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_settype(pthread_mutexattr_t*, int) @trusted;
     int pthread_setconcurrency(int);
 }
@@ -1263,69 +1264,69 @@ else
 // Timeouts (TMO)
 //
 /*
-int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 */
 
 version (CRuntime_Glibc)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (Darwin)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (FreeBSD)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (NetBSD)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (OpenBSD)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (DragonFlyBSD)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (Solaris)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (CRuntime_Bionic)
 {
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (CRuntime_Musl)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else version (CRuntime_UClibc)
 {
-    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
+    int pthread_mutex_timedlock(pthread_mutex_t*, const scope timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, const scope timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, const scope timespec*);
 }
 else
 {
@@ -1340,10 +1341,10 @@ PTHREAD_PRIO_INHERIT (TPI)
 PTHREAD_PRIO_NONE (TPP|TPI)
 PTHREAD_PRIO_PROTECT (TPI)
 
-int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*); (TPP)
+int pthread_mutex_getprioceiling(const scope pthread_mutex_t*, int*); (TPP)
 int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*); (TPP)
 int pthread_mutexattr_getprioceiling(pthread_mutexattr_t*, int*); (TPP)
-int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*); (TPI|TPP)
+int pthread_mutexattr_getprotocol(const scope pthread_mutexattr_t*, int*); (TPI|TPP)
 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int); (TPP)
 int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int); (TPI|TPP)
 */
@@ -1356,10 +1357,10 @@ version (Darwin)
         PTHREAD_PRIO_PROTECT
     }
 
-    int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*);
+    int pthread_mutex_getprioceiling(const scope pthread_mutex_t*, int*);
     int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*);
-    int pthread_mutexattr_getprioceiling(in pthread_mutexattr_t*, int*);
-    int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getprioceiling(const scope pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getprotocol(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int);
     int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int);
 }
@@ -1372,10 +1373,10 @@ else version (Solaris)
         PTHREAD_PRIO_PROTECT = 0x20,
     }
 
-    int pthread_mutex_getprioceiling(in pthread_mutex_t*, int*);
+    int pthread_mutex_getprioceiling(const scope pthread_mutex_t*, int*);
     int pthread_mutex_setprioceiling(pthread_mutex_t*, int, int*);
-    int pthread_mutexattr_getprioceiling(in pthread_mutexattr_t*, int*);
-    int pthread_mutexattr_getprotocol(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getprioceiling(const scope pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getprotocol(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setprioceiling(pthread_mutexattr_t*, int);
     int pthread_mutexattr_setprotocol(pthread_mutexattr_t*, int);
 }
@@ -1387,14 +1388,14 @@ else version (Solaris)
 PTHREAD_SCOPE_PROCESS
 PTHREAD_SCOPE_SYSTEM
 
-int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-int pthread_attr_getscope(in pthread_attr_t*, int*);
+int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+int pthread_attr_getscope(const scope pthread_attr_t*, int*);
 int pthread_attr_setinheritsched(pthread_attr_t*, int);
 int pthread_attr_setschedpolicy(pthread_attr_t*, int);
 int pthread_attr_setscope(pthread_attr_t*, int);
 int pthread_getschedparam(pthread_t, int*, sched_param*);
-int pthread_setschedparam(pthread_t, int, in sched_param*);
+int pthread_setschedparam(pthread_t, int, const scope sched_param*);
 int pthread_setschedprio(pthread_t, int);
 */
 
@@ -1406,14 +1407,14 @@ version (CRuntime_Glibc)
         PTHREAD_SCOPE_PROCESS
     }
 
-    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*, int*);
     int pthread_attr_setinheritsched(pthread_attr_t*, int);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
     int pthread_attr_setscope(pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
-    int pthread_setschedparam(pthread_t, int, in sched_param*);
+    int pthread_setschedparam(pthread_t, int, const scope sched_param*);
     int pthread_setschedprio(pthread_t, int);
 }
 else version (Darwin)
@@ -1424,14 +1425,14 @@ else version (Darwin)
         PTHREAD_SCOPE_PROCESS   = 2
     }
 
-    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*, int*);
     int pthread_attr_setinheritsched(pthread_attr_t*, int);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
     int pthread_attr_setscope(pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
-    int pthread_setschedparam(pthread_t, int, in sched_param*);
+    int pthread_setschedparam(pthread_t, int, const scope sched_param*);
     // int pthread_setschedprio(pthread_t, int); // not implemented
 }
 else version (FreeBSD)
@@ -1442,12 +1443,12 @@ else version (FreeBSD)
         PTHREAD_SCOPE_SYSTEM    = 0x2
     }
 
-    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*, int*);
     int pthread_attr_setinheritsched(pthread_attr_t*, int);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
-    int pthread_attr_setscope(in pthread_attr_t*, int);
+    int pthread_attr_setscope(const scope pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
     int pthread_setschedparam(pthread_t, int, sched_param*);
     // int pthread_setschedprio(pthread_t, int); // not implemented
@@ -1460,12 +1461,12 @@ else version (NetBSD)
         PTHREAD_SCOPE_SYSTEM    = 0x1
     }
 
-    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*, int*);
     int pthread_attr_setinheritsched(pthread_attr_t*, int);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
-    int pthread_attr_setscope(in pthread_attr_t*, int);
+    int pthread_attr_setscope(const scope pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
     int pthread_setschedparam(pthread_t, int, sched_param*);
     //int pthread_setschedprio(pthread_t, int);
@@ -1478,12 +1479,12 @@ else version (OpenBSD)
         PTHREAD_SCOPE_SYSTEM    = 0x2
     }
 
-    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*, int*);
     int pthread_attr_setinheritsched(pthread_attr_t*, int);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
-    int pthread_attr_setscope(in pthread_attr_t*, int);
+    int pthread_attr_setscope(const scope pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
     int pthread_setschedparam(pthread_t, int, sched_param*);
     // int pthread_setschedprio(pthread_t, int); // not implemented
@@ -1496,12 +1497,12 @@ else version (DragonFlyBSD)
         PTHREAD_SCOPE_SYSTEM    = 0x2
     }
 
-    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*, int*);
     int pthread_attr_setinheritsched(pthread_attr_t*, int);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
-    int pthread_attr_setscope(in pthread_attr_t*, int);
+    int pthread_attr_setscope(const scope pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
     int pthread_setschedparam(pthread_t, int, sched_param*);
 }
@@ -1513,12 +1514,12 @@ else version (Solaris)
         PTHREAD_SCOPE_SYSTEM = 1,
     }
 
-    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*, int*);
     int pthread_attr_setinheritsched(pthread_attr_t*, int);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
-    int pthread_attr_setscope(in pthread_attr_t*, int);
+    int pthread_attr_setscope(const scope pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
     int pthread_setschedparam(pthread_t, int, sched_param*);
     int pthread_setschedprio(pthread_t, int);
@@ -1531,12 +1532,12 @@ else version (CRuntime_Bionic)
         PTHREAD_SCOPE_PROCESS
     }
 
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
     int pthread_attr_setscope(pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
-    int pthread_setschedparam(pthread_t, int, in sched_param*);
+    int pthread_setschedparam(pthread_t, int, const scope sched_param*);
 }
 else version (CRuntime_Musl)
 {
@@ -1547,7 +1548,7 @@ else version (CRuntime_Musl)
     }
 
     int pthread_getschedparam(pthread_t, int*, sched_param*);
-    int pthread_setschedparam(pthread_t, int, in sched_param*);
+    int pthread_setschedparam(pthread_t, int, const scope sched_param*);
     int pthread_setschedprio(pthread_t, int);
 }
 else version (CRuntime_UClibc)
@@ -1558,14 +1559,14 @@ else version (CRuntime_UClibc)
         PTHREAD_SCOPE_PROCESS
     }
 
-    int pthread_attr_getinheritsched(in pthread_attr_t*, int*);
-    int pthread_attr_getschedpolicy(in pthread_attr_t*, int*);
-    int pthread_attr_getscope(in pthread_attr_t*, int*);
+    int pthread_attr_getinheritsched(const scope pthread_attr_t*, int*);
+    int pthread_attr_getschedpolicy(const scope pthread_attr_t*, int*);
+    int pthread_attr_getscope(const scope pthread_attr_t*, int*);
     int pthread_attr_setinheritsched(pthread_attr_t*, int);
     int pthread_attr_setschedpolicy(pthread_attr_t*, int);
     int pthread_attr_setscope(pthread_attr_t*, int);
     int pthread_getschedparam(pthread_t, int*, sched_param*);
-    int pthread_setschedparam(pthread_t, int, in sched_param*);
+    int pthread_setschedparam(pthread_t, int, const scope sched_param*);
     int pthread_setschedprio(pthread_t, int);
 }
 else
@@ -1577,9 +1578,9 @@ else
 // Stack (TSA|TSS)
 //
 /*
-int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*); (TSA|TSS)
-int pthread_attr_getstackaddr(in pthread_attr_t*, void**); (TSA)
-int pthread_attr_getstacksize(in pthread_attr_t*, size_t*); (TSS)
+int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*); (TSA|TSS)
+int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**); (TSA)
+int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*); (TSS)
 int pthread_attr_setstack(pthread_attr_t*, void*, size_t); (TSA|TSS)
 int pthread_attr_setstackaddr(pthread_attr_t*, void*); (TSA)
 int pthread_attr_setstacksize(pthread_attr_t*, size_t); (TSS)
@@ -1587,86 +1588,86 @@ int pthread_attr_setstacksize(pthread_attr_t*, size_t); (TSS)
 
 version (CRuntime_Glibc)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (Darwin)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (FreeBSD)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (NetBSD)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (OpenBSD)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (DragonFlyBSD)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (Solaris)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (CRuntime_Bionic)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (CRuntime_Musl)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
 else version (CRuntime_UClibc)
 {
-    int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
-    int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
-    int pthread_attr_getstacksize(in pthread_attr_t*, size_t*);
+    int pthread_attr_getstack(const scope pthread_attr_t*, void**, size_t*);
+    int pthread_attr_getstackaddr(const scope pthread_attr_t*, void**);
+    int pthread_attr_getstacksize(const scope pthread_attr_t*, size_t*);
     int pthread_attr_setstack(pthread_attr_t*, void*, size_t);
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
@@ -1680,39 +1681,39 @@ else
 // Shared Synchronization (TSH)
 //
 /*
-int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
 int pthread_condattr_setpshared(pthread_condattr_t*, int);
-int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
 int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 */
 
 version (CRuntime_Glibc)
 {
-    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
     int pthread_condattr_setpshared(pthread_condattr_t*, int);
-    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
 else version (FreeBSD)
 {
-    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
     int pthread_condattr_setpshared(pthread_condattr_t*, int);
-    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
 else version (NetBSD)
 {
-    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
     int pthread_condattr_setpshared(pthread_condattr_t*, int);
-    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
 else version (OpenBSD)
@@ -1720,29 +1721,29 @@ else version (OpenBSD)
 }
 else version (DragonFlyBSD)
 {
-    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
     int pthread_condattr_setpshared(pthread_condattr_t*, int);
-    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
 else version (Darwin)
 {
-    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
     int pthread_condattr_setpshared(pthread_condattr_t*, int);
-    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
 else version (Solaris)
 {
-    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
     int pthread_condattr_setpshared(pthread_condattr_t*, int);
-    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
 else version (CRuntime_Bionic)
@@ -1765,11 +1766,11 @@ else version (CRuntime_Musl)
 }
 else version (CRuntime_UClibc)
 {
-    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
+    int pthread_condattr_getpshared(const scope pthread_condattr_t*, int*);
     int pthread_condattr_setpshared(pthread_condattr_t*, int);
-    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_getpshared(const scope pthread_mutexattr_t*, int*);
     int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_getpshared(const scope pthread_rwlockattr_t*, int*);
     int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
 else
diff --git a/libphobos/libdruntime/core/sys/posix/pwd.d b/libphobos/libdruntime/core/sys/posix/pwd.d
index 9d9aaa3b361..e7ddda79973 100644
--- a/libphobos/libdruntime/core/sys/posix/pwd.d
+++ b/libphobos/libdruntime/core/sys/posix/pwd.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.pwd;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types; // for gid_t, uid_t
 
 version (OSX)
@@ -30,6 +30,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // Required
@@ -44,7 +45,7 @@ struct passwd
     char*   pw_shell;
 }
 
-passwd* getpwnam(in char*);
+passwd* getpwnam(const scope char*);
 passwd* getpwuid(uid_t);
 */
 
@@ -201,47 +202,47 @@ else
     static assert(false, "Unsupported platform");
 }
 
-passwd* getpwnam(in char*);
+passwd* getpwnam(const scope char*);
 passwd* getpwuid(uid_t);
 
 //
 // Thread-Safe Functions (TSF)
 //
 /*
-int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
 int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 */
 
 version (CRuntime_Glibc)
 {
-    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else version (Darwin)
 {
-    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else version (FreeBSD)
 {
-    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else version (NetBSD)
 {
-    int __getpwnam_r50(in char*, passwd*, char*, size_t, passwd**);
+    int __getpwnam_r50(const scope char*, passwd*, char*, size_t, passwd**);
     alias __getpwnam_r50 getpwnam_r;
     int __getpwuid_r50(uid_t, passwd*, char*, size_t, passwd**);
     alias __getpwuid_r50 getpwuid_r;
 }
 else version (OpenBSD)
 {
-    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else version (DragonFlyBSD)
 {
-    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else version (Solaris)
@@ -250,7 +251,7 @@ else version (Solaris)
     alias getpwuid_r = __posix_getpwuid_r;
 
     // POSIX.1c standard version of the functions
-    int __posix_getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int __posix_getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
     int __posix_getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else version (CRuntime_Bionic)
@@ -258,12 +259,12 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else version (CRuntime_UClibc)
 {
-    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwnam_r(const scope char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else
diff --git a/libphobos/libdruntime/core/sys/posix/sched.d b/libphobos/libdruntime/core/sys/posix/sched.d
index 9cf80bd7cf3..f9d286217fb 100644
--- a/libphobos/libdruntime/core/sys/posix/sched.d
+++ b/libphobos/libdruntime/core/sys/posix/sched.d
@@ -15,7 +15,7 @@
  */
 module core.sys.posix.sched;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.time;
 public import core.sys.posix.sys.types;
 
@@ -32,6 +32,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // Required
@@ -53,8 +54,8 @@ SCHED_OTHER
 
 int sched_getparam(pid_t, sched_param*);
 int sched_getscheduler(pid_t);
-int sched_setparam(pid_t, in sched_param*);
-int sched_setscheduler(pid_t, int, in sched_param*);
+int sched_setparam(pid_t, const scope sched_param*);
+int sched_setscheduler(pid_t, int, const scope sched_param*);
 */
 
 version (CRuntime_Glibc)
@@ -189,8 +190,8 @@ else
 
 int sched_getparam(pid_t, sched_param*);
 int sched_getscheduler(pid_t);
-int sched_setparam(pid_t, in sched_param*);
-int sched_setscheduler(pid_t, int, in sched_param*);
+int sched_setparam(pid_t, const scope sched_param*);
+int sched_setscheduler(pid_t, int, const scope sched_param*);
 
 //
 // Thread (THR)
diff --git a/libphobos/libdruntime/core/sys/posix/semaphore.d b/libphobos/libdruntime/core/sys/posix/semaphore.d
index cae47773989..4f6f63988ff 100644
--- a/libphobos/libdruntime/core/sys/posix/semaphore.d
+++ b/libphobos/libdruntime/core/sys/posix/semaphore.d
@@ -14,8 +14,8 @@
  */
 module core.sys.posix.semaphore;
 
-private import core.sys.posix.config;
-private import core.sys.posix.time;
+import core.sys.posix.config;
+import core.sys.posix.time;
 
 version (OSX)
     version = Darwin;
@@ -30,6 +30,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // Required
@@ -42,10 +43,10 @@ int sem_close(sem_t*);
 int sem_destroy(sem_t*);
 int sem_getvalue(sem_t*, int*);
 int sem_init(sem_t*, int, uint);
-sem_t* sem_open(in char*, int, ...);
+sem_t* sem_open(const scope char*, int, ...);
 int sem_post(sem_t*);
 int sem_trywait(sem_t*);
-int sem_unlink(in char*);
+int sem_unlink(const scope char*);
 int sem_wait(sem_t*);
 */
 
@@ -169,58 +170,58 @@ int sem_close(sem_t*);
 int sem_destroy(sem_t*);
 int sem_getvalue(sem_t*, int*);
 int sem_init(sem_t*, int, uint);
-sem_t* sem_open(in char*, int, ...);
+sem_t* sem_open(const scope char*, int, ...);
 int sem_post(sem_t*);
 int sem_trywait(sem_t*);
-int sem_unlink(in char*);
+int sem_unlink(const scope char*);
 int sem_wait(sem_t*);
 
 //
 // Timeouts (TMO)
 //
 /*
-int sem_timedwait(sem_t*, in timespec*);
+int sem_timedwait(sem_t*, const scope timespec*);
 */
 
 version (CRuntime_Glibc)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (Darwin)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (FreeBSD)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (NetBSD)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (OpenBSD)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (DragonFlyBSD)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (Solaris)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (CRuntime_Bionic)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (CRuntime_Musl)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else version (CRuntime_UClibc)
 {
-    int sem_timedwait(sem_t*, in timespec*);
+    int sem_timedwait(sem_t*, const scope timespec*);
 }
 else
 {
diff --git a/libphobos/libdruntime/core/sys/posix/setjmp.d b/libphobos/libdruntime/core/sys/posix/setjmp.d
index 38d4f7086f2..b98d321a883 100644
--- a/libphobos/libdruntime/core/sys/posix/setjmp.d
+++ b/libphobos/libdruntime/core/sys/posix/setjmp.d
@@ -14,11 +14,12 @@
  */
 module core.sys.posix.setjmp;
 
-private import core.sys.posix.config;
-private import core.sys.posix.signal; // for sigset_t
+import core.sys.posix.config;
+import core.sys.posix.signal; // for sigset_t
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 version (RISCV32) version = RISCV_Any;
 version (RISCV64) version = RISCV_Any;
@@ -151,7 +152,8 @@ version (CRuntime_Glibc)
             c_long __pc;
             c_long[12] __regs;
             c_long __sp;
-            double[12] __fpregs;
+            static if (__traits(getTargetInfo, "floatAbi") == "double")
+                double[12] __fpregs;
         }
         alias __jmp_buf = __riscv_jmp_buf[1];
     }
@@ -210,7 +212,7 @@ else version (FreeBSD)
     {
         enum _JBLEN = 31;
         // __int128_t
-        struct _jmp_buf { long[2][_JBLEN + 1] _jb; };
+        struct _jmp_buf { long[2][_JBLEN + 1] _jb; }
     }
     else version (PPC_Any)
     {
@@ -362,7 +364,7 @@ else version (CRuntime_UClibc)
                 double[8] __fpregs;
             else
                 double[6] __fpregs;
-        };
+        }
     }
     else
         static assert(0, "unimplemented");
@@ -422,7 +424,7 @@ else version (FreeBSD)
     else version (AArch64)
     {
         // __int128_t
-        struct _sigjmp_buf { long[2][_JBLEN + 1] _jb; };
+        struct _sigjmp_buf { long[2][_JBLEN + 1] _jb; }
     }
     else version (PPC_Any)
     {
diff --git a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d
index 9a97709b473..44f45f2e0c3 100644
--- a/libphobos/libdruntime/core/sys/posix/signal.d
+++ b/libphobos/libdruntime/core/sys/posix/signal.d
@@ -11,7 +11,7 @@
 
 module core.sys.posix.signal;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.stdc.signal;
 public import core.sys.posix.sys.types; // for pid_t
 //public import core.sys.posix.time;      // for timespec, now defined here
@@ -43,7 +43,8 @@ version (X86_64)  version = X86_Any;
 
 version (Posix):
 extern (C):
-//nothrow:  // this causes Issue 12738
+//nothrow:  // this causes http://issues.dlang.org/show_bug.cgi?id=12738 (which has been fixed)
+//@system:
 
 //
 // Required
@@ -150,30 +151,6 @@ version (Solaris)
         return sig;
     }
 }
-else version (CRuntime_Glibc)
-{
-    private extern (C) nothrow @nogc
-    {
-        int __libc_current_sigrtmin();
-        int __libc_current_sigrtmax();
-    }
-
-    @property int SIGRTMIN() nothrow @nogc {
-        __gshared static int sig = -1;
-        if (sig == -1) {
-            sig = __libc_current_sigrtmin();
-        }
-        return sig;
-    }
-
-    @property int SIGRTMAX() nothrow @nogc {
-        __gshared static int sig = -1;
-        if (sig == -1) {
-            sig = __libc_current_sigrtmax();
-        }
-        return sig;
-    }
-}
 else version (FreeBSD) {
     // Note: it appears that FreeBSD (prior to 7) and OSX do not support realtime signals
     // https://github.com/freebsd/freebsd/blob/e79c62ff68fc74d88cb6f479859f6fae9baa5101/sys/sys/signal.h#L117
@@ -189,9 +166,11 @@ else version (NetBSD)
     enum SIGRTMIN = 33;
     enum SIGRTMAX = 63;
 }
-else version (CRuntime_Bionic)
+else version (linux)
 {
-    // Switched to calling these functions since Lollipop
+    // Note: CRuntime_Bionic switched to calling these functions
+    // since Lollipop, and Glibc, UClib and Musl all implement them
+    // the same way since it's part of LSB.
     private extern (C) nothrow @nogc
     {
         int __libc_current_sigrtmin();
@@ -214,24 +193,6 @@ else version (CRuntime_Bionic)
         return sig;
     }
 }
-else version (CRuntime_UClibc)
-{
-    private extern (C) nothrow @nogc
-    {
-        int __libc_current_sigrtmin();
-        int __libc_current_sigrtmax();
-    }
-
-    @property int SIGRTMIN() nothrow @nogc
-    {
-        return __libc_current_sigrtmin();
-    }
-
-    @property int SIGRTMAX() nothrow @nogc
-    {
-        return __libc_current_sigrtmax();
-    }
-}
 
 version (linux)
 {
@@ -874,16 +835,16 @@ SI_ASYNCIO
 SI_MESGQ
 
 int kill(pid_t, int);
-int sigaction(int, in sigaction_t*, sigaction_t*);
+int sigaction(int, const scope sigaction_t*, sigaction_t*);
 int sigaddset(sigset_t*, int);
 int sigdelset(sigset_t*, int);
 int sigemptyset(sigset_t*);
 int sigfillset(sigset_t*);
-int sigismember(in sigset_t*, int);
+int sigismember(const scope sigset_t*, int);
 int sigpending(sigset_t*);
-int sigprocmask(int, in sigset_t*, sigset_t*);
-int sigsuspend(in sigset_t*);
-int sigwait(in sigset_t*, int*);
+int sigprocmask(int, const scope sigset_t*, sigset_t*);
+int sigsuspend(const scope sigset_t*);
+int sigwait(const scope sigset_t*, int*);
 */
 
 nothrow @nogc
@@ -1007,16 +968,16 @@ version (CRuntime_Glibc)
     }
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t*);
     int sigfillset(sigset_t*);
-    int sigismember(in sigset_t*, int);
+    int sigismember(const scope sigset_t*, int);
     int sigpending(sigset_t*);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else version (Darwin)
 {
@@ -1059,16 +1020,16 @@ else version (Darwin)
     enum SI_MESGQ   = 0x10005;
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t*);
     int sigfillset(sigset_t*);
-    int sigismember(in sigset_t*, int);
+    int sigismember(const scope sigset_t*, int);
     int sigpending(sigset_t*);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else version (FreeBSD)
 {
@@ -1137,16 +1098,16 @@ else version (FreeBSD)
     enum SI_MESGQ   = 0x10005;
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t *);
     int sigfillset(sigset_t *);
-    int sigismember(in sigset_t*, int);
+    int sigismember(const scope sigset_t*, int);
     int sigpending(sigset_t *);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else version (NetBSD)
 {
@@ -1223,16 +1184,16 @@ else version (NetBSD)
     enum SI_MESGQ   = -4;
 
     int kill(pid_t, int);
-    int __sigaction14(int, in sigaction_t*, sigaction_t*);
+    int __sigaction14(int, const scope sigaction_t*, sigaction_t*);
     int __sigaddset14(sigset_t*, int);
     int __sigdelset14(sigset_t*, int);
     int __sigemptyset14(sigset_t *);
     int __sigfillset14(sigset_t *);
-    int __sigismember14(in sigset_t*, int);
+    int __sigismember14(const scope sigset_t*, int);
     int __sigpending14(sigset_t *);
-    int __sigprocmask14(int, in sigset_t*, sigset_t*);
-    int __sigsuspend14(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int __sigprocmask14(int, const scope sigset_t*, sigset_t*);
+    int __sigsuspend14(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 
     alias __sigaction14 sigaction;
     alias __sigaddset14 sigaddset;
@@ -1309,16 +1270,16 @@ else version (OpenBSD)
     enum SI_TIMER  = -3;
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t *);
     int sigfillset(sigset_t *);
-    int sigismember(in sigset_t*, int);
+    int sigismember(const scope sigset_t*, int);
     int sigpending(sigset_t *);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else version (DragonFlyBSD)
 {
@@ -1358,16 +1319,16 @@ else version (DragonFlyBSD)
     enum SI_MESGQ     = -4;
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t *);
     int sigfillset(sigset_t *);
-    int sigismember(in sigset_t*, int);
+    int sigismember(const scope sigset_t*, int);
     int sigpending(sigset_t *);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else version (Solaris)
 {
@@ -1467,21 +1428,21 @@ else version (Solaris)
     }
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t*);
     int sigfillset(sigset_t*);
-    int sigismember(in sigset_t*, int);
+    int sigismember(const scope sigset_t*, int);
     int sigpending(sigset_t*);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else version (CRuntime_Bionic)
 {
     public import core.sys.posix.time: timer_t;
-    private import core.stdc.string : memset;
+    import core.stdc.string : memset;
 
     version (X86)
     {
@@ -1581,7 +1542,7 @@ else version (CRuntime_Bionic)
     }
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
 
     // These functions are defined inline in bionic.
     int sigaddset(sigset_t* set, int signum)
@@ -1612,9 +1573,9 @@ else version (CRuntime_Bionic)
     }
 
     int sigpending(sigset_t*);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else version (CRuntime_Musl)
 {
@@ -1724,16 +1685,16 @@ else version (CRuntime_Musl)
     }
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t*);
     int sigfillset(sigset_t*);
-    int sigismember(in sigset_t*, int);
+    int sigismember(const scope sigset_t*, int);
     int sigpending(sigset_t*);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else version (CRuntime_UClibc)
 {
@@ -1967,16 +1928,16 @@ else version (CRuntime_UClibc)
     }
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, const scope sigaction_t*, sigaction_t*);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t*);
     int sigfillset(sigset_t*);
-    int sigismember(in sigset_t*, int);
+    int sigismember(const scope sigset_t*, int);
     int sigpending(sigset_t*);
-    int sigprocmask(int, in sigset_t*, sigset_t*);
-    int sigsuspend(in sigset_t*);
-    int sigwait(in sigset_t*, int*);
+    int sigprocmask(int, const scope sigset_t*, sigset_t*);
+    int sigsuspend(const scope sigset_t*);
+    int sigwait(const scope sigset_t*, int*);
 }
 else
 {
@@ -2069,7 +2030,7 @@ sigfn_t bsd_signal(int sig, sigfn_t func);
 sigfn_t sigset(int sig, sigfn_t func);
 
 int killpg(pid_t, int);
-int sigaltstack(in stack_t*, stack_t*);
+int sigaltstack(const scope stack_t*, stack_t*);
 int sighold(int);
 int sigignore(int);
 int siginterrupt(int, int);
@@ -2261,7 +2222,7 @@ version (CRuntime_Glibc)
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int sighold(int);
     int sigignore(int);
     int siginterrupt(int, int);
@@ -2371,7 +2332,7 @@ else version (Darwin)
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int sighold(int);
     int sigignore(int);
     int siginterrupt(int, int);
@@ -2406,7 +2367,7 @@ else version (FreeBSD)
 
     enum MINSIGSTKSZ = 512 * 4;
     enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
-;
+
     //ucontext_t (defined in core.sys.posix.ucontext)
     //mcontext_t (defined in core.sys.posix.ucontext)
 
@@ -2495,7 +2456,7 @@ else version (FreeBSD)
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int sighold(int);
     int sigignore(int);
     int siginterrupt(int, int);
@@ -2530,7 +2491,7 @@ else version (NetBSD)
 
     enum MINSIGSTKSZ = 8192;
     enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
-;
+
     //ucontext_t (defined in core.sys.posix.ucontext)
     //mcontext_t (defined in core.sys.posix.ucontext)
 
@@ -2619,7 +2580,7 @@ else version (NetBSD)
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int sighold(int);
     int sigignore(int);
     int siginterrupt(int, int);
@@ -2738,7 +2699,7 @@ else version (OpenBSD)
   nothrow:
   @nogc:
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int siginterrupt(int, int);
     int sigpause(int);
 }
@@ -2770,7 +2731,7 @@ else version (DragonFlyBSD)
 
     enum MINSIGSTKSZ = 8192;
     enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
-;
+
     //ucontext_t (defined in core.sys.posix.ucontext)
     //mcontext_t (defined in core.sys.posix.ucontext)
 
@@ -2859,7 +2820,7 @@ else version (DragonFlyBSD)
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int sighold(int);
     int sigignore(int);
     int siginterrupt(int, int);
@@ -2983,7 +2944,7 @@ else version (Solaris)
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int sighold(int);
     int sigignore(int);
     int siginterrupt(int, int);
@@ -3088,7 +3049,7 @@ else version (CRuntime_Bionic)
     sigfn_t2 bsd_signal(int, sigfn_t2);
 
     int killpg(int, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int siginterrupt(int, int);
 }
 else version (CRuntime_Musl)
@@ -3258,7 +3219,7 @@ else version (CRuntime_Musl)
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int sighold(int);
     int sigignore(int);
     int siginterrupt(int, int);
@@ -3440,7 +3401,7 @@ else version (CRuntime_UClibc)
     sigfn_t2 sigset(int sig, sigfn_t2 func);
 
     int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
+    int sigaltstack(const scope stack_t*, stack_t*);
     int sighold(int);
     int sigignore(int);
     int siginterrupt(int, int);
@@ -3543,8 +3504,8 @@ struct sigevent
 }
 
 int sigqueue(pid_t, int, in sigval);
-int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
-int sigwaitinfo(in sigset_t*, siginfo_t*);
+int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 */
 
 nothrow:
@@ -3583,8 +3544,8 @@ version (CRuntime_Glibc)
     }
 
     int sigqueue(pid_t, int, in sigval);
-    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
-    int sigwaitinfo(in sigset_t*, siginfo_t*);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (FreeBSD)
 {
@@ -3606,8 +3567,8 @@ else version (FreeBSD)
     }
 
     int sigqueue(pid_t, int, in sigval);
-    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
-    int sigwaitinfo(in sigset_t*, siginfo_t*);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (NetBSD)
 {
@@ -3621,8 +3582,8 @@ else version (NetBSD)
     }
 
     int sigqueue(pid_t, int, in sigval);
-    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
-    int sigwaitinfo(in sigset_t*, siginfo_t*);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (OpenBSD)
 {
@@ -3636,14 +3597,14 @@ else version (DragonFlyBSD)
         int                       sigev_signo;
         int                       sigev_notify_kqueue;
         void /*pthread_attr_t*/ * sigev_notify_attributes;
-    };
+    }
     union _sigval_t
     {
         int                       sival_int;
         void                    * sival_ptr;
         int                       sigval_int;
         void                    * sigval_ptr;
-    };
+    }
     struct sigevent
     {
         int                       sigev_notify;
@@ -3653,8 +3614,8 @@ else version (DragonFlyBSD)
     }
 
     int sigqueue(pid_t, int, in sigval);
-    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
-    int sigwaitinfo(in sigset_t*, siginfo_t*);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (Darwin)
 {
@@ -3680,8 +3641,8 @@ else version (Solaris)
     }
 
     int sigqueue(pid_t, int, in sigval);
-    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
-    int sigwaitinfo(in sigset_t*, siginfo_t*);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else version (CRuntime_Bionic)
 {
@@ -3757,8 +3718,8 @@ else version (CRuntime_UClibc)
     @property void* sigev_notify_attributes(ref sigevent _sigevent) { return  _sigevent._sigev_un._sigev_thread._attribute; }
 
     int sigqueue(pid_t, int, in sigval);
-    int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
-    int sigwaitinfo(in sigset_t*, siginfo_t*);
+    int sigtimedwait(const scope sigset_t*, siginfo_t*, const scope timespec*);
+    int sigwaitinfo(const scope sigset_t*, siginfo_t*);
 }
 else
 {
@@ -3770,58 +3731,58 @@ else
 //
 /*
 int pthread_kill(pthread_t, int);
-int pthread_sigmask(int, in sigset_t*, sigset_t*);
+int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 */
 
 version (CRuntime_Glibc)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (Darwin)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (FreeBSD)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (NetBSD)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (OpenBSD)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (DragonFlyBSD)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (Solaris)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (CRuntime_Bionic)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (CRuntime_Musl)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
 }
 else version (CRuntime_UClibc)
 {
     int pthread_kill(pthread_t, int);
-    int pthread_sigmask(int, in sigset_t*, sigset_t*);
+    int pthread_sigmask(int, const scope sigset_t*, sigset_t*);
     int pthread_sigqueue(pthread_t, int, sigval);
 }
 else
diff --git a/libphobos/libdruntime/core/sys/posix/spawn.d b/libphobos/libdruntime/core/sys/posix/spawn.d
index aa59c2f0bf0..86b17517335 100644
--- a/libphobos/libdruntime/core/sys/posix/spawn.d
+++ b/libphobos/libdruntime/core/sys/posix/spawn.d
@@ -49,6 +49,7 @@ public import core.sys.posix.sched : sched_param;
 extern(C):
 @nogc:
 nothrow:
+@system:
 
 int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t*, int);
 int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t*, int, int);
diff --git a/libphobos/libdruntime/core/sys/posix/stdc/time.d b/libphobos/libdruntime/core/sys/posix/stdc/time.d
new file mode 100644
index 00000000000..89029de09a8
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/stdc/time.d
@@ -0,0 +1,191 @@
+/**
+ * D header file for C99.
+ *
+ * $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_time.h.html, _time.h)
+ *
+ * Copyright: Copyright Sean Kelly 2005 - 2009.
+ * License: Distributed under the
+ *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
+ *    (See accompanying file LICENSE)
+ * Authors:   Sean Kelly,
+ *            Alex Rønne Petersen
+ * Source:    $(DRUNTIMESRC core/stdc/_time.d)
+ * Standards: ISO/IEC 9899:1999 (E)
+ */
+
+module core.sys.posix.stdc.time;
+
+version (Posix):
+
+import core.stdc.config;
+
+version (OSX)
+    version = Darwin;
+else version (iOS)
+    version = Darwin;
+else version (TVOS)
+    version = Darwin;
+else version (WatchOS)
+    version = Darwin;
+
+extern (C):
+@trusted: // There are only a few functions here that use unsafe C strings.
+nothrow:
+@nogc:
+
+///
+struct tm
+{
+    int     tm_sec;     /// seconds after the minute [0-60]
+    int     tm_min;     /// minutes after the hour [0-59]
+    int     tm_hour;    /// hours since midnight [0-23]
+    int     tm_mday;    /// day of the month [1-31]
+    int     tm_mon;     /// months since January [0-11]
+    int     tm_year;    /// years since 1900
+    int     tm_wday;    /// days since Sunday [0-6]
+    int     tm_yday;    /// days since January 1 [0-365]
+    int     tm_isdst;   /// Daylight Savings Time flag
+    c_long  tm_gmtoff;  /// offset from CUT in seconds
+    char*   tm_zone;    /// timezone abbreviation
+}
+
+public import core.sys.posix.sys.types : time_t, clock_t;
+
+///
+version (OSX)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000; // was 100 until OSX 10.4/10.5
+    version (X86)
+        extern (C) pragma(mangle, "clock$UNIX2003") clock_t clock();
+    else
+        clock_t clock();
+}
+else version (Darwin) // other Darwins (iOS, TVOS, WatchOS)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (FreeBSD)
+{
+    enum clock_t CLOCKS_PER_SEC = 128;
+    clock_t clock();
+}
+else version (NetBSD)
+{
+    enum clock_t CLOCKS_PER_SEC = 100;
+    clock_t clock();
+}
+else version (OpenBSD)
+{
+    enum clock_t CLOCKS_PER_SEC = 100;
+    clock_t clock();
+}
+else version (DragonFlyBSD)
+{
+    enum clock_t CLOCKS_PER_SEC = 128;
+    clock_t clock();
+}
+else version (Solaris)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (CRuntime_Glibc)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (CRuntime_Musl)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (CRuntime_Bionic)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else version (CRuntime_UClibc)
+{
+    enum clock_t CLOCKS_PER_SEC = 1_000_000;
+    clock_t clock();
+}
+else
+{
+    static assert(0, "unsupported system");
+}
+
+version (Darwin)
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version (CRuntime_Glibc)
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version (FreeBSD)
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version (NetBSD)
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version (OpenBSD)
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version (DragonFlyBSD)
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version (Solaris)
+{
+    ///
+    void tzset();
+    ///
+    extern __gshared const(char)*[2] tzname;
+}
+else version (CRuntime_Bionic)
+{
+    ///
+    void tzset();
+    ///
+    extern __gshared const(char)*[2] tzname;
+}
+else version (CRuntime_Musl)
+{
+    ///
+    void tzset();                            // non-standard
+    ///
+    extern __gshared const(char)*[2] tzname; // non-standard
+}
+else version (CRuntime_UClibc)
+{
+    ///
+    void tzset();
+    ///
+    extern __gshared const(char)*[2] tzname;
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}
diff --git a/libphobos/libdruntime/core/sys/posix/stdio.d b/libphobos/libdruntime/core/sys/posix/stdio.d
index bc2329e6bf8..031bcb7341f 100644
--- a/libphobos/libdruntime/core/sys/posix/stdio.d
+++ b/libphobos/libdruntime/core/sys/posix/stdio.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.stdio;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.stdc.stdio;
 public import core.sys.posix.sys.types; // for off_t
 
@@ -32,6 +32,7 @@ extern (C):
 
 nothrow:
 @nogc:
+@system:
 
 //
 // Required (defined in core.stdc.stdio)
@@ -65,44 +66,44 @@ int    fflush(FILE*);
 int    fgetc(FILE*);
 int    fgetpos(FILE*, fpos_t *);
 char*  fgets(char*, int, FILE*);
-FILE*  fopen(in char*, in char*);
-int    fprintf(FILE*, in char*, ...);
+FILE*  fopen(const scope char*, const scope char*);
+int    fprintf(FILE*, const scope char*, ...);
 int    fputc(int, FILE*);
-int    fputs(in char*, FILE*);
+int    fputs(const scope char*, FILE*);
 size_t fread(void *, size_t, size_t, FILE*);
-FILE*  freopen(in char*, in char*, FILE*);
-int    fscanf(FILE*, in char*, ...);
+FILE*  freopen(const scope char*, const scope char*, FILE*);
+int    fscanf(FILE*, const scope char*, ...);
 int    fseek(FILE*, c_long, int);
-int    fsetpos(FILE*, in fpos_t*);
+int    fsetpos(FILE*, const scope fpos_t*);
 c_long ftell(FILE*);
 size_t fwrite(in void *, size_t, size_t, FILE*);
 int    getc(FILE*);
 int    getchar();
 char*  gets(char*);
-void   perror(in char*);
-int    printf(in char*, ...);
+void   perror(const scope char*);
+int    printf(const scope char*, ...);
 int    putc(int, FILE*);
 int    putchar(int);
-int    puts(in char*);
-int    remove(in char*);
-int    rename(in char*, in char*);
+int    puts(const scope char*);
+int    remove(const scope char*);
+int    rename(const scope char*, const scope char*);
 void   rewind(FILE*);
-int    scanf(in char*, ...);
+int    scanf(const scope char*, ...);
 void   setbuf(FILE*, char*);
 int    setvbuf(FILE*, char*, int, size_t);
-int    snprintf(char*, size_t, in char*, ...);
-int    sprintf(char*, in char*, ...);
-int    sscanf(in char*, in char*, int ...);
+int    snprintf(char*, size_t, const scope char*, ...);
+int    sprintf(char*, const scope char*, ...);
+int    sscanf(const scope char*, const scope char*, int ...);
 FILE*  tmpfile();
 char*  tmpnam(char*);
 int    ungetc(int, FILE*);
-int    vfprintf(FILE*, in char*, va_list);
-int    vfscanf(FILE*, in char*, va_list);
-int    vprintf(in char*, va_list);
-int    vscanf(in char*, va_list);
-int    vsnprintf(char*, size_t, in char*, va_list);
-int    vsprintf(char*, in char*, va_list);
-int    vsscanf(in char*, in char*, va_list arg);
+int    vfprintf(FILE*, const scope char*, va_list);
+int    vfscanf(FILE*, const scope char*, va_list);
+int    vprintf(const scope char*, va_list);
+int    vscanf(const scope char*, va_list);
+int    vsnprintf(char*, size_t, const scope char*, va_list);
+int    vsprintf(char*, const scope char*, va_list);
+int    vsscanf(const scope char*, const scope char*, va_list arg);
 */
 
 version (CRuntime_Glibc)
@@ -117,15 +118,15 @@ version (CRuntime_Glibc)
         int   fgetpos64(FILE*, fpos_t *);
         alias fgetpos64 fgetpos;
 
-        FILE* fopen64(in char*, in char*);
+        FILE* fopen64(const scope char*, const scope char*);
         alias fopen64 fopen;
 
-        FILE* freopen64(in char*, in char*, FILE*);
+        FILE* freopen64(const scope char*, const scope char*, FILE*);
         alias freopen64 freopen;
 
         int   fseek(FILE*, c_long, int);
 
-        int   fsetpos64(FILE*, in fpos_t*);
+        int   fsetpos64(FILE*, const scope fpos_t*);
         alias fsetpos64 fsetpos;
 
         FILE* tmpfile64();
@@ -134,20 +135,20 @@ version (CRuntime_Glibc)
     else
     {
         int   fgetpos(FILE*, fpos_t *);
-        FILE* fopen(in char*, in char*);
-        FILE* freopen(in char*, in char*, FILE*);
+        FILE* fopen(const scope char*, const scope char*);
+        FILE* freopen(const scope char*, const scope char*, FILE*);
         int   fseek(FILE*, c_long, int);
-        int   fsetpos(FILE*, in fpos_t*);
+        int   fsetpos(FILE*, const scope fpos_t*);
         FILE* tmpfile();
     }
 }
 else version (CRuntime_Bionic)
 {
     int   fgetpos(FILE*, fpos_t *);
-    FILE* fopen(in char*, in char*);
-    FILE* freopen(in char*, in char*, FILE*);
+    FILE* fopen(const scope char*, const scope char*);
+    FILE* freopen(const scope char*, const scope char*, FILE*);
     int   fseek(FILE*, c_long, int);
-    int   fsetpos(FILE*, in fpos_t*);
+    int   fsetpos(FILE*, const scope fpos_t*);
 }
 else version (CRuntime_UClibc)
 {
@@ -156,15 +157,15 @@ else version (CRuntime_UClibc)
         int   fgetpos64(FILE*, fpos_t *);
         alias fgetpos64 fgetpos;
 
-        FILE* fopen64(in char*, in char*);
+        FILE* fopen64(const scope char*, const scope char*);
         alias fopen64 fopen;
 
-        FILE* freopen64(in char*, in char*, FILE*);
+        FILE* freopen64(const scope char*, const scope char*, FILE*);
         alias freopen64 freopen;
 
         int   fseek(FILE*, c_long, int);
 
-        int   fsetpos64(FILE*, in fpos_t*);
+        int   fsetpos64(FILE*, const scope fpos_t*);
         alias fsetpos64 fsetpos;
 
         FILE* tmpfile64();
@@ -173,10 +174,10 @@ else version (CRuntime_UClibc)
     else
     {
         int   fgetpos(FILE*, fpos_t *);
-        FILE* fopen(in char*, in char*);
-        FILE* freopen(in char*, in char*, FILE*);
+        FILE* fopen(const scope char*, const scope char*);
+        FILE* freopen(const scope char*, const scope char*, FILE*);
         int   fseek(FILE*, c_long, int);
-        int   fsetpos(FILE*, in fpos_t*);
+        int   fsetpos(FILE*, const scope fpos_t*);
         FILE* tmpfile();
     }
 }
@@ -187,15 +188,15 @@ else version (CRuntime_Musl)
         int   fgetpos64(FILE*, fpos_t *);
         alias fgetpos64 fgetpos;
 
-        FILE* fopen64(in char*, in char*);
+        FILE* fopen64(const scope char*, const scope char*);
         alias fopen64 fopen;
 
-        FILE* freopen64(in char*, in char*, FILE*);
+        FILE* freopen64(const scope char*, const scope char*, FILE*);
         alias freopen64 freopen;
 
         int   fseek(FILE*, c_long, int);
 
-        int   fsetpos64(FILE*, in fpos_t*);
+        int   fsetpos64(FILE*, const scope fpos_t*);
         alias fsetpos64 fsetpos;
 
         FILE* tmpfile64();
@@ -204,10 +205,10 @@ else version (CRuntime_Musl)
     else
     {
         int   fgetpos(FILE*, fpos_t *);
-        FILE* fopen(in char*, in char*);
-        FILE* freopen(in char*, in char*, FILE*);
+        FILE* fopen(const scope char*, const scope char*);
+        FILE* freopen(const scope char*, const scope char*, FILE*);
         int   fseek(FILE*, c_long, int);
-        int   fsetpos(FILE*, in fpos_t*);
+        int   fsetpos(FILE*, const scope fpos_t*);
         FILE* tmpfile();
     }
 }
@@ -218,15 +219,15 @@ else version (Solaris)
         int   fgetpos64(FILE*, fpos_t *);
         alias fgetpos = fgetpos64;
 
-        FILE* fopen64(in char*, in char*);
+        FILE* fopen64(const scope char*, const scope char*);
         alias fopen = fopen64;
 
-        FILE* freopen64(in char*, in char*, FILE*);
+        FILE* freopen64(const scope char*, const scope char*, FILE*);
         alias freopen = freopen64;
 
         int   fseek(FILE*, c_long, int);
 
-        int   fsetpos64(FILE*, in fpos_t*);
+        int   fsetpos64(FILE*, const scope fpos_t*);
         alias fsetpos = fsetpos64;
 
         FILE* tmpfile64();
@@ -235,10 +236,10 @@ else version (Solaris)
     else
     {
         int   fgetpos(FILE*, fpos_t *);
-        FILE* fopen(in char*, in char*);
-        FILE* freopen(in char*, in char*, FILE*);
+        FILE* fopen(const scope char*, const scope char*);
+        FILE* freopen(const scope char*, const scope char*, FILE*);
         int   fseek(FILE*, c_long, int);
-        int   fsetpos(FILE*, in fpos_t*);
+        int   fsetpos(FILE*, const scope fpos_t*);
         FILE* tmpfile();
     }
 }
@@ -249,64 +250,72 @@ else version (Solaris)
 /*
 L_ctermid
 
-char*  ctermid(char*);
-FILE*  fdopen(int, in char*);
-int    fileno(FILE*);
-int    fseeko(FILE*, off_t, int);
-off_t  ftello(FILE*);
-char*  gets(char*);
-int    pclose(FILE*);
-FILE*  popen(in char*, in char*);
+char*   ctermid(char*);
+FILE*   fdopen(int, const scope char*);
+int     fileno(FILE*);
+int     fseeko(FILE*, off_t, int);
+off_t   ftello(FILE*);
+ssize_t getdelim(char**, size_t*, int, FILE*);
+ssize_t getline(char**, size_t*, FILE*);
+char*   gets(char*);
+int     pclose(FILE*);
+FILE*   popen(const scope char*, const scope char*);
 */
 
 version (CRuntime_Glibc)
 {
     enum L_ctermid = 9;
 
-  static if ( __USE_FILE_OFFSET64 )
-  {
-    int   fseeko64(FILE*, off_t, int);
-    alias fseeko64 fseeko;
-  }
-  else
-  {
-    int   fseeko(FILE*, off_t, int);
-  }
-
-  static if ( __USE_FILE_OFFSET64 )
-  {
-    off_t ftello64(FILE*);
-    alias ftello64 ftello;
-  }
-  else
-  {
-    off_t ftello(FILE*);
-  }
+    static if ( __USE_FILE_OFFSET64 )
+    {
+        int   fseeko64(FILE*, off_t, int);
+        alias fseeko64 fseeko;
+    }
+    else
+    {
+        int   fseeko(FILE*, off_t, int);
+    }
+
+    static if ( __USE_FILE_OFFSET64 )
+    {
+        off_t ftello64(FILE*);
+        alias ftello64 ftello;
+    }
+    else
+    {
+        off_t ftello(FILE*);
+    }
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
 }
 else version (CRuntime_UClibc)
 {
     enum L_ctermid = 9;
     enum L_cuserid = 9;
 
-  static if ( __USE_FILE_OFFSET64 )
-  {
-    int   fseeko64(FILE*, off_t, int);
-    alias fseeko64 fseeko;
-  }
-  else
-  {
-    int   fseeko(FILE*, off_t, int);
-  }
-
-  static if ( __USE_FILE_OFFSET64 )
-  {
-    off_t ftello64(FILE*);
-    alias ftello64 ftello;
-  }
-  else
-  {
-    off_t ftello(FILE*);
-  }
+    static if ( __USE_FILE_OFFSET64 )
+    {
+        int   fseeko64(FILE*, off_t, int);
+        alias fseeko64 fseeko;
+    }
+    else
+    {
+        int   fseeko(FILE*, off_t, int);
+    }
+
+    static if ( __USE_FILE_OFFSET64 )
+    {
+        off_t ftello64(FILE*);
+        alias ftello64 ftello;
+    }
+    else
+    {
+        off_t ftello(FILE*);
+    }
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
 }
 else version (CRuntime_Musl)
 {
@@ -331,6 +340,91 @@ else version (CRuntime_Musl)
     {
         off_t ftello(FILE*);
     }
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
+}
+else version (CRuntime_Bionic)
+{
+    enum L_ctermid = 1024;
+
+    static if ( __USE_FILE_OFFSET64 )
+    {
+        int   fseeko64(FILE*, off_t, int);
+        alias fseeko64 fseeko;
+    }
+    else
+    {
+        int   fseeko(FILE*, off_t, int);
+    }
+
+    static if ( __USE_FILE_OFFSET64 )
+    {
+        off_t ftello64(FILE*);
+        alias ftello64 ftello;
+    }
+    else
+    {
+        off_t ftello(FILE*);
+    }
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
+}
+else version (Darwin)
+{
+    enum L_ctermid = 1024;
+
+    int   fseeko(FILE*, off_t, int);
+    off_t ftello(FILE*);
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
+}
+else version (FreeBSD)
+{
+    import core.sys.freebsd.config;
+
+    enum L_ctermid = 1024;
+
+    int   fseeko(FILE*, off_t, int);
+    off_t ftello(FILE*);
+
+    static if (__FreeBSD_version >= 800000)
+    {
+        ssize_t getdelim(char**, size_t*, int, FILE*);
+        ssize_t getline(char**, size_t*, FILE*);
+    }
+}
+else version (NetBSD)
+{
+    enum L_ctermid = 1024;
+
+    int   fseeko(FILE*, off_t, int);
+    off_t ftello(FILE*);
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
+}
+else version (OpenBSD)
+{
+    enum L_ctermid = 1024;
+
+    int   fseeko(FILE*, off_t, int);
+    off_t ftello(FILE*);
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
+}
+else version (DragonFlyBSD)
+{
+    enum L_ctermid = 1024;
+
+    int   fseeko(FILE*, off_t, int);
+    off_t ftello(FILE*);
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
 }
 else version (Solaris)
 {
@@ -356,6 +450,9 @@ else version (Solaris)
     {
         off_t ftello(FILE*);
     }
+
+    ssize_t getdelim(char**, size_t*, int, FILE*);
+    ssize_t getline(char**, size_t*, FILE*);
 }
 else version (Posix)
 {
@@ -364,13 +461,11 @@ else version (Posix)
 }
 
 char*  ctermid(char*);
-FILE*  fdopen(int, in char*);
+FILE*  fdopen(int, const scope char*);
 int    fileno(FILE*);
-//int    fseeko(FILE*, off_t, int);
-//off_t  ftello(FILE*);
 char*  gets(char*);
 int    pclose(FILE*);
-FILE*  popen(in char*, in char*);
+FILE*  popen(const scope char*, const scope char*);
 
 
 // memstream functions are conforming to POSIX.1-2008.  These functions are
@@ -392,7 +487,7 @@ else version (CRuntime_Musl)
 
 version (HaveMemstream)
 {
-    FILE*  fmemopen(in void* buf, in size_t size, in char* mode);
+    FILE*  fmemopen(const scope void* buf, in size_t size, const scope char* mode);
     FILE*  open_memstream(char** ptr, size_t* sizeloc);
     version (CRuntime_UClibc) {} else
     FILE*  open_wmemstream(wchar_t** ptr, size_t* sizeloc);
@@ -459,10 +554,10 @@ else version (CRuntime_UClibc)
 P_tmpdir
 va_list (defined in core.stdc.stdarg)
 
-char*  tempnam(in char*, in char*);
+char*  tempnam(const scope char*, const scope char*);
 */
 
-char*  tempnam(in char*, in char*);
+char*  tempnam(const scope char*, const scope char*);
 
 version (CRuntime_Glibc)
 {
@@ -546,7 +641,3 @@ unittest
     assert(memcmp(ptr, testdata.ptr, testdata.length*wchar_t.sizeof) == 0);
     assert(fclose(f) == 0);
 }
-
-
-ssize_t getdelim (char** lineptr, size_t* n, int delimiter, FILE* stream);
-ssize_t getline (char** lineptr, size_t* n, FILE* stream);
diff --git a/libphobos/libdruntime/core/sys/posix/stdlib.d b/libphobos/libdruntime/core/sys/posix/stdlib.d
index a218f958077..4c10d4e0ed5 100644
--- a/libphobos/libdruntime/core/sys/posix/stdlib.d
+++ b/libphobos/libdruntime/core/sys/posix/stdlib.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.stdlib;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.stdc.stdlib;
 public import core.sys.posix.sys.wait;
 
@@ -31,6 +31,7 @@ version (Posix):
 extern (C):
 nothrow:
 @nogc:
+@system:
 
 //
 // Required (defined in core.stdc.stdlib)
@@ -51,37 +52,37 @@ void    _Exit(int);
 void    abort();
 int     abs(int);
 int     atexit(void function());
-double  atof(in char*);
-int     atoi(in char*);
-c_long  atol(in char*);
-long    atoll(in char*);
-void*   bsearch(in void*, in void*, size_t, size_t, int function(in void*, in void*));
+double  atof(const scope char*);
+int     atoi(const scope char*);
+c_long  atol(const scope char*);
+long    atoll(const scope char*);
+void*   bsearch(const scope void*, const scope void*, size_t, size_t, int function(const scope void*, const scope void*));
 void*   calloc(size_t, size_t);
 div_t   div(int, int);
 void    exit(int);
 void    free(void*);
-char*   getenv(in char*);
+char*   getenv(const scope char*);
 c_long  labs(c_long);
 ldiv_t  ldiv(c_long, c_long);
 long    llabs(long);
 lldiv_t lldiv(long, long);
 void*   malloc(size_t);
-int     mblen(in char*, size_t);
-size_t  mbstowcs(wchar_t*, in char*, size_t);
-int     mbtowc(wchar_t*, in char*, size_t);
-void    qsort(void*, size_t, size_t, int function(in void*, in void*));
+int     mblen(const scope char*, size_t);
+size_t  mbstowcs(wchar_t*, const scope char*, size_t);
+int     mbtowc(wchar_t*, const scope char*, size_t);
+void    qsort(void*, size_t, size_t, int function(const scope void*, const scope void*));
 int     rand();
 void*   realloc(void*, size_t);
 void    srand(uint);
-double  strtod(in char*, char**);
-float   strtof(in char*, char**);
-c_long  strtol(in char*, char**, int);
-real    strtold(in char*, char**);
-long    strtoll(in char*, char**, int);
-c_ulong strtoul(in char*, char**, int);
-ulong   strtoull(in char*, char**, int);
-int     system(in char*);
-size_t  wcstombs(char*, in wchar_t*, size_t);
+double  strtod(const scope char*, char**);
+float   strtof(const scope char*, char**);
+c_long  strtol(const scope char*, char**, int);
+real    strtold(const scope char*, char**);
+long    strtoll(const scope char*, char**, int);
+c_ulong strtoul(const scope char*, char**, int);
+ulong   strtoull(const scope char*, char**, int);
+int     system(const scope char*);
+size_t  wcstombs(char*, const scope wchar_t*, size_t);
 int     wctomb(char*, wchar_t);
 */
 
@@ -138,75 +139,75 @@ else version (CRuntime_UClibc)
 // C Extension (CX)
 //
 /*
-int setenv(in char*, in char*, int);
-int unsetenv(in char*);
+int setenv(const scope char*, const scope char*, int);
+int unsetenv(const scope char*);
 */
 
 version (CRuntime_Glibc)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
 
     void* valloc(size_t); // LEGACY non-standard
 }
 else version (Darwin)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
 
     void* valloc(size_t); // LEGACY non-standard
 }
 else version (FreeBSD)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
 
     void* valloc(size_t); // LEGACY non-standard
 }
 else version (NetBSD)
 {
-    int setenv(in char*, in char*, int);
-    int __unsetenv13(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int __unsetenv13(const scope char*);
     alias __unsetenv13 unsetenv;
     void* valloc(size_t); // LEGACY non-standard
 }
 else version (OpenBSD)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
 
     void* valloc(size_t); // LEGACY non-standard
 }
 else version (DragonFlyBSD)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
 
     void* valloc(size_t); // LEGACY non-standard
 }
 else version (CRuntime_Bionic)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
 
     void* valloc(size_t);
 }
 else version (Solaris)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
 
     void* valloc(size_t); // LEGACY non-standard
 }
 else version (CRuntime_Musl)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
 }
 else version (CRuntime_UClibc)
 {
-    int setenv(in char*, in char*, int);
-    int unsetenv(in char*);
+    int setenv(const scope char*, const scope char*, int);
+    int unsetenv(const scope char*);
     void* valloc(size_t);
 }
 
@@ -263,14 +264,14 @@ WIFSTOPPED  (defined in core.sys.posix.sys.wait)
 WSTOPSIG    (defined in core.sys.posix.sys.wait)
 WTERMSIG    (defined in core.sys.posix.sys.wait)
 
-c_long a64l(in char*);
+c_long a64l(const scope char*);
 double drand48();
 char*  ecvt(double, int, int *, int *); // LEGACY
 double erand48(ref ushort[3]);
 char*  fcvt(double, int, int *, int *); // LEGACY
 char*  gcvt(double, int, char*); // LEGACY
 // per spec: int getsubopt(char** char* const*, char**);
-int    getsubopt(char**, in char**, char**);
+int    getsubopt(char**, const scope char**, char**);
 int    grantpt(int);
 char*  initstate(uint, char*, size_t);
 c_long jrand48(ref ushort[3]);
@@ -286,10 +287,10 @@ int    posix_openpt(int);
 char*  ptsname(int);
 int    putenv(char*);
 c_long random();
-char*  realpath(in char*, char*);
+char*  realpath(const scope char*, char*);
 ushort *seed48(ref ushort[3]);
-void   setkey(in char*);
-char*  setstate(in char*);
+void   setkey(const scope char*);
+char*  setstate(const scope char*);
 void   srand48(c_long);
 void   srandom(uint);
 int    unlockpt(int);
@@ -306,13 +307,13 @@ version (CRuntime_Glibc)
     //WSTOPSIG    (defined in core.sys.posix.sys.wait)
     //WTERMSIG    (defined in core.sys.posix.sys.wait)
 
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     char*  ecvt(double, int, int *, int *); // LEGACY
     double erand48(ref ushort[3]);
     char*  fcvt(double, int, int *, int *); // LEGACY
     char*  gcvt(double, int, char*); // LEGACY
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -328,10 +329,10 @@ version (CRuntime_Glibc)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort *seed48(ref ushort[3]);
-    void   setkey(in char*);
-    char*  setstate(in char*);
+    void   setkey(const scope char*);
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
@@ -357,13 +358,13 @@ else version (Darwin)
     //WSTOPSIG    (defined in core.sys.posix.sys.wait)
     //WTERMSIG    (defined in core.sys.posix.sys.wait)
 
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     char*  ecvt(double, int, int *, int *); // LEGACY
     double erand48(ref ushort[3]);
     char*  fcvt(double, int, int *, int *); // LEGACY
     char*  gcvt(double, int, char*); // LEGACY
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -379,10 +380,10 @@ else version (Darwin)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort *seed48(ref ushort[3]);
-    void   setkey(in char*);
-    char*  setstate(in char*);
+    void   setkey(const scope char*);
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
@@ -398,13 +399,13 @@ else version (FreeBSD)
     //WSTOPSIG    (defined in core.sys.posix.sys.wait)
     //WTERMSIG    (defined in core.sys.posix.sys.wait)
 
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     //char*  ecvt(double, int, int *, int *); // LEGACY
     double erand48(ref ushort[3]);
     //char*  fcvt(double, int, int *, int *); // LEGACY
     //char*  gcvt(double, int, char*); // LEGACY
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -420,10 +421,10 @@ else version (FreeBSD)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort *seed48(ref ushort[3]);
-    void   setkey(in char*);
-    char*  setstate(in char*);
+    void   setkey(const scope char*);
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
@@ -439,13 +440,13 @@ else version (NetBSD)
     //WSTOPSIG    (defined in core.sys.posix.sys.wait)
     //WTERMSIG    (defined in core.sys.posix.sys.wait)
 
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     //char*  ecvt(double, int, int *, int *); // LEGACY
     double erand48(ref ushort[3]);
     //char*  fcvt(double, int, int *, int *); // LEGACY
     //char*  gcvt(double, int, char*); // LEGACY
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -461,10 +462,10 @@ else version (NetBSD)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort *seed48(ref ushort[3]);
-    void   setkey(in char*);
-    char*  setstate(in char*);
+    void   setkey(const scope char*);
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
@@ -480,13 +481,13 @@ else version (OpenBSD)
     //WSTOPSIG    (defined in core.sys.posix.sys.wait)
     //WTERMSIG    (defined in core.sys.posix.sys.wait)
 
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     //char*  ecvt(double, int, int *, int *); // LEGACY
     double erand48(ref ushort[3]);
     //char*  fcvt(double, int, int *, int *); // LEGACY
     //char*  gcvt(double, int, char*); // LEGACY
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -502,10 +503,10 @@ else version (OpenBSD)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort *seed48(ref ushort[3]);
-    // void   setkey(in char*); // not implemented
-    char*  setstate(in char*);
+    // void   setkey(const scope char*); // not implemented
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
@@ -521,13 +522,13 @@ else version (DragonFlyBSD)
     //WSTOPSIG    (defined in core.sys.posix.sys.wait)
     //WTERMSIG    (defined in core.sys.posix.sys.wait)
 
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     //char*  ecvt(double, int, int *, int *); // LEGACY
     double erand48(ref ushort[3]);
     //char*  fcvt(double, int, int *, int *); // LEGACY
     //char*  gcvt(double, int, char*); // LEGACY
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -543,10 +544,10 @@ else version (DragonFlyBSD)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort *seed48(ref ushort[3]);
-    void   setkey(in char*);
-    char*  setstate(in char*);
+    void   setkey(const scope char*);
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
@@ -564,9 +565,9 @@ else version (CRuntime_Bionic)
     c_long  mrand48();
     c_long  nrand48(ref ushort[3]);
     char*   ptsname(int);
-    int     putenv(in char*);
+    int     putenv(const scope char*);
     c_long  random() { return lrand48(); }
-    char*   realpath(in char*, char*);
+    char*   realpath(const scope char*, char*);
     ushort* seed48(ref ushort[3]);
     void    srand48(c_long);
     void    srandom(uint s) { srand48(s); }
@@ -574,13 +575,13 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     char*  ecvt(double, int, int *, int *); // LEGACY
     double erand48(ref ushort[3]);
     char*  fcvt(double, int, int *, int *); // LEGACY
     char*  gcvt(double, int, char*); // LEGACY
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -596,10 +597,10 @@ else version (CRuntime_Musl)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort *seed48(ref ushort[3]);
-    void   setkey(in char*);
-    char*  setstate(in char*);
+    void   setkey(const scope char*);
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
@@ -626,13 +627,13 @@ else version (Solaris)
     //WSTOPSIG    (defined in core.sys.posix.sys.wait)
     //WTERMSIG    (defined in core.sys.posix.sys.wait)
 
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     char*  ecvt(double, int, int *, int *); // LEGACY
     double erand48(ref ushort[3]);
     char*  fcvt(double, int, int *, int *); // LEGACY
     char*  gcvt(double, int, char*); // LEGACY
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -648,10 +649,10 @@ else version (Solaris)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort *seed48(ref ushort[3]);
-    void   setkey(in char*);
-    char*  setstate(in char*);
+    void   setkey(const scope char*);
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
@@ -675,13 +676,13 @@ else version (Solaris)
 }
 else version (CRuntime_UClibc)
 {
-    c_long a64l(in char*);
+    c_long a64l(const scope char*);
     double drand48();
     char*  ecvt(double, int, int *, int *);
     double erand48(ref ushort[3]);
     char*  fcvt(double, int, int *, int *);
     char*  gcvt(double, int, char*);
-    int    getsubopt(char**, in char**, char**);
+    int    getsubopt(char**, const scope char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
     c_long jrand48(ref ushort[3]);
@@ -696,10 +697,10 @@ else version (CRuntime_UClibc)
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
-    char*  realpath(in char*, char*);
+    char*  realpath(const scope char*, char*);
     ushort* seed48(ref ushort[3]);
-    void   setkey(in char*);
-    char*  setstate(in char*);
+    void   setkey(const scope char*);
+    char*  setstate(const scope char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
diff --git a/libphobos/libdruntime/core/sys/posix/string.d b/libphobos/libdruntime/core/sys/posix/string.d
new file mode 100644
index 00000000000..e17dfc66d33
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/string.d
@@ -0,0 +1,52 @@
+/**
+ * D header file for POSIX's <string.h>.
+ *
+ * Note:
+ * - The <string.h> header shall define NULL and size_t as described in <stddef.h>.
+ *   However, D has builtin `null` and `size_t` is defined in `object`.
+ *
+ * See_Also:  https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/string.h.html
+ * Copyright: D Language Foundation, 2019
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Mathias 'Geod24' Lang
+ * Standards: The Open Group Base Specifications Issue 7, 2018 edition
+ * Source:    $(DRUNTIMESRC core/sys/posix/_string.d)
+ */
+module core.sys.posix.string;
+
+version (Posix):
+extern(C):
+@system:
+nothrow:
+@nogc:
+
+/// Exposes `locale_t` as defined in `core.sys.posix.locale` (`<locale.h>`)
+public import core.sys.posix.locale : locale_t;
+
+/**
+ * Exposes the C99 functions
+ *
+ * C extensions and XSI extensions are missing
+ */
+public import core.stdc.string;
+
+/// Copy string until character found
+void*  memccpy(return void* dst, scope const void* src, int c, size_t n);
+/// Copy string (including terminating '\0')
+char*  stpcpy(return char* dst, scope const char* src);
+/// Ditto
+char*  stpncpy(return char* dst, const char* src, size_t len);
+/// Compare strings according to current collation
+int    strcoll_l(scope const char* s1, scope const char* s2, locale_t locale);
+///
+char*  strerror_l(int, locale_t);
+/// Save a copy of a string
+char*  strndup(scope const char* str, size_t len);
+/// Find length of string up to `maxlen`
+size_t strnlen(scope const char* str, size_t maxlen);
+/// System signal messages
+const(char)*  strsignal(int);
+/// Isolate sequential tokens in a null-terminated string
+char*  strtok_r(return char* str, scope const char* sep, char** context) pure;
+/// Transform a string under locale
+size_t strxfrm_l(char* s1, scope const char* s2, size_t n, locale_t locale);
diff --git a/libphobos/libdruntime/core/sys/posix/strings.d b/libphobos/libdruntime/core/sys/posix/strings.d
new file mode 100644
index 00000000000..96fbcccaee7
--- /dev/null
+++ b/libphobos/libdruntime/core/sys/posix/strings.d
@@ -0,0 +1,34 @@
+/**
+ * D header file for POSIX's <strings.h>.
+ *
+ * Note: Do not mistake this module for <string.h> (singular),
+ * available at `core.sys.posix.string`.
+ *
+ * See_Also:  https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/strings.h.html
+ * Copyright: D Language Foundation, 2019
+ * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
+ * Authors:   Mathias 'Geod24' Lang
+ * Standards: The Open Group Base Specifications Issue 7, 2018 edition
+ * Source:    $(DRUNTIMESRC core/sys/posix/_strings.d)
+ */
+module core.sys.posix.strings;
+
+version (Posix):
+extern(C):
+@system:
+nothrow:
+@nogc:
+
+///
+public import core.sys.posix.locale : locale_t;
+
+/// Find first bit set in a word
+int ffs(int i) @safe pure;
+/// Compare two strings ignoring case
+int strcasecmp(scope const char* s1, scope const char* s2);
+/// Compare two strings ignoring case, with the specified locale
+int strcasecmp_l(scope const char* s1, scope const char* s2, scope locale_t locale);
+/// Compare two strings ignoring case, up to n characters
+int strncasecmp(scope const char* s1, scope const char* s2, size_t n);
+/// Compare two strings ignoring case, with the specified locale, up to n characters
+int strncasecmp_l(scope const char* s1, const char* s2, size_t n, locale_t locale);
diff --git a/libphobos/libdruntime/core/sys/posix/sys/filio.d b/libphobos/libdruntime/core/sys/posix/sys/filio.d
index 3574bc69ada..afb6f82d978 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/filio.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/filio.d
@@ -20,6 +20,7 @@ else version (WatchOS)
 version (Posix):
 
 nothrow @nogc:
+@system:
 
 version (Darwin)
 {
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ioccom.d b/libphobos/libdruntime/core/sys/posix/sys/ioccom.d
old mode 100644
new mode 100755
index 51f1d2272aa..4c1a820161c
--- a/libphobos/libdruntime/core/sys/posix/sys/ioccom.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/ioccom.d
@@ -18,6 +18,7 @@ else version (WatchOS)
 version (Posix):
 
 nothrow @nogc:
+@system:
 
 version (Darwin)
 {
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ioctl.d b/libphobos/libdruntime/core/sys/posix/sys/ioctl.d
index 7c77e803ce9..0266200c811 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/ioctl.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/ioctl.d
@@ -29,6 +29,7 @@ else version (WatchOS)
 version (Posix):
 
 extern (C) nothrow @nogc:
+@system:
 
 version (CRuntime_Glibc)
 {
@@ -213,7 +214,7 @@ version (CRuntime_Glibc)
     enum TIOCGSID = 0x5429;
 
     enum TCGETS2 = _IOR!termios2('T', 0x2A);
-    enum TCSETS2 = _IOR!termios2('T', 0x2B);
+    enum TCSETS2 = _IOW!termios2('T', 0x2B);
     enum TCSETSW2 = _IOW!termios2('T', 0x2C);
     enum TCSETSF2 = _IOW!termios2('T', 0x2D);
 
@@ -624,7 +625,7 @@ else version (CRuntime_UClibc)
     enum TIOCGSID = 0x5429;
 
     enum TCGETS2 = _IOR!termios2('T', 0x2A);
-    enum TCSETS2 = _IOR!termios2('T', 0x2B);
+    enum TCSETS2 = _IOW!termios2('T', 0x2B);
     enum TCSETSW2 = _IOW!termios2('T', 0x2C);
     enum TCSETSF2 = _IOW!termios2('T', 0x2D);
 
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ipc.d b/libphobos/libdruntime/core/sys/posix/sys/ipc.d
index 04601f2eef1..d397a28ec5a 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/ipc.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/ipc.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.sys.ipc;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types; // for uid_t, gid_t, mode_t, key_t
 
 version (OSX)
@@ -28,6 +28,7 @@ else version (WatchOS)
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // XOpen (XSI)
@@ -52,7 +53,7 @@ IPC_RMID
 IPC_SET
 IPC_STAT
 
-key_t ftok(in char*, int);
+key_t ftok(const scope char*, int);
 */
 
 version (CRuntime_Glibc)
@@ -82,7 +83,7 @@ version (CRuntime_Glibc)
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
 
-    key_t ftok(in char*, int);
+    key_t ftok(const scope char*, int);
 }
 else version (Darwin)
 {
@@ -122,7 +123,7 @@ else version (FreeBSD)
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
 
-    key_t ftok(in char*, int);
+    key_t ftok(const scope char*, int);
 }
 else version (NetBSD)
 {
@@ -147,7 +148,7 @@ else version (NetBSD)
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
 
-    key_t ftok(in char*, int);
+    key_t ftok(const scope char*, int);
 }
 else version (OpenBSD)
 {
@@ -172,7 +173,7 @@ else version (OpenBSD)
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
 
-    key_t ftok(in char*, int);
+    key_t ftok(const scope char*, int);
 }
 else version (DragonFlyBSD)
 {
@@ -197,7 +198,7 @@ else version (DragonFlyBSD)
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
 
-    key_t ftok(in char*, int);
+    key_t ftok(const scope char*, int);
 }
 else version (CRuntime_Bionic)
 {
@@ -240,7 +241,7 @@ else version (CRuntime_Bionic)
     enum IPC_SET        = 1;
     enum IPC_STAT       = 2;
 
-    key_t ftok(in char*, int);
+    key_t ftok(const scope char*, int);
 }
 else version (CRuntime_UClibc)
 {
@@ -270,5 +271,5 @@ else version (CRuntime_UClibc)
     enum IPC_STAT       = 2;
     enum IPC_INFO       = 3;
 
-    key_t ftok(in char*, int);
+    key_t ftok(const scope char*, int);
 }
diff --git a/libphobos/libdruntime/core/sys/posix/sys/mman.d b/libphobos/libdruntime/core/sys/posix/sys/mman.d
index f682320a359..a74a213691c 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/mman.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/mman.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.sys.mman;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types; // for off_t, mode_t
 
 version (OSX)
@@ -45,6 +45,7 @@ version (X86_64)  version = X86_Any;
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // Advisory Information (ADV)
@@ -511,7 +512,7 @@ else version (CRuntime_Bionic)
     enum MS_ASYNC       = 1;
     enum MS_INVALIDATE  = 2;
 
-    int msync(in void*, size_t, int);
+    int msync(const scope void*, size_t, int);
 }
 else version (CRuntime_Musl)
 {
@@ -694,59 +695,59 @@ else
 // Range Memory Locking (MLR)
 //
 /*
-int mlock(in void*, size_t);
-int munlock(in void*, size_t);
+int mlock(const scope void*, size_t);
+int munlock(const scope void*, size_t);
 */
 
 version (CRuntime_Glibc)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (Darwin)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (FreeBSD)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (NetBSD)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (OpenBSD)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (DragonFlyBSD)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (Solaris)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (CRuntime_Bionic)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (CRuntime_Musl)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else version (CRuntime_UClibc)
 {
-    int mlock(in void*, size_t);
-    int munlock(in void*, size_t);
+    int mlock(const scope void*, size_t);
+    int munlock(const scope void*, size_t);
 }
 else
 {
@@ -790,7 +791,7 @@ else version (Solaris)
 }
 else version (CRuntime_Bionic)
 {
-    int mprotect(in void*, size_t, int);
+    int mprotect(const scope void*, size_t, int);
 }
 else version (CRuntime_Musl)
 {
@@ -809,57 +810,57 @@ else
 // Shared Memory Objects (SHM)
 //
 /*
-int shm_open(in char*, int, mode_t);
-int shm_unlink(in char*);
+int shm_open(const scope char*, int, mode_t);
+int shm_unlink(const scope char*);
 */
 
 version (CRuntime_Glibc)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else version (Darwin)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else version (FreeBSD)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else version (NetBSD)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else version (OpenBSD)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else version (DragonFlyBSD)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else version (Solaris)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else version (CRuntime_Bionic)
 {
 }
 else version (CRuntime_Musl)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else version (CRuntime_UClibc)
 {
-    int shm_open(in char*, int, mode_t);
-    int shm_unlink(in char*);
+    int shm_open(const scope char*, int, mode_t);
+    int shm_unlink(const scope char*);
 }
 else
 {
@@ -879,7 +880,7 @@ struct posix_typed_mem_info
     size_t posix_tmi_length;
 }
 
-int posix_mem_offset(in void*, size_t, off_t *, size_t *, int *);
+int posix_mem_offset(const scope void*, size_t, off_t *, size_t *, int *);
 int posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
-int posix_typed_mem_open(in char*, int, int);
+int posix_typed_mem_open(const scope char*, int, int);
 */
diff --git a/libphobos/libdruntime/core/sys/posix/sys/msg.d b/libphobos/libdruntime/core/sys/posix/sys/msg.d
index 208e5c2dd47..4760f2e22f6 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/msg.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/msg.d
@@ -14,6 +14,7 @@ import core.stdc.config;
 version (CRuntime_Glibc):
 // Some of these may be from linux kernel headers.
 extern (C):
+@system:
 
 version (ARM)     version = ARM_Any;
 version (AArch64) version = ARM_Any;
diff --git a/libphobos/libdruntime/core/sys/posix/sys/resource.d b/libphobos/libdruntime/core/sys/posix/sys/resource.d
index 56a8fd428e8..c5d584c5804 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/resource.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/resource.d
@@ -23,6 +23,7 @@ else version (WatchOS)
     version = Darwin;
 
 nothrow @nogc extern(C):
+@system:
 
 //
 // XOpen (XSI)
@@ -528,7 +529,7 @@ else version (CRuntime_Musl)
     enum RLIM_INFINITY = cast(c_ulong)(~0UL);
 
     int getrlimit(int, rlimit*);
-    int setrlimit(int, in rlimit*);
+    int setrlimit(int, const scope rlimit*);
     alias getrlimit getrlimit64;
     alias setrlimit setrlimit64;
     enum
@@ -677,14 +678,14 @@ version (CRuntime_Glibc)
     static if (__USE_FILE_OFFSET64)
     {
         int getrlimit64(int, rlimit*);
-        int setrlimit64(int, in rlimit*);
+        int setrlimit64(int, const scope rlimit*);
         alias getrlimit = getrlimit64;
         alias setrlimit = setrlimit64;
     }
     else
     {
         int getrlimit(int, rlimit*);
-        int setrlimit(int, in rlimit*);
+        int setrlimit(int, const scope rlimit*);
     }
     int getrusage(int, rusage*);
 }
@@ -692,57 +693,57 @@ else version (CRuntime_Bionic)
 {
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
-    int setrlimit(int, in rlimit*);
+    int setrlimit(int, const scope rlimit*);
 }
 else version (Darwin)
 {
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
-    int setrlimit(int, in rlimit*);
+    int setrlimit(int, const scope rlimit*);
 }
 else version (FreeBSD)
 {
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
-    int setrlimit(int, in rlimit*);
+    int setrlimit(int, const scope rlimit*);
 }
 else version (NetBSD)
 {
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
-    int setrlimit(int, in rlimit*);
+    int setrlimit(int, const scope rlimit*);
 }
 else version (OpenBSD)
 {
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
-    int setrlimit(int, in rlimit*);
+    int setrlimit(int, const scope rlimit*);
 }
 else version (DragonFlyBSD)
 {
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
-    int setrlimit(int, in rlimit*);
+    int setrlimit(int, const scope rlimit*);
 }
 else version (Solaris)
 {
     int getrlimit(int, rlimit*);
     int getrusage(int, rusage*);
-    int setrlimit(int, in rlimit*);
+    int setrlimit(int, const scope rlimit*);
 }
 else version (CRuntime_UClibc)
 {
     static if (__USE_FILE_OFFSET64)
     {
         int getrlimit64(int, rlimit*);
-        int setrlimit64(int, in rlimit*);
+        int setrlimit64(int, const scope rlimit*);
         alias getrlimit = getrlimit64;
         alias setrlimit = setrlimit64;
     }
     else
     {
         int getrlimit(int, rlimit*);
-        int setrlimit(int, in rlimit*);
+        int setrlimit(int, const scope rlimit*);
     }
     int getrusage(int, rusage*);
 }
diff --git a/libphobos/libdruntime/core/sys/posix/sys/select.d b/libphobos/libdruntime/core/sys/posix/sys/select.d
index 83e47582f84..2a659c30dc0 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/select.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/select.d
@@ -8,7 +8,7 @@
  */
 module core.sys.posix.sys.select;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.stdc.time;           // for timespec
 public import core.sys.posix.sys.time;  // for timeval
 public import core.sys.posix.sys.types; // for time_t
@@ -27,6 +27,7 @@ else version (WatchOS)
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // Required
@@ -46,7 +47,7 @@ void FD_ZERO(fd_set* fdset);
 
 FD_SETSIZE
 
-int  pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+int  pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
 int  select(int, fd_set*, fd_set*, fd_set*, timeval*);
 */
 
@@ -130,7 +131,7 @@ version (CRuntime_Glibc)
          __result; }))
      +/
 
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else version (Darwin)
@@ -168,7 +169,7 @@ else version (Darwin)
         fdset.fds_bits[0 .. $] = 0;
     }
 
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else version (FreeBSD)
@@ -217,7 +218,7 @@ else version (FreeBSD)
             _p.__fds_bits[--_n] = 0;
     }
 
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else version (NetBSD)
@@ -266,7 +267,7 @@ else version (NetBSD)
             _p.__fds_bits[--_n] = 0;
     }
 
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else version (OpenBSD)
@@ -313,7 +314,7 @@ else version (OpenBSD)
             _p.__fds_bits[--_n] = 0;
     }
 
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else version (DragonFlyBSD)
@@ -362,7 +363,7 @@ else version (DragonFlyBSD)
             _p.__fds_bits[--_n] = 0;
     }
 
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else version (Solaris)
@@ -406,7 +407,7 @@ else version (Solaris)
     }
 
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
 }
 else version (CRuntime_Bionic)
 {
@@ -454,7 +455,7 @@ else version (CRuntime_Bionic)
         fdset.fds_bits[0 .. $] = 0;
     }
 
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else version (CRuntime_Musl)
@@ -501,7 +502,7 @@ else version (CRuntime_Musl)
     {
         fdset.fds_bits[0 .. $] = 0;
     }
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else version (CRuntime_UClibc)
@@ -549,7 +550,7 @@ else version (CRuntime_UClibc)
         fdset.fds_bits[0 .. $] = 0;
     }
 
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
+    int pselect(int, fd_set*, fd_set*, fd_set*, const scope timespec*, const scope sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
 else
diff --git a/libphobos/libdruntime/core/sys/posix/sys/shm.d b/libphobos/libdruntime/core/sys/posix/sys/shm.d
index 8902451d951..2e85096ba4a 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/shm.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/shm.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.sys.shm;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types; // for pid_t, time_t, key_t
 public import core.sys.posix.sys.ipc;
 
@@ -29,6 +29,7 @@ else version (WatchOS)
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // XOpen (XSI)
@@ -53,9 +54,9 @@ struct shmid_ds
     time_t      shm_ctime;
 }
 
-void* shmat(int, in void*, int);
+void* shmat(int, const scope void*, int);
 int   shmctl(int, int, shmid_ds*);
-int   shmdt(in void*);
+int   shmdt(const scope void*);
 int   shmget(key_t, size_t, int);
 */
 
@@ -87,9 +88,9 @@ version (CRuntime_Glibc)
         c_ulong     __unused5;
     }
 
-    void* shmat(int, in void*, int);
+    void* shmat(int, const scope void*, int);
     int   shmctl(int, int, shmid_ds*);
-    int   shmdt(in void*);
+    int   shmdt(const scope void*);
     int   shmget(key_t, size_t, int);
 }
 else version (FreeBSD)
@@ -125,9 +126,9 @@ else version (FreeBSD)
          time_t      shm_ctime;
     }
 
-    void* shmat(int, in void*, int);
+    void* shmat(int, const scope void*, int);
     int   shmctl(int, int, shmid_ds*);
-    int   shmdt(in void*);
+    int   shmdt(const scope void*);
     int   shmget(key_t, size_t, int);
 }
 else version (NetBSD)
@@ -151,9 +152,9 @@ else version (NetBSD)
         void*           shm_internal;
     }
 
-    void* shmat(int, in void*, int);
+    void* shmat(int, const scope void*, int);
     int   shmctl(int, int, shmid_ds*);
-    int   shmdt(in void*);
+    int   shmdt(const scope void*);
     int   shmget(key_t, size_t, int);
 }
 else version (OpenBSD)
@@ -180,9 +181,9 @@ else version (OpenBSD)
         void*      shm_internal;
     }
 
-    void* shmat(int, in void*, int);
+    void* shmat(int, const scope void*, int);
     int   shmctl(int, int, shmid_ds*);
-    int   shmdt(in void*);
+    int   shmdt(const scope void*);
     int   shmget(key_t, size_t, int);
 }
 else version (DragonFlyBSD)
@@ -206,9 +207,9 @@ else version (DragonFlyBSD)
          private void*  shm_internal;
     }
 
-    void* shmat(int, in void*, int);
+    void* shmat(int, const scope void*, int);
     int   shmctl(int, int, shmid_ds*);
-    int   shmdt(in void*);
+    int   shmdt(const scope void*);
     int   shmget(key_t, size_t, int);
 }
 else version (Darwin)
@@ -273,8 +274,8 @@ else version (CRuntime_UClibc)
         c_ulong swap_successes;
     }
 
-    void* shmat(int, in void*, int);
+    void* shmat(int, const scope void*, int);
     int   shmctl(int, int, shmid_ds*);
-    int   shmdt(in void*);
+    int   shmdt(const scope void*);
     int   shmget(key_t, size_t, int);
 }
diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d
index 05f52fc76af..430d0c0d1e3 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/socket.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.sys.socket;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types; // for ssize_t
 public import core.sys.posix.sys.uio;   // for iovec
 
@@ -45,6 +45,7 @@ version (X86_64)  version = X86_Any;
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // Required
@@ -138,8 +139,8 @@ SHUT_RDWR
 SHUT_WR
 
 int     accept(int, sockaddr*, socklen_t*);
-int     bind(int, in sockaddr*, socklen_t);
-int     connect(int, in sockaddr*, socklen_t);
+int     bind(int, const scope sockaddr*, socklen_t);
+int     connect(int, const scope sockaddr*, socklen_t);
 int     getpeername(int, sockaddr*, socklen_t*);
 int     getsockname(int, sockaddr*, socklen_t*);
 int     getsockopt(int, int, int, void*, socklen_t*);
@@ -147,10 +148,10 @@ int     listen(int, int);
 ssize_t recv(int, void*, size_t, int);
 ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
 ssize_t recvmsg(int, msghdr*, int);
-ssize_t send(int, in void*, size_t, int);
-ssize_t sendmsg(int, in msghdr*, int);
-ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-int     setsockopt(int, int, int, in void*, socklen_t);
+ssize_t send(int, const scope void*, size_t, int);
+ssize_t sendmsg(int, const scope msghdr*, int);
+ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+int     setsockopt(int, int, int, const scope void*, socklen_t);
 int     shutdown(int, int);
 int     socket(int, int, int);
 int     sockatmark(int);
@@ -216,7 +217,7 @@ version (CRuntime_Glibc)
     }
     else
     {
-        extern (D) inout(ubyte)*   CMSG_DATA( inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
+        extern (D) inout(ubyte)*   CMSG_DATA( return inout(cmsghdr)* cmsg ) pure nothrow @nogc { return cast(ubyte*)( cmsg + 1 ); }
     }
 
     private inout(cmsghdr)* __cmsg_nxthdr(inout(msghdr)*, inout(cmsghdr)*) pure nothrow @nogc;
@@ -571,8 +572,8 @@ version (CRuntime_Glibc)
     }
 
     int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, scope sockaddr*, scope socklen_t*);
     int     getsockname(int, scope sockaddr*, scope socklen_t*);
     int     getsockopt(int, int, int, scope void*, scope socklen_t*);
@@ -580,10 +581,10 @@ version (CRuntime_Glibc)
     ssize_t recv(int, scope void*, size_t, int);
     ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
     ssize_t recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int) @safe;
     int     socket(int, int, int) @safe;
     int     sockatmark(int) @safe;
@@ -727,8 +728,8 @@ else version (Darwin)
     }
 
     int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, scope sockaddr*, scope socklen_t*);
     int     getsockname(int, scope sockaddr*, scope socklen_t*);
     int     getsockopt(int, int, int, scope void*, scope socklen_t*);
@@ -736,10 +737,10 @@ else version (Darwin)
     ssize_t recv(int, scope void*, size_t, int);
     ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
     ssize_t recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int) @safe;
     int     socket(int, int, int) @safe;
     int     sockatmark(int) @safe;
@@ -904,8 +905,8 @@ else version (FreeBSD)
     }
 
     int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, scope sockaddr*, scope socklen_t*);
     int     getsockname(int, scope sockaddr*, scope socklen_t*);
     int     getsockopt(int, int, int, scope void*, scope socklen_t*);
@@ -913,10 +914,10 @@ else version (FreeBSD)
     ssize_t recv(int, scope void*, size_t, int);
     ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
     ssize_t recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int) @safe;
     int     socket(int, int, int) @safe;
     int     sockatmark(int) @safe;
@@ -1101,8 +1102,8 @@ else version (NetBSD)
     }
 
     int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, scope sockaddr*, scope socklen_t*);
     int     getsockname(int, scope sockaddr*, scope socklen_t*);
     int     getsockopt(int, int, int, scope void*, scope socklen_t*);
@@ -1110,10 +1111,10 @@ else version (NetBSD)
     ssize_t recv(int, scope void*, size_t, int);
     ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
     ssize_t recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int) @safe;
     int     socket(int, int, int) @safe;
     int     sockatmark(int) @safe;
@@ -1274,8 +1275,8 @@ else version (OpenBSD)
     }
 
     int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, scope sockaddr*, scope socklen_t*);
     int     getsockname(int, scope sockaddr*, scope socklen_t*);
     int     getsockopt(int, int, int, scope void*, scope socklen_t*);
@@ -1283,10 +1284,10 @@ else version (OpenBSD)
     ssize_t recv(int, scope void*, size_t, int);
     ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
     ssize_t recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int) @safe;
     int     socket(int, int, int) @safe;
     int     sockatmark(int) @safe;
@@ -1446,7 +1447,7 @@ else version (DragonFlyBSD)
             gid_t           cmcred_gid;
             short           cmcred_ngroups;
             gid_t[CMGROUP_MAX] cmcred_groups;
-    };
+    }
 
     enum : uint
     {
@@ -1499,13 +1500,13 @@ else version (DragonFlyBSD)
         int                 hdr_cnt;
         iovec *             trailers;
         int                 trl_cnt;
-    };
+    }
 */
 
     int     accept(int, sockaddr*, socklen_t*);
 //    int     accept4(int, sockaddr*, socklen_t*, int);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
 //    int     extconnect(int, int, sockaddr*, socklen_t);
     int     getpeername(int, sockaddr*, socklen_t*);
     int     getsockname(int, sockaddr*, socklen_t*);
@@ -1514,11 +1515,11 @@ else version (DragonFlyBSD)
     ssize_t recv(int, void*, size_t, int);
     ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
     ssize_t recvmsg(int, msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    ssize_t sendmsg(int, in msghdr*, int);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    ssize_t sendmsg(int, const scope msghdr*, int);
 //    int     sendfile(int, int, off_t, size_t, sf_hdtr *, off_t *, int);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int);
     int     sockatmark(int);
     int     socket(int, int, int);
@@ -1655,8 +1656,8 @@ else version (Solaris)
     }
 
     int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, scope sockaddr*, scope socklen_t*);
     int     getsockname(int, scope sockaddr*, scope socklen_t*);
     int     getsockopt(int, int, int, scope void*, scope socklen_t*);
@@ -1664,10 +1665,10 @@ else version (Solaris)
     ssize_t recv(int, scope void*, size_t, int);
     ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
     ssize_t recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int) @safe;
     int     socket(int, int, int) @safe;
     int     sockatmark(int) @safe;
@@ -1816,8 +1817,8 @@ else version (CRuntime_Bionic)
     enum SOCK_RDM = 4;
 
     int     accept(int, scope sockaddr*, scope socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, scope sockaddr*, scope socklen_t*);
     int     getsockname(int, scope sockaddr*, scope socklen_t*);
     int     getsockopt(int, int, int, scope void*, scope socklen_t*);
@@ -1825,10 +1826,10 @@ else version (CRuntime_Bionic)
     ssize_t recv(int, scope void*, size_t, int);
     ssize_t recvfrom(int, scope void*, size_t, int, scope sockaddr*, scope socklen_t*);
     int     recvmsg(int, scope msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    int     sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    int     sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int) @safe;
     int     socket(int, int, int) @safe;
     int     sockatmark(int) @safe;
@@ -1970,8 +1971,8 @@ else version (CRuntime_Musl)
         int msg_flags;
     }
     int     accept(int, sockaddr*, socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, sockaddr*, socklen_t*);
     int     getsockname(int, sockaddr*, socklen_t*);
     int     getsockopt(int, int, int, void*, socklen_t*);
@@ -1979,10 +1980,10 @@ else version (CRuntime_Musl)
     ssize_t recv(int, void*, size_t, int);
     ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
     ssize_t recvmsg(int, msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int);
     int     socket(int, int, int);
     int     sockatmark(int);
@@ -2167,8 +2168,8 @@ else version (CRuntime_UClibc)
     }
 
     int     accept(int, sockaddr*, socklen_t*);
-    int     bind(int, in sockaddr*, socklen_t);
-    int     connect(int, in sockaddr*, socklen_t);
+    int     bind(int, const scope sockaddr*, socklen_t);
+    int     connect(int, const scope sockaddr*, socklen_t);
     int     getpeername(int, sockaddr*, socklen_t*);
     int     getsockname(int, sockaddr*, socklen_t*);
     int     getsockopt(int, int, int, void*, socklen_t*);
@@ -2176,10 +2177,10 @@ else version (CRuntime_UClibc)
     ssize_t recv(int, void*, size_t, int);
     ssize_t recvfrom(int, void*, size_t, int, sockaddr*, socklen_t*);
     ssize_t recvmsg(int, msghdr*, int);
-    ssize_t send(int, in void*, size_t, int);
-    ssize_t sendmsg(int, in msghdr*, int);
-    ssize_t sendto(int, in void*, size_t, int, in sockaddr*, socklen_t);
-    int     setsockopt(int, int, int, in void*, socklen_t);
+    ssize_t send(int, const scope void*, size_t, int);
+    ssize_t sendmsg(int, const scope msghdr*, int);
+    ssize_t sendto(int, const scope void*, size_t, int, const scope sockaddr*, socklen_t);
+    int     setsockopt(int, int, int, const scope void*, socklen_t);
     int     shutdown(int, int);
     int     socket(int, int, int);
     int     sockatmark(int);
diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d
index 35b1f1cffee..6b4d022b825 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/stat.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d
@@ -14,9 +14,9 @@
  */
 module core.sys.posix.sys.stat;
 
-private import core.sys.posix.config;
-private import core.stdc.stdint;
-private import core.sys.posix.time;     // for timespec
+import core.sys.posix.config;
+import core.stdc.stdint;
+import core.sys.posix.time;     // for timespec
 public import core.sys.posix.sys.types; // for off_t, mode_t
 
 version (OSX)
@@ -30,9 +30,12 @@ else version (WatchOS)
 
 version (RISCV32) version = RISCV_Any;
 version (RISCV64) version = RISCV_Any;
+version (SPARC)   version = SPARC_Any;
+version (SPARC64) version = SPARC_Any;
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // Required
@@ -80,13 +83,13 @@ S_TYPEISMQ(buf)
 S_TYPEISSEM(buf)
 S_TYPEISSHM(buf)
 
-int    chmod(in char*, mode_t);
+int    chmod(const scope char*, mode_t);
 int    fchmod(int, mode_t);
 int    fstat(int, stat*);
-int    lstat(in char*, stat*);
-int    mkdir(in char*, mode_t);
-int    mkfifo(in char*, mode_t);
-int    stat(in char*, stat*);
+int    lstat(const scope char*, stat*);
+int    mkdir(const scope char*, mode_t);
+int    mkfifo(const scope char*, mode_t);
+int    stat(const scope char*, stat*);
 mode_t umask(mode_t);
  */
 
@@ -120,11 +123,11 @@ version (CRuntime_Glibc)
                 timespec    st_atim;
                 timespec    st_mtim;
                 timespec    st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -167,11 +170,11 @@ version (CRuntime_Glibc)
                 timespec    st_atim;
                 timespec    st_mtim;
                 timespec    st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -249,11 +252,11 @@ version (CRuntime_Glibc)
                 __timespec st_atim;
                 __timespec st_mtim;
                 __timespec st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -309,11 +312,11 @@ version (CRuntime_Glibc)
                 timespec    st_atim;
                 timespec    st_mtim;
                 timespec    st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -373,11 +376,11 @@ version (CRuntime_Glibc)
                 timespec    st_atim;
                 timespec    st_mtim;
                 timespec    st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -514,11 +517,11 @@ version (CRuntime_Glibc)
                 __timespec st_atim;
                 __timespec st_mtim;
                 __timespec st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -596,11 +599,11 @@ version (CRuntime_Glibc)
                 __timespec st_atim;
                 __timespec st_mtim;
                 __timespec st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -691,11 +694,11 @@ version (CRuntime_Glibc)
                 __timespec st_atim;
                 __timespec st_mtim;
                 __timespec st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -714,7 +717,7 @@ version (CRuntime_Glibc)
         else
             static assert(stat_t.sizeof == 104);
     }
-    else version (SPARC64)
+    else version (SPARC_Any)
     {
         private
         {
@@ -736,8 +739,15 @@ version (CRuntime_Glibc)
         struct stat_t
         {
             __dev_t st_dev;
-            ushort __pad1;
-            __ino_t st_ino;
+            static if (__WORDSIZE == 64 || !__USE_FILE_OFFSET64)
+            {
+                ushort __pad1;
+                __ino_t st_ino;
+            }
+            else
+            {
+                __ino64_t st_ino;
+            }
             __mode_t st_mode;
             __nlink_t st_nlink;
             __uid_t st_uid;
@@ -769,11 +779,11 @@ version (CRuntime_Glibc)
                 __timespec st_atim;
                 __timespec st_mtim;
                 __timespec st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -789,7 +799,15 @@ version (CRuntime_Glibc)
             c_ulong __unused4;
             c_ulong __unused5;
         }
-        static assert(stat_t.sizeof == 144);
+        static if (__USE_LARGEFILE64) alias stat_t stat64_t;
+
+        static if (__WORDSIZE == 64)
+            static assert(stat_t.sizeof == 144);
+        else static if (__USE_FILE_OFFSET64)
+            static assert(stat_t.sizeof == 104);
+        else
+            static assert(stat_t.sizeof == 88);
+
     }
     else version (S390)
     {
@@ -838,11 +856,11 @@ version (CRuntime_Glibc)
                 __timespec st_atim;
                 __timespec st_mtim;
                 __timespec st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -902,11 +920,11 @@ version (CRuntime_Glibc)
                 __timespec st_atim;
                 __timespec st_mtim;
                 __timespec st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -1264,11 +1282,11 @@ else version (OpenBSD)
         timespec  st_atim;
         timespec  st_mtim;
         timespec  st_ctim;
-        extern(D)
+        extern(D) @safe @property inout pure nothrow
         {
-            @property ref time_t st_atime() { return st_atim.tv_sec; }
-            @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-            @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+            ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+            ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+            ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
         }
       }
       else
@@ -1348,7 +1366,7 @@ else version (DragonFlyBSD)
             int32_t   st_lspare;
             int64_t   st_qspare1;           /* was recursive change detect */
             int64_t   st_qspare2;
-    };
+    }
 
     enum S_IRUSR    = 0x100; // octal 0000400
     enum S_IWUSR    = 0x080; // octal 0000200
@@ -2001,11 +2019,11 @@ else version (CRuntime_UClibc)
                 timespec    st_atim;
                 timespec    st_mtim;
                 timespec    st_ctim;
-                extern(D)
+                extern(D) @safe @property inout pure nothrow
                 {
-                    @property ref time_t st_atime() { return st_atim.tv_sec; }
-                    @property ref time_t st_mtime() { return st_mtim.tv_sec; }
-                    @property ref time_t st_ctime() { return st_ctim.tv_sec; }
+                    ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
+                    ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
+                    ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
                 }
             }
             else
@@ -2167,13 +2185,13 @@ else
     static assert(false, "Unsupported platform");
 }
 
-int    chmod(in char*, mode_t);
+int    chmod(const scope char*, mode_t);
 int    fchmod(int, mode_t);
 //int    fstat(int, stat_t*);
-//int    lstat(in char*, stat_t*);
-int    mkdir(in char*, mode_t);
-int    mkfifo(in char*, mode_t);
-//int    stat(in char*, stat_t*);
+//int    lstat(const scope char*, stat_t*);
+int    mkdir(const scope char*, mode_t);
+int    mkfifo(const scope char*, mode_t);
+//int    stat(const scope char*, stat_t*);
 mode_t umask(mode_t);
 
 version (CRuntime_Glibc)
@@ -2183,17 +2201,17 @@ version (CRuntime_Glibc)
     int   fstat64(int, stat_t*) @trusted;
     alias fstat64 fstat;
 
-    int   lstat64(in char*, stat_t*);
+    int   lstat64(const scope char*, stat_t*);
     alias lstat64 lstat;
 
-    int   stat64(in char*, stat_t*);
+    int   stat64(const scope char*, stat_t*);
     alias stat64 stat;
   }
   else
   {
     int   fstat(int, stat_t*) @trusted;
-    int   lstat(in char*, stat_t*);
-    int   stat(in char*, stat_t*);
+    int   lstat(const scope char*, stat_t*);
+    int   stat(const scope char*, stat_t*);
   }
 }
 else version (Solaris)
@@ -2201,8 +2219,8 @@ else version (Solaris)
     version (D_LP64)
     {
         int fstat(int, stat_t*) @trusted;
-        int lstat(in char*, stat_t*);
-        int stat(in char*, stat_t*);
+        int lstat(const scope char*, stat_t*);
+        int stat(const scope char*, stat_t*);
 
         static if (__USE_LARGEFILE64)
         {
@@ -2218,17 +2236,17 @@ else version (Solaris)
             int   fstat64(int, stat_t*) @trusted;
             alias fstat64 fstat;
 
-            int   lstat64(in char*, stat_t*);
+            int   lstat64(const scope char*, stat_t*);
             alias lstat64 lstat;
 
-            int   stat64(in char*, stat_t*);
+            int   stat64(const scope char*, stat_t*);
             alias stat64 stat;
         }
         else
         {
             int fstat(int, stat_t*) @trusted;
-            int lstat(in char*, stat_t*);
-            int stat(in char*, stat_t*);
+            int lstat(const scope char*, stat_t*);
+            int stat(const scope char*, stat_t*);
         }
     }
 }
@@ -2238,28 +2256,55 @@ else version (Darwin)
     // inode functions by appending $INODE64 to newer 64-bit inode functions.
     version (OSX)
     {
-        pragma(mangle, "fstat$INODE64") int fstat(int, stat_t*);
-        pragma(mangle, "lstat$INODE64") int lstat(in char*, stat_t*);
-        pragma(mangle, "stat$INODE64")  int stat(in char*, stat_t*);
+        version (AArch64)
+        {
+            int fstat(int, stat_t*);
+            int lstat(const scope char*, stat_t*);
+            int stat(const scope char*, stat_t*);
+        }
+        else
+        {
+            pragma(mangle, "fstat$INODE64") int fstat(int, stat_t*);
+            pragma(mangle, "lstat$INODE64") int lstat(const scope char*, stat_t*);
+            pragma(mangle, "stat$INODE64")  int stat(const scope char*, stat_t*);
+        }
     }
     else
     {
         int fstat(int, stat_t*);
-        int lstat(in char*, stat_t*);
-        int stat(in char*, stat_t*);
+        int lstat(const scope char*, stat_t*);
+        int stat(const scope char*, stat_t*);
     }
 }
 else version (FreeBSD)
 {
-    int   fstat(int, stat_t*);
-    int   lstat(in char*, stat_t*);
-    int   stat(in char*, stat_t*);
+    version (GNU)
+    {
+        int   fstat(int, stat_t*);
+        int   lstat(const scope char*, stat_t*);
+        int   stat(const scope char*, stat_t*);
+    }
+    else
+    {
+        static if (__FreeBSD_version >= INO64_FIRST)
+        {
+            pragma(mangle, "fstat@FBSD_1.5") int   fstat(int, stat_t*);
+            pragma(mangle, "lstat@FBSD_1.5") int   lstat(const scope char*, stat_t*);
+            pragma(mangle, "stat@FBSD_1.5")  int   stat(const scope char*, stat_t*);
+        }
+        else
+        {
+            pragma(mangle, "fstat@FBSD_1.0") int   fstat(int, stat_t*);
+            pragma(mangle, "lstat@FBSD_1.0") int   lstat(const scope char*, stat_t*);
+            pragma(mangle, "stat@FBSD_1.0")  int   stat(const scope char*, stat_t*);
+        }
+    }
 }
 else version (NetBSD)
 {
     int   __fstat50(int, stat_t*);
-    int   __lstat50(in char*, stat_t*);
-    int   __stat50(in char*, stat_t*);
+    int   __lstat50(const scope char*, stat_t*);
+    int   __stat50(const scope char*, stat_t*);
     alias __fstat50 fstat;
     alias __lstat50 lstat;
     alias __stat50 stat;
@@ -2267,26 +2312,26 @@ else version (NetBSD)
 else version (OpenBSD)
 {
     int   fstat(int, stat_t*);
-    int   lstat(in char*, stat_t*);
-    int   stat(in char*, stat_t*);
+    int   lstat(const scope char*, stat_t*);
+    int   stat(const scope char*, stat_t*);
 }
 else version (DragonFlyBSD)
 {
     int   fstat(int, stat_t*);
-    int   lstat(in char*, stat_t*);
-    int   stat(in char*, stat_t*);
+    int   lstat(const scope char*, stat_t*);
+    int   stat(const scope char*, stat_t*);
 }
 else version (CRuntime_Bionic)
 {
     int   fstat(int, stat_t*) @trusted;
-    int   lstat(in char*, stat_t*);
-    int   stat(in char*, stat_t*);
+    int   lstat(const scope char*, stat_t*);
+    int   stat(const scope char*, stat_t*);
 }
 else version (CRuntime_Musl)
 {
-    int stat(in char*, stat_t*);
+    int stat(const scope char*, stat_t*);
     int fstat(int, stat_t*);
-    int lstat(in char*, stat_t*);
+    int lstat(const scope char*, stat_t*);
 
     alias fstat fstat64;
     alias lstat lstat64;
@@ -2299,17 +2344,17 @@ else version (CRuntime_UClibc)
     int   fstat64(int, stat_t*) @trusted;
     alias fstat64 fstat;
 
-    int   lstat64(in char*, stat_t*);
+    int   lstat64(const scope char*, stat_t*);
     alias lstat64 lstat;
 
-    int   stat64(in char*, stat_t*);
+    int   stat64(const scope char*, stat_t*);
     alias stat64 stat;
   }
   else
   {
     int   fstat(int, stat_t*) @trusted;
-    int   lstat(in char*, stat_t*);
-    int   stat(in char*, stat_t*);
+    int   lstat(const scope char*, stat_t*);
+    int   stat(const scope char*, stat_t*);
   }
 }
 
@@ -2347,7 +2392,7 @@ version (CRuntime_Glibc)
     enum S_IFLNK    = 0xA000; // octal 0120000
     enum S_IFSOCK   = 0xC000; // octal 0140000
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else version (Darwin)
 {
@@ -2360,7 +2405,7 @@ else version (Darwin)
     enum S_IFLNK    = 0xA000; // octal 0120000
     enum S_IFSOCK   = 0xC000; // octal 0140000
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else version (FreeBSD)
 {
@@ -2373,7 +2418,17 @@ else version (FreeBSD)
     enum S_IFLNK    = 0xA000; // octal 0120000
     enum S_IFSOCK   = 0xC000; // octal 0140000
 
-    int mknod(in char*, mode_t, dev_t);
+    version (GNU)
+    {
+        int mknod(const scope char*, mode_t, dev_t);
+    }
+    else
+    {
+        static if (__FreeBSD_version >= INO64_FIRST)
+            pragma(mangle, "mknod@FBSD_1.5") int mknod(const scope char*, mode_t, dev_t);
+        else
+            pragma(mangle, "mknod@FBSD_1.0") int mknod(const scope char*, mode_t, dev_t);
+    }
 }
 else version (NetBSD)
 {
@@ -2386,7 +2441,7 @@ else version (NetBSD)
     enum S_IFLNK    = 0xA000; // octal 0120000
     enum S_IFSOCK   = 0xC000; // octal 0140000
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else version (OpenBSD)
 {
@@ -2399,7 +2454,7 @@ else version (OpenBSD)
     enum S_IFLNK    = 0xA000; // octal 0120000
     enum S_IFSOCK   = 0xC000; // octal 0140000
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else version (DragonFlyBSD)
 {
@@ -2412,7 +2467,7 @@ else version (DragonFlyBSD)
     enum S_IFLNK    = 0xA000; // octal 0120000
     enum S_IFSOCK   = 0xC000; // octal 0140000
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else version (Solaris)
 {
@@ -2427,7 +2482,7 @@ else version (Solaris)
     enum S_IFDOOR = 0xD000;
     enum S_IFPORT = 0xE000;
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else version (CRuntime_Bionic)
 {
@@ -2440,7 +2495,7 @@ else version (CRuntime_Bionic)
     enum S_IFLNK    = 0xA000; // octal 0120000
     enum S_IFSOCK   = 0xC000; // octal 0140000
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else version (CRuntime_Musl)
 {
@@ -2455,7 +2510,7 @@ else version (CRuntime_Musl)
         S_IFSOCK   = 0xC000, // octal 0140000
     }
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else version (CRuntime_UClibc)
 {
@@ -2468,7 +2523,7 @@ else version (CRuntime_UClibc)
     enum S_IFLNK    = 0xA000; // octal 0120000
     enum S_IFSOCK   = 0xC000; // octal 0140000
 
-    int mknod(in char*, mode_t, dev_t);
+    int mknod(const scope char*, mode_t, dev_t);
 }
 else
 {
diff --git a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d
index 795d96d87f1..aeaf5bce3fa 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/statvfs.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/statvfs.d
@@ -8,14 +8,15 @@
                       The Open Group Base Specifications Issue 7 IEEE Std 1003.1, 2018 Edition)
  +/
 module core.sys.posix.sys.statvfs;
-private import core.stdc.config;
-private import core.sys.posix.config;
+import core.stdc.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types;
 
 version (Posix):
 extern (C) :
 nothrow:
 @nogc:
+@system:
 
 version (CRuntime_Glibc) {
     static if (__WORDSIZE == 32)
@@ -181,57 +182,75 @@ else version (FreeBSD)
     enum FFlag
     {
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_RDONLY = 1,          /* read only filesystem */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_SYNCHRONOUS = 2,     /* fs written synchronously */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_NOEXEC = 4,          /* can't exec from filesystem */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_NOSUID  = 8,         /* don't honor setuid fs bits */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_NFS4ACLS = 16,       /* enable NFS version 4 ACLs */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_UNION = 32,          /* union with underlying fs */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_ASYNC = 64,          /* fs written asynchronously */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_SUIDDIR = 128,       /* special SUID dir handling */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_SOFTDEP = 256,       /* using soft updates */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_NOSYMFOLLOW = 512,   /* do not follow symlinks */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_GJOURNAL = 1024,     /* GEOM journal support enabled */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_MULTILABEL = 2048,   /* MAC support for objects */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_ACLS = 4096,         /* ACL support enabled */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_NOATIME = 8192,      /* dont update file access time */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_NOCLUSTERR = 16384,  /* disable cluster read */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_NOCLUSTERW = 32768,  /* disable cluster write */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_SUJ = 65536,         /* using journaled soft updates */
 
         // @@@DEPRECATED_2.091@@@
+        deprecated("Moved to core.sys.freebsd.sys.mount to correspond to C header file sys/mount.h")
         MNT_AUTOMOUNTED = 131072 /* mounted by automountd(8) */
     }
 
@@ -259,8 +278,16 @@ else version (FreeBSD)
     enum uint ST_RDONLY = 0x1;
     enum uint ST_NOSUID = 0x2;
 
-    int fstatvfs(int, statvfs_t*);
-    int statvfs(const char*, statvfs_t*);
+    version (GNU)
+    {
+        int fstatvfs(int, statvfs_t*);
+        int statvfs(const char*, statvfs_t*);
+    }
+    else
+    {
+        pragma(mangle, "fstatvfs@FBSD_1.0") int fstatvfs(int, statvfs_t*);
+        pragma(mangle, "statvfs@FBSD_1.0")  int statvfs(const char*, statvfs_t*);
+    }
 }
 else
 {
diff --git a/libphobos/libdruntime/core/sys/posix/sys/time.d b/libphobos/libdruntime/core/sys/posix/sys/time.d
index 4c82930ffd6..95cf88364c7 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/time.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/time.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.sys.time;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types;  // for time_t, suseconds_t
 public import core.sys.posix.sys.select; // for fd_set, FD_CLR() FD_ISSET() FD_SET() FD_ZERO() FD_SETSIZE, select()
 
@@ -31,6 +31,7 @@ version (linux) public import core.sys.linux.sys.time;
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // XOpen (XSI)
@@ -55,8 +56,8 @@ ITIMER_PROF
 int getitimer(int, itimerval*);
 int gettimeofday(timeval*, void*);
 int select(int, fd_set*, fd_set*, fd_set*, timeval*); (defined in core.sys.posix.sys.signal)
-int setitimer(int, in itimerval*, itimerval*);
-int utimes(in char*, ref const(timeval)[2]); // LEGACY
+int setitimer(int, const scope itimerval*, itimerval*);
+int utimes(const scope char*, ref const(timeval)[2]); // LEGACY
 */
 
 version (CRuntime_Glibc)
@@ -79,8 +80,8 @@ version (CRuntime_Glibc)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, void*);
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]); // LEGACY
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]); // LEGACY
 }
 else version (CRuntime_Musl)
 {
@@ -90,7 +91,7 @@ else version (CRuntime_Musl)
         suseconds_t tv_usec;
     }
     int gettimeofday(timeval*, void*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else version (Darwin)
 {
@@ -115,8 +116,8 @@ else version (Darwin)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else version (FreeBSD)
 {
@@ -141,8 +142,8 @@ else version (FreeBSD)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else version (NetBSD)
 {
@@ -160,8 +161,8 @@ else version (NetBSD)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, void*); // timezone_t* is normally void*
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else version (OpenBSD)
 {
@@ -186,8 +187,8 @@ else version (OpenBSD)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, timezone_t*);
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else version (DragonFlyBSD)
 {
@@ -212,8 +213,8 @@ else version (DragonFlyBSD)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else version (Solaris)
 {
@@ -231,8 +232,8 @@ else version (Solaris)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, void*);
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else version (CRuntime_Bionic)
 {
@@ -260,8 +261,8 @@ else version (CRuntime_Bionic)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, timezone_t*);
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else version (CRuntime_UClibc)
 {
@@ -283,8 +284,8 @@ else version (CRuntime_UClibc)
 
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, void*);
-    int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int setitimer(int, const scope itimerval*, itimerval*);
+    int utimes(const scope char*, ref const(timeval)[2]);
 }
 else
 {
diff --git a/libphobos/libdruntime/core/sys/posix/sys/ttycom.d b/libphobos/libdruntime/core/sys/posix/sys/ttycom.d
old mode 100644
new mode 100755
index 38abb2fcf86..1a6c11be291
--- a/libphobos/libdruntime/core/sys/posix/sys/ttycom.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/ttycom.d
@@ -22,6 +22,7 @@ else version (WatchOS)
 version (Posix):
 
 nothrow @nogc:
+@system:
 
 version (Darwin)
 {
diff --git a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d
index 2d8ef92720e..8e84ddb4c60 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/types.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/types.d
@@ -15,8 +15,8 @@
  */
 module core.sys.posix.sys.types;
 
-private import core.sys.posix.config;
-private import core.stdc.stdint;
+import core.sys.posix.config;
+import core.stdc.stdint;
 public import core.stdc.stddef;
 
 version (OSX)
@@ -30,6 +30,7 @@ else version (WatchOS)
 
 version (Posix):
 extern (C):
+@system:
 
 //
 // bits/typesizes.h -- underlying types for *_t.
@@ -139,10 +140,33 @@ else version (CRuntime_Musl)
     alias int        pid_t;
     alias uint       uid_t;
     alias uint       gid_t;
+
+    /**
+     * Musl versions before v1.2.0 (up to v1.1.24) had different
+     * definitions for `time_t` for 32 bits.
+     * This was changed to always be 64 bits in v1.2.0:
+     * https://musl.libc.org/time64.html
+     * This change was only for 32 bits system and
+     * didn't affect 64 bits systems
+     *
+     * To check previous definitions, `grep` for `time_t` in `arch/`,
+     * and the result should be (in v1.1.24):
+     * ---
+     * // arch/riscv64/bits/alltypes.h.in:20:TYPEDEF long time_t;
+     * // arch/s390x/bits/alltypes.h.in:17:TYPEDEF long time_t;
+     * // arch/sh/bits/alltypes.h.in:21:TYPEDEF long time_t;
+     * ---
+     *
+     * In order to be compatible with old versions of Musl,
+     * one can recompile druntime with `CRuntime_Musl_Pre_Time64`.
+     */
     version (D_X32)
         alias long   time_t;
-    else
+    else version (CRuntime_Musl_Pre_Time64)
         alias c_long time_t;
+    else
+        alias long   time_t;
+
     alias c_long     clock_t;
     alias c_ulong    pthread_t;
     version (D_LP64)
@@ -688,6 +712,18 @@ version (CRuntime_Glibc)
         enum __SIZEOF_PTHREAD_BARRIER_T = 32;
         enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
     }
+    else version (SPARC)
+    {
+        enum __SIZEOF_PTHREAD_ATTR_T = 36;
+        enum __SIZEOF_PTHREAD_MUTEX_T = 24;
+        enum __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
+        enum __SIZEOF_PTHREAD_COND_T = 48;
+        enum __SIZEOF_PTHREAD_CONDATTR_T = 4;
+        enum __SIZEOF_PTHREAD_RWLOCK_T = 32;
+        enum __SIZEOF_PTHREAD_RWLOCKATTR_T = 8;
+        enum __SIZEOF_PTHREAD_BARRIER_T = 20;
+        enum __SIZEOF_PTHREAD_BARRIERATTR_T = 4;
+    }
     else version (SPARC64)
     {
         enum __SIZEOF_PTHREAD_ATTR_T = 56;
diff --git a/libphobos/libdruntime/core/sys/posix/sys/uio.d b/libphobos/libdruntime/core/sys/posix/sys/uio.d
index df34ef35c2a..2563c6df5ad 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/uio.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/uio.d
@@ -14,7 +14,7 @@
  */
 module core.sys.posix.sys.uio;
 
-private import core.sys.posix.config;
+import core.sys.posix.config;
 public import core.sys.posix.sys.types; // for ssize_t
 
 version (OSX)
@@ -28,6 +28,7 @@ else version (WatchOS)
 
 version (Posix):
 extern (C) nothrow @nogc:
+@system:
 
 //
 // Required
@@ -42,8 +43,8 @@ struct iovec
 ssize_t // from core.sys.posix.sys.types
 size_t  // from core.sys.posix.sys.types
 
-ssize_t readv(int, in iovec*, int);
-ssize_t writev(int, in iovec*, int);
+ssize_t readv(int, const scope iovec*, int);
+ssize_t writev(int, const scope iovec*, int);
 */
 
 version (CRuntime_Glibc)
@@ -54,8 +55,8 @@ version (CRuntime_Glibc)
         size_t iov_len;
     }
 
-    ssize_t readv(int, in iovec*, int);
-    ssize_t writev(int, in iovec*, int);
+    ssize_t readv(int, const scope iovec*, int);
+    ssize_t writev(int, const scope iovec*, int);
 }
 else version (Darwin)
 {
@@ -65,8 +66,8 @@ else version (Darwin)
         size_t iov_len;
     }
 
-    ssize_t readv(int, in iovec*, int);
-    ssize_t writev(int, in iovec*, int);
+    ssize_t readv(int, const scope iovec*, int);
+    ssize_t writev(int, const sco[...]

[diff truncated at 524288 bytes]


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-28 17:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28 17:31 [gcc(refs/users/ibuclaw/heads/darwin)] libphobos: Synchronize libdruntime bindings with upstream druntime Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).