Abou Meaty Skeleton

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
AwfulMint
Member
Member
Posts: 35
Joined: Wed Nov 01, 2017 7:41 pm

Abou Meaty Skeleton

Post by AwfulMint »

So I compiled mah first kernel with success! But when reading http://wiki.osdev.org/Meaty_Skeleton#libc_and_libk and http://wiki.osdev.org/Hosted_GCC_Cross-Compiler I found a mistake.

in the first link we can see in libc's string.h:

Code: Select all

#ifndef _STRING_H
#define _STRING_H 1
 
#include <sys/cdefs.h>
 
#include <stddef.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
int memcmp(const void*, const void*, size_t);
void* memcpy(void* __restrict, const void* __restrict, size_t);
void* memmove(void*, const void*, size_t);
void* memset(void*, int, size_t);
size_t strlen(const char*);
 
#ifdef __cplusplus
}
#endif
 
#endif
My question is about the include #include <sys/cdefs.h> where in the code I need to create this? Or this is provided by the compiler? Because in the Hosted GCC Cross-Compiler we can read:
To correctly complete this tutorial, your libc must need particular minimum requirements. The libgcc will be built with libc support, meaning that your libc needs a few standard headers that define particular types, constants and functions. In particular, you need to supply:
sys/types.h: This header is just required to exist and can be empty.
errno.h: This header is just required to exist and can be empty.
stdlib.h: abort(), free(), malloc().
stdio.h: FILE, stderr, fflush(), fprintf().
string.h: size_t, memcpy, memset(), strlen().
time.h: This header is just required to exist and can be empty.
unistd.h: This header is just required to exist and can be empty.
Additionally, the all-target-libgcc target also unconditionally builds the libgcov support library, which has these additional requirements:
sys/types.h: pid_t.
stdlib.h: atexit(), atoi(), getenv().
stdio.h: size_t, SEEK_SET, fclose(), fopen(), fread(), fseek(), ftell(), fwrite(), setbuf(), vfprintf().
string.h: strcpy().
unistd.h: pid_t, fork(), execv(), execve(), execvp().
So, these imports are provided by the compiler or I have to write all of them? If I need to write all of them, how? Thanks in Advice ;)
OS Development is awesome!

|AetherOS Project|
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: Abou Meaty Skeleton

Post by FallenAvatar »

Wiki wrote:The standard headers use a BSD-like scheme where sys/cdefs.h declares a bunch of useful preprocessor macros meant for internal use by the standard library.
http://wiki.osdev.org/Meaty_Skeleton#li ... ibk_Design

- Amy
Post Reply