I was searching for the source code of the C standard libraries. What I mean with it is, for example, how are cos, abs, printf, scanf, fopen, and all the other standard C functions written, I mean to see their source code.
我正在寻找C标准库的源代码。我的意思是,例如,cos,abs,printf,scanf,fopen和所有其他标准C函数是如何编写的,我的意思是看它们的源代码。
So while searching for this, I came across with GLIBC, but I don't know what it actually is. It is GNU C Library, and it contains some source codes, but what are they actually, are they the source code of the standard functions or are they something else? And what is it used for?
所以在搜索这个时,我遇到了GLIBC,但我不知道它到底是什么。它是GNU C库,它包含一些源代码,但实际上它们是标准函数的源代码还是其他东西?它用于什么?
4 个解决方案
#1
35
Its the implementation of Standard C library described in C standards plus some extra useful stuffs which are not strictly standard but used frequently.
它是C标准中描述的标准C库的实现,加上一些非常有用的东西,它们不是严格标准的,而是经常使用的。
Its main contents are :
其主要内容是:
1) C library described in ANSI,c99,c11 standards. It includes macros, symbols, function implementations etc.(printf(),malloc() etc)
1)C库,ANSI,c99,c11标准中描述。它包括宏,符号,函数实现等。(printf(),malloc()等)
2) POSIX standard library. The "userland" glue of system calls. (open(),read() etc. Actually glibc does not "implement" system calls. kernel does it. But glibc provides the user land interface to the services provided by kernel so that user application can use a system call just like a ordinary function.
2)POSIX标准库。系统调用的“userland”粘合剂。 (open(),read()等。实际上glibc并没有“实现”系统调用。内核会这样做。但是glibc为内核提供的服务提供了用户界面,这样用户应用程序就可以像普通的一样使用系统调用功能。
3) Also some nonstandard but usefull stuffs.
3)还有一些非标准但有用的东西。
"use the force, read the source "
“使用武力,阅读来源”
$git clone git://sourceware.org/git/glibc.git
(I was recently pretty enlightened when i looked through malloc.c in glibc)
(当我在glibc中查看malloc.c时,我最近很开明)
#2
7
There are several implementations of the standard. Glibc is the implementation that most Linuxes use, but there are others. Glibc also contains (as Aftnix states) the glue functions which set up the scene for jumps into the kernel (also known as system calls). So many of glibc's 'functions' don't do the actual work but only delegate to the kernel.
该标准有几种实现方式。 Glibc是大多数Linux使用的实现,但还有其他。 Glibc还包含(如Aftnix所述)胶合函数,用于设置跳转到内核的场景(也称为系统调用)。很多glibc的“函数”都没有做实际的工作,只是委托给内核。
To read the source of Glibc, just google for it. There are myriad sites which carry it, and also several variations.
要阅读Glibc的来源,只需google即可。有无数的网站携带它,还有几个变种。
Windows uses Microsoft's own implementation, which I believe is called MSVCR.DLL. I doubt that you will find the source code to that library anywhere. Also note that some functions which a Linux hacker might think of as 'standard', simply don't exist on Windows (notably fork). The reverse is also true.
Windows使用Microsoft自己的实现,我相信它被称为MSVCR.DLL。我怀疑你会在任何地方找到该库的源代码。另请注意,Linux黑客可能认为某些功能是“标准”的,在Windows上并不存在(特别是fork)。反之亦然。
Other systems will have their own libc.
其他系统将拥有自己的libc。
#3
6
The glibc package contains standard libraries which are used by multiple programs on the system. In order to save disk space and memory, as well as to make upgrading easier, common system code iskept in one place and shared between programs. This particular package contains the most important sets of shared libraries: the standard C library and the standard math library. Without these two libraries, a Linux system will not function. The glibc package also contains national language (locale) support.
glibc包中包含标准库,这些库由系统上的多个程序使用。为了节省磁盘空间和内存,以及使升级更容易,常见的系统代码在一个地方保存并在程序之间共享。这个特定的包包含最重要的共享库集:标准C库和标准数学库。没有这两个库,Linux系统将无法运行。 glibc包还包含国家语言(语言环境)支持。
#4
1
Yes, It's the implementation of standard library functions.
是的,这是标准库函数的实现。
More specifically, it is the implementation for all GNU systems and in almost all *NIX systems that use the Linux kernel.
更具体地说,它是所有GNU系统和几乎所有使用Linux内核的* NIX系统的实现。
#1
35
Its the implementation of Standard C library described in C standards plus some extra useful stuffs which are not strictly standard but used frequently.
它是C标准中描述的标准C库的实现,加上一些非常有用的东西,它们不是严格标准的,而是经常使用的。
Its main contents are :
其主要内容是:
1) C library described in ANSI,c99,c11 standards. It includes macros, symbols, function implementations etc.(printf(),malloc() etc)
1)C库,ANSI,c99,c11标准中描述。它包括宏,符号,函数实现等。(printf(),malloc()等)
2) POSIX standard library. The "userland" glue of system calls. (open(),read() etc. Actually glibc does not "implement" system calls. kernel does it. But glibc provides the user land interface to the services provided by kernel so that user application can use a system call just like a ordinary function.
2)POSIX标准库。系统调用的“userland”粘合剂。 (open(),read()等。实际上glibc并没有“实现”系统调用。内核会这样做。但是glibc为内核提供的服务提供了用户界面,这样用户应用程序就可以像普通的一样使用系统调用功能。
3) Also some nonstandard but usefull stuffs.
3)还有一些非标准但有用的东西。
"use the force, read the source "
“使用武力,阅读来源”
$git clone git://sourceware.org/git/glibc.git
(I was recently pretty enlightened when i looked through malloc.c in glibc)
(当我在glibc中查看malloc.c时,我最近很开明)
#2
7
There are several implementations of the standard. Glibc is the implementation that most Linuxes use, but there are others. Glibc also contains (as Aftnix states) the glue functions which set up the scene for jumps into the kernel (also known as system calls). So many of glibc's 'functions' don't do the actual work but only delegate to the kernel.
该标准有几种实现方式。 Glibc是大多数Linux使用的实现,但还有其他。 Glibc还包含(如Aftnix所述)胶合函数,用于设置跳转到内核的场景(也称为系统调用)。很多glibc的“函数”都没有做实际的工作,只是委托给内核。
To read the source of Glibc, just google for it. There are myriad sites which carry it, and also several variations.
要阅读Glibc的来源,只需google即可。有无数的网站携带它,还有几个变种。
Windows uses Microsoft's own implementation, which I believe is called MSVCR.DLL. I doubt that you will find the source code to that library anywhere. Also note that some functions which a Linux hacker might think of as 'standard', simply don't exist on Windows (notably fork). The reverse is also true.
Windows使用Microsoft自己的实现,我相信它被称为MSVCR.DLL。我怀疑你会在任何地方找到该库的源代码。另请注意,Linux黑客可能认为某些功能是“标准”的,在Windows上并不存在(特别是fork)。反之亦然。
Other systems will have their own libc.
其他系统将拥有自己的libc。
#3
6
The glibc package contains standard libraries which are used by multiple programs on the system. In order to save disk space and memory, as well as to make upgrading easier, common system code iskept in one place and shared between programs. This particular package contains the most important sets of shared libraries: the standard C library and the standard math library. Without these two libraries, a Linux system will not function. The glibc package also contains national language (locale) support.
glibc包中包含标准库,这些库由系统上的多个程序使用。为了节省磁盘空间和内存,以及使升级更容易,常见的系统代码在一个地方保存并在程序之间共享。这个特定的包包含最重要的共享库集:标准C库和标准数学库。没有这两个库,Linux系统将无法运行。 glibc包还包含国家语言(语言环境)支持。
#4
1
Yes, It's the implementation of standard library functions.
是的,这是标准库函数的实现。
More specifically, it is the implementation for all GNU systems and in almost all *NIX systems that use the Linux kernel.
更具体地说,它是所有GNU系统和几乎所有使用Linux内核的* NIX系统的实现。