Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: How does gcc (any compiler) actually convert a function call, say atoi(), into assembly/machine code? Date: Fri, 23 Dec 2016 15:12:05 -0800 Organization: None to speak of Lines: 83 Message-ID: References: <87wpeqbza5.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="25660e100c54d3825f982612bc6543d5"; logging-data="15409"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+PPubiWoR3DvP3pnzPCC8" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:uxgaXeSko/TIZlVar30N2wHfgg0= sha1:NcKfNsNZzWY6evWXVwQR3nqcsTE= Xref: csiph.com comp.lang.c:100101 BartC writes: > On 23/12/2016 21:08, Keith Thompson wrote: >> BartC writes: >> [...] >>> Maybe you already knew enough to type in the right search terms. Doing >>> something like "c atoi function source" didn't give anything useful on >>> the first page. >> >> I just tried that exact search. 5 of the 10 results on the first page >> included (attempted) implementations of atoi() -- most of them >> incorrect. Is that what you meant when you said the results weren't >> useful? > > The first ten results were either about /using/ atoi, or various > assorted attempts to write a function like atoi, none of which seemed > likely to be an official implementation from a C library, or were more > generally about the C runtime library. "Yes" would have been a perfectly good answer to my question. What exactly do you mean by "official"? Neither glibc nor any other implementation has any official standing as far as the C standard is concerned. An implementation is conforming or not. > The second page was more of the same. With a smattering of C++ versions. > > It's only when you start using "glibc atoi function source" that you get > more relevant results. So it's this "glibc" that appears to be the magic > keyword, that you have to know about. glibc is *one* C library implementation. Yes, it's GNU-specific. If you don't care about GNU-specific code, you don't need to know about it. What exactly are you complaining about? > What why should anyone know about "glibc"? Why not? Now you know about glibc. You should now know what it is. (And BTW if you're using C on Windows, you're probably not using it glibc.) What exactly are you complaining about? > It doesn't appear in K&R or > the C Standard. Of course not. Did you expect it to? > It's also gnu-specific, but there must be plenty of > other C libraries (and people here are fond of pointing out that there > is no connection with a C compiler and a particular library. Apparently > they all interoperable.). Some of them are interoperable. Some are not. There is no requirement for a given library implementation to work with any given compiler. If a compiler and library work together correctly, they can be the basis of a conforming C implementation. If not, they can't. Come on, you know this stuff, don't you? > I don't know however what search terms Ben used; or which search engine > (I used google). Perhaps if you could clarify just what you're looking for, we could help you find it. If you're looking for a definitive implementation of atoi(), there's no such thing. If you're looking for one particular implementation, that's going to depend on which one you want. In some cases, the source won't be available. It might also help to know *why* you want the source code for atoi(). You certainly don't need that to be able to use it (which is why implementers don't generally don't go out of their way to make it easy to find). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"