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

Stefan Midjich stefan.midjich at gmail.com
Thu Feb 4 15:24:01 UTC 2010


Thank you all for your wonderful replies!

I should have known it was a macro, thank you.

Very informative help from you Oliver.

2010/2/3 Daniel Molina Wegener <dmw at coder.cl>

> 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/
>



-- 


Med vänliga hälsningar / With kind regards

Stefan Midjich
http://swehack.se/cv
https://www.swehack.se/cv


More information about the freebsd-hackers mailing list