#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <errno.h>
#include "utils/ellipsis-error.h"
#include "utils/ellipsis-malloc.h"
Go to the source code of this file.
Typedefs | |
typedef struct ellipsis‿contracts‿is_ice | ellipsis‿contracts‿is_ice |
typedef enum ellipsis‿init‿flex | ellipsis‿init‿flex |
Functions | |
void * | ellipsis‿alloc‿flex_core_s‿_Ctra (signed long long len, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char const base_init[restrict static 1], unsigned char const dat_init[restrict static 1]) |
void * | ellipsis‿alloc‿flex_core_s (signed long long len, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char const base_init[restrict static 1], unsigned char const dat_init[restrict static 1]) |
void * | ellipsis‿alloc‿flex_core_u‿_Ctra (unsigned long long len, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char const base_init[restrict static 1], unsigned char const dat_init[restrict static 1]) |
void * | ellipsis‿alloc‿flex_core_u (unsigned long long len, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char const base_init[restrict static 1], unsigned char const dat_init[restrict static 1]) |
bool | ellipsis‿init‿check_range (size_t len, size_t size_dat, size_t off_dat) |
bool | ellipsis‿init‿check_type (ellipsis‿init‿flex type, size_t len) |
void * | ellipsis‿init‿flex_core_s‿_Ctra (signed long long len, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char ret[restrict static(off_dat+len *size_dat)], unsigned char const base_init[restrict static 1], unsigned char const dat_init[restrict static 1]) |
void * | ellipsis‿init‿flex_core_s (signed long long len, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char ret[restrict static(off_dat+len *size_dat)], unsigned char const base_init[restrict static 1], unsigned char const dat_init[restrict static 1]) |
void * | ellipsis‿init‿flex_core_u‿_Ctra (unsigned long long len, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char ret[restrict static(off_dat+len *size_dat)], unsigned char const base_init[restrict static 1], unsigned char const dat_init[restrict static 1]) |
void * | ellipsis‿init‿flex_core_u (unsigned long long len, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char ret[restrict static(off_dat+len *size_dat)], unsigned char const base_init[restrict static 1], unsigned char const dat_init[restrict static 1]) |
void * | ellipsis‿init‿obfuscate (void *p) |
void | ellipsis‿init‿repeat‿_Ctra (size_t n, unsigned char const sample[restrict static n], size_t m, unsigned char buffer[restrict static m]) |
void | ellipsis‿init‿repeat (size_t n, unsigned char const sample[restrict static n], size_t m, unsigned char buffer[restrict static m]) |
void * | ellipsis‿realloc‿flex_core_s‿_Ctra (signed long long len, void *ostart_, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char const ini[restrict static 1]) |
void * | ellipsis‿realloc‿flex_core_s (signed long long len, void *ostart_, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char const ini[restrict static 1]) |
void * | ellipsis‿realloc‿flex_core_u‿_Ctra (unsigned long long len, void *ostart_, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char const ini[restrict static 1]) |
void * | ellipsis‿realloc‿flex_core_u (unsigned long long len, void *ostart_, size_t size_base, ellipsis‿init‿flex type, size_t off_len, size_t size_dat, size_t off_dat, unsigned char const ini[restrict static 1]) |
Variables | |
thread_local bool volatile | ellipsis‿contracts‿ignore‿dynamic |
thread_local bool volatile | ellipsis‿contracts‿proceed‿dynamic |
thread_local bool volatile | ellipsis‿contracts‿verbose‿dynamic |
This implements initialization of arrays and structures with flexible array members as has been proposed in
Jens Gustedt, Martin Uecker: Initialization, allocation and effective type
#define ellipsis_alloc | ( | L, | |
... | |||
) | ELLIPSIS_ALLOC_Iplus ((L) __VA_OPT__(,) __VA_ARGS__) |
Allocate a target array with a base type as indicated by T
. T
can be a typename of a pointer type or a pointer value. In most cases, the array has the same type unless the pointer is a void pointer in which case the array has base type unsigned char.
at least one argument must be provided
#define ellipsis_alloc_flex | ( | L, | |
T, | |||
FL, | |||
LEN, | |||
... | |||
) |
#define ELLIPSIS_ALLOC_I | ( | L | ) | ELLIPSIS_ALLOC_IIplus (L, void) |
#define ELLIPSIS_ALLOC_IIplus | ( | L, | |
T, | |||
... | |||
) |
#define ELLIPSIS_ALLOC_Iplus | ( | L, | |
... | |||
) | ELLIPSIS_ALLOC_I ## __VA_OPT__(Iplus) (L __VA_OPT__(,) __VA_ARGS__) |
#define ELLIPSIS_CONTRACT | ( | COUNT, | |
COND, | |||
ACTION, | |||
VERB, | |||
CSTR, | |||
CTYPE, | |||
... | |||
) |
#define ELLIPSIS_CONTRACT_CHECK_STATIC | ( | CTYPE, | |
COND, | |||
CSTR, | |||
... | |||
) |
#define ELLIPSIS_CONTRACT_ICE_OR_TRUE | ( | ... | ) |
#define ELLIPSIS_CONTRACT_IMPL | ( | COUNT, | |
COND, | |||
ACTION, | |||
VERB, | |||
CSTR, | |||
CTYPE, | |||
... | |||
) |
#define ELLIPSIS_CONTRACT_VIOLATION | ( | COUNT, | |
VERB, | |||
CTYPE, | |||
CSTR, | |||
... | |||
) |
#define ellipsis_init | ( | L, | |
P, | |||
... | |||
) | ELLIPSIS_INIT_IIplus((L), (P) __VA_OPT__(,) __VA_ARGS__) |
Initialize a target array at position P with a base type as indicated by T. T can be a typename of a pointer type or a pointer value. In most cases, the array has the pointed-to type by T unless the T is a void pointer in which case the array has base type unsigned char. P will in general be pointer returned by malloc
or similar function.
This type-generic macro overwrites repeatedly *P as much contents as possible with an initializer of type indicated by T. If there is no initializer (... is empty or absent) a default initialized object is used. If T is missing, void*
is used instead.
This macro also overwrites the effective type of the target array. That is, if the target is allocated (has no declaration) the initializer is copied into it and the effective type changes to the target type.
The implementation is a bit more complicated because we have to take care of implementations that do not yet implement {}
initialization for_DEFER_REPLAY_FOR VLA.
#define ELLIPSIS_INIT_DEFAULT 0 |
#define ellipsis_init_flex | ( | L, | |
P, | |||
T, | |||
FL, | |||
LEN, | |||
... | |||
) |
#define ELLIPSIS_INIT_FLEX_TYPE | ( | ... | ) |
#define ELLIPSIS_INIT_II | ( | L, | |
P | |||
) | ELLIPSIS_INIT_IIIIplus (L, P, void, ELLIPSIS_INIT_DEFAULT) |
#define ELLIPSIS_INIT_III | ( | L, | |
P, | |||
T | |||
) | ELLIPSIS_INIT_IIIIplus (L, P, T, ELLIPSIS_INIT_DEFAULT) |
#define ELLIPSIS_INIT_IIIIplus | ( | L, | |
P, | |||
T, | |||
... | |||
) |
#define ELLIPSIS_INIT_IIIplus | ( | L, | |
P, | |||
T, | |||
... | |||
) | ELLIPSIS_INIT_III ## __VA_OPT__(Iplus)(L, P, T __VA_OPT__(,) __VA_ARGS__) |
#define ELLIPSIS_INIT_IIplus | ( | L, | |
P, | |||
... | |||
) | ELLIPSIS_INIT_II ## __VA_OPT__(Iplus)(L, P __VA_OPT__(,) __VA_ARGS__) |
#define ELLIPSIS_INIT_OBFUSCATE | ( | X | ) | ((typeof(X)restrict const){ellipsis‿init‿obfuscate(X), }) |
Enable us to reinterpret a given pointer to carry a new object that does not alias with any object that we have seen so far.
#define ELLIPSIS_INIT_WHEN_SIGNED | ( | X, | |
A, | |||
B | |||
) |
#define ellipsis_realloc_flex | ( | L, | |
P, | |||
FL, | |||
LEN | |||
) |
#define ELLIPSIS_TEST_ICE | ( | ... | ) | (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr) |
#define ELLIPSIS_TO_VOIDS | ( | ... | ) | ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__)))) |
#define STRINGIFY | ( | ... | ) | STRINGIFY_(__VA_ARGS__) |
#define STRINGIFY_ | ( | ... | ) | #__VA_ARGS__ |
#define TARGET_SIZE | ( | T | ) |
Determine element size of target array to which points T. T can be a typename of a pointer type or a pointer value. In most cases, the result type is just the size each element, unless the pointer is a void pointer in which case the size is 1.
#define TARGET_TYPE | ( | T | ) |
Determine type of target array to which points T. T can be a typename of a pointer type or a pointer value. In most cases, the result type is an expression of the same type unless the pointer is a void pointer in which case the target type is changed to a unsigned char.
typedef struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice |
typedef enum ellipsis‿init‿flex ellipsis‿init‿flex |
enum ellipsis‿init‿flex |
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
defer needs braces and a semicolon
end inner defer anchor, level 1
References ellipsis‿alloc‿flex_core_s‿_Ctra(), ellipsis‿alloc‿flex_core_s‿_Inner(), ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿alloc‿flex_core_s‿_Ctra(), and ellipsis‿alloc‿flex_core_s‿_Insta().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
defer needs braces and a semicolon
end inner defer anchor, level 1
References ellipsis‿alloc‿flex_core_s‿_Insta(), ellipsis‿alloc‿flex_core_s, ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), and ELLIPSIS_CONTRACT.
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
defer needs braces and a semicolon
end inner defer anchor, level 1
References ellipsis‿alloc‿flex_core_u‿_Ctra(), ellipsis‿alloc‿flex_core_u‿_Inner(), ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿alloc‿flex_core_u‿_Ctra(), and ellipsis‿alloc‿flex_core_u‿_Insta().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
defer needs braces and a semicolon
end inner defer anchor, level 1
References ellipsis‿alloc‿flex_core_u‿_Insta(), ellipsis‿alloc‿flex_core_u, ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), and ELLIPSIS_CONTRACT.
|
inline |
Referenced by ellipsis‿alloc‿flex_core_s‿_Ctra(), ellipsis‿alloc‿flex_core_s(), ellipsis‿alloc‿flex_core_u‿_Ctra(), ellipsis‿alloc‿flex_core_u(), ellipsis‿init‿flex_core_s‿_Ctra(), ellipsis‿init‿flex_core_s(), ellipsis‿init‿flex_core_u‿_Ctra(), ellipsis‿init‿flex_core_u(), ellipsis‿realloc‿flex_core_s‿_Ctra(), ellipsis‿realloc‿flex_core_s(), ellipsis‿realloc‿flex_core_u‿_Ctra(), and ellipsis‿realloc‿flex_core_u().
|
inline |
References ALLOC_CHECK_RETURN.
Referenced by ellipsis‿alloc‿flex_core_s‿_Ctra(), ellipsis‿alloc‿flex_core_s(), ellipsis‿alloc‿flex_core_u‿_Ctra(), ellipsis‿alloc‿flex_core_u(), ellipsis‿init‿flex_core_s‿_Ctra(), ellipsis‿init‿flex_core_s(), ellipsis‿init‿flex_core_u‿_Ctra(), ellipsis‿init‿flex_core_u(), ellipsis‿realloc‿flex_core_s‿_Ctra(), ellipsis‿realloc‿flex_core_s(), ellipsis‿realloc‿flex_core_u‿_Ctra(), and ellipsis‿realloc‿flex_core_u().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
end inner defer anchor, level 1
References ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), ellipsis‿init‿flex_core_s‿_Ctra(), ellipsis‿init‿flex_core_s‿_Inner(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿init‿flex_core_s‿_Ctra(), and ellipsis‿init‿flex_core_s‿_Insta().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
end inner defer anchor, level 1
References ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), ellipsis‿init‿flex_core_s‿_Insta(), ellipsis‿init‿flex_core_s(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿init‿flex_core_s().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
end inner defer anchor, level 1
References ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), ellipsis‿init‿flex_core_u‿_Ctra(), ellipsis‿init‿flex_core_u‿_Inner(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿init‿flex_core_u‿_Ctra(), and ellipsis‿init‿flex_core_u‿_Insta().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
end inner defer anchor, level 1
References ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), ellipsis‿init‿flex_core_u‿_Insta(), ellipsis‿init‿flex_core_u(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿init‿flex_core_s‿_Inner(), and ellipsis‿init‿flex_core_u().
void * ellipsis‿init‿obfuscate | ( | void * | p | ) |
|
inline |
References ellipsis‿init‿repeat‿_Ctra(), ellipsis‿init‿repeat‿_Inner(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿init‿repeat‿_Ctra(), and ellipsis‿init‿repeat‿_Insta().
|
inline |
References ellipsis‿init‿repeat‿_Insta(), ellipsis‿init‿repeat(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿alloc‿flex_core_u‿_Inner(), ellipsis‿init‿flex_core_u‿_Inner(), ellipsis‿init‿repeat(), and ellipsis‿realloc‿flex_core_u‿_Inner().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
defer needs braces and a semicolon
end inner defer anchor, level 1
References ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), ellipsis‿realloc‿flex_core_s‿_Ctra(), ellipsis‿realloc‿flex_core_s‿_Inner(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿realloc‿flex_core_s‿_Ctra(), and ellipsis‿realloc‿flex_core_s‿_Insta().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
defer needs braces and a semicolon
end inner defer anchor, level 1
References ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), ellipsis‿realloc‿flex_core_s‿_Insta(), ellipsis‿realloc‿flex_core_s, and ELLIPSIS_CONTRACT.
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
defer needs braces and a semicolon
end inner defer anchor, level 1
References ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), ellipsis‿realloc‿flex_core_u‿_Ctra(), ellipsis‿realloc‿flex_core_u‿_Inner(), and ELLIPSIS_CONTRACT.
Referenced by ellipsis‿realloc‿flex_core_u‿_Ctra(), and ellipsis‿realloc‿flex_core_u‿_Insta().
|
inline |
start inner defer anchor at level 1
DEFER_TYPE needs a semicolon
defer needs braces and a semicolon
end inner defer anchor, level 1
References ellipsis‿init‿check_range(), ellipsis‿init‿check_type(), ellipsis‿realloc‿flex_core_u‿_Insta(), ellipsis‿realloc‿flex_core_u, and ELLIPSIS_CONTRACT.
|
extern |
|
extern |
|
extern |