+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
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
CFLAGS="$CFLAGS $G_THREAD_CFLAGS"
-
dnl **********************************************
dnl *** GDefaultMutex setup and initialization ***
dnl **********************************************
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
{
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)))
*) 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"
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
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
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 ();
+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
}
}
-#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
#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)
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)
{
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)
{
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 ();