{"id":26536922,"url":"https://github.com/radutul/mini-lib-c","last_synced_at":"2025-03-21T22:17:39.438Z","repository":{"id":283232153,"uuid":"951092738","full_name":"RaduTul/Mini-lib-c","owner":"RaduTul","description":"A minimal implementation of a C library.","archived":false,"fork":false,"pushed_at":"2025-03-19T07:31:17.000Z","size":0,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T07:34:51.460Z","etag":null,"topics":["c","library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RaduTul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-19T06:35:57.000Z","updated_at":"2025-03-19T07:31:21.000Z","dependencies_parsed_at":"2025-03-19T07:45:08.568Z","dependency_job_id":null,"html_url":"https://github.com/RaduTul/Mini-lib-c","commit_stats":null,"previous_names":["radutul/mini-lib-c"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaduTul%2FMini-lib-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaduTul%2FMini-lib-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaduTul%2FMini-lib-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaduTul%2FMini-lib-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RaduTul","download_url":"https://codeload.github.com/RaduTul/Mini-lib-c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244875043,"owners_count":20524591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","library"],"created_at":"2025-03-21T22:17:38.472Z","updated_at":"2025-03-21T22:17:39.374Z","avatar_url":"https://github.com/RaduTul.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mini-libc\n\n## Objectives\n- Understand the structure and functionalities of the standard C library.\n- Get familiar with the Linux syscall interface.\n- Improve knowledge of string and memory management functions.\n- Learn how the standard C library supports low-level input/output operations.\n\n## Statement\nBuild a minimalistic [standard C library](https://en.wikipedia.org/wiki/C_standard_library) implementation for Linux systems, named **mini-libc**. This library will serve as a replacement for the system libc (glibc in Linux) and will provide essential functionalities such as string management, basic memory support, and POSIX file I/O.\n\nThe **mini-libc** implementation will be freestanding, meaning it will not use external library calls. It will be based on the system call interface provided by Linux on an **x86_64** architecture. Any required functions from libc must be implemented manually, and previously implemented functions can be reused in other parts of the mini-libc.\n\nFor macOS users with **ARM64 / Aarch64**, an **x86_64 virtual machine** must be installed to complete the assignment.\n\n## Support Code\nThe project consists of three main directories:\n- **libc/** – The skeleton mini-libc implementation, where missing parts must be implemented.\n- **samples/** – Contains use cases and test examples for mini-libc.\n- **tests/** – Includes tests for validating and grading the implementation.\n\nSystem call invocation is handled by the `syscall()` function in `libc/syscall.c`, which relies on the architecture-specific implementation in `libc/internal/arch/x86_64/syscall_arch.h`.\n\n## API and Implementation Tasks\n### Required Headers and Functions\n#### `\u003cstring.h\u003e` – String-handling functions\n- `strcpy()`, `strcat()`, `strlen()`, `strncpy()`, `strncat()`\n- `strcmp()`, `strncmp()`, `strstr()`, `strrstr()`\n- `memcpy()`, `memset()`, `memmove()`, `memcmp()`\n\n#### `\u003cstdio.h\u003e` – Printing and I/O functions\n- `puts()`\n\n#### `\u003cunistd.h\u003e`, `\u003csys/fcntl.h\u003e`, `\u003csys/stat.h\u003e` – I/O primitives\n- `open()`, `close()`, `lseek()`, `stat()`, `fstat()`\n- `truncate()`, `ftruncate()`\n- `nanosleep()`, `sleep()`\n\n#### `\u003cstdlib.h\u003e`, `\u003csys/mman.h\u003e` – Memory allocation functions\n- `malloc()`, `free()`, `calloc()`, `realloc()`, `realloc_array()`\n- `mmap()`, `mremap()`, `munmap()`\n\n#### `\u003cerrno.h\u003e` – Error handling\n- The `errno` variable must be properly modified by certain functions.\n\n### Additional Tasks\nSome tests will not compile initially due to missing components. To fix this, the following items must be implemented:\n- `time.h` header\n- `puts()` function\n- `nanosleep()` and `sleep()` functions\n- Update the **libc Makefile** to include the above functions.\n\n## Building Mini-libc\nTo build **mini-libc**, navigate to the `libc/` directory and run:\n```sh\ncd libc/\nmake\n```\n\nTo build the **samples**, navigate to the `samples/` directory and run:\n```sh\ncd samples/\nmake\n```\n\n## Testing and Grading\nThe **tests/** directory contains automated tests.\nTo list available tests:\n```sh\nls -F tests/\n```\n\nTo run all tests and check the implementation:\n```sh\ncd tests/\nmake check\n```\n\nThe total number of points available is **900**, with the maximum possible grade being **90** (points divided by 10).\n\n### Expected Output\nInitially, many tests will fail due to missing implementations. A successful run should display passing tests, such as:\n```sh\ntest_strcpy                      ........................ passed ..   9\ntest_memcpy                      ........................ passed ..  11\ntest_open_non_existent_file      ........................ passed ..   8\ntest_sleep                       ........................ passed ..  20\n```\n\nTo achieve full marks, all required functions must be correctly implemented and tested.\n\n## Notes\n- Some files will fail to build initially. This is expected and will be resolved as missing functions are implemented.\n- Many tests will initially fail due to missing functionality.\n- Pay attention to functions that modify `errno`.\n\nBy completing this assignment, you will gain hands-on experience with **low-level C programming**, **memory management**, and **system calls** in Linux.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradutul%2Fmini-lib-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fradutul%2Fmini-lib-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradutul%2Fmini-lib-c/lists"}