This is the mail archive of the libc-alpha@sources.redhat.com 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]

FreeBSD port (2): make it compile without linuxthreads


Hi,

Compilation of glibc without linuxthreads (whether on Linux or on FreeBSD)
gives a few apparently unintended errors. Here is a patch to fix them.

The errors are:

1) elf/rtld.c: initialization of a variable which is defined in
sysdeps/generic/ldsodefs.h through __libc_lock_define_recursive
and therefore doesn't exist in !_LIBC_REENTRANT mode.

2) Symbol 'fileno_unlocked' is undefined, leading to link errors
for iconvconfig etc. If !_LIBC_REENTRANT, it must be aliased to 'fileno'.

3) malloc/hooks.c: Access of undefined variable 'max_total_mem'.

4) misc/syslog.c: In functions openlog() and closelog(), access to
a variable (&syslog_lock) which is defined through
__libc_lock_define_initialized and therefore doesn't exist in
!_LIBC_REENTRANT mode. Furthermore, attempt to use as a function a
macro which is #defined to empty (this leads to a nice syntax error).


2002-07-06  Bruno Haible  <bruno@clisp.org>

	* elf/rtld.c (_rtld_global): Don't initialize _dl_load_lock if
	compiling without threads.
	* libio/fileno.c (fileno_unlocked): Define also if compiling without
	threads.
	* malloc/hooks.c (public_gET_STATe): Access max_total_mem in mp_.
	* misc/syslog.c (syslog_lock): Define as a dummy if compiling without
	threads.
	* sysdeps/generic/bits/libc-lock.h (__libc_mutex_unlock): Define as
	an inline function, to make misc/syslog.c compile.

diff -r -c3 glibc-20020627.bak/elf/rtld.c glibc-20020627/elf/rtld.c
--- glibc-20020627.bak/elf/rtld.c	Thu Jun 27 20:59:52 2002
+++ glibc-20020627/elf/rtld.c	Fri Jul  5 01:16:54 2002
@@ -90,10 +90,12 @@
     ._dl_dynamic_weak = 1,
 #endif
     ._dl_lazy = 1,
+#ifdef _LIBC_REENTRANT
+    ._dl_load_lock = _LIBC_LOCK_RECURSIVE_INITIALIZER,
+#endif
     ._dl_fpu_control = _FPU_DEFAULT,
     ._dl_correct_cache_id = _DL_CACHE_DEFAULT_ID,
-    ._dl_hwcap_mask = HWCAP_IMPORTANT,
-    ._dl_load_lock = _LIBC_LOCK_RECURSIVE_INITIALIZER
+    ._dl_hwcap_mask = HWCAP_IMPORTANT
   };
 strong_alias (_rtld_global, _rtld_local);
 
diff -r -c3 glibc-20020627.bak/libio/fileno.c glibc-20020627/libio/fileno.c
--- glibc-20020627.bak/libio/fileno.c	Tue Jul 10 22:58:52 2001
+++ glibc-20020627/libio/fileno.c	Fri Jul  5 01:17:05 2002
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1995-1997, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -43,12 +43,10 @@
   return _IO_fileno (fp);
 }
 
-#ifdef _IO_MTSAFE_IO
 #ifdef weak_alias
 /* The fileno implementation for libio does not require locking because
    it only accesses once a single variable and this is already atomic
-   (at least at thread level).  */
+   (at least at thread level).  Therefore we don't test _IO_MTSAFE_IO here.  */
 
 weak_alias (fileno, fileno_unlocked)
 #endif
-#endif
diff -r -c3 glibc-20020627.bak/malloc/hooks.c glibc-20020627/malloc/hooks.c
--- glibc-20020627.bak/malloc/hooks.c	Thu Apr  4 20:11:23 2002
+++ glibc-20020627/malloc/hooks.c	Fri Jul  5 01:17:06 2002
@@ -532,7 +532,7 @@
   ms->check_action = check_action;
   ms->max_sbrked_mem = main_arena.max_system_mem;
 #ifdef NO_THREADS
-  ms->max_total_mem = max_total_mem;
+  ms->max_total_mem = mp_.max_total_mem;
 #else
   ms->max_total_mem = 0;
 #endif
diff -r -c3 glibc-20020627.bak/misc/syslog.c glibc-20020627/misc/syslog.c
--- glibc-20020627.bak/misc/syslog.c	Thu Apr  4 20:11:24 2002
+++ glibc-20020627/misc/syslog.c	Fri Jul  5 01:17:06 2002
@@ -69,7 +69,11 @@
 extern char	*__progname;		/* Program name, from crt0. */
 
 /* Define the lock.  */
+#ifdef _LIBC_REENTRANT
 __libc_lock_define_initialized (static, syslog_lock)
+#else
+static int syslog_lock;
+#endif
 
 static void openlog_internal(const char *, int, int) internal_function;
 static void closelog_internal(void);
diff -r -c3 glibc-20020627.bak/sysdeps/generic/bits/libc-lock.h glibc-20020627/sysdeps/generic/bits/libc-lock.h
--- glibc-20020627.bak/sysdeps/generic/bits/libc-lock.h	Sat Aug 25 02:56:27 2001
+++ glibc-20020627/sysdeps/generic/bits/libc-lock.h	Fri Jul  5 01:17:07 2002
@@ -1,5 +1,5 @@
 /* libc-internal interface for mutex locks.  Stub version.
-   Copyright (C) 1996,97,99,2000,01 Free Software Foundation, Inc.
+   Copyright (C) 1996,97,99,2000-2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -114,7 +114,9 @@
 
 
 /* We need portable names for some of the functions.  */
-#define __libc_mutex_unlock
+static __inline void __libc_mutex_unlock (void *__lock)
+{
+}
 
 /* Type for key of thread specific data.  */
 typedef int __libc_key_t;


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