Skip to content

Commit ee9b993

Browse files
committed
snapshot 1 and 0: put tag back in event struct, flatten event_u
prior to this PR, event_u was a union with only one variant fd_readwrite. the change into tagged union ended up changing the memory layout of the event struct. so, rather than use tagged unions in the event struct, we just use a struct that you ignore in the case of the clock event, which has the same ABI as previously. in ephemeral, we use a tagged union for events, because we dont have any ABI stability guarantees to maintain there.
1 parent ab5f8fc commit ee9b993

File tree

4 files changed

+22
-46
lines changed

4 files changed

+22
-46
lines changed

phases/old/snapshot_0/docs.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -637,16 +637,6 @@ The number of bytes available for reading or writing.
637637
- <a href="#event_fd_readwrite.flags" name="event_fd_readwrite.flags"></a> `flags`: [`eventrwflags`](#eventrwflags)
638638
The state of the file descriptor.
639639

640-
## <a href="#event_u" name="event_u"></a> `event_u`: Union
641-
The contents of an $event.
642-
643-
### Union variants
644-
- <a href="#event_u.fd_read" name="event_u.fd_read"></a> `fd_read`: [`event_fd_readwrite`](#event_fd_readwrite)
645-
646-
- <a href="#event_u.fd_write" name="event_u.fd_write"></a> `fd_write`: [`event_fd_readwrite`](#event_fd_readwrite)
647-
648-
- <a href="#event_u.clock" name="event_u.clock"></a> `clock`
649-
650640
## <a href="#event" name="event"></a> `event`: Struct
651641
An event that occurred.
652642

@@ -657,8 +647,12 @@ User-provided value that got attached to [`subscription::userdata`](#subscriptio
657647
- <a href="#event.error" name="event.error"></a> `error`: [`errno`](#errno)
658648
If non-zero, an error that occurred while processing the subscription request.
659649

660-
- <a href="#event.u" name="event.u"></a> `u`: [`event_u`](#event_u)
661-
The type of event that occured, and its contents.
650+
- <a href="#event.type" name="event.type"></a> `type`: [`eventtype`](#eventtype)
651+
The type of event that occured
652+
653+
- <a href="#event.fd_readwrite" name="event.fd_readwrite"></a> `fd_readwrite`: [`event_fd_readwrite`](#event_fd_readwrite)
654+
The contents of the event, if it is an [`eventtype::fd_read`](#eventtype.fd_read) or
655+
[`eventtype::fd_write`](#eventtype.fd_write). [`eventtype::clock`](#eventtype.clock) events ignore this field.
662656

663657
## <a href="#subclockflags" name="subclockflags"></a> `subclockflags`: Flags(`u16`)
664658
Flags determining how to interpret the timestamp provided in

phases/old/snapshot_0/witx/typenames.witx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -514,24 +514,18 @@
514514
)
515515
)
516516

517-
;;; The contents of an $event.
518-
(typename $event_u
519-
(union $eventtype
520-
(field $fd_read $event_fd_readwrite)
521-
(field $fd_write $event_fd_readwrite)
522-
(empty $clock)
523-
)
524-
)
525-
526517
;;; An event that occurred.
527518
(typename $event
528519
(struct
529520
;;; User-provided value that got attached to `subscription::userdata`.
530521
(field $userdata $userdata)
531522
;;; If non-zero, an error that occurred while processing the subscription request.
532523
(field $error $errno)
533-
;;; The type of event that occured, and its contents.
534-
(field $u $event_u)
524+
;;; The type of event that occured
525+
(field $type $eventtype)
526+
;;; The contents of the event, if it is an `eventtype::fd_read` or
527+
;;; `eventtype::fd_write`. `eventtype::clock` events ignore this field.
528+
(field $fd_readwrite $event_fd_readwrite)
535529
)
536530
)
537531

phases/snapshot/docs.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -639,16 +639,6 @@ The number of bytes available for reading or writing.
639639
- <a href="#event_fd_readwrite.flags" name="event_fd_readwrite.flags"></a> `flags`: [`eventrwflags`](#eventrwflags)
640640
The state of the file descriptor.
641641

642-
## <a href="#event_u" name="event_u"></a> `event_u`: Union
643-
The contents of an $event.
644-
645-
### Union variants
646-
- <a href="#event_u.fd_read" name="event_u.fd_read"></a> `fd_read`: [`event_fd_readwrite`](#event_fd_readwrite)
647-
648-
- <a href="#event_u.fd_write" name="event_u.fd_write"></a> `fd_write`: [`event_fd_readwrite`](#event_fd_readwrite)
649-
650-
- <a href="#event_u.clock" name="event_u.clock"></a> `clock`
651-
652642
## <a href="#event" name="event"></a> `event`: Struct
653643
An event that occurred.
654644

@@ -659,8 +649,12 @@ User-provided value that got attached to [`subscription::userdata`](#subscriptio
659649
- <a href="#event.error" name="event.error"></a> `error`: [`errno`](#errno)
660650
If non-zero, an error that occurred while processing the subscription request.
661651

662-
- <a href="#event.u" name="event.u"></a> `u`: [`event_u`](#event_u)
663-
The type of the event that occurred, and its contents.
652+
- <a href="#event.type" name="event.type"></a> `type`: [`eventtype`](#eventtype)
653+
The type of event that occured
654+
655+
- <a href="#event.fd_readwrite" name="event.fd_readwrite"></a> `fd_readwrite`: [`event_fd_readwrite`](#event_fd_readwrite)
656+
The contents of the event, if it is an [`eventtype::fd_read`](#eventtype.fd_read) or
657+
[`eventtype::fd_write`](#eventtype.fd_write). [`eventtype::clock`](#eventtype.clock) events ignore this field.
664658

665659
## <a href="#subclockflags" name="subclockflags"></a> `subclockflags`: Flags(`u16`)
666660
Flags determining how to interpret the timestamp provided in

phases/snapshot/witx/typenames.witx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -516,24 +516,18 @@
516516
)
517517
)
518518

519-
;;; The contents of an $event.
520-
(typename $event_u
521-
(union $eventtype
522-
(field $fd_read $event_fd_readwrite)
523-
(field $fd_write $event_fd_readwrite)
524-
(empty $clock)
525-
)
526-
)
527-
528519
;;; An event that occurred.
529520
(typename $event
530521
(struct
531522
;;; User-provided value that got attached to `subscription::userdata`.
532523
(field $userdata $userdata)
533524
;;; If non-zero, an error that occurred while processing the subscription request.
534525
(field $error $errno)
535-
;;; The type of the event that occurred, and its contents.
536-
(field $u $event_u)
526+
;;; The type of event that occured
527+
(field $type $eventtype)
528+
;;; The contents of the event, if it is an `eventtype::fd_read` or
529+
;;; `eventtype::fd_write`. `eventtype::clock` events ignore this field.
530+
(field $fd_readwrite $event_fd_readwrite)
537531
)
538532
)
539533

0 commit comments

Comments
 (0)