Font Size: a A A

Some Function Implementations Of C Library

Posted on:2022-10-22Degree:MasterType:Thesis
Country:ChinaCandidate:C WangFull Text:PDF
GTID:2518306329961239Subject:Computer software and theory
Abstract/Summary:PDF Full Text Request
C standard library(libc)provides macros,type definitions and functions for string handling,mathematical computations,input/output processing,memory management and other operating system services.llvm-libc is the implementation of C standard library(targeting C17 and above)and the extension of related specific platform.Most implementations of libc are integrated.Only selecting the parts related to platforms is a difficult porting task.The build system of llvm-libc is expected to be as simple as possible,the build target is highly modular,and reflects the "as a library" idea.This makes it a straightforward task to select the required parts.Most libc implementations use a large number of assembly and use platform specific ABI(Application Binary Interface).llvm-libc hopes the implementation is based on source code as much as possible instead of assembly.llvm-libc provides the C symbols specified by the standard,it takes advantage of the C++ features and uses C++for the core implementation.In terms of generating public and internal header files,other libc implementations use preprocessing macros generate platform related header files.When macros are not available,they rely on the build system to select the correct file set for compilation and export.Although these methods work well,some parts of the system become extremely complex and difficult to modify,expand and maintain.In order to avoid these problems,we use a header generation mechanism driven by header configuration language.This paper introduces the definition and implementation of some C library functions,including:stmcpy,memcmp,memmove,abs,labs,llabs and redirected malloc.The implementation of each function should not only meet the requirements of C standard,but also consider the requirements and optimization of use scenarios,including generating header file of target platform,generating build target,designing unit test,coding,simplifying and optimizing code,code review and revision.stmcpy,memcmp and memmove are implemented by manipulating bytes.abs,labs and llabs are implemented with templates.The implementation of the memory allocator is complex.In order to make memory management function work temporarily,the redirected malloc delegating system-libc is implemented.The above functions have passed unit tests and have been commited to the GitHub repository of llvm-libc(except for the redirected malloc).Mainly referenced to Information Technology Programming Languages C:ISO/IEC 9899:2018(C17)and cppreference.com.C11 and C99 standards are also referenced.
Keywords/Search Tags:C Standard, Library Function, String Handling, Memory Management
PDF Full Text Request
Related items