Re: underscores and function names

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

 



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: signature.asc
Description: Digital signature


[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