Skip to content

A lightweight, freestanding C standard library designed to replace glibc. Includes essential POSIX-compliant string, memory, and file I/O functions implemented directly using Linux system calls

License

Notifications You must be signed in to change notification settings

florian-ariasu/mini-libc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

🚀 Mini-libc: A Minimalist Standard C Library Implementation

🌟 Overview

Welcome to mini-libc, a lightweight and freestanding implementation of the standard C library for Linux systems! This project is built from the ground up to replace the default system libc, relying solely on Linux system calls. By crafting a minimal yet functional libc, you'll dive deep into string manipulation, memory management, and low-level file I/O operations.

🎯 Objectives

  • 🔍 Understand the structure and purpose of the C standard library
  • 🏗️ Develop a freestanding implementation using only syscalls
  • 📝 Implement fundamental string and memory functions
  • 📂 Provide essential file I/O and process utilities
  • ⚙️ Gain insights into Linux syscall interfaces

🔧 Core Features

📜 String Manipulation (<string.h>)

Efficient string-handling functions:

  • strcpy() / strncpy()
  • strcat() / strncat()
  • strlen()
  • strcmp() / strncmp()
  • strstr() / strrstr()
  • memcpy() / memmove()
  • memset() / memcmp()

📝 Input/Output (<stdio.h>)

  • puts() – Simple string printing via syscall(__NR_write) 📢

📂 File & Process Control (<unistd.h>, <sys/fcntl.h>, <sys/stat.h>)

Essential POSIX-compliant file operations:

  • open() / close() 🔑
  • lseek() 🔄
  • stat() / fstat() 📊
  • truncate() / ftruncate() ✂️

⏳ Time Utilities (<time.h>)

  • nanosleep() / sleep() 💤

🧠 Memory Management (<stdlib.h>, <sys/mman.h>)

Lightweight dynamic memory allocation:

  • malloc() / free() 🔄
  • calloc()
  • realloc() / reallocarray() 🔧
  • mmap() / mremap() / munmap() 🗂️

🚨 Error Handling (<errno.h>)

  • errno variable management for system call failures

🏗️ Build & Installation

🔨 Compiling mini-libc

cd src/
make

📚 Resources & References

About

A lightweight, freestanding C standard library designed to replace glibc. Includes essential POSIX-compliant string, memory, and file I/O functions implemented directly using Linux system calls

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published