Make dos errno multimapping linkage tinier

640 bytes for old kDos2Errno table
182 bytes for new kDos2Errno under hello2.com (MODE=fastbuild)
122 bytes for new kDos2Errno under hello2.com (MODE=tiny)
This commit is contained in:
Justine Tunney 2022-09-13 06:25:50 -07:00
parent 9fa6725067
commit 8f5678882d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
63 changed files with 602 additions and 160 deletions

View file

@ -36,7 +36,7 @@ privileged errno_t __dos2errno(uint32_t error) {
if (error) {
for (i = 0; kDos2Errno[i].doscode; ++i) {
if (error == kDos2Errno[i].doscode) {
return *(const int *)((intptr_t)kDos2Errno + kDos2Errno[i].systemv);
return *(const int *)((intptr_t)kDos2Errno[i].systemv);
}
}
}

View file

@ -16,160 +16,17 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/nt/errors.h"
#include "libc/nt/errors.h"
#include "libc/macros.internal.h"
// @fileoverview data structure for __dos2errno()
// @see libc/sysv/dos2errno.sh for the numbers
.macro .e doscode systemv
.short \doscode
.long \systemv - kDos2Errno
.endm
.section .rodata,"a",@progbits
.align 4
.underrun
kDos2Errno:
// .e kNtErrorInvalidFunction,ENOSYS # in consts.sh
// .e kNtErrorFileNotFound,ENOENT # in consts.sh
// .e kNtErrorPathNotFound,ENOTDIR # in consts.sh
// .e kNtErrorTooManyOpenFiles,EMFILE # in consts.sh
// .e kNtErrorTooManyDescriptors,ENFILE # in consts.sh
// .e kNtErrorTooManyLinks,EMLINK # in consts.sh
// .e kNtErrorAccessDenied,EACCES # in consts.sh
// .e kNtErrorInvalidHandle,EBADF # in consts.sh
// .e kNtErrorInvalidAccess,EPERM # in consts.sh
// .e kNtErrorNotEnoughQuota,EDQUOT # in consts.sh
// .e kNtErrorSeek,ESPIPE # in consts.sh
// .e kNtErrorNotDosDisk,ENOTBLK # in consts.sh
// .e kNtErrorFileExists,EEXIST # in consts.sh
// .e kNtErrorInvalidParameter,EINVAL # in consts.sh
// .e kNtErrorOutofmemory,ENOMEM # in consts.sh
// .e kNtErrorBrokenPipe,EPIPE # in consts.sh
// .e kNtErrorWaitNoChildren,ECHILD # in consts.sh
// .e kNtErrorPathBusy,ETXTBSY # in consts.sh
// .e kNtErrorBusy,EBUSY # in consts.sh
// .e kNtErrorAlreadyExists,EEXIST # in consts.sh
// .e kNtErrorBadExeFormat,ENOEXEC # in consts.sh
// .e kNtErrorFileTooLarge,EFBIG # in consts.sh
// .e kNtErrorDirectoryNotSupported,EISDIR # in consts.sh
// .e kNtErrorInvalidAddress,EFAULT # in consts.sh
// .e kNtErrorThreadNotInProcess,ESRCH # in consts.sh
// .e kNtErrorNoMediaInDrive,ENXIO # in consts.sh
// .e kNtErrorIoDevice,EIO # in consts.sh
// .e kNtErrorSerialNoDevice,ENOTTY # in consts.sh
// .e kNtErrorPossibleDeadlock,EDEADLK # in consts.sh
// .e kNtErrorBadDevice,ENODEV # in consts.sh
// .e kNtErrorInvalidCommandLine,E2BIG # in consts.sh
// .e kNtErrorFileReadOnly,EROFS # in consts.sh
// .e kNtErrorNoData,ENODATA # in consts.sh
// .e WSAEPROCLIM,EPROCLIM # in consts.sh
// .e WSAESHUTDOWN,ESHUTDOWN # in consts.sh
// .e WSAEINPROGRESS,EINPROGRESS # in consts.sh
// .e WSAENETDOWN,ENETDOWN # in consts.sh
// .e WSAENETUNREACH,ENETUNREACH # in consts.sh
// .e WSAENETRESET,ENETRESET # in consts.sh
// .e WSAEUSERS,EUSERS # in consts.sh
// .e WSAENOTSOCK,ENOTSOCK # in consts.sh
// .e WSAEDESTADDRREQ,EDESTADDRREQ # in consts.sh
// .e WSAEMSGSIZE,EMSGSIZE # in consts.sh
// .e WSAEPROTOTYPE,EPROTOTYPE # in consts.sh
// .e WSAENOPROTOOPT,ENOPROTOOPT # in consts.sh
// .e WSAEPROTONOSUPPORT,EPROTONOSUPPORT # in consts.sh
// .e WSAESOCKTNOSUPPORT,ESOCKTNOSUPPORT # in consts.sh
// .e WSAEOPNOTSUPP,ENOTSUP # in consts.sh
// .e WSAEOPNOTSUPP,EOPNOTSUPP # in consts.sh
// .e WSAEPFNOSUPPORT,EPFNOSUPPORT # in consts.sh
// .e WSAEAFNOSUPPORT,EAFNOSUPPORT # in consts.sh
// .e WSAEADDRINUSE,EADDRINUSE # in consts.sh
// .e WSAEADDRNOTAVAIL,EADDRNOTAVAIL # in consts.sh
// .e WSAECONNABORTED,ECONNABORTED # in consts.sh
// .e WSAECONNRESET,ECONNRESET # in consts.sh
// .e WSAENOBUFS,ENOBUFS # in consts.sh
// .e WSAEISCONN,EISCONN # in consts.sh
// .e WSAENOTCONN,ENOTCONN # in consts.sh
// .e WSAESHUTDOWN,ESHUTDOWN # in consts.sh
// .e WSAETOOMANYREFS,ETOOMANYREFS # in consts.sh
// .e WSAETIMEDOUT,ETIMEDOUT # in consts.sh
// .e WSAECONNREFUSED,ECONNREFUSED # in consts.sh
// .e WSAEHOSTDOWN,EHOSTDOWN # in consts.sh
// .e WSAEHOSTUNREACH,EHOSTUNREACH # in consts.sh
// .e WSAEALREADY,EALREADY # in consts.sh
// .e WSAESTALE,ESTALE # in consts.sh
// .e WSAEREMOTE,EREMOTE # in consts.sh
// .e WSAEINTR,EINTR # in consts.sh
.e kNtErrorModNotFound,ENOSYS
.e kNtErrorBadCommand,EACCES
.e kNtErrorBadLength,EACCES
.e kNtErrorBadNetpath,ENOENT
.e kNtErrorBadNetName,ENOENT
.e kNtErrorBadPathname,ENOENT
.e kNtErrorBadNetResp,ENETDOWN
.e kNtErrorFileExists,EEXIST
.e kNtErrorCannotMake,EACCES
.e kNtErrorCommitmentLimit,ENOMEM
.e kNtErrorConnectionAborted,ECONNABORTED
.e kNtErrorConnectionActive,EISCONN
.e kNtErrorConnectionRefused,ECONNREFUSED
.e kNtErrorCrc,EACCES
.e kNtErrorDirNotEmpty,ENOTEMPTY
.e kNtErrorDupName,EADDRINUSE
.e kNtErrorFilenameExcedRange,ENAMETOOLONG
.e kNtErrorGenFailure,EACCES
.e kNtErrorGracefulDisconnect,EPIPE
.e kNtErrorHostDown,EHOSTUNREACH
.e kNtErrorHostUnreachable,EHOSTUNREACH
.e kNtErrorInsufficientBuffer,EFAULT
.e kNtErrorNoaccess,EFAULT
.e kNtErrorInvalidAddress,EADDRNOTAVAIL
.e kNtErrorNotAReparsePoint,EINVAL
.e kNtErrorInvalidFunction,EINVAL
.e kNtErrorInvalidNetname,EADDRNOTAVAIL
.e kNtErrorInvalidUserBuffer,EMSGSIZE
.e kNtErrorIoPending,EINPROGRESS
.e kNtErrorLockViolation,EACCES
.e kNtErrorMoreData,EMSGSIZE
.e kNtErrorNetnameDeleted,ECONNABORTED
.e kNtErrorNetworkAccessDenied,EACCES
.e kNtErrorNetworkBusy,ENETDOWN
.e kNtErrorNetworkUnreachable,ENETUNREACH
.e kNtErrorNonpagedSystemResources,ENOMEM
.e kNtErrorNotEnoughMemory,ENOMEM
.e kNtErrorNotEnoughQuota,ENOMEM
.e kNtErrorNotFound,ENOENT
.e kNtErrorNotLocked,EACCES
.e kNtErrorNotReady,EACCES
.e kNtErrorNotSupported,ENOTSUP
.e kNtErrorNoMoreFiles,ENOENT
.e kNtErrorNoSystemResources,ENOMEM
.e kNtErrorOperationAborted,EINTR
.e kNtErrorOutOfPaper,EACCES
.e kNtErrorPagedSystemResources,ENOMEM
.e kNtErrorPagefileQuota,ENOMEM
.e kNtErrorPipeNotConnected,EPIPE
.e kNtErrorPortUnreachable,ECONNRESET
.e kNtErrorProtocolUnreachable,ENETUNREACH
.e kNtErrorRemNotList,ECONNREFUSED
.e kNtErrorRequestAborted,EINTR
.e kNtErrorReqNotAccep,EWOULDBLOCK
.e kNtErrorSectorNotFound,EACCES
.e kNtErrorSemTimeout,ETIMEDOUT
.e kNtErrorSharingViolation,EACCES
.e kNtErrorTooManyNames,ENOMEM
.e kNtErrorUnexpNetErr,ECONNABORTED
.e kNtErrorWorkingSetQuota,ENOMEM
.e kNtErrorWriteProtect,EACCES
.e kNtErrorWrongDisk,EACCES
.e WSAEACCES,EACCES
.e WSAEDISCON,EPIPE
.e WSAEFAULT,EFAULT
.e WSAEINVAL,EINVAL
.e WSAEDQUOT,EDQUOT
.e WSAEPROCLIM,ENOMEM
.e WSANOTINITIALISED,ENETDOWN
.e WSASYSNOTREADY,ENETDOWN
.e WSAVERNOTSUPPORTED,ENOSYS
.section .sort.rodata.dos2errno.1,"a",@progbits
.align 8
kDos2Errno:/*
...decentralized content...
*/.endobj kDos2Errno,globl
.previous
.section .sort.rodata.dos2errno.3,"a",@progbits
.short 0
.endobj kDos2Errno,globl,hidden
.overrun
.previous

View file

@ -89,7 +89,7 @@
#define kNtErrorBufferOverflow 111
#define kNtErrorDiskFull 112 /* ENOSPC */
#define kNtErrorNoMoreSearchHandles 113
#define kNtErrorInvalidTargetHandle 114
#define kNtErrorInvalidTargetHandle 114 /* EBADF */
#define kNtErrorInvalidCategory 117
#define kNtErrorInvalidVerifySwitch 118
#define kNtErrorBadDriverLevel 119
@ -103,7 +103,7 @@
#define kNtErrorProcNotFound 127
#define kNtErrorWaitNoChildren 128 /* ECHILD */
#define kNtErrorChildNotComplete 129
#define kNtErrorDirectAccessHandle 130
#define kNtErrorDirectAccessHandle 130 /* EBADF */
#define kNtErrorNegativeSeek 131
#define kNtErrorSeekOnDevice 132
#define kNtErrorIsJoinTarget 133

View file

@ -1,2 +1,15 @@
.include "o/libc/nt/codegen.inc"
.imp kernel32,__imp_SuspendThread,SuspendThread,0
.text.windows
SuspendThread:
push %rbp
mov %rsp,%rbp
.profilable
mov %rdi,%rcx
sub $32,%rsp
call *__imp_SuspendThread(%rip)
leave
ret
.endfn SuspendThread,globl
.previous

View file

@ -983,7 +983,7 @@ imp 'SleepConditionVariableSRW' SleepConditionVariableSRW kernel32 0
imp 'SleepEx' SleepEx kernel32 0 2
imp 'SortCloseHandle' SortCloseHandle kernel32 1416
imp 'SortGetHandle' SortGetHandle kernel32 1417
imp 'SuspendThread' SuspendThread kernel32 0
imp 'SuspendThread' SuspendThread kernel32 0 1
imp 'SwitchToFiber' SwitchToFiber kernel32 0
imp 'SwitchToThread' SwitchToThread kernel32 0
imp 'SystemTimeToFileTime' SystemTimeToFileTime kernel32 0 2

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EACCES,13,13,13,13,13,5
.yoink kDos2Errno.EACCES

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EADDRINUSE,98,48,48,48,48,10048
.yoink kDos2Errno.EADDRINUSE

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EADDRNOTAVAIL,99,49,49,49,49,10049
.yoink kDos2Errno.EADDRNOTAVAIL

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EBADF,9,9,9,9,9,6
.yoink kDos2Errno.EBADF

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ECONNABORTED,103,53,53,53,53,10053
.yoink kDos2Errno.ECONNABORTED

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ECONNREFUSED,111,61,61,61,61,10061
.yoink kDos2Errno.ECONNREFUSED

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ECONNRESET,104,54,54,54,54,10054
.yoink kDos2Errno.ECONNRESET

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EDQUOT,122,69,69,69,69,1816
.yoink kDos2Errno.EDQUOT

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EEXIST,17,17,17,17,17,183
.yoink kDos2Errno.EEXIST

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EFAULT,14,14,14,14,14,487
.yoink kDos2Errno.EFAULT

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EHOSTUNREACH,113,65,65,65,65,10065
.yoink kDos2Errno.EHOSTUNREACH

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EINPROGRESS,115,36,36,36,36,10036
.yoink kDos2Errno.EINPROGRESS

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EINTR,4,4,4,4,4,10004
.yoink kDos2Errno.EINTR

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EINVAL,22,22,22,22,22,87
.yoink kDos2Errno.EINVAL

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EISCONN,106,56,56,56,56,10056
.yoink kDos2Errno.EISCONN

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EMSGSIZE,90,40,40,40,40,10040
.yoink kDos2Errno.EMSGSIZE

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENAMETOOLONG,36,63,63,63,63,10063
.yoink kDos2Errno.ENAMETOOLONG

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENETDOWN,100,50,50,50,50,10050
.yoink kDos2Errno.ENETDOWN

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENETUNREACH,101,51,51,51,51,10051
.yoink kDos2Errno.ENETUNREACH

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENOENT,2,2,2,2,2,2
.yoink kDos2Errno.ENOENT

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENOMEM,12,12,12,12,12,14
.yoink kDos2Errno.ENOMEM

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENOSYS,38,78,78,78,78,1
.yoink kDos2Errno.ENOSYS

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENOTEMPTY,39,66,66,66,66,145
.yoink kDos2Errno.ENOTEMPTY

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ENOTSUP,95,45,45,91,86,10045
.yoink kDos2Errno.ENOTSUP

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,EPIPE,32,32,32,32,32,109
.yoink kDos2Errno.EPIPE

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon errno,ETIMEDOUT,110,60,60,60,60,10060
.yoink kDos2Errno.ETIMEDOUT

View file

@ -1,2 +1,3 @@
.include "o/libc/sysv/consts/syscon.internal.inc"
.syscon compat,EWOULDBLOCK,11,35,35,35,35,10035
.yoink kDos2Errno.EWOULDBLOCK

173
libc/sysv/dos2errno.sh Executable file
View file

@ -0,0 +1,173 @@
/*bin/echo ' -*- mode:sh; indent-tabs-mode:nil; tab-width:8; coding:utf-8 -*-│
│vi: set net ft=sh ts=2 sts=2 sw=2 fenc=utf-8 :vi│
╞══════════════════════════════════════════════════════════════════════════════╡
│ Copyright 2020 Justine Alexandra Roberts Tunney │
│ │
│ Permission to use, copy, modify, and/or distribute this software for
│ any purpose with or without fee is hereby granted, provided that the │
│ above copyright notice and this permission notice appear in all copies. │
│ │
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚────────────────────────────────────────────────────────────────'>/dev/null #*/
dir=libc/sysv/dos2errno
. libc/sysv/gen.sh
# # DOS ERRNO CANONICAL MAPPINGS
# #
# # These are defined by consts.sh.
# # They're here too as a reminder.
# #
# dos kNtErrorInvalidFunction ENOSYS # in consts.sh
# dos kNtErrorFileNotFound ENOENT # in consts.sh
# dos kNtErrorPathNotFound ENOTDIR # in consts.sh
# dos kNtErrorTooManyOpenFiles EMFILE # in consts.sh
# dos kNtErrorTooManyDescriptors ENFILE # in consts.sh
# dos kNtErrorTooManyLinks EMLINK # in consts.sh
# dos kNtErrorAccessDenied EACCES # in consts.sh
# dos kNtErrorInvalidHandle EBADF # in consts.sh
# dos kNtErrorInvalidAccess EPERM # in consts.sh
# dos kNtErrorNotEnoughQuota EDQUOT # in consts.sh
# dos kNtErrorSeek ESPIPE # in consts.sh
# dos kNtErrorNotDosDisk ENOTBLK # in consts.sh
# dos kNtErrorFileExists EEXIST # in consts.sh
# dos kNtErrorInvalidParameter EINVAL # in consts.sh
# dos kNtErrorOutofmemory ENOMEM # in consts.sh
# dos kNtErrorBrokenPipe EPIPE # in consts.sh
# dos kNtErrorWaitNoChildren ECHILD # in consts.sh
# dos kNtErrorPathBusy ETXTBSY # in consts.sh
# dos kNtErrorBusy EBUSY # in consts.sh
# dos kNtErrorAlreadyExists EEXIST # in consts.sh
# dos kNtErrorBadExeFormat ENOEXEC # in consts.sh
# dos kNtErrorFileTooLarge EFBIG # in consts.sh
# dos kNtErrorDirectoryNotSupported EISDIR # in consts.sh
# dos kNtErrorInvalidAddress EFAULT # in consts.sh
# dos kNtErrorThreadNotInProcess ESRCH # in consts.sh
# dos kNtErrorNoMediaInDrive ENXIO # in consts.sh
# dos kNtErrorIoDevice EIO # in consts.sh
# dos kNtErrorSerialNoDevice ENOTTY # in consts.sh
# dos kNtErrorPossibleDeadlock EDEADLK # in consts.sh
# dos kNtErrorBadDevice ENODEV # in consts.sh
# dos kNtErrorInvalidCommandLine E2BIG # in consts.sh
# dos kNtErrorFileReadOnly EROFS # in consts.sh
# dos kNtErrorNoData ENODATA # in consts.sh
# dos WSAEPROCLIM EPROCLIM # in consts.sh
# dos WSAESHUTDOWN ESHUTDOWN # in consts.sh
# dos WSAEINPROGRESS EINPROGRESS # in consts.sh
# dos WSAENETDOWN ENETDOWN # in consts.sh
# dos WSAENETUNREACH ENETUNREACH # in consts.sh
# dos WSAENETRESET ENETRESET # in consts.sh
# dos WSAEUSERS EUSERS # in consts.sh
# dos WSAENOTSOCK ENOTSOCK # in consts.sh
# dos WSAEDESTADDRREQ EDESTADDRREQ # in consts.sh
# dos WSAEMSGSIZE EMSGSIZE # in consts.sh
# dos WSAEPROTOTYPE EPROTOTYPE # in consts.sh
# dos WSAENOPROTOOPT ENOPROTOOPT # in consts.sh
# dos WSAEPROTONOSUPPORT EPROTONOSUPPORT # in consts.sh
# dos WSAESOCKTNOSUPPORT ESOCKTNOSUPPORT # in consts.sh
# dos WSAEOPNOTSUPP ENOTSUP # in consts.sh
# dos WSAEOPNOTSUPP EOPNOTSUPP # in consts.sh
# dos WSAEPFNOSUPPORT EPFNOSUPPORT # in consts.sh
# dos WSAEAFNOSUPPORT EAFNOSUPPORT # in consts.sh
# dos WSAEADDRINUSE EADDRINUSE # in consts.sh
# dos WSAEADDRNOTAVAIL EADDRNOTAVAIL # in consts.sh
# dos WSAECONNABORTED ECONNABORTED # in consts.sh
# dos WSAECONNRESET ECONNRESET # in consts.sh
# dos WSAENOBUFS ENOBUFS # in consts.sh
# dos WSAEISCONN EISCONN # in consts.sh
# dos WSAENOTCONN ENOTCONN # in consts.sh
# dos WSAESHUTDOWN ESHUTDOWN # in consts.sh
# dos WSAETOOMANYREFS ETOOMANYREFS # in consts.sh
# dos WSAETIMEDOUT ETIMEDOUT # in consts.sh
# dos WSAECONNREFUSED ECONNREFUSED # in consts.sh
# dos WSAEHOSTDOWN EHOSTDOWN # in consts.sh
# dos WSAEHOSTUNREACH EHOSTUNREACH # in consts.sh
# dos WSAEALREADY EALREADY # in consts.sh
# dos WSAESTALE ESTALE # in consts.sh
# dos WSAEREMOTE EREMOTE # in consts.sh
# dos WSAEINTR EINTR # in consts.sh
# DOS ERRNO MULTIMAPPINGS
#
# These mappings are defined in a decentralized section which are
# grouped at linktime into kDos2Errno. (libc/intrin/kdos2errno.S)
#
dos kNtErrorInvalidTargetHandle EBADF
dos kNtErrorDirectAccessHandle EBADF
dos kNtErrorModNotFound ENOSYS
dos kNtErrorBadCommand EACCES
dos kNtErrorBadLength EACCES
dos kNtErrorBadNetpath ENOENT
dos kNtErrorBadNetName ENOENT
dos kNtErrorBadPathname ENOENT
dos kNtErrorBadNetResp ENETDOWN
dos kNtErrorFileExists EEXIST
dos kNtErrorCannotMake EACCES
dos kNtErrorCommitmentLimit ENOMEM
dos kNtErrorConnectionAborted ECONNABORTED
dos kNtErrorConnectionActive EISCONN
dos kNtErrorConnectionRefused ECONNREFUSED
dos kNtErrorCrc EACCES
dos kNtErrorDirNotEmpty ENOTEMPTY
dos kNtErrorDupName EADDRINUSE
dos kNtErrorFilenameExcedRange ENAMETOOLONG
dos kNtErrorGenFailure EACCES
dos kNtErrorGracefulDisconnect EPIPE
dos kNtErrorHostDown EHOSTUNREACH
dos kNtErrorHostUnreachable EHOSTUNREACH
dos kNtErrorInsufficientBuffer EFAULT
dos kNtErrorNoaccess EFAULT
dos kNtErrorInvalidAddress EADDRNOTAVAIL
dos kNtErrorNotAReparsePoint EINVAL
dos kNtErrorInvalidFunction EINVAL
dos kNtErrorInvalidNetname EADDRNOTAVAIL
dos kNtErrorInvalidUserBuffer EMSGSIZE
dos kNtErrorIoPending EINPROGRESS
dos kNtErrorLockViolation EACCES
dos kNtErrorMoreData EMSGSIZE
dos kNtErrorNetnameDeleted ECONNABORTED
dos kNtErrorNetworkAccessDenied EACCES
dos kNtErrorNetworkBusy ENETDOWN
dos kNtErrorNetworkUnreachable ENETUNREACH
dos kNtErrorNonpagedSystemResources ENOMEM
dos kNtErrorNotEnoughMemory ENOMEM
dos kNtErrorNotEnoughQuota ENOMEM
dos kNtErrorNotFound ENOENT
dos kNtErrorNotLocked EACCES
dos kNtErrorNotReady EACCES
dos kNtErrorNotSupported ENOTSUP
dos kNtErrorNoMoreFiles ENOENT
dos kNtErrorNoSystemResources ENOMEM
dos kNtErrorOperationAborted EINTR
dos kNtErrorOutOfPaper EACCES
dos kNtErrorPagedSystemResources ENOMEM
dos kNtErrorPagefileQuota ENOMEM
dos kNtErrorPipeNotConnected EPIPE
dos kNtErrorPortUnreachable ECONNRESET
dos kNtErrorProtocolUnreachable ENETUNREACH
dos kNtErrorRemNotList ECONNREFUSED
dos kNtErrorRequestAborted EINTR
dos kNtErrorReqNotAccep EWOULDBLOCK
dos kNtErrorSectorNotFound EACCES
dos kNtErrorSemTimeout ETIMEDOUT
dos kNtErrorSharingViolation EACCES
dos kNtErrorTooManyNames ENOMEM
dos kNtErrorUnexpNetErr ECONNABORTED
dos kNtErrorWorkingSetQuota ENOMEM
dos kNtErrorWriteProtect EACCES
dos kNtErrorWrongDisk EACCES
dos WSAEACCES EACCES
dos WSAEDISCON EPIPE
dos WSAEFAULT EFAULT
dos WSAEINVAL EINVAL
dos WSAEDQUOT EDQUOT
dos WSAEPROCLIM ENOMEM
dos WSANOTINITIALISED ENETDOWN
dos WSASYSNOTREADY ENETDOWN
dos WSAVERNOTSUPPORTED ENOSYS

View file

@ -0,0 +1,25 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EACCES
.type kDos2Errno.EACCES,@object
kDos2Errno.EACCES:
.e kNtErrorBadCommand,EACCES
.e kNtErrorBadLength,EACCES
.e kNtErrorCannotMake,EACCES
.e kNtErrorCrc,EACCES
.e kNtErrorGenFailure,EACCES
.e kNtErrorLockViolation,EACCES
.e kNtErrorNetworkAccessDenied,EACCES
.e kNtErrorNotLocked,EACCES
.e kNtErrorNotReady,EACCES
.e kNtErrorOutOfPaper,EACCES
.e kNtErrorSectorNotFound,EACCES
.e kNtErrorSharingViolation,EACCES
.e kNtErrorWriteProtect,EACCES
.e kNtErrorWrongDisk,EACCES
.e WSAEACCES,EACCES

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EADDRINUSE
.type kDos2Errno.EADDRINUSE,@object
kDos2Errno.EADDRINUSE:
.e kNtErrorDupName,EADDRINUSE

View file

@ -0,0 +1,12 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EADDRNOTAVAIL
.type kDos2Errno.EADDRNOTAVAIL,@object
kDos2Errno.EADDRNOTAVAIL:
.e kNtErrorInvalidAddress,EADDRNOTAVAIL
.e kNtErrorInvalidNetname,EADDRNOTAVAIL

View file

@ -0,0 +1,12 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EBADF
.type kDos2Errno.EBADF,@object
kDos2Errno.EBADF:
.e kNtErrorInvalidTargetHandle,EBADF
.e kNtErrorDirectAccessHandle,EBADF

View file

@ -0,0 +1,13 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ECONNABORTED
.type kDos2Errno.ECONNABORTED,@object
kDos2Errno.ECONNABORTED:
.e kNtErrorConnectionAborted,ECONNABORTED
.e kNtErrorNetnameDeleted,ECONNABORTED
.e kNtErrorUnexpNetErr,ECONNABORTED

View file

@ -0,0 +1,12 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ECONNREFUSED
.type kDos2Errno.ECONNREFUSED,@object
kDos2Errno.ECONNREFUSED:
.e kNtErrorConnectionRefused,ECONNREFUSED
.e kNtErrorRemNotList,ECONNREFUSED

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ECONNRESET
.type kDos2Errno.ECONNRESET,@object
kDos2Errno.ECONNRESET:
.e kNtErrorPortUnreachable,ECONNRESET

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EDQUOT
.type kDos2Errno.EDQUOT,@object
kDos2Errno.EDQUOT:
.e WSAEDQUOT,EDQUOT

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EEXIST
.type kDos2Errno.EEXIST,@object
kDos2Errno.EEXIST:
.e kNtErrorFileExists,EEXIST

View file

@ -0,0 +1,13 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EFAULT
.type kDos2Errno.EFAULT,@object
kDos2Errno.EFAULT:
.e kNtErrorInsufficientBuffer,EFAULT
.e kNtErrorNoaccess,EFAULT
.e WSAEFAULT,EFAULT

View file

@ -0,0 +1,12 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EHOSTUNREACH
.type kDos2Errno.EHOSTUNREACH,@object
kDos2Errno.EHOSTUNREACH:
.e kNtErrorHostDown,EHOSTUNREACH
.e kNtErrorHostUnreachable,EHOSTUNREACH

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EINPROGRESS
.type kDos2Errno.EINPROGRESS,@object
kDos2Errno.EINPROGRESS:
.e kNtErrorIoPending,EINPROGRESS

View file

@ -0,0 +1,12 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EINTR
.type kDos2Errno.EINTR,@object
kDos2Errno.EINTR:
.e kNtErrorOperationAborted,EINTR
.e kNtErrorRequestAborted,EINTR

View file

@ -0,0 +1,13 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EINVAL
.type kDos2Errno.EINVAL,@object
kDos2Errno.EINVAL:
.e kNtErrorNotAReparsePoint,EINVAL
.e kNtErrorInvalidFunction,EINVAL
.e WSAEINVAL,EINVAL

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EISCONN
.type kDos2Errno.EISCONN,@object
kDos2Errno.EISCONN:
.e kNtErrorConnectionActive,EISCONN

View file

@ -0,0 +1,12 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EMSGSIZE
.type kDos2Errno.EMSGSIZE,@object
kDos2Errno.EMSGSIZE:
.e kNtErrorInvalidUserBuffer,EMSGSIZE
.e kNtErrorMoreData,EMSGSIZE

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ENAMETOOLONG
.type kDos2Errno.ENAMETOOLONG,@object
kDos2Errno.ENAMETOOLONG:
.e kNtErrorFilenameExcedRange,ENAMETOOLONG

View file

@ -0,0 +1,14 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ENETDOWN
.type kDos2Errno.ENETDOWN,@object
kDos2Errno.ENETDOWN:
.e kNtErrorBadNetResp,ENETDOWN
.e kNtErrorNetworkBusy,ENETDOWN
.e WSANOTINITIALISED,ENETDOWN
.e WSASYSNOTREADY,ENETDOWN

View file

@ -0,0 +1,12 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ENETUNREACH
.type kDos2Errno.ENETUNREACH,@object
kDos2Errno.ENETUNREACH:
.e kNtErrorNetworkUnreachable,ENETUNREACH
.e kNtErrorProtocolUnreachable,ENETUNREACH

View file

@ -0,0 +1,15 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ENOENT
.type kDos2Errno.ENOENT,@object
kDos2Errno.ENOENT:
.e kNtErrorBadNetpath,ENOENT
.e kNtErrorBadNetName,ENOENT
.e kNtErrorBadPathname,ENOENT
.e kNtErrorNotFound,ENOENT
.e kNtErrorNoMoreFiles,ENOENT

View file

@ -0,0 +1,20 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ENOMEM
.type kDos2Errno.ENOMEM,@object
kDos2Errno.ENOMEM:
.e kNtErrorCommitmentLimit,ENOMEM
.e kNtErrorNonpagedSystemResources,ENOMEM
.e kNtErrorNotEnoughMemory,ENOMEM
.e kNtErrorNotEnoughQuota,ENOMEM
.e kNtErrorNoSystemResources,ENOMEM
.e kNtErrorPagedSystemResources,ENOMEM
.e kNtErrorPagefileQuota,ENOMEM
.e kNtErrorTooManyNames,ENOMEM
.e kNtErrorWorkingSetQuota,ENOMEM
.e WSAEPROCLIM,ENOMEM

View file

@ -0,0 +1,12 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ENOSYS
.type kDos2Errno.ENOSYS,@object
kDos2Errno.ENOSYS:
.e kNtErrorModNotFound,ENOSYS
.e WSAVERNOTSUPPORTED,ENOSYS

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ENOTEMPTY
.type kDos2Errno.ENOTEMPTY,@object
kDos2Errno.ENOTEMPTY:
.e kNtErrorDirNotEmpty,ENOTEMPTY

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ENOTSUP
.type kDos2Errno.ENOTSUP,@object
kDos2Errno.ENOTSUP:
.e kNtErrorNotSupported,ENOTSUP

View file

@ -0,0 +1,13 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EPIPE
.type kDos2Errno.EPIPE,@object
kDos2Errno.EPIPE:
.e kNtErrorGracefulDisconnect,EPIPE
.e kNtErrorPipeNotConnected,EPIPE
.e WSAEDISCON,EPIPE

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.ETIMEDOUT
.type kDos2Errno.ETIMEDOUT,@object
kDos2Errno.ETIMEDOUT:
.e kNtErrorSemTimeout,ETIMEDOUT

View file

@ -0,0 +1,11 @@
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.EWOULDBLOCK
.type kDos2Errno.EWOULDBLOCK,@object
kDos2Errno.EWOULDBLOCK:
.e kNtErrorReqNotAccep,EWOULDBLOCK

View file

@ -29,9 +29,17 @@ scall() {
}
syscon() {
if [ -f "libc/sysv/dos2errno/${2/$/-}.S" ]; then
EXT=".S"
else
EXT=".s"
fi
{
echo ".include \"o/libc/sysv/consts/syscon.internal.inc\""
echo ".syscon" "$*"
if [ -f "libc/sysv/dos2errno/${2/$/-}.S" ]; then
echo ".yoink kDos2Errno.${2/$/-}"
fi
} >"$dir/${2/$/-}.s"
}
@ -59,3 +67,23 @@ errfun() {
' "$ERRNO" "$NAME"
} >"$dir/${1/$/-}.S"
}
dos() {
DOS="$1"
UNIX="$2"
if ! [ -f "$dir/${UNIX/$/-}.S" ]; then
cat <<EOF >"$dir/${UNIX/$/-}.S"
// generated by libc/sysv/dos2errno.sh
#include "libc/nt/errors.h"
.macro .e doscode systemv
.short \doscode
.long \systemv
.endm
.section .sort.rodata.dos2errno.2,"a",@progbits
.globl kDos2Errno.${UNIX}
.type kDos2Errno.${UNIX},@object
kDos2Errno.${UNIX}:
EOF
fi
printf %s\\n " .e ${DOS},${UNIX}" >>"$dir/${UNIX/$/-}.S"
}

View file

@ -43,7 +43,8 @@ LIBC_SYSV_A_FILES := \
libc/sysv/strace.greg.c \
libc/sysv/describeos.greg.c \
$(wildcard libc/sysv/consts/*) \
$(wildcard libc/sysv/errfuns/*)
$(wildcard libc/sysv/errfuns/*) \
$(wildcard libc/sysv/dos2errno/*)
LIBC_SYSV_A_SRCS = \
$(LIBC_SYSV_A_SRCS_A) \

View file

@ -17,11 +17,11 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/errno.h"
#include "libc/fmt/fmt.h"
#include "libc/intrin/dos2errno.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/nt/errors.h"
#include "libc/sock/internal.h"
#include "libc/sock/sock.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
TEST(__dos2errno, test) {