Skip to content

Commit 2bcfe64

Browse files
alexcrichtonsunfishcode
authored andcommitted
Define Flags in terms of integers
Remove the `Type::Flags` variant in favor of a witx-specific way to define a bitflags with a number of constants.
1 parent 90f2ba9 commit 2bcfe64

File tree

17 files changed

+190
-253
lines changed

17 files changed

+190
-253
lines changed

phases/ephemeral/docs.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,14 @@ Cross-device link.
282282
- <a href="#errno.notcapable" name="errno.notcapable"></a> `notcapable`
283283
Extension: Capabilities insufficient.
284284

285-
## <a href="#rights" name="rights"></a> `rights`: Flags(`u64`)
285+
## <a href="#rights" name="rights"></a> `rights`: `u64`
286286
File descriptor rights, determining which actions may be performed.
287287

288288
Size: 8
289289

290290
Alignment: 8
291291

292-
### Flags
292+
### Constants
293293
- <a href="#rights.fd_datasync" name="rights.fd_datasync"></a> `fd_datasync`
294294
The right to invoke `fd_datasync`.
295295
If `path_open` is set, includes the right to invoke
@@ -487,6 +487,9 @@ Size: 8
487487

488488
Alignment: 8
489489

490+
### Constants
491+
- <a href="#dircookie.start" name="dircookie.start"></a> `start`
492+
490493
## <a href="#dirnamlen" name="dirnamlen"></a> `dirnamlen`: `u32`
491494
The type for the [`dirent::d_namlen`](#dirent.d_namlen) field of [`dirent`](#dirent).
492495

@@ -590,14 +593,14 @@ The application expects that it will not access the specified data in the near f
590593
- <a href="#advice.noreuse" name="advice.noreuse"></a> `noreuse`
591594
The application expects to access the specified data once and then not reuse it thereafter.
592595

593-
## <a href="#fdflags" name="fdflags"></a> `fdflags`: Flags(`u16`)
596+
## <a href="#fdflags" name="fdflags"></a> `fdflags`: `u16`
594597
File descriptor flags.
595598

596599
Size: 2
597600

598601
Alignment: 2
599602

600-
### Flags
603+
### Constants
601604
- <a href="#fdflags.append" name="fdflags.append"></a> `append`
602605
Append mode: Data written to the file is always appended to the file's end.
603606

@@ -652,14 +655,14 @@ Size: 8
652655

653656
Alignment: 8
654657

655-
## <a href="#fstflags" name="fstflags"></a> `fstflags`: Flags(`u16`)
658+
## <a href="#fstflags" name="fstflags"></a> `fstflags`: `u16`
656659
Which file time attributes to adjust.
657660

658661
Size: 2
659662

660663
Alignment: 2
661664

662-
### Flags
665+
### Constants
663666
- <a href="#fstflags.atim" name="fstflags.atim"></a> `atim`
664667
Adjust the last data access timestamp to the value stored in [`filestat::atim`](#filestat.atim).
665668

@@ -672,25 +675,25 @@ Adjust the last data modification timestamp to the value stored in [`filestat::m
672675
- <a href="#fstflags.mtim_now" name="fstflags.mtim_now"></a> `mtim_now`
673676
Adjust the last data modification timestamp to the time of clock [`clockid::realtime`](#clockid.realtime).
674677

675-
## <a href="#lookupflags" name="lookupflags"></a> `lookupflags`: Flags(`u32`)
678+
## <a href="#lookupflags" name="lookupflags"></a> `lookupflags`: `u32`
676679
Flags determining the method of how paths are resolved.
677680

678681
Size: 4
679682

680683
Alignment: 4
681684

682-
### Flags
685+
### Constants
683686
- <a href="#lookupflags.symlink_follow" name="lookupflags.symlink_follow"></a> `symlink_follow`
684687
As long as the resolved path corresponds to a symbolic link, it is expanded.
685688

686-
## <a href="#oflags" name="oflags"></a> `oflags`: Flags(`u16`)
689+
## <a href="#oflags" name="oflags"></a> `oflags`: `u16`
687690
Open flags used by `path_open`.
688691

689692
Size: 2
690693

691694
Alignment: 2
692695

693-
### Flags
696+
### Constants
694697
- <a href="#oflags.create" name="oflags.create"></a> `create`
695698
Create file if it does not exist.
696699

@@ -710,7 +713,7 @@ Size: 8
710713

711714
Alignment: 8
712715

713-
## <a href="#permissions" name="permissions"></a> `permissions`: Flags(`u8`)
716+
## <a href="#permissions" name="permissions"></a> `permissions`: `u8`
714717
File permissions. This represents the permissions associated with a
715718
file in a filesystem, and don't fully reflect all the conditions
716719
which determine whether a given WASI program can access the file.
@@ -719,7 +722,7 @@ Size: 1
719722

720723
Alignment: 1
721724

722-
### Flags
725+
### Constants
723726
- <a href="#permissions.read" name="permissions.read"></a> `read`
724727
For files, permission to read the file.
725728
For directories, permission to do [`readdir`](#readdir) and access files
@@ -825,15 +828,15 @@ available for reading. This event always triggers for regular files.
825828
File descriptor [`subscription_fd_readwrite::fd`](#subscription_fd_readwrite.fd) has capacity
826829
available for writing. This event always triggers for regular files.
827830

828-
## <a href="#eventrwflags" name="eventrwflags"></a> `eventrwflags`: Flags(`u16`)
831+
## <a href="#eventrwflags" name="eventrwflags"></a> `eventrwflags`: `u16`
829832
The state of the file descriptor subscribed to with
830833
[`eventtype::fd_read`](#eventtype.fd_read) or [`eventtype::fd_write`](#eventtype.fd_write).
831834

832835
Size: 2
833836

834837
Alignment: 2
835838

836-
### Flags
839+
### Constants
837840
- <a href="#eventrwflags.fd_readwrite_hangup" name="eventrwflags.fd_readwrite_hangup"></a> `fd_readwrite_hangup`
838841
The peer of this socket has closed or disconnected.
839842

@@ -899,15 +902,15 @@ The type of the event that occurred, and the contents of the event
899902

900903
Offset: 16
901904

902-
## <a href="#subclockflags" name="subclockflags"></a> `subclockflags`: Flags(`u16`)
905+
## <a href="#subclockflags" name="subclockflags"></a> `subclockflags`: `u16`
903906
Flags determining how to interpret the timestamp provided in
904907
[`subscription_clock::timeout`](#subscription_clock.timeout).
905908

906909
Size: 2
907910

908911
Alignment: 2
909912

910-
### Flags
913+
### Constants
911914
- <a href="#subclockflags.subscription_clock_abstime" name="subclockflags.subscription_clock_abstime"></a> `subscription_clock_abstime`
912915
If set, treat the timestamp provided in
913916
[`subscription_clock::timeout`](#subscription_clock.timeout) as an absolute timestamp of clock
@@ -1004,28 +1007,28 @@ Size: 4
10041007

10051008
Alignment: 4
10061009

1007-
## <a href="#riflags" name="riflags"></a> `riflags`: Flags(`u16`)
1010+
## <a href="#riflags" name="riflags"></a> `riflags`: `u16`
10081011
Flags provided to `sock_recv`.
10091012

10101013
Size: 2
10111014

10121015
Alignment: 2
10131016

1014-
### Flags
1017+
### Constants
10151018
- <a href="#riflags.recv_peek" name="riflags.recv_peek"></a> `recv_peek`
10161019
Returns the message without removing it from the socket's receive queue.
10171020

10181021
- <a href="#riflags.recv_waitall" name="riflags.recv_waitall"></a> `recv_waitall`
10191022
On byte-stream sockets, block until the full amount of data can be returned.
10201023

1021-
## <a href="#roflags" name="roflags"></a> `roflags`: Flags(`u16`)
1024+
## <a href="#roflags" name="roflags"></a> `roflags`: `u16`
10221025
Flags returned by `sock_recv`.
10231026

10241027
Size: 2
10251028

10261029
Alignment: 2
10271030

1028-
### Flags
1031+
### Constants
10291032
- <a href="#roflags.recv_data_truncated" name="roflags.recv_data_truncated"></a> `recv_data_truncated`
10301033
Returned by `sock_recv`: Message data has been truncated.
10311034

@@ -1037,14 +1040,14 @@ Size: 2
10371040

10381041
Alignment: 2
10391042

1040-
## <a href="#sdflags" name="sdflags"></a> `sdflags`: Flags(`u8`)
1043+
## <a href="#sdflags" name="sdflags"></a> `sdflags`: `u8`
10411044
Which channels on a socket to shut down.
10421045

10431046
Size: 1
10441047

10451048
Alignment: 1
10461049

1047-
### Flags
1050+
### Constants
10481051
- <a href="#sdflags.rd" name="sdflags.rd"></a> `rd`
10491052
Disables further receive operations.
10501053

phases/ephemeral/witx/typenames.witx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195

196196
;;; File descriptor rights, determining which actions may be performed.
197197
(typename $rights
198-
(flags u64
198+
(flags (@witx bitflags u64)
199199
;;; The right to invoke `fd_datasync`.
200200
;;
201201
;;; If `path_open` is set, includes the right to invoke
@@ -392,7 +392,7 @@
392392

393393
;;; File descriptor flags.
394394
(typename $fdflags
395-
(flags u16
395+
(flags (@witx bitflags u16)
396396
;;; Append mode: Data written to the file is always appended to the file's end.
397397
$append
398398
;;; Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
@@ -429,7 +429,7 @@
429429

430430
;;; Which file time attributes to adjust.
431431
(typename $fstflags
432-
(flags u16
432+
(flags (@witx bitflags u16)
433433
;;; Adjust the last data access timestamp to the value stored in `filestat::atim`.
434434
$atim
435435
;;; Adjust the last data access timestamp to the time of clock `clockid::realtime`.
@@ -443,15 +443,15 @@
443443

444444
;;; Flags determining the method of how paths are resolved.
445445
(typename $lookupflags
446-
(flags u32
446+
(flags (@witx bitflags u32)
447447
;;; As long as the resolved path corresponds to a symbolic link, it is expanded.
448448
$symlink_follow
449449
)
450450
)
451451

452452
;;; Open flags used by `path_open`.
453453
(typename $oflags
454-
(flags u16
454+
(flags (@witx bitflags u16)
455455
;;; Create file if it does not exist.
456456
$create
457457
;;; Fail if not a directory.
@@ -470,7 +470,7 @@
470470
;;; file in a filesystem, and don't fully reflect all the conditions
471471
;;; which determine whether a given WASI program can access the file.
472472
(typename $permissions
473-
(flags u8
473+
(flags (@witx bitflags u8)
474474
;;; For files, permission to read the file.
475475
;;; For directories, permission to do `readdir` and access files
476476
;;; within the directory.
@@ -543,7 +543,7 @@
543543
;;; The state of the file descriptor subscribed to with
544544
;;; `eventtype::fd_read` or `eventtype::fd_write`.
545545
(typename $eventrwflags
546-
(flags u16
546+
(flags (@witx bitflags u16)
547547
;;; The peer of this socket has closed or disconnected.
548548
$fd_readwrite_hangup
549549
)
@@ -584,7 +584,7 @@
584584
;;; Flags determining how to interpret the timestamp provided in
585585
;;; `subscription_clock::timeout`.
586586
(typename $subclockflags
587-
(flags u16
587+
(flags (@witx bitflags u16)
588588
;;; If set, treat the timestamp provided in
589589
;;; `subscription_clock::timeout` as an absolute timestamp of clock
590590
;;; `subscription_clock::id`. If clear, treat the timestamp
@@ -643,7 +643,7 @@
643643

644644
;;; Flags provided to `sock_recv`.
645645
(typename $riflags
646-
(flags u16
646+
(flags (@witx bitflags u16)
647647
;;; Returns the message without removing it from the socket's receive queue.
648648
$recv_peek
649649
;;; On byte-stream sockets, block until the full amount of data can be returned.
@@ -653,7 +653,7 @@
653653

654654
;;; Flags returned by `sock_recv`.
655655
(typename $roflags
656-
(flags u16
656+
(flags (@witx bitflags u16)
657657
;;; Returned by `sock_recv`: Message data has been truncated.
658658
$recv_data_truncated
659659
)
@@ -665,7 +665,7 @@
665665

666666
;;; Which channels on a socket to shut down.
667667
(typename $sdflags
668-
(flags u8
668+
(flags (@witx bitflags u8)
669669
;;; Disables further receive operations.
670670
$rd
671671
;;; Disables further send operations.

0 commit comments

Comments
 (0)