Re: [gtk-list] pbms on freebsd w/ threads



Hi, Emmanuel

> Everything below apply to freebsd boxes (tested on
> 2.2.8, but should apply to 2.2.x and 3.x)
> 
> I have it. Before anything, a fast rewind :
> after a succesfull install of gtk-1.2.2 on my freebsd
> 2.2.8 box, I experienced some problems in some
> configure scripts (such as the one of the gimp 1.0.4,
> imlib 1.9.4, and so on...). These configure script failed
> on the version detection, giving the message "success in
> compil, failed to run.". The problem was not related to
> a bad install, but to some nasty side-effect of a
> 'thread-enable' compilation of gdk.
> 
> In fact, using the D_THREAD_SAFE and D_REENTRANT flags
> to compile code that use getc() produce an inline function
> _getc_locked() that is use instead of getc(). This
> _getc_locked() func uses an extern variable called __isthreaded,
> that is defined in the c_r library (the thread safe c library
> on freebsd). So, using getc() in any code that is compiled using
> the two flags above result in an obligation for the output
> object to be linked with the thread safe c lib...
> 
> Such linking is not needed for non-threaded programs.
> The solution for this is to not use getc() in any portion of
> gtk/gdk, and define another gthread_ function that do the
> same. If _THREAD_SAFE is not defined, a new version of the
> function (probably inlined) is defined in glib.h.

I attach a patch, that should solve your problems. Please tell me the
necessary MACROS to test for (e.g. #ifdef FREEBSD... or even NETBSD?) to
enable that fix, beacuse we do not want to have it on platforms other than
those necessary. A general solution a la g_getc is IMHO not needed, as the
getc thing only poses problems to libraries for both MT and non-MT (currently
not so many, it seems) and as such should be taken care of by the libraries
themselfs.
 
> This solution fits all the architecture, and eliminates the
> freebsd problem. I'll post some diff in a few days (need some
> tests).

Bye,
Sebastian
-- 
Sebastian Wilhelmi                   |            här ovanför alla molnen
mailto:wilhelmi@ira.uka.de           |      är himmlen så förunerligt blå
http://goethe.ira.uka.de/~wilhelmi   |
? stamp-h.in
? gtk+.spec
? gdk/gdkconfig.h
? gdk/stamp-gc-h
? gtk/gtkfilesel.c.new_g_getpwuid
Index: gdk/gdkpixmap.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkpixmap.c,v
retrieving revision 1.25
diff -u -b -B -r1.25 gdkpixmap.c
--- gdkpixmap.c	1999/02/24 07:33:08	1.25
+++ gdkpixmap.c	1999/05/05 13:58:40
@@ -214,17 +214,25 @@
   return FALSE;
 }
 
+static int internal_getc(FILE *stream)
+{
+  char result;
+  if (fread (&result, 1, 1, stream))
+    return result;
+  return EOF;
+}
+
 static gint
 gdk_pixmap_seek_char (FILE  *infile,
                       gchar  c)
 {
   gint b, oldb;
 
-  while ((b = getc(infile)) != EOF)
+  while ((b = internal_getc(infile)) != EOF)
     {
       if (c != b && b == '/')
 	{
-	  b = getc (infile);
+	  b = internal_getc (infile);
 	  if (b == EOF)
 	    return FALSE;
 	  else if (b == '*')	/* we have a comment */
@@ -233,7 +241,7 @@
 	      do
  		{
  		  oldb = b;
-		  b = getc (infile);
+		  b = internal_getc (infile);
  		  if (b == EOF)
  		    return FALSE;
  		}
@@ -264,13 +272,13 @@
     }
 
   do
-    c = getc (infile);
+    c = internal_getc (infile);
   while (c != EOF && c != '"');
 
   if (c != '"')
     goto out;
 
-  while ((c = getc(infile)) != EOF)
+  while ((c = internal_getc(infile)) != EOF)
     {
       if (cnt == bufsiz)
 	{


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