Skip to content

Commit

Permalink
Require size_t to be at least 32 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaaaa123456789 committed Jan 24, 2022
1 parent 0264c24 commit 294423c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Note: releases are listed from latest to oldest.
- Added and improved some safety checks that detect maliciously-crafted and other pathological files
- Added detection for empty GIF files (erroring out with `PLUM_ERR_NO_DATA` instead of `PLUM_ERR_INVALID_FILE_FORMAT`)
- Improved PNG compression by fixing a lookback bug in the compressor
- Added and documented a restriction requiring `size_t` to be at least 32 bits wide
- Some minor documentation updates and code cleanup

## Version 0.3 (10 January 2022)
Expand Down
2 changes: 2 additions & 0 deletions docs/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ here for completeness.
This is enforced by the usage of the `uint8_t` type.
- The system uses two's complement for signed numbers.
This is enforced by the usage of the `int16_t` type.
- The `size_t` type is at least 32 bits wide.
This is checked when compiling the library.
- All data pointers ("object pointers" in the standard's parlance) have the same representation; in other words, you
can copy one pointer into another and access it that way (assuming the pointer is properly aligned).
This in turn implies that, if a union contains pointers as members, a value assigned to one of those members can be
Expand Down
4 changes: 4 additions & 0 deletions src/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

#define PLUM_DEFS

#include <stdint.h>

#if defined(PLUM_NO_STDINT) || defined(PLUM_NO_ANON_MEMBERS) || defined(PLUM_NO_VLA)
#error libplum feature-test macros must not be defined when compiling the library.
#elif defined(__cplusplus)
#error libplum cannot be compiled with a C++ compiler.
#elif __STDC_VERSION__ < 201710L
#error libplum requires C17 or later.
#elif SIZE_MAX < 0xffffffffu
#error libplum requires size_t to be at least 32 bits wide.
#endif

#ifdef noreturn
Expand Down

0 comments on commit 294423c

Please sign in to comment.