Browsing C library in Linux

  • Thread starter Madhusudhanan Chandrasekaran
  • Start date
M

Madhusudhanan Chandrasekaran

Hi,

I know that it is impossible to browse through
the source code of C library in Linux. But I do not remember
how. In short, I would like to see the implementation
of standard header files such as <string.h> etc.

I use Ubuntu. I've even downloaded the linux-headers.
I can see only asm code in /usr/src/linux/include/asm-i386.
Any pointers/help appreciated.


Thanks,
MC
 
W

William Ahern

Madhusudhanan Chandrasekaran said:
Hi,

I know that it is impossible to browse through
the source code of C library in Linux. But I do not remember
how. In short, I would like to see the implementation
of standard header files such as <string.h> etc.

I use Ubuntu. I've even downloaded the linux-headers.
I can see only asm code in /usr/src/linux/include/asm-i386.
Any pointers/help appreciated.

This is off-topic in this group, almost akin to asking where the nearest
petrol station is to your home.

In any event, on most Ubnutu and Debian-derived system, you can
automagically download and unpack the source (into your $CWD) using
incantions similar to:

$ apt-get source glibc

(You may need to `apt-get install dpkg-dev`, first; if you ask in a proper
group people might be quicker to correct me if I prove wrong.)

glibc suffers from a large, complex, and in places nearly impenetrable code
base. You might want to study the string implementation here before diving
into glibc's optimized assembly and C code:

http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/
 
R

Robert Latest

Madhusudhanan said:
Hi,

I know that it is impossible to browse through
the source code of C library in Linux. But I do not remember
how.

That's easy. Just don't do it.

But in case you made the reverse mistake of those that use the word
"flammable" when in fact they mean "inflammable":
In short, I would like to see the implementation
of standard header files such as <string.h> etc.

If you want to see the implementation of the header, just look in
/usr/include. If you want to see how the library itself is implemented, just
download the glibc sources and inspect those.
I use Ubuntu. I've even downloaded the linux-headers.

Those are just for the linux kernel API and have nothing to do with the
Standard library.
I can see only asm code in [...]

You'll find that siginificant portions of the C library are implemented in
assembler. You'll also find the C source quite illegible.

robert
 
J

jacob navia

Robert said:
If you want to see the implementation of the header, just look in
/usr/include. If you want to see how the library itself is implemented, just
download the glibc sources and inspect those.

Those were the old times Robert. When you would just look in the
include directory. This days, software bloat makes that impossible
since the system compiler stores the *real* includes under
/usr/lib/gcc... and a VERY long path. That path is of course not
fixed and changes from version to version so that you can
install 26 different gcc compilers in your machine, each with its own
headers, whatever.

I think you can obtain that path with
gcc -v
then look where the includes are but I am not so sure.

This trend started long ago, when "ld" was replaced with
"collect2" (a script), then continued with the linker
calling the C compiler to compile code generated while linking,
then it continued by transforming some libraries from binaries to
some sort of linker scripts (and retaining the .a suffix)
and all kind of hacks that are thrown upon the older hacks until
only a few selected people in the world really understand
what is going on under the hood.

And this worrisome trend goes on with everything else under
linux, software quality goes down the drain...

VISTA of course is much better :)

There, the bloat is so big that the linux hacks are ridiculous in
comparison.
 
B

Ben Bacarisse

jacob navia said:
Those were the old times Robert. When you would just look in the
include directory. This days, software bloat makes that impossible
since the system compiler stores the *real* includes under
/usr/lib/gcc... and a VERY long path.

An excellent example of why off-topic posts should be re-directed to a
more suitable news group. I'll limit my answer to say that, at least
in general, you are wrong about this. To find out more re-post this
comment to a group where Linux experts will feel free to comment on it
 
P

pete

Madhusudhanan said:
In short, I would like to see the implementation
of standard header files such as <string.h> etc.

Make sure that you do Not immitate
any reserved identifier conventions.

__Don't _start _writing __code _with __leading __underscores!
 
J

James Kuyper

Tomás Ó hÉilidhe said:
James Kuyper:



I thought he was being sarcastic.

The first part of his response sarcastically answered the question as it
was actually worded. The lines cited above were the introduction to the
subsequent section of his response, in which he addressed the question
as the OP presumably intended to write it, with "impossible" corrected
to "possible".

Based upon my personal experience (which is extensive, because my wife
and many of my co-workers are not native speakers of English), I think
Robert Latest was being excessively subtle. It requires considerable
fluency in a language to recognize criticisms written that subtly, and I
suspect that Madhusudhanan lacks that level of fluency - though I may be
making an unjustified assumption based upon his name.
 
C

CBFalconer

Robert said:
.... snip ...

But in case you made the reverse mistake of those that use the
word "flammable" when in fact they mean "inflammable":

However those two words have the identical meaning. Really.
 
R

Richard Bos

=?iso-8859-1?q?Tom=E1s_=D3_h=C9ilidhe?= said:
James Kuyper:


I thought he was being sarcastic.

While we're on the subject of stupidities in English, I was never quite
comfortable with the term "ingenius"

Neither am I.

Richard (not being 100% ingenuous)
 

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

No members online now.

Forum statistics

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

Latest Threads

Top