@@ -1431,129 +1431,15 @@ addToLibrary({
14311431 'EOWNERDEAD': {{{ cDefs.EOWNERDEAD }}},
14321432 'ESTRPIPE': {{{ cDefs.ESTRPIPE }}},
14331433 }` ,
1434- $ERRNO_MESSAGES : {
1435- 0 : 'Success ',
1436- { { { cDefs . EPERM } } } : 'Not super - user ',
1437- { { { cDefs . ENOENT } } } : 'No such file or directory' ,
1438- { { { cDefs. ESRCH } } } : 'No such process' ,
1439- { { { cDefs. EINTR } } } : 'Interrupted system call' ,
1440- { { { cDefs. EIO } } } : 'I/O error' ,
1441- { { { cDefs. ENXIO } } } : 'No such device or address' ,
1442- { { { cDefs. E2BIG } } } : 'Arg list too long' ,
1443- { { { cDefs . ENOEXEC } } } : 'Exec format error' ,
1444- { { { cDefs. EBADF } } } : 'Bad file number' ,
1445- { { { cDefs . ECHILD } } } : 'No children' ,
1446- { { { cDefs . EWOULDBLOCK } } } : 'No more processes' ,
1447- { { { cDefs . ENOMEM } } } : 'Not enough core' ,
1448- { { { cDefs . EACCES } } } : 'Permission denied' ,
1449- { { { cDefs . EFAULT } } } : 'Bad address' ,
1450- { { { cDefs . ENOTBLK } } } : 'Block device required' ,
1451- { { { cDefs. EBUSY } } } : 'Mount device busy' ,
1452- { { { cDefs . EEXIST } } } : 'File exists' ,
1453- { { { cDefs. EXDEV } } } : 'Cross-device link' ,
1454- { { { cDefs . ENODEV } } } : 'No such device' ,
1455- { { { cDefs . ENOTDIR } } } : 'Not a directory' ,
1456- { { { cDefs . EISDIR } } } : 'Is a directory' ,
1457- { { { cDefs . EINVAL } } } : 'Invalid argument' ,
1458- { { { cDefs . ENFILE } } } : 'Too many open files in system' ,
1459- { { { cDefs . EMFILE } } } : 'Too many open files' ,
1460- { { { cDefs . ENOTTY } } } : 'Not a typewriter' ,
1461- { { { cDefs . ETXTBSY } } } : 'Text file busy' ,
1462- { { { cDefs. EFBIG } } } : 'File too large' ,
1463- { { { cDefs . ENOSPC } } } : 'No space left on device' ,
1464- { { { cDefs . ESPIPE } } } : 'Illegal seek' ,
1465- { { { cDefs. EROFS } } } : 'Read only file system' ,
1466- { { { cDefs . EMLINK } } } : 'Too many links' ,
1467- { { { cDefs. EPIPE } } } : 'Broken pipe' ,
1468- { { { cDefs. EDOM } } } : 'Math arg out of domain of func' ,
1469- { { { cDefs . ERANGE } } } : 'Math result not representable' ,
1470- { { { cDefs . ENOMSG } } } : 'No message of desired type' ,
1471- { { { cDefs. EIDRM } } } : 'Identifier removed' ,
1472- { { { cDefs . ECHRNG } } } : 'Channel number out of range' ,
1473- { { { cDefs . EL2NSYNC } } } : 'Level 2 not synchronized' ,
1474- { { { cDefs . EL3HLT } } } : 'Level 3 halted' ,
1475- { { { cDefs . EL3RST } } } : 'Level 3 reset' ,
1476- { { { cDefs . ELNRNG } } } : 'Link number out of range' ,
1477- { { { cDefs . EUNATCH } } } : 'Protocol driver not attached' ,
1478- { { { cDefs . ENOCSI } } } : 'No CSI structure available' ,
1479- { { { cDefs . EL2HLT } } } : 'Level 2 halted' ,
1480- { { { cDefs . EDEADLK } } } : 'Deadlock condition' ,
1481- { { { cDefs . ENOLCK } } } : 'No record locks available' ,
1482- { { { cDefs. EBADE } } } : 'Invalid exchange' ,
1483- { { { cDefs. EBADR } } } : 'Invalid request descriptor' ,
1484- { { { cDefs . EXFULL } } } : 'Exchange full' ,
1485- { { { cDefs . ENOANO } } } : 'No anode' ,
1486- { { { cDefs . EBADRQC } } } : 'Invalid request code' ,
1487- { { { cDefs . EBADSLT } } } : 'Invalid slot' ,
1488- { { { cDefs . EDEADLOCK } } } : 'File locking deadlock error' ,
1489- { { { cDefs . EBFONT } } } : 'Bad font file fmt' ,
1490- { { { cDefs . ENOSTR } } } : 'Device not a stream' ,
1491- { { { cDefs . ENODATA } } } : 'No data (for no delay io)' ,
1492- { { { cDefs. ETIME } } } : 'Timer expired' ,
1493- { { { cDefs. ENOSR } } } : 'Out of streams resources' ,
1494- { { { cDefs . ENONET } } } : 'Machine is not on the network' ,
1495- { { { cDefs . ENOPKG } } } : 'Package not installed' ,
1496- { { { cDefs . EREMOTE } } } : 'The object is remote' ,
1497- { { { cDefs . ENOLINK } } } : 'The link has been severed' ,
1498- { { { cDefs. EADV } } } : 'Advertise error' ,
1499- { { { cDefs . ESRMNT } } } : 'Srmount error' ,
1500- { { { cDefs. ECOMM } } } : 'Communication error on send' ,
1501- { { { cDefs . EPROTO } } } : 'Protocol error' ,
1502- { { { cDefs . EMULTIHOP } } } : 'Multihop attempted' ,
1503- { { { cDefs . EDOTDOT } } } : 'Cross mount point (not really error)' ,
1504- { { { cDefs . EBADMSG } } } : 'Trying to read unreadable message' ,
1505- { { { cDefs . ENOTUNIQ } } } : 'Given log. name not unique' ,
1506- { { { cDefs . EBADFD } } } : 'f.d. invalid for this operation' ,
1507- { { { cDefs . EREMCHG } } } : 'Remote address changed' ,
1508- { { { cDefs . ELIBACC } } } : 'Can access a needed shared lib' ,
1509- { { { cDefs . ELIBBAD } } } : 'Accessing a corrupted shared lib' ,
1510- { { { cDefs . ELIBSCN } } } : '.lib section in a.out corrupted' ,
1511- { { { cDefs . ELIBMAX } } } : 'Attempting to link in too many libs' ,
1512- { { { cDefs . ELIBEXEC } } } : 'Attempting to exec a shared library' ,
1513- { { { cDefs . ENOSYS } } } : 'Function not implemented' ,
1514- { { { cDefs . ENOTEMPTY } } } : 'Directory not empty' ,
1515- { { { cDefs . ENAMETOOLONG } } } : 'File or path name too long' ,
1516- { { { cDefs. ELOOP } } } : 'Too many symbolic links' ,
1517- { { { cDefs . EOPNOTSUPP } } } : 'Operation not supported on transport endpoint' ,
1518- { { { cDefs . EPFNOSUPPORT } } } : 'Protocol family not supported' ,
1519- { { { cDefs . ECONNRESET } } } : 'Connection reset by peer' ,
1520- { { { cDefs . ENOBUFS } } } : 'No buffer space available' ,
1521- { { { cDefs . EAFNOSUPPORT } } } : 'Address family not supported by protocol family' ,
1522- { { { cDefs . EPROTOTYPE } } } : 'Protocol wrong type for socket' ,
1523- { { { cDefs . ENOTSOCK } } } : 'Socket operation on non-socket' ,
1524- { { { cDefs . ENOPROTOOPT } } } : 'Protocol not available' ,
1525- { { { cDefs . ESHUTDOWN } } } : 'Can\'t send after socket shutdown' ,
1526- { { { cDefs . ECONNREFUSED } } } : 'Connection refused' ,
1527- { { { cDefs . EADDRINUSE } } } : 'Address already in use' ,
1528- { { { cDefs . ECONNABORTED } } } : 'Connection aborted' ,
1529- { { { cDefs . ENETUNREACH } } } : 'Network is unreachable' ,
1530- { { { cDefs . ENETDOWN } } } : 'Network interface is not configured' ,
1531- { { { cDefs . ETIMEDOUT } } } : 'Connection timed out' ,
1532- { { { cDefs . EHOSTDOWN } } } : 'Host is down' ,
1533- { { { cDefs . EHOSTUNREACH } } } : 'Host is unreachable' ,
1534- { { { cDefs . EINPROGRESS } } } : 'Connection already in progress' ,
1535- { { { cDefs . EALREADY } } } : 'Socket already connected' ,
1536- { { { cDefs . EDESTADDRREQ } } } : 'Destination address required' ,
1537- { { { cDefs . EMSGSIZE } } } : 'Message too long' ,
1538- { { { cDefs . EPROTONOSUPPORT } } } : 'Unknown protocol' ,
1539- { { { cDefs . ESOCKTNOSUPPORT } } } : 'Socket type not supported' ,
1540- { { { cDefs . EADDRNOTAVAIL } } } : 'Address not available' ,
1541- { { { cDefs . ENETRESET } } } : 'Connection reset by network' ,
1542- { { { cDefs . EISCONN } } } : 'Socket is already connected' ,
1543- { { { cDefs . ENOTCONN } } } : 'Socket is not connected' ,
1544- { { { cDefs . ETOOMANYREFS } } } : 'Too many references' ,
1545- { { { cDefs . EUSERS } } } : 'Too many users' ,
1546- { { { cDefs . EDQUOT } } } : 'Quota exceeded' ,
1547- { { { cDefs . ESTALE } } } : 'Stale file handle' ,
1548- { { { cDefs . ENOTSUP } } } : 'Not supported' ,
1549- { { { cDefs . ENOMEDIUM } } } : 'No medium (in tape drive)' ,
1550- { { { cDefs . EILSEQ } } } : 'Illegal byte sequence' ,
1551- { { { cDefs . EOVERFLOW } } } : 'Value too large for defined data type' ,
1552- { { { cDefs . ECANCELED } } } : 'Operation canceled' ,
1553- { { { cDefs . ENOTRECOVERABLE } } } : 'State not recoverable' ,
1554- { { { cDefs . EOWNERDEAD } } } : 'Previous owner died' ,
1555- { { { cDefs . ESTRPIPE } } } : 'Streams pipe error' ,
1434+
1435+ #if PURE_WASI
1436+ $strError : ( errno ) = > errno + '' ,
1437+ #else
1438+ $strError__deps : [ 'strerror' , '$UTF8ToString' ] ,
1439+ $strError : ( errno ) = > {
1440+ return UTF8ToString ( _strerror ( errno ) ) ;
15561441 } ,
1442+ #endif
15571443
15581444#if PROXY_POSIX_SOCKETS == 0
15591445 // ==========================================================================
@@ -3386,7 +3272,7 @@ function wrapSyscallFunction(x, library, isWasi) {
33863272 pre += "var ret = (() => {" ;
33873273 post += "})();\n" ;
33883274 post += "if (ret && ret < 0 && canWarn) {\n" ;
3389- post += " dbg(`error: syscall may have failed with ${-ret} (${ERRNO_MESSAGES[ -ret] })`);\n" ;
3275+ post += " dbg(`error: syscall may have failed with ${-ret} (${strError( -ret) })`);\n" ;
33903276 post += "}\n" ;
33913277 post += "dbg(`syscall return: ${ret}`);\n" ;
33923278 post += "return ret;\n" ;
@@ -3400,7 +3286,7 @@ function wrapSyscallFunction(x, library, isWasi) {
34003286 " if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;\n" ;
34013287#if SYSCALL_DEBUG
34023288 handler +=
3403- " dbg(`error: syscall failed with ${e.errno} (${ERRNO_MESSAGES[ e.errno] })`);\n" +
3289+ " dbg(`error: syscall failed with ${e.errno} (${strError( e.errno) })`);\n" +
34043290 " canWarn = false;\n" ;
34053291#endif
34063292 // Musl syscalls are negated.
0 commit comments