One of the features of our new symbol exporting regime is that it forces
config.h to be included at the top of every .c file.
This was missed in gthread-impl.c.
The only reason this wasn't noticed is because nothing in this file is
being used anymore. We need those symbols to continue to be exported
for reasons of ABI backwards compatibility, however.
This was turning all the GLIB_VARs in the glib headers into
dllexports on windows, causing all sort of nastiness. libgthread is
mostly empty now anyway, so we don't need any GLIB_COMPILATION like
flag.
g_thread_init() is now a deprecated API, so drop G_DISABLE_DEPRECATED
from the CFLAGS for gthread/. Add the missing declaration for
g_thread_init_with_errorcheck_mutexes() back to deprecated/gthread.h.
configure.ac defined G_THREAD_SOURCE and gthread-impl would #include it.
Instead, since we only have two thread implementations now, and since we
always use the Windows one only on Windows, move the logic to the
Makefile, predicated on 'if OS_WIN32'. Then have the chosen backend do
the #include "gthread-impl.c" from there.
Remove the G_THREAD_SOURCE define from configure.ac.
The translation of GLib priorities into the thread priorities of
different operating systems belongs in the implementation -- not
half-way in the front end.
g_thread_gettime() is an undocumented public function pointer that
points to a function that returns the monotonic time in nanoseconds.
g_get_monotonic_time() does the same in microseconds, so it can be used
instead.
GLib had one internal user in GFileMonitor that only cared about
millisecond accuracy; it has been ported to g_get_monotonic_time().
G_THREADS_ENABLED still exists, but is always defined. It is still
possible to use libglib without threads, but gobject (and everything
above it) is now guaranteed to be using threads (as, in fact, it was
before, since it was accidentally impossible to compile with
--disable-threads).
https://bugzilla.gnome.org/show_bug.cgi?id=616754
We now allow g_thread_init(NULL) to be called after other glib calls (with
some minor limitations). This is mainly a documentation change as this
really was already possible.
We also allow g_thread_init() to be called multiple times. Only the
first call actually initializes the threading system, further calls
are ignored (but print a warning if the argument is not NULL).
https://bugzilla.gnome.org/show_bug.cgi?id=606775
* gthread-impl.c: Implement g_thread_init_with_errorcheck_mutexes
in the !G_THREAD_ENABLED case. Pointed out by Jan Nieuwenhuizen
svn path=/trunk/; revision=7364
2007-01-16 Matthias Clasen <mclasen@redhat.com>
* glib/gthread.h:
* glib/gthread.c:
* glib/glib.symbols: Revert an accidental ABI break by
moving gettime out of the GThreadFunctions struct and making
it a separate variable. (#397139, Joe Marcus Clarke)
* gthread/*.c: Adapt.
svn path=/trunk/; revision=5279
2007-01-07 Matthias Clasen <mclasen@redhat.com>
Don't link glib against libpthread. (#393812)
* configure.in: Link gthread against librt, not glib itself.
* glib/gthread.h:
* glib/gthread.c: Add a new thread function, gettime.
* glib/gtimer.c: Use gettime instead of directly working with
the various system interfaces.
* gthread/gthread-impl.c:
* gthread/gthread-posix.c:
* gthread/gthread-win32.c: Implement gettime.
svn path=/trunk/; revision=5227
2006-05-10 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthread.h, gthread/gthread-impl.c: Make the magic and
location arguments to the error-checking-mutex functions const and
do not write to them, as we might not own them. Clean up the
error-checking-mutex code quite a bit. (#335198, Chris Wilson)
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gthreadinit.h: Renamed to glib/gthreadprivate.h and moved
system thread identifier comparision and assignment macros from
glib/gthread.c to glib/gthreadprivate.h.
* glib/Makefile.am, glib/gatomic.c, glib/gconvert.c, glib/gmain.c,
glib/gmem.c, glib/gmessages.c, glib/grand.c, glib/gslice.c,
glib/gthread.c, glib/gutils.c, gthread/gthread-impl.c: Use
glib/gthreadprivate.h instead of glib/gthreadinit.h.
* gthread/gthread-impl.c: Use GSystemThread instead of GThread for
owner determination. This fixes#311043 and is mostly modeled
after the patch from jylefort@FreeBSD.org.
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
* glib/gprintf.c, glib/gspawn-win32.c, glib/gutf8.c,
gthread/gthread-impl.c, gthread/gthread-posix.c,
gthread/gthread-win32.c: Use canonical include form for internal
headers. config.h is always there.
2003-02-14 Sebastian Wilhelmi <seppi@seppi.de>
Fixes for #101264 and #99372:
* glib/gconvert.h, glib/gmain.c, glib/gmem.c, glib/gmessages.c,
glib/grand.c: Include gthreadinit.h and rename the thread
initialization functions a bit and let them start with _, so that
later we can stop exporting them.
* glib/gmem.c, glib/gmessages.c: Move the g_private_new() calls to
new functions. They have to be called after setting
g_threads_got_initialized to TRUE (see #101264).
* glib/gthread.c: Include gthreadinit.h. Renamed g_mutex_init() to
g_thread_init_glib(). Call the thread initialization functions
(which are not allowed to call g_private_new), then set
g_threads_got_initialized to TRUE, then call the other thread
initialization functions (which must not call anything but
g_private_new()).
* glib/gthreadinit.h: New private header to cleanly declare all
thread initialization functions.
* gthread/gthread-impl.c: Include gthreadinit.h. In
g_thread_init() just call g_thread_init_glib(), which in turn calls the
other functions (see #99372).
* glib/Makefile.am: Added gthreadinit.h.
2002-11-26 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/grand.c, gthread/gthread-impl.c, tests/rand-test.c:
Improved the seeding algorithm. Old behaviour can be achived by
setting envvar G_RANDOM_VERSION to "2.0". (#99262)
* docs/reference/glib/glib-docs.sgml,
docs/reference/glib/Makefile.am: Renamed
docs/reference/glib/changes-2.0.sgml to
docs/reference/glib/changes.sgml and added section for changes
from 2.0 to 2.2 (Also corrected 1.0 to 1.2).
* README.in, docs/reference/glib/running.sgml,
docs/reference/glib/tmpl/random_numbers.sgml,
docs/reference/glib/changes.sgml: Added notes about the new
seeding algorithm.
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gmain.c: Factor out g_main_context_init_pipe from
g_main_context_new to initialize the wakeup pipe of a
context. Call that function from g_main_context_new if threads are
initialized and for all contexts when threads are initialized
in g_main_thread_init. (#86872)
* gthread/gthread-impl.c: Call g_main_thread_init. (#86872)
2002-08-06 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* glib/gthread.c: Set the normal PID surrogate priority according
to getpid() to avoid errors for niced processes. (#86116)
* gthread/gthread-impl.c, gthread/gthread-posix.c,
gthread/gthread-solaris.c: Do the same for the posix/dce
implementation. Solaris still needs to set priority of the main
thread, because all unbound threads will schedule according to
that value and it defaults to 0 (the minimal value).
2002-03-12 Alexander Larsson <alla@lysator.liu.se>
* glib/gconvert.c:
Cache getenv("G_BROKEN_FILENAMES") in have_broken_filenames() and
use instead. Add g_convert_init() that calls have_broken_filenames()
* gthread/gthread-impl.c:
Have g_thread_init call g_convert_init.
2002-02-09 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Make --disable-threads work again. (#71034)
* gthread-impl.c: Only compile most of this file, if
G_THREAD_ENABLED is set.
2001-09-24 Bruno Haible <haible@clisp.cons.org>
* glib/gwin32.c (g_win32_getlocale): When the sublangid is
SUBLANG_DEFAULT, return the locale of the language's main country,
not a country-neutral locale. E.g. "en_US" instead of "en". Add
handling of LANG_SORBIAN. Fix typo for SUBLANG_CHINESE_SIMPLIFIED
(China == CN, CH == Switzerland). Ignore empty environment
variable values.
2001-09-28 Tor Lillqvist <tml@iki.fi>
* glib/makefile.{mingw,msc}.in: Add localcharset.o. Just copy the
source file from libcharset and compile in this directory.
* glib/giochannel.c: Mark rest of g_set_error strings for
translation, too.
* glib/giowin32.c: Add some debugging output functions, call them
when debugging.
(create_events, g_io_win32_msg_write): Free message fetched with
g_win32_error_message ().
(g_io_win32_check): Indentation fixes.
(g_io_win32_fd_read,g_io_win32_sock_read): Don't always return
G_IO_STATUS_NORMAL. Do return G_IO_STATUS_EOF if we got 0 bytes,
like on Unix. This helps making the test programs run
successfully.
* glib/gmain.c (g_poll): Return the code ifdeffed out with
TEST_WITHOUT_THIS. Can't remember why it was ifdeffed out. Things
seem to work as previously with the code in place. Especially
spawn-test didn't work with the code ifdeffed out (Bug#61067).
* glib/grand.c (g_rand_new): Don't try to use /dev/urandom unless
on Unix.
* glib/gspawn-win32-helper.c (WinMain): Remove Sleep(10000)
accidentally left in.
gthread:
2001-09-28 Tor Lillqvist <tml@iki.fi>
* gthread-win32.c: Use an extra level of indirection for GMutex.
It is now a pointer either to a pointer to a CRITICAL_SECTION
struct, or to a mutex HANDLE. This is needed in case the user
defines G_ERRORCHECK_MUTEXES. G_MUTEX_SIZE must correctly reflect
the size of *GMutex, but this used to vary depending on whether we
at run-time chose to use CRITICAL_SECTIONs or mutexes.
(g_mutex_free_win32_cs_impl, g_cond_free_win32_impl): Call
DeleteCriticalSection() when done with it.
* gthread-impl.c (g_thread_init_with_errorcheck_mutexes): Call
g_thread_impl_init() before accessing
g_thread_functions_for_glib_use_default, as the
g_thread_impl_init() function might modify it.
po:
2001-09-28 Tor Lillqvist <tml@iki.fi>
* POTFILES.in: Add iochannel.c and giowin32.c.
* sv.po: Remove a bogus fuzziness indicator.
2001-09-25 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread-impl.c: Corrected the array size (cough, cough). Pointed
out by gpablo@intersystems.com.ar. Fixes#61065.
2001-05-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* config.h.win32.in: Removed POSIX_*. Defined G_THREAD_SOURCE to
"gthread-win32.c".
* glibconfig.h.win32.in: Define G_HAVE_ISO_VARARGS for gcc, don't
know about MSC. Define G_THREADS_IMPL_WIN32 instead of
G_THREADS_IMPL_POSIX and define the right static mutex macros and
types.
* build/win32/make.mingw (CXX): Removed PTHREAD defs. Added
-O2 -Wall to compile flags.
* gthread/gthread-impl.c (g_thread_init): Move the thread
implementation initialization to before assigning
GThreadFuncs, which now is just struct assigned and not
memcpy'ed. Completed check for zero members of GThreadFuncs.
* gthread/makefile.mingw: Don't link to pthread anymore.
* gthread/gthread-win32.c: New file for native thread support for
win32. Thanks to Hans Breuer <hans@breuer.org> to got me
kickstarted.
* gthread/Makefile.am: Also distribute gthread-win32.c.
2001-04-03 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread-posix.c: Added special case for priorities on
FreeBSD. Thanks to David Reid <dreid@jetnet.co.uk> for the info.
* gthread-impl.c: Made two macros safe with ().
2001-02-21 Tor Lillqvist <tml@iki.fi>
* Makefile.am: Use libglib-1.3.la from top_builddir. Invoke
libtool with -no-undefined for Win32 and Cygwin.
* gthread-impl.c (g_thread_init): Win32 code snippet used also on
Cygwin.
2001-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread/gthread-impl.c (g_thread_init_with_errorcheck_mutexes): Call
g_thread_impl_init(), as g_thread_init won't call it.
* glib/glib-sections.txt, glib/tmpl/threads.sgml: Added
g_static_mutex_free
* gthread.c, gthread.h: Added g_static_mutex_free to allow using
GStaticMutexes with limited lifetime without leaking.
* configure.in: GStaticMutex doesn't have to provide extra space
for debugging information for G_ERRORCHECK_MUTEXES, as then the
non-default implementation (runtime_mutex) is used anyway.
2001-01-30 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.h (g_cond_wait): Added debug information for
g_mutex_free calls, if G_ERRORCHECK_MUTEXES is defined.
* gthread/gthread-impl.c (g_mutex_free_errorcheck_impl): Fixed it for
real. Sorry for this mess. It looked like a real obvious fix, so I
didn't check. Bad boy. Added some casts to quiet the compiler.
2001-01-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread.c: Broadcast the condition, if there are waiting
readers, as all might read at the same time. Only signal the
writer thread, if there are no more readers.
* gthread/gthread-impl.c (g_mutex_free_errorcheck_impl): Add
new check to errorcheck mutexes to abort, if a locked mutex is freed.
2000-11-28 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread-impl.c: Revamped errorcheck mutexes and added errorcheck
cond_wait() and cond_timed_wait() funtions. This makes he whole
thing work. Now we only show the location of the locking/unlocking
for -DG_ERRORCHECK_MUTEXES and not the name of the mutex.
* gthread.c: Set the thread data before locking the mutex, because
the locking call might use g_thread_self ().
* gthread.h: Do only show the location of the locking/unlocking
for -DG_ERRORCHECK_MUTEXES and not the name of the mutex. Add the
errorcheck capability for g_cond_wait and g_cond_timed_wait as
well.
2000-11-21 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Add a surrogate for thread priorities using PID
niceness for systems with no thread priorities and different PIDs
for threads of the same process (most notably: Linux). Define
G_THREAD_USE_PID_SURROGATE in that case, as used by
gthread-posix.c. Also make the system thread bigger by
sizeof (long) to contain the thread's PID.
* gfileutils.c: Include stdlib.h for mkstemp prototype.
* gthread.c: Add priority range checks to the affected functions.
* gthreadpool.c: Remove unused variable.
* gthread-impl.c, gthread-posix.c, gthread-solaris.c: Removed
g_thread_map_priority function in favour of the
g_thread_priority_map array. Initialize the array with
PRIORITY_{...}_VALUE, if available and interpolate beetween the
bounds if .._NORMAL_.. and .._HIGH_.. are not available.
* gthread-posix.c: If we should use the PID niceness as a
surrogate for thread priorities (G_THREAD_USE_PID_SURROGATE is
defined), then disable normal priority handling and use PIDs and
setpriority() instead. Depends on the thread to write its PID into
the place after the thread id right after thread creation.
2000-09-29 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, glib.h: Added errorcheck mutexes. These are
activated through the preprocessor symbol
G_ERRORCHECK_MUTEXES. Need to add an extra word to StaticMutex in
order to achieve this. g_(static_)mutex_* functions instrument the
mutex operations with mutex name and location, when compiled with
-DG_ERRORCHECK_MUTEXES. g_thread_init activates the errorcheck
mutexes, when compiled with -DG_ERRORCHECK_MUTEXES.
* gthread/gthread-impl.c: Added errorcheck mutexes. New
exported function
g_thread_init_with_errorcheck_mutexes, which is called instead of
g_thread_init, when compiled with -DG_ERRORCHECK_MUTEXES. New
static functions
g_mutex_(new|lock|trylock|unlock|free)_errorcheck_impl to
implement errorcheck mutexes.
* gthread/gthread-posix.impl.c, gthread/gthread-solaris-impl.c:
Define the size of a mutex.
Wed Jul 26 12:59:31 2000 Tim Janik <timj@gtk.org>
* *.[hc]: applied patch from Andreas Persenius <ndap@swipnet.se> that
updates the license headers to the GNU Lesser General Public License,
as well as updating the copyright year to 2000.
2000-02-22 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* gthread-posix.c, gthread-solaris.c: check for sysconf
(_SC_THREAD_STACK_MIN), which returns the minimal stack size for
new threads. Patch from Soeren Sandmann <sandmann@daimi.au.dk>.
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.