mirror of
https://github.com/tailix/libkernaux.git
synced 2025-03-17 17:14:00 -04:00
Header macro for private struct attributes (#72)
This commit is contained in:
parent
ff436031f5
commit
2de2bd9679
10 changed files with 44 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
|||
2022-06-20 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
* include/kernaux/alloc.h: Finished, made stable
|
||||
|
||||
2022-06-18 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
* include/kernaux/mutex.h: Added
|
||||
|
|
|
@ -19,6 +19,8 @@ endif
|
|||
libc/libc.la:
|
||||
$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/libc libc.la
|
||||
|
||||
AM_CFLAGS += -DKERNAUX_PRIVATE_NO
|
||||
|
||||
lib_LTLIBRARIES = libkernaux.la
|
||||
|
||||
libkernaux_la_SOURCES = src/libc.h src/assert.c src/mutex.c
|
||||
|
|
|
@ -54,7 +54,7 @@ zero). Work-in-progress APIs can change at any time.
|
|||
* [Framebuffer](/include/kernaux/framebuffer.h) (*planned*)
|
||||
* USB (*planned*)
|
||||
* Algorithms
|
||||
* [Memory allocator](/include/kernaux/alloc.h) (*work in progress*)
|
||||
* [Memory allocator](/include/kernaux/alloc.h) (*non-breaking since* **?.?.?**)
|
||||
* [Simple command line parser](/include/kernaux/cmdline.h) (*non-breaking since* **0.2.0**)
|
||||
* [Example](/examples/cmdline.c)
|
||||
* [Page Frame Allocator](/include/kernaux/pfa.h) (*work in progress*)
|
||||
|
|
|
@ -4,6 +4,7 @@ nobase_include_HEADERS = \
|
|||
kernaux/arch/riscv64.h \
|
||||
kernaux/arch/x86_64.h \
|
||||
kernaux/assert.h \
|
||||
kernaux/macro.h \
|
||||
kernaux/mutex.h \
|
||||
kernaux/version.h
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
#include <kernaux/assert.h>
|
||||
#include <kernaux/macro.h>
|
||||
#include <kernaux/mutex.h>
|
||||
#include <kernaux/version.h>
|
||||
|
||||
|
|
|
@ -5,19 +5,21 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/macro.h>
|
||||
#include <kernaux/mutex.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct KernAux_Alloc_Node {
|
||||
struct KernAux_Alloc_Node *next, *prev;
|
||||
size_t size;
|
||||
char *block;
|
||||
struct KernAux_Alloc_Node *KERNAUX_PRIVATE_FIELD(next);
|
||||
struct KernAux_Alloc_Node *KERNAUX_PRIVATE_FIELD(prev);
|
||||
size_t KERNAUX_PRIVATE_FIELD(size);
|
||||
char *KERNAUX_PRIVATE_FIELD(block);
|
||||
} *KernAux_Alloc_Node;
|
||||
|
||||
typedef struct KernAux_Alloc {
|
||||
KernAux_Mutex mutex;
|
||||
KernAux_Alloc_Node head;
|
||||
KernAux_Mutex KERNAUX_PRIVATE_FIELD(mutex);
|
||||
KernAux_Alloc_Node KERNAUX_PRIVATE_FIELD(head);
|
||||
} *KernAux_Alloc;
|
||||
|
||||
struct KernAux_Alloc KernAux_Alloc_create(KernAux_Mutex mutex);
|
||||
|
|
18
include/kernaux/macro.h
Normal file
18
include/kernaux/macro.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef KERNAUX_INCLUDED_MACRO
|
||||
#define KERNAUX_INCLUDED_MACRO
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef KERNAUX_PRIVATE_NO
|
||||
#define KERNAUX_PRIVATE_FIELD(id) id
|
||||
#else
|
||||
#define KERNAUX_PRIVATE_FIELD(id) _private_##id
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -5,6 +5,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <kernaux/macro.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
@ -20,10 +22,10 @@ typedef const struct KernAux_MemMap_Entry {
|
|||
} *KernAux_MemMap_Entry;
|
||||
|
||||
typedef struct KernAux_MemMap {
|
||||
bool is_finished;
|
||||
size_t memory_size;
|
||||
size_t entries_count;
|
||||
struct KernAux_MemMap_Entry entries[KERNAUX_MEMMAP_ENTRIES_MAX];
|
||||
bool KERNAUX_PRIVATE_FIELD(is_finished);
|
||||
size_t KERNAUX_PRIVATE_FIELD(memory_size);
|
||||
size_t KERNAUX_PRIVATE_FIELD(entries_count);
|
||||
struct KernAux_MemMap_Entry KERNAUX_PRIVATE_FIELD(entries)[KERNAUX_MEMMAP_ENTRIES_MAX];
|
||||
} KernAux_MemMap[1];
|
||||
|
||||
struct KernAux_MemMap KernAux_MemMap_create(size_t memory_size);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define KERNAUX_PRIVATE_NO
|
||||
|
||||
#include "helper.h"
|
||||
|
||||
#include <kernaux/alloc.h>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define KERNAUX_PRIVATE_NO
|
||||
|
||||
#include <kernaux/assert.h>
|
||||
#include <kernaux/memmap.h>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue