1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-10-30 11:54:01 -04:00

Do not use "-nostdinc" option

This commit is contained in:
Alex Kotov 2020-12-06 15:16:15 +05:00
parent e3afde92f9
commit 115b6f28c4
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
13 changed files with 104 additions and 111 deletions

View file

@ -28,8 +28,6 @@ API
* ELF utils *(planned)*
* [Architecture-specific helpers](/include/kernaux/arch/)
* [stdlib replacement](/include/kernaux/stdlib.h) (with prefix):
* `NULL`
* `bool`, `FALSE`, `TRUE`
* `memset`
* `strlen`
* `strncpy`
@ -50,7 +48,7 @@ Configure with cross-compiler in `$PATH` to make without it in `$PATH`:
AR="$(which x86-elf-ar)" \
CC="$(which x86-elf-gcc)" \
RANLIB="$(which x86-elf-ranlib)" \
CFLAGS='-ffreestanding -nostdinc -nostdlib -fno-builtin -fno-stack-protector'
CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector'
```
To install into specific directory use full path:

View file

@ -1,7 +1,7 @@
#ifndef KERNAUX_INCLUDED_CMDLINE
#define KERNAUX_INCLUDED_CMDLINE 1
#include <kernaux/stdlib.h>
#include <stdbool.h>
#define KERNAUX_CMDLINE_ERROR_MSG_SIZE_MAX 256
#define KERNAUX_CMDLINE_ERROR_MSG_SLEN_MAX \
@ -11,7 +11,7 @@
extern "C" {
#endif
kernaux_bool kernaux_cmdline_parse(
bool kernaux_cmdline_parse(
const char *cmdline,
char *error_msg,
unsigned int *argc,

View file

@ -1,7 +1,7 @@
#ifndef KERNAUX_INCLUDED_MULTIBOOT2
#define KERNAUX_INCLUDED_MULTIBOOT2 1
#include <kernaux/stdlib.h>
#include <stdbool.h>
#define KERNAUX_MULTIBOOT2_MAGIC 0x36d76289
@ -348,122 +348,122 @@ __attribute__((nonnull));
* Validation functions *
************************/
kernaux_bool KernAux_Multiboot2_is_valid(
bool KernAux_Multiboot2_is_valid(
const struct KernAux_Multiboot2 *multiboot2
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_TagBase_is_valid(
bool KernAux_Multiboot2_TagBase_is_valid(
const struct KernAux_Multiboot2_TagBase *tag_base
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_None_is_valid(
bool KernAux_Multiboot2_Tag_None_is_valid(
const struct KernAux_Multiboot2_Tag_None *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_BootCmdLine_is_valid(
bool KernAux_Multiboot2_Tag_BootCmdLine_is_valid(
const struct KernAux_Multiboot2_Tag_BootCmdLine *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_BootLoaderName_is_valid(
bool KernAux_Multiboot2_Tag_BootLoaderName_is_valid(
const struct KernAux_Multiboot2_Tag_BootLoaderName *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_Module_is_valid(
bool KernAux_Multiboot2_Tag_Module_is_valid(
const struct KernAux_Multiboot2_Tag_Module *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_BasicMemoryInfo_is_valid(
bool KernAux_Multiboot2_Tag_BasicMemoryInfo_is_valid(
const struct KernAux_Multiboot2_Tag_BasicMemoryInfo *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_BIOSBootDevice_is_valid(
bool KernAux_Multiboot2_Tag_BIOSBootDevice_is_valid(
const struct KernAux_Multiboot2_Tag_BIOSBootDevice *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_MemoryMap_is_valid(
bool KernAux_Multiboot2_Tag_MemoryMap_is_valid(
const struct KernAux_Multiboot2_Tag_MemoryMap *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_VBEInfo_is_valid(
bool KernAux_Multiboot2_Tag_VBEInfo_is_valid(
const struct KernAux_Multiboot2_Tag_VBEInfo *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_FramebufferInfo_is_valid(
bool KernAux_Multiboot2_Tag_FramebufferInfo_is_valid(
const struct KernAux_Multiboot2_Tag_FramebufferInfo *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_ELFSymbols_is_valid(
bool KernAux_Multiboot2_Tag_ELFSymbols_is_valid(
const struct KernAux_Multiboot2_Tag_ELFSymbols *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_APMTable_is_valid(
bool KernAux_Multiboot2_Tag_APMTable_is_valid(
const struct KernAux_Multiboot2_Tag_APMTable *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_EFI32bitSystemTablePtr_is_valid(
bool KernAux_Multiboot2_Tag_EFI32bitSystemTablePtr_is_valid(
const struct KernAux_Multiboot2_Tag_EFI32bitSystemTablePtr *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_EFI64bitSystemTablePtr_is_valid(
bool KernAux_Multiboot2_Tag_EFI64bitSystemTablePtr_is_valid(
const struct KernAux_Multiboot2_Tag_EFI64bitSystemTablePtr *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_SMBIOSTables_is_valid(
bool KernAux_Multiboot2_Tag_SMBIOSTables_is_valid(
const struct KernAux_Multiboot2_Tag_SMBIOSTables *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_ACPIOldRSDP_is_valid(
bool KernAux_Multiboot2_Tag_ACPIOldRSDP_is_valid(
const struct KernAux_Multiboot2_Tag_ACPIOldRSDP *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_ACPINewRSDP_is_valid(
bool KernAux_Multiboot2_Tag_ACPINewRSDP_is_valid(
const struct KernAux_Multiboot2_Tag_ACPINewRSDP *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_NetworkingInfo_is_valid(
bool KernAux_Multiboot2_Tag_NetworkingInfo_is_valid(
const struct KernAux_Multiboot2_Tag_NetworkingInfo *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_EFIMemoryMap_is_valid(
bool KernAux_Multiboot2_Tag_EFIMemoryMap_is_valid(
const struct KernAux_Multiboot2_Tag_EFIMemoryMap *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_EFIBootServicesNotTerminated_is_valid(
bool KernAux_Multiboot2_Tag_EFIBootServicesNotTerminated_is_valid(
const struct KernAux_Multiboot2_Tag_EFIBootServicesNotTerminated *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_EFI32bitImageHandlePtr_is_valid(
bool KernAux_Multiboot2_Tag_EFI32bitImageHandlePtr_is_valid(
const struct KernAux_Multiboot2_Tag_EFI32bitImageHandlePtr *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_EFI64bitImageHandlePtr_is_valid(
bool KernAux_Multiboot2_Tag_EFI64bitImageHandlePtr_is_valid(
const struct KernAux_Multiboot2_Tag_EFI64bitImageHandlePtr *tag
)
__attribute__((nonnull));
kernaux_bool KernAux_Multiboot2_Tag_ImageLoadBasePhysAddr_is_valid(
bool KernAux_Multiboot2_Tag_ImageLoadBasePhysAddr_is_valid(
const struct KernAux_Multiboot2_Tag_ImageLoadBasePhysAddr *tag
)
__attribute__((nonnull));

View file

@ -1,7 +1,7 @@
#ifndef KERNAUX_INCLUDED_PFA
#define KERNAUX_INCLUDED_PFA 1
#include <kernaux/stdlib.h>
#include <stdbool.h>
#define KERNAUX_PFA_PAGE_SIZE (4 * 1024)
#define KERNAUX_PFA_PAGES_COUNT_MAX (1024 * 1024)
@ -11,7 +11,7 @@ extern "C" {
#endif
struct KernAux_PFA {
kernaux_bool pages[KERNAUX_PFA_PAGES_COUNT_MAX];
bool pages[KERNAUX_PFA_PAGES_COUNT_MAX];
};
void KernAux_PFA_initialize(struct KernAux_PFA *pfa)

View file

@ -1,17 +1,10 @@
#ifndef KERNAUX_INCLUDED_STDLIB
#define KERNAUX_INCLUDED_STDLIB 1
#define KERNAUX_NULL ((void*)0)
#define KERNAUX_FALSE ((kernaux_bool)0)
#define KERNAUX_TRUE ((kernaux_bool)1)
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned char kernaux_bool;
void kernaux_memset(
void *buffer,
unsigned char value,

View file

@ -1,6 +1,9 @@
#include "config.h"
#include <kernaux/cmdline.h>
#include <kernaux/stdlib.h>
#include <stddef.h>
enum State {
INITIAL,
@ -10,7 +13,7 @@ enum State {
BACKSLASHED,
};
kernaux_bool kernaux_cmdline_parse(
bool kernaux_cmdline_parse(
const char *const cmdline,
char *error_msg,
unsigned int *const argc,
@ -20,27 +23,27 @@ kernaux_bool kernaux_cmdline_parse(
const unsigned int arg_size_max
) {
if (
cmdline == KERNAUX_NULL ||
error_msg == KERNAUX_NULL ||
argc == KERNAUX_NULL ||
argv == KERNAUX_NULL ||
cmdline == NULL ||
error_msg == NULL ||
argc == NULL ||
argv == NULL ||
argv_count_max == 0 ||
arg_size_max == 0
) {
return KERNAUX_FALSE;
return false;
}
kernaux_memset(error_msg, '\0', KERNAUX_CMDLINE_ERROR_MSG_SIZE_MAX);
*argc = 0;
for (unsigned int index = 0; index < argv_count_max; ++index) {
argv[index] = KERNAUX_NULL;
argv[index] = NULL;
}
kernaux_memset(buffer, '\0', argv_count_max * arg_size_max);
if (cmdline[0] == '\0') {
return KERNAUX_TRUE;
return true;
}
enum State state = INITIAL;
@ -179,16 +182,16 @@ kernaux_bool kernaux_cmdline_parse(
}
}
return KERNAUX_TRUE;
return true;
fail:
*argc = 0;
for (unsigned int index = 0; index < argv_count_max; ++index) {
argv[index] = KERNAUX_NULL;
argv[index] = NULL;
}
kernaux_memset(buffer, '\0', argv_count_max * arg_size_max);
return KERNAUX_FALSE;
return false;
}

View file

@ -2,6 +2,8 @@
#include <kernaux/multiboot2.h>
#include <stddef.h>
const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_first_tag_with_type(
const struct KernAux_Multiboot2 *const multiboot2,
const enum KernAux_Multiboot2_TagType tag_type
@ -11,7 +13,7 @@ const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_first_tag_with_type(
while ((void*)tag_base < (void*)multiboot2 + multiboot2->total_size) {
if (!KernAux_Multiboot2_TagBase_is_valid(tag_base)) {
return KERNAUX_NULL;
return NULL;
}
if (tag_base->type == tag_type) {
@ -23,7 +25,7 @@ const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_first_tag_with_type(
);
}
return KERNAUX_NULL;
return NULL;
}
const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_tag_with_type_after(
@ -36,7 +38,7 @@ const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_tag_with_type_after(
while ((void*)tag_base < (void*)multiboot2 + multiboot2->total_size) {
if (!KernAux_Multiboot2_TagBase_is_valid(tag_base)) {
return KERNAUX_NULL;
return NULL;
}
if (tag_base->type == tag_type && tag_base > after_tag) {
@ -48,7 +50,7 @@ const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_tag_with_type_after(
);
}
return KERNAUX_NULL;
return NULL;
}
const char *KernAux_Multiboot2_boot_cmd_line(
@ -62,7 +64,7 @@ const char *KernAux_Multiboot2_boot_cmd_line(
);
if (!tag) {
return KERNAUX_NULL;
return NULL;
}
return tag->cmdline;

View file

@ -2,25 +2,27 @@
#include <kernaux/multiboot2.h>
kernaux_bool KernAux_Multiboot2_is_valid(
#include <stddef.h>
bool KernAux_Multiboot2_is_valid(
const struct KernAux_Multiboot2 *const multiboot2
) {
if (multiboot2->total_size <= 8) {
return KERNAUX_FALSE;
return false;
}
const struct KernAux_Multiboot2_TagBase *tag_base =
(struct KernAux_Multiboot2_TagBase*)multiboot2->data;
const struct KernAux_Multiboot2_TagBase *none_tag_base = KERNAUX_NULL;
const struct KernAux_Multiboot2_TagBase *none_tag_base = NULL;
while ((void*)tag_base < (void*)multiboot2 + multiboot2->total_size) {
if (!KernAux_Multiboot2_TagBase_is_valid(tag_base)) {
return KERNAUX_FALSE;
return false;
}
if (tag_base->type == KERNAUX_MULTIBOOT2_TAGTYPE_NONE &&
none_tag_base == KERNAUX_NULL
none_tag_base == NULL
) {
none_tag_base = tag_base;
}
@ -31,19 +33,19 @@ kernaux_bool KernAux_Multiboot2_is_valid(
}
if ((void*)tag_base != (void*)multiboot2 + multiboot2->total_size) {
return KERNAUX_FALSE;
return false;
}
if (none_tag_base !=
(void*)tag_base - sizeof(struct KernAux_Multiboot2_Tag_None)
) {
return KERNAUX_FALSE;
return false;
}
return KERNAUX_TRUE;
return true;
}
kernaux_bool KernAux_Multiboot2_TagBase_is_valid(
bool KernAux_Multiboot2_TagBase_is_valid(
const struct KernAux_Multiboot2_TagBase *const tag_base
) {
switch (tag_base->type) {
@ -136,11 +138,11 @@ kernaux_bool KernAux_Multiboot2_TagBase_is_valid(
(struct KernAux_Multiboot2_Tag_ImageLoadBasePhysAddr*)tag_base
);
default:
return KERNAUX_FALSE;
return false;
}
}
kernaux_bool KernAux_Multiboot2_Tag_None_is_valid(
bool KernAux_Multiboot2_Tag_None_is_valid(
const struct KernAux_Multiboot2_Tag_None *const tag
) {
return (
@ -149,7 +151,7 @@ kernaux_bool KernAux_Multiboot2_Tag_None_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_BootCmdLine_is_valid(
bool KernAux_Multiboot2_Tag_BootCmdLine_is_valid(
const struct KernAux_Multiboot2_Tag_BootCmdLine *const tag
) {
unsigned int index = 1;
@ -168,7 +170,7 @@ kernaux_bool KernAux_Multiboot2_Tag_BootCmdLine_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_BootLoaderName_is_valid(
bool KernAux_Multiboot2_Tag_BootLoaderName_is_valid(
const struct KernAux_Multiboot2_Tag_BootLoaderName *const tag
) {
unsigned int index = 1;
@ -187,7 +189,7 @@ kernaux_bool KernAux_Multiboot2_Tag_BootLoaderName_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_Module_is_valid(
bool KernAux_Multiboot2_Tag_Module_is_valid(
const struct KernAux_Multiboot2_Tag_Module *const tag
) {
unsigned int index = 1;
@ -207,7 +209,7 @@ kernaux_bool KernAux_Multiboot2_Tag_Module_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_BasicMemoryInfo_is_valid(
bool KernAux_Multiboot2_Tag_BasicMemoryInfo_is_valid(
const struct KernAux_Multiboot2_Tag_BasicMemoryInfo *const tag
) {
return (
@ -216,7 +218,7 @@ kernaux_bool KernAux_Multiboot2_Tag_BasicMemoryInfo_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_BIOSBootDevice_is_valid(
bool KernAux_Multiboot2_Tag_BIOSBootDevice_is_valid(
const struct KernAux_Multiboot2_Tag_BIOSBootDevice *const tag
) {
return (
@ -225,7 +227,7 @@ kernaux_bool KernAux_Multiboot2_Tag_BIOSBootDevice_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_MemoryMap_is_valid(
bool KernAux_Multiboot2_Tag_MemoryMap_is_valid(
const struct KernAux_Multiboot2_Tag_MemoryMap *const tag
) {
return (
@ -237,7 +239,7 @@ kernaux_bool KernAux_Multiboot2_Tag_MemoryMap_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_VBEInfo_is_valid(
bool KernAux_Multiboot2_Tag_VBEInfo_is_valid(
const struct KernAux_Multiboot2_Tag_VBEInfo *const tag
) {
return (
@ -246,7 +248,7 @@ kernaux_bool KernAux_Multiboot2_Tag_VBEInfo_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_FramebufferInfo_is_valid(
bool KernAux_Multiboot2_Tag_FramebufferInfo_is_valid(
const struct KernAux_Multiboot2_Tag_FramebufferInfo *const tag
) {
return (
@ -255,7 +257,7 @@ kernaux_bool KernAux_Multiboot2_Tag_FramebufferInfo_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_ELFSymbols_is_valid(
bool KernAux_Multiboot2_Tag_ELFSymbols_is_valid(
const struct KernAux_Multiboot2_Tag_ELFSymbols *const tag
) {
return (
@ -266,7 +268,7 @@ kernaux_bool KernAux_Multiboot2_Tag_ELFSymbols_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_APMTable_is_valid(
bool KernAux_Multiboot2_Tag_APMTable_is_valid(
const struct KernAux_Multiboot2_Tag_APMTable *const tag
) {
return (
@ -275,7 +277,7 @@ kernaux_bool KernAux_Multiboot2_Tag_APMTable_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_EFI32bitSystemTablePtr_is_valid(
bool KernAux_Multiboot2_Tag_EFI32bitSystemTablePtr_is_valid(
const struct KernAux_Multiboot2_Tag_EFI32bitSystemTablePtr *const tag
) {
return (
@ -285,7 +287,7 @@ kernaux_bool KernAux_Multiboot2_Tag_EFI32bitSystemTablePtr_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_EFI64bitSystemTablePtr_is_valid(
bool KernAux_Multiboot2_Tag_EFI64bitSystemTablePtr_is_valid(
const struct KernAux_Multiboot2_Tag_EFI64bitSystemTablePtr *const tag
) {
return (
@ -295,7 +297,7 @@ kernaux_bool KernAux_Multiboot2_Tag_EFI64bitSystemTablePtr_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_SMBIOSTables_is_valid(
bool KernAux_Multiboot2_Tag_SMBIOSTables_is_valid(
const struct KernAux_Multiboot2_Tag_SMBIOSTables *const tag
) {
return (
@ -304,7 +306,7 @@ kernaux_bool KernAux_Multiboot2_Tag_SMBIOSTables_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_ACPIOldRSDP_is_valid(
bool KernAux_Multiboot2_Tag_ACPIOldRSDP_is_valid(
const struct KernAux_Multiboot2_Tag_ACPIOldRSDP *const tag
) {
return (
@ -313,7 +315,7 @@ kernaux_bool KernAux_Multiboot2_Tag_ACPIOldRSDP_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_ACPINewRSDP_is_valid(
bool KernAux_Multiboot2_Tag_ACPINewRSDP_is_valid(
const struct KernAux_Multiboot2_Tag_ACPINewRSDP *const tag
) {
return (
@ -322,7 +324,7 @@ kernaux_bool KernAux_Multiboot2_Tag_ACPINewRSDP_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_NetworkingInfo_is_valid(
bool KernAux_Multiboot2_Tag_NetworkingInfo_is_valid(
const struct KernAux_Multiboot2_Tag_NetworkingInfo *const tag
) {
return (
@ -331,7 +333,7 @@ kernaux_bool KernAux_Multiboot2_Tag_NetworkingInfo_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_EFIMemoryMap_is_valid(
bool KernAux_Multiboot2_Tag_EFIMemoryMap_is_valid(
const struct KernAux_Multiboot2_Tag_EFIMemoryMap *const tag
) {
return (
@ -340,7 +342,7 @@ kernaux_bool KernAux_Multiboot2_Tag_EFIMemoryMap_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_EFIBootServicesNotTerminated_is_valid(
bool KernAux_Multiboot2_Tag_EFIBootServicesNotTerminated_is_valid(
const struct KernAux_Multiboot2_Tag_EFIBootServicesNotTerminated *const tag
) {
return (
@ -350,7 +352,7 @@ kernaux_bool KernAux_Multiboot2_Tag_EFIBootServicesNotTerminated_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_EFI32bitImageHandlePtr_is_valid(
bool KernAux_Multiboot2_Tag_EFI32bitImageHandlePtr_is_valid(
const struct KernAux_Multiboot2_Tag_EFI32bitImageHandlePtr *const tag
) {
return (
@ -360,7 +362,7 @@ kernaux_bool KernAux_Multiboot2_Tag_EFI32bitImageHandlePtr_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_EFI64bitImageHandlePtr_is_valid(
bool KernAux_Multiboot2_Tag_EFI64bitImageHandlePtr_is_valid(
const struct KernAux_Multiboot2_Tag_EFI64bitImageHandlePtr *const tag
) {
return (
@ -370,7 +372,7 @@ kernaux_bool KernAux_Multiboot2_Tag_EFI64bitImageHandlePtr_is_valid(
);
}
kernaux_bool KernAux_Multiboot2_Tag_ImageLoadBasePhysAddr_is_valid(
bool KernAux_Multiboot2_Tag_ImageLoadBasePhysAddr_is_valid(
const struct KernAux_Multiboot2_Tag_ImageLoadBasePhysAddr *const tag
) {
return (

View file

@ -2,6 +2,8 @@
#include <kernaux/multiboot2.h>
#include <stddef.h>
static const char *KernAux_Multiboot2_TagType_to_str(
enum KernAux_Multiboot2_TagType tag_type
);
@ -67,7 +69,7 @@ const char *KernAux_Multiboot2_TagType_to_str(
case KERNAUX_MULTIBOOT2_TAGTYPE_IMAGE_LOAD_BASE_PHYS_ADDR:
return "image load base phys addr";
default:
return KERNAUX_NULL;
return NULL;
}
}

View file

@ -5,7 +5,7 @@
static void KernAux_PFA_mark(
struct KernAux_PFA *pfa,
kernaux_bool status,
bool status,
unsigned int start,
unsigned int end
)
@ -13,7 +13,7 @@ __attribute__((nonnull));
void KernAux_PFA_initialize(struct KernAux_PFA *const pfa)
{
kernaux_memset(pfa->pages, KERNAUX_FALSE, sizeof(pfa->pages));
kernaux_memset(pfa->pages, false, sizeof(pfa->pages));
}
void KernAux_PFA_mark_available(
@ -21,7 +21,7 @@ void KernAux_PFA_mark_available(
unsigned int start,
unsigned int end
) {
KernAux_PFA_mark(pfa, KERNAUX_TRUE, start, end);
KernAux_PFA_mark(pfa, true, start, end);
}
void KernAux_PFA_mark_unavailable(
@ -29,12 +29,12 @@ void KernAux_PFA_mark_unavailable(
unsigned int start,
unsigned int end
) {
KernAux_PFA_mark(pfa, KERNAUX_FALSE, start, end);
KernAux_PFA_mark(pfa, false, start, end);
}
void KernAux_PFA_mark(
struct KernAux_PFA *const pfa,
const kernaux_bool status,
const bool status,
unsigned int start,
unsigned int end
) {
@ -68,7 +68,7 @@ unsigned int KernAux_PFA_alloc_page(struct KernAux_PFA *pfa)
//
for (unsigned int index = 1; index < KERNAUX_PFA_PAGES_COUNT_MAX; ++index) {
if (pfa->pages[index]) {
pfa->pages[index] = KERNAUX_FALSE;
pfa->pages[index] = false;
return index * KERNAUX_PFA_PAGE_SIZE;
}
}
@ -82,5 +82,5 @@ void KernAux_PFA_free_page(struct KernAux_PFA *pfa, unsigned int page_addr)
return;
}
pfa->pages[page_addr / KERNAUX_PFA_PAGE_SIZE] = KERNAUX_TRUE;
pfa->pages[page_addr / KERNAUX_PFA_PAGE_SIZE] = true;
}

View file

@ -2,6 +2,7 @@
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
static const unsigned int ARGV_COUNT_MAX = 100;
@ -186,6 +187,6 @@ void test(
}
for (unsigned int index = argc; index < argv_count_max; ++index) {
assert(argv[index] == KERNAUX_NULL);
assert(argv[index] == NULL);
}
}

View file

@ -9,7 +9,7 @@ int main()
KernAux_PFA_initialize(&pfa);
for (unsigned int index = 0; index < KERNAUX_PFA_PAGES_COUNT_MAX; ++index) {
assert(pfa.pages[index] == KERNAUX_FALSE);
assert(pfa.pages[index] == false);
}
KernAux_PFA_mark_available(&pfa, 0, 654335);
@ -17,23 +17,23 @@ int main()
KernAux_PFA_mark_unavailable(&pfa, 4194304, 6291455); // [4 MB, 6 MB)
for (unsigned int index = 0; index < 159; ++index) {
assert(pfa.pages[index] == KERNAUX_TRUE);
assert(pfa.pages[index] == true);
}
for (unsigned int index = 159; index < 256; ++index) {
assert(pfa.pages[index] == KERNAUX_FALSE);
assert(pfa.pages[index] == false);
}
for (unsigned int index = 256; index < 1024; ++index) { // [1 MB, 4 MB)
assert(pfa.pages[index] == KERNAUX_TRUE);
assert(pfa.pages[index] == true);
}
for (unsigned int index = 1024; index < 1536; ++index) { // [4 MB, 6 MB)
assert(pfa.pages[index] == KERNAUX_FALSE);
assert(pfa.pages[index] == false);
}
for (unsigned int index = 1536; index < 32736; ++index) { // [6 MB, ~127 MB)
assert(pfa.pages[index] == KERNAUX_TRUE);
assert(pfa.pages[index] == true);
}
for (
@ -41,7 +41,7 @@ int main()
index < KERNAUX_PFA_PAGES_COUNT_MAX;
++index
) {
assert(pfa.pages[index] == KERNAUX_FALSE);
assert(pfa.pages[index] == false);
}
unsigned int page_addr = KernAux_PFA_alloc_page(&pfa);

View file

@ -1,17 +1,9 @@
#include <kernaux/stdlib.h>
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
int main()
{
assert(sizeof(kernaux_bool) == sizeof(bool));
assert(KERNAUX_NULL == NULL);
assert(KERNAUX_FALSE == false);
assert(KERNAUX_TRUE == true);
// kernaux_memset
{