added g_hash_table_find and a bunch of g_queue_*

2003-02-26 Hans Breuer  <hans@breuer.org>

	* glib/glib.def : added g_hash_table_find and a
	bunch of g_queue_*

	* glib/gmain.c : make it compile on win32,
	child_wake_up_pipe replaced by semaphore like it is done
	for the other wake_up_pipe

	* config.h.win32.in : added HAVE_INT64_AND_I64
	* glibconfig.h.win32.in : G_MAXSIZE .. G_M??INT64,
	and typedef for GPid

	* test/env-test.c : don't let the local log function
	collide in namespace with standard C
This commit is contained in:
Hans Breuer 2004-02-25 23:48:22 +00:00 committed by Hans Breuer
parent 28a267e306
commit fc9afe0d21
11 changed files with 170 additions and 3 deletions

View File

@ -1,3 +1,19 @@
2003-02-26 Hans Breuer <hans@breuer.org>
* glib/glib.def : added g_hash_table_find and a
bunch of g_queue_*
* glib/gmain.c : make it compile on win32,
child_wake_up_pipe replaced by semaphore like it is done
for the other wake_up_pipe
* config.h.win32.in : added HAVE_INT64_AND_I64
* glibconfig.h.win32.in : G_MAXSIZE .. G_M??INT64,
and typedef for GPid
* test/env-test.c : don't let the local log function
collide in namespace with standard C
2004-02-25 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gthread.c: For the PID thread priorities

View File

@ -1,3 +1,19 @@
2003-02-26 Hans Breuer <hans@breuer.org>
* glib/glib.def : added g_hash_table_find and a
bunch of g_queue_*
* glib/gmain.c : make it compile on win32,
child_wake_up_pipe replaced by semaphore like it is done
for the other wake_up_pipe
* config.h.win32.in : added HAVE_INT64_AND_I64
* glibconfig.h.win32.in : G_MAXSIZE .. G_M??INT64,
and typedef for GPid
* test/env-test.c : don't let the local log function
collide in namespace with standard C
2004-02-25 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gthread.c: For the PID thread priorities

View File

@ -1,3 +1,19 @@
2003-02-26 Hans Breuer <hans@breuer.org>
* glib/glib.def : added g_hash_table_find and a
bunch of g_queue_*
* glib/gmain.c : make it compile on win32,
child_wake_up_pipe replaced by semaphore like it is done
for the other wake_up_pipe
* config.h.win32.in : added HAVE_INT64_AND_I64
* glibconfig.h.win32.in : G_MAXSIZE .. G_M??INT64,
and typedef for GPid
* test/env-test.c : don't let the local log function
collide in namespace with standard C
2004-02-25 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gthread.c: For the PID thread priorities

View File

@ -1,3 +1,19 @@
2003-02-26 Hans Breuer <hans@breuer.org>
* glib/glib.def : added g_hash_table_find and a
bunch of g_queue_*
* glib/gmain.c : make it compile on win32,
child_wake_up_pipe replaced by semaphore like it is done
for the other wake_up_pipe
* config.h.win32.in : added HAVE_INT64_AND_I64
* glibconfig.h.win32.in : G_MAXSIZE .. G_M??INT64,
and typedef for GPid
* test/env-test.c : don't let the local log function
collide in namespace with standard C
2004-02-25 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gthread.c: For the PID thread priorities

View File

@ -1,3 +1,19 @@
2003-02-26 Hans Breuer <hans@breuer.org>
* glib/glib.def : added g_hash_table_find and a
bunch of g_queue_*
* glib/gmain.c : make it compile on win32,
child_wake_up_pipe replaced by semaphore like it is done
for the other wake_up_pipe
* config.h.win32.in : added HAVE_INT64_AND_I64
* glibconfig.h.win32.in : G_MAXSIZE .. G_M??INT64,
and typedef for GPid
* test/env-test.c : don't let the local log function
collide in namespace with standard C
2004-02-25 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gthread.c: For the PID thread priorities

View File

@ -1,3 +1,19 @@
2003-02-26 Hans Breuer <hans@breuer.org>
* glib/glib.def : added g_hash_table_find and a
bunch of g_queue_*
* glib/gmain.c : make it compile on win32,
child_wake_up_pipe replaced by semaphore like it is done
for the other wake_up_pipe
* config.h.win32.in : added HAVE_INT64_AND_I64
* glibconfig.h.win32.in : G_MAXSIZE .. G_M??INT64,
and typedef for GPid
* test/env-test.c : don't let the local log function
collide in namespace with standard C
2004-02-25 Sebastian Wilhelmi <seppi@seppi.de>
* configure.in, glib/gthread.c: For the PID thread priorities

View File

@ -178,6 +178,7 @@
#else /* _MSC_VER */
/* #undef HAVE_LONG_LONG */
#endif /* _MSC_VER */
#define HAVE_INT64_AND_I64 1
/* define if system printf can print long long */
#define HAVE_LONG_LONG_FORMAT 1

View File

@ -173,6 +173,7 @@ EXPORTS
g_get_user_name
g_getenv
g_hash_table_destroy
g_hash_table_find
g_hash_table_foreach
g_hash_table_foreach_remove
g_hash_table_foreach_steal
@ -423,19 +424,43 @@ EXPORTS
g_quark_from_string
g_quark_to_string
g_quark_try_string
g_queue_copy
g_queue_delete_link
g_queue_find
g_queue_foreach
g_queue_free
g_queue_get_length
g_queue_index
g_queue_insert_after
g_queue_insert_before
g_queue_insert_sorted
g_queue_is_empty
g_queue_link_index
g_queue_new
g_queue_peek_head
g_queue_peek_head_link
g_queue_peek_nth
g_queue_peek_nth_link
g_queue_peek_tail
g_queue_peek_tail_link
g_queue_pop_head
g_queue_pop_head_link
g_queue_pop_nth
g_queue_pop_nth_link
g_queue_pop_tail
g_queue_pop_tail_link
g_queue_push_head
g_queue_push_head_link
g_queue_push_nth
g_queue_push_nth_link
g_queue_push_tail
g_queue_push_tail_link
g_queue_remove
g_queue_remove_all
g_queue_reverse
g_queue_sort
g_queue_unlink
g_rand_copy
g_rand_double
g_rand_double_range
g_rand_free

View File

@ -251,7 +251,11 @@ enum {
};
static gint child_watch_init_state = CHILD_WATCH_UNINITIALIZED;
static gint child_watch_count = 0;
#ifndef G_OS_WIN32
static gint child_watch_wake_up_pipe[2] = {0, 0};
#else
static HANDLE child_watch_wake_up_semaphore = NULL;
#endif
G_LOCK_DEFINE_STATIC (main_context_list);
static GSList *main_context_list = NULL;
@ -692,9 +696,9 @@ g_main_context_unref (GMainContext *context)
static void
g_main_context_init_pipe (GMainContext *context)
{
# ifndef G_OS_WIN32
if (context->wake_up_pipe[0] != -1)
return;
# ifndef G_OS_WIN32
if (pipe (context->wake_up_pipe) < 0)
g_error ("Cannot create pipe main loop wake-up: %s\n",
g_strerror (errno));
@ -702,6 +706,8 @@ g_main_context_init_pipe (GMainContext *context)
context->wake_up_rec.fd = context->wake_up_pipe[0];
context->wake_up_rec.events = G_IO_IN;
# else
if (context->wake_up_semaphore != NULL)
return;
context->wake_up_semaphore = CreateSemaphore (NULL, 0, 100, NULL);
if (context->wake_up_semaphore == NULL)
g_error ("Cannot create wake-up semaphore: %s",
@ -747,8 +753,12 @@ g_main_context_new ()
context->owner = NULL;
context->waiters = NULL;
# ifndef G_OS_WIN32
context->wake_up_pipe[0] = -1;
context->wake_up_pipe[1] = -1;
# else
context->wake_up_semaphore = NULL;
# endif
#endif
context->ref_count = 1;
@ -3253,9 +3263,15 @@ check_for_child_exited (GSource *source)
if (child_watch_source->count < count)
{
#ifndef G_OS_WIN32
gint child_status;
if (waitpid (child_watch_source->pid, &child_status, WNOHANG) > 0)
#else
DWORD child_status;
if (GetExitCodeProcess (child_watch_source->pid, &child_status) &&
child_status != STILL_ACTIVE)
#endif
{
child_watch_source->child_status = child_status;
child_watch_source->child_exited = TRUE;
@ -3319,7 +3335,11 @@ g_child_watch_signal_handler (int signum)
if (child_watch_init_state == CHILD_WATCH_INITIALIZED_THREADED)
{
#ifndef G_OS_WIN32
write (child_watch_wake_up_pipe[1], "B", 1);
#else
ReleaseSemaphore(child_watch_wake_up_semaphore, 1, NULL);
#endif
}
else
{
@ -3336,7 +3356,11 @@ g_child_watch_source_init_single (void)
child_watch_init_state = CHILD_WATCH_INITIALIZED_SINGLE;
#ifndef G_OS_WIN32
signal (SIGCHLD, g_child_watch_signal_handler);
#else
/* FIXME: really nothing to be done ? --hb */
#endif
}
static gpointer
@ -3351,15 +3375,21 @@ child_watch_helper_thread (gpointer data)
poll_func = g_poll;
#endif
#ifndef G_OS_WIN32
fds.fd = child_watch_wake_up_pipe[0];
fds.events = G_IO_IN;
#endif
while (1)
{
gchar b[20];
GSList *list;
#ifndef G_OS_WIN32
read (child_watch_wake_up_pipe[0], b, 20);
#else
WaitForSingleObject(child_watch_wake_up_semaphore, INFINITE);
#endif
/* We were woken up. Wake up all other contexts in all other threads */
G_UNLOCK (main_context_list);
@ -3382,16 +3412,24 @@ g_child_watch_source_init_multi_threaded (void)
g_assert (g_thread_supported());
#ifndef G_OS_WIN32
if (pipe (child_watch_wake_up_pipe) < 0)
g_error ("Cannot create wake up pipe: %s\n", g_strerror (errno));
fcntl (child_watch_wake_up_pipe[1], F_SETFL, O_NONBLOCK | fcntl (child_watch_wake_up_pipe[1], F_GETFL));
#else
child_watch_wake_up_semaphore = CreateSemaphore (NULL, 0, G_MAXINT, NULL);
#endif
/* We create a helper thread that polls on the wakeup pipe indefinitely */
/* FIXME: Think this through for races */
if (g_thread_create (child_watch_helper_thread, NULL, FALSE, &error) == NULL)
g_error ("Cannot create a thread to monitor child exit status: %s\n", error->message);
child_watch_init_state = CHILD_WATCH_INITIALIZED_THREADED;
#ifndef G_OS_WIN32
signal (SIGCHLD, g_child_watch_signal_handler);
#else
/* FIXME: really nothing to be done ? --hb */
#endif
}
static void

View File

@ -27,6 +27,11 @@ G_BEGIN_DECLS
#define G_MINLONG LONG_MIN
#define G_MAXLONG LONG_MAX
#define G_MAXULONG ULONG_MAX
#define G_MAXSIZE UINT_MAX
#define G_MININT64 G_GINT64_CONSTANT(0x8000000000000000)
#define G_MAXINT64 G_GINT64_CONSTANT(0x7fffffffffffffff)
#define G_MAXUINT64 G_GINT64_CONSTANT(0xffffffffffffffffU)
typedef signed char gint8;
typedef unsigned char guint8;
@ -187,6 +192,8 @@ union _GSystemThread
#define G_MODULE_SUFFIX "dll"
typedef int GPid;
G_END_DECLS
#endif /* GLIBCONFIG_H */

View File

@ -44,7 +44,7 @@
#endif
static void
log (const gchar *log_domain,
_log (const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
gpointer user_data)
@ -62,7 +62,7 @@ main (int argc, char *argv[])
gchar *value1 = "works";
gchar *value2 = "again";
g_log_set_handler ("GLib", G_LOG_LEVEL_CRITICAL, log, NULL);
g_log_set_handler ("GLib", G_LOG_LEVEL_CRITICAL, _log, NULL);
data = g_getenv (variable);
g_assert (data == NULL && "TEST_G_SETENV already set");