MonkOS  v0.1
A simple 64-bit operating system (x86_64)
core.h File Reference

Core include file. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdatomic.h>

Go to the source code of this file.

Macros

#define __forceinline   inline __attribute__((always_inline))
 Force a function to be inline, even in debug mode. More...
 
#define arrsize(x)   ((int)(sizeof(x) / sizeof(x[0])))
 Return the number of elements in the C array. More...
 
#define min(a, b)   ((a) < (b) ? (a) : (b))
 Generic min/max routines. More...
 
#define max(a, b)   ((a) > (b) ? (a) : (b))
 
#define div_dn(a, b)   ((a) / (b))
 
#define div_up(a, b)   (((a) + (b) - 1) / (b))
 
#define align_dn(a, b)   (div_dn(a, b) * (b))
 
#define align_up(a, b)   (div_up(a, b) * (b))
 
#define ptr_add(t, p, o)   ((t *)((uint8_t *)(p) + (o)))
 
#define ptr_sub(t, p, o)   ((t *)((uint8_t *)(p) - (o)))
 
#define STATIC_ASSERT(a, b)   _Static_assert(a, b)
 Compile-time static assertion. More...
 
#define PACKSTRUCT   __attribute__((packed, aligned(1)))
 Forced structure packing (use only when absolutely necessary) More...
 

Detailed Description

Core include file.

Definition in file core.h.

Macro Definition Documentation

#define __forceinline   inline __attribute__((always_inline))

Force a function to be inline, even in debug mode.

Definition at line 23 of file core.h.

Referenced by cpuid(), disable_interrupts(), enable_interrupts(), halt(), invalid_opcode(), invalidate_page(), io_inb(), io_ind(), io_inw(), io_outb(), io_outd(), io_outw(), rdmsr(), set_pagetable(), and wrmsr().

#define arrsize (   x)    ((int)(sizeof(x) / sizeof(x[0])))

Return the number of elements in the C array.

Definition at line 26 of file core.h.

Referenced by cmd_display_help(), command_exec(), command_run(), isr_fatal(), kshell(), and logvf().

#define min (   a,
 
)    ((a) < (b) ? (a) : (b))

Generic min/max routines.

Definition at line 29 of file core.h.

Referenced by collapse_overlaps().

#define max (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 30 of file core.h.

Referenced by collapse_overlaps(), grow_heap(), and heap_create().

#define div_dn (   a,
 
)    ((a) / (b))

Definition at line 33 of file core.h.

#define div_up (   a,
 
)    (((a) + (b) - 1) / (b))

Definition at line 34 of file core.h.

Referenced by grow_heap().

#define align_dn (   a,
 
)    (div_dn(a, b) * (b))

Definition at line 37 of file core.h.

#define align_up (   a,
 
)    (div_up(a, b) * (b))

Definition at line 38 of file core.h.

#define ptr_add (   t,
  p,
 
)    ((t *)((uint8_t *)(p) + (o)))
#define ptr_sub (   t,
  p,
 
)    ((t *)((uint8_t *)(p) - (o)))

Definition at line 42 of file core.h.

Referenced by grow_heap(), heap_free(), prev_fblock(), and prev_fblock_adj().

#define STATIC_ASSERT (   a,
 
)    _Static_assert(a, b)

Compile-time static assertion.

Definition at line 45 of file core.h.

struct acpi_madt_iso PACKSTRUCT   __attribute__((packed, aligned(1)))

Forced structure packing (use only when absolutely necessary)

Definition at line 48 of file core.h.