File kcore/kcore.md artifact 28c0315020 part of check-in 93014cedbc
kcore
kcore is the foundation for the rest of libk. it defines types and structs that are needed by every program, and provides the stub that launches a program's "entry" function.
entry
when using libk, your program's entry point will not be the int main(int,char**)
function that libc opens into. libk will call the function stat entry(kenv)
instead. like libc, the value returned by entry
will be returned to the host platform.
types
kcore contains fixed-width integer types. note that the available of each depends on your platform; compilation will fail if e.g. you try to use a u64 or a u128 on a 32-bit platform, so where exact lengths are not required, you may wish to use the built-in C types instead.
u8
- an unsigned 8-bit integers8
- a signed 8-bit integeru16
- an unsigned 16-bit integers16
- a signed 16-bit integeru32
- an unsigned 32-bit integers32
- a signed 32-bit integeru64
- an unsigned 64-bit integers64
- a signed 64-bit integeru128
- an unsigned 128-bit integers128
- a signed 128-bit integerword
- an unsigned integer of platform word-length (e.g. 32 bits on x86.32; 64 on x86.64)sword
- a signed integer of platform word-length (e.g. 32 bits on x86.32; 64 on x86.64)stat
- the type of process return values expected by the platform (usually u8 on linux)
struct kenv
kenv
is a struct that encompasses the environment the program was launched in.
* kiochan std
- a stereo IO channel for reading and writing to and from stdout.
* kiochan err
- a mono IO channel for writing to stderr.
* kvar* env
- a pointer into the program's environment
struct kvar
kvar
is a struct that abstracts over platform environment variables.
* kstr name
- the name of an environment variable
* kstr val
- the value of an environment variable
* char* platform
- a pointer into the platform's underlying representation