免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 5167 | 回复: 11
打印 上一主题 下一主题

glibc与系统以及机器的关系 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-11-30 00:25 |只看该作者 |倒序浏览
如题,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

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
2 [报告]
发表于 2010-11-30 08:49 |只看该作者
如题,libc不就是c写的供调用的函数吗?为什么同是linux glibc不一样?为什么机器不同(比如:mips IA64 AR ...
wwthappy 发表于 2010-11-30 00:25



    对外接口语意一样,实现却可以五花八门,这个很正常啊,glibc同样有版本之别

论坛徽章:
0
3 [报告]
发表于 2010-11-30 16:31 |只看该作者
回复 2# cjaizss


    我的意思是glibc为什么会与机器有关呢?到底和机器有什么关系呢?我看了看sysdep下面的一些汇编文件,模模糊糊了解到可能与机器的堆栈初始化等有关,如果您知道的话您可以解释的稍微详细一点吗?谢谢啦

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
4 [报告]
发表于 2010-11-30 21:07 |只看该作者
回复  cjaizss


    我的意思是glibc为什么会与机器有关呢?到底和机器有什么关系呢?我看了看sysdep下 ...
wwthappy 发表于 2010-11-30 16:31



    打个比方,memcpy,内存复制,很多处理器都提供快速的内存复制手段,这些需要汇编实现的。

论坛徽章:
0
5 [报告]
发表于 2010-12-01 12:25 |只看该作者
优化,处理器的版本都是针对处理器优化

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
6 [报告]
发表于 2010-12-01 12:33 |只看该作者
还有,比如对<stdarg.h>的支持,即可变参数的支持,机器相关

论坛徽章:
3
2015年迎新春徽章
日期:2015-03-04 09:56:11数据库技术版块每日发帖之星
日期:2016-08-03 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
7 [报告]
发表于 2010-12-01 12:35 |只看该作者
还有,比如对的支持,即可变参数的支持,机器相关
cjaizss 发表于 2010-12-01 12:33



    一般来说,编译器为了支持可变参数,可任意长的可变参数,不像open系统调用这样的,而像printf这样的,都采取压栈,这样才可以能够统一处理

论坛徽章:
0
8 [报告]
发表于 2010-12-12 00:42 |只看该作者
回复 5# readkernel
是奥,最近看了看手册,说是在相应文件夹下可以写优化版本的库函数。谢谢

论坛徽章:
0
9 [报告]
发表于 2010-12-12 00:44 |只看该作者
回复 7# cjaizss
谢谢你的耐心解答,我感觉我的水太浅,还要好好学习,向前辈们看齐。

论坛徽章:
0
10 [报告]
发表于 2010-12-28 17:50 |只看该作者
回复 6# cjaizss


   如果我想一直glibc,最简单的情况(不要优化)是不是只要写一个start.s就可以了?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP