You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/os/README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,7 @@ inspiration for several decisions in this library.
50
50
- do not use `OS\ErrnoException` if the error condition would not be indicated
51
51
by the `errno` variable in C. Consider adding another similar class, e.g.
52
52
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`.
53
54
- add and use Hack classes (not type aliases) for long-lived 'handle'-like
54
55
parameters and return values, e.g. `OS\open()` returns a
55
56
`HH\Lib\FileDescriptor` instead of an `int`; as well as aiding type safety,
@@ -61,10 +62,8 @@ inspiration for several decisions in this library.
61
62
- this can aid for common use by allowing string literals, rather than
62
63
requiring otherwise-unused locals
63
64
- 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`.
68
67
69
68
## Implementation notes
70
69
@@ -111,6 +110,7 @@ inspiration for several decisions in this library.
111
110
112
111
| C type | Hack type |
113
112
|---|---|
113
+
|`int` or `short` as a bit set |`keyset<Flag>` where `Flag` is an `enum`|
114
114
|`int socket` or `int filedes`, or other long-lived system resources |`HH\Lib\OS\FileDescriptor` or other wrapper classes |
115
115
| 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)|
0 commit comments