Re: underscores and function names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi ,

It would be nice if you could add the explanation 
in the FAQ at the kernelnewbies.org website .

More info here 
http://mail.nl.linux.org/kernelnewbies/2003-11/msg00014.html

Cheers !

--- Jan Hudec <bulb@xxxxxx> wrote:

> On Mon, Jan 03, 2005 at 10:46:49 -0800, Om wrote:
> > Michael R. Hines wrote:
> > >
> > >The ones with underscores usually have matching
> functions withOUT 
> > >underscores. They are meant to be private calls.
> > >
> > >The ones without underscores usually call the one
> with underscores, and 
> > >these are the ones that actually do the work.
> > >
> > >The kernel will sometimes call the underscore'd
> functions directly 
> > >because it knows what it's doing.......
> > >
> > >But while programming, we should generally call
> the ones without them.
> > Yes, unless we know what we do ;-)
> > for example, lets take arch/i386/lib/usercopy.c :
> copy_to_user(). This 
> > function performs some checks (access_ok()) on the
> passed parameter and 
> > then call the actual function that implements the
> functionlity 
> > include/asm/uaccess.h:__copy_to_user(). The
> implementation might use 
> > other functions as well.
> > 
> > If the target area is already checked for
> access_ok, then the caller 
> > call skip the call copy_to_user() and make a call
> directly to 
> > __copy_to_user(). This will save some time/code
> size.
> > 
> > I am not familiar with functions with single
> underscore starting. But 
> > the idea is same.
> 
> In fact I believe it's not. While __ means something
> like "bare bones
> version to use if you are sure you have made all
> sanity-checks and hold
> all the locks", _ rather means "this function isn't
> here". Symbols
> starting with one _ are traditionaly used for
> library symbols, that
> should have been static, but for some techical
> reason can't. I believe
> it's the same in kernel.
> 
>
-------------------------------------------------------------------------------
> 						 Jan 'Bulb' Hudec <bulb@xxxxxx>
> 

> ATTACHMENT part 2 application/pgp-signature
name=signature.asc




		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux