Skip to content

Commit c8a4594

Browse files
committed
Add design notes for for bit sets and OS specific functions
1 parent 59ef35a commit c8a4594

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/os/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ inspiration for several decisions in this library.
5050
- do not use `OS\ErrnoException` if the error condition would not be indicated
5151
by the `errno` variable in C. Consider adding another similar class, e.g.
5252
add `OS\HErrnoException` if you want to report an error exposed via `h_errno`
53+
- use `keyset<Flag>` to represent a C bit set, where `Flag` is a Hack `enum`.
5354
- add and use Hack classes (not type aliases) for long-lived 'handle'-like
5455
parameters and return values, e.g. `OS\open()` returns a
5556
`HH\Lib\FileDescriptor` instead of an `int`; as well as aiding type safety,
@@ -61,10 +62,8 @@ inspiration for several decisions in this library.
6162
- this can aid for common use by allowing string literals, rather than
6263
requiring otherwise-unused locals
6364
- if the primary purpose of a set of functions is to create, mutate and
64-
destroy a C data structure, whose reference would not be held by C
65-
libraries, they should be exposed as a `vec`. See [Appendix:
66-
short-lived C pointer encoding](#appendix-short-lived-c-pointer-encoding)
67-
section for more detail.
65+
- Functions that are not available in all the Hack supported operating systems
66+
should put into separate namespaces, e.g. `HH\Lib\OS\Bsd` or `HH\Lib\OS\Linux`.
6867

6968
## Implementation notes
7069

@@ -111,6 +110,7 @@ inspiration for several decisions in this library.
111110

112111
| C type | Hack type |
113112
|---|---|
113+
| `int` or `short` as a bit set | `keyset<Flag>` where `Flag` is an `enum` |
114114
| `int socket` or `int filedes`, or other long-lived system resources | `HH\Lib\OS\FileDescriptor` or other wrapper classes |
115115
| Setters for `void *` or `struct *` whose reference would not be held by C libraries | `vec`, see [Appendix: encoding lightweight C data types with setters](#appendix-encoding-lightweight-c-data-types-with-setters) |
116116

0 commit comments

Comments
 (0)