summaryrefslogtreecommitdiff
path: root/gmain.c
AgeCommit message (Collapse)Author
2000-07-29Finally, a new and improved IO Channel and condition watch implementationTor Lillqvist
2000-07-30 Tor Lillqvist <tml@iki.fi> Finally, a new and improved IO Channel and condition watch implementation for Win32. Based on code provided by Craig Setera. When watching file descriptors, for which there is no select() like functionality on Win32 that would work on all Win32 platforms for all types of file descriptors (including anonymous pipes), we start a new thread that blocks while trying to read from the file descriptor. When the read returns, a Win32 Event is signalled that the polling routine eventually notices. Meanwhile, the data being read is stored in a circular buffer, from where the IO channel's read() method picks it up. If the buffer fills up the reading thread has to wait for space becoming available. For this another Win32 Event is used. The IO Channel's read() method signals this when it has read some data out of the buffer. The separate reader thread(s), and the circular buffer(s) with associated events mean lots of possibilities for fun parallellism errors. But it seems to work OK, i.e. GIMP runs. * gmain.c: Small changes to the Win32 polling function. (g_main_win32_get_poll_func): New function. Perhaps it would be a good idea to provide this on all platforms. * giowin32.c: The bulk of the new implementation. (g_io_channel_win32_wait_for_condition): New function. To be used where on Unix one does a select() on the channel's fd, like libgimp's gimp_extension_process(). Could be provided on all platforms. * glib.h: Update documentation for IO Channels on Win32. Remove the declarations for the as of now obsolete old functions related to IO Channels for pipes with "wakeup" messages. * glib.def: Some new functions. * tests/gio-test.c: New file, to test GIOChannel and main loop. * tests/Makefile.am * tests/makefile.mingw.in: Add it.
2000-07-26applied patch from Andreas Persenius <ndap@swipnet.se> that updates theTim Janik
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-05-19fixed SIZEOF_LONG==4 assumption with ENABLE_MEM_CHECK, from Art HaasTim Janik
Fri May 19 09:00:44 2000 Tim Janik <timj@gtk.org> * gmem.c (g_free): fixed SIZEOF_LONG==4 assumption with ENABLE_MEM_CHECK, from Art Haas <ahaas@neosoft.com>. * gslist.c (g_slist_reverse): shut up compiler. * gscanner.c (g_scanner_get_token_ll): removed inline assignment. * garray.c: remove index>=0 checks for unsigned indices. * gmain.c (g_idle_prepare): timeout assignment fix. * gtree.c (g_tree_node_rotate_right): shut up compiler.
2000-04-17Add configure test for garbage collector friendliness for GLib. IfSebastian Wilhelmi
2000-04-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * configure.in, acconfig.h: Add configure test for garbage collector friendliness for GLib. If enabled, ENABLE_GC_FRIENDLY will be defined. * garray.c, ghash.c, glist.c, gmain.c, gmem.c, gnode.c, gqueue.c, gslist.c, gtree.c: If ENABLE_GC_FRIENDLY is defined, NULLify all memory released by the user, but cached by GLib. This lets a garbage collector have a more correct view of the actually used memory.
2000-03-20Warn in case of an error during the call to poll(2). Closes Bug#7564 asSebastian Wilhelmi
2000-03-20 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gmain.c (g_main_poll): Warn in case of an error during the call to poll(2). Closes Bug#7564 as reported by David Helder <dhelder@umich.edu>.
2000-03-01minor optimization.Tim Janik
Wed Mar 1 10:39:39 2000 Tim Janik <timj@gtk.org> * gslist.c (g_slist_reverse): minor optimization. * testglib.c (g_node_test): added a couple of tests for g_node_copy(). * glib.h: * gnode.c (g_node_copy): new function to copy subtrees, supplied by dbsears@ix.netcom.com. changed iterator to walk the children list backwards, so we get down from O(n^2) to O(n). * gnode.c (g_node_first_sibling): applied patch from dbsears@ix.netcom.com to optimize access if node->parent is present. * gutils.c (g_get_any_init): backed out HAVE_PW_GECOS check around assignment of g_real_name, sicne HAVE_PW_GECOS is never defined and thus breaks the original code. * merged changes from 1.2.7. Sat Feb 19 19:43:29 2000 Tim Janik <timj@gtk.org> * testgmodule.c (main): added test to check that not yet bound symbols in shared libraries of the main module are retrievable, from David Gero. Fri Jan 28 11:37:41 2000 Owen Taylor <otaylor@redhat.com> Bug #4156 - Changes vaguely modelled after Scott Gifford's patch * gtimer.c (g_timer_elapsed): Never report negative times - clip times to 0. * gmain.c (g_timeout_prepare): Guard against unexpected clock shifts by never setting a timeout of more than data->interval msecs.
2000-01-26s/current_time/dispatch_time/ for the dispatch() handlers. refetch theTim Janik
Wed Jan 26 05:24:38 2000 Tim Janik <timj@gtk.org> * glib.h: * gmain.c: s/current_time/dispatch_time/ for the dispatch() handlers. refetch the current time after invocation of poll() to cover up for the time spent in that function call.
1999-10-04G_OS_FOO #defines. I *think* I got the cygwin and beos stuff right, butManish Singh
I haven't tested it. The respective porters should fix any screwups -Yosh
1999-07-2418:36. incorporated proposed cleanups from gtk-devel-list.Tim Janik
Sat Jul 24 20:11:35 1999 Tim Janik <timj@gtk.org> * merged GLib 1.3.0 with glib-1.2.3 from Fri Jul 16 22:18:36. * incorporated proposed cleanups from gtk-devel-list. * bumped version number to GLib-1.3.1 * glib.h: * gqueue.c: * gstring.c: * glist.c: removed string tokenisation (we got g_strsplit() and g_strjoin() already) and readline functions. s/g_list_delete/g_list_delete_link. implemented g_slist_delete_link. removed notion of g_ATEXIT() macro in glib.h, this is an *internal* macro, g_atexit() is provided for public consumption. added GTrashStack inline utility functions. reimplement double eneded queues. removed GStack implementation, people can use a queue or a (singly) linked list for this task. deprecated g_strescape(), we need the SunOS variants here. * gdate.c: added DEBUG_MSG() macro to wrap old messages. * *.*: CVS merges. * upgrade to libtool 1.3.3.
1999-05-08Port to BeOS by myself and Richard Offer.CDT 1999 Shawn T. Amundson
Sat May 8 01:52:29 CDT 1999 Shawn T. Amundson <amundson@gtk.org> * configure.in gerror.c gmain.c gstrfuncs.c gutils.c ltconfig ltmain.sh gmodule/Makefile.am gmodule/gmodule.c gmodule/gmoduleconf.h.in gmodule/gmodule-beos.c gthread/Makefile.am: Port to BeOS by myself and Richard Offer.
1999-04-24 Support added for building using a GNU toolchain on Win32,Tor Lillqvist
i.e. gcc -mno-cygwin on cygwin (a.k.a. mingw32, using egcs-1.1.2). * README.win32: Updated. * build-dll makefile.cygwin tests/makefile.cygwin: New files. * glib.h glib.def glibconfig.h.win32 makefile.msc: Slight updates. * gmain.c: No need to include <fcntl.h> and <io.h> on Win32. * gmain.c gutils.c testglib.c tests/string-test.c: Test for NATIVE_WIN32, not _MSC_VER. * gmutex.c: Must declare g_thread_functions_for_glib_use as exported (using the GUTILS_C_VAR macro). * gutils.c gmodule/libgplugin_[ab].c: LibMain not needed. * gmodule/gmoduleconf.h.win32: Need underscore with gcc. * gthread/gthread.c: With gcc on Win32, must use memcpy to assign value of g_thread_functions_for_glib_use (?). * makefile.msc tests/makefile.msc: Cosmetics.
1999-03-14Remove widechar tests and defines. (fd_set): Change the grep for `fd_mask'Raja R Harinath
* configure.in (glibconfig.h): Remove widechar tests and defines. (fd_set): Change the grep for `fd_mask' to search for `fd_set'. * gerror.c (fd_mask): Remove conditional typedef. It is not used elsewhere in the file. * gmain.c (fd_mask): Likewise.
1999-02-24inserted additional note to look for ChangeLog and AUTHORS file for a logCST 1999 Shawn T. Amundson
Wed Feb 24 00:08:42 CST 1999 Shawn T. Amundson <amundson@gtk.org> * *.[ch]: inserted additional note to look for ChangeLog and AUTHORS file for a log of modifications.
1999-02-10s/G_LOCK_DECLARE/G_LOCK_DEFINE/ throuhout glib. Added G_LOCK_EXTERN macroSebastian Wilhelmi
1999-02-10 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * glib.h: s/G_LOCK_DECLARE/G_LOCK_DEFINE/ throuhout glib. Added G_LOCK_EXTERN macro to declare a lock externally.
1999-02-02Release the main_loop lock around calls to prepare() and check() so thatOwen Taylor
Mon Feb 1 19:04:28 1999 Owen Taylor <otaylor@redhat.com> * gmain.c (g_main_iterate): Release the main_loop lock around calls to prepare() and check() so that we are not holding the main loop lock over user code.
1999-01-17added a define G_HOOK_DEFERRED_DESTROY, to substitute a noopTim Janik
Sun Jan 17 14:13:52 1999 Tim Janik <timj@gtk.org> * glib.h: added a define G_HOOK_DEFERRED_DESTROY, to substitute a noop GHookList.hook_destroy function. * ghook.c (g_hook_destroy_link): don't really call hook_destroy if it is G_HOOK_DEFERRED_DESTROY. for the case where we invoke hook->destroy() we now clean up the hook completely afterwards, i.e. data, func and destroy are immediately set to NULL and hook_free can't play with that values anymore. * gmain.c (g_source_add): set hook_destroy to G_HOOK_DEFERRED_DESTROY, instead of using an ugly _noop() hack, this is to avoid an uneccessary function invokation. set hook_free to g_source_destroy_func, this way we always invoke the destroy notifiers for user_data and source_data after execution of dispatch(). thus, g_source_destroy_func() will always be called within the main_loop lock (this wasn't really assured before), and can release and reaquire the look around destroy notifier invokation.
1999-01-17reentrancy fixupsTim Janik
1999-01-17incremented version number to 1.1.13, bin age 0, interface age 0.Tim Janik
Sun Jan 17 05:12:17 1999 Tim Janik <timj@gtk.org> * configure.in: incremented version number to 1.1.13, bin age 0, interface age 0. * glib.h: added hook_destroy member to struct _GHookList. * ghook.c (g_hook_destroy_link): if the hook_list defines a hook_destroy function, use that to marshal hook destruction notifiers. * gmain.c: removed g_source_free_func and added g_source_destroy_func, which marshalls the user_data and source_data destructors of sources outside of the main_loop lock. removed GIdleData struct since its single member callback can be passed as source_data directly. added a gboolean return value to all g_source_remove* functions, indicating whether the source could be removed, because these functions don't issue warnings upon unseccessful removals themselves. this way at least the caller gets a chance to warn upon failing removals. (g_main_iterate): set in_check_or_prepare around calls to check() or prepare(). (g_main_pending): simply return FALSE if called from within check() or prepare(). (g_main_iteration): issue a warning if called from within check() or prepare() and bail out with FALSE. (g_main_run): likewise. (g_source_remove_by_funcs_user_data): new function to remove sources by user data and function table. (g_idle_remove_by_data): new function to really remove idles only, since g_source_remove_by_user_data would remove timeouts or other sources as well.
1999-01-16Merge in current Win32 version. Almost no Unix code touched.Tor Lillqvist
* README.win32: More text. * config.h.win32 glibconfig.h.win32: Update to match the corresponding generated files on Unix. * makefile.msc: Update with new source files, and gthread library. Use the compiler flag -MD instead of using -D_DLL and "/nodefaultlib:libc msvcrt.lib" in the link phase. * glib.def: Include new functions, drop removed ones. * glib.h: Add comments about main loop and polling on Win32. (In general, it's only for the GIMP's use.) Add Win32 IO Channel functions. Remove the obsoleted old IO Channel stuff (which was in #if 0 already). * giowin32.c: New file. * gmain.c: Include config.h, conditionalize <sys/time.h> inclusion. Add g_poll implementation for Win32 (only for the GIMP's needs for now, it's hard or even impossible to be as clean and generic as on Unix). Implement g_get_current_time on Win32. If threads aren't supported, don't try to wake up main thread's loop. On Win32, use a semaphore and not a pipe to wake up the main loop. * gmessages.c: On Win32, allocate a console window if the standard output handle is invalid before writing to stdout, and reopen stdout to that console window. * giochannel.c: Conditionalize unistd.h inclusion. Some indentation cleanup. * gstrfuncs.c: Include <signal.h>. * gutils.c: On Win32, also check the HOMEDRIVE and HOMEPATH environment variables. * gmodule-dl.c gmodule-dld.c: In _g_module_build_path, don't add the "lib" prefix and ".so" or ".sl" suffix if already there. * gmodule-win32.c: Likewise for the ".dll" suffix. * gthread-posix.c: Conditionalize <sys/time.h> inclusion.
1999-01-07Call the source-specific free function when the hook is freed not when itOwen Taylor
Thu Jan 7 15:14:08 1999 Owen Taylor <otaylor@redhat.com> * gmain.c (g_source_free_func): Call the source-specific free function when the hook is freed not when it is destroyed; this fixes a bug where a timeout destroyed from itself would access already freed data.
1999-01-04eliminated extraneous "register" qualifiers in variable declarations.Tim Janik
Mon Jan 4 20:58:50 1999 Tim Janik <timj@gtk.org> * gscanner.c: eliminated extraneous "register" qualifiers in variable declarations. * gmain.c: #undef events and revents which may have been defined in sys/poll.h for SVR3,4 compatibility on some AIX systems. fix been provided by Philippe Defert <Philippe.Defert@cern.ch>.
1999-01-02avoid unneccessary extra hook referencing (the explicit hook referencingTim Janik
Sat Jan 2 02:20:59 1999 Tim Janik <timj@gtk.org> * ghook.c: (g_hook_list_invoke): (g_hook_list_invoke_check): (g_hook_list_marshal_check): (g_hook_list_marshal): avoid unneccessary extra hook referencing (the explicit hook referencing became unneccessarry with my changes from Mon Dec 21 21:48:29 1998). * gmain.c (g_main_iterate): fixed reference counting leaks with premature loop aborts. Fri Jan 1 22:47:44 1999 Tim Janik <timj@gtk.org> * gscanner.c (g_scanner_unexp_token): handle G_TOKEN_IDENTIFIER_NULL as G_TOKEN_IDENTIFIER.
1998-12-23don't cast to timeval since timeval is for some reason not always a structGeorge Lebl
Wed Dec 23 04:18:11 1998 George Lebl <jirka@5z.com> * gmain.c: (g_get_current_time) don't cast to timeval since timeval is for some reason not always a struct of longs, weird
1998-12-21there was a reference count race for hooks during invocation loops. sinceTim Janik
Mon Dec 21 21:48:29 1998 Tim Janik <timj@gtk.org> * glib.h: * gmain.c: there was a reference count race for hooks during invocation loops. since all (known) hook loop implementations, do currently start out with g_hook_first_valid() and iterate with g_hook_next_valid(), g_hook_first_valid() will now return a referenced hook, and g_hook_next_valid() will "eat" that, and eventually transfer it to the next hook. <sigh> unfortunately this requires g_hook_next_valid() to take the hook_list as additional argument. * gmain.c (g_main_iterate): adjusted callers of g_hook_next_valid().
1998-12-21default initialize source_timeout with -1 so we have a sane timeout valueTim Janik
Mon Dec 21 03:48:04 1998 Tim Janik <timj@gtk.org> * gmain.c (g_main_iterate): default initialize source_timeout with -1 so we have a sane timeout value if (*prpare) doesn't set it.
1998-12-19Add #defines defining scale of priorities.Owen Taylor
Sat Dec 19 16:56:02 1998 Owen Taylor <otaylor@redhat.com> * glib.h gmain.c (G_PRIORITY_LOW): Add #defines defining scale of priorities.
1998-12-19Allocate space for pollfd's _after_ adding poll wake-up-pipe record.Owen Taylor
Sat Dec 19 16:56:02 1998 Owen Taylor <otaylor@redhat.com> * gmain.c (g_main_poll): Allocate space for pollfd's _after_ adding poll wake-up-pipe record. * gmain.c (g_main_add_poll): Changed name of internal function g_main_add_poll_unlocked() back from the non-sensical g_main_add_unlocking_poll().
1998-12-19fixed up sys/poll.h and sys/types.h inclusions.Tim Janik
Sat Dec 19 04:27:17 1998 Tim Janik <timj@gtk.org> * fixed up sys/poll.h and sys/types.h inclusions.
1998-12-18 Dec 18 12:51:39 1998 Owen Taylor <otaylor@redhat.com>Owen Taylor
* gmain.c: Fix errors in computation of timeout expiration times > 1sec.
1998-12-18new function to check whether a main loop has been quitted. (g_main_new):Tim Janik
Fri Dec 18 00:03:17 1998 Tim Janik <timj@gtk.org> * glib.h: * gmain.c: (g_main_is_running): new function to check whether a main loop has been quitted. (g_main_new): added a gboolean argument to determine whether the loop should be considered initially running or not. however, g_main_run () will still reset the main loops running state to TRUE upon initial entrance. * gmain.c: (g_main_iterate): documented this function's purpose in 5 steps. for step 2), flag sources as G_SOURCE_READY even if !dispatch and check G_SOURCE_READY prior to (*prepare), so we don't call (*prepare) on them multiple times. Thu Dec 17 23:43:47 1998 Tim Janik <timj@gtk.org> * gmain.c (g_main_add_poll): reordered arguments, so GPollFD* comes first, <sigh> (sorry Snorfle, i should have let you know in the first place). (g_main_dispatch): stack G_HOOK_FLAG_IN_CALL flags. call source's destructor when destroying a source.
1998-12-17giounix.c: s/g_main_poll_add/g_main_remove_add/gCST 1998 Shawn T. Amundson
Wed Dec 16 22:32:13 CST 1998 Shawn T. Amundson <amundson@gtk.org> * glib.h: giounix.c: s/g_main_poll_add/g_main_remove_add/g s/g_main_poll_remove/g_main_remove_poll/g s/g_main_poll_add_unlocking/g_main_add_unlocking_poll/g (from Tim Janik) * gthread-posix.c: use g_free in mutex_free (from Tim Janik)
1998-12-17if !G_THREADS_ENABLED, eat the trailing semicolon with a bogus functionTim Janik
Thu Dec 17 04:10:49 1998 Tim Janik <timj@gtk.org> * glib.h (G_LOCK_DECLARE_*): if !G_THREADS_ENABLED, eat the trailing semicolon with a bogus function declaration, instead of with a bogus variable declarations, so we avoid unused variable warnings.
1998-12-16Updated to reflect the existence of gthread.Sebastian Wilhelmi
1998-12-16 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * docs/glib-config.1: Updated to reflect the existence of gthread. * gmain.c (g_main_poll_add_unlocking): Changed g_main_poll_add_unlocked to g_main_poll_add_unlocking to match semantic, (indeed, main_loop must be locked, when calling this function). Removed the unlocking from the end of that function, as that is not right. Made a 'HOLDS' comment above the function.
1998-12-16version bump to 1.1.8, binary age 0, interface age 0.Tim Janik
Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org> * configure.in: version bump to 1.1.8, binary age 0, interface age 0. * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and g_trylock() to G_TRYLOCK(), since these are macros that expand to nothing with --disable-threads. changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE(). changed semantics of g_thread_supported to g_thread_supported() so it can be used as a function like g_module_supported(). the actuall definition is still a macro that expands into a variable for performance reasons though. various indentation and coding style cleanups. * configure.in: added --enable-threads that defaults to yes. * gmutex.c: changed tests g_thread_supported to g_thread_supported (), changed variable settings of g_thread_supported to g_threads_got_initialized. garray.c: gcache.c: gdataset.c: gdate.c: ghash.c: glist.c: gmain.c: gnode.c: gslist.c: gstring.c: gtree.c: gutils.c: changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/, s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
1998-12-15This commit merges the glib-threads branch into the mainOwen Taylor
branch. See the ChangeLog for details of the changes. In brief overview: - The set of threading functions can be set - A default implementation is provided in -lgthread - All static data structures are locked using these functions if g_thread_init() is called.
1998-12-08fixes to #undef HAVE_POLL caseManish Singh
-Yosh
1998-12-02Merge main loop into head. This probably breaks Win32, untilOwen Taylor
someone does the necessary updates. Sat Nov 28 12:53:47 1998 Owen Taylor <otaylor@redhat.com> * Makefile.am configure.in acconfig.h giochannel.c glib.h glist.c gmain.c gutils.c: - Revised GIOChannel to provide a generic virtual-function based interface. - Added unix fd-based GIOChannel's - Added generic main-loop abstraction - Added timeouts and idle functions using main-loop abstraction.