Re: double underscores

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

 



On Tue, Jun 04, 2002 at 02:17:01PM -0500, Little, John wrote:
> why do some functions begin with double underscores?

Identifiers starting with an underscore are reserved for the C
implementation. Since the kernel doesn't use too much of the C
implementation (run time support.. libgcc, libcrt, perhaps), someone
decided that names beginning with an underscore was probably a safe
enough way to mark some functions as dangerous and for internal use
only.

You'll often see functions named like this:
 function ()
 __function ()

where the function() simply does some sanity checks on input before
calling __function (). It is done for speed reasons: if you've checked
that the inputs are sane and safe, you can call the __ version. If you
haven't, you should call the normal version, and let it do the checking.

As far as I know, this isn't a codified practice, so I wouldn't suggest
relying on it, unless you've looked at both versions, and are fairly
certain your checks are sufficient...

-- 
http://www.wirex.com/

Attachment: pgp00087.pgp
Description: PGP 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