bug-gnulib
[Top][All Lists]
Advanced

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

Re: lock module question


From: Simon Josefsson
Subject: Re: lock module question
Date: Thu, 06 Mar 2008 10:45:26 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux)

Bruno Haible <address@hidden> writes:

>> Using -pthread allow option like -D_REENTRANT to be defined when
>> compiling Gnulib, which sound like a requirement if the program using
>> Gnulib is multithreaded.
>
> Neither -pthread nor -D_REENTRANT is a requirement for building multithreaded
> programs on Linux with glibc.
>
> On platforms where it is needed (OSF/1 and Solaris), the 'lock' module adds
> -D_REENTRANT to the CPPFLAGS. Make sure to use both CFLAGS and CPPFLAGS in
> your compilation commands; these is automatically done if you use automake.

Hm.  lock.m4 contains:

    # For using <pthread.h>:
    case "$host_os" in
      osf*)
        # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
        # groks <pthread.h>. cc also understands the flag -pthread, but
        # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
        # 2. putting a flag into CPPFLAGS that has an effect on the linker
        # causes the AC_TRY_LINK test below to succeed unexpectedly,
        # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
        CPPFLAGS="$CPPFLAGS -D_REENTRANT"
        ;;
    esac

This seems to imply that if I don't use pthread.h, I won't find
-D_REENTRANT useful, except for possibly the next statement:

    # Some systems optimize for single-threaded programs by default, and
    # need special flags to disable these optimizations. For example, the
    # definition of 'errno' in <errno.h>.
    case "$host_os" in
      aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
      solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
    esac

Do you know any operating system manuals that document this?  I'm trying
to understand precisely when I need to use any of these flags.

Generally, if some systems need -D_REENTRANT to get a usable errno,
wouldn't that be something we could write a gnulib module for?

/Simon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]