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

Re: Bug#162576: marked as done (libc6-dev: errno is a function call in non-threaded program)



reopen 162576
thanks

Too quick on the trigger finger, Ben.

On Fri, Sep 27, 2002 at 09:18:27AM -0500, Debian Bug Tracking System wrote:
> On Fri, Sep 27, 2002 at 08:55:30PM +1000, herbert@gondor.apana.org.au wrote:
> > Package: libc6-dev
> > Version: 2.2.5-14.3
> > Severity: minor
> > 
> > bits/errno.h defines errno to be a function call even when the application
> > has no need for threads at all.  This definition should be made conditional
> > so that non-threaded programs do not suffer the overhead of the function
> > call.
> 
> How do you figure?
> 
> # ifndef __ASSEMBLER__
> /* We now need a declaration of the `errno' variable.  */
> extern int errno;
> 
> /* Function to get address of global `errno' variable.  */
> extern int *__errno_location (void) __THROW __attribute__ ((__const__));
> 
> #  if defined _LIBC
> /* We wouldn't need a special macro anymore but it is history.  */
> #   define __set_errno(val) (*__errno_location ()) = (val)
> #  endif /* _LIBC */
> 
> #  if !defined _LIBC || defined _LIBC_REENTRANT
> /* When using threads, errno is a per-thread value.  */
> #   define errno (*__errno_location ())
> #  endif
> # endif /* !__ASSEMBLER__ */
> 
> Clearly it only gets defined as (*__errno_location ()) if we are not
> _LIBC (not the case for us ever) or _LIBC_REENTRANT is defined.
> 
> Now, -D_REENTRANT does not assume threads, but it does assume thread
> safe, so the definition is perfectly normal in that case (e.g. a module
> or library that does not use threads, being usable by a threaded program
> should use this). I don't think this is a bug at all.

_LIBC is only defined when _BUILDING_ glibc.  And _LIBC_REENTRANT !=
_REENTRANT.

Any application code will have !_LIBC.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



Reply to: