问题
I'm looking through the glib header files that reside in /usr/include to get a feel for what is going on behind the scenes. All the files I'm looking at simply declare a bunch of macros and functions but I want to take a look at the implementation of these functions.
回答1:
The glibc source repository is here:
https://sourceware.org/git/?p=glibc.git;a=tree
Note that a lot of the interesting code is under the sysdeps
directory, particularly sysdeps/unix/sysv/linux/*
. Also worth noting is that stdio is split between stdio-common
and libio
, and all of the POSIX threads interfaces are implemented under nptl
(which also has its own sysdeps
tree.
Further, note that there are a lot of functions for which you will simply not find source code at all. Many of the standard functions are simply entry points for making calls to the kernel (syscalls), and these wrappers are automatically generated as part of the build process.
回答2:
The readable form of the implementation of the functions within the GLibC is contained within its source code, downloadable from its website.
Note that some of the functions are stubs that delegate to system calls, and the complete implementation will be found within the source code of your operating system.
来源:https://stackoverflow.com/questions/19498474/where-is-the-implementation-of-the-gnu-c-library