Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bb296f1

Browse files
committedDec 13, 2019
Avoid using cast expressions in WASI API constants.
Cast expressions aren't valid to use in some preprocessor constants, so change the constants to use `UINT32_C` etc. instead of casts. Fixes #146.
1 parent f645f49 commit bb296f1

File tree

3 files changed

+379
-370
lines changed

3 files changed

+379
-370
lines changed
 

‎expected/wasm32-wasi/predefined-macros.txt

+183-183
Original file line numberDiff line numberDiff line change
@@ -2880,190 +2880,190 @@
28802880
#define __UINT_LEAST8_MAX__ 255
28812881
#define __UINT_LEAST8_TYPE__ unsigned char
28822882
#define __USER_LABEL_PREFIX__
2883-
#define __WASI_ADVICE_DONTNEED ((__wasi_advice_t)4)
2884-
#define __WASI_ADVICE_NOREUSE ((__wasi_advice_t)5)
2885-
#define __WASI_ADVICE_NORMAL ((__wasi_advice_t)0)
2886-
#define __WASI_ADVICE_RANDOM ((__wasi_advice_t)2)
2887-
#define __WASI_ADVICE_SEQUENTIAL ((__wasi_advice_t)1)
2888-
#define __WASI_ADVICE_WILLNEED ((__wasi_advice_t)3)
2889-
#define __WASI_CLOCKID_MONOTONIC ((__wasi_clockid_t)1)
2890-
#define __WASI_CLOCKID_PROCESS_CPUTIME_ID ((__wasi_clockid_t)2)
2891-
#define __WASI_CLOCKID_REALTIME ((__wasi_clockid_t)0)
2892-
#define __WASI_CLOCKID_THREAD_CPUTIME_ID ((__wasi_clockid_t)3)
2883+
#define __WASI_ADVICE_DONTNEED (UINT8_C(4))
2884+
#define __WASI_ADVICE_NOREUSE (UINT8_C(5))
2885+
#define __WASI_ADVICE_NORMAL (UINT8_C(0))
2886+
#define __WASI_ADVICE_RANDOM (UINT8_C(2))
2887+
#define __WASI_ADVICE_SEQUENTIAL (UINT8_C(1))
2888+
#define __WASI_ADVICE_WILLNEED (UINT8_C(3))
2889+
#define __WASI_CLOCKID_MONOTONIC (UINT32_C(1))
2890+
#define __WASI_CLOCKID_PROCESS_CPUTIME_ID (UINT32_C(2))
2891+
#define __WASI_CLOCKID_REALTIME (UINT32_C(0))
2892+
#define __WASI_CLOCKID_THREAD_CPUTIME_ID (UINT32_C(3))
28932893
#define __WASI_DIRCOOKIE_START (UINT64_C(0))
2894-
#define __WASI_ERRNO_2BIG ((__wasi_errno_t)1)
2895-
#define __WASI_ERRNO_ACCES ((__wasi_errno_t)2)
2896-
#define __WASI_ERRNO_ADDRINUSE ((__wasi_errno_t)3)
2897-
#define __WASI_ERRNO_ADDRNOTAVAIL ((__wasi_errno_t)4)
2898-
#define __WASI_ERRNO_AFNOSUPPORT ((__wasi_errno_t)5)
2899-
#define __WASI_ERRNO_AGAIN ((__wasi_errno_t)6)
2900-
#define __WASI_ERRNO_ALREADY ((__wasi_errno_t)7)
2901-
#define __WASI_ERRNO_BADF ((__wasi_errno_t)8)
2902-
#define __WASI_ERRNO_BADMSG ((__wasi_errno_t)9)
2903-
#define __WASI_ERRNO_BUSY ((__wasi_errno_t)10)
2904-
#define __WASI_ERRNO_CANCELED ((__wasi_errno_t)11)
2905-
#define __WASI_ERRNO_CHILD ((__wasi_errno_t)12)
2906-
#define __WASI_ERRNO_CONNABORTED ((__wasi_errno_t)13)
2907-
#define __WASI_ERRNO_CONNREFUSED ((__wasi_errno_t)14)
2908-
#define __WASI_ERRNO_CONNRESET ((__wasi_errno_t)15)
2909-
#define __WASI_ERRNO_DEADLK ((__wasi_errno_t)16)
2910-
#define __WASI_ERRNO_DESTADDRREQ ((__wasi_errno_t)17)
2911-
#define __WASI_ERRNO_DOM ((__wasi_errno_t)18)
2912-
#define __WASI_ERRNO_DQUOT ((__wasi_errno_t)19)
2913-
#define __WASI_ERRNO_EXIST ((__wasi_errno_t)20)
2914-
#define __WASI_ERRNO_FAULT ((__wasi_errno_t)21)
2915-
#define __WASI_ERRNO_FBIG ((__wasi_errno_t)22)
2916-
#define __WASI_ERRNO_HOSTUNREACH ((__wasi_errno_t)23)
2917-
#define __WASI_ERRNO_IDRM ((__wasi_errno_t)24)
2918-
#define __WASI_ERRNO_ILSEQ ((__wasi_errno_t)25)
2919-
#define __WASI_ERRNO_INPROGRESS ((__wasi_errno_t)26)
2920-
#define __WASI_ERRNO_INTR ((__wasi_errno_t)27)
2921-
#define __WASI_ERRNO_INVAL ((__wasi_errno_t)28)
2922-
#define __WASI_ERRNO_IO ((__wasi_errno_t)29)
2923-
#define __WASI_ERRNO_ISCONN ((__wasi_errno_t)30)
2924-
#define __WASI_ERRNO_ISDIR ((__wasi_errno_t)31)
2925-
#define __WASI_ERRNO_LOOP ((__wasi_errno_t)32)
2926-
#define __WASI_ERRNO_MFILE ((__wasi_errno_t)33)
2927-
#define __WASI_ERRNO_MLINK ((__wasi_errno_t)34)
2928-
#define __WASI_ERRNO_MSGSIZE ((__wasi_errno_t)35)
2929-
#define __WASI_ERRNO_MULTIHOP ((__wasi_errno_t)36)
2930-
#define __WASI_ERRNO_NAMETOOLONG ((__wasi_errno_t)37)
2931-
#define __WASI_ERRNO_NETDOWN ((__wasi_errno_t)38)
2932-
#define __WASI_ERRNO_NETRESET ((__wasi_errno_t)39)
2933-
#define __WASI_ERRNO_NETUNREACH ((__wasi_errno_t)40)
2934-
#define __WASI_ERRNO_NFILE ((__wasi_errno_t)41)
2935-
#define __WASI_ERRNO_NOBUFS ((__wasi_errno_t)42)
2936-
#define __WASI_ERRNO_NODEV ((__wasi_errno_t)43)
2937-
#define __WASI_ERRNO_NOENT ((__wasi_errno_t)44)
2938-
#define __WASI_ERRNO_NOEXEC ((__wasi_errno_t)45)
2939-
#define __WASI_ERRNO_NOLCK ((__wasi_errno_t)46)
2940-
#define __WASI_ERRNO_NOLINK ((__wasi_errno_t)47)
2941-
#define __WASI_ERRNO_NOMEM ((__wasi_errno_t)48)
2942-
#define __WASI_ERRNO_NOMSG ((__wasi_errno_t)49)
2943-
#define __WASI_ERRNO_NOPROTOOPT ((__wasi_errno_t)50)
2944-
#define __WASI_ERRNO_NOSPC ((__wasi_errno_t)51)
2945-
#define __WASI_ERRNO_NOSYS ((__wasi_errno_t)52)
2946-
#define __WASI_ERRNO_NOTCAPABLE ((__wasi_errno_t)76)
2947-
#define __WASI_ERRNO_NOTCONN ((__wasi_errno_t)53)
2948-
#define __WASI_ERRNO_NOTDIR ((__wasi_errno_t)54)
2949-
#define __WASI_ERRNO_NOTEMPTY ((__wasi_errno_t)55)
2950-
#define __WASI_ERRNO_NOTRECOVERABLE ((__wasi_errno_t)56)
2951-
#define __WASI_ERRNO_NOTSOCK ((__wasi_errno_t)57)
2952-
#define __WASI_ERRNO_NOTSUP ((__wasi_errno_t)58)
2953-
#define __WASI_ERRNO_NOTTY ((__wasi_errno_t)59)
2954-
#define __WASI_ERRNO_NXIO ((__wasi_errno_t)60)
2955-
#define __WASI_ERRNO_OVERFLOW ((__wasi_errno_t)61)
2956-
#define __WASI_ERRNO_OWNERDEAD ((__wasi_errno_t)62)
2957-
#define __WASI_ERRNO_PERM ((__wasi_errno_t)63)
2958-
#define __WASI_ERRNO_PIPE ((__wasi_errno_t)64)
2959-
#define __WASI_ERRNO_PROTO ((__wasi_errno_t)65)
2960-
#define __WASI_ERRNO_PROTONOSUPPORT ((__wasi_errno_t)66)
2961-
#define __WASI_ERRNO_PROTOTYPE ((__wasi_errno_t)67)
2962-
#define __WASI_ERRNO_RANGE ((__wasi_errno_t)68)
2963-
#define __WASI_ERRNO_ROFS ((__wasi_errno_t)69)
2964-
#define __WASI_ERRNO_SPIPE ((__wasi_errno_t)70)
2965-
#define __WASI_ERRNO_SRCH ((__wasi_errno_t)71)
2966-
#define __WASI_ERRNO_STALE ((__wasi_errno_t)72)
2967-
#define __WASI_ERRNO_SUCCESS ((__wasi_errno_t)0)
2968-
#define __WASI_ERRNO_TIMEDOUT ((__wasi_errno_t)73)
2969-
#define __WASI_ERRNO_TXTBSY ((__wasi_errno_t)74)
2970-
#define __WASI_ERRNO_XDEV ((__wasi_errno_t)75)
2971-
#define __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP ((__wasi_eventrwflags_t)1)
2972-
#define __WASI_EVENTTYPE_CLOCK ((__wasi_eventtype_t)0)
2973-
#define __WASI_EVENTTYPE_FD_READ ((__wasi_eventtype_t)1)
2974-
#define __WASI_EVENTTYPE_FD_WRITE ((__wasi_eventtype_t)2)
2975-
#define __WASI_FDFLAGS_APPEND ((__wasi_fdflags_t)1)
2976-
#define __WASI_FDFLAGS_DSYNC ((__wasi_fdflags_t)2)
2977-
#define __WASI_FDFLAGS_NONBLOCK ((__wasi_fdflags_t)4)
2978-
#define __WASI_FDFLAGS_RSYNC ((__wasi_fdflags_t)8)
2979-
#define __WASI_FDFLAGS_SYNC ((__wasi_fdflags_t)16)
2980-
#define __WASI_FILETYPE_BLOCK_DEVICE ((__wasi_filetype_t)1)
2981-
#define __WASI_FILETYPE_CHARACTER_DEVICE ((__wasi_filetype_t)2)
2982-
#define __WASI_FILETYPE_DIRECTORY ((__wasi_filetype_t)3)
2983-
#define __WASI_FILETYPE_REGULAR_FILE ((__wasi_filetype_t)4)
2984-
#define __WASI_FILETYPE_SOCKET_DGRAM ((__wasi_filetype_t)5)
2985-
#define __WASI_FILETYPE_SOCKET_STREAM ((__wasi_filetype_t)6)
2986-
#define __WASI_FILETYPE_SYMBOLIC_LINK ((__wasi_filetype_t)7)
2987-
#define __WASI_FILETYPE_UNKNOWN ((__wasi_filetype_t)0)
2988-
#define __WASI_FSTFLAGS_ATIM ((__wasi_fstflags_t)1)
2989-
#define __WASI_FSTFLAGS_ATIM_NOW ((__wasi_fstflags_t)2)
2990-
#define __WASI_FSTFLAGS_MTIM ((__wasi_fstflags_t)4)
2991-
#define __WASI_FSTFLAGS_MTIM_NOW ((__wasi_fstflags_t)8)
2992-
#define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW ((__wasi_lookupflags_t)1)
2993-
#define __WASI_OFLAGS_CREAT ((__wasi_oflags_t)1)
2994-
#define __WASI_OFLAGS_DIRECTORY ((__wasi_oflags_t)2)
2995-
#define __WASI_OFLAGS_EXCL ((__wasi_oflags_t)4)
2996-
#define __WASI_OFLAGS_TRUNC ((__wasi_oflags_t)8)
2997-
#define __WASI_PREOPENTYPE_DIR ((__wasi_preopentype_t)0)
2998-
#define __WASI_RIFLAGS_RECV_PEEK ((__wasi_riflags_t)1)
2999-
#define __WASI_RIFLAGS_RECV_WAITALL ((__wasi_riflags_t)2)
3000-
#define __WASI_RIGHTS_FD_ADVISE ((__wasi_rights_t)128)
3001-
#define __WASI_RIGHTS_FD_ALLOCATE ((__wasi_rights_t)256)
3002-
#define __WASI_RIGHTS_FD_DATASYNC ((__wasi_rights_t)1)
3003-
#define __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS ((__wasi_rights_t)8)
3004-
#define __WASI_RIGHTS_FD_FILESTAT_GET ((__wasi_rights_t)2097152)
3005-
#define __WASI_RIGHTS_FD_FILESTAT_SET_SIZE ((__wasi_rights_t)4194304)
3006-
#define __WASI_RIGHTS_FD_FILESTAT_SET_TIMES ((__wasi_rights_t)8388608)
3007-
#define __WASI_RIGHTS_FD_READ ((__wasi_rights_t)2)
3008-
#define __WASI_RIGHTS_FD_READDIR ((__wasi_rights_t)16384)
3009-
#define __WASI_RIGHTS_FD_SEEK ((__wasi_rights_t)4)
3010-
#define __WASI_RIGHTS_FD_SYNC ((__wasi_rights_t)16)
3011-
#define __WASI_RIGHTS_FD_TELL ((__wasi_rights_t)32)
3012-
#define __WASI_RIGHTS_FD_WRITE ((__wasi_rights_t)64)
3013-
#define __WASI_RIGHTS_PATH_CREATE_DIRECTORY ((__wasi_rights_t)512)
3014-
#define __WASI_RIGHTS_PATH_CREATE_FILE ((__wasi_rights_t)1024)
3015-
#define __WASI_RIGHTS_PATH_FILESTAT_GET ((__wasi_rights_t)262144)
3016-
#define __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE ((__wasi_rights_t)524288)
3017-
#define __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES ((__wasi_rights_t)1048576)
3018-
#define __WASI_RIGHTS_PATH_LINK_SOURCE ((__wasi_rights_t)2048)
3019-
#define __WASI_RIGHTS_PATH_LINK_TARGET ((__wasi_rights_t)4096)
3020-
#define __WASI_RIGHTS_PATH_OPEN ((__wasi_rights_t)8192)
3021-
#define __WASI_RIGHTS_PATH_READLINK ((__wasi_rights_t)32768)
3022-
#define __WASI_RIGHTS_PATH_REMOVE_DIRECTORY ((__wasi_rights_t)33554432)
3023-
#define __WASI_RIGHTS_PATH_RENAME_SOURCE ((__wasi_rights_t)65536)
3024-
#define __WASI_RIGHTS_PATH_RENAME_TARGET ((__wasi_rights_t)131072)
3025-
#define __WASI_RIGHTS_PATH_SYMLINK ((__wasi_rights_t)16777216)
3026-
#define __WASI_RIGHTS_PATH_UNLINK_FILE ((__wasi_rights_t)67108864)
3027-
#define __WASI_RIGHTS_POLL_FD_READWRITE ((__wasi_rights_t)134217728)
3028-
#define __WASI_RIGHTS_SOCK_SHUTDOWN ((__wasi_rights_t)268435456)
3029-
#define __WASI_ROFLAGS_RECV_DATA_TRUNCATED ((__wasi_roflags_t)1)
3030-
#define __WASI_SDFLAGS_RD ((__wasi_sdflags_t)1)
3031-
#define __WASI_SDFLAGS_WR ((__wasi_sdflags_t)2)
3032-
#define __WASI_SIGNAL_ABRT ((__wasi_signal_t)6)
3033-
#define __WASI_SIGNAL_ALRM ((__wasi_signal_t)14)
3034-
#define __WASI_SIGNAL_BUS ((__wasi_signal_t)7)
3035-
#define __WASI_SIGNAL_CHLD ((__wasi_signal_t)16)
3036-
#define __WASI_SIGNAL_CONT ((__wasi_signal_t)17)
3037-
#define __WASI_SIGNAL_FPE ((__wasi_signal_t)8)
3038-
#define __WASI_SIGNAL_HUP ((__wasi_signal_t)1)
3039-
#define __WASI_SIGNAL_ILL ((__wasi_signal_t)4)
3040-
#define __WASI_SIGNAL_INT ((__wasi_signal_t)2)
3041-
#define __WASI_SIGNAL_KILL ((__wasi_signal_t)9)
3042-
#define __WASI_SIGNAL_NONE ((__wasi_signal_t)0)
3043-
#define __WASI_SIGNAL_PIPE ((__wasi_signal_t)13)
3044-
#define __WASI_SIGNAL_POLL ((__wasi_signal_t)28)
3045-
#define __WASI_SIGNAL_PROF ((__wasi_signal_t)26)
3046-
#define __WASI_SIGNAL_PWR ((__wasi_signal_t)29)
3047-
#define __WASI_SIGNAL_QUIT ((__wasi_signal_t)3)
3048-
#define __WASI_SIGNAL_SEGV ((__wasi_signal_t)11)
3049-
#define __WASI_SIGNAL_STOP ((__wasi_signal_t)18)
3050-
#define __WASI_SIGNAL_SYS ((__wasi_signal_t)30)
3051-
#define __WASI_SIGNAL_TERM ((__wasi_signal_t)15)
3052-
#define __WASI_SIGNAL_TRAP ((__wasi_signal_t)5)
3053-
#define __WASI_SIGNAL_TSTP ((__wasi_signal_t)19)
3054-
#define __WASI_SIGNAL_TTIN ((__wasi_signal_t)20)
3055-
#define __WASI_SIGNAL_TTOU ((__wasi_signal_t)21)
3056-
#define __WASI_SIGNAL_URG ((__wasi_signal_t)22)
3057-
#define __WASI_SIGNAL_USR1 ((__wasi_signal_t)10)
3058-
#define __WASI_SIGNAL_USR2 ((__wasi_signal_t)12)
3059-
#define __WASI_SIGNAL_VTALRM ((__wasi_signal_t)25)
3060-
#define __WASI_SIGNAL_WINCH ((__wasi_signal_t)27)
3061-
#define __WASI_SIGNAL_XCPU ((__wasi_signal_t)23)
3062-
#define __WASI_SIGNAL_XFSZ ((__wasi_signal_t)24)
3063-
#define __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME ((__wasi_subclockflags_t)1)
3064-
#define __WASI_WHENCE_CUR ((__wasi_whence_t)1)
3065-
#define __WASI_WHENCE_END ((__wasi_whence_t)2)
3066-
#define __WASI_WHENCE_SET ((__wasi_whence_t)0)
2894+
#define __WASI_ERRNO_2BIG (UINT16_C(1))
2895+
#define __WASI_ERRNO_ACCES (UINT16_C(2))
2896+
#define __WASI_ERRNO_ADDRINUSE (UINT16_C(3))
2897+
#define __WASI_ERRNO_ADDRNOTAVAIL (UINT16_C(4))
2898+
#define __WASI_ERRNO_AFNOSUPPORT (UINT16_C(5))
2899+
#define __WASI_ERRNO_AGAIN (UINT16_C(6))
2900+
#define __WASI_ERRNO_ALREADY (UINT16_C(7))
2901+
#define __WASI_ERRNO_BADF (UINT16_C(8))
2902+
#define __WASI_ERRNO_BADMSG (UINT16_C(9))
2903+
#define __WASI_ERRNO_BUSY (UINT16_C(10))
2904+
#define __WASI_ERRNO_CANCELED (UINT16_C(11))
2905+
#define __WASI_ERRNO_CHILD (UINT16_C(12))
2906+
#define __WASI_ERRNO_CONNABORTED (UINT16_C(13))
2907+
#define __WASI_ERRNO_CONNREFUSED (UINT16_C(14))
2908+
#define __WASI_ERRNO_CONNRESET (UINT16_C(15))
2909+
#define __WASI_ERRNO_DEADLK (UINT16_C(16))
2910+
#define __WASI_ERRNO_DESTADDRREQ (UINT16_C(17))
2911+
#define __WASI_ERRNO_DOM (UINT16_C(18))
2912+
#define __WASI_ERRNO_DQUOT (UINT16_C(19))
2913+
#define __WASI_ERRNO_EXIST (UINT16_C(20))
2914+
#define __WASI_ERRNO_FAULT (UINT16_C(21))
2915+
#define __WASI_ERRNO_FBIG (UINT16_C(22))
2916+
#define __WASI_ERRNO_HOSTUNREACH (UINT16_C(23))
2917+
#define __WASI_ERRNO_IDRM (UINT16_C(24))
2918+
#define __WASI_ERRNO_ILSEQ (UINT16_C(25))
2919+
#define __WASI_ERRNO_INPROGRESS (UINT16_C(26))
2920+
#define __WASI_ERRNO_INTR (UINT16_C(27))
2921+
#define __WASI_ERRNO_INVAL (UINT16_C(28))
2922+
#define __WASI_ERRNO_IO (UINT16_C(29))
2923+
#define __WASI_ERRNO_ISCONN (UINT16_C(30))
2924+
#define __WASI_ERRNO_ISDIR (UINT16_C(31))
2925+
#define __WASI_ERRNO_LOOP (UINT16_C(32))
2926+
#define __WASI_ERRNO_MFILE (UINT16_C(33))
2927+
#define __WASI_ERRNO_MLINK (UINT16_C(34))
2928+
#define __WASI_ERRNO_MSGSIZE (UINT16_C(35))
2929+
#define __WASI_ERRNO_MULTIHOP (UINT16_C(36))
2930+
#define __WASI_ERRNO_NAMETOOLONG (UINT16_C(37))
2931+
#define __WASI_ERRNO_NETDOWN (UINT16_C(38))
2932+
#define __WASI_ERRNO_NETRESET (UINT16_C(39))
2933+
#define __WASI_ERRNO_NETUNREACH (UINT16_C(40))
2934+
#define __WASI_ERRNO_NFILE (UINT16_C(41))
2935+
#define __WASI_ERRNO_NOBUFS (UINT16_C(42))
2936+
#define __WASI_ERRNO_NODEV (UINT16_C(43))
2937+
#define __WASI_ERRNO_NOENT (UINT16_C(44))
2938+
#define __WASI_ERRNO_NOEXEC (UINT16_C(45))
2939+
#define __WASI_ERRNO_NOLCK (UINT16_C(46))
2940+
#define __WASI_ERRNO_NOLINK (UINT16_C(47))
2941+
#define __WASI_ERRNO_NOMEM (UINT16_C(48))
2942+
#define __WASI_ERRNO_NOMSG (UINT16_C(49))
2943+
#define __WASI_ERRNO_NOPROTOOPT (UINT16_C(50))
2944+
#define __WASI_ERRNO_NOSPC (UINT16_C(51))
2945+
#define __WASI_ERRNO_NOSYS (UINT16_C(52))
2946+
#define __WASI_ERRNO_NOTCAPABLE (UINT16_C(76))
2947+
#define __WASI_ERRNO_NOTCONN (UINT16_C(53))
2948+
#define __WASI_ERRNO_NOTDIR (UINT16_C(54))
2949+
#define __WASI_ERRNO_NOTEMPTY (UINT16_C(55))
2950+
#define __WASI_ERRNO_NOTRECOVERABLE (UINT16_C(56))
2951+
#define __WASI_ERRNO_NOTSOCK (UINT16_C(57))
2952+
#define __WASI_ERRNO_NOTSUP (UINT16_C(58))
2953+
#define __WASI_ERRNO_NOTTY (UINT16_C(59))
2954+
#define __WASI_ERRNO_NXIO (UINT16_C(60))
2955+
#define __WASI_ERRNO_OVERFLOW (UINT16_C(61))
2956+
#define __WASI_ERRNO_OWNERDEAD (UINT16_C(62))
2957+
#define __WASI_ERRNO_PERM (UINT16_C(63))
2958+
#define __WASI_ERRNO_PIPE (UINT16_C(64))
2959+
#define __WASI_ERRNO_PROTO (UINT16_C(65))
2960+
#define __WASI_ERRNO_PROTONOSUPPORT (UINT16_C(66))
2961+
#define __WASI_ERRNO_PROTOTYPE (UINT16_C(67))
2962+
#define __WASI_ERRNO_RANGE (UINT16_C(68))
2963+
#define __WASI_ERRNO_ROFS (UINT16_C(69))
2964+
#define __WASI_ERRNO_SPIPE (UINT16_C(70))
2965+
#define __WASI_ERRNO_SRCH (UINT16_C(71))
2966+
#define __WASI_ERRNO_STALE (UINT16_C(72))
2967+
#define __WASI_ERRNO_SUCCESS (UINT16_C(0))
2968+
#define __WASI_ERRNO_TIMEDOUT (UINT16_C(73))
2969+
#define __WASI_ERRNO_TXTBSY (UINT16_C(74))
2970+
#define __WASI_ERRNO_XDEV (UINT16_C(75))
2971+
#define __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP (UINT16_C(1))
2972+
#define __WASI_EVENTTYPE_CLOCK (UINT8_C(0))
2973+
#define __WASI_EVENTTYPE_FD_READ (UINT8_C(1))
2974+
#define __WASI_EVENTTYPE_FD_WRITE (UINT8_C(2))
2975+
#define __WASI_FDFLAGS_APPEND (UINT16_C(1))
2976+
#define __WASI_FDFLAGS_DSYNC (UINT16_C(2))
2977+
#define __WASI_FDFLAGS_NONBLOCK (UINT16_C(4))
2978+
#define __WASI_FDFLAGS_RSYNC (UINT16_C(8))
2979+
#define __WASI_FDFLAGS_SYNC (UINT16_C(16))
2980+
#define __WASI_FILETYPE_BLOCK_DEVICE (UINT8_C(1))
2981+
#define __WASI_FILETYPE_CHARACTER_DEVICE (UINT8_C(2))
2982+
#define __WASI_FILETYPE_DIRECTORY (UINT8_C(3))
2983+
#define __WASI_FILETYPE_REGULAR_FILE (UINT8_C(4))
2984+
#define __WASI_FILETYPE_SOCKET_DGRAM (UINT8_C(5))
2985+
#define __WASI_FILETYPE_SOCKET_STREAM (UINT8_C(6))
2986+
#define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7))
2987+
#define __WASI_FILETYPE_UNKNOWN (UINT8_C(0))
2988+
#define __WASI_FSTFLAGS_ATIM (UINT16_C(1))
2989+
#define __WASI_FSTFLAGS_ATIM_NOW (UINT16_C(2))
2990+
#define __WASI_FSTFLAGS_MTIM (UINT16_C(4))
2991+
#define __WASI_FSTFLAGS_MTIM_NOW (UINT16_C(8))
2992+
#define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW (UINT32_C(1))
2993+
#define __WASI_OFLAGS_CREAT (UINT16_C(1))
2994+
#define __WASI_OFLAGS_DIRECTORY (UINT16_C(2))
2995+
#define __WASI_OFLAGS_EXCL (UINT16_C(4))
2996+
#define __WASI_OFLAGS_TRUNC (UINT16_C(8))
2997+
#define __WASI_PREOPENTYPE_DIR (UINT8_C(0))
2998+
#define __WASI_RIFLAGS_RECV_PEEK (UINT16_C(1))
2999+
#define __WASI_RIFLAGS_RECV_WAITALL (UINT16_C(2))
3000+
#define __WASI_RIGHTS_FD_ADVISE (UINT64_C(128))
3001+
#define __WASI_RIGHTS_FD_ALLOCATE (UINT64_C(256))
3002+
#define __WASI_RIGHTS_FD_DATASYNC (UINT64_C(1))
3003+
#define __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS (UINT64_C(8))
3004+
#define __WASI_RIGHTS_FD_FILESTAT_GET (UINT64_C(2097152))
3005+
#define __WASI_RIGHTS_FD_FILESTAT_SET_SIZE (UINT64_C(4194304))
3006+
#define __WASI_RIGHTS_FD_FILESTAT_SET_TIMES (UINT64_C(8388608))
3007+
#define __WASI_RIGHTS_FD_READ (UINT64_C(2))
3008+
#define __WASI_RIGHTS_FD_READDIR (UINT64_C(16384))
3009+
#define __WASI_RIGHTS_FD_SEEK (UINT64_C(4))
3010+
#define __WASI_RIGHTS_FD_SYNC (UINT64_C(16))
3011+
#define __WASI_RIGHTS_FD_TELL (UINT64_C(32))
3012+
#define __WASI_RIGHTS_FD_WRITE (UINT64_C(64))
3013+
#define __WASI_RIGHTS_PATH_CREATE_DIRECTORY (UINT64_C(512))
3014+
#define __WASI_RIGHTS_PATH_CREATE_FILE (UINT64_C(1024))
3015+
#define __WASI_RIGHTS_PATH_FILESTAT_GET (UINT64_C(262144))
3016+
#define __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE (UINT64_C(524288))
3017+
#define __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES (UINT64_C(1048576))
3018+
#define __WASI_RIGHTS_PATH_LINK_SOURCE (UINT64_C(2048))
3019+
#define __WASI_RIGHTS_PATH_LINK_TARGET (UINT64_C(4096))
3020+
#define __WASI_RIGHTS_PATH_OPEN (UINT64_C(8192))
3021+
#define __WASI_RIGHTS_PATH_READLINK (UINT64_C(32768))
3022+
#define __WASI_RIGHTS_PATH_REMOVE_DIRECTORY (UINT64_C(33554432))
3023+
#define __WASI_RIGHTS_PATH_RENAME_SOURCE (UINT64_C(65536))
3024+
#define __WASI_RIGHTS_PATH_RENAME_TARGET (UINT64_C(131072))
3025+
#define __WASI_RIGHTS_PATH_SYMLINK (UINT64_C(16777216))
3026+
#define __WASI_RIGHTS_PATH_UNLINK_FILE (UINT64_C(67108864))
3027+
#define __WASI_RIGHTS_POLL_FD_READWRITE (UINT64_C(134217728))
3028+
#define __WASI_RIGHTS_SOCK_SHUTDOWN (UINT64_C(268435456))
3029+
#define __WASI_ROFLAGS_RECV_DATA_TRUNCATED (UINT16_C(1))
3030+
#define __WASI_SDFLAGS_RD (UINT8_C(1))
3031+
#define __WASI_SDFLAGS_WR (UINT8_C(2))
3032+
#define __WASI_SIGNAL_ABRT (UINT8_C(6))
3033+
#define __WASI_SIGNAL_ALRM (UINT8_C(14))
3034+
#define __WASI_SIGNAL_BUS (UINT8_C(7))
3035+
#define __WASI_SIGNAL_CHLD (UINT8_C(16))
3036+
#define __WASI_SIGNAL_CONT (UINT8_C(17))
3037+
#define __WASI_SIGNAL_FPE (UINT8_C(8))
3038+
#define __WASI_SIGNAL_HUP (UINT8_C(1))
3039+
#define __WASI_SIGNAL_ILL (UINT8_C(4))
3040+
#define __WASI_SIGNAL_INT (UINT8_C(2))
3041+
#define __WASI_SIGNAL_KILL (UINT8_C(9))
3042+
#define __WASI_SIGNAL_NONE (UINT8_C(0))
3043+
#define __WASI_SIGNAL_PIPE (UINT8_C(13))
3044+
#define __WASI_SIGNAL_POLL (UINT8_C(28))
3045+
#define __WASI_SIGNAL_PROF (UINT8_C(26))
3046+
#define __WASI_SIGNAL_PWR (UINT8_C(29))
3047+
#define __WASI_SIGNAL_QUIT (UINT8_C(3))
3048+
#define __WASI_SIGNAL_SEGV (UINT8_C(11))
3049+
#define __WASI_SIGNAL_STOP (UINT8_C(18))
3050+
#define __WASI_SIGNAL_SYS (UINT8_C(30))
3051+
#define __WASI_SIGNAL_TERM (UINT8_C(15))
3052+
#define __WASI_SIGNAL_TRAP (UINT8_C(5))
3053+
#define __WASI_SIGNAL_TSTP (UINT8_C(19))
3054+
#define __WASI_SIGNAL_TTIN (UINT8_C(20))
3055+
#define __WASI_SIGNAL_TTOU (UINT8_C(21))
3056+
#define __WASI_SIGNAL_URG (UINT8_C(22))
3057+
#define __WASI_SIGNAL_USR1 (UINT8_C(10))
3058+
#define __WASI_SIGNAL_USR2 (UINT8_C(12))
3059+
#define __WASI_SIGNAL_VTALRM (UINT8_C(25))
3060+
#define __WASI_SIGNAL_WINCH (UINT8_C(27))
3061+
#define __WASI_SIGNAL_XCPU (UINT8_C(23))
3062+
#define __WASI_SIGNAL_XFSZ (UINT8_C(24))
3063+
#define __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME (UINT16_C(1))
3064+
#define __WASI_WHENCE_CUR (UINT8_C(1))
3065+
#define __WASI_WHENCE_END (UINT8_C(2))
3066+
#define __WASI_WHENCE_SET (UINT8_C(0))
30673067
#define __WCHAR_MAX__ 2147483647
30683068
#define __WCHAR_TYPE__ int
30693069
#define __WCHAR_WIDTH__ 32

