Does getc(3) use the read(2) syscall?

Daniel Molina Wegener dmw at coder.cl
Wed Feb 3 19:57:51 UTC 2010


On Wednesday 03 February 2010,
Marc Olzheim <zlo at zlo.nu> wrote:

> On Wed, Feb 03, 2010 at 10:23:50AM -0300, Daniel Molina Wegener wrote:
> > > I'm having trouble looking this function up in the source tree, the
> > > trail seems to end at __sys_read which has a bunch of prototypes but i
> > > can't find the actual function code.
> >
> >   Well, you can try cscope --- IMO the best option to
> > search for symbols in the source tree. Also you have
> > well done front-ends like cbrowser, codelite and emacs
> > plus cscope mode.
> 
> Works wonders in vim as well. :-)

  Sure, vim supports cscope since 2000 and possibly before that,
indeed vim was my first programming editor in FreeBSD and Linux.
Then I've learned emcas, and now I use both editors --- the first
available on the machine that I'm working on --- also emacs requires
a lot of configurations, but is my primary editor on my FreeBSD
boxes.

> 
> > > So my question is primarily, does getc use the read system call
> > > eventually?
> >
> >   No, certainly not. Take a look on stdio.h and libc
> > implementation on lib/libc/stdio/getc.c. Mainly on the
> > __sgetc(f) macro.
> 
> If you follow macros long enough, you'll find that it obviously does use
> the read system call. read, readv, pread, preadv are basicly the system
> calls through which all normal reads take place.

  That's right, but cscope or even etags should help a lot
finding those simbols, most for large source trees like
the FreeBSD base system ;)

> 
> Marc
> 

Best regards,
-- 
Daniel Molina Wegener <dmw [at] coder [dot] cl>
Software Architect, System Programmer & Web Developer
Phone: +1 (510) 629-4267 | Blog: http://coder.cl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20100203/950bb261/attachment.pgp


More information about the freebsd-hackers mailing list