~ashn/autil

13609ee6726e67bff0ce5eb8eff03c8fc50dbcd1 — ashn 1 year, 2 months ago 6860733
Remove the AUTIL_ALIGNOF macro

WG14 N2350 defines the behavior of `offsetof(type, member)` to be
undefined if `type` defines a new type.
2 files changed, 2 insertions(+), 11 deletions(-)

M CHANGELOG-autil.txt
M autil.h
M CHANGELOG-autil.txt => CHANGELOG-autil.txt +1 -0
@@ 2,6 2,7 @@ Unreleased
--------------------------------
+ Replace autil_string_split* functions with a single autil_string_split.
+ Remove autil_sipool and associated functions.
+ Remove AUTIL_ALIGNOF

v1.0.2 - 2022-06-03
--------------------------------

M autil.h => autil.h +1 -11
@@ 61,7 61,7 @@ LICENSE
#endif

#include <stdarg.h> /* va_list */
#include <stddef.h> /* size_t, NULL, offsetof */
#include <stddef.h> /* size_t, NULL */
#include <stdio.h> /* FILE*, printf-family */

struct autil_vstr;


@@ 113,12 113,6 @@ typedef union {
// Number of characters in a formatted string.
#define AUTIL_FMT_COUNT(fmt, ...) ((size_t)snprintf(NULL, 0, fmt, __VA_ARGS__))

// C99 compatible _Alignof operator.
// Produces an integer constant expression.
// clang-format off
#define AUTIL_ALIGNOF(type) offsetof(struct{char _; type ty;}, ty)
// clang-format on

// C99 compatible(ish) _Static_assert.
// Macro parameter what should be a valid identifier describing the assertion.
// Flips the order of arguments from C11's _Static_assert so that assertions


@@ 1477,10 1471,6 @@ autil_vstr_ends_with(
    return autil_memcmp(start, target->start, target->count) == 0;
}

AUTIL_STATIC_ASSERT(
    SBUF_HEADER_OFFSET_IS_ALIGNED,
    AUTIL__SBUF_HEADER_OFFSET_ % AUTIL_ALIGNOF(autil_max_align_type) == 0);

/* reserve */
AUTIL_API void*
autil__sbuf_rsv_(size_t elemsize, void* sbuf, size_t cap)