This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Resolve idempotency issue with libgomp's config.h/libgomp.h


On Wed, Apr 20, 2016 at 09:55:35AM +0200, Thomas Schwinge wrote:
> diff --git libgomp/config.h.in libgomp/config.h.in
> index 226ac53..1ef51ca 100644
> --- libgomp/config.h.in
> +++ libgomp/config.h.in
> @@ -1,5 +1,11 @@
>  /* config.h.in.  Generated from configure.ac by autoheader.  */
>  
> +
> +  #ifdef LIBGOMP_H
> +  # error Must not #include "config.h" after #include "libgomp.h".
> +  #endif
> +
> +
>  /* Define to 1 if the target assembler supports .symver directive. */
>  #undef HAVE_AS_SYMVER_DIRECTIVE

> --- libgomp/libgomp.h
> +++ libgomp/libgomp.h
> @@ -33,7 +33,12 @@
>     that are part of the external ABI, and the lower case prefix "gomp"
>     is used group items that are completely private to the library.  */
>  
> -#ifndef LIBGOMP_H 
> +#ifndef LIBGOMP_H
> +/* We #include "config.h" early, before we #define LIBGOMP_H, so that we can
> +   use the latter to check in "config.h" that it's not being included again,
> +   which might conflict with configuration changes done further down in
> +   libgomp.h.  */
> +#include "config.h"
>  #define LIBGOMP_H 1

The above breaks the multiple inclusion guards of libgomp.h, the
preprocessor will need to treat them as normal macros.
So IMNSHO it would be better to just use a different macro for this, keep
config.h included where it is now in libgomp.h and just make sure the macro
is defined after it.
Either use one of the many preexisting macros, like gomp_alloca, ...,
REFCOUNT_INFINITY, ... _LIBGOMP_OMP_LOCK_DEFINED, attribute_hidden, ...,
ialias, ..., or add one specially for this purpose.

Otherwise it is reasonable, but only for trunk and 6.2.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]