diff mbox

[17/19,v2] Use IS_IN only when _LIBC is defined

Message ID 20140828065509.GI8020@spoyarek.pnq.redhat.com
State New
Headers show

Commit Message

Siddhesh Poyarekar Aug. 28, 2014, 6:55 a.m. UTC
Hi,

Here's an updated patch that fixes conformtest failures due to IS_IN.
The conformtest tests ideally ought to include the headers to be
installed, but cannot do so currently and hence does its tests using
headers in include/.  Due to this it fails because it doesn't include
any of the libc headers and consequently does not have a definition
for IS_IN.  This patch guards instances in such headers with #ifdef
_LIBC.

There are a couple of installed headers that have this problem too -
stdio-lock.h and libc-lock.h.  Both headers however never get used in
normal applications since they're only included when _IO_MTSAFE_IO is
defined, which it isn't in the normal case.  I haven't tried to fix
these headers because it won't make a difference and ideally they
ought to be removed.  I intend to do that as a separate patch after
2.20 is released.

I have also verified that this does not result in any change in
generated code on x86_64.

Siddhesh

From 00592dd98e35bc9771d17114f9c1da62368f8488 Mon Sep 17 00:00:00 2001
From: Siddhesh Poyarekar <siddhesh@redhat.com>
Date: Mon, 25 Aug 2014 15:58:46 +0530
Subject: [PATCH] Use IS_IN when _LIBC is defined

This change is only useful for the conformance tests since the headers
changed are not installed.  The conformance tests fail due to IS_IN
not being defined, so wrap it with a check to make sure that _LIBC is
defined.

	* include/bits/stdlib-float.h: Use IS_IN only if _LIBC is
	defined.
	* include/mqueue.h: Likewise.
	* include/stdlib.h: Likewise.
---
 include/bits/stdlib-float.h |  6 ++++--
 include/mqueue.h            |  4 +++-
 include/stdlib.h            | 10 ++++++----
 3 files changed, 13 insertions(+), 7 deletions(-)

Comments

Joseph Myers Aug. 28, 2014, 4:58 p.m. UTC | #1
On Thu, 28 Aug 2014, Siddhesh Poyarekar wrote:

> diff --git a/include/bits/stdlib-float.h b/include/bits/stdlib-float.h
> index 3466314..debb364 100644
> --- a/include/bits/stdlib-float.h
> +++ b/include/bits/stdlib-float.h
> @@ -1,4 +1,6 @@
>  /* No floating-point inline functions in rtld.  */
> -#if !IS_IN (rtld)
> -# include <stdlib/bits/stdlib-float.h>
> +#ifdef _LIBC
> +# if !IS_IN (rtld)
> +#  include <stdlib/bits/stdlib-float.h>
> +# endif
>  #endif

That seems wrong - it would mean that <stdlib/bits/stdlib-float.h> doesn't 
get included at all unless _LIBC.  But <stdlib/bits/stdlib-float.h> should 
be included for the conformance tests, because it would be included for a 
normal user build (by virtue of being installed as <bits/stdlib-float.h>).

So you could include this header for _ISOMAC (for example), in addition to 
a #else / #if !IS_IN (rtld) case.

> diff --git a/include/mqueue.h b/include/mqueue.h
> index aba788e..e40f3cb 100644
> --- a/include/mqueue.h
> +++ b/include/mqueue.h
> @@ -1,7 +1,9 @@
>  #include <rt/mqueue.h>
>  
> -#if IS_IN (librt)
> +#ifdef _LIBC
> +# if IS_IN (librt)
>  hidden_proto (mq_timedsend)
>  hidden_proto (mq_timedreceive)
>  hidden_proto (mq_setattr)
> +# endif
>  #endif

Normally, #ifndef _ISOMAC would be the conditional around such extra 
internal-only contents (and then #if IS_IN (librt) could go inside the 
!_ISOMAC case).

