Skip to content

SebiBahrin/Mini-LibC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Project Description

The goal of Mini-libc is to build a freestanding, minimal implementation of the C standard library on Linux. Unlike traditional libraries, Mini-libc is built on top of Linux system calls, meaning that any functionality typically provided by libc must be implemented from scratch.

The implementation covers the following areas:

  • String Handling (<string.h>): Implement functions like strcpy(), strcat(), strlen(), strncpy(), strncat(), strcmp(), strncmp(), strstr(), strrstr(), memcpy(), memset(), memmove(), and memcmp().
  • Standard I/O (<stdio.h>): Provide a minimal implementation of functions such as puts().
  • File I/O and POSIX operations (<unistd.h>, <sys/fcntl.h>, <sys/stat.h>): Implement functions like open(), close(), lseek(), stat(), fstat(), truncate(), ftruncate(), along with sleep functions like nanosleep() and sleep().
  • Memory Allocation (<stdlib.h>, <sys/mman.h>): Implement memory management functions including malloc(), free(), calloc(), realloc(), realloc_array(), and memory mapping functions mmap(), mremap(), and munmap(). A simple memory list structure is provided to assist with managing memory areas.
  • Error Handling (<errno.h>): Properly manage the global variable errno to indicate errors in system calls and library functions.

Objectives Achieved:

  • Understood the Standard C Library: Gained a solid understanding of how the C standard library is structured and how it provides essential functionalities through organized headers and modular implementation.

  • Implemented Linux System Calls: Worked directly with the Linux syscall interface on x86_64 to recreate standard library functionality without relying on external libraries like glibc.

  • Handled String & Memory Operations: Successfully implemented core string manipulation functions (strcpy, strlen, strcmp, etc.) and memory handling functions (memcpy, memset, memmove, etc.), ensuring correct behavior and efficiency.

  • Supported Low-level I/O Operations: Developed and tested essential POSIX-compliant file I/O operations (open, close, lseek, stat, etc.), allowing the library to interact directly with the file system through syscalls.

  • Built a Freestanding Library: Designed and implemented a minimal C library from scratch that is self-contained and does not depend on any existing C standard library, fulfilling the freestanding requirement

Local Checker:

Run the following command from the project root to execute the local checker: ./local.sh checker

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published