This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: [PATCH] fix include files to support non-GNU compilers



On Mon, 1 Sep 2014, Joseph S. Myers wrote:

> On Sun, 31 Aug 2014, Mikulas Patocka wrote:
> 
> > @@ -40,6 +42,8 @@
> >  
> >  #ifdef __WCHAR_MIN__
> >  # define __WCHAR_MIN	__WCHAR_MIN__
> > +#elif defined(__DECC)
> > +# define __WCHAR_MAX	(-__WCHAR_MAX - 1)
> 
> That seems wrong (defining __WCHAR_MAX in the section of code that should 
> be defining __WCHAR_MIN).
> 
> For the __align issue, you should use __glibc_align, as per the 
> __glibc_block precedent.

OK. Here I'm sending version 3 of the patch.




stdio.h: egcs doesn't respond to _VA_LIST_DEFINED. We only use this code
path on reasonably new gcc.

limits.h: __LONG_LONG_MAX__ is not defined by egcs. So we can't use it in
the definition of LLONG_MAX.

math.h: __REDIRECT_NTH is not defined on non-GNU compilers. In this case,
we don't declare long double redirection and instead declare a dummy
"struct __empty__declaration__" (we must declare something because C
doesn't allow stray semicolon in the program).

alpha-linux-gnu/sys/cdefs.h: for non-GNU compilers, we must define empty
__LDBL_REDIR1_DECL

alpha-linux-gnu/bits/wchar-ldbl.h: remove spurious semicolons. The
semicolon already exists at the end of __LDBL_REDIR_DECL and
__LDBL_REDIR1_DECL definition.

alpha-linux-gnu/bits/wchar.h: DEC C doesn't handle L'\0' in preprocessor
expression.

alpha-linux-gnu/bits/pthreadtypes.h:
alpha-linux-gnu/bits/semaphore.h:
netinet/in.h: __align is a keyword for the DEC C compiler. Use
__glibc_align instead.

---
 bits/wchar.h                                      |    4 +++
 include/limits.h                                  |    6 +++-
 inet/netinet/in.h                                 |    2 -
 libio/stdio.h                                     |    3 +-
 math/math.h                                       |    7 ++++-
 misc/sys/cdefs.h                                  |    1 
 sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h |   18 +++++++-------
 sysdeps/unix/sysv/linux/alpha/bits/semaphore.h    |    2 -
 wcsmbs/bits/wchar-ldbl.h                          |   28 +++++++++++-----------
 9 files changed, 43 insertions(+), 28 deletions(-)

Index: glibc/libio/stdio.h
===================================================================
--- glibc.orig/libio/stdio.h
+++ glibc/libio/stdio.h
@@ -74,7 +74,7 @@ typedef struct _IO_FILE __FILE;
 #include <libio.h>
 
 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
-# ifdef __GNUC__
+# if defined __GNUC__ && __GNUC__ >= 3
 #  ifndef _VA_LIST_DEFINED
 typedef _G_va_list va_list;
 #   define _VA_LIST_DEFINED
Index: glibc/include/limits.h
===================================================================
--- glibc.orig/include/limits.h
+++ glibc/include/limits.h
@@ -131,7 +131,11 @@
 #  define LLONG_MIN	(-LLONG_MAX-1)
 # endif
 # ifndef LLONG_MAX
-#  define LLONG_MAX	__LONG_LONG_MAX__
+#  ifdef __LONG_LONG_MAX__
+#   define LLONG_MAX	__LONG_LONG_MAX__
+#  else
+#   define LLONG_MAX	9223372036854775807LL
+#  endif
 # endif
 # ifndef ULLONG_MAX
 #  define ULLONG_MAX	(LLONG_MAX * 2ULL + 1)
Index: glibc/math/math.h
===================================================================
--- glibc.orig/math/math.h
+++ glibc/math/math.h
@@ -111,9 +111,14 @@ extern long double __REDIRECT_NTH (nextt
 #   endif
 
 #   undef __MATHDECL_1
-#   define __MATHDECL_2(type, function,suffix, args, alias) \
+#   ifdef __REDIRECT_NTH
+#    define __MATHDECL_2(type, function,suffix, args, alias) \
   extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
 			     args, alias)
+#   else
+#    define __MATHDECL_2(type, function,suffix, args, alias) \
+		struct __empty__declaration__
+#   endif
 #   define __MATHDECL_1(type, function,suffix, args) \
   __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
 #  endif
Index: glibc/misc/sys/cdefs.h
===================================================================
--- glibc.orig/misc/sys/cdefs.h
+++ glibc/misc/sys/cdefs.h
@@ -419,6 +419,7 @@
 # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
 # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
 # define __LDBL_REDIR_DECL(name)
+# define __LDBL_REDIR1_DECL(name, alias)
 # ifdef __REDIRECT
 #  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
 #  define __REDIRECT_NTH_LDBL(name, proto, alias) \
Index: glibc/wcsmbs/bits/wchar-ldbl.h
===================================================================
--- glibc.orig/wcsmbs/bits/wchar-ldbl.h
+++ glibc/wcsmbs/bits/wchar-ldbl.h
@@ -22,12 +22,12 @@
 
 #if defined __USE_ISOC95 || defined __USE_UNIX98
 __BEGIN_NAMESPACE_C99
-__LDBL_REDIR_DECL (fwprintf);
-__LDBL_REDIR_DECL (wprintf);
-__LDBL_REDIR_DECL (swprintf);
-__LDBL_REDIR_DECL (vfwprintf);
-__LDBL_REDIR_DECL (vwprintf);
-__LDBL_REDIR_DECL (vswprintf);
+__LDBL_REDIR_DECL (fwprintf)
+__LDBL_REDIR_DECL (wprintf)
+__LDBL_REDIR_DECL (swprintf)
+__LDBL_REDIR_DECL (vfwprintf)
+__LDBL_REDIR_DECL (vwprintf)
+__LDBL_REDIR_DECL (vswprintf)
 # if defined __USE_ISOC99 && !defined __USE_GNU \
      && !defined __REDIRECT \
      && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
@@ -35,31 +35,31 @@ __LDBL_REDIR1_DECL (fwscanf, __nldbl___i
 __LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf)
 __LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf)
 # else
