https://github.com/awslabs/aws-c-common
Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 84 committers (1.2%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.7%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.
Basic Info
Statistics
- Stars: 284
- Watchers: 35
- Forks: 169
- Open Issues: 16
- Releases: 199
Topics
Metadata Files
README.md
AWS C Common
Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.
License
This library is licensed under the Apache 2.0 License.
Usage
Building
aws-c-common uses CMake for setting up build environments. This library has no non-kernel dependencies so the build is quite simple.
For example:
git clone git@github.com:awslabs/aws-c-common.git aws-c-common
mkdir aws-c-common-build
cd aws-c-common-build
cmake ../aws-c-common
make -j 12
make test
sudo make install
Keep in mind that CMake supports multiple build systems, so for each platform you can pass your own build system
as the -G option. For example:
cmake -GNinja ../aws-c-common
ninja build
ninja test
sudo ninja install
Or on windows,
cmake -G "Visual Studio 14 2015 Win64" ../aws-c-common
msbuild.exe ALL_BUILD.vcproj
CMake Options
- -DCMAKECLANGTIDY=/path/to/clang-tidy (or just clang-tidy or clang-tidy-7.0 if it is in your PATH) - Runs clang-tidy as part of your build.
- -DENABLESANITIZERS=ON - Enables gcc/clang sanitizers, by default this adds -fsanitizer=address,undefined to the compile flags for projects that call awsadd_sanitizers.
- -DENABLEFUZZTESTS=ON - Includes fuzz tests in the unit test suite. Off by default, because fuzz tests can take a long time. Set -DFUZZTESTSMAX_TIME=N to determine how long to run each fuzz test (default 60s).
- -DCMAKEINSTALLPREFIX=/path/to/install - Standard way of installing to a user defined path. If specified when configuring aws-c-common, ensure the same prefix is specified when configuring other aws-c-* SDKs.
- -DAWSSTATICMSVCRUNTIMELIBRARY=ON - Windows-only. Turn ON to use the statically-linked MSVC runtime lib, instead of the DLL.
API style and conventions
Every API has a specific set of styles and conventions. We'll outline them here. These conventions are followed in every library in the AWS C SDK ecosystem.
Error handling
Every function that returns an int type, returns AWS_OP_SUCCESS ( 0 ) or AWS_OP_ERR (-1) on failure. To retrieve
the error code, use the function aws_last_error(). Each error code also has a corresponding error string that can be
accessed via the aws_error_str() function.
In addition, you can install both a global and a thread local error handler by using the aws_set_global_error_handler_fn()
and aws_set_thread_local_error_handler_fn() functions.
All error functions are in the include/aws/common/error.h header file.
Naming
Any function that allocates and initializes an object will be suffixed with new (e.g. aws_myobj_new()). Similarly, these objects will always
have a corresponding function with a destroy suffix. The new functions will return the allocated object
on success and NULL on failure. To respond to the error, call aws_last_error(). If several new or destroy
functions are available, the variants should be named like new_x or destroy_x (e.g. aws_myobj_new_copy() or aws_myobj_destroy_secure()).
Any function that initializes an existing object will be suffixed with init (e.g. aws_myobj_init(). These objects will have a corresponding
clean_up function if necessary. In these cases, you are responsible for making the decisions for how your object is
allocated. The init functions return AWS_OP_SUCCESS ( 0 ) or AWS_OP_ERR (-1) on failure. If several init or
clean_up functions are available, they should be named like init_x or clean_up_x (e.g. aws_myobj_init_static() or
aws_myobj_clean_up_secure()).
Contributing
If you are contributing to this code-base, first off, THANK YOU!. There are a few things to keep in mind to minimize the pull request turn around time.
Coding "guidelines"
These "guidelines" are followed in every library in the AWS C SDK ecosystem.
Memory Management
- All APIs that need to be able to allocate memory, must take an instance of
aws_allocatorand use that. Nomalloc()orfree()calls should be made directly. - If an API does not allocate the memory, it does not free it. All allocations and deallocations should take place at the same level. For example, if a user allocates memory, the user is responsible for freeing it. There will inevitably be a few exceptions to this rule, but they will need significant justification to make it through the code-review.
- All functions that allocate memory must raise an
AWS_ERROR_OOMerror code upon allocation failures. If it is anew()function it should return NULL. If it is aninit()function, it should returnAWS_OP_ERR.
Threading
- Occasionally a thread is necessary. In those cases, prefer for memory not to be shared between threads. If memory must cross a thread barrier it should be a complete ownership hand-off. Bias towards, "if I need a mutex, I'm doing it wrong".
- Do not sleep or block .... ever .... under any circumstances, in non-test-code.
- Do not expose blocking APIs.
Error Handling
- For APIs returning an
interror code. The only acceptable return types areAWS_OP_SUCCESSandAWS_OP_ERR. Before returning control to the caller, if you have an error to raise, use theaws_raise_error()function. - For APIs returning an allocated instance of an object, return the memory on success, and
NULLon failure. Before returning control to the caller, if you have an error to raise, use theaws_raise_error()function.
See error-handling.md for a longer tutorial.
Log Subjects & Error Codes
The logging & error handling infrastructure is designed to support multiple libraries. For this to work, AWS maintained libraries have pre-slotted log subjects & error codes for each library. The currently allocated ranges are:
| Range | Library Name | | --- | --- | | [0x0000, 0x0400) | aws-c-common | | [0x0400, 0x0800) | aws-c-io | | [0x0800, 0x0C00) | aws-c-http | | [0x0C00, 0x1000) | aws-c-compression | | [0x1000, 0x1400) | aws-c-eventstream | | [0x1400, 0x1800) | aws-c-mqtt | | [0x1800, 0x1C00) | aws-c-auth | | [0x1C00, 0x2000) | aws-c-cal | | [0x2000, 0x2400) | aws-crt-cpp | | [0x2400, 0x2800) | aws-crt-java | | [0x2800, 0x2C00) | aws-crt-python | | [0x2C00, 0x3000) | aws-crt-nodejs | | [0x3000, 0x3400) | aws-crt-dotnet | | [0x3400, 0x3800) | aws-c-iot | | [0x3800, 0x3C00) | aws-c-s3 | | [0x3C00, 0x4000) | aws-c-sdkutils | | [0x4000, 0x4400) | aws-crt-kotlin | | [0x4400, 0x4800) | aws-crt-swift | | [0x4800, 0x4C00) | (reserved for future project) |
Each library should begin its error and log subject values at the beginning of its range and follow in sequence (don't skip codes). Upon adding an AWS maintained library, a new enum range must be approved and added to the above table.
Testing
We have a high bar for test coverage, and PRs fixing bugs or introducing new functionality need to have tests before they will be accepted. A couple of tips:
Aws Test Harness
We provide a test harness for writing unit tests. This includes an allocator that will fail your test if you have any
memory leaks, as well as some ASSERT macros. To write a test:
- Create a *.c test file in the tests directory of the project.
- Implement one or more tests with the signature
int test_case_name(struct aws_allocator *, void *ctx) - Use the
AWS_TEST_CASEmacro to declare the test. - Include your test in the
tests/main.cfile. - Include your test in the
tests/CMakeLists.txtfile.
Coding Style
- No Tabs.
- Indent is 4 spaces.
- K & R style for braces.
- Space after if, before the
(. elseandelse ifstay on the same line as the closing brace.
Example:
if (condition) {
do_something();
} else {
do_something_else();
}
- Avoid C99 features in header files. For some types such as bool, uint32_t etc..., these are defined if not available for the language
standard being used in
aws/common/common.h, so feel free to use them. - For C++ compatibility, don't put const members in structs.
- Avoid C++ style comments e.g.
//in header files and prefer block style (/* */) for long blocks of text. C++ style comments are fine in C files. - All public API functions need C++ guards and Windows dll semantics.
- Use Unix line endings.
- Where implementation hiding is desired for either ABI or runtime polymorphism reasons, use the
void *implpattern. v-tables should be the last member in the struct. - For #ifdef, put a # as the first character on the line and then indent the compilation branches.
Example:
#ifdef FOO
do_something();
# ifdef BAR
do_something_else();
# endif
#endif
- For all error code names with the exception of aws-c-common, use
AWS_ERROR_<lib name>_<error name>. - All error strings should be written using correct English grammar.
- SNAKEUPPERCASE constants, macros, and enum members.
- snakelowercase everything else.
static(local file scope) variables that are notconstare prefixed bys_and lower snake case.- Global variables not prefixed as
constare prefixed byg_and lower snake case. - Thread local variables are prefixed as
tl_and lower snake case. - Macros and
constvariables are upper snake case. - For constants, prefer anonymous enums.
- Don't typedef structs. It breaks forward declaration ability.
- Don't typedef enums. It breaks forward declaration ability.
typedef function definitions for use as function pointers as values and suffixed with _fn.
Do this:
typedef int(fn_name_fn)(void *);Not this:
typedef int(*fn_name_fn)(void *);If a callback may be async, then always have it be async. Callbacks that are sometimes async and sometimes sync are hard to code around and lead to bugs (see this blog post). Unfortunately many callbacks in this codebase currently violate this rule, so be careful. But do not add any more.
Every source and header file must have a copyright header (The standard AWS one for apache 2).
Use standard include guards (e.g. #IFNDEF HEADERNAME #define HEADERNAME etc...).
Include order should be: the header for the translation unit for the .c file newline header files in a directory in alphabetical order newline header files not in a directory (system and stdlib headers)
Platform specifics should be handled in c files and partitioned by directory.
Do not use
extern inline. It's too unpredictable between compiler versions and language standards.Namespace all definitions in header files with
aws_<libname>?_<api>_<what it does>. Lib name is not always required if a conflict is not likely and it provides better ergonomics.init,clean_up,new,destroyare suffixed to the function names for their object.
Example:
AWS_COMMON_API
int awsmoduleinit(awsmodulet *module); AWSCOMMONAPI void awsmodulecleanup(awsmodulet *module); AWSCOMMONAPI awsmodulet *awsmodulenew(awsallocatort *allocator); AWSCOMMONAPI void awsmoduledestroy(awsmodule_t *module);
Avoid c-strings, and don't write code that depends on
NULLterminators.- Pass strings via
struct aws_byte_cursor. This is a non-owning view type. Pass it by value. Strings passed this way do not need aNULLterminator. - Only pass
const char *when thinly wrapping an OS function that requires aNULLterminator. - Store const strings as
struct aws_string * - Store mutable string buffers as
struct aws_byte_buf
- Pass strings via
There is only one valid character encoding-- UTF-8. Try not to ever need to care about character encodings, but where you do, the working assumption should always be UTF-8 unless it's something we don't get a choice in (e.g. a protocol explicitly mandates a character set).
If a function has many arguments, or any optional arguments use an options-struct.
If a variable is time-related, always include the unit of time in its name (e.g.
timeout_ms).If you are adding/using a compiler specific keyword, macro, or intrinsic, hide it behind a platform independent macro definition. This mainly applies to header files. Obviously, if you are writing a file that will only be built on a certain platform, you have more liberty on this.
When checking more than one error condition, check and log each condition separately with a unique message.
Do this:
if (options->callback == NULL) { AWS_LOGF_ERROR(AWS_LS_SOME_SUBJECT, "Invalid options - callback is null"); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); } if (options->allocator == NULL) { AWS_LOGF_ERROR(AWS_LS_SOME_SUBJECT, "Invalid options - allocator is null"); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); }Not this:
if (options->callback == NULL || options->allocator == NULL) { AWS_LOGF_ERROR(AWS_LS_SOME_SUBJECT, "Invalid options - something is null"); return aws_raise_error(AWS_ERROR_INVALID_ARGUMENT); }
CBMC
To learn more about CBMC and proofs specifically, review the training material here.
The verification/cbmc/proofs directory contains CBMC proofs.
In order to run these proofs you will need to install CBMC and other tools by following the instructions here.
Owner
- Name: Amazon Web Services - Labs
- Login: awslabs
- Kind: organization
- Location: Seattle, WA
- Website: http://amazon.com/aws/
- Repositories: 914
- Profile: https://github.com/awslabs
AWS Labs
GitHub Events
Total
- Create event: 77
- Issues event: 13
- Release event: 15
- Watch event: 19
- Delete event: 46
- Issue comment event: 70
- Push event: 251
- Pull request review comment event: 76
- Pull request review event: 102
- Pull request event: 95
- Fork event: 12
Last Year
- Create event: 77
- Issues event: 13
- Release event: 15
- Watch event: 19
- Delete event: 46
- Issue comment event: 70
- Push event: 251
- Pull request review comment event: 76
- Pull request review event: 102
- Pull request event: 95
- Fork event: 12
Committers
Last synced: almost 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Michael Graeb | g****m@a****m | 99 |
| Bret Ambrose | b****e@g****m | 84 |
| Justin Boswell | b****j@a****m | 71 |
| Daniel Schwartz-Narbonne | d****n | 59 |
| Jonathan M. Henson | j****n@g****m | 58 |
| Felipe R. Monteiro | f****s@a****m | 48 |
| Colden Cullen | c****n@c****m | 45 |
| Jonathan M. Henson | h****o@a****m | 39 |
| David Koenig | d****g@a****m | 28 |
| bdonlan | b****n@g****m | 26 |
| Bryan Donlan | b****n@a****m | 24 |
| Colden Cullen | C****n@G****m | 22 |
| Dmitriy Musatkin | 6****n | 21 |
| Colden Cullen | c****n@a****m | 18 |
| Felipe R. Monteiro | r****e@g****m | 18 |
| Konstantinos Kallas | k****s@h****m | 16 |
| Waqar Ahmed Khan | w****7@g****m | 16 |
| Kareem Khazem | k****z@a****m | 15 |
| Justin Boswell | j****l@g****m | 14 |
| Marco Magdy | m****y | 13 |
| Dengke Tang | d****t@a****m | 13 |
| David Koenig | 3****g | 12 |
| Dengke Tang | 8****5@q****m | 10 |
| TwistedTwigleg | n****d@a****m | 8 |
| Ryan Carper | 5****r | 6 |
| Jacob Peddicord | j****d | 6 |
| David Oguns | 3****S | 6 |
| Joseph Klix | j****l@a****m | 5 |
| Nathan Chong | 5****s | 4 |
| tegansb | 6****b | 4 |
| and 54 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 9 months ago
All Time
- Total issues: 78
- Total pull requests: 361
- Average time to close issues: about 2 years
- Average time to close pull requests: 3 months
- Total issue authors: 50
- Total pull request authors: 48
- Average comments per issue: 1.64
- Average comments per pull request: 0.72
- Merged pull requests: 261
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 9
- Pull requests: 99
- Average time to close issues: 11 days
- Average time to close pull requests: 8 days
- Issue authors: 9
- Pull request authors: 16
- Average comments per issue: 1.0
- Average comments per pull request: 0.74
- Merged pull requests: 70
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- feliperodri (6)
- thomas-roos (4)
- grrtrr (4)
- glaubitz (3)
- jkuszmaul (3)
- jeking3 (3)
- danielsn (3)
- tegansb (2)
- stewartsmith (2)
- markus289 (2)
- TingDaoK (2)
- jmklix (2)
- pbadari (2)
- nchong-at-aws (2)
- disa6302 (2)
Pull Request Authors
- graebm (69)
- waahm7 (49)
- DmitriyMusatkin (46)
- TingDaoK (39)
- bretambrose (19)
- sfod (14)
- jmklix (13)
- JonathanHenson (13)
- tautschnig (11)
- xiazhvera (7)
- grrtrr (5)
- karkhaz (5)
- qinheping (4)
- teo-tsirpanis (4)
- knightjoel (4)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 16
-
Total downloads:
- homebrew 4,906 last-month
-
Total dependent packages: 422
(may contain duplicates) -
Total dependent repositories: 130
(may contain duplicates) - Total versions: 374
- Total maintainers: 3
alpine-v3.18: aws-c-common
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.9.12-r0
published about 2 years ago
Rankings
Maintainers (1)
alpine-v3.18: aws-c-common-dev
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling (development files)
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.9.12-r0
published about 2 years ago
Rankings
Maintainers (1)
proxy.golang.org: github.com/awslabs/aws-c-common
- Documentation: https://pkg.go.dev/github.com/awslabs/aws-c-common#section-documentation
- License: apache-2.0
-
Latest release: v0.12.4
published 11 months ago
Rankings
alpine-edge: aws-c-common
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.12.4-r1
published 10 months ago
Rankings
Maintainers (1)
alpine-edge: aws-c-common-dev
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling (development files)
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.12.4-r1
published 10 months ago
Rankings
Maintainers (1)
conda-forge.org: aws-c-common
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.8.5
published over 3 years ago
Rankings
anaconda.org: aws-c-common
Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.12.4
published 9 months ago
Rankings
formulae.brew.sh: aws-c-common
Core c99 package for AWS SDK for C
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.12.4
published 10 months ago
Rankings
alpine-v3.21: aws-c-common-dev
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling (development files)
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.10.5-r0
published over 1 year ago
Rankings
Maintainers (1)
alpine-v3.19: aws-c-common
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.9.12-r0
published almost 2 years ago
Rankings
alpine-v3.21: aws-c-common
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.10.5-r0
published over 1 year ago
Rankings
Maintainers (1)
alpine-v3.22: aws-c-common-dev
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling (development files)
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.12.3-r0
published about 1 year ago
Rankings
Maintainers (1)
alpine-v3.20: aws-c-common
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.9.19-r0
published about 2 years ago
Rankings
alpine-v3.20: aws-c-common-dev
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling (development files)
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.9.19-r0
published about 2 years ago
Rankings
alpine-v3.19: aws-c-common-dev
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling (development files)
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.9.12-r0
published almost 2 years ago
Rankings
alpine-v3.22: aws-c-common
Core c99 package for AWS SDK for C including cross-platform primitives, configuration, data structures, and error handling
- Homepage: https://github.com/awslabs/aws-c-common
- License: Apache-2.0
-
Latest release: 0.12.3-r0
published about 1 year ago