Source-Changes-HG archive

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

[src/trunk]: src Define a new __c99inline macro for compilers known to implem...



details:   https://anonhg.NetBSD.org/src/rev/607a47794521
branches:  trunk
changeset: 756738:607a47794521
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Jul 31 00:04:42 2010 +0000

description:
Define a new __c99inline macro for compilers known to implement the C99
behavior.  This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.

diffstat:

 include/signal.h         |  29 +++++++++++++----------------
 lib/libc/gen/sigsetops.c |   6 +++---
 sys/sys/cdefs.h          |  19 ++++++++++++++++++-
 3 files changed, 34 insertions(+), 20 deletions(-)

diffs (138 lines):

diff -r d514600cb447 -r 607a47794521 include/signal.h
--- a/include/signal.h  Fri Jul 30 21:10:44 2010 +0000
+++ b/include/signal.h  Sat Jul 31 00:04:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: signal.h,v 1.52 2010/05/04 09:07:11 plunky Exp $       */
+/*     $NetBSD: signal.h,v 1.53 2010/07/31 00:04:42 joerg Exp $        */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -87,7 +87,12 @@
     __RENAME(__sigprocmask14);
 int    sigsuspend(const sigset_t *) __RENAME(__sigsuspend14);
 
-#if (defined(__GNUC__) && defined(__STDC__)) || defined(_SIGINLINE)
+#if defined(__c99inline) || defined(__SIGSETOPS_BODY)
+
+#if defined(__SIGSETOPS_BODY)
+#undef __c99inline
+#define        __c99inline
+#endif
 
 /* note: this appears in both errno.h and signal.h */
 #ifndef __errno
@@ -100,15 +105,7 @@
 #define ___errno (*__errno())
 #endif
 
-#ifndef _SIGINLINE
-#if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
-#define _SIGINLINE extern __inline
-#else
-#define _SIGINLINE __inline
-#endif
-#endif
-
-_SIGINLINE int
+__c99inline int
 sigaddset(sigset_t *set, int signo)
 {
        if (signo <= 0 || signo >= _NSIG) {
@@ -119,7 +116,7 @@
        return (0);
 }
 
-_SIGINLINE int
+__c99inline int
 sigdelset(sigset_t *set, int signo)
 {
        if (signo <= 0 || signo >= _NSIG) {
@@ -130,7 +127,7 @@
        return (0);
 }
 
-_SIGINLINE int
+__c99inline int
 sigismember(const sigset_t *set, int signo)
 {
        if (signo <= 0 || signo >= _NSIG) {
@@ -140,20 +137,20 @@
        return (__sigismember(set, signo));
 }
 
-_SIGINLINE int
+__c99inline int
 sigemptyset(sigset_t *set)
 {
        __sigemptyset(set);
        return (0);
 }
 
-_SIGINLINE int
+__c99inline int
 sigfillset(sigset_t *set)
 {
        __sigfillset(set);
        return (0);
 }
-#endif /* (__GNUC__ && __STDC__) || _SIGINLINE */
+#endif /* __c99inline */
 #endif /* !__LIBC12_SOURCE__ */
 
 /*
diff -r d514600cb447 -r 607a47794521 lib/libc/gen/sigsetops.c
--- a/lib/libc/gen/sigsetops.c  Fri Jul 30 21:10:44 2010 +0000
+++ b/lib/libc/gen/sigsetops.c  Sat Jul 31 00:04:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sigsetops.c,v 1.15 2005/09/13 01:44:09 christos Exp $  */
+/*     $NetBSD: sigsetops.c,v 1.16 2010/07/31 00:04:43 joerg Exp $     */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -36,11 +36,11 @@
 #if 0
 static char sccsid[] = "@(#)sigsetops.c        8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: sigsetops.c,v 1.15 2005/09/13 01:44:09 christos Exp $");
+__RCSID("$NetBSD: sigsetops.c,v 1.16 2010/07/31 00:04:43 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
-#define        _SIGINLINE
+#define        __SIGSETOPS_BODY
 
 #include <errno.h>
 #include <signal.h>
diff -r d514600cb447 -r 607a47794521 sys/sys/cdefs.h
--- a/sys/sys/cdefs.h   Fri Jul 30 21:10:44 2010 +0000
+++ b/sys/sys/cdefs.h   Sat Jul 31 00:04:42 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdefs.h,v 1.78 2009/10/02 21:05:28 christos Exp $      */
+/*     $NetBSD: cdefs.h,v 1.79 2010/07/31 00:04:43 joerg Exp $ */
 
 /*
  * Copyright (c) 1991, 1993
@@ -228,6 +228,23 @@
 #define        __used          __unused
 #endif
 
+/*
+ * Non-static C99 inline functions are optional bodies.  They don't
+ * create global symbols if not used, but can be replaced if desirable.
+ * This differs from the behavior of GCC before version 4.3.  The nearest
+ * equivalent for older GCC is `extern inline'.  For newer GCC, use the
+ * gnu_inline attribute additionally to get the old behavior.
+ *
+ * For C99 compilers other than GCC, the C99 behavior is expected.
+ */
+#if defined(__GNUC__) && defined(__GNUC_STDC_INLINE__)
+#define        __c99inline     extern __attribute__((__gnu_inline__)) __inline
+#elif defined(__GNUC__)
+#define        __c99inline     extern __inline
+#elif defined(__STDC_VERSION__)
+#define        __c99inline     __inline
+#endif
+
 #if defined(__lint__)
 #define        __packed        __packed
 #define        __aligned(x)    /* delete */



Home | Main Index | Thread Index | Old Index