-__LDBL_REDIR_DECL (fwscanf);
-__LDBL_REDIR_DECL (wscanf);
-__LDBL_REDIR_DECL (swscanf);
+__LDBL_REDIR_DECL (fwscanf)
+__LDBL_REDIR_DECL (wscanf)
+__LDBL_REDIR_DECL (swscanf)
 # endif
 __END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_ISOC99
 __BEGIN_NAMESPACE_C99
-__LDBL_REDIR1_DECL (wcstold, wcstod);
+__LDBL_REDIR1_DECL (wcstold, wcstod)
 # if !defined __USE_GNU && !defined __REDIRECT \
      && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
 __LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf)
 __LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf)
 __LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf)
 # else
-__LDBL_REDIR_DECL (vfwscanf);
-__LDBL_REDIR_DECL (vwscanf);
-__LDBL_REDIR_DECL (vswscanf);
+__LDBL_REDIR_DECL (vfwscanf)
+__LDBL_REDIR_DECL (vwscanf)
+__LDBL_REDIR_DECL (vswscanf)
 # endif
 __END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_GNU
-__LDBL_REDIR1_DECL (wcstold_l, wcstod_l);
+__LDBL_REDIR1_DECL (wcstold_l, wcstod_l)
 #endif
 
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
Index: glibc/bits/wchar.h
===================================================================
--- glibc.orig/bits/wchar.h
+++ glibc/bits/wchar.h
@@ -32,6 +32,8 @@
 
 #ifdef __WCHAR_MAX__
 # define __WCHAR_MAX	__WCHAR_MAX__
+#elif defined __DECC
+# define __WCHAR_MAX	0x7fffffff
 #elif L'\0' - 1 > 0
 # define __WCHAR_MAX	(0xffffffffu + L'\0')
 #else
@@ -40,6 +42,8 @@
 
 #ifdef __WCHAR_MIN__
 # define __WCHAR_MIN	__WCHAR_MIN__
+#elif defined __DECC
+# define __WCHAR_MIN	(-__WCHAR_MAX - 1)
 #elif L'\0' - 1 > 0
 # define __WCHAR_MIN	(L'\0' + 0)
 #else
Index: glibc/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
===================================================================
--- glibc.orig/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
+++ glibc/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
@@ -38,7 +38,7 @@ typedef unsigned long int pthread_t;
 union pthread_attr_t
 {
   char __size[__SIZEOF_PTHREAD_ATTR_T];
-  long int __align;
+  long int __glibc_align;
 };
 #ifndef __have_pthread_attr_t
 typedef union pthread_attr_t pthread_attr_t;
@@ -70,7 +70,7 @@ typedef union
 #define __PTHREAD_MUTEX_HAVE_PREV	1
   } __data;
   char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
+  long int __glibc_align;
 } pthread_mutex_t;
 
 /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
@@ -79,7 +79,7 @@ typedef union
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
-  int __align;
+  int __glibc_align;
 } pthread_mutexattr_t;
 
 
@@ -99,13 +99,13 @@ typedef union
     unsigned int __broadcast_seq;
   } __data;
   char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
+  __extension__ long long int __glibc_align;
 } pthread_cond_t;
 
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
-  int __align;
+  int __glibc_align;
 } pthread_condattr_t;
 
 
@@ -139,7 +139,7 @@ typedef union
     unsigned int __flags;
   } __data;
   char __size[__SIZEOF_PTHREAD_RWLOCK_T];
-  long int __align;
+  long int __glibc_align;
 } pthread_rwlock_t;
 
 #define __PTHREAD_RWLOCK_ELISION_EXTRA 0
@@ -147,7 +147,7 @@ typedef union
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
-  long int __align;
+  long int __glibc_align;
 } pthread_rwlockattr_t;
 #endif
 
@@ -161,13 +161,13 @@ typedef volatile int pthread_spinlock_t;
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_BARRIER_T];
-  long int __align;
+  long int __glibc_align;
 } pthread_barrier_t;
 
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
-  int __align;
+  int __glibc_align;
 } pthread_barrierattr_t;
 #endif
 
Index: glibc/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h
===================================================================
--- glibc.orig/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h
+++ glibc/sysdeps/unix/sysv/linux/alpha/bits/semaphore.h
@@ -29,5 +29,5 @@
 typedef union
 {
   char __size[__SIZEOF_SEM_T];
-  long int __align;
+  long int __glibc_align;
 } sem_t;
Index: glibc/inet/netinet/in.h
===================================================================
--- glibc.orig/inet/netinet/in.h
+++ glibc/inet/netinet/in.h
@@ -567,8 +567,8 @@ extern int inet6_option_find (const stru
 /* Hop-by-Hop and Destination Options Processing (RFC 3542).  */
 extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __THROW;
 extern int inet6_opt_append (void *__extbuf, socklen_t __extlen, int __offset,
-			     uint8_t __type, socklen_t __len, uint8_t __align,
-			     void **__databufp) __THROW;
+			     uint8_t __type, socklen_t __len,
+			     uint8_t __glibc_align, void **__databufp) __THROW;
 extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __offset)
      __THROW;
 extern int inet6_opt_set_val (void *__databuf, int __offset, void *__val,


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