lz4

Форк
0
/
CODING_STYLE 
57 строк · 3.4 Кб
1
LZ4 CODING STYLE
2
================
3

4
When contributing code and patches to the `LZ4` project, the following rules are expected to be followed for a successful merge.
5

6

7
Library
8
-------
9

10
The library's source code in `lib/` directory has a BSD 2-clause license.
11
It's designed to be integrated into 3rd party applications.
12

13
It adheres relatively strictly to vanilla `C90`, with the following exceptions:
14
- `long long` type is required, in order to support 64-bit values
15
- Variadic Macros are used for debug mode (but not required in release mode)
16

17
Beyond that, all other rules and limitations of C90 must be respected, including `/* ... */` comment style only, and variable declaration at top of block only. The automated CI test suite will check for these rules.
18

19
The code is allowed to use more modern variants (C99 / C11 / C23) when useful
20
as long as it provides a clean C90 backup for older compilers.
21
For example, C99+ compilers will employ the `restrict` keyword, while `C90` ones will ignore it, thanks to conditional macros.
22
This ensures maximum portability across a wide range of systems.
23

24
Moreover, in the interest of safety, the code has to respect a fairly strigent list of additional restrictions, provided through warning flags, the list of which is maintained within `Makefile`.
25
Among the less common ones, we want the source to be compatible with `-Wc++-compat`, which ensures that the code can be compiled "as is", with no modification, as C++ code. It makes it possible to copy-paste the code into other C++ source files, or the source files are just dropped into a C++ environment which then compiles them as C++ source files.
26

27

28
Command Line Interface
29
----------------------
30

31
The CLI executable's source code in `programs/` directory has a GPLv2+ license.
32
While it's designed to be portable and freely distributable, it's not meant to be integrated into 3rd party applications.
33
The license difference is meant to reflect that choice.
34

35
Similar to the library, the CLI adheres relatively strictly to vanilla `C90`, and features the same exceptions:
36
- `long long` requirement for 64-bit values
37
- Variadic Macros for console messages (now used all the time, not just debug mode)
38

39
The code can also use system-specific libraries and symbols (such as `posix` ones)
40
as long as it provides a backup for plain `C90` platforms.
41
It's even allowed to lose capabilities, as long as the CLI can be cleanly compiled on `C90`.
42
For example, systems without `<pthread>` support nor Completion Ports will just not feature multi-threading support, and run single threaded.
43

44
In the interest of build familiarity, the CLI source code also respects the same set of advanced warning flags as the library.
45
That being said, this last part is debatable and could deviate in the future.
46
For example, there are less reasons to support `-Wc++-compat` on the CLI side, since it's not meant to be integrated into 3rd party applications.
47

48

49
Others
50
------
51

52
The repository includes other directories with their own set of compilable projects, such as `tests/`, `examples/` and `contrib/`.
53

54
These repositories do not have to respect the same set of restrictions, and can employ a larger array of different languages.
55
For example, some tests employ `sh`, and others employ `python`.
56

57
These directories may nonetheless include several targets employing the same coding convention as the `lz4` library. This is in a no way a rule, more like a side effect of build familiarity.
58

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.