glibc与系统以及机器的关系
如题,libc不就是c写的供调用的函数吗?为什么同是linux glibc不一样?为什么机器不同(比如:mips IA64 ARM)glibc也不同?是不是glibc中大部分是与这些无关的?
glibc porting的说法:
All the machine-dependent and operating system-dependent files in the library are in the subdirectory sysdeps under the top-level library source directory. This directory contains a hierarchy of subdirectories (see Hierarchy Conventions).
Each subdirectory of sysdeps contains source files for a particular machine or operating system, or for a class of machine or operating system (for example, systems by a particular vendor, or all machines that use IEEE 754 floating-point format). A configuration specifies an ordered list of these subdirectories. Each subdirectory implicitly appends its parent directory to the list. For example, specifying the list unix/bsd/vax is equivalent to specifying the list unix/bsd/vax unix/bsd unix. A subdirectory can also specify that it implies other subdirectories which are not directly above it in the directory hierarchy. If the file Implies exists in a subdirectory, it lists other subdirectories of sysdeps which are appended to the list, appearing after the subdirectory containing the Implies file. Lines in an Implies file that begin with a ‘#’ character are ignored as comments. For example, unix/bsd/Implies contains:
# BSD has Internet-related things.
unix/inet
and unix/Implies contains:
posix
So the final list is unix/bsd/vax unix/bsd unix/inet unix posix.
sysdeps has a “special” subdirectory called generic. It is always implicitly appended to the list of subdirectories, so you needn't put it in an Implies file, and you should not create any subdirectories under it intended to be new specific categories. generic serves two purposes. First, the makefiles do not bother to look for a system-dependent version of a file that's not in generic. This means that any system-dependent source file must have an analogue in generic, even if the routines defined by that file are not implemented on other platforms. Second, the generic version of a system-dependent file is used if the makefiles do not find a version specific to the system you're compiling for.
///////////////////////////////////////////////////////////////////
支持的操作系统和机器:
Version 2 currently supports only GNU systems (both Hurd-based and Linux-based). The list of supported architectures is
GNU/Hurd. We believe all platforms the Hurd runs on are also supported by GNU libc.
GNU/Linux. GNU libc works with the Linux kernel, version 2.0.10 or later, on the following architectures:
Intel ix86
Motorola 680x0
DEC Alpha
PowerPC (32 and 64 bit)
Sparc
Sparc64
ARM
MIPS (Kernels > 2.2.15)
Intel IA64 (Kernels > 2.4.0)
IBM S/390 (32 and 64 bit)
SH
CRIS
AMD x86-64
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
回复 6# cjaizss
如果我想一直glibc,最简单的情况(不要优化)是不是只要写一个start.s就可以了?
回复 7# cjaizss
谢谢你的耐心解答,我感觉我的水太浅,还要好好学习,向前辈们看齐。
回复 5# readkernel
是奥,最近看了看手册,说是在相应文件夹下可以写优化版本的库函数。谢谢
一般来说,编译器为了支持可变参数,可任意长的可变参数,不像open系统调用这样的,而像printf这样的,都采取压栈,这样才可以能够统一处理
还有,比如对<stdarg.h>的支持,即可变参数的支持,机器相关
优化,处理器的版本都是针对处理器优化
打个比方,memcpy,内存复制,很多处理器都提供快速的内存复制手段,这些需要汇编实现的。
回复 2# cjaizss
我的意思是glibc为什么会与机器有关呢?到底和机器有什么关系呢?我看了看sysdep下面的一些汇编文件,模模糊糊了解到可能与机器的堆栈初始化等有关,如果您知道的话您可以解释的稍微详细一点吗?谢谢啦
对外接口语意一样,实现却可以五花八门,这个很正常啊,glibc同样有版本之别