Module: sys.platform.libc

Source: ./sys/platform/libc.reef


Overview

sys/platform/libc - Consolidated C Library FFI Declarations

This module provides a single source of truth for all libc FFI declarations used by the Reef standard library. Instead of each module declaring its own extern "C" functions, they import from here.

Categories:

  • Memory: calloc, malloc, free, memcpy, memset, memmove
  • String: strcpy, strcat, strlen
  • Math: sin, cos, sqrt, pow, etc. (libm)
  • I/O: Basic file operations (when not using reef_* wrappers)

Note: The libc/ module in stdlib is a separate, intentional wrapper for programs that want direct libc access. This module is for internal stdlib use.

For Reef runtime functions (reef_*), see sys/platform/runtime.reef


Functions

fn calloc(count: int, size: int): pointer

fn malloc(size: int): pointer

fn memcpy(dest: pointer, src: pointer, n: int): pointer

fn memset(dest: pointer, c: int, n: int): pointer

fn memmove(dest: pointer, src: pointer, n: int): pointer

fn strcpy(dest: string, src: string): string

fn strcat(dest: string, src: string): string

fn strlen(s: string): int

fn strcmp(s1: string, s2: string): int

fn strncpy(dest: string, src: string, n: int): string

fn strncmp(s1: string, s2: string, n: int): int

fn sqrt(x: float): float

Basic

fn pow(base: float, exp: float): float

fn fabs(x: float): float

fn sin(x: float): float

Trigonometric

fn cos(x: float): float

fn tan(x: float): float

fn asin(x: float): float

fn acos(x: float): float

fn atan(x: float): float

fn atan2(y: float, x: float): float

fn sinh(x: float): float

Hyperbolic

fn cosh(x: float): float

fn tanh(x: float): float

fn exp(x: float): float

Exponential and Logarithmic

fn log(x: float): float

fn log2(x: float): float

fn log10(x: float): float

fn floor(x: float): float

Rounding

fn ceil(x: float): float

fn round(x: float): float

fn trunc(x: float): float

fn cbrt(x: float): float

Other

fn hypot(x: float, y: float): float

fn rand(): int


Procedures

proc free(ptr: pointer)

proc srand(seed: uint32)


Generated by reefc doc