libk  Artifact [d664110812]

Artifact d664110812760e51b828d47c8d32104921054828f994a80fe1dff4542bdbd972:


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 (in <k/type.h>). note that the availability 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 integer
  • s8 - a signed 8-bit integer
  • u16 - an unsigned 16-bit integer
  • s16 - a signed 16-bit integer
  • u32 - an unsigned 32-bit integer
  • s32 - a signed 32-bit integer
  • u64 - an unsigned 64-bit integer
  • s64 - a signed 64-bit integer
  • u128 - an unsigned 128-bit integer
  • s128 - a signed 128-bit integer
  • word - 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* vars - 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