From: Iain Buclaw Date: Sat, 14 Mar 2020 18:30:24 +0000 (+0100) Subject: libphobos: Merge upstream druntime 7915b6a3 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6e5084b44016113f2c6950be8782d8c84397ef4b;p=gcc.git libphobos: Merge upstream druntime 7915b6a3 Includes port fixes for Musl on ARM, AArch64, and SystemZ targets. Reviewed-on: https://github.com/dlang/druntime/pull/2751 https://github.com/dlang/druntime/pull/2843 https://github.com/dlang/druntime/pull/2844 https://github.com/dlang/druntime/pull/2898 --- diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index b8da026ba02..0e2c5d1c139 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -5bb8ce19fa495e5f794b3c513ae1bf7aabae93ff +7915b6a399fbb6d9c0db351eb5a8fda7e43fe8c5 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/core/stdc/errno.d b/libphobos/libdruntime/core/stdc/errno.d index 06c2b5d94b6..80105d70de7 100644 --- a/libphobos/libdruntime/core/stdc/errno.d +++ b/libphobos/libdruntime/core/stdc/errno.d @@ -144,6 +144,15 @@ else version (Solaris) alias errno = ___errno; } } +else version (Haiku) +{ + // https://github.com/haiku/haiku/blob/master/headers/posix/errno.h + extern (C) + { + ref int _errnop(); + alias errno = _errnop; + } +} else { /// @@ -1709,6 +1718,325 @@ else version (Solaris) enum EINPROGRESS = 150 /** operation now in progress */; enum ESTALE = 151 /** Stale NFS file handle */; } +else version (Haiku) +{ + // https://github.com/haiku/haiku/blob/master/headers/os/support/Errors.h + // https://github.com/haiku/haiku/blob/master/headers/build/os/support/Errors.h + import core.stdc.limits : INT_MIN; + enum B_GENERAL_ERROR_BASE = INT_MIN; + enum B_OS_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x1000); + enum B_APP_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x2000); + enum B_INTERFACE_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x3000); + enum B_MEDIA_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x4000); + /* - 0x41ff */ + enum B_TRANSLATION_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x4800); + /* - 0x48ff */ + enum B_MIDI_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x5000); + enum B_STORAGE_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x6000); + enum B_POSIX_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x7000); + enum B_MAIL_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x8000); + enum B_PRINT_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0x9000); + enum B_DEVICE_ERROR_BASE = (B_GENERAL_ERROR_BASE + 0xa000); + + /* General Errors */ + enum B_NO_MEMORY = (B_GENERAL_ERROR_BASE + 0); + enum B_IO_ERROR = (B_GENERAL_ERROR_BASE + 1); + enum B_PERMISSION_DENIED = (B_GENERAL_ERROR_BASE + 2); + enum B_BAD_INDEX = (B_GENERAL_ERROR_BASE + 3); + enum B_BAD_TYPE = (B_GENERAL_ERROR_BASE + 4); + enum B_BAD_VALUE = (B_GENERAL_ERROR_BASE + 5); + enum B_MISMATCHED_VALUES = (B_GENERAL_ERROR_BASE + 6); + enum B_NAME_NOT_FOUND = (B_GENERAL_ERROR_BASE + 7); + enum B_NAME_IN_USE = (B_GENERAL_ERROR_BASE + 8); + enum B_TIMED_OUT = (B_GENERAL_ERROR_BASE + 9); + enum B_INTERRUPTED = (B_GENERAL_ERROR_BASE + 10); + enum B_WOULD_BLOCK = (B_GENERAL_ERROR_BASE + 11); + enum B_CANCELED = (B_GENERAL_ERROR_BASE + 12); + enum B_NO_INIT = (B_GENERAL_ERROR_BASE + 13); + enum B_NOT_INITIALIZED = (B_GENERAL_ERROR_BASE + 13); + enum B_BUSY = (B_GENERAL_ERROR_BASE + 14); + enum B_NOT_ALLOWED = (B_GENERAL_ERROR_BASE + 15); + enum B_BAD_DATA = (B_GENERAL_ERROR_BASE + 16); + enum B_DONT_DO_THAT = (B_GENERAL_ERROR_BASE + 17); + + enum B_ERROR = (-1); + enum B_OK = (int(0)); + enum B_NO_ERROR = (int(0)); + + /* Kernel Kit Errors */ + enum B_BAD_SEM_ID = (B_OS_ERROR_BASE + 0); + enum B_NO_MORE_SEMS = (B_OS_ERROR_BASE + 1); + + enum B_BAD_THREAD_ID = (B_OS_ERROR_BASE + 0x100); + enum B_NO_MORE_THREADS = (B_OS_ERROR_BASE + 0x101); + enum B_BAD_THREAD_STATE = (B_OS_ERROR_BASE + 0x102); + enum B_BAD_TEAM_ID = (B_OS_ERROR_BASE + 0x103); + enum B_NO_MORE_TEAMS = (B_OS_ERROR_BASE + 0x104); + + enum B_BAD_PORT_ID = (B_OS_ERROR_BASE + 0x200); + enum B_NO_MORE_PORTS = (B_OS_ERROR_BASE + 0x201); + + enum B_BAD_IMAGE_ID = (B_OS_ERROR_BASE + 0x300); + enum B_BAD_ADDRESS = (B_OS_ERROR_BASE + 0x301); + enum B_NOT_AN_EXECUTABLE = (B_OS_ERROR_BASE + 0x302); + enum B_MISSING_LIBRARY = (B_OS_ERROR_BASE + 0x303); + enum B_MISSING_SYMBOL = (B_OS_ERROR_BASE + 0x304); + enum B_UNKNOWN_EXECUTABLE = (B_OS_ERROR_BASE + 0x305); + enum B_LEGACY_EXECUTABLE = (B_OS_ERROR_BASE + 0x306); + + enum B_DEBUGGER_ALREADY_INSTALLED = (B_OS_ERROR_BASE + 0x400); + + /* Application Kit Errors */ + enum B_BAD_REPLY = (B_APP_ERROR_BASE + 0); + enum B_DUPLICATE_REPLY = (B_APP_ERROR_BASE + 1); + enum B_MESSAGE_TO_SELF = (B_APP_ERROR_BASE + 2); + enum B_BAD_HANDLER = (B_APP_ERROR_BASE + 3); + enum B_ALREADY_RUNNING = (B_APP_ERROR_BASE + 4); + enum B_LAUNCH_FAILED = (B_APP_ERROR_BASE + 5); + enum B_AMBIGUOUS_APP_LAUNCH = (B_APP_ERROR_BASE + 6); + enum B_UNKNOWN_MIME_TYPE = (B_APP_ERROR_BASE + 7); + enum B_BAD_SCRIPT_SYNTAX = (B_APP_ERROR_BASE + 8); + enum B_LAUNCH_FAILED_NO_RESOLVE_LINK = (B_APP_ERROR_BASE + 9); + enum B_LAUNCH_FAILED_EXECUTABLE = (B_APP_ERROR_BASE + 10); + enum B_LAUNCH_FAILED_APP_NOT_FOUND = (B_APP_ERROR_BASE + 11); + enum B_LAUNCH_FAILED_APP_IN_TRASH = (B_APP_ERROR_BASE + 12); + enum B_LAUNCH_FAILED_NO_PREFERRED_APP = (B_APP_ERROR_BASE + 13); + enum B_LAUNCH_FAILED_FILES_APP_NOT_FOUND = (B_APP_ERROR_BASE + 14); + enum B_BAD_MIME_SNIFFER_RULE = (B_APP_ERROR_BASE + 15); + enum B_NOT_A_MESSAGE = (B_APP_ERROR_BASE + 16); + enum B_SHUTDOWN_CANCELLED = (B_APP_ERROR_BASE + 17); + enum B_SHUTTING_DOWN = (B_APP_ERROR_BASE + 18); + + /* Storage Kit/File System Errors */ + enum B_FILE_ERROR = (B_STORAGE_ERROR_BASE + 0); + enum B_FILE_NOT_FOUND = (B_STORAGE_ERROR_BASE + 1); + /* deprecated: use B_ENTRY_NOT_FOUND instead */ + enum B_FILE_EXISTS = (B_STORAGE_ERROR_BASE + 2); + enum B_ENTRY_NOT_FOUND = (B_STORAGE_ERROR_BASE + 3); + enum B_NAME_TOO_LONG = (B_STORAGE_ERROR_BASE + 4); + enum B_NOT_A_DIRECTORY = (B_STORAGE_ERROR_BASE + 5); + enum B_DIRECTORY_NOT_EMPTY = (B_STORAGE_ERROR_BASE + 6); + enum B_DEVICE_FULL = (B_STORAGE_ERROR_BASE + 7); + enum B_READ_ONLY_DEVICE = (B_STORAGE_ERROR_BASE + 8); + enum B_IS_A_DIRECTORY = (B_STORAGE_ERROR_BASE + 9); + enum B_NO_MORE_FDS = (B_STORAGE_ERROR_BASE + 10); + enum B_CROSS_DEVICE_LINK = (B_STORAGE_ERROR_BASE + 11); + enum B_LINK_LIMIT = (B_STORAGE_ERROR_BASE + 12); + enum B_BUSTED_PIPE = (B_STORAGE_ERROR_BASE + 13); + enum B_UNSUPPORTED = (B_STORAGE_ERROR_BASE + 14); + enum B_PARTITION_TOO_SMALL = (B_STORAGE_ERROR_BASE + 15); + enum B_PARTIAL_READ = (B_STORAGE_ERROR_BASE + 16); + enum B_PARTIAL_WRITE = (B_STORAGE_ERROR_BASE + 17); + + /* POSIX Errors */ + enum B_USE_POSITIVE_POSIX_ERRORS = false; + + static if (B_USE_POSITIVE_POSIX_ERRORS) + { + enum B_TO_POSIX_ERROR(int code) = -code; + } + else + { + enum B_TO_POSIX_ERROR(int code) = code; + } + alias B_FROM_POSIX_ERROR = B_TO_POSIX_ERROR; + + enum B_POSIX_ENOMEM = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 0); + enum E2BIG = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 1); + enum ECHILD = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 2); + enum EDEADLK = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 3); + enum EFBIG = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 4); + enum EMLINK = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 5); + enum ENFILE = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 6); + enum ENODEV = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 7); + enum ENOLCK = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 8); + enum ENOSYS = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 9); + enum ENOTTY = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 10); + enum ENXIO = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 11); + enum ESPIPE = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 12); + enum ESRCH = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 13); + enum EFPOS = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 14); + enum ESIGPARM = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 15); + enum EDOM = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 16); + enum ERANGE = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 17); + enum EPROTOTYPE = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 18); + enum EPROTONOSUPPORT = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 19); + enum EPFNOSUPPORT = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 20); + enum EAFNOSUPPORT = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 21); + enum EADDRINUSE = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 22); + enum EADDRNOTAVAIL = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 23); + enum ENETDOWN = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 24); + enum ENETUNREACH = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 25); + enum ENETRESET = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 26); + enum ECONNABORTED = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 27); + enum ECONNRESET = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 28); + enum EISCONN = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 29); + enum ENOTCONN = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 30); + enum ESHUTDOWN = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 31); + enum ECONNREFUSED = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 32); + enum EHOSTUNREACH = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 33); + enum ENOPROTOOPT = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 34); + enum ENOBUFS = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 35); + enum EINPROGRESS = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 36); + enum EALREADY = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 37); + enum EILSEQ = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 38); + enum ENOMSG = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 39); + enum ESTALE = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 40); + enum EOVERFLOW = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 41); + enum EMSGSIZE = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 42); + enum EOPNOTSUPP = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 43); + enum ENOTSOCK = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 44); + enum EHOSTDOWN = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 45); + enum EBADMSG = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 46); + enum ECANCELED = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 47); + enum EDESTADDRREQ = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 48); + enum EDQUOT = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 49); + enum EIDRM = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 50); + enum EMULTIHOP = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 51); + enum ENODATA = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 52); + enum ENOLINK = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 53); + enum ENOSR = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 54); + enum ENOSTR = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 55); + enum ENOTSUP = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 56); + enum EPROTO = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 57); + enum ETIME = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 58); + enum ETXTBSY = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 59); + enum ENOATTR = B_TO_POSIX_ERROR!(B_POSIX_ERROR_BASE + 60); + + /* B_NO_MEMORY (0x80000000) can't be negated, so it needs special handling */ + static if (B_USE_POSITIVE_POSIX_ERRORS) + enum ENOMEM = B_POSIX_ENOMEM; + else + enum ENOMEM = B_NO_MEMORY; + + /* POSIX errors that can be mapped to BeOS error codes */ + enum EACCES = B_TO_POSIX_ERROR!(B_PERMISSION_DENIED); + enum EINTR = B_TO_POSIX_ERROR!(B_INTERRUPTED); + enum EIO = B_TO_POSIX_ERROR!(B_IO_ERROR); + enum EBUSY = B_TO_POSIX_ERROR!(B_BUSY); + enum EFAULT = B_TO_POSIX_ERROR!(B_BAD_ADDRESS); + enum ETIMEDOUT = B_TO_POSIX_ERROR!(B_TIMED_OUT); + enum EAGAIN = B_TO_POSIX_ERROR!(B_WOULD_BLOCK) /* SysV compatibility */; + enum EWOULDBLOCK = B_TO_POSIX_ERROR!(B_WOULD_BLOCK) /* BSD compatibility */; + enum EBADF = B_TO_POSIX_ERROR!(B_FILE_ERROR); + enum EEXIST = B_TO_POSIX_ERROR!(B_FILE_EXISTS); + enum EINVAL = B_TO_POSIX_ERROR!(B_BAD_VALUE); + enum ENAMETOOLONG = B_TO_POSIX_ERROR!(B_NAME_TOO_LONG); + enum ENOENT = B_TO_POSIX_ERROR!(B_ENTRY_NOT_FOUND); + enum EPERM = B_TO_POSIX_ERROR!(B_NOT_ALLOWED); + enum ENOTDIR = B_TO_POSIX_ERROR!(B_NOT_A_DIRECTORY); + enum EISDIR = B_TO_POSIX_ERROR!(B_IS_A_DIRECTORY); + enum ENOTEMPTY = B_TO_POSIX_ERROR!(B_DIRECTORY_NOT_EMPTY); + enum ENOSPC = B_TO_POSIX_ERROR!(B_DEVICE_FULL); + enum EROFS = B_TO_POSIX_ERROR!(B_READ_ONLY_DEVICE); + enum EMFILE = B_TO_POSIX_ERROR!(B_NO_MORE_FDS); + enum EXDEV = B_TO_POSIX_ERROR!(B_CROSS_DEVICE_LINK); + enum ELOOP = B_TO_POSIX_ERROR!(B_LINK_LIMIT); + enum ENOEXEC = B_TO_POSIX_ERROR!(B_NOT_AN_EXECUTABLE); + enum EPIPE = B_TO_POSIX_ERROR!(B_BUSTED_PIPE); + + /* new error codes that can be mapped to POSIX errors */ + enum B_BUFFER_OVERFLOW = B_FROM_POSIX_ERROR!(EOVERFLOW); + enum B_TOO_MANY_ARGS = B_FROM_POSIX_ERROR!(E2BIG); + enum B_FILE_TOO_LARGE = B_FROM_POSIX_ERROR!(EFBIG); + enum B_RESULT_NOT_REPRESENTABLE = B_FROM_POSIX_ERROR!(ERANGE); + enum B_DEVICE_NOT_FOUND = B_FROM_POSIX_ERROR!(ENODEV); + enum B_NOT_SUPPORTED = B_FROM_POSIX_ERROR!(EOPNOTSUPP); + + /* Media Kit Errors */ + enum B_STREAM_NOT_FOUND = (B_MEDIA_ERROR_BASE + 0); + enum B_SERVER_NOT_FOUND = (B_MEDIA_ERROR_BASE + 1); + enum B_RESOURCE_NOT_FOUND = (B_MEDIA_ERROR_BASE + 2); + enum B_RESOURCE_UNAVAILABLE = (B_MEDIA_ERROR_BASE + 3); + enum B_BAD_SUBSCRIBER = (B_MEDIA_ERROR_BASE + 4); + enum B_SUBSCRIBER_NOT_ENTERED = (B_MEDIA_ERROR_BASE + 5); + enum B_BUFFER_NOT_AVAILABLE = (B_MEDIA_ERROR_BASE + 6); + enum B_LAST_BUFFER_ERROR = (B_MEDIA_ERROR_BASE + 7); + + enum B_MEDIA_SYSTEM_FAILURE = (B_MEDIA_ERROR_BASE + 100); + enum B_MEDIA_BAD_NODE = (B_MEDIA_ERROR_BASE + 101); + enum B_MEDIA_NODE_BUSY = (B_MEDIA_ERROR_BASE + 102); + enum B_MEDIA_BAD_FORMAT = (B_MEDIA_ERROR_BASE + 103); + enum B_MEDIA_BAD_BUFFER = (B_MEDIA_ERROR_BASE + 104); + enum B_MEDIA_TOO_MANY_NODES = (B_MEDIA_ERROR_BASE + 105); + enum B_MEDIA_TOO_MANY_BUFFERS = (B_MEDIA_ERROR_BASE + 106); + enum B_MEDIA_NODE_ALREADY_EXISTS = (B_MEDIA_ERROR_BASE + 107); + enum B_MEDIA_BUFFER_ALREADY_EXISTS = (B_MEDIA_ERROR_BASE + 108); + enum B_MEDIA_CANNOT_SEEK = (B_MEDIA_ERROR_BASE + 109); + enum B_MEDIA_CANNOT_CHANGE_RUN_MODE = (B_MEDIA_ERROR_BASE + 110); + enum B_MEDIA_APP_ALREADY_REGISTERED = (B_MEDIA_ERROR_BASE + 111); + enum B_MEDIA_APP_NOT_REGISTERED = (B_MEDIA_ERROR_BASE + 112); + enum B_MEDIA_CANNOT_RECLAIM_BUFFERS = (B_MEDIA_ERROR_BASE + 113); + enum B_MEDIA_BUFFERS_NOT_RECLAIMED = (B_MEDIA_ERROR_BASE + 114); + enum B_MEDIA_TIME_SOURCE_STOPPED = (B_MEDIA_ERROR_BASE + 115); + enum B_MEDIA_TIME_SOURCE_BUSY = (B_MEDIA_ERROR_BASE + 116); + enum B_MEDIA_BAD_SOURCE = (B_MEDIA_ERROR_BASE + 117); + enum B_MEDIA_BAD_DESTINATION = (B_MEDIA_ERROR_BASE + 118); + enum B_MEDIA_ALREADY_CONNECTED = (B_MEDIA_ERROR_BASE + 119); + enum B_MEDIA_NOT_CONNECTED = (B_MEDIA_ERROR_BASE + 120); + enum B_MEDIA_BAD_CLIP_FORMAT = (B_MEDIA_ERROR_BASE + 121); + enum B_MEDIA_ADDON_FAILED = (B_MEDIA_ERROR_BASE + 122); + enum B_MEDIA_ADDON_DISABLED = (B_MEDIA_ERROR_BASE + 123); + enum B_MEDIA_CHANGE_IN_PROGRESS = (B_MEDIA_ERROR_BASE + 124); + enum B_MEDIA_STALE_CHANGE_COUNT = (B_MEDIA_ERROR_BASE + 125); + enum B_MEDIA_ADDON_RESTRICTED = (B_MEDIA_ERROR_BASE + 126); + enum B_MEDIA_NO_HANDLER = (B_MEDIA_ERROR_BASE + 127); + enum B_MEDIA_DUPLICATE_FORMAT = (B_MEDIA_ERROR_BASE + 128); + enum B_MEDIA_REALTIME_DISABLED = (B_MEDIA_ERROR_BASE + 129); + enum B_MEDIA_REALTIME_UNAVAILABLE = (B_MEDIA_ERROR_BASE + 130); + + /* Mail Kit Errors */ + enum B_MAIL_NO_DAEMON = (B_MAIL_ERROR_BASE + 0); + enum B_MAIL_UNKNOWN_USER = (B_MAIL_ERROR_BASE + 1); + enum B_MAIL_WRONG_PASSWORD = (B_MAIL_ERROR_BASE + 2); + enum B_MAIL_UNKNOWN_HOST = (B_MAIL_ERROR_BASE + 3); + enum B_MAIL_ACCESS_ERROR = (B_MAIL_ERROR_BASE + 4); + enum B_MAIL_UNKNOWN_FIELD = (B_MAIL_ERROR_BASE + 5); + enum B_MAIL_NO_RECIPIENT = (B_MAIL_ERROR_BASE + 6); + enum B_MAIL_INVALID_MAIL = (B_MAIL_ERROR_BASE + 7); + + /* Printing Errors */ + enum B_NO_PRINT_SERVER = (B_PRINT_ERROR_BASE + 0); + + /* Device Kit Errors */ + enum B_DEV_INVALID_IOCTL = (B_DEVICE_ERROR_BASE + 0); + enum B_DEV_NO_MEMORY = (B_DEVICE_ERROR_BASE + 1); + enum B_DEV_BAD_DRIVE_NUM = (B_DEVICE_ERROR_BASE + 2); + enum B_DEV_NO_MEDIA = (B_DEVICE_ERROR_BASE + 3); + enum B_DEV_UNREADABLE = (B_DEVICE_ERROR_BASE + 4); + enum B_DEV_FORMAT_ERROR = (B_DEVICE_ERROR_BASE + 5); + enum B_DEV_TIMEOUT = (B_DEVICE_ERROR_BASE + 6); + enum B_DEV_RECALIBRATE_ERROR = (B_DEVICE_ERROR_BASE + 7); + enum B_DEV_SEEK_ERROR = (B_DEVICE_ERROR_BASE + 8); + enum B_DEV_ID_ERROR = (B_DEVICE_ERROR_BASE + 9); + enum B_DEV_READ_ERROR = (B_DEVICE_ERROR_BASE + 10); + enum B_DEV_WRITE_ERROR = (B_DEVICE_ERROR_BASE + 11); + enum B_DEV_NOT_READY = (B_DEVICE_ERROR_BASE + 12); + enum B_DEV_MEDIA_CHANGED = (B_DEVICE_ERROR_BASE + 13); + enum B_DEV_MEDIA_CHANGE_REQUESTED = (B_DEVICE_ERROR_BASE + 14); + enum B_DEV_RESOURCE_CONFLICT = (B_DEVICE_ERROR_BASE + 15); + enum B_DEV_CONFIGURATION_ERROR = (B_DEVICE_ERROR_BASE + 16); + enum B_DEV_DISABLED_BY_USER = (B_DEVICE_ERROR_BASE + 17); + enum B_DEV_DOOR_OPEN = (B_DEVICE_ERROR_BASE + 18); + + enum B_DEV_INVALID_PIPE = (B_DEVICE_ERROR_BASE + 19); + enum B_DEV_CRC_ERROR = (B_DEVICE_ERROR_BASE + 20); + enum B_DEV_STALLED = (B_DEVICE_ERROR_BASE + 21); + enum B_DEV_BAD_PID = (B_DEVICE_ERROR_BASE + 22); + enum B_DEV_UNEXPECTED_PID = (B_DEVICE_ERROR_BASE + 23); + enum B_DEV_DATA_OVERRUN = (B_DEVICE_ERROR_BASE + 24); + enum B_DEV_DATA_UNDERRUN = (B_DEVICE_ERROR_BASE + 25); + enum B_DEV_FIFO_OVERRUN = (B_DEVICE_ERROR_BASE + 26); + enum B_DEV_FIFO_UNDERRUN = (B_DEVICE_ERROR_BASE + 27); + enum B_DEV_PENDING = (B_DEVICE_ERROR_BASE + 28); + enum B_DEV_MULTIPLE_ERRORS = (B_DEVICE_ERROR_BASE + 29); + enum B_DEV_TOO_LATE = (B_DEVICE_ERROR_BASE + 30); + + /* Translation Kit Errors */ + enum B_TRANSLATION_BASE_ERROR = (B_TRANSLATION_ERROR_BASE + 0); + enum B_NO_TRANSLATOR = (B_TRANSLATION_ERROR_BASE + 1); + enum B_ILLEGAL_DATA = (B_TRANSLATION_ERROR_BASE + 2); +} else { static assert(false, "Unsupported platform"); diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d index e101bb249fb..e5d2519a00d 100644 --- a/libphobos/libdruntime/core/stdc/fenv.d +++ b/libphobos/libdruntime/core/stdc/fenv.d @@ -386,6 +386,8 @@ else version (CRuntime_Musl) } else version (ARM) { + import core.stdc.config : c_ulong; + struct fenv_t { c_ulong __cw; diff --git a/libphobos/libdruntime/core/sys/posix/config.d b/libphobos/libdruntime/core/sys/posix/config.d index 38a75d609af..9ac42a130a0 100644 --- a/libphobos/libdruntime/core/sys/posix/config.d +++ b/libphobos/libdruntime/core/sys/posix/config.d @@ -67,15 +67,21 @@ version (CRuntime_Glibc) } else version (CRuntime_Musl) { + // off_t is always 64 bits on Musl enum _FILE_OFFSET_BITS = 64; + // Not present in Musl sources enum __REDIRECT = false; + // Those three are irrelevant for Musl as it always uses 64 bits off_t enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64; enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; - enum __WORDSIZE=64; + version (D_LP64) + enum __WORDSIZE = 64; + else + enum __WORDSIZE = 32; } else version (CRuntime_UClibc) { diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d index 867356c67e6..9febcff849b 100644 --- a/libphobos/libdruntime/core/sys/posix/fcntl.d +++ b/libphobos/libdruntime/core/sys/posix/fcntl.d @@ -779,7 +779,102 @@ else version (CRuntime_Bionic) } else version (CRuntime_Musl) { - enum { + version (X86_64) + { + enum + { + O_DIRECTORY = 0x010000, // octal 0200000 + O_NOFOLLOW = 0x020000, // octal 0400000 + O_DIRECT = 0x004000, // octal 040000 + O_LARGEFILE = 0, + O_TMPFILE = 0x410000, // octal 020200000 + + F_GETLK = 5, + F_SETLK = 6, + F_SETLKW = 7, + } + } + // Note: Definitions for i386 are in arch/generic/bits/fcntl.h + else version (X86) + { + enum + { + O_DIRECTORY = 0x010000, // octal 0200000 + O_NOFOLLOW = 0x020000, // octal 0400000 + O_DIRECT = 0x004000, // octal 040000 + O_LARGEFILE = 0x008000, // octal 0100000 + O_TMPFILE = 0x410000, // octal 020200000 + + F_GETLK = 12, + F_SETLK = 13, + F_SETLKW = 14, + } + } + else version (ARM) + { + enum + { + O_DIRECTORY = 0x004000, // octal 040000 + O_NOFOLLOW = 0x008000, // octal 0100000 + O_DIRECT = 0x010000, // octal 0200000 + O_LARGEFILE = 0x020000, // octal 0400000 + O_TMPFILE = 0x404000, // octal 020040000 + + F_GETLK = 12, + F_SETLK = 13, + F_SETLKW = 14, + } + } + else version (AArch64) + { + enum + { + O_DIRECTORY = 0x004000, // octal 040000 + O_NOFOLLOW = 0x008000, // octal 0100000 + O_DIRECT = 0x010000, // octal 0200000 + O_LARGEFILE = 0x020000, // octal 0400000 + O_TMPFILE = 0x404000, // octal 020040000 + + F_GETLK = 5, + F_SETLK = 6, + F_SETLKW = 7, + } + } + else version (SystemZ) + { + enum + { + O_DIRECTORY = 0x010000, // octal 0200000 + O_NOFOLLOW = 0x020000, // octal 0400000 + O_DIRECT = 0x004000, // octal 040000 + O_LARGEFILE = 0x008000, // octal 0100000 + O_TMPFILE = 0x410000, // octal 020200000 + + F_GETLK = 5, + F_SETLK = 6, + F_SETLKW = 7, + } + } + else version (PPC64) + { + enum + { + O_DIRECTORY = 0x004000, // octal 040000 + O_NOFOLLOW = 0x008000, // octal 0100000 + O_DIRECT = 0x020000, // octal 0400000 + O_LARGEFILE = 0x010000, // octal 0200000 + O_TMPFILE = 0x410000, // octal 020200000 + + F_GETLK = 5, + F_SETLK = 6, + F_SETLKW = 7, + } + } + else + static assert(0, "Platform not supported"); + + enum + { O_CREAT = 0x40, // octal 0100 O_EXCL = 0x80, // octal 0200 O_NOCTTY = 0x100, // octal 0400 @@ -790,16 +885,11 @@ else version (CRuntime_Musl) O_DSYNC = 0x1000, // octal 010000 O_SYNC = 0x101000, // octal 04010000 O_RSYNC = O_SYNC, - O_DIRECTORY = 0x10000, - O_NOFOLLOW = 0x20000, O_CLOEXEC = 0x80000, O_ASYNC = 0x2000, - O_DIRECT = 0x4000, - O_LARGEFILE = 0, O_NOATIME = 0x40000, O_PATH = 0x200000, - O_TMPFILE = 0x410000, O_NDELAY = O_NONBLOCK, O_SEARCH = O_PATH, O_EXEC = O_PATH, @@ -809,19 +899,19 @@ else version (CRuntime_Musl) O_WRONLY = 01, O_RDWR = 02, } - enum { + enum + { F_DUPFD = 0, F_GETFD = 1, F_SETFD = 2, F_GETFL = 3, F_SETFL = 4, - F_GETLK = 5, - F_SETLK = 6, - F_SETLKW = 7, + // F_GETLK, F_SETLK, F_SETLKW are arch-specific F_SETOWN = 8, F_GETOWN = 9, } - enum { + enum + { F_RDLCK = 0, F_WRLCK = 1, F_UNLCK = 2, diff --git a/libphobos/libdruntime/core/sys/posix/semaphore.d b/libphobos/libdruntime/core/sys/posix/semaphore.d index ae22d9db54f..cae47773989 100644 --- a/libphobos/libdruntime/core/sys/posix/semaphore.d +++ b/libphobos/libdruntime/core/sys/posix/semaphore.d @@ -143,8 +143,10 @@ else version (CRuntime_Bionic) else version (CRuntime_Musl) { struct sem_t { - int[4*long.sizeof/int.sizeof] __val; + int[4*c_long.sizeof/int.sizeof] __val; } + + enum SEM_FAILED = (sem_t*).init; } else version (CRuntime_UClibc) { diff --git a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d index 791a59328f7..0732a48ab88 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/socket.d +++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d @@ -1895,22 +1895,52 @@ else version (CRuntime_Musl) enum { - SO_DEBUG = 1, - SO_REUSEADDR = 2, - SO_TYPE = 3, - SO_ERROR = 4, - SO_DONTROUTE = 5, - SO_BROADCAST = 6, - SO_SNDBUF = 7, - SO_RCVBUF = 8, - SO_KEEPALIVE = 9, - SO_OOBINLINE = 10, - SO_LINGER = 13, - SO_RCVLOWAT = 18, - SO_SNDLOWAT = 19, - SO_RCVTIMEO = 20, - SO_SNDTIMEO = 21, - SO_ACCEPTCONN = 30 + SO_DEBUG = 1 + } + + version (MIPS_Any) + { + enum + { + SO_REUSEADDR = 0x0004, + SO_TYPE = 0x1008, + SO_ERROR = 0x1007, + SO_DONTROUTE = 0x0010, + SO_BROADCAST = 0x0020, + SO_SNDBUF = 0x1001, + SO_RCVBUF = 0x1002, + SO_KEEPALIVE = 0x0008, + SO_OOBINLINE = 0x0100, + SO_LINGER = 0x0080, + SO_REUSEPORT = 0x0200, + SO_RCVLOWAT = 0x1004, + SO_SNDLOWAT = 0x1003, + SO_RCVTIMEO = 0x1006, + SO_SNDTIMEO = 0x1005, + SO_ACCEPTCONN = 0x1009 + } + } + else + { + enum + { + SO_REUSEADDR = 2, + SO_TYPE = 3, + SO_ERROR = 4, + SO_DONTROUTE = 5, + SO_BROADCAST = 6, + SO_SNDBUF = 7, + SO_RCVBUF = 8, + SO_KEEPALIVE = 9, + SO_OOBINLINE = 10, + SO_LINGER = 13, + SO_REUSEPORT = 15, + SO_RCVLOWAT = 18, + SO_SNDLOWAT = 19, + SO_RCVTIMEO = 20, + SO_SNDTIMEO = 21, + SO_ACCEPTCONN = 30 + } } enum : uint diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d index 8692014ffe1..52b51bd3c71 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/stat.d +++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d @@ -1664,31 +1664,225 @@ else version (CRuntime_Musl) S_ISGID = 0x400, // octal 02000 S_ISVTX = 0x200, // octal 01000 } - struct stat_t { - dev_t st_dev; - ino_t st_ino; - nlink_t st_nlink; - - mode_t st_mode; - uid_t st_uid; - gid_t st_gid; - uint __pad0; - dev_t st_rdev; - off_t st_size; - blksize_t st_blksize; - blkcnt_t st_blocks; + version (ARM) + { + struct stat_t + { + dev_t st_dev; + int __st_dev_padding; + c_long __st_ino_truncated; + mode_t st_mode; + nlink_t st_nlink; + + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + int __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + ino_t st_ino; + + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } + } + } + else version (AArch64) + { + struct stat_t + { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + c_ulong __pad; + off_t st_size; + blksize_t st_blksize; + int __pad2; + blkcnt_t st_blocks; + + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + uint[2] __unused; + + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } + } + } + else version (X86_64) + { + struct stat_t + { + dev_t st_dev; + ino_t st_ino; + nlink_t st_nlink; + + mode_t st_mode; + uid_t st_uid; + gid_t st_gid; + uint __pad0; + dev_t st_rdev; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + + c_long[3] __unused; + + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } + } + } + else version (X86) + { + struct stat_t + { + dev_t st_dev; + int __st_dev_padding; + c_long __st_ino_truncated; + mode_t st_mode; + nlink_t st_nlink; + + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + int __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + ino_t st_ino; + + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } + } + } + else version (MIPS64) + { + struct stat_t + { + dev_t st_dev; + int[3] __pad1; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + uint[2] __pad2; + off_t st_size; + int __pad3; + + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + blksize_t st_blksize; + uint __pad4; + blkcnt_t st_blocks; + int[14] __pad5; + + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } + } + } + else version (PPC64) + { + struct stat_t + { + dev_t st_dev; + ino_t st_ino; + nlink_t st_nlink; + mode_t st_mode; - timespec st_atim; - timespec st_mtim; - timespec st_ctim; - extern(D) @safe @property inout pure nothrow + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + c_ulong[3] __unused; + + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } + } + } + else version (SystemZ) + { + struct stat_t { - 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; } + dev_t st_dev; + ino_t st_ino; + nlink_t st_nlink; + mode_t st_mode; + + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + + blksize_t st_blksize; + blkcnt_t st_blocks; + c_ulong[3] __unused; + + extern(D) @safe @property inout pure nothrow + { + ref inout(time_t) st_atime() return { return st_atim.tv_sec; } + ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } + ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } + } } - long[3] __unused; } + else + static assert("Unsupported platform"); + private { extern (D) bool S_ISTYPE( mode_t mode, uint mask ) diff --git a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d index 6188047cf0e..169287c3bec 100644 --- a/libphobos/libdruntime/core/sys/posix/sys/types.d +++ b/libphobos/libdruntime/core/sys/posix/sys/types.d @@ -112,8 +112,26 @@ version (CRuntime_Glibc) } else version (CRuntime_Musl) { - alias c_long blksize_t; - alias c_ulong nlink_t; + version (AArch64) + { + alias int blksize_t; + alias uint nlink_t; + } + else version (MIPS64) + { + alias c_long blksize_t; + alias uint nlink_t; + } + else version (RISCV64) + { + alias int blksize_t; + alias uint nlink_t; + } + else + { + alias c_long blksize_t; + alias c_ulong nlink_t; + } alias long dev_t; alias long blkcnt_t; alias ulong ino_t;