Skip to content

Commit 4c5861c

Browse files
committed
Add introduction/constants/enumeration/uninitialized to CONVENTIONS.
1 parent 6e99ad6 commit 4c5861c

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

CONVENTIONS.md

+41-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,44 @@
1-
# Bitflags
1+
# Conventions
2+
3+
In order to achieve our goal of wrapping [libc][libc] code in idiomatic rust
4+
constructs with minimal performance overhead, we follow the following
5+
conventions.
6+
7+
Note that, thus far, not all the code follows these conventions and not all
8+
conventions we try to follow have been documented here. If you find an instance
9+
of either, feel free to remedy the flaw by opening a pull request with
10+
appropriate changes or additions.
11+
12+
13+
## Integer Constants
14+
15+
We do not define integer constants ourselves, but use or reexport them from the
16+
[libc crate][libc].
17+
18+
19+
## Bitflags
220

321
We represent sets of constants that are intended to be combined using bitwise
422
operations as parameters to functions by types defined using the `bitflags!`
5-
macro from the [bitflags crate](https://crates.io/crates/bitflags/).
6-
Instead of providing the concrete values ourselves, we prefer taking the
7-
constants defined in [libc crate](https://crates.io/crates/libc/).
23+
macro from the [bitflags crate][bitflags].
24+
25+
26+
## Enumerations
27+
28+
We represent sets of constants that are intended as mutually exclusive arguments
29+
to parameters of functions by [enumerations][enum].
30+
31+
32+
## Structures Initialized by libc Functions
33+
34+
Whenever we need to use a [libc][libc] function to properly initialize a
35+
variable and said function allows us to use uninitialized memory, we use
36+
[`std::mem::uninitialized`][std_uninitialized] (or [`core::mem::uninitialized`][core_uninitialized])
37+
when defining the variable. This allows us to avoid the overhead incurred by
38+
zeroing or otherwise initializing the variable.
39+
40+
[bitflags]: https://crates.io/crates/bitflags/
41+
[core_uninitialized]: https://doc.rust-lang.org/core/mem/fn.uninitialized.html
42+
[enum]: https://doc.rust-lang.org/reference.html#enumerations
43+
[libc]: https://crates.io/crates/libc/
44+
[std_uninitialized]: https://doc.rust-lang.org/std/mem/fn.uninitialized.html

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ Then, add this to your crate root:
2828
```rust
2929
extern crate nix;
3030
```
31+
32+
## Contributing
33+
34+
See [CONTRIBUTING](CONTRIBUTING.md).

0 commit comments

Comments
 (0)