Main: include/kernaux/malloc.h: Added

This commit is contained in:
Alex Kotov 2022-06-17 19:06:19 +03:00
parent 6d171841b4
commit 4c0d4d192c
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
8 changed files with 40 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2022-06-17 Alex Kotov <kotovalexarian@gmail.com>
* configure.ac: Added package "malloc"
* include/kernaux/malloc.h: Added
2022-06-16 Alex Kotov <kotovalexarian@gmail.com>
libkernaux 0.4.0 released

View File

@ -51,6 +51,9 @@ endif
if WITH_LIBC
libkernaux_la_LIBADD += libc/libc.la
endif
if WITH_MALLOC
libkernaux_la_SOURCES += src/malloc.c
endif
if WITH_MBR
libkernaux_la_SOURCES += src/mbr.c
endif

View File

@ -65,6 +65,7 @@ zero). Work-in-progress APIs can change at any time.
* Utilities
* [Measurement units utils](/include/kernaux/units.h) (*work in progress*)
* [Example: To human](/examples/units_human.c)
* [Memory allocator](/include/kernaux/malloc.h) (*work in progress*)
* [Memory map](/include/kernaux/memmap.h.in) (*non-breaking since* **0.4.0**)
* [Example](/examples/memmap.c)
* [printf format parser](/include/kernaux/printf_fmt.h) (*work in progress*)
@ -148,6 +149,7 @@ explicitly included, use `--without-all`.
* `--with[out]-cmdline` - command line parser
* `--with[out]-io` - input/output
* `--with[out]-malloc` - memory allocator
* `--with[out]-memmap` - memory map
* `--with[out]-ntoa` - itoa/ftoa
* `--with[out]-printf` - printf

View File

@ -62,6 +62,7 @@ AC_ARG_WITH( [console], AS_HELP_STRING([--without-console], [without s
AC_ARG_WITH( [elf], AS_HELP_STRING([--without-elf], [without ELF utils]))
AC_ARG_WITH( [framebuffer], AS_HELP_STRING([--without-framebuffer], [without framebuffer]))
AC_ARG_WITH( [io], AS_HELP_STRING([--without-io], [without input/output]))
AC_ARG_WITH( [malloc], AS_HELP_STRING([--without-malloc], [without memory allocator]))
AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without Master Boot Record]))
AC_ARG_WITH( [memmap], AS_HELP_STRING([--without-memmap], [without memory map]))
AC_ARG_WITH( [multiboot2], AS_HELP_STRING([--without-multiboot2], [without Multiboot 2 information parser]))
@ -94,6 +95,7 @@ if test -z "$with_console"; then with_console=no; fi
if test -z "$with_elf"; then with_elf=no; fi
if test -z "$with_framebuffer"; then with_framebuffer=no; fi
if test -z "$with_io"; then with_io=no; fi
if test -z "$with_malloc"; then with_malloc=no; fi
if test -z "$with_mbr"; then with_mbr=no; fi
if test -z "$with_memmap"; then with_memmap=no; fi
if test -z "$with_multiboot2"; then with_multiboot2=no; fi
@ -130,6 +132,7 @@ AS_IF([test "$with_console" = no ], [with_console=no], [with_cons
AS_IF([test "$with_elf" = no ], [with_elf=no], [with_elf=yes])
AS_IF([test "$with_framebuffer" = no ], [with_framebuffer=no], [with_framebuffer=yes])
AS_IF([test "$with_io" = no ], [with_io=no], [with_io=yes])
AS_IF([test "$with_malloc" = no ], [with_malloc=no], [with_malloc=yes])
AS_IF([test "$with_mbr" = no ], [with_mbr=no], [with_mbr=yes])
AS_IF([test "$with_memmap" = no ], [with_memmap=no], [with_memmap=yes])
AS_IF([test "$with_multiboot2" = no ], [with_multiboot2=no], [with_multiboot2=yes])
@ -187,6 +190,7 @@ AM_CONDITIONAL([WITH_CONSOLE], [test "$with_console" = yes])
AM_CONDITIONAL([WITH_ELF], [test "$with_elf" = yes])
AM_CONDITIONAL([WITH_FRAMEBUFFER], [test "$with_framebuffer" = yes])
AM_CONDITIONAL([WITH_IO], [test "$with_io" = yes])
AM_CONDITIONAL([WITH_MALLOC], [test "$with_malloc" = yes])
AM_CONDITIONAL([WITH_MBR], [test "$with_mbr" = yes])
AM_CONDITIONAL([WITH_MEMMAP], [test "$with_memmap" = yes])
AM_CONDITIONAL([WITH_MULTIBOOT2], [test "$with_multiboot2" = yes])
@ -227,6 +231,7 @@ AS_IF([test "$with_console" = yes], [AC_DEFINE([WITH_CONSOLE], [1]
AS_IF([test "$with_elf" = yes], [AC_DEFINE([WITH_ELF], [1], [with ELF utils])])
AS_IF([test "$with_framebuffer" = yes], [AC_DEFINE([WITH_FRAMEBUFFER], [1], [with framebuffer])])
AS_IF([test "$with_io" = yes], [AC_DEFINE([WITH_IO], [1], [with input/output])])
AS_IF([test "$with_malloc" = yes], [AC_DEFINE([WITH_MALLOC], [1], [with memory allocator])])
AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with Master Boot Record])])
AS_IF([test "$with_memmap" = yes], [AC_DEFINE([WITH_MEMMAP], [1], [with memory map])])
AS_IF([test "$with_multiboot2" = yes], [AC_DEFINE([WITH_MULTIBOOT2], [1], [with Multiboot 2 information parser])])
@ -254,6 +259,7 @@ AS_IF([test "$with_console" = no], [AC_SUBST([comment_line_console], [//
AS_IF([test "$with_elf" = no], [AC_SUBST([comment_line_elf], [//])])
AS_IF([test "$with_framebuffer" = no], [AC_SUBST([comment_line_framebuffer], [//])])
AS_IF([test "$with_io" = no], [AC_SUBST([comment_line_io], [//])])
AS_IF([test "$with_malloc" = no], [AC_SUBST([comment_line_malloc], [//])])
AS_IF([test "$with_mbr" = no], [AC_SUBST([comment_line_mbr], [//])])
AS_IF([test "$with_memmap" = no], [AC_SUBST([comment_line_memmap], [//])])
AS_IF([test "$with_multiboot2" = no], [AC_SUBST([comment_line_multiboot2], [//])])

View File

@ -31,6 +31,9 @@ endif
if WITH_IO
nobase_include_HEADERS += kernaux/io.h
endif
if WITH_MALLOC
nobase_include_HEADERS += kernaux/malloc.h
endif
if WITH_MBR
nobase_include_HEADERS += kernaux/mbr.h
endif

View File

@ -11,6 +11,7 @@
@comment_line_elf@#include <kernaux/elf.h>
@comment_line_framebuffer@#include <kernaux/framebuffer.h>
@comment_line_io@#include <kernaux/io.h>
@comment_line_malloc@#include <kernaux/malloc.h>
@comment_line_mbr@#include <kernaux/mbr.h>
@comment_line_memmap@#include <kernaux/memmap.h>
@comment_line_multiboot2@#include <kernaux/multiboot2.h>

12
include/kernaux/malloc.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef KERNAUX_INCLUDED_MALLOC
#define KERNAUX_INCLUDED_MALLOC
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

8
src/malloc.c Normal file
View File

@ -0,0 +1,8 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <kernaux/malloc.h>
__attribute__((unused))
static const int foobar = 1;