|
|
@ -47,12 +47,10 @@ typedef unsigned long ulong; |
|
|
|
# define ATTR_UNUSED __attribute__((unused)) |
|
|
|
# define ATTR_UNUSED __attribute__((unused)) |
|
|
|
# define ATTR_NORETURN __attribute__((noreturn)) |
|
|
|
# define ATTR_NORETURN __attribute__((noreturn)) |
|
|
|
# define ATTR_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) |
|
|
|
# define ATTR_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) |
|
|
|
# define ATTR_PACKED(ref) __attribute__((packed,aligned(sizeof(ref)))) |
|
|
|
|
|
|
|
#else |
|
|
|
#else |
|
|
|
# define ATTR_UNUSED |
|
|
|
# define ATTR_UNUSED |
|
|
|
# define ATTR_NORETURN |
|
|
|
# define ATTR_NORETURN |
|
|
|
# define ATTR_PRINTFLIKE(fmt,var) |
|
|
|
# define ATTR_PRINTFLIKE(fmt,var) |
|
|
|
# define ATTR_PACKED(ref) |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#if defined(__clang__) |
|
|
|
#if defined(__clang__) |
|
|
@ -137,7 +135,7 @@ void flushn( void ); |
|
|
|
typedef struct string_list { |
|
|
|
typedef struct string_list { |
|
|
|
struct string_list *next; |
|
|
|
struct string_list *next; |
|
|
|
char string[1]; |
|
|
|
char string[1]; |
|
|
|
} ATTR_PACKED(void *) string_list_t; |
|
|
|
} string_list_t; |
|
|
|
|
|
|
|
|
|
|
|
void add_string_list_n( string_list_t **list, const char *str, uint len ); |
|
|
|
void add_string_list_n( string_list_t **list, const char *str, uint len ); |
|
|
|
void add_string_list( string_list_t **list, const char *str ); |
|
|
|
void add_string_list( string_list_t **list, const char *str ); |
|
|
@ -176,22 +174,26 @@ int map_name( const char *arg, char **result, uint reserve, const char *in, cons |
|
|
|
typedef struct { \
|
|
|
|
typedef struct { \
|
|
|
|
T *data; \
|
|
|
|
T *data; \
|
|
|
|
uint size; \
|
|
|
|
uint size; \
|
|
|
|
} ATTR_PACKED(T *) T##_array_t; \
|
|
|
|
} T##_array_t; \
|
|
|
|
typedef struct { \
|
|
|
|
typedef union { \
|
|
|
|
T##_array_t array; \
|
|
|
|
T##_array_t array; \
|
|
|
|
uint alloc; \
|
|
|
|
struct { \
|
|
|
|
} ATTR_PACKED(T *) T##_array_alloc_t; \
|
|
|
|
T *dummy_data; \
|
|
|
|
|
|
|
|
uint dummy_size; \
|
|
|
|
|
|
|
|
uint alloc; \
|
|
|
|
|
|
|
|
} extra; \
|
|
|
|
|
|
|
|
} T##_array_alloc_t; \
|
|
|
|
static INLINE T *T##_array_append( T##_array_alloc_t *arr ) \
|
|
|
|
static INLINE T *T##_array_append( T##_array_alloc_t *arr ) \
|
|
|
|
{ \
|
|
|
|
{ \
|
|
|
|
if (arr->array.size == arr->alloc) { \
|
|
|
|
if (arr->array.size == arr->extra.alloc) { \
|
|
|
|
arr->alloc = arr->alloc * 2 + 100; \
|
|
|
|
arr->extra.alloc = arr->extra.alloc * 2 + 100; \
|
|
|
|
arr->array.data = nfrealloc( arr->array.data, arr->alloc * sizeof(T) ); \
|
|
|
|
arr->array.data = nfrealloc( arr->array.data, arr->extra.alloc * sizeof(T) ); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
return &arr->array.data[arr->array.size++]; \
|
|
|
|
return &arr->array.data[arr->array.size++]; \
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define ARRAY_INIT(arr) \ |
|
|
|
#define ARRAY_INIT(arr) \ |
|
|
|
do { (arr)->array.data = NULL; (arr)->array.size = (arr)->alloc = 0; } while (0) |
|
|
|
do { (arr)->array.data = NULL; (arr)->array.size = (arr)->extra.alloc = 0; } while (0) |
|
|
|
|
|
|
|
|
|
|
|
#define ARRAY_SQUEEZE(arr) \ |
|
|
|
#define ARRAY_SQUEEZE(arr) \ |
|
|
|
do { \
|
|
|
|
do { \
|
|
|
|