> diff --git a/include/stdlib.h b/include/stdlib.h
> index 734f251..a884b51 100644
> --- a/include/stdlib.h
> +++ b/include/stdlib.h
> @@ -226,11 +226,13 @@ extern int __qfcvt_r (long double __value, int __ndigit,
>  		      int *__restrict __decpt, int *__restrict __sign,
>  		      char *__restrict __buf, size_t __len);
>  
> -# if IS_IN (libc)
> -#  undef MB_CUR_MAX
> -#  define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX))
> +# if defined _LIBC
> +#  if IS_IN (libc)
> +#   undef MB_CUR_MAX
> +#   define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX))
>  
> -# define __cxa_atexit(func, arg, d) INTUSE(__cxa_atexit) (func, arg, d)
> +#   define __cxa_atexit(func, arg, d) INTUSE(__cxa_atexit) (func, arg, d)
> +#  endif
>  # endif

Why do you need this?  Aren't you already inside a !defined _ISOMAC case?
Roland McGrath Nov. 7, 2014, 11:33 p.m. UTC | #2
Use #if defined _LIBC && IS_IN (...) rather than nesting.
Otherwise OK.
Siddhesh Poyarekar Nov. 18, 2014, 1:54 p.m. UTC | #3
On Fri, Nov 07, 2014 at 03:33:33PM -0800, Roland McGrath wrote:
> Use #if defined _LIBC && IS_IN (...) rather than nesting.
> Otherwise OK.

That doesn't work - the compiler complains about IS_IN not being
defined.  That is why I had to nest it.

Siddhesh
Siddhesh Poyarekar Nov. 18, 2014, 1:55 p.m. UTC | #4
On Tue, Nov 18, 2014 at 07:24:45PM +0530, Siddhesh Poyarekar wrote:
> On Fri, Nov 07, 2014 at 03:33:33PM -0800, Roland McGrath wrote:
> > Use #if defined _LIBC && IS_IN (...) rather than nesting.
> > Otherwise OK.
> 
> That doesn't work - the compiler complains about IS_IN not being
> defined.  That is why I had to nest it.

s/compiler/preprocessor/ of course.

Siddhesh
Roland McGrath Nov. 18, 2014, 6:42 p.m. UTC | #5
I see.  I was not expecting such an error because it doesn't give one for
"#if defined notdefined && alsonotdefined" but evidently the function-like
macro case is different.
Andreas Schwab Nov. 18, 2014, 7:53 p.m. UTC | #6
Roland McGrath <roland@hack.frob.com> writes:

> I see.  I was not expecting such an error because it doesn't give one for
> "#if defined notdefined && alsonotdefined" but evidently the function-like
> macro case is different.

The problem is that all remaining identifiers are replaced by 0 before
the expression is evaluated, thus resulting in a non-syntactical
expression.

Andreas.
diff mbox

Patch

diff --git a/include/bits/stdlib-float.h b/include/bits/stdlib-float.h
index 3466314..debb364 100644
--- a/include/bits/stdlib-float.h
+++ b/include/bits/stdlib-float.h
@@ -1,4 +1,6 @@ 
 /* No floating-point inline functions in rtld.  */
-#if !IS_IN (rtld)
-# include <stdlib/bits/stdlib-float.h>
+#ifdef _LIBC
+# if !IS_IN (rtld)
+#  include <stdlib/bits/stdlib-float.h>
+# endif
 #endif
diff --git a/include/mqueue.h b/include/mqueue.h
index aba788e..e40f3cb 100644
--- a/include/mqueue.h
+++ b/include/mqueue.h
@@ -1,7 +1,9 @@ 
 #include <rt/mqueue.h>
 
-#if IS_IN (librt)
+#ifdef _LIBC
+# if IS_IN (librt)
 hidden_proto (mq_timedsend)
 hidden_proto (mq_timedreceive)
 hidden_proto (mq_setattr)
+# endif
 #endif
diff --git a/include/stdlib.h b/include/stdlib.h
index 734f251..a884b51 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -226,11 +226,13 @@  extern int __qfcvt_r (long double __value, int __ndigit,
 		      int *__restrict __decpt, int *__restrict __sign,
 		      char *__restrict __buf, size_t __len);
 
-# if IS_IN (libc)
-#  undef MB_CUR_MAX
-#  define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX))
+# if defined _LIBC
+#  if IS_IN (libc)
+#   undef MB_CUR_MAX
+#   define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX))
 
-# define __cxa_atexit(func, arg, d) INTUSE(__cxa_atexit) (func, arg, d)
+#   define __cxa_atexit(func, arg, d) INTUSE(__cxa_atexit) (func, arg, d)
+#  endif
 # endif
 
 extern void *__default_morecore (ptrdiff_t) __THROW;