Remove macros

This commit is contained in:
Alex Kotov 2022-12-25 13:58:52 +04:00
parent e7a6eed1cf
commit ea359a1795
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
7 changed files with 0 additions and 130 deletions

View File

@ -38,9 +38,6 @@ We use [semantic versioning](https://semver.org) for stable APIs. Stable APIs
may only change when major version number is increased (or minor while major is
zero). Work-in-progress APIs can change at any time.
* Basic features
* [Macros](/include/kernaux/macro.h) (*non-breaking since* **0.6.0**)
* Stack trace *(planned)*
* libc replacement (*work in progress*)
* [ctype.h](/libc/include/ctype.h)
* [errno.h](/libc/include/errno.h)
@ -50,17 +47,6 @@ zero). Work-in-progress APIs can change at any time.
* [string.h](/libc/include/string.h)
* [sys/types.h](/libc/include/sys/types.h)
### Definitions
`#define` the following C preprocessor macros before including `<kernaux.h>` and
`<kernaux/*.h>` files. They have effect on your code, not the library code.
* `KERNAUX_ACCESS_PRIVATE` - disable access modifier "private". Don't do this!
* `KERNAUX_ACCESS_PROTECTED` - disable access modifier "protected". Only do this
in a file where you implement an inherited type.
* `KERNAUX_BITFIELDS` - enable bitfields in packed structs. It doesn't follow
the C standard and may be incompatible with some compilers.

View File

@ -1,5 +0,0 @@
nobase_include_HEADERS = \
kernaux.h \
kernaux/macro.h \
kernaux/macro/packing_end.run \
kernaux/macro/packing_start.run

View File

@ -1 +0,0 @@
#include <kernaux/macro.h>

View File

@ -1,100 +0,0 @@
#ifndef KERNAUX_INCLUDED_MACRO
#define KERNAUX_INCLUDED_MACRO
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
/*********************
* Language features *
*********************/
#define KERNAUX_NORETURN __attribute__((noreturn))
#define KERNAUX_RETURNS_TWICE __attribute__((returns_twice))
#define KERNAUX_UNUSED __attribute__((unused))
#define KERNAUX_USED __attribute__((used))
#define KERNAUX_ALIGNED(num) __attribute__((aligned(num)))
#define KERNAUX_SECTION(name) __attribute__((section(name)))
#ifdef __TINYC__
# define KERNAUX_PACKED
#else
# define KERNAUX_PACKED __attribute__((packed))
#endif
#define KERNAUX_ASM(...) do { __asm__ __volatile__(__VA_ARGS__); } while (0)
/**************
* Visibility *
**************/
#ifdef KERNAUX_ACCESS_PRIVATE
# define KERNAUX_PRIVATE_FIELD(id) id
# define KERNAUX_PROTECTED_FIELD(id) id
#else
# define KERNAUX_PRIVATE_FIELD(id) _private_##id
# ifdef KERNAUX_ACCESS_PROTECTED
# define KERNAUX_PROTECTED_FIELD(id) id
# else
# define KERNAUX_PROTECTED_FIELD(id) _protected_##id
# endif
#endif // KERNAUX_ACCESS_PRIVATE
/*********************
* Static assertions *
*********************/
#define KERNAUX_STATIC_TEST(name, cond) \
KERNAUX_UNUSED \
static const int \
_kernaux_static_test_##name[(cond) ? 1 : -1]
#define KERNAUX_STATIC_TEST_STRUCT_SIZE(name, size) \
KERNAUX_STATIC_TEST(struct_size_##name, sizeof(struct name) == (size))
#define KERNAUX_STATIC_TEST_UNION_SIZE(name, size) \
KERNAUX_STATIC_TEST(union_size_##name, sizeof(union name) == (size))
/*****************
* Simple values *
*****************/
#define KERNAUX_EOF (-1)
/*********************
* Calculated values *
*********************/
#define KERNAUX_CONTAINER_OF(ptr, type, member) \
((type*)((uintptr_t)(ptr) - offsetof(type, member)))
#define KERNAUX_BITS(n) (1u << (n))
#define KERNAUX_BITS8(n) ((uint8_t )(((uint8_t )1) << (n)))
#define KERNAUX_BITS16(n) ((uint16_t)(((uint16_t)1) << (n)))
#define KERNAUX_BITS32(n) ((uint32_t)(((uint32_t)1) << (n)))
#define KERNAUX_BITS64(n) ((uint64_t)(((uint64_t)1) << (n)))
/*********************
* Safe type casting *
*********************/
#define KERNAUX_CAST_VAR(type, name, value) \
KERNAUX_STATIC_TEST(cast_pos_##name, sizeof(value) <= sizeof(type)); \
KERNAUX_STATIC_TEST(cast_neg_##name, sizeof(-(value)) <= sizeof(type)); \
type name = (type)(value); \
do {} while (0)
#define KERNAUX_CAST_CONST(type, name, value) \
KERNAUX_CAST_VAR(const type, name, value)
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,3 +0,0 @@
#ifdef __TINYC__
#pragma pack(pop)
#endif

View File

@ -1,3 +0,0 @@
#ifdef __TINYC__
#pragma pack(push, 1)
#endif

View File

@ -1,7 +1,3 @@
include/kernaux.h
include/kernaux/macro.h
include/kernaux/macro/packing_end.run
include/kernaux/macro/packing_start.run
lib/libkernaux.a
lib/libkernaux.so
lib/libkernaux.so.0