gnustep-dev
[Top][All Lists]
Advanced

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

Re: Thread question


From: Philippe Roussel
Subject: Re: Thread question
Date: Mon, 07 Mar 2011 11:16:37 +0100

[Adding Daving to Cc]

Le lundi 07 mars 2011 à 09:28 +0000, Richard Frith-Macdonald a écrit :
> On 7 Mar 2011, at 09:04, Philippe Roussel wrote:
> 
> > Hi
> > 
> > Le samedi 05 mars 2011 à 17:06 +0000, Richard Frith-Macdonald a écrit :
> > 
> >> I added a configure-time check in gnustep-base to detect objc runtime 
> >> libraries which don't support +initialise properly and warn about them.
> >> I also added a run-time alert to be printed if a program becomes 
> >> multithreaded and configure had detected that the runtime library was not 
> >> thread safe.
> > 
> > Is this test supposed to pass with libobjc2 trunk ?
> 
> It's supposed to pass with any runtime which supports +initialize
> properly, but I haven't tested all the different runtimes to see which
> do .... but I know the old gnu runtime was buggy and that the gnustep
> libobjc in trunk ought to be OK  since I applied the patch I submitted
> to gcc a few years back.  I'm not entirely happy with that patch (I've
> never found time to clean it up properly), but it's better than
> nothing, and I've been running code using it for a couple of years.

Ok, I didn't know gnustep libobjc was still active. I guess I should try
it.

> The configure check is a new check, so it's probably not bomb-proof...
> It certainly won't work without pthreads support ... but since we now
> require pthreads to build base, this should not be a problem

Here is an snippet from config.log with libobjc2 trunk, gcc 4.4.3 and
the appended patch applied :

configure:13221: checking for thread-safe +initialize in runtime
configure:13241: gcc -o conftest -g -O2  
-I/opt/GNUstep-trunk/System/Library/Headers 
-I/opt/GNUstep-trunk/Local/Library/Headers 
-I/opt/GNUstep-trunk/Local/Library/Headers 
-I/opt/GNUstep-trunk/Local/Library/Headers -fgnu-runtime -x objective-c  
-L/opt/GNUstep-trunk/System/Library/Libraries 
-L/opt/GNUstep-trunk/Local/Library/Libraries 
-L/opt/GNUstep-trunk/Local/Library/Libraries 
-L/opt/GNUstep-trunk/Local/Library/Libraries conftest.c -lrt -ldl  -lpthread 
-lobjc     >&5
In file included from ./config/config.initialize.m:4,
                 from conftest.c:1:
./config/objc-common.g: In function '+[NSObject new]':
./config/objc-common.g:44: warning: incompatible implicit declaration of 
built-in function 'calloc'
In file included from conftest.c:1:
./config/config.initialize.m: In function 'main':
./config/config.initialize.m:53: warning: passing argument 3 of 
'pthread_create' from incompatible pointer type
/usr/include/pthread.h:227: note: expected 'void * (*)(void *)' but argument is 
of type 'void (*)(void *)'
./config/config.initialize.m:66: warning: passing argument 3 of 
'pthread_create' from incompatible pointer type
/usr/include/pthread.h:227: note: expected 'void * (*)(void *)' but argument is 
of type 'void (*)(void *)'
configure:13245: $? = 0
configure:13251: ./conftest
problem with initialize
initialize_entered : 1
initialize_exited : 0
class_entered : 0
objc capability : 1
configure:13255: $? = 1
configure: program exited with status 1

I added a call to objc_test_capability to be sure it's using the right
libobjc as I think only libobjc2 provides it.

Philippe

Index: config/config.initialize.m
===================================================================
--- config/config.initialize.m  (révision 32479)
+++ config/config.initialize.m  (copie de travail)
@@ -2,6 +2,7 @@
  */
 
 #include "objc-common.g"
+#include "objc/capabilities.h"
 #include <pthread.h>
 #include <stdio.h>
 
@@ -88,6 +89,10 @@
              return 0; // OK
            }
          fprintf(stderr, "problem with initialize\n");
+         fprintf(stderr, "initialize_entered : %d\n", initialize_entered);
+         fprintf(stderr, "initialize_exited : %d\n", initialize_exited);
+          fprintf(stderr, "class_entered : %d\n", class_entered);
+          fprintf(stderr, "objc capability : %d\n", 
objc_test_capability(OBJC_CAP_EXCEPTIONS));
           return 1;
        }
       else





reply via email to

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