C library VS (Unix) System calls ?

R

Richard Bos

I have a question that deals with the standard c library VS (Unix)
system calls.

If you do this, you probably want a copy of the Standard. Order from ISO
or ANSI, or in book from from Wiley & Sons:
The question is: which header files (and functions) are part of the C
library and which header files (and function calls) are part of the
(Unix) system calls.

Yup, definitely a job for the Standard.

As a first approximation, you can use the last public draft, found here:
I know that the C library make use of the system calls.

Correction: you know that it _usually_ does so. Nothing in the Standard
requires this, though.

Richard
 
M

markus

Hi,

I have a question that deals with the standard c library VS (Unix)
system calls.

The question is: which header files (and functions) are part of the C
library and which header files (and function calls) are part of the
(Unix) system calls.

The cause of my confusion is that for example stdio.h is considered
both as a header file of the C library, as well as a header file of
the (Unix) system calls?

Indeed, all of the following 18 standard C headers are part of the
(Unix) system call headers as well.

The full set of 18 Standard C headers:
<assert.h>, <ctype.h>, <errno.h>, <float.h>, <iso646.h>, <limits.h>,
<locale.h>, <math.h>, <setjmp.h>, <signal.h>, <stdarg.h>, <stddef.h>,
<stdio.h>, <stdlib.h>, <string.h>, <time.h>, <wchar.h>, and
<wctype.h>.

The same headerfiles appear at the definition of the system call
headers:
http://www.unix.org/version3/apis/headers.html

So, which header files (and functions) are part of the C library and
which headers files (and functions) are part of the system calls?

I know that the C library make use of the system calls.

Best regards
 
J

Jens.Toerring

Richard Bos said:
(e-mail address removed) (markus) wrote:
If you do this, you probably want a copy of the Standard. Order from ISO
or ANSI, or in book from from Wiley & Sons:
<http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470845732.html>.
Yup, definitely a job for the Standard.
As a first approximation, you can use the last public draft, found here:
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n869/>.

And the UNIX (SUSv3) standard you can get (for free, registration
required) from

http://www.unix.org/version3/online.html

A table of headers, including the C89 and C99 headers, is here:

http://www.unix.org/version3/apis/headers.html

Finally, the complete set of functions is listed on

http://www.unix.org/version3/apis/t_XXX.html

(replace XXX with the numbers between 1 and 11).

Regards, Jens
 
F

Fredrik Tolf

Hi,

I have a question that deals with the standard c library VS (Unix)
system calls.

The question is: which header files (and functions) are part of the C
library and which header files (and function calls) are part of the
(Unix) system calls.

That seems like a strange question to me. No header files at all are
part of the UNIX system calls. The system calls are kernel traps, which
must be called through assembly language, and thus have nothing to do
with C to begin with.

There are a few functions in the C library that are system call
wrappers, such as read, write, fork, etc. They _are_ not system calls,
however - they _do_ system calls.

Thus, to answer the question: All header files are part of the C
library. Not necessarily the C standard, however (many, such as
unistd.h, are UNIX extensions).
The cause of my confusion is that for example stdio.h is considered
both as a header file of the C library, as well as a header file of
the (Unix) system calls?

Why do you think that stdio.h is "a header file of the UNIX system
calls"? Again, since the syscalls have no header files at all, that's
more or less an oxymoron.
The same headerfiles appear at the definition of the system call
headers:
http://www.unix.org/version3/apis/headers.html

The headers listed there do not have anything at all to do with
syscalls. They only describe which headers are required in a UNIX C
implementation.

Fredrik Tolf
 
M

Michael Wojcik

I have a question that deals with the standard c library VS (Unix)
system calls.

The question is: which header files (and functions) are part of the C
library and which header files (and function calls) are part of the
(Unix) system calls.

The headers and functions defined by the C standard as part of the C
library are part of the C library.

Unix headers and functions, including system calls, are specified by
the Unix standard - which is currently any of the "Austin Group"
standards: POSIX, SUS, and ISO/IEC 9945, which have been combined
into one document.[1]

However, these two documents overlap, because the Unix standard
includes much of the C standard. Note, though, that the Unix
standard defers to the C standard where they overlap, and claims that
any discrepancies are errors in the Unix standard.

So you should treat any headers and functions defined in the C
standard (of whatever version is appropriate for your purposes) as
part of C, because they are. For other headers and functions, check
the Unix standard: if they appear there, then they're part of Unix;
otherwise, they're implementation-defined.
The cause of my confusion is that for example stdio.h is considered
both as a header file of the C library, as well as a header file of
the (Unix) system calls?

That's because the Unix standard explicitly includes the C library.
The front matter to the Unix standard explains this in more detail.

In general, one standard can incorporate another; they needn't be
mutually exclusive.


1. http://www.opengroup.org/onlinepubs/009695399/
 
K

Kelsey Bjarnason

[snips]

There are a few functions in the C library that are system call
wrappers, such as read, write, fork, etc. They _are_ not system calls,

Nor are they C. :)
Thus, to answer the question: All header files are part of the C
library. Not necessarily the C standard, however (many, such as
unistd.h, are UNIX extensions).

Then they'd be third-party extension libraries, rather than the C library,
right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top