diff options
author | Sebastian Wilhelmi <wilhelmi@ira.uka.de> | 1999-01-07 16:17:42 +0000 |
---|---|---|
committer | Sebastian Wilhelmi <wilhelmi@src.gnome.org> | 1999-01-07 16:17:42 +0000 |
commit | 81f8d0bb10c945c459b2a8063bf70039be113771 (patch) | |
tree | ca4b4ce4df360d0a728e542beeb92aa455e3f712 | |
parent | 9200f444626fd7b814c30f351f872a11e0d9a64c (diff) |
Here we must replace getpwuid by getpwuid_r, but as I do not know how for
1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gutils.c (g_get_any_init): Here we must replace getpwuid by
getpwuid_r, but as I do not know how for now, I just made a FIXME
note ;-)
* gdate.c (g_date_set_time): localtime --> localtime_r to make it
thread safe.
* configure.in: We do not need to check for broken solaris mutex
intitializer any longer. Provide a macro to show the used thread
implementation. Not nice, but this is needed until thread support
is completed here inside glib.
* gthread/testgthread.c: conditionally compile according to the
G_THREADS_IMPL_??? macros.
(test_private_func): use rand_r instead of rand to make it
thread safe.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-12 | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 14 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 14 | ||||
-rw-r--r-- | configure.in | 25 | ||||
-rw-r--r-- | gdate.c | 29 | ||||
-rw-r--r-- | glib/gdate.c | 29 | ||||
-rw-r--r-- | glib/gutils.c | 13 | ||||
-rw-r--r-- | gthread/ChangeLog | 7 | ||||
-rw-r--r-- | gthread/testgthread.c | 27 | ||||
-rw-r--r-- | gutils.c | 13 |
15 files changed, 195 insertions, 60 deletions
@@ -1,3 +1,17 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * gutils.c (g_get_any_init): Here we must replace getpwuid by + getpwuid_r, but as I do not know how for now, I just made a FIXME + note ;-) + + * gdate.c (g_date_set_time): localtime --> localtime_r to make it + thread safe. + + * configure.in: We do not need to check for broken solaris mutex + intitializer any longer. Provide a macro to show the used thread + implementation. Not nice, but this is needed until thread support + is completed here inside glib. + Tue Jan 5 12:23:52 PST 1999 Manish Singh <yosh@gimp.org> * configure.in: ditch whitespace before GLIB_SYSDEFS #includes, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index fdd1e9a94..539009053 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,17 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * gutils.c (g_get_any_init): Here we must replace getpwuid by + getpwuid_r, but as I do not know how for now, I just made a FIXME + note ;-) + + * gdate.c (g_date_set_time): localtime --> localtime_r to make it + thread safe. + + * configure.in: We do not need to check for broken solaris mutex + intitializer any longer. Provide a macro to show the used thread + implementation. Not nice, but this is needed until thread support + is completed here inside glib. + Tue Jan 5 12:23:52 PST 1999 Manish Singh <yosh@gimp.org> * configure.in: ditch whitespace before GLIB_SYSDEFS #includes, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index fdd1e9a94..539009053 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * gutils.c (g_get_any_init): Here we must replace getpwuid by + getpwuid_r, but as I do not know how for now, I just made a FIXME + note ;-) + + * gdate.c (g_date_set_time): localtime --> localtime_r to make it + thread safe. + + * configure.in: We do not need to check for broken solaris mutex + intitializer any longer. Provide a macro to show the used thread + implementation. Not nice, but this is needed until thread support + is completed here inside glib. + Tue Jan 5 12:23:52 PST 1999 Manish Singh <yosh@gimp.org> * configure.in: ditch whitespace before GLIB_SYSDEFS #includes, diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index fdd1e9a94..539009053 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,17 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * gutils.c (g_get_any_init): Here we must replace getpwuid by + getpwuid_r, but as I do not know how for now, I just made a FIXME + note ;-) + + * gdate.c (g_date_set_time): localtime --> localtime_r to make it + thread safe. + + * configure.in: We do not need to check for broken solaris mutex + intitializer any longer. Provide a macro to show the used thread + implementation. Not nice, but this is needed until thread support + is completed here inside glib. + Tue Jan 5 12:23:52 PST 1999 Manish Singh <yosh@gimp.org> * configure.in: ditch whitespace before GLIB_SYSDEFS #includes, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index fdd1e9a94..539009053 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,17 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * gutils.c (g_get_any_init): Here we must replace getpwuid by + getpwuid_r, but as I do not know how for now, I just made a FIXME + note ;-) + + * gdate.c (g_date_set_time): localtime --> localtime_r to make it + thread safe. + + * configure.in: We do not need to check for broken solaris mutex + intitializer any longer. Provide a macro to show the used thread + implementation. Not nice, but this is needed until thread support + is completed here inside glib. + Tue Jan 5 12:23:52 PST 1999 Manish Singh <yosh@gimp.org> * configure.in: ditch whitespace before GLIB_SYSDEFS #includes, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index fdd1e9a94..539009053 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * gutils.c (g_get_any_init): Here we must replace getpwuid by + getpwuid_r, but as I do not know how for now, I just made a FIXME + note ;-) + + * gdate.c (g_date_set_time): localtime --> localtime_r to make it + thread safe. + + * configure.in: We do not need to check for broken solaris mutex + intitializer any longer. Provide a macro to show the used thread + implementation. Not nice, but this is needed until thread support + is completed here inside glib. + Tue Jan 5 12:23:52 PST 1999 Manish Singh <yosh@gimp.org> * configure.in: ditch whitespace before GLIB_SYSDEFS #includes, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index fdd1e9a94..539009053 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * gutils.c (g_get_any_init): Here we must replace getpwuid by + getpwuid_r, but as I do not know how for now, I just made a FIXME + note ;-) + + * gdate.c (g_date_set_time): localtime --> localtime_r to make it + thread safe. + + * configure.in: We do not need to check for broken solaris mutex + intitializer any longer. Provide a macro to show the used thread + implementation. Not nice, but this is needed until thread support + is completed here inside glib. + Tue Jan 5 12:23:52 PST 1999 Manish Singh <yosh@gimp.org> * configure.in: ditch whitespace before GLIB_SYSDEFS #includes, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index fdd1e9a94..539009053 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * gutils.c (g_get_any_init): Here we must replace getpwuid by + getpwuid_r, but as I do not know how for now, I just made a FIXME + note ;-) + + * gdate.c (g_date_set_time): localtime --> localtime_r to make it + thread safe. + + * configure.in: We do not need to check for broken solaris mutex + intitializer any longer. Provide a macro to show the used thread + implementation. Not nice, but this is needed until thread support + is completed here inside glib. + Tue Jan 5 12:23:52 PST 1999 Manish Singh <yosh@gimp.org> * configure.in: ditch whitespace before GLIB_SYSDEFS #includes, diff --git a/configure.in b/configure.in index 901bb5cac..b6b0ba119 100644 --- a/configure.in +++ b/configure.in @@ -628,35 +628,27 @@ case $have_threads in mutex_default_type='pthread_mutex_t' mutex_default_init='PTHREAD_MUTEX_INITIALIZER' mutex_header_file='pthread.h' + g_threads_impl="POSIX" ;; solaris) G_THREAD_LIBS=error AC_CHECK_LIB(thread, cond_init, G_THREAD_LIBS="-lthread") - # solaris has a broken initializer for mutexes, if we find it, - # we will replace it. - AC_MSG_CHECKING(for broken solaris mutex initialization) - AC_EGREP_CPP([ *begin *{ *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *, *0 *} *end *], - [#include <thread.h> - begin DEFAULTMUTEX end], - [solaris_mutex_init_broken=yes], - [solaris_mutex_init_broken=no]) - AC_MSG_RESULT($solaris_mutex_init_broken) mutex_has_default=yes mutex_default_type='mutex_t' - if test x$solaris_mutex_init_broken = xyes; then - mutex_default_init="{ { { 0, 0, 0, 0 }, USYNC_THREAD }, { { { 0, 0, 0, 0, 0, 0, 0, 0 } } }, 0}" - else - mutex_default_init="DEFAULTMUTEX" - fi + mutex_default_init="DEFAULTMUTEX" mutex_header_file='thread.h' + g_threads_impl="SOLARIS" ;; nspr) AC_CHECK_LIB(nspr21, PRP_NewNakedCondVar, G_THREAD_LIBS="-lnspr21") + g_threads_impl="NSPR" ;; none) + g_threads_impl="NONE" ;; *) + g_threads_impl="NONE" G_THREAD_LIBS=error ;; esac @@ -718,7 +710,6 @@ AC_SUBST(G_THREAD_LIBS) CFLAGS="$CFLAGS $G_THREAD_CFLAGS" - dnl ********************************************** dnl *** GDefaultMutex setup and initialization *** dnl ********************************************** @@ -890,6 +881,7 @@ _______EOF if test x$g_mutex_has_default = xyes; then cat >>$outfile <<_______EOF $g_enable_threads_def G_THREADS_ENABLED +#define G_THREADS_IMPL_$g_threads_impl_def typedef struct _GStaticMutex GStaticMutex; struct _GStaticMutex { @@ -909,6 +901,7 @@ _______EOF else cat >>$outfile <<_______EOF $g_enable_threads_def G_THREADS_ENABLED +#define $g_threads_impl_def typedef struct _GMutex* GStaticMutex; #define G_STATIC_MUTEX_INIT NULL #define g_static_mutex_get_mutex(mutex) (g_static_mutex_get_mutex_impl (&(mutex))) @@ -1182,6 +1175,8 @@ xyes) g_enable_threads_def="#define";; *) g_enable_threads_def="#undef ";; esac +g_threads_impl_def=$g_threads_impl + g_mutex_has_default="$mutex_has_default" g_mutex_sizeof="$glib_cv_sizeof_gmutex" g_mutex_contents="$glib_cv_byte_contents_gmutex" @@ -790,28 +790,21 @@ g_date_set_time (GDate *d, GTime time) { time_t t = time; - struct tm *tm; + struct tm tm; g_return_if_fail (d != NULL); - tm = localtime (&t); + localtime_r (&t, &tm); - if (tm) - { - d->julian = FALSE; - - d->month = tm->tm_mon + 1; - d->day = tm->tm_mday; - d->year = tm->tm_year + 1900; - - g_return_if_fail (g_date_valid_dmy (d->day, d->month, d->year)); - - d->dmy = TRUE; - } - else - { - g_date_clear (d, 1); - } + d->julian = FALSE; + + d->month = tm.tm_mon + 1; + d->day = tm.tm_mday; + d->year = tm.tm_year + 1900; + + g_return_if_fail (g_date_valid_dmy (d->day, d->month, d->year)); + + d->dmy = TRUE; } void diff --git a/glib/gdate.c b/glib/gdate.c index 471aaadf7..08b3b0b08 100644 --- a/glib/gdate.c +++ b/glib/gdate.c @@ -790,28 +790,21 @@ g_date_set_time (GDate *d, GTime time) { time_t t = time; - struct tm *tm; + struct tm tm; g_return_if_fail (d != NULL); - tm = localtime (&t); + localtime_r (&t, &tm); - if (tm) - { - d->julian = FALSE; - - d->month = tm->tm_mon + 1; - d->day = tm->tm_mday; - d->year = tm->tm_year + 1900; - - g_return_if_fail (g_date_valid_dmy (d->day, d->month, d->year)); - - d->dmy = TRUE; - } - else - { - g_date_clear (d, 1); - } + d->julian = FALSE; + + d->month = tm.tm_mon + 1; + d->day = tm.tm_mday; + d->year = tm.tm_year + 1900; + + g_return_if_fail (g_date_valid_dmy (d->day, d->month, d->year)); + + d->dmy = TRUE; } void diff --git a/glib/gutils.c b/glib/gutils.c index c6958f122..e235d295f 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -416,6 +416,19 @@ g_get_any_init (void) g_home_dir = g_strdup (g_getenv ("HOME")); #ifdef HAVE_PWD_H + /* FIXME: we must actually use the getpwuid_r function here, as + getpwuid is not MT-safe, but the prototype doesn't seem to be + agreed upon on the different systems, i.e. it is + + struct passwd *getpwuid_r(uid_t uid, struct passwd * pwd, + char *buffer, int buflen); + + on solaris, but + + int getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, + size_t bufsize struct passwd **result); + + on posix. weird. */ setpwent (); pw = getpwuid (getuid ()); endpwent (); diff --git a/gthread/ChangeLog b/gthread/ChangeLog index 0a20f089b..939ae56c5 100644 --- a/gthread/ChangeLog +++ b/gthread/ChangeLog @@ -1,3 +1,10 @@ +1999-01-07 Sebastian Wilhelmi <wilhelmi@ira.uka.de> + + * testgthread.c: conditionally compile according to the + G_THREADS_IMPL_??? macros. + (test_private_func): use rand_r instead of rand to make it + thread safe. + 1998-12-18 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * testgthread.c (new_thread): As a joinable thread seems to be the diff --git a/gthread/testgthread.c b/gthread/testgthread.c index c2149d461..8fabc5add 100644 --- a/gthread/testgthread.c +++ b/gthread/testgthread.c @@ -40,12 +40,11 @@ test_mutexes (void) } } -#if defined(NSPR) /* we are using nspr threads */ -/* this option must be specified by hand during compile of - testgthread. also note, that you have to link with whatever library - nspr is building upon, it might otherwise (as on solaris) lead to - run time failure, as the mutex functions are defined in libc, but - as noops, that will make some nspr assertions fail. */ +#if defined(G_THREADS_IMPL_NSPR) +#warning "note, that you have to link with whatever library" +#warning "nspr is building upon, it might otherwise (as on solaris) lead to" +#warning "run time failure, as the mutex functions are defined in libc, but" +#warning "as noops, that will make some nspr assertions fail." #include <prthread.h> gpointer @@ -59,7 +58,8 @@ new_thread (GHookFunc func, gpointer data) #define join_thread(thread) PR_JoinThread (thread) #define self_thread() PR_GetCurrentThread () -#elif defined(DEFAULTMUTEX) /* we are using solaris threads */ +#elif defined(G_THREADS_IMPL_SOLARIS) +#include <thread.h> gpointer new_thread (GHookFunc func, gpointer data) @@ -72,7 +72,9 @@ new_thread (GHookFunc func, gpointer data) thr_join ((thread_t)GPOINTER_TO_UINT (thread), NULL, NULL) #define self_thread() GUINT_TO_POINTER (thr_self ()) -#elif defined(PTHREAD_MUTEX_INITIALIZER) /* we are using posix threads */ +#elif defined(G_THREADS_IMPL_POSIX) +#include <pthread.h> + gpointer new_thread(GHookFunc func, gpointer data) { @@ -151,10 +153,17 @@ void test_private_func (void *data) { guint i = 0; + static unsigned int seed = 0; + if (!seed) + { + GTimeVal now; + g_get_current_time (&now); + seed = now.tv_usec; + } wait_thread (1); while (i < TEST_PRIVATE_ROUNDS) { - guint random_value = rand () % 10000; + guint random_value = rand_r (&seed) % 10000; guint *data = g_static_private_get (&private_key); if (!data) { @@ -416,6 +416,19 @@ g_get_any_init (void) g_home_dir = g_strdup (g_getenv ("HOME")); #ifdef HAVE_PWD_H + /* FIXME: we must actually use the getpwuid_r function here, as + getpwuid is not MT-safe, but the prototype doesn't seem to be + agreed upon on the different systems, i.e. it is + + struct passwd *getpwuid_r(uid_t uid, struct passwd * pwd, + char *buffer, int buflen); + + on solaris, but + + int getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, + size_t bufsize struct passwd **result); + + on posix. weird. */ setpwent (); pw = getpwuid (getuid ()); endpwent (); |