Differences From Artifact [e71e68e9ff]:
- File
src/macros.h
— part of check-in
[0c3c3b6efa]
at
2024-05-01 15:19:55
on branch trunk
— Document a lot of undocumented functions & macros
Also fixes Doxygen not creating documentation for `static OF_INLINE`
functions. (user: js, size: 25888) [annotate] [blame] [check-ins using] [more...]
To Artifact [3c8f4714cc]:
- File
src/macros.h
— part of check-in
[96f946d7ad]
at
2024-05-09 10:21:24
on branch trunk
— Use unsigned long for bit sets
This should be more efficient on some architectures.
As a nice side effect, this is also what Linux does in some userspace
APIs, so after this change, these macros can be used for this as well
(and Linux interestingly does not provide similar macros in the
userspace headers). (user: js, size: 25972) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
936 937 938 939 940 941 942 943 | * @param pow2 The power of 2 to round up to * @param value The value to round up to the specified power of two * @return The specified value rounded up to the specified power of two */ #define OFRoundUpToPowerOf2(pow2, value) \ (((value) + (pow2) - 1) & ~((pow2) - 1)) static OF_INLINE bool | > > | | | | | | | 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 | * @param pow2 The power of 2 to round up to * @param value The value to round up to the specified power of two * @return The specified value rounded up to the specified power of two */ #define OFRoundUpToPowerOf2(pow2, value) \ (((value) + (pow2) - 1) & ~((pow2) - 1)) #define OF_ULONG_BIT (sizeof(unsigned long) * CHAR_BIT) static OF_INLINE bool OFBitSetIsSet(unsigned long *_Nonnull storage, size_t idx) { return storage[idx / OF_ULONG_BIT] & (1ul << (idx % OF_ULONG_BIT)); } static OF_INLINE void OFBitSetSet(unsigned long *_Nonnull storage, size_t idx) { storage[idx / OF_ULONG_BIT] |= (1ul << (idx % OF_ULONG_BIT)); } static OF_INLINE void OFBitSetClear(unsigned long *_Nonnull storage, size_t idx) { storage[idx / OF_ULONG_BIT] &= ~(1ul << (idx % OF_ULONG_BIT)); } static OF_INLINE void OFZeroMemory(void *_Nonnull buffer_, size_t length) { volatile unsigned char *buffer = (volatile unsigned char *)buffer_; |
︙ | ︙ |