Skip to content

Commit 852d093

Browse files
committed
wasi/api.h: regenerated with tagged unions
1 parent 4f03c9b commit 852d093

1 file changed

Lines changed: 31 additions & 57 deletions

File tree

  • libc-bottom-half/headers/public/wasi

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

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,16 +1169,20 @@ _Static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, "witx calculat
11691169
/**
11701170
* The contents of an $event.
11711171
*/
1172-
typedef union __wasi_event_u_t {
1173-
/**
1174-
* When type is `eventtype::fd_read` or `eventtype::fd_write`:
1175-
*/
1176-
__wasi_event_fd_readwrite_t fd_readwrite;
1177-
1172+
typedef union __wasi_event_u_u_t {
1173+
__wasi_event_fd_readwrite_t fd_read;
1174+
__wasi_event_fd_readwrite_t fd_write;
1175+
} __wasi_event_u_u_t;
1176+
typedef struct __wasi_event_u_t {
1177+
__wasi_eventtype_t tag;
1178+
__wasi_event_u_u_t u;
11781179
} __wasi_event_u_t;
11791180

1180-
_Static_assert(sizeof(__wasi_event_u_t) == 16, "witx calculated size");
1181+
_Static_assert(sizeof(__wasi_event_u_t) == 24, "witx calculated size");
11811182
_Static_assert(_Alignof(__wasi_event_u_t) == 8, "witx calculated align");
1183+
_Static_assert(offsetof(__wasi_event_u_t, u) == 8, "witx calculated union offset");
1184+
_Static_assert(sizeof(__wasi_event_u_u_t) == 16, "witx calculated union size");
1185+
_Static_assert(_Alignof(__wasi_event_u_u_t) == 8, "witx calculated union align");
11821186

11831187
/**
11841188
* An event that occurred.
@@ -1195,22 +1199,16 @@ typedef struct __wasi_event_t {
11951199
__wasi_errno_t error;
11961200

11971201
/**
1198-
* The type of the event that occurred.
1199-
*/
1200-
__wasi_eventtype_t type;
1201-
1202-
/**
1203-
* The contents of the event.
1202+
* The type of the event that occurred, and its contents.
12041203
*/
12051204
__wasi_event_u_t u;
12061205

12071206
} __wasi_event_t;
12081207

1209-
_Static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size");
1208+
_Static_assert(sizeof(__wasi_event_t) == 40, "witx calculated size");
12101209
_Static_assert(_Alignof(__wasi_event_t) == 8, "witx calculated align");
12111210
_Static_assert(offsetof(__wasi_event_t, userdata) == 0, "witx calculated offset");
12121211
_Static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset");
1213-
_Static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset");
12141212
_Static_assert(offsetof(__wasi_event_t, u) == 16, "witx calculated offset");
12151213

