mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 23:58:54 +02:00
Warn if no callback. Call callback correctly. (g_io_win32_create_watch):
2000-12-14 Tor Lillqvist <tml@iki.fi> * giowin32.c (g_io_win32_dispatch): Warn if no callback. Call callback correctly. (g_io_win32_create_watch): Fix typo. (g_io_win32_fd_create_watch): Ditto. (g_io_channel_unix_new): If it is a file descriptor (i.e., a Unix fd lookalike provided by the C library), call g_io_channel_win32_new_fd(). If it is a socket (from WinSock), call g_io_cahnnel_win32_new_stream_socket(). Hopefully sockets and fds don't overlap. TODO: Implement also datagram sockets. (g_io_channel_win32_poll): Call g_main_context_get_poll_func(). * gcompletion.h: Include <unistd.h> only on Unix. Is this inclusion really needed here? OTOH, do include <stddef.h>, for size_t. * gmessages.c: (Win32) Don't define a function called "write" that might clash with the prototype from <io.h>, use a #define. * glib.def: Update. * gmain.c (g_source_add_poll): Don't return a value from void function. (g_main_context_get_poll_func): Compile also for non-Win32, as presumably was intended. The result var is a GPollFunc, not a GPollFunc*. Return the result! gobject: 2000-12-14 Tor Lillqvist <tml@iki.fi> * makefile.mingw.in: Update, include parts from Makefile.am to build gmarshal.[ch]. Some day, we won't need these separate makefiles for Win32 compilation. I hope. * makefile.msc.in: Update. No use trying to build gmarshal.[ch] here, it would require Unixish tools. MSVC users building from CVS sources are out of luck. * gobject.def: Update.
This commit is contained in:
committed by
Tor Lillqvist
parent
b0baf3db03
commit
b74e7d2f47
@@ -28,7 +28,10 @@
|
||||
#define __G_COMPLETION_H__
|
||||
|
||||
#include <glist.h>
|
||||
#include <stddef.h> /* For size_t */
|
||||
#ifdef G_OS_UNIX
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@@ -354,11 +354,19 @@ g_io_win32_dispatch (GSource *source,
|
||||
GSourceFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GIOFunc func = (GIOFunc)callback;
|
||||
GIOWin32Watch *watch = (GIOWin32Watch *)source;
|
||||
|
||||
return (*callback) (watch->channel,
|
||||
watch->pollfd.revents & watch->condition,
|
||||
user_data);
|
||||
if (!func)
|
||||
{
|
||||
g_warning ("GIOWin32Watch dispatched without callback\n"
|
||||
"You must call g_source_connect().");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (*func) (watch->channel,
|
||||
watch->pollfd.revents & watch->condition,
|
||||
user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -379,7 +387,7 @@ static GSourceFuncs win32_watch_funcs = {
|
||||
static GSource *
|
||||
g_io_win32_create_watch (GIOChannel *channel,
|
||||
GIOCondition condition,
|
||||
int (*reader) (int, guchar *, int)))
|
||||
int (*reader) (int, guchar *, int))
|
||||
{
|
||||
GIOWin32Channel *win32_channel = (GIOWin32Channel *) channel;
|
||||
GIOWin32Watch *watch;
|
||||
@@ -741,7 +749,7 @@ static GSource *
|
||||
g_io_win32_sock_create_watch (GIOChannel *channel,
|
||||
GIOCondition condition)
|
||||
{
|
||||
return g_io_win32_add_watch (channel, condition, sock_reader);
|
||||
return g_io_win32_create_watch (channel, condition, sock_reader);
|
||||
}
|
||||
|
||||
static GIOFuncs win32_channel_msg_funcs = {
|
||||
@@ -837,7 +845,16 @@ g_io_channel_win32_new_stream_socket (int socket)
|
||||
GIOChannel *
|
||||
g_io_channel_unix_new (gint fd)
|
||||
{
|
||||
return g_io_channel_win32_new_fd (fd);
|
||||
struct stat st;
|
||||
|
||||
if (fstat (fd, &st) == 0)
|
||||
return g_io_channel_win32_new_fd (fd);
|
||||
|
||||
if (getsockopt (fd, SOL_SOCKET, SO_TYPE, NULL, NULL) != SO_ERROR)
|
||||
return g_io_channel_win32_new_stream_socket(fd);
|
||||
|
||||
g_warning ("%d isn't a file descriptor or a socket", fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gint
|
||||
@@ -864,7 +881,7 @@ g_io_channel_win32_poll (GPollFD *fds,
|
||||
|
||||
g_return_val_if_fail (n_fds >= 0, 0);
|
||||
|
||||
result = (*g_main_win32_get_poll_func ()) (fds, n_fds, timeout);
|
||||
result = (*g_main_context_get_poll_func (NULL)) (fds, n_fds, timeout);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -157,6 +157,7 @@ EXPORTS
|
||||
g_idle_add
|
||||
g_idle_add_full
|
||||
g_idle_remove_by_data
|
||||
g_idle_source_new
|
||||
g_int_equal
|
||||
g_int_hash
|
||||
g_io_add_watch
|
||||
@@ -215,17 +216,26 @@ EXPORTS
|
||||
g_log_set_fatal_mask
|
||||
g_log_set_handler
|
||||
g_logv
|
||||
g_main_add_poll
|
||||
g_main_destroy
|
||||
g_main_is_running
|
||||
g_main_iteration
|
||||
g_main_new
|
||||
g_main_pending
|
||||
g_main_quit
|
||||
g_main_remove_poll
|
||||
g_main_run
|
||||
g_main_set_poll_func
|
||||
g_main_win32_get_poll_func
|
||||
g_main_context_add_poll
|
||||
g_main_context_check
|
||||
g_main_context_default
|
||||
g_main_context_dispatch
|
||||
g_main_context_find_source_by_funcs_user_data
|
||||
g_main_context_find_source_by_id
|
||||
g_main_context_find_source_by_user_data
|
||||
g_main_context_get
|
||||
g_main_context_get_poll_func
|
||||
g_main_context_iteration
|
||||
g_main_context_pending
|
||||
g_main_context_prepare
|
||||
g_main_context_query
|
||||
g_main_context_remove_poll
|
||||
g_main_context_set_poll_func
|
||||
g_main_loop_destroy
|
||||
g_main_loop_is_running
|
||||
g_main_loop_new
|
||||
g_main_loop_quit
|
||||
g_main_loop_run
|
||||
g_malloc
|
||||
g_malloc0
|
||||
g_markup_error_quark
|
||||
@@ -397,10 +407,24 @@ EXPORTS
|
||||
g_slist_sort
|
||||
g_slist_sort_with_data
|
||||
g_snprintf
|
||||
g_source_add
|
||||
g_source_add_poll
|
||||
g_source_attach
|
||||
g_source_destroy
|
||||
g_source_get_can_recurse
|
||||
g_source_get_context
|
||||
g_source_get_current_time
|
||||
g_source_get_id
|
||||
g_source_get_priority
|
||||
g_source_new
|
||||
g_source_ref
|
||||
g_source_remove
|
||||
g_source_remove_by_source_data
|
||||
g_source_remove_by_funcs_user_data
|
||||
g_source_remove_by_user_data
|
||||
g_source_set_callback
|
||||
g_source_set_callback_indirect
|
||||
g_source_set_can_recurse
|
||||
g_source_set_priority
|
||||
g_source_unref
|
||||
g_spaced_primes_closest
|
||||
g_spawn_async
|
||||
g_spawn_async_with_pipes
|
||||
@@ -432,6 +456,7 @@ EXPORTS
|
||||
g_strdelimit
|
||||
g_strdown
|
||||
g_strdup
|
||||
g_strdupv
|
||||
g_strdup_printf
|
||||
g_strdup_vprintf
|
||||
g_strerror
|
||||
@@ -486,6 +511,7 @@ EXPORTS
|
||||
g_threads_got_initialized
|
||||
g_timeout_add
|
||||
g_timeout_add_full
|
||||
g_timeout_source_new
|
||||
g_timer_destroy
|
||||
g_timer_elapsed
|
||||
g_timer_new
|
||||
|
12
glib/gmain.c
12
glib/gmain.c
@@ -904,7 +904,7 @@ g_source_add_poll (GSource *source,
|
||||
|
||||
g_return_if_fail (source != NULL);
|
||||
g_return_if_fail (fd != NULL);
|
||||
g_return_val_if_fail (!SOURCE_DESTROYED (source), 0);
|
||||
g_return_if_fail (!SOURCE_DESTROYED (source));
|
||||
|
||||
context = source->context;
|
||||
|
||||
@@ -2440,8 +2440,6 @@ g_main_context_set_poll_func (GMainContext *context,
|
||||
UNLOCK_CONTEXT (context);
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
|
||||
/**
|
||||
* g_main_context_get_poll_func:
|
||||
* @context: a #GMainContext
|
||||
@@ -2453,7 +2451,7 @@ g_main_context_set_poll_func (GMainContext *context,
|
||||
GPollFunc
|
||||
g_main_context_get_poll_func (GMainContext *context)
|
||||
{
|
||||
GPollFunc *result;
|
||||
GPollFunc result;
|
||||
|
||||
if (!context)
|
||||
context = g_main_context_default ();
|
||||
@@ -2461,9 +2459,9 @@ g_main_context_get_poll_func (GMainContext *context)
|
||||
LOCK_CONTEXT (context);
|
||||
result = context->poll_func;
|
||||
UNLOCK_CONTEXT (context);
|
||||
}
|
||||
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
/* HOLDS: context's lock */
|
||||
/* Wake the main loop up from a poll() */
|
||||
@@ -2477,7 +2475,7 @@ g_main_context_wakeup (GMainContext *context)
|
||||
#ifndef G_OS_WIN32
|
||||
write (context->wake_up_pipe[1], "A", 1);
|
||||
#else
|
||||
ReleaseSemaphore (context->context->wake_up_semaphore, 1, NULL);
|
||||
ReleaseSemaphore (context->wake_up_semaphore, 1, NULL);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@@ -98,15 +98,18 @@ static gboolean alloc_console_called = FALSE;
|
||||
/* Just use stdio. If we're out of memory, we're hosed anyway. */
|
||||
#undef write
|
||||
static inline int
|
||||
write (FILE *fd,
|
||||
const char *buf,
|
||||
int len)
|
||||
dowrite (FILE *fd,
|
||||
const void *buf,
|
||||
unsigned int len)
|
||||
{
|
||||
fwrite (buf, len, 1, fd);
|
||||
fflush (fd);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
#define write(fd, buf, len) dowrite(fd, buf, len)
|
||||
|
||||
static void
|
||||
ensure_stdout_valid (void)
|
||||
{
|
||||
|
Reference in New Issue
Block a user