gnustep-dev
[Top][All Lists]
Advanced

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

Re: fix for 30094 breaks HURD compilation again


From: Yavor Doganov
Subject: Re: fix for 30094 breaks HURD compilation again
Date: Fri, 11 Jun 2010 12:54:23 +0300
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/23.1 (i486-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Riccardo Mottola wrote:
> Yavor's patch is in theory correct, but in practice wrong. GLIBC is a 
> mess to work with.

It becomes a mess if you start playing with defines, yes.
Furthermore, you have to adjust them for every new porting target.

> I already tried to make the original code which used __USE_UNIX98
> more portable.

...and which will break every time Mr.Drepper & co decide to do
something different with it.  Using internal glibc macros/defines is a
bad idea.

> now using __GLIBC__ causes troubles on Hurd with GCC (and possibly other 
> platforms which I don't remember),

The Debian archive is full of code like this, so it's strange that it
causes trouble.  What is the specific error?

> Else I think I will revert the check to my version, which was very
> proven.

How about a simple and more portable solution like the attached patch?
-D_GNU_SOURCE has no effect on other systems, and no matter how the
glibc developers reorganize their headers/definitions, it will always
work.

This approach is used in many packages (GNU and non-GNU) and is known
to work accross many platforms.

Also, I notice something fishy here (in GSPThread.h):
PTHREAD_RECURSIVE_MUTEX_INITIALIZER(_NP) is available on all GNU
systems, but since XOPEN_SOURCE is defined, it is never used.  So the
GS_INIT_RECURSIVE_MUTEX conditionional definition is kinda useless,
because GSPThreadInitRecursiveMutex will always be used.

Please test the patch on all systems you have access to; thanks.
=== modified file 'Source/GSPThread.h'
--- Source/GSPThread.h  2010-03-25 22:53:21 +0000
+++ Source/GSPThread.h  2010-06-11 09:31:54 +0000
@@ -23,19 +23,6 @@
 #ifndef _GSPThread_h_
 #define _GSPThread_h_
 
-/*
- * Since glibc does not enable Unix98 extensions by default, we need to tell it
- * to do so explicitly. That support is switched on by _XOPEN_SOURCE and
- * __USE_UNIX98 is an internal flag which can cause trouble if enabled alone.
- * For safety we enable this only on linux and hurd where glibc is likely.
- * We include features.h explicitely to avoid weird problems.
- */
-#if defined __linux__ || defined __GNU__
-#  ifndef _XOPEN_SOURCE
-#    define _XOPEN_SOURCE 600
-#  endif
-#endif
-
 #include <pthread.h>
 
 /*
@@ -43,9 +30,9 @@
  * libobjc2 (lock.h).
  */
 #      ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
-#              define GS_INIT_RECURSIVE_MUTEX(x) x = 
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#              define GS_INIT_RECURSIVE_MUTEX(x) x = (pthread_mutex_t) 
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
 #      elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER)
-#              define GS_INIT_RECURSIVE_MUTEX(x) x = 
PTHREAD_RECURSIVE_MUTEX_INITIALIZER
+#              define GS_INIT_RECURSIVE_MUTEX(x) x = (pthread_mutex_t) 
PTHREAD_RECURSIVE_MUTEX_INITIALIZER
 #      else
 #              define GS_INIT_RECURSIVE_MUTEX(x) 
GSPThreadInitRecursiveMutex(&(x))
 

=== modified file 'Source/NSDecimal.m'
--- Source/NSDecimal.m  2010-02-19 08:12:46 +0000
+++ Source/NSDecimal.m  2010-06-10 21:37:46 +0000
@@ -27,7 +27,6 @@
    */
 
 #import "common.h"
-#define _GNU_SOURCE
 #include <math.h>
 #if !defined(__APPLE__) || !defined(GNU_RUNTIME)
 #include <ctype.h>

=== modified file 'Source/NSDecimalNumber.m'
--- Source/NSDecimalNumber.m    2010-04-14 11:37:23 +0000
+++ Source/NSDecimalNumber.m    2010-06-10 21:46:25 +0000
@@ -26,10 +26,6 @@
    $Date$ $Revision$
    */
 
-/* Need to include math.h with C99 option ... do before common.h
- */
-#define _GNU_SOURCE
-#define _ISOC99_SOURCE
 #include <math.h>
 
 #import "common.h"

=== modified file 'Source/NSException.m'
--- Source/NSException.m        2010-03-19 12:10:11 +0000
+++ Source/NSException.m        2010-06-10 21:44:46 +0000
@@ -121,12 +121,6 @@
 #endif  /* USE_BINUTILS */
 #else  /* __MINGW__ */
 
-#ifndef GNU_SOURCE
-#define GNU_SOURCE
-#endif
-#ifndef __USE_GNU
-#define __USE_GNU
-#endif
 #include <dlfcn.h>
 
 #if    defined(USE_BINUTILS)

=== modified file 'Source/NSLock.m'
--- Source/NSLock.m     2010-03-25 22:53:21 +0000
+++ Source/NSLock.m     2010-06-10 21:29:42 +0000
@@ -22,16 +22,7 @@
    <ignore> All autogsdoc markup is in the header
 */
 
-
-// This file uses some SUS'98 extensions, so we need to tell glibc not to hide
-// them.  Other platforms have more sensible libcs, which just default to being
-// standards-compliant.
-#if defined __linux__ || defined __GNU__
-#  ifndef _XOPEN_SOURCE
-#    define _XOPEN_SOURCE 600
-#  endif
-#endif
-
+#import "common.h"
 
 #include <pthread.h>
 #import "GNUstepBase/GSConfig.h"
@@ -45,8 +36,6 @@
 #define        EXPOSE_NSCondition_IVARS        1
 #define        EXPOSE_NSConditionLock_IVARS    1
 
-#import "common.h"
-
 #import "Foundation/NSLock.h"
 #import "Foundation/NSException.h"
 

=== modified file 'Source/NSString.m'
--- Source/NSString.m   2010-06-10 04:04:55 +0000
+++ Source/NSString.m   2010-06-10 21:45:08 +0000
@@ -43,11 +43,6 @@
    Limited choice of default encodings.
 */
 
-/* Needed for visiblity of fwprintf prototype.  */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
 #import "common.h"
 #include <stdio.h>
 #include <string.h>

=== modified file 'Source/NSZone.m'
--- Source/NSZone.m     2010-03-25 22:53:21 +0000
+++ Source/NSZone.m     2010-06-11 09:25:43 +0000
@@ -86,16 +86,6 @@
 
 #define IN_NSZONE_M 1
 
-/* we define _XOPEN_SOURCE to get all the necessary pthread attributes
- * and we need to define it here and not just in GSPThread.h because
- * GLIBC is so picky with defines */
-#if defined __linux__ || defined __GNU__
-#  ifndef _XOPEN_SOURCE
-#    define _XOPEN_SOURCE 600
-#  endif
-#endif
-
-
 #import "common.h"
 #include <stddef.h>
 #include <string.h>

=== modified file 'Source/ObjectiveC2/sync.m'
--- Source/ObjectiveC2/sync.m   2010-06-09 12:26:22 +0000
+++ Source/ObjectiveC2/sync.m   2010-06-10 21:16:38 +0000
@@ -1,10 +1,4 @@
-/* Ensure Unix98 compatible pthreads for glibc */
-#if defined __linux__ || defined __GNU__ || defined __GLIBC__
-#  ifndef _XOPEN_SOURCE
-#    define _XOPEN_SOURCE 600
-#  endif
-#endif
-
+#include "config.h"
 #include "ObjectiveC2/runtime.h"
 
 #include <pthread.h>

=== modified file 'Source/objc-load.m'
--- Source/objc-load.m  2010-03-19 12:10:11 +0000
+++ Source/objc-load.m  2010-06-10 21:24:48 +0000
@@ -32,12 +32,6 @@
 
 #import "common.h"
 
-#ifdef HAVE_DLADDR
-/* Define _GNU_SOURCE because that is required with GNU libc in order
- * to have dladdr() available.  */
-# define _GNU_SOURCE
-#endif
-
 #include <stdio.h>
 #include <objc/objc-api.h>
 #ifndef NeXT_RUNTIME


=== modified file 'configure.ac'
--- configure.ac        2010-06-10 08:51:40 +0000
+++ configure.ac        2010-06-10 21:15:54 +0000
@@ -32,6 +32,7 @@
 builtin(include, config/addlibrarypath.m4)dnl
 
 AC_INIT
+AC_PREREQ([2.60])
 AC_CONFIG_SRCDIR([Source/NSArray.m])
 
 # If GNUSTEP_MAKEFILES is undefined, try to use gnustep-config to determine it.
@@ -978,6 +979,7 @@
 #--------------------------------------------------------------------
 AC_PROG_CC
 AC_PROG_CPP
+AC_USE_SYSTEM_EXTENSIONS
 
 AC_PATH_PROG(WHOAMI, whoami, echo, $PATH:/usr/ucb)
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]