From ea359a179577c63f2184a5cfcf2e9b37e8de859a Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 25 Dec 2022 13:58:52 +0400 Subject: [PATCH] Remove macros --- README.md | 14 ---- include/Makefile.am | 5 -- include/kernaux.h | 1 - include/kernaux/macro.h | 100 ------------------------ include/kernaux/macro/packing_end.run | 3 - include/kernaux/macro/packing_start.run | 3 - pkgs/freebsd/devel/libkernaux/pkg-plist | 4 - 7 files changed, 130 deletions(-) delete mode 100644 include/Makefile.am delete mode 100644 include/kernaux.h delete mode 100644 include/kernaux/macro.h delete mode 100644 include/kernaux/macro/packing_end.run delete mode 100644 include/kernaux/macro/packing_start.run diff --git a/README.md b/README.md index 3f8ab06..03be0f3 100644 --- a/README.md +++ b/README.md @@ -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 `` and -`` 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. - diff --git a/include/Makefile.am b/include/Makefile.am deleted file mode 100644 index a03bc06..0000000 --- a/include/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -nobase_include_HEADERS = \ - kernaux.h \ - kernaux/macro.h \ - kernaux/macro/packing_end.run \ - kernaux/macro/packing_start.run diff --git a/include/kernaux.h b/include/kernaux.h deleted file mode 100644 index 9cde769..0000000 --- a/include/kernaux.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/include/kernaux/macro.h b/include/kernaux/macro.h deleted file mode 100644 index 841d247..0000000 --- a/include/kernaux/macro.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef KERNAUX_INCLUDED_MACRO -#define KERNAUX_INCLUDED_MACRO - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/********************* - * 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 diff --git a/include/kernaux/macro/packing_end.run b/include/kernaux/macro/packing_end.run deleted file mode 100644 index 2254f00..0000000 --- a/include/kernaux/macro/packing_end.run +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef __TINYC__ -#pragma pack(pop) -#endif diff --git a/include/kernaux/macro/packing_start.run b/include/kernaux/macro/packing_start.run deleted file mode 100644 index 72752fd..0000000 --- a/include/kernaux/macro/packing_start.run +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef __TINYC__ -#pragma pack(push, 1) -#endif diff --git a/pkgs/freebsd/devel/libkernaux/pkg-plist b/pkgs/freebsd/devel/libkernaux/pkg-plist index c76544b..4851932 100644 --- a/pkgs/freebsd/devel/libkernaux/pkg-plist +++ b/pkgs/freebsd/devel/libkernaux/pkg-plist @@ -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