Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.

Latest commit

 

History

History
95 lines (73 loc) · 1.92 KB

File metadata and controls

95 lines (73 loc) · 1.92 KB

MalibC API Reference

Version: 1.0.0.1 ABI: x86-64 Linux (System V)

Core Functionality

Version Reporting

const char *gnu_get_libc_version(void);

Memory Management

void* malloc(size_t size);

void free(void* ptr);

Standard I/O

int putchar(int c);

int printf(const char* fmt, ...);

File Operations

FILE* fopen(const char* path, const char* mode);

size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream);

int fclose(FILE* stream);

System Interfaces

Startup

; Program entry point (_start)
; Stack layout on entry:
;   rsp   -> argc
;   rsp+8 -> argv[0]
; Clobbers: rbp, rcx, r11

Type Definitions

typedef unsigned long size_t;  // Size type (32/64-bit compatible).
#define NULL ((void*)0)        // Null pointer constant.

Limitations

Feature Status Notes
Buffered I/O ❌ Not implemented Direct syscalls only
Thread Safety ❌ Not thread-safe Single-threaded only
Error Reporting ⚠️ Limited Only NULL/EOF returns
Floating Point ❌ Not supported No %f in printf

Example Usage

Basic Program

#include <stdio.h>

int main() {
    printf("Allocated %zu bytes\n", sizeof(int) * 100);
    int* arr = malloc(sizeof(int) * 100);
    free(arr);
    return 0;
}

File Operations

FILE* f = fopen("data.txt", "r");
if (f) {
    char buf[100];
    size_t n = fread(buf, 1, sizeof(buf), f);
    printf("Read %zu bytes\n", n);
    fclose(f);
}

Compliance

Standard Support Level
ANSI C89 Partial
POSIX Minimal
Linux ABI Full

Note: For production systems, consider linking with full libc implementations like glibc or musl.