用于Unix的C运行时库 [英] C runtime library for Unix

查看:71
本文介绍了用于Unix的C运行时库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想移植PDPCLIB:

http:/ /sourceforge.net/projects/pdos/

我的公共域C运行时库,适用于DOS,OS / 2,

Win32,MVS到Unix现在。


我对如何做到这一点感到有点困惑。 Unix / Posix

系统提供open(),我可以用它来实现

fopen()。但是Posix也需要定义fopen(),

所以这不是我需要实现它的级别。


虽然我不喜欢我认为CRT应该首先使用open()来污染

命名空间。


如果较低级别依赖于平台,那么平台

我希望定位的是Linux。


有人能让我开始吗?


谢谢。 Paul。

I would like to port PDPCLIB:

http://sourceforge.net/projects/pdos/

my public domain C runtime library for DOS, OS/2,
Win32, MVS to Unix now.

I am a bit perplexed as to how to do this. Unix/Posix
systems provide open() with which I can implement
fopen(). But then Posix is also required to define fopen(),
so this is not the level at which I need to implement it.

Although I don''t think the CRT should be polluting the
namespace by using open() in the first place.

If the lower level is platform-dependent, then the platform
I wish to target is Linux.

Can someone get me started?

Thanks. Paul.

推荐答案

Paul Edwards写道:
Paul Edwards wrote:

我想移植PDPCLIB:

http://sourceforge.net/projects/pdos/


我的公共域C运行时库,适用于DOS,OS / 2,

Win32,MVS到Unix现在。

我对如何做到这一点感到有点困惑。 Unix / Posix

系统提供open(),我可以用它来实现

fopen()。但是Posix也需要定义fopen(),

所以这不是我需要实现它的级别。


虽然我不喜欢我认为CRT应该首先使用open()来污染

命名空间。


如果较低级别依赖于平台,那么平台

我希望定位的是Linux。


有人能让我开始吗?
I would like to port PDPCLIB:

http://sourceforge.net/projects/pdos/

my public domain C runtime library for DOS, OS/2,
Win32, MVS to Unix now.

I am a bit perplexed as to how to do this. Unix/Posix
systems provide open() with which I can implement
fopen(). But then Posix is also required to define fopen(),
so this is not the level at which I need to implement it.

Although I don''t think the CRT should be polluting the
namespace by using open() in the first place.

If the lower level is platform-dependent, then the platform
I wish to target is Linux.

Can someone get me started?



作为一个系统库,你只需要依赖操作系统导出的

的API。 Linux旨在实现POSIX合规性,从而实现POSIX定义的许多

API。系统C库通常还提供POSIX

界面。


一般情况下,你应该尝试在标准C中尽可能多地做。

并在需要时编写特定函数。如果你想将

库移植到大多数UNIX,它的结构和编译将更多地涉及到
。如果它专门用于Linux,那么它将会更加简单。


至少你需要参考C标准,POSIX

标准和OS API的2页。棘手的部分将是

满足操作系统而不会牺牲太多的可移植性。


将Linux API相关问题发布到其中一个Linux组。详细信息

在标准C部分可以在这里讨论或在comp.std.c中讨论,(但是

我怀疑那些区域对你来说是个大问题)。


Linux新闻组可能会对您有所帮助。另外浏览诸如dietlibc等C库的

来源。

As a system library, you''ll need to only rely on the APIs exported by
the OS. Linux aims towards POSIX compliance and thus implements many
APIs defined by POSIX. The system C library often also provides POSIX
interface.

In general you should try to do as much as possible within standard C
and write specific functions when they''re called for. If you want the
library to port to most UNIXes, it''s structure and compilation will get
more involved. If it''s specifically for Linux, then it''ll be much
simpler.

At a minimum you''ll need to refer to the C standard, the POSIX
standards and the man 2 pages for the OS API. The tricky part will be
satisfying the OS without sacrificing too much portability.

Post Linux API related questions to one of the Linux groups. Details
within standard C portions can be discussed here or in comp.std.c, (but
I doubt that those areas would be much of a problem for you).

The Linux newsgroups will probably help you best. Also browse the
sources of C libraries like dietlibc etc.


" santosh" < sa ********* @ gmail.com在消息新闻中写道:11 ********************** @ e3g2000cwe.googlegro ups.com ...
"santosh" <sa*********@gmail.comwrote in message news:11**********************@e3g2000cwe.googlegro ups.com...

还可以浏览像Dietlibc等C库的来源。
Also browse the sources of C libraries like dietlibc etc.



谢谢。我发现了,他们的fopen()调用了__libc_open()

,而这又调用了__syscall_open()。


__syscall_open()大概就是操作系统导出,

以及我需要使用什么来避免通过直接调用open()来污染用户的命名空间




我还没找到__syscall_open()定义的地方,

但我在syscalls.h中找到了一个sys_open()。也许那是'

合适的人使用。


BFN。 Paul。

Thanks. I found that, and their fopen() calls __libc_open()
which in turn calls __syscall_open().

The __syscall_open() is presumably what the OS exports,
and what I need to use to avoid polluting the user''s namespace
by a direct call to open().

I haven''t found where __syscall_open() is defined yet,
but I found a sys_open() in syscalls.h. Maybe that''s the
proper one to use.

BFN. Paul.


Paul Edwards skrev:


[...]
Paul Edwards skrev:

[...]

我还没找到__syscall_open()定义的地方,

但我在syscalls.h中找到了一个sys_open()。也许

这是正确使用的。
I haven''t found where __syscall_open() is defined yet,
but I found a sys_open() in syscalls.h. Maybe
that''s the proper one to use.



sys_open()

sys_read()

sys_write()

sys_close ()


但是,为什么不在Linux论坛上查找Linux内核文档或

问题?


comp.os.linux.misc

comp.os.linux.development.system

comp.os.linux.development.apps



< gd& r>


-

Tor< torust AT online DOT no>

sys_open()
sys_read()
sys_write()
sys_close()

BUT, why not look up the Linux kernel documentation or
ask in a forum where Linux is on-topic?

comp.os.linux.misc
comp.os.linux.development.system
comp.os.linux.development.apps
etc.

<gd&r>

--
Tor <torust AT online DOT no>


这篇关于用于Unix的C运行时库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