MT-safe EH AIX patch

David Edelsohn dje@watson.ibm.com
Tue Dec 9 08:27:00 GMT 1997


>>>>> Teemu Torma writes:

> Is the _PTHREADS macro required by POSIX?  That macro is not set
> by AIX but _THREAD_SAFE is.  Would it be possible for you to test for the
> standard AIX macro instead of polluting the AIX macro namespace?

Teemu> No, but since libstdc++ uses it already, I thought of using the same.
Teemu> Besides, the macro should be something that is not defined by system
Teemu> so that we can compile multilibs with and without threads.
    
	I thought that GCC was suppose to behave like the standard system
compiler, including its use of macro namespace.  Included in the patches
for MT-safe EH is a change for AIX to emit -D_PTHREADS.  Is this the
preferred solution or should the package testing the macro solve the
problem?  Two possible solutions:

	#if defined(_PTHREADS) || defined(_THREAD_SAFE)

*or*

	#if defined(_AIX41) && defined(_THREAD_SAFE)
	#define _PTHREADS
	#endif

I think that the latter is the cleaner solution for a number of reasons:
If IBM's XLC in re-entrant mode is used to compile libstdc++, threading
will be recognized correctly.  GCC can safely define the _PTHREADS macro
because is reserved to system, so it should not be defined by others.
However, some application might code for _PTHREADS and _THREAD_SAFE
differently to distinguish between AIX and another system; GCC defining
both will break the app.

	Is there a general policy on this?  Should the compiler define
macros to satisfy tests in a library or should the library test any and
all necessary macros?

David



More information about the Gcc mailing list