‎libc-bottom-half/headers/public/wasi/api.h

+183-183
Large diffs are not rendered by default.

‎tools/wasi-headers/src/c_header.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ fn print_enum(ret: &mut String, name: &Id, e: &EnumDatatype) {
137137
ret.push_str(" */\n");
138138
}
139139
ret.push_str(&format!(
140-
"#define __WASI_{}_{} ((__wasi_{}_t){})\n",
140+
"#define __WASI_{}_{} ({}({}))\n",
141141
ident_name(&name).to_shouty_snake_case(),
142142
ident_name(&variant.name).to_shouty_snake_case(),
143-
ident_name(&name),
143+
intrepr_const(e.repr),
144144
index
145145
));
146146
ret.push_str("\n");
@@ -164,10 +164,10 @@ fn print_flags(ret: &mut String, name: &Id, f: &FlagsDatatype) {
164164
ret.push_str(" */\n");
165165
}
166166
ret.push_str(&format!(
167-
"#define __WASI_{}_{} ((__wasi_{}_t){})\n",
167+
"#define __WASI_{}_{} ({}({}))\n",
168168
ident_name(name).to_shouty_snake_case(),
169169
ident_name(&flag.name).to_shouty_snake_case(),
170-
ident_name(name),
170+
intrepr_const(f.repr),
171171
1u128 << index
172172
));
173173
ret.push_str("\n");
@@ -418,3 +418,12 @@ fn intrepr_name(i: IntRepr) -> &'static str {
418418
IntRepr::U64 => "uint64_t",
419419
}
420420
}
421+
422+
fn intrepr_const(i: IntRepr) -> &'static str {
423+
match i {
424+
IntRepr::U8 => "UINT8_C",
425+
IntRepr::U16 => "UINT16_C",
426+
IntRepr::U32 => "UINT32_C",
427+
IntRepr::U64 => "UINT64_C",
428+
}
429+
}

0 commit comments

Comments
 (0)
Please sign in to comment.