12161214
/**
@@ -1284,21 +1282,21 @@ _Static_assert(offsetof(__wasi_subscription_fd_readwrite_t, file_descriptor) ==
12841282
/**
12851283
* The contents of a $subscription.
12861284
*/
1287-
typedef union __wasi_subscription_u_t {
1288-
/**
1289-
* When type is `eventtype::clock`:
1290-
*/
1285+
typedef union __wasi_subscription_u_u_t {
12911286
__wasi_subscription_clock_t clock;
1292-
1293-
/**
1294-
* When type is `eventtype::fd_read` or `eventtype::fd_write`:
1295-
*/
1296-
__wasi_subscription_fd_readwrite_t fd_readwrite;
1297-
1287+
__wasi_subscription_fd_readwrite_t fd_read;
1288+
__wasi_subscription_fd_readwrite_t fd_write;
1289+
} __wasi_subscription_u_u_t;
1290+
typedef struct __wasi_subscription_u_t {
1291+
__wasi_eventtype_t tag;
1292+
__wasi_subscription_u_u_t u;
12981293
} __wasi_subscription_u_t;
12991294

1300-
_Static_assert(sizeof(__wasi_subscription_u_t) == 32, "witx calculated size");
1295+
_Static_assert(sizeof(__wasi_subscription_u_t) == 40, "witx calculated size");
13011296
_Static_assert(_Alignof(__wasi_subscription_u_t) == 8, "witx calculated align");
1297+
_Static_assert(offsetof(__wasi_subscription_u_t, u) == 8, "witx calculated union offset");
1298+
_Static_assert(sizeof(__wasi_subscription_u_u_t) == 32, "witx calculated union size");
1299+
_Static_assert(_Alignof(__wasi_subscription_u_u_t) == 8, "witx calculated union align");
13021300

13031301
/**
13041302
* Subscription to an event.
@@ -1311,12 +1309,7 @@ typedef struct __wasi_subscription_t {
13111309
__wasi_userdata_t userdata;
13121310

13131311
/**
1314-
* The type of the event to which to subscribe.
1315-
*/
1316-
__wasi_eventtype_t type;
1317-
1318-
/**
1319-
* The contents of the subscription.
1312+
* The type of the event to which to subscribe, and its contents
13201313
*/
13211314
__wasi_subscription_u_t u;
13221315

@@ -1325,8 +1318,7 @@ typedef struct __wasi_subscription_t {
13251318
_Static_assert(sizeof(__wasi_subscription_t) == 48, "witx calculated size");
13261319
_Static_assert(_Alignof(__wasi_subscription_t) == 8, "witx calculated align");
13271320
_Static_assert(offsetof(__wasi_subscription_t, userdata) == 0, "witx calculated offset");
1328-
_Static_assert(offsetof(__wasi_subscription_t, type) == 8, "witx calculated offset");
1329-
_Static_assert(offsetof(__wasi_subscription_t, u) == 16, "witx calculated offset");
1321+
_Static_assert(offsetof(__wasi_subscription_t, u) == 8, "witx calculated offset");
13301322

13311323
/**
13321324
* Exit code generated by a process when exiting.
@@ -1617,39 +1609,21 @@ _Static_assert(_Alignof(__wasi_prestat_dir_t) == 4, "witx calculated align");
16171609
_Static_assert(offsetof(__wasi_prestat_dir_t, pr_name_len) == 0, "witx calculated offset");
16181610

16191611
/**
1620-
* The contents of an $prestat.
1612+
* Information about a pre-opened capability.
16211613
*/
16221614
typedef union __wasi_prestat_u_t {
1623-
/**
1624-
* When type is `preopentype::dir`:
1625-
*/
16261615
__wasi_prestat_dir_t dir;
1627-
16281616
} __wasi_prestat_u_t;
1629-
1630-
_Static_assert(sizeof(__wasi_prestat_u_t) == 4, "witx calculated size");
1631-
_Static_assert(_Alignof(__wasi_prestat_u_t) == 4, "witx calculated align");
1632-
1633-
/**
1634-
* Information about a pre-opened capability.
1635-
*/
16361617
typedef struct __wasi_prestat_t {
1637-
/**
1638-
* The type of the pre-opened capability.
1639-
*/
1640-
__wasi_preopentype_t pr_type;
1641-
1642-
/**
1643-
* The contents of the information.
1644-
*/
1618+
__wasi_preopentype_t tag;
16451619
__wasi_prestat_u_t u;
1646-
16471620
} __wasi_prestat_t;
16481621

16491622
_Static_assert(sizeof(__wasi_prestat_t) == 8, "witx calculated size");
16501623
_Static_assert(_Alignof(__wasi_prestat_t) == 4, "witx calculated align");
1651-
_Static_assert(offsetof(__wasi_prestat_t, pr_type) == 0, "witx calculated offset");
1652-
_Static_assert(offsetof(__wasi_prestat_t, u) == 4, "witx calculated offset");
1624+
_Static_assert(offsetof(__wasi_prestat_t, u) == 4, "witx calculated union offset");
1625+
_Static_assert(sizeof(__wasi_prestat_u_t) == 4, "witx calculated union size");
1626+
_Static_assert(_Alignof(__wasi_prestat_u_t) == 4, "witx calculated union align");
16531627

16541628
/**
16551629
* @defgroup wasi_snapshot_preview1

0 commit comments

Comments
 (0)