#include <mono/io-layer/collection.h>
#include <mono/io-layer/handles-private.h>
-#define LOGDEBUG(...)
-// #define LOGDEBUG(...) g_message(__VA_ARGS__)
+#if 0
+// #define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
static pthread_t collection_thread_id;
if (!_wapi_shm_enabled ())
return;
- LOGDEBUG ("%s: (%d) Starting a collection", __func__, _wapi_getpid ());
+ DEBUG ("%s: (%d) Starting a collection", __func__, _wapi_getpid ());
/* Become the collection master */
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
- LOGDEBUG ("%s: (%d) Master set", __func__, _wapi_getpid ());
+ DEBUG ("%s: (%d) Master set", __func__, _wapi_getpid ());
/* If count has changed, someone else jumped in as master */
if (count == _wapi_shared_layout->collection_count) {
data = &_wapi_shared_layout->handles[i];
if (data->timestamp < too_old) {
- LOGDEBUG ("%s: (%d) Deleting handle 0x%x", __func__, _wapi_getpid (), i);
+ DEBUG ("%s: (%d) Deleting handle 0x%x", __func__, _wapi_getpid (), i);
memset (&_wapi_shared_layout->handles[i], '\0', sizeof(struct _WapiHandleShared));
}
}
_wapi_handle_unlock_shared_handles ();
- LOGDEBUG ("%s: (%d) Collection done", __func__, _wapi_getpid ());
+ DEBUG ("%s: (%d) Collection done", __func__, _wapi_getpid ());
}
#include "mono-mutex.h"
-#undef DEBUG
-
/* A critical section is really just like a lightweight mutex. It
* can't be waited for, and doesn't have a handle.
*/
#define CMSG_SPACE(size) (sizeof (struct cmsghdr) + (size))
#endif
-#define LOGDEBUG(...)
-// #define LOGDEBUG(...) g_message(__VA_ARGS__)
+#if 0
+// #define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
static mono_mutex_t req_mutex;
static mono_once_t attr_key_once = MONO_ONCE_INIT;
/* The next loop around poll() should tidy up */
}
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
if(msg.msg_flags & MSG_OOB) {
g_message ("%s: OOB data received", __func__);
}
cmsg=CMSG_FIRSTHDR (&msg);
if(cmsg!=NULL && cmsg->cmsg_level==SOL_SOCKET &&
cmsg->cmsg_type==SCM_RIGHTS) {
- LOGDEBUG ("%s: cmsg->cmsg_len=%d", __func__, cmsg->cmsg_len);
- LOGDEBUG ("%s: cmsg->level=%d cmsg->type=%d", __func__, cmsg->cmsg_level, cmsg->cmsg_type);
+ DEBUG ("%s: cmsg->cmsg_len=%d", __func__, cmsg->cmsg_len);
+ DEBUG ("%s: cmsg->level=%d cmsg->type=%d", __func__, cmsg->cmsg_level, cmsg->cmsg_type);
memcpy (fds, (int *)CMSG_DATA (cmsg), sizeof(int)*3);
*has_fds=TRUE;
- LOGDEBUG ("%s: fd[0]=%d, fd[1]=%d, fd[2]=%d", __func__, fds[0], fds[1], fds[2]);
+ DEBUG ("%s: fd[0]=%d, fd[1]=%d, fd[2]=%d", __func__, fds[0], fds[1], fds[2]);
} else {
- LOGDEBUG ("%s: no ancillary data", __func__);
+ DEBUG ("%s: no ancillary data", __func__);
*has_fds=FALSE;
}
}
while (ret==-1 && errno==EINTR);
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
if(ret==-1 || ret != sizeof(WapiHandleResponse)) {
g_warning ("%s: Send error: %s", __func__, strerror (errno));
/* The next loop around poll() should tidy up */
#include <mono/io-layer/daemon-private.h>
#include <mono/io-layer/socket-wrappers.h>
-#define LOGDEBUG(...)
-#undef DEBUG
-// #define LOGDEBUG(...) g_message(__VA_ARGS__)
+#if 0
+// #define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
/* The shared thread codepath doesn't seem to work yet... */
#undef _POSIX_THREAD_PROCESS_SHARED
{
guint32 i;
- LOGDEBUG ("%s: Seeing if we should exit", __func__);
+ DEBUG ("%s: Seeing if we should exit", __func__);
if(nfds>1) {
- LOGDEBUG ("%s: Still got clients", __func__);
+ DEBUG ("%s: Still got clients", __func__);
return;
}
i<_wapi_shared_data[0]->num_segments * _WAPI_HANDLES_PER_SEGMENT;
i++) {
if(daemon_channel_data->open_handles[i]>0) {
- LOGDEBUG ("%s: Still got handle references", __func__);
+ DEBUG ("%s: Still got handle references", __func__);
_wapi_shared_data[0]->daemon_running=DAEMON_RUNNING;
return;
}
fds[0].events=POLLIN;
fds[0].revents=0;
- LOGDEBUG ("%s: Last connect check", __func__);
+ DEBUG ("%s: Last connect check", __func__);
if(poll (fds, 1, 0)>0) {
/* Someone did connect, so carry on running */
- LOGDEBUG ("%s: Someone connected", __func__);
+ DEBUG ("%s: Someone connected", __func__);
_wapi_shared_data[0]->daemon_running=DAEMON_RUNNING;
return;
}
#endif
- LOGDEBUG ("%s: Byebye", __func__);
+ DEBUG ("%s: Byebye", __func__);
cleanup ();
exit (0);
*/
static void signal_handler (int signo)
{
- LOGDEBUG ("%s: daemon received signal %d", __func__, signo);
+ DEBUG ("%s: daemon received signal %d", __func__, signo);
cleanup ();
exit (-1);
_wapi_shared_data[segment]->handles[idx].ref++;
channel_data->open_handles[handle]++;
- LOGDEBUG ("%s: handle 0x%x ref now %d (%d this process)", __func__, handle,
+ DEBUG ("%s: handle 0x%x ref now %d (%d this process)", __func__, handle,
_wapi_shared_data[segment]->handles[idx].ref,
channel_data->open_handles[handle]);
}
_wapi_shared_data[segment]->handles[idx].ref--;
channel_data->open_handles[handle]--;
- LOGDEBUG ("%s: handle 0x%x ref now %d (%d this process)", __func__, handle,
+ DEBUG ("%s: handle 0x%x ref now %d (%d this process)", __func__, handle,
_wapi_shared_data[segment]->handles[idx].ref,
channel_data->open_handles[handle]);
g_warning ("%s: per-process open_handles mismatch, set to %d, should be 0",__func__, channel_data->open_handles[handle]);
}
- LOGDEBUG ("%s: Destroying handle 0x%x", __func__, handle);
+ DEBUG ("%s: Destroying handle 0x%x", __func__, handle);
/* if this was a file handle, save the device and
* inode numbers so we can scan the share info data
exit (-1);
}
- LOGDEBUG ("%s: Removing client fd %d", __func__, fd);
+ DEBUG ("%s: Removing client fd %d", __func__, fd);
if (channel_data->io_source == 0) {
- LOGDEBUG ("%s: channel already closed for fd %d", __func__, fd);
+ DEBUG ("%s: channel already closed for fd %d", __func__, fd);
return;
}
handle_count=channel_data->open_handles[i];
for(j=0; j<handle_count; j++) {
- LOGDEBUG ("%s: closing handle 0x%x for client at index %d", __func__, i, g_io_channel_unix_get_fd (channel));
+ DEBUG ("%s: closing handle 0x%x for client at index %d", __func__, i, g_io_channel_unix_get_fd (channel));
/* Ignore the hint to the client to destroy
* the handle private data
*/
if (file_handle->device == sharekey->device &&
file_handle->inode == sharekey->inode) {
- LOGDEBUG ("%s: found one, handle %p", __func__, handle);
+ DEBUG ("%s: found one, handle %p", __func__, handle);
return(TRUE);
} else {
return(FALSE);
ShareKey sharekey;
gpointer file_handle;
- LOGDEBUG ("%s: Checking if anything has (dev 0x%llx, inode %lld) still open", __func__, device, inode);
+ DEBUG ("%s: Checking if anything has (dev 0x%llx, inode %lld) still open", __func__, device, inode);
sharekey.device = device;
sharekey.inode = inode;
/* Delete this share info, as the last handle to it
* has been closed
*/
- LOGDEBUG ("%s: Deleting share data for (dev 0x%llx inode %lld)", __func__, device, inode);
+ DEBUG ("%s: Deleting share data for (dev 0x%llx inode %lld)", __func__, device, inode);
g_hash_table_remove (file_share_hash, &sharekey);
}
* _wapi_handle_set_signal_state() unless we have
* process-shared pthread support.
*/
- LOGDEBUG ("%s: Set thread handle %p signalled, because its process died", __func__, handle);
+ DEBUG ("%s: Set thread handle %p signalled, because its process died", __func__, handle);
thread_handle->exitstatus=0;
* This may happen if we use Process.EnableRaisingEvents +
* process.Exited event and the parent has finished.
*/
- LOGDEBUG ("%s: Couldn't find handle for process %d!", __func__, pid);
+ DEBUG ("%s: Couldn't find handle for process %d!", __func__, pid);
} else {
/* Signal the handle. Don't use
* _wapi_handle_set_signal_state() unless we have
*/
struct timeval tv;
- LOGDEBUG ("%s: Set process %d exitstatus to %d", __func__, pid,
+ DEBUG ("%s: Set process %d exitstatus to %d", __func__, pid,
WEXITSTATUS (status));
/* If the child terminated due to the receipt of a signal,
check_processes=FALSE;
- LOGDEBUG ("%s: Reaping processes", __func__);
+ DEBUG ("%s: Reaping processes", __func__);
while(TRUE) {
pid=waitpid (-1, &status, WNOHANG);
return;
} else {
/* pid contains the ID of a dead process */
- LOGDEBUG ( "%s: process %d reaped", __func__, pid);
+ DEBUG ( "%s: process %d reaped", __func__, pid);
process_post_mortem (pid, status);
}
}
ref_handle (channel_data, handle);
- LOGDEBUG ("%s: returning new handle 0x%x", __func__, handle);
+ DEBUG ("%s: returning new handle 0x%x", __func__, handle);
resp.type=WapiHandleResponseType_New;
resp.u.new.type=type;
if(shared->type!=WAPI_HANDLE_UNUSED && handle!=0) {
ref_handle (channel_data, handle);
- LOGDEBUG ("%s: returning new handle 0x%x", __func__, handle);
+ DEBUG ("%s: returning new handle 0x%x", __func__, handle);
resp.type=WapiHandleResponseType_Open;
resp.u.new.type=shared->type;
resp.type=WapiHandleResponseType_Close;
resp.u.close.destroy=unref_handle (channel_data, handle);
- LOGDEBUG ("%s: unreffing handle 0x%x", __func__, handle);
+ DEBUG ("%s: unreffing handle 0x%x", __func__, handle);
send_reply (channel, &resp);
}
resp.type=WapiHandleResponseType_Scratch;
resp.u.scratch.idx=_wapi_handle_scratch_store_internal (length, &resp.u.scratch.remap);
- LOGDEBUG ("%s: allocating scratch index 0x%x", __func__, resp.u.scratch.idx);
+ DEBUG ("%s: allocating scratch index 0x%x", __func__, resp.u.scratch.idx);
send_reply (channel, &resp);
}
resp.type=WapiHandleResponseType_ScratchFree;
_wapi_handle_scratch_delete_internal (scratch_idx);
- LOGDEBUG ("%s: deleting scratch index 0x%x", __func__, scratch_idx);
+ DEBUG ("%s: deleting scratch index 0x%x", __func__, scratch_idx);
send_reply (channel, &resp);
}
resp.type = WapiHandleResponseType_ProcessKill;
- LOGDEBUG ("%s: kill (%d, %d)", __func__, process_kill.pid, process_kill.signo);
+ DEBUG ("%s: kill (%d, %d)", __func__, process_kill.pid, process_kill.signo);
if (kill (process_kill.pid, process_kill.signo) == -1) {
resp.u.process_kill.err = errno;
- LOGDEBUG ("%s: kill (%d, %d) failed: %d", __func__, process_kill.pid, process_kill.signo, resp.u.process_kill.err);
+ DEBUG ("%s: kill (%d, %d) failed: %d", __func__, process_kill.pid, process_kill.signo, resp.u.process_kill.err);
}
send_reply (channel, &resp);
*/
process_handle_data->exec_errno=gerr->code;
} else {
- LOGDEBUG ("%s: forking", __func__);
+ DEBUG ("%s: forking", __func__);
/* Fork, exec cmd with args and optional env,
* and return the handles with pid and blank
env[env_count+2]=NULL;
}
-#ifdef DEBUG
- LOGDEBUG ("%s: exec()ing [%s] in dir [%s]", __func__, cmd, dir);
+#ifdef DEBUG_ENABLED
+ DEBUG ("%s: exec()ing [%s] in dir [%s]", __func__, cmd, dir);
{
i=0;
while(argv[i]!=NULL) {
- LOGDEBUG ("arg %d: [%s]", i, argv[i]);
+ DEBUG ("arg %d: [%s]", i, argv[i]);
i++;
}
i=0;
while(env[i]!=NULL) {
- LOGDEBUG ("env %d: [%s]", i, env[i]);
+ DEBUG ("env %d: [%s]", i, env[i]);
i++;
}
}
resp.type = WapiHandleResponseType_SetShare;
- LOGDEBUG ("%s: Setting share for file (dev:0x%llx, ino:%lld) mode 0x%x access 0x%x", __func__, set_share.device, set_share.inode, set_share.sharemode, set_share.access);
+ DEBUG ("%s: Setting share for file (dev:0x%llx, ino:%lld) mode 0x%x access 0x%x", __func__, set_share.device, set_share.inode, set_share.sharemode, set_share.access);
sharemode_set (set_share.device, set_share.inode, set_share.sharemode,
set_share.access);
resp.type = WapiHandleResponseType_GetOrSetShare;
- LOGDEBUG ("%s: Getting share status for file (dev:0x%llx, ino:%lld)", __func__, get_share.device, get_share.inode);
+ DEBUG ("%s: Getting share status for file (dev:0x%llx, ino:%lld)", __func__, get_share.device, get_share.inode);
resp.u.get_or_set_share.exists = sharemode_get (get_share.device, get_share.inode, &resp.u.get_or_set_share.sharemode, &resp.u.get_or_set_share.access);
if (resp.u.get_or_set_share.exists) {
- LOGDEBUG ("%s: Share mode: 0x%x", __func__, resp.u.get_or_set_share.sharemode);
+ DEBUG ("%s: Share mode: 0x%x", __func__, resp.u.get_or_set_share.sharemode);
} else {
- LOGDEBUG ("%s: file share info not already known, setting", __func__);
+ DEBUG ("%s: file share info not already known, setting", __func__);
sharemode_set (get_share.device, get_share.inode,
get_share.new_sharemode, get_share.new_access);
}
fds, &has_fds);
if(ret==0) {
/* Other end went away */
- LOGDEBUG ("Read 0 bytes on fd %d, closing it",
+ DEBUG ("Read 0 bytes on fd %d, closing it",
g_io_channel_unix_get_fd (channel));
rem_fd (channel, channel_data);
return(FALSE);
}
- LOGDEBUG ("Process request %d", req.type);
+ DEBUG ("Process request %d", req.type);
switch(req.type) {
case WapiHandleRequestType_New:
process_new (channel, channel_data, req.u.new.type);
break;
case WapiHandleRequestType_Open:
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
g_assert(req.u.open.handle < _wapi_shared_data[0]->num_segments * _WAPI_HANDLES_PER_SEGMENT);
#endif
process_open (channel, channel_data, req.u.open.handle);
break;
case WapiHandleRequestType_Close:
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
g_assert(req.u.close.handle < _wapi_shared_data[0]->num_segments * _WAPI_HANDLES_PER_SEGMENT);
#endif
process_close (channel, channel_data, req.u.close.handle);
}
if(has_fds==TRUE) {
- LOGDEBUG ("%s: closing %d", __func__, fds[0]);
- LOGDEBUG ("%s: closing %d", __func__, fds[1]);
- LOGDEBUG ("%s: closing %d", __func__, fds[2]);
+ DEBUG ("%s: closing %d", __func__, fds[0]);
+ DEBUG ("%s: closing %d", __func__, fds[1]);
+ DEBUG ("%s: closing %d", __func__, fds[2]);
close (fds[0]);
close (fds[1]);
GMainContext *context=data;
if(condition & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) {
- LOGDEBUG ("fd %d error", fd);
+ DEBUG ("fd %d error", fd);
rem_fd (channel, channel_data);
return(FALSE);
}
exit (-1);
}
- LOGDEBUG ("accept returning %d", newsock);
+ DEBUG ("accept returning %d", newsock);
add_fd (newsock, context);
} else {
- LOGDEBUG ("reading data on fd %d", fd);
+ DEBUG ("reading data on fd %d", fd);
return(read_message (channel, channel_data));
}
int ret;
GMainContext *context;
- LOGDEBUG ("Starting up...");
+ DEBUG ("Starting up...");
_wapi_shared_data[0]=data;
_wapi_shared_scratch=scratch;
exit(-1);
}
- LOGDEBUG("bound");
+ DEBUG("bound");
ret=listen(main_sock, 5);
if(ret==-1) {
_wapi_shared_data[0]->daemon_running=DAEMON_DIED_AT_STARTUP;
exit(-1);
}
- LOGDEBUG("listening");
+ DEBUG("listening");
context = g_main_context_new ();
process_died ();
}
- LOGDEBUG ("polling");
+ DEBUG ("polling");
/* Block until something happens. We don't use
* g_main_loop_run() because we rely on the SIGCHLD
#include <mono/io-layer/event-private.h>
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
static void event_signal(gpointer handle);
static gboolean event_own (gpointer handle);
return (FALSE);
}
-#ifdef DEBUG
- g_message("%s: owning event handle %p", __func__, handle);
-#endif
+ DEBUG("%s: owning event handle %p", __func__, handle);
if(event_handle->manual==FALSE) {
g_assert (event_handle->set_count > 0);
struct _WapiHandle_namedevent *namedevent_handle;
gboolean ok;
-#ifdef DEBUG
- g_message ("%s: owning named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: owning named event handle %p", __func__, handle);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDEVENT,
(gpointer *)&namedevent_handle);
*/
SetLastError (ERROR_SUCCESS);
-#ifdef DEBUG
- g_message ("%s: Creating unnamed event", __func__);
-#endif
+ DEBUG ("%s: Creating unnamed event", __func__);
event_handle.manual = manual;
event_handle.set_count = 0;
_wapi_handle_set_signal_state (handle, TRUE, FALSE);
}
-#ifdef DEBUG
- g_message("%s: created new event handle %p", __func__, handle);
-#endif
+ DEBUG("%s: created new event handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-#ifdef DEBUG
- g_message ("%s: Creating named event [%s]", __func__, utf8_name);
-#endif
+ DEBUG ("%s: Creating named event [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT,
utf8_name);
_wapi_handle_unlock_shared_handles ();
}
-#ifdef DEBUG
- g_message ("%s: returning event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning event handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: Pulsing event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Pulsing event handle %p", __func__, handle);
if (event_handle->manual == TRUE) {
_wapi_handle_set_signal_state (handle, TRUE, TRUE);
* have proceeded. Currently we rely on broadcasting
* a condition.
*/
-#ifdef DEBUG
- g_message ("%s: Obtained write lock on event handle %p",
+ DEBUG ("%s: Obtained write lock on event handle %p",
__func__, handle);
-#endif
pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle, handle);
thr_ret = _wapi_handle_lock_handle (handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: Pulsing named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Pulsing named event handle %p", __func__, handle);
if (namedevent_handle->manual == TRUE) {
_wapi_shared_handle_set_signal_state (handle, TRUE);
* have proceeded. Currently we rely on waiting for
* twice the shared handle poll interval.
*/
-#ifdef DEBUG
- g_message ("%s: Obtained write lock on event handle %p",
+ DEBUG ("%s: Obtained write lock on event handle %p",
__func__, handle);
-#endif
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
return(FALSE);
}
-#ifdef DEBUG
- g_message ("%s: Resetting event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Resetting event handle %p", __func__, handle);
pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
handle);
g_assert (thr_ret == 0);
if (_wapi_handle_issignalled (handle) == FALSE) {
-#ifdef DEBUG
- g_message ("%s: No need to reset event handle %p", __func__,
+ DEBUG ("%s: No need to reset event handle %p", __func__,
handle);
-#endif
} else {
-#ifdef DEBUG
- g_message ("%s: Obtained write lock on event handle %p",
+ DEBUG ("%s: Obtained write lock on event handle %p",
__func__, handle);
-#endif
_wapi_handle_set_signal_state (handle, FALSE, FALSE);
}
return(FALSE);
}
-#ifdef DEBUG
- g_message ("%s: Resetting named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Resetting named event handle %p", __func__, handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
if (_wapi_handle_issignalled (handle) == FALSE) {
-#ifdef DEBUG
- g_message ("%s: No need to reset named event handle %p",
+ DEBUG ("%s: No need to reset named event handle %p",
__func__, handle);
-#endif
} else {
-#ifdef DEBUG
- g_message ("%s: Obtained write lock on named event handle %p",
+ DEBUG ("%s: Obtained write lock on named event handle %p",
__func__, handle);
-#endif
_wapi_shared_handle_set_signal_state (handle, FALSE);
}
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: Setting event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Setting event handle %p", __func__, handle);
if (event_handle->manual == TRUE) {
_wapi_handle_set_signal_state (handle, TRUE, TRUE);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: Setting named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Setting named event handle %p", __func__, handle);
if (namedevent_handle->manual == TRUE) {
_wapi_shared_handle_set_signal_state (handle, TRUE);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-#ifdef DEBUG
- g_message ("%s: Opening named event [%s]", __func__, utf8_name);
-#endif
+ DEBUG ("%s: Opening named event [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDEVENT,
utf8_name);
}
ret = handle;
-#ifdef DEBUG
- g_message ("%s: returning named event handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning named event handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
#include <mono/io-layer/process-private.h>
#include <mono/io-layer/critical-section-private.h>
-#undef DEBUG
#undef DEBUG_REFS
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
+
static void (*_wapi_handle_ops_get_close_func (WapiHandleType type))(gpointer, gpointer);
static WapiHandleCapability handle_caps[WAPI_HANDLE_COUNT]={0};
}
for(k = handle_data->ref; k > 0; k--) {
-#ifdef DEBUG
- g_message ("%s: unreffing %s handle %p", __func__, _wapi_handle_typename[type], handle);
-#endif
+ DEBUG ("%s: unreffing %s handle %p", __func__, _wapi_handle_typename[type], handle);
_wapi_handle_unref_full (handle, TRUE);
}
gpointer handle;
int thr_ret;
-#ifdef DEBUG
- g_message ("%s: Creating new handle of type %s", __func__,
+ DEBUG ("%s: Creating new handle of type %s", __func__,
_wapi_handle_typename[type]);
-#endif
g_assert(!_WAPI_FD_HANDLE(type));
handle = GUINT_TO_POINTER (handle_idx);
-#ifdef DEBUG
- g_message ("%s: Allocated new handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Allocated new handle %p", __func__, handle);
if (_WAPI_SHARED_HANDLE(type)) {
/* Add the shared section too */
}
_WAPI_PRIVATE_HANDLES(handle_idx).u.shared.offset = ref;
-#ifdef DEBUG
- g_message ("%s: New shared handle at offset 0x%x", __func__,
+ DEBUG ("%s: New shared handle at offset 0x%x", __func__,
ref);
-#endif
}
done:
mono_once (&shared_init_once, shared_init);
-#ifdef DEBUG
- g_message ("%s: Creating new handle of type %s to offset %d", __func__,
+ DEBUG ("%s: Creating new handle of type %s to offset %d", __func__,
_wapi_handle_typename[type], offset);
-#endif
g_assert(!_WAPI_FD_HANDLE(type));
g_assert(_WAPI_SHARED_HANDLE(type));
if (handle != INVALID_HANDLE_VALUE) {
_wapi_handle_ref (handle);
-#ifdef DEBUG
- g_message ("%s: Returning old handle %p referencing 0x%x",
+ DEBUG ("%s: Returning old handle %p referencing 0x%x",
__func__, handle, offset);
-#endif
return (handle);
}
if (shared->type == WAPI_HANDLE_UNUSED) {
/* Someone deleted this handle while we were working */
-#ifdef DEBUG
- g_message ("%s: Handle at 0x%x unused", __func__, offset);
-#endif
+ DEBUG ("%s: Handle at 0x%x unused", __func__, offset);
goto done;
}
if (shared->type != type) {
-#ifdef DEBUG
- g_message ("%s: Wrong type at %d 0x%x! Found %s wanted %s",
+ DEBUG ("%s: Wrong type at %d 0x%x! Found %s wanted %s",
__func__, offset, offset,
_wapi_handle_typename[shared->type],
_wapi_handle_typename[type]);
-#endif
goto done;
}
_WAPI_PRIVATE_HANDLES(handle_idx).u.shared.offset = offset;
InterlockedIncrement ((gint32 *)&shared->handle_refs);
-#ifdef DEBUG
- g_message ("%s: Allocated new handle %p referencing 0x%x (shared refs %d)", __func__, handle, offset, shared->handle_refs);
-#endif
+ DEBUG ("%s: Allocated new handle %p referencing 0x%x (shared refs %d)", __func__, handle, offset, shared->handle_refs);
done:
_wapi_handle_unlock_shared_handles ();
mono_once (&shared_init_once, shared_init);
-#ifdef DEBUG
- g_message ("%s: Creating new handle of type %s", __func__,
+ DEBUG ("%s: Creating new handle of type %s", __func__,
_wapi_handle_typename[type]);
-#endif
g_assert(_WAPI_FD_HANDLE(type));
g_assert(!_WAPI_SHARED_HANDLE(type));
if (fd >= _wapi_fd_reserve) {
-#ifdef DEBUG
- g_message ("%s: fd %d is too big", __func__, fd);
-#endif
+ DEBUG ("%s: fd %d is too big", __func__, fd);
return(GUINT_TO_POINTER (_WAPI_HANDLE_INVALID));
}
handle = &_WAPI_PRIVATE_HANDLES(fd);
if (handle->type != WAPI_HANDLE_UNUSED) {
-#ifdef DEBUG
- g_message ("%s: fd %d is already in use!", __func__, fd);
-#endif
+ DEBUG ("%s: fd %d is already in use!", __func__, fd);
/* FIXME: clean up this handle? We can't do anything
* with the fd, cos thats the new one
*/
}
-#ifdef DEBUG
- g_message ("%s: Assigning new fd handle %d", __func__, fd);
-#endif
+ DEBUG ("%s: Assigning new fd handle %d", __func__, fd);
/* Prevent file share entries racing with us, when the file
* handle is only half initialised
if (!found && search_shared && _WAPI_SHARED_HANDLE (type)) {
/* Not found yet, so search the shared memory too */
-#ifdef DEBUG
- g_message ("%s: Looking at other shared handles...", __func__);
-#endif
+ DEBUG ("%s: Looking at other shared handles...", __func__);
for (i = 0; i < _WAPI_HANDLE_INITIAL_COUNT; i++) {
shared = &_wapi_shared_layout->handles[i];
continue;
}
-#ifdef DEBUG
- g_message ("%s: Opened tmp handle %p (type %s) from offset %d", __func__, ret, _wapi_handle_typename[type], i);
-#endif
+ DEBUG ("%s: Opened tmp handle %p (type %s) from offset %d", __func__, ret, _wapi_handle_typename[type], i);
/* It's possible that the shared part
* of this handle has now been blown
g_assert(_WAPI_SHARED_HANDLE(type));
-#ifdef DEBUG
- g_message ("%s: Lookup for handle named [%s] type %s", __func__,
+ DEBUG ("%s: Lookup for handle named [%s] type %s", __func__,
utf8_name, _wapi_handle_typename[type]);
-#endif
/* Do a handle collection before starting to look, so that any
* stale cruft gets removed
continue;
}
-#ifdef DEBUG
- g_message ("%s: found a shared namespace handle at 0x%x (type %s)", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
-#endif
+ DEBUG ("%s: found a shared namespace handle at 0x%x (type %s)", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
sharedns=(WapiSharedNamespace *)&shared_handle_data->u;
-#ifdef DEBUG
- g_message ("%s: name is [%s]", __func__, sharedns->name);
-#endif
+ DEBUG ("%s: name is [%s]", __func__, sharedns->name);
if (strcmp (sharedns->name, utf8_name) == 0) {
if (shared_handle_data->type != type) {
/* Its the wrong type, so fail now */
-#ifdef DEBUG
- g_message ("%s: handle 0x%x matches name but is wrong type: %s", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
-#endif
+ DEBUG ("%s: handle 0x%x matches name but is wrong type: %s", __func__, i, _wapi_handle_typename[shared_handle_data->type]);
ret = -1;
goto done;
} else {
-#ifdef DEBUG
- g_message ("%s: handle 0x%x matches name and type", __func__, i);
-#endif
+ DEBUG ("%s: handle 0x%x matches name and type", __func__, i);
ret = i;
goto done;
}
pthread_cleanup_push ((void(*)(void *))mono_mutex_unlock_in_cleanup, (void *)&scan_mutex);
thr_ret = mono_mutex_lock (&scan_mutex);
-#ifdef DEBUG
- g_message ("%s: Destroying handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Destroying handle %p", __func__, handle);
memcpy (&handle_data, &_WAPI_PRIVATE_HANDLES(idx),
sizeof (struct _WapiHandleUnshared));
type = _WAPI_PRIVATE_HANDLES(idx).type;
-#ifdef DEBUG
- g_message ("%s: testing 0x%x against 0x%x (%d)", __func__,
+ DEBUG ("%s: testing 0x%x against 0x%x (%d)", __func__,
handle_caps[type], caps, handle_caps[type] & caps);
-#endif
return((handle_caps[type] & caps) != 0);
}
gpointer handle = handles[i];
guint32 idx = GPOINTER_TO_UINT(handle);
-#ifdef DEBUG
- g_message ("%s: attempting to lock %p", __func__, handle);
-#endif
+ DEBUG ("%s: attempting to lock %p", __func__, handle);
type = _WAPI_PRIVATE_HANDLES(idx).type;
if (thr_ret != 0) {
/* Bummer */
-#ifdef DEBUG
- g_message ("%s: attempt failed for %p: %s", __func__,
+ DEBUG ("%s: attempt failed for %p: %s", __func__,
handle, strerror (thr_ret));
-#endif
thr_ret = _wapi_handle_unlock_shared_handles ();
g_assert (thr_ret == 0);
iter=1;
}
-#ifdef DEBUG
- g_message ("%s: Backing off for %d ms", __func__,
+ DEBUG ("%s: Backing off for %d ms", __func__,
iter*10);
-#endif
_wapi_handle_spin (10 * iter);
goto again;
}
}
-#ifdef DEBUG
- g_message ("%s: Locked all handles", __func__);
-#endif
+ DEBUG ("%s: Locked all handles", __func__);
count=0;
*lowest=numhandles;
type = _WAPI_PRIVATE_HANDLES(idx).type;
-#ifdef DEBUG
- g_message ("%s: Checking handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: Checking handle %p", __func__, handle);
if(((_wapi_handle_test_capabilities (handle, WAPI_HANDLE_CAP_OWN)==TRUE) &&
(_wapi_handle_ops_isowned (handle) == TRUE)) ||
_WAPI_PRIVATE_HANDLES(idx).signalled == TRUE)) {
count++;
-#ifdef DEBUG
- g_message ("%s: Handle %p signalled", __func__,
+ DEBUG ("%s: Handle %p signalled", __func__,
handle);
-#endif
if(*lowest>i) {
*lowest=i;
}
}
}
-#ifdef DEBUG
- g_message ("%s: %d event handles signalled", __func__, count);
-#endif
+ DEBUG ("%s: %d event handles signalled", __func__, count);
if ((waitall == TRUE && count == numhandles) ||
(waitall == FALSE && count > 0)) {
ret=FALSE;
}
-#ifdef DEBUG
- g_message ("%s: Returning %d", __func__, ret);
-#endif
+ DEBUG ("%s: Returning %d", __func__, ret);
*retcount=count;
for(i=0; i<numhandles; i++) {
gpointer handle = handles[i];
-#ifdef DEBUG
- g_message ("%s: unlocking handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: unlocking handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
int _wapi_handle_wait_signal_handle (gpointer handle, gboolean alertable)
{
-#ifdef DEBUG
- g_message ("%s: waiting for %p", __func__, handle);
-#endif
+ DEBUG ("%s: waiting for %p", __func__, handle);
return _wapi_handle_timedwait_signal_handle (handle, NULL, alertable, FALSE);
}
int _wapi_handle_timedwait_signal_handle (gpointer handle,
struct timespec *timeout, gboolean alertable, gboolean poll)
{
-#ifdef DEBUG
- g_message ("%s: waiting for %p (type %s)", __func__, handle,
+ DEBUG ("%s: waiting for %p (type %s)", __func__, handle,
_wapi_handle_typename[_wapi_handle_type (handle)]);
-#endif
if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {
if (WAPI_SHARED_HANDLE_DATA(handle).signalled == TRUE) {
* owned by someone else) so mark this share info as
* dead
*/
-#ifdef DEBUG
- g_message ("%s: Didn't find it, destroying entry", __func__);
-#endif
+ DEBUG ("%s: Didn't find it, destroying entry", __func__);
memset (share_info, '\0', sizeof(struct _WapiFileShare));
}
struct _WapiHandle_file *file_handle = &handle->u.file;
if (file_handle->share_info == share_info) {
-#ifdef DEBUG
- g_message ("%s: handle 0x%x has this file open!",
+ DEBUG ("%s: handle 0x%x has this file open!",
__func__, i);
-#endif
goto done;
}
continue;
}
-#ifdef DEBUG
- g_message ("%s: Looking in %s", __func__, subdir);
-#endif
+ DEBUG ("%s: Looking in %s", __func__, subdir);
proc_fds = TRUE;
stat (path, &link_stat);
if (link_stat.st_dev == share_info->device &&
link_stat.st_ino == share_info->inode) {
-#ifdef DEBUG
- g_message ("%s: Found it at %s",
+ DEBUG ("%s: Found it at %s",
__func__, path);
-#endif
found = TRUE;
}
_wapi_handle_check_share_by_pid (share_info);
} else if (found == FALSE) {
/* Blank out this entry, as it is stale */
-#ifdef DEBUG
- g_message ("%s: Didn't find it, destroying entry", __func__);
-#endif
+ DEBUG ("%s: Didn't find it, destroying entry", __func__);
memset (share_info, '\0', sizeof(struct _WapiFileShare));
}
if (_WAPI_SHARED_HANDLE(handle->type)) {
struct _WapiHandleShared *shared_data;
-#ifdef DEBUG
- g_message ("%s: (%d) handle 0x%x is SHARED (%s)", __func__, _wapi_getpid (), i * _WAPI_HANDLE_INITIAL_COUNT + k, _wapi_handle_typename[handle->type]);
-#endif
+ DEBUG ("%s: (%d) handle 0x%x is SHARED (%s)", __func__, _wapi_getpid (), i * _WAPI_HANDLE_INITIAL_COUNT + k, _wapi_handle_typename[handle->type]);
shared_data = &_wapi_shared_layout->handles[handle->u.shared.offset];
-#ifdef DEBUG
- g_message ("%s: (%d) Updating timestamp of handle 0x%x", __func__, _wapi_getpid (), handle->u.shared.offset);
-#endif
+ DEBUG ("%s: (%d) Updating timestamp of handle 0x%x", __func__, _wapi_getpid (), handle->u.shared.offset);
InterlockedExchange ((gint32 *)&shared_data->timestamp, now);
} else if (handle->type == WAPI_HANDLE_FILE) {
struct _WapiHandle_file *file_handle = &handle->u.file;
-#ifdef DEBUG
- g_message ("%s: (%d) handle 0x%x is FILE", __func__, _wapi_getpid (), i * _WAPI_HANDLE_INITIAL_COUNT + k);
-#endif
+ DEBUG ("%s: (%d) handle 0x%x is FILE", __func__, _wapi_getpid (), i * _WAPI_HANDLE_INITIAL_COUNT + k);
g_assert (file_handle->share_info != NULL);
-#ifdef DEBUG
- g_message ("%s: (%d) Inc refs on fileshare 0x%x", __func__, _wapi_getpid (), (file_handle->share_info - &_wapi_fileshare_layout->share_info[0]) / sizeof(struct _WapiFileShare));
-#endif
+ DEBUG ("%s: (%d) Inc refs on fileshare 0x%x", __func__, _wapi_getpid (), (file_handle->share_info - &_wapi_fileshare_layout->share_info[0]) / sizeof(struct _WapiFileShare));
InterlockedExchange ((gint32 *)&file_handle->share_info->timestamp, now);
}
#include <mono/io-layer/io-portability.h>
#include <mono/utils/strenc.h>
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#define DEBUG_ENABLED 1
+#else
+#define DEBUG(...)
+#endif
static void file_close (gpointer handle, gpointer data);
static WapiFileType file_getfiletype(void);
{
struct _WapiHandle_file *file_handle = (struct _WapiHandle_file *)data;
-#ifdef DEBUG
- g_message("%s: closing file handle %p [%s]", __func__, handle,
+ DEBUG("%s: closing file handle %p [%s]", __func__, handle,
file_handle->filename);
-#endif
if (file_handle->attrs & FILE_FLAG_DELETE_ON_CLOSE)
_wapi_unlink (file_handle->filename);
if(!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_READ access: %u",
+ DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
__func__, handle, file_handle->fileaccess);
-#endif
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
if(ret==-1) {
gint err = errno;
-#ifdef DEBUG
- g_message("%s: read of handle %p error: %s", __func__,
+ DEBUG("%s: read of handle %p error: %s", __func__,
handle, strerror(err));
-#endif
SetLastError (_wapi_get_win32_file_error (err));
return(FALSE);
}
if(!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-#endif
+ DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
*/
current_pos = lseek (fd, (off_t)0, SEEK_CUR);
if (current_pos == -1) {
-#ifdef DEBUG
- g_message ("%s: handle %p lseek failed: %s", __func__,
+ DEBUG ("%s: handle %p lseek failed: %s", __func__,
handle, strerror (errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
}
} else {
_wapi_set_last_error_from_errno ();
-#ifdef DEBUG
- g_message("%s: write of handle %p error: %s",
+ DEBUG("%s: write of handle %p error: %s",
__func__, handle, strerror(errno));
-#endif
return(FALSE);
}
if(!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-#endif
+ DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
ret=fsync(fd);
if (ret==-1) {
-#ifdef DEBUG
- g_message("%s: fsync of handle %p error: %s", __func__, handle,
+ DEBUG("%s: fsync of handle %p error: %s", __func__, handle,
strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
if(!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-#endif
+ DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(INVALID_SET_FILE_POINTER);
whence=SEEK_END;
break;
default:
-#ifdef DEBUG
- g_message("%s: invalid seek type %d", __func__, method);
-#endif
+ DEBUG("%s: invalid seek type %d", __func__, method);
SetLastError (ERROR_INVALID_PARAMETER);
return(INVALID_SET_FILE_POINTER);
#ifdef HAVE_LARGE_FILE_SUPPORT
if(highmovedistance==NULL) {
offset=movedistance;
-#ifdef DEBUG
- g_message("%s: setting offset to %lld (low %d)", __func__,
+ DEBUG("%s: setting offset to %lld (low %d)", __func__,
offset, movedistance);
-#endif
} else {
offset=((gint64) *highmovedistance << 32) | (guint32)movedistance;
-#ifdef DEBUG
- g_message("%s: setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", __func__, offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
-#endif
+ DEBUG("%s: setting offset to %lld 0x%llx (high %d 0x%x, low %d 0x%x)", __func__, offset, offset, *highmovedistance, *highmovedistance, movedistance, movedistance);
}
#else
offset=movedistance;
#endif
-#ifdef DEBUG
#ifdef HAVE_LARGE_FILE_SUPPORT
- g_message("%s: moving handle %p by %lld bytes from %d", __func__,
+ DEBUG ("%s: moving handle %p by %lld bytes from %d", __func__,
handle, offset, whence);
#else
- g_message("%s: moving handle %p fd %d by %ld bytes from %d", __func__,
+ DEBUG ("%s: moving handle %p fd %d by %ld bytes from %d", __func__,
handle, offset, whence);
-#endif
#endif
newpos=lseek(fd, offset, whence);
if(newpos==-1) {
-#ifdef DEBUG
- g_message("%s: lseek on handle %p returned error %s",
+ DEBUG("%s: lseek on handle %p returned error %s",
__func__, handle, strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(INVALID_SET_FILE_POINTER);
}
-#ifdef DEBUG
#ifdef HAVE_LARGE_FILE_SUPPORT
- g_message("%s: lseek returns %lld", __func__, newpos);
+ DEBUG ("%s: lseek returns %lld", __func__, newpos);
#else
- g_message ("%s: lseek returns %ld", __func__, newpos);
-#endif
+ DEBUG ("%s: lseek returns %ld", __func__, newpos);
#endif
#ifdef HAVE_LARGE_FILE_SUPPORT
}
#endif
-#ifdef DEBUG
- g_message ("%s: move of handle %p returning %d/%d", __func__,
+ DEBUG ("%s: move of handle %p returning %d/%d", __func__,
handle, ret, highmovedistance==NULL?0:*highmovedistance);
-#endif
return(ret);
}
if(!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-#endif
+ DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
ret=fstat(fd, &statbuf);
if(ret==-1) {
-#ifdef DEBUG
- g_message ("%s: handle %p fstat failed: %s", __func__,
+ DEBUG ("%s: handle %p fstat failed: %s", __func__,
handle, strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
pos=lseek(fd, (off_t)0, SEEK_CUR);
if(pos==-1) {
-#ifdef DEBUG
- g_message("%s: handle %p lseek failed: %s", __func__,
+ DEBUG("%s: handle %p lseek failed: %s", __func__,
handle, strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
!_wapi_thread_cur_apc_pending());
if(ret==-1) {
-#ifdef DEBUG
- g_message("%s: handle %p extend write failed: %s", __func__, handle, strerror(errno));
-#endif
+ DEBUG("%s: handle %p extend write failed: %s", __func__, handle, strerror(errno));
_wapi_set_last_error_from_errno ();
return(FALSE);
/* And put the file position back after the write */
ret = lseek (fd, pos, SEEK_SET);
if (ret == -1) {
-#ifdef DEBUG
- g_message ("%s: handle %p second lseek failed: %s",
+ DEBUG ("%s: handle %p second lseek failed: %s",
__func__, handle, strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
}
while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
if(ret==-1) {
-#ifdef DEBUG
- g_message("%s: handle %p ftruncate failed: %s", __func__,
+ DEBUG("%s: handle %p ftruncate failed: %s", __func__,
handle, strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
if(!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-#endif
+ DEBUG("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(INVALID_FILE_SIZE);
ret = fstat(fd, &statbuf);
if (ret == -1) {
-#ifdef DEBUG
- g_message ("%s: handle %p fstat failed: %s", __func__,
+ DEBUG ("%s: handle %p fstat failed: %s", __func__,
handle, strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(INVALID_FILE_SIZE);
if (S_ISBLK(statbuf.st_mode)) {
guint64 bigsize;
if (ioctl(fd, BLKGETSIZE64, &bigsize) < 0) {
-#ifdef DEBUG
- g_message ("%s: handle %p ioctl BLKGETSIZE64 failed: %s",
+ DEBUG ("%s: handle %p ioctl BLKGETSIZE64 failed: %s",
__func__, handle, strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(INVALID_FILE_SIZE);
*highsize = bigsize>>32;
}
-#ifdef DEBUG
- g_message ("%s: Returning block device size %d/%d",
+ DEBUG ("%s: Returning block device size %d/%d",
__func__, size, *highsize);
-#endif
return(size);
}
size = statbuf.st_size;
#endif
-#ifdef DEBUG
- g_message ("%s: Returning size %d/%d", __func__, size, *highsize);
-#endif
+ DEBUG ("%s: Returning size %d/%d", __func__, size, *highsize);
return(size);
}
if(!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_READ access: %u",
+ DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
__func__, handle, file_handle->fileaccess);
-#endif
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
ret=fstat(fd, &statbuf);
if(ret==-1) {
-#ifdef DEBUG
- g_message("%s: handle %p fstat failed: %s", __func__, handle,
+ DEBUG("%s: handle %p fstat failed: %s", __func__, handle,
strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
}
-#ifdef DEBUG
- g_message("%s: atime: %ld ctime: %ld mtime: %ld", __func__,
+ DEBUG("%s: atime: %ld ctime: %ld mtime: %ld", __func__,
statbuf.st_atime, statbuf.st_ctime,
statbuf.st_mtime);
-#endif
/* Try and guess a meaningful create time by using the older
* of atime or ctime
access_ticks=((guint64)statbuf.st_atime*10000000)+116444736000000000ULL;
write_ticks=((guint64)statbuf.st_mtime*10000000)+116444736000000000ULL;
-#ifdef DEBUG
- g_message("%s: aticks: %llu cticks: %llu wticks: %llu", __func__,
+ DEBUG("%s: aticks: %llu cticks: %llu wticks: %llu", __func__,
access_ticks, create_ticks, write_ticks);
-#endif
if(create_time!=NULL) {
create_time->dwLowDateTime = create_ticks & 0xFFFFFFFF;
if(!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
-#endif
+ DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
if(file_handle->filename == NULL) {
-#ifdef DEBUG
- g_message("%s: handle %p unknown filename", __func__, handle);
-#endif
+ DEBUG("%s: handle %p unknown filename", __func__, handle);
SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
*/
ret=fstat (fd, &statbuf);
if(ret==-1) {
-#ifdef DEBUG
- g_message("%s: handle %p fstat failed: %s", __func__, handle,
+ DEBUG("%s: handle %p fstat failed: %s", __func__, handle,
strerror(errno));
-#endif
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
* but this will do for now.
*/
if (access_ticks < 116444736000000000ULL) {
-#ifdef DEBUG
- g_message ("%s: attempt to set access time too early",
+ DEBUG ("%s: attempt to set access time too early",
__func__);
-#endif
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
}
* but this will do for now.
*/
if (write_ticks < 116444736000000000ULL) {
-#ifdef DEBUG
- g_message ("%s: attempt to set write time too early",
+ DEBUG ("%s: attempt to set write time too early",
__func__);
-#endif
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
}
utbuf.modtime=statbuf.st_mtime;
}
-#ifdef DEBUG
- g_message ("%s: setting handle %p access %ld write %ld", __func__,
+ DEBUG ("%s: setting handle %p access %ld write %ld", __func__,
handle, utbuf.actime, utbuf.modtime);
-#endif
ret = _wapi_utime (file_handle->filename, &utbuf);
if (ret == -1) {
-#ifdef DEBUG
- g_message ("%s: handle %p [%s] utime failed: %s", __func__,
+ DEBUG ("%s: handle %p [%s] utime failed: %s", __func__,
handle, file_handle->filename, strerror(errno));
-#endif
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
}
{
struct _WapiHandle_file *console_handle = (struct _WapiHandle_file *)data;
-#ifdef DEBUG
- g_message("%s: closing console handle %p", __func__, handle);
-#endif
+ DEBUG("%s: closing console handle %p", __func__, handle);
g_free (console_handle->filename);
if(!(console_handle->fileaccess & GENERIC_READ) &&
!(console_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message ("%s: handle %p doesn't have GENERIC_READ access: %u",
+ DEBUG ("%s: handle %p doesn't have GENERIC_READ access: %u",
__func__, handle, console_handle->fileaccess);
-#endif
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
} while (ret==-1 && errno==EINTR && !_wapi_thread_cur_apc_pending());
if(ret==-1) {
-#ifdef DEBUG
- g_message("%s: read of handle %p error: %s", __func__, handle,
+ DEBUG("%s: read of handle %p error: %s", __func__, handle,
strerror(errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
if(!(console_handle->fileaccess & GENERIC_WRITE) &&
!(console_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, console_handle->fileaccess);
-#endif
+ DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, console_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
} else {
_wapi_set_last_error_from_errno ();
-#ifdef DEBUG
- g_message ("%s: write of handle %p error: %s",
+ DEBUG ("%s: write of handle %p error: %s",
__func__, handle, strerror(errno));
-#endif
return(FALSE);
}
static void pipe_close (gpointer handle, gpointer data G_GNUC_UNUSED)
{
-#ifdef DEBUG
- g_message("%s: closing pipe handle %p", __func__, handle);
-#endif
+ DEBUG("%s: closing pipe handle %p", __func__, handle);
/* No filename with pipe handles */
if(!(pipe_handle->fileaccess & GENERIC_READ) &&
!(pipe_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_READ access: %u",
+ DEBUG("%s: handle %p doesn't have GENERIC_READ access: %u",
__func__, handle, pipe_handle->fileaccess);
-#endif
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
-#ifdef DEBUG
- g_message ("%s: reading up to %d bytes from pipe %p", __func__,
+ DEBUG ("%s: reading up to %d bytes from pipe %p", __func__,
numbytes, handle);
-#endif
do {
ret=read(fd, buffer, numbytes);
} else {
_wapi_set_last_error_from_errno ();
-#ifdef DEBUG
- g_message("%s: read of handle %p error: %s", __func__,
+ DEBUG("%s: read of handle %p error: %s", __func__,
handle, strerror(errno));
-#endif
return(FALSE);
}
}
-#ifdef DEBUG
- g_message ("%s: read %d bytes from pipe", __func__, ret);
-#endif
+ DEBUG ("%s: read %d bytes from pipe", __func__, ret);
if(bytesread!=NULL) {
*bytesread=ret;
if(!(pipe_handle->fileaccess & GENERIC_WRITE) &&
!(pipe_handle->fileaccess & GENERIC_ALL)) {
-#ifdef DEBUG
- g_message("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, pipe_handle->fileaccess);
-#endif
+ DEBUG("%s: handle %p doesn't have GENERIC_WRITE access: %u", __func__, handle, pipe_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
-#ifdef DEBUG
- g_message ("%s: writing up to %d bytes to pipe %p", __func__, numbytes,
+ DEBUG ("%s: writing up to %d bytes to pipe %p", __func__, numbytes,
handle);
-#endif
do {
ret = write (fd, buffer, numbytes);
} else {
_wapi_set_last_error_from_errno ();
-#ifdef DEBUG
- g_message("%s: write of handle %p error: %s", __func__,
+ DEBUG("%s: write of handle %p error: %s", __func__,
handle, strerror(errno));
-#endif
return(FALSE);
}
flags=O_RDWR;
break;
default:
-#ifdef DEBUG
- g_message("%s: Unknown access type 0x%x", __func__,
+ DEBUG("%s: Unknown access type 0x%x", __func__,
fileaccess);
-#endif
break;
}
flags|=O_TRUNC;
break;
default:
-#ifdef DEBUG
- g_message("%s: Unknown create mode 0x%x", __func__,
+ DEBUG("%s: Unknown create mode 0x%x", __func__,
createmode);
-#endif
break;
}
*/
if (file_existing_share == 0) {
/* Quick and easy, no possibility to share */
-#ifdef DEBUG
- g_message ("%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
-#endif
+ DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing = NONE", __func__, fileaccess);
_wapi_handle_share_release (*share_info);
((file_existing_share == FILE_SHARE_WRITE) &&
(fileaccess != GENERIC_WRITE))) {
/* New access mode doesn't match up */
-#ifdef DEBUG
- g_message ("%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
-#endif
+ DEBUG ("%s: Share mode prevents open: requested access: 0x%x, file has sharing: 0x%x", __func__, fileaccess, file_existing_share);
_wapi_handle_share_release (*share_info);
((file_existing_access & GENERIC_WRITE) &&
!(sharemode & FILE_SHARE_WRITE))) {
/* New share mode doesn't match up */
-#ifdef DEBUG
- g_message ("%s: Access mode prevents open: requested share: 0x%x, file has access: 0x%x", __func__, sharemode, file_existing_access);
-#endif
+ DEBUG ("%s: Access mode prevents open: requested share: 0x%x, file has access: 0x%x", __func__, sharemode, file_existing_access);
_wapi_handle_share_release (*share_info);
return(FALSE);
}
} else {
-#ifdef DEBUG
- g_message ("%s: New file!", __func__);
-#endif
+ DEBUG ("%s: New file!", __func__);
}
return(TRUE);
}
if (name == NULL) {
-#ifdef DEBUG
- g_message ("%s: name is NULL", __func__);
-#endif
+ DEBUG ("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(INVALID_HANDLE_VALUE);
filename = mono_unicode_to_external (name);
if (filename == NULL) {
-#ifdef DEBUG
- g_message("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(INVALID_HANDLE_VALUE);
}
-#ifdef DEBUG
- g_message ("%s: Opening %s with share 0x%x and access 0x%x", __func__,
+ DEBUG ("%s: Opening %s with share 0x%x and access 0x%x", __func__,
filename, sharemode, fileaccess);
-#endif
fd = _wapi_open (filename, flags, perms);
}
if (fd == -1) {
-#ifdef DEBUG
- g_message("%s: Error opening file %s: %s", __func__, filename,
+ DEBUG("%s: Error opening file %s: %s", __func__, filename,
strerror(errno));
-#endif
_wapi_set_last_path_error_from_errno (NULL, filename);
g_free (filename);
}
if (fd >= _wapi_fd_reserve) {
-#ifdef DEBUG
- g_message ("%s: File descriptor is too big", __func__);
-#endif
+ DEBUG ("%s: File descriptor is too big", __func__);
SetLastError (ERROR_TOO_MANY_OPEN_FILES);
ret = fstat (fd, &statbuf);
if (ret == -1) {
-#ifdef DEBUG
- g_message ("%s: fstat error of file %s: %s", __func__,
+ DEBUG ("%s: fstat error of file %s: %s", __func__,
filename, strerror (errno));
-#endif
_wapi_set_last_error_from_errno ();
g_free (filename);
close (fd);
}
if (file_handle.share_info == NULL) {
/* No space, so no more files can be opened */
-#ifdef DEBUG
- g_message ("%s: No space in the share table", __func__);
-#endif
+ DEBUG ("%s: No space in the share table", __func__);
SetLastError (ERROR_TOO_MANY_OPEN_FILES);
close (fd);
return(INVALID_HANDLE_VALUE);
}
-#ifdef DEBUG
- g_message("%s: returning handle %p", __func__, handle);
-#endif
+ DEBUG("%s: returning handle %p", __func__, handle);
return(handle);
}
#endif
if(name==NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
filename=mono_unicode_to_external(name);
if(filename==NULL) {
-#ifdef DEBUG
- g_message("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
attrs = GetFileAttributes (name);
if (attrs == INVALID_FILE_ATTRIBUTES) {
-#ifdef DEBUG
- g_message ("%s: file attributes error", __func__);
-#endif
+ DEBUG ("%s: file attributes error", __func__);
/* Error set by GetFileAttributes() */
g_free (filename);
return(FALSE);
struct _WapiFileShare *shareinfo;
if(name==NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return FALSE;
}
if(dest_name==NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
g_free (utf8_name);
SetLastError (ERROR_INVALID_NAME);
utf8_dest_name = mono_unicode_to_external (dest_name);
if (utf8_dest_name == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
g_free (utf8_name);
SetLastError (ERROR_INVALID_NAME);
if (report_errors)
_wapi_set_last_error_from_errno ();
-#ifdef DEBUG
- g_message ("%s: write failed.", __func__);
-#endif
+ DEBUG ("%s: write failed.", __func__);
free (buf);
return FALSE;
}
gboolean ret = TRUE;
if(name==NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_src = mono_unicode_to_external (name);
if (utf8_src == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion of source returned NULL",
+ DEBUG ("%s: unicode conversion of source returned NULL",
__func__);
-#endif
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
}
if(dest_name==NULL) {
-#ifdef DEBUG
- g_message("%s: dest is NULL", __func__);
-#endif
+ DEBUG("%s: dest is NULL", __func__);
g_free (utf8_src);
SetLastError (ERROR_INVALID_NAME);
utf8_dest = mono_unicode_to_external (dest_name);
if (utf8_dest == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion of dest returned NULL",
+ DEBUG ("%s: unicode conversion of dest returned NULL",
__func__);
-#endif
SetLastError (ERROR_INVALID_PARAMETER);
gchar *utf8_ret;
if (arg == NULL) {
-#ifdef DEBUG
- g_message ("%s: %s is NULL", __func__, arg_name);
-#endif
+ DEBUG ("%s: %s is NULL", __func__, arg_name);
SetLastError (ERROR_INVALID_NAME);
return NULL;
}
utf8_ret = mono_unicode_to_external (arg);
if (utf8_ret == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion of %s returned NULL",
+ DEBUG ("%s: unicode conversion of %s returned NULL",
__func__, arg_name);
-#endif
SetLastError (ERROR_INVALID_PARAMETER);
return NULL;
}
break;
default:
-#ifdef DEBUG
- g_message("%s: unknown standard handle type", __func__);
-#endif
+ DEBUG("%s: unknown standard handle type", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(INVALID_HANDLE_VALUE);
const guint16 *ip;
if(system_time==NULL) {
-#ifdef DEBUG
- g_message("%s: system_time NULL", __func__);
-#endif
+ DEBUG("%s: system_time NULL", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
* year and day calculation to work later
*/
if(file_ticks<0) {
-#ifdef DEBUG
- g_message("%s: file_time too big", __func__);
-#endif
+ DEBUG("%s: file_time too big", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(FALSE);
totaldays=(file_ticks / TICKS_PER_DAY);
rem = file_ticks % TICKS_PER_DAY;
-#ifdef DEBUG
- g_message("%s: totaldays: %lld rem: %lld", __func__, totaldays, rem);
-#endif
+ DEBUG("%s: totaldays: %lld rem: %lld", __func__, totaldays, rem);
system_time->wHour=rem/TICKS_PER_HOUR;
rem %= TICKS_PER_HOUR;
-#ifdef DEBUG
- g_message("%s: Hour: %d rem: %lld", __func__, system_time->wHour, rem);
-#endif
+ DEBUG("%s: Hour: %d rem: %lld", __func__, system_time->wHour, rem);
system_time->wMinute = rem / TICKS_PER_MINUTE;
rem %= TICKS_PER_MINUTE;
-#ifdef DEBUG
- g_message("%s: Minute: %d rem: %lld", __func__, system_time->wMinute,
+ DEBUG("%s: Minute: %d rem: %lld", __func__, system_time->wMinute,
rem);
-#endif
system_time->wSecond = rem / TICKS_PER_SECOND;
rem %= TICKS_PER_SECOND;
-#ifdef DEBUG
- g_message("%s: Second: %d rem: %lld", __func__, system_time->wSecond,
+ DEBUG("%s: Second: %d rem: %lld", __func__, system_time->wSecond,
rem);
-#endif
system_time->wMilliseconds = rem / TICKS_PER_MILLISECOND;
-#ifdef DEBUG
- g_message("%s: Milliseconds: %d", __func__,
+ DEBUG("%s: Milliseconds: %d", __func__,
system_time->wMilliseconds);
-#endif
/* January 1, 1601 was a Monday, according to Emacs calendar */
system_time->wDayOfWeek = ((1 + totaldays) % 7) + 1;
-#ifdef DEBUG
- g_message("%s: Day of week: %d", __func__, system_time->wDayOfWeek);
-#endif
+ DEBUG("%s: Day of week: %d", __func__, system_time->wDayOfWeek);
/* This algorithm to find year and month given days from epoch
* from glibc
while(totaldays < 0 || totaldays >= (isleap(y)?366:365)) {
/* Guess a corrected year, assuming 365 days per year */
gint64 yg = y + totaldays / 365 - (totaldays % 365 < 0);
-#ifdef DEBUG
- g_message("%s: totaldays: %lld yg: %lld y: %lld", __func__,
+ DEBUG("%s: totaldays: %lld yg: %lld y: %lld", __func__,
totaldays, yg,
y);
g_message("%s: LEAPS(yg): %lld LEAPS(y): %lld", __func__,
LEAPS_THRU_END_OF(yg-1), LEAPS_THRU_END_OF(y-1));
-#endif
/* Adjust days and y to match the guessed year. */
totaldays -= ((yg - y) * 365
+ LEAPS_THRU_END_OF (yg - 1)
- LEAPS_THRU_END_OF (y - 1));
-#ifdef DEBUG
- g_message("%s: totaldays: %lld", __func__, totaldays);
-#endif
+ DEBUG("%s: totaldays: %lld", __func__, totaldays);
y = yg;
-#ifdef DEBUG
- g_message("%s: y: %lld", __func__, y);
-#endif
+ DEBUG("%s: y: %lld", __func__, y);
}
system_time->wYear = y;
-#ifdef DEBUG
- g_message("%s: Year: %d", __func__, system_time->wYear);
-#endif
+ DEBUG("%s: Year: %d", __func__, system_time->wYear);
ip = mon_yday[isleap(y)];
continue;
}
totaldays-=ip[y];
-#ifdef DEBUG
- g_message("%s: totaldays: %lld", __func__, totaldays);
-#endif
+ DEBUG("%s: totaldays: %lld", __func__, totaldays);
system_time->wMonth = y + 1;
-#ifdef DEBUG
- g_message("%s: Month: %d", __func__, system_time->wMonth);
-#endif
+ DEBUG("%s: Month: %d", __func__, system_time->wMonth);
system_time->wDay = totaldays + 1;
-#ifdef DEBUG
- g_message("%s: Day: %d", __func__, system_time->wDay);
-#endif
+ DEBUG("%s: Day: %d", __func__, system_time->wDay);
return(TRUE);
}
int result;
if (pattern == NULL) {
-#ifdef DEBUG
- g_message ("%s: pattern is NULL", __func__);
-#endif
+ DEBUG ("%s: pattern is NULL", __func__);
SetLastError (ERROR_PATH_NOT_FOUND);
return(INVALID_HANDLE_VALUE);
utf8_pattern = mono_unicode_to_external (pattern);
if (utf8_pattern == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(INVALID_HANDLE_VALUE);
}
-#ifdef DEBUG
- g_message ("%s: looking for [%s]", __func__, utf8_pattern);
-#endif
+ DEBUG ("%s: looking for [%s]", __func__, utf8_pattern);
/* Figure out which bit of the pattern is the directory */
dir_part = _wapi_dirname (utf8_pattern);
}
if (result < 0) {
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
gint errnum = errno;
#endif
_wapi_set_last_path_error_from_errno (dir_part, NULL);
-#ifdef DEBUG
- g_message ("%s: scandir error: %s", __func__,
+ DEBUG ("%s: scandir error: %s", __func__,
g_strerror (errnum));
-#endif
g_free (utf8_pattern);
g_free (entry_part);
g_free (dir_part);
g_free (utf8_pattern);
g_free (entry_part);
-#ifdef DEBUG
- g_message ("%s: Got %d matches", __func__, result);
-#endif
+ DEBUG ("%s: Got %d matches", __func__, result);
find_handle.dir_part = dir_part;
find_handle.num = result;
}
if (result != 0) {
-#ifdef DEBUG
- g_message ("%s: stat failed: %s", __func__, filename);
-#endif
+ DEBUG ("%s: stat failed: %s", __func__, filename);
g_free (filename);
goto retry;
result = _wapi_lstat (filename, &linkbuf);
if (result != 0) {
-#ifdef DEBUG
- g_message ("%s: lstat failed: %s", __func__, filename);
-#endif
+ DEBUG ("%s: lstat failed: %s", __func__, filename);
g_free (filename);
goto retry;
}
g_free (filename);
-#ifdef DEBUG
- g_message ("%s: Found [%s]", __func__, utf8_filename);
-#endif
+ DEBUG ("%s: Found [%s]", __func__, utf8_filename);
/* fill data block */
int result;
if (name == NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return FALSE;
int result;
if (name == NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return FALSE;
guint32 ret;
if (name == NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return (INVALID_FILE_ATTRIBUTES);
int result;
if (level != GetFileExInfoStandard) {
-#ifdef DEBUG
- g_message ("%s: info level %d not supported.", __func__,
+ DEBUG ("%s: info level %d not supported.", __func__,
level);
-#endif
SetLastError (ERROR_INVALID_PARAMETER);
return FALSE;
}
if (name == NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return FALSE;
*/
if (name == NULL) {
-#ifdef DEBUG
- g_message("%s: name is NULL", __func__);
-#endif
+ DEBUG("%s: name is NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
utf8_name = mono_unicode_to_external (name);
if (utf8_name == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return FALSE;
mono_once (&io_ops_once, io_ops_init);
-#ifdef DEBUG
- g_message ("%s: Creating pipe", __func__);
-#endif
+ DEBUG ("%s: Creating pipe", __func__);
ret=pipe (filedes);
if(ret==-1) {
-#ifdef DEBUG
- g_message ("%s: Error creating pipe: %s", __func__,
+ DEBUG ("%s: Error creating pipe: %s", __func__,
strerror (errno));
-#endif
_wapi_set_last_error_from_errno ();
return(FALSE);
if (filedes[0] >= _wapi_fd_reserve ||
filedes[1] >= _wapi_fd_reserve) {
-#ifdef DEBUG
- g_message ("%s: File descriptor is too big", __func__);
-#endif
+ DEBUG ("%s: File descriptor is too big", __func__);
SetLastError (ERROR_TOO_MANY_OPEN_FILES);
*readpipe = read_handle;
*writepipe = write_handle;
-#ifdef DEBUG
- g_message ("%s: Returning pipe: read handle %p, write handle %p",
+ DEBUG ("%s: Returning pipe: read handle %p, write handle %p",
__func__, read_handle, write_handle);
-#endif
return(TRUE);
}
dirlen=(bytes/2);
if(dirlen+1>len) {
-#ifdef DEBUG
- g_message ("%s: Size %d smaller than needed (%ld)",
+ DEBUG ("%s: Size %d smaller than needed (%ld)",
__func__, len, dirlen+1);
-#endif
ret=dirlen+1;
} else {
else {
utf8_path_name = mono_unicode_to_external (path_name);
if (utf8_path_name == NULL) {
-#ifdef DEBUG
- g_message("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(FALSE);
if (ret == -1) {
_wapi_set_last_error_from_errno ();
-#ifdef DEBUG
- g_message ("%s: statvfs failed: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: statvfs failed: %s", __func__, strerror (errno));
return(FALSE);
}
else {
utf8_root_path_name = mono_unicode_to_external (root_path_name);
if (utf8_root_path_name == NULL) {
-#ifdef DEBUG
- g_message("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG("%s: unicode conversion returned NULL", __func__);
return(DRIVE_NO_ROOT_DIR);
}
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/io-private.h>
-#define LOGDEBUG(...)
-//#define LOGDEBUG(...) g_message (__VA_ARGS__)
+#if 0
+// #define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
gboolean
_wapi_lock_file_region (int fd, off_t offset, off_t length)
ret = fcntl (fd, F_SETLK, &lock_data);
} while(ret == -1 && errno == EINTR);
- LOGDEBUG ("%s: fcntl returns %d", __func__, ret);
+ DEBUG ("%s: fcntl returns %d", __func__, ret);
if (ret == -1) {
/*
ret = fcntl (fd, F_SETLK, &lock_data);
} while(ret == -1 && errno == EINTR);
- LOGDEBUG ("%s: fcntl returns %d", __func__, ret);
+ DEBUG ("%s: fcntl returns %d", __func__, ret);
if (ret == -1) {
/*
if (!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- LOGDEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
offset = ((gint64)offset_high << 32) | offset_low;
length = ((gint64)length_high << 32) | length_low;
- LOGDEBUG ("%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+ DEBUG ("%s: Locking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
#else
offset = offset_low;
length = length_low;
-#ifdef DEBUG
- g_message ("%s: Locking handle %p, offset %ld, length %ld", __func__,
+ DEBUG ("%s: Locking handle %p, offset %ld, length %ld", __func__,
handle, offset, length);
-#endif
#endif
return(_wapi_lock_file_region (fd, offset, length));
if (!(file_handle->fileaccess & GENERIC_READ) &&
!(file_handle->fileaccess & GENERIC_WRITE) &&
!(file_handle->fileaccess & GENERIC_ALL)) {
- LOGDEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
+ DEBUG ("%s: handle %p doesn't have GENERIC_READ or GENERIC_WRITE access: %u", __func__, handle, file_handle->fileaccess);
SetLastError (ERROR_ACCESS_DENIED);
return(FALSE);
}
offset = ((gint64)offset_high << 32) | offset_low;
length = ((gint64)length_high << 32) | length_low;
- LOGDEBUG ("%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
+ DEBUG ("%s: Unlocking handle %p, offset %lld, length %lld", __func__, handle, offset, length);
#else
offset = offset_low;
length = length_low;
- LOGDEBUG ("%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
+ DEBUG ("%s: Unlocking handle %p, offset %ld, length %ld", __func__, handle, offset, length);
#endif
return(_wapi_unlock_file_region (fd, offset, length));
#include <mono/io-layer/mono-mutex.h>
#include <mono/io-layer/mutex-private.h>
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
static void mutex_signal(gpointer handle);
static gboolean mutex_own (gpointer handle);
_wapi_thread_own_mutex (handle);
-#ifdef DEBUG
- g_message("%s: owning mutex handle %p", __func__, handle);
-#endif
+ DEBUG("%s: owning mutex handle %p", __func__, handle);
_wapi_handle_set_signal_state (handle, FALSE, FALSE);
mutex_handle->tid = pthread_self ();
mutex_handle->recursion++;
-#ifdef DEBUG
- g_message ("%s: mutex handle %p locked %d times by %d:%ld", __func__,
+ DEBUG ("%s: mutex handle %p locked %d times by %d:%ld", __func__,
handle, mutex_handle->recursion, mutex_handle->pid,
mutex_handle->tid);
-#endif
return(TRUE);
}
return(FALSE);
}
-#ifdef DEBUG
- g_message("%s: testing ownership mutex handle %p", __func__, handle);
-#endif
+ DEBUG("%s: testing ownership mutex handle %p", __func__, handle);
if (mutex_handle->recursion > 0 &&
mutex_handle->pid == _wapi_getpid () &&
pthread_equal (mutex_handle->tid, pthread_self ())) {
-#ifdef DEBUG
- g_message ("%s: mutex handle %p owned by %d:%ld", __func__,
+ DEBUG ("%s: mutex handle %p owned by %d:%ld", __func__,
handle, _wapi_getpid (), pthread_self ());
-#endif
return(TRUE);
} else {
-#ifdef DEBUG
- g_message ("%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), mutex_handle->recursion, mutex_handle->pid, mutex_handle->tid);
-#endif
+ DEBUG ("%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), mutex_handle->recursion, mutex_handle->pid, mutex_handle->tid);
return(FALSE);
}
struct _WapiHandle_namedmutex *namedmutex_handle;
gboolean ok;
-#ifdef DEBUG
- g_message ("%s: owning named mutex handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: owning named mutex handle %p", __func__, handle);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDMUTEX,
(gpointer *)&namedmutex_handle);
_wapi_shared_handle_set_signal_state (handle, FALSE);
-#ifdef DEBUG
- g_message ("%s: mutex handle %p locked %d times by %d:%ld", __func__,
+ DEBUG ("%s: mutex handle %p locked %d times by %d:%ld", __func__,
handle, namedmutex_handle->recursion,
namedmutex_handle->pid, namedmutex_handle->tid);
-#endif
return(TRUE);
}
return(FALSE);
}
-#ifdef DEBUG
- g_message ("%s: testing ownership mutex handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: testing ownership mutex handle %p", __func__, handle);
if (namedmutex_handle->recursion > 0 &&
namedmutex_handle->pid == _wapi_getpid () &&
pthread_equal (namedmutex_handle->tid, pthread_self ())) {
-#ifdef DEBUG
- g_message ("%s: mutex handle %p owned by %d:%ld", __func__,
+ DEBUG ("%s: mutex handle %p owned by %d:%ld", __func__,
handle, _wapi_getpid (), pthread_self ());
-#endif
return(TRUE);
} else {
-#ifdef DEBUG
- g_message ("%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), namedmutex_handle->recursion, namedmutex_handle->pid, namedmutex_handle->tid);
-#endif
+ DEBUG ("%s: mutex handle %p not owned by %d:%ld, but locked %d times by %d:%ld", __func__, handle, _wapi_getpid (), pthread_self (), namedmutex_handle->recursion, namedmutex_handle->pid, namedmutex_handle->tid);
return(FALSE);
}
return;
}
-#ifdef DEBUG
- g_message ("%s: Checking ownership of named mutex handle %p", __func__,
+ DEBUG ("%s: Checking ownership of named mutex handle %p", __func__,
handle);
-#endif
if (namedmutex_handle->recursion == 0) {
-#ifdef DEBUG
- g_message ("%s: Named mutex handle %p not owned", __func__,
+ DEBUG ("%s: Named mutex handle %p not owned", __func__,
handle);
-#endif
} else if (namedmutex_handle->pid == _wapi_getpid ()) {
-#ifdef DEBUG
- g_message ("%s: Named mutex handle %p owned by this process",
+ DEBUG ("%s: Named mutex handle %p owned by this process",
__func__, handle);
-#endif
} else {
int thr_ret;
gpointer proc_handle;
-#ifdef DEBUG
- g_message ("%s: Named mutex handle %p owned by another process", __func__, handle);
-#endif
+ DEBUG ("%s: Named mutex handle %p owned by another process", __func__, handle);
proc_handle = OpenProcess (0, 0, namedmutex_handle->pid);
if (proc_handle == NULL) {
/* Didn't find the process that this handle
* was owned by, overriding it
*/
-#ifdef DEBUG
- g_message ("%s: overriding old owner of named mutex handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: overriding old owner of named mutex handle %p", __func__, handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
_wapi_shared_handle_set_signal_state (handle, TRUE);
_wapi_handle_unlock_shared_handles ();
} else {
-#ifdef DEBUG
- g_message ("%s: Found active pid %d for named mutex handle %p", __func__, namedmutex_handle->pid, handle);
-#endif
+ DEBUG ("%s: Found active pid %d for named mutex handle %p", __func__, namedmutex_handle->pid, handle);
}
if (proc_handle != NULL)
CloseProcess (proc_handle);
if (mutex_handle->pid == pid &&
pthread_equal (mutex_handle->tid, tid)) {
-#ifdef DEBUG
- g_message ("%s: Mutex handle %p abandoned!", __func__, handle);
-#endif
+ DEBUG ("%s: Mutex handle %p abandoned!", __func__, handle);
mutex_handle->recursion = 0;
mutex_handle->pid = 0;
if (mutex_handle->pid == pid &&
pthread_equal (mutex_handle->tid, tid)) {
-#ifdef DEBUG
- g_message ("%s: Mutex handle %p abandoned!", __func__, handle);
-#endif
+ DEBUG ("%s: Mutex handle %p abandoned!", __func__, handle);
mutex_handle->recursion = 0;
mutex_handle->pid = 0;
*/
SetLastError (ERROR_SUCCESS);
-#ifdef DEBUG
- g_message ("%s: Creating unnamed mutex", __func__);
-#endif
+ DEBUG ("%s: Creating unnamed mutex", __func__);
handle = _wapi_handle_new (WAPI_HANDLE_MUTEX, &mutex_handle);
if (handle == _WAPI_HANDLE_INVALID) {
_wapi_handle_set_signal_state (handle, TRUE, FALSE);
}
-#ifdef DEBUG
- g_message ("%s: returning mutex handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning mutex handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-#ifdef DEBUG
- g_message ("%s: Creating named mutex [%s]", __func__, utf8_name);
-#endif
+ DEBUG ("%s: Creating named mutex [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDMUTEX,
utf8_name);
_wapi_handle_unlock_shared_handles ();
}
-#ifdef DEBUG
- g_message ("%s: returning mutex handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning mutex handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message("%s: Releasing mutex handle %p", __func__, handle);
-#endif
+ DEBUG("%s: Releasing mutex handle %p", __func__, handle);
if (!pthread_equal (mutex_handle->tid, tid) ||
mutex_handle->pid != pid) {
-#ifdef DEBUG
- g_message("%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
-#endif
+ DEBUG("%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
goto cleanup;
}
if(mutex_handle->recursion==0) {
_wapi_thread_disown_mutex (handle);
-#ifdef DEBUG
- g_message("%s: Unlocking mutex handle %p", __func__, handle);
-#endif
+ DEBUG("%s: Unlocking mutex handle %p", __func__, handle);
mutex_handle->pid=0;
mutex_handle->tid=0;
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message("%s: Releasing mutex handle %p", __func__, handle);
-#endif
+ DEBUG("%s: Releasing mutex handle %p", __func__, handle);
if (!pthread_equal (mutex_handle->tid, tid) ||
mutex_handle->pid != pid) {
-#ifdef DEBUG
- g_message("%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
-#endif
+ DEBUG("%s: We don't own mutex handle %p (owned by %d:%ld, me %d:%ld)", __func__, handle, mutex_handle->pid, mutex_handle->tid, _wapi_getpid (), tid);
goto cleanup;
}
if(mutex_handle->recursion==0) {
_wapi_thread_disown_mutex (handle);
-#ifdef DEBUG
- g_message("%s: Unlocking mutex handle %p", __func__, handle);
-#endif
+ DEBUG("%s: Unlocking mutex handle %p", __func__, handle);
mutex_handle->pid=0;
mutex_handle->tid=0;
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-#ifdef DEBUG
- g_message ("%s: Opening named mutex [%s]", __func__, utf8_name);
-#endif
+ DEBUG ("%s: Opening named mutex [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDMUTEX,
utf8_name);
}
ret = handle;
-#ifdef DEBUG
- g_message ("%s: returning named mutex handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning named mutex handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/io-private.h>
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
+
static guint32
convert_from_flags(int flags)
{
} else if ((flags & O_ACCMODE) == O_RDWR) {
fileaccess=GENERIC_READ|GENERIC_WRITE;
} else {
-#ifdef DEBUG
- g_message("%s: Can't figure out flags 0x%x", __func__, flags);
-#endif
+ DEBUG("%s: Can't figure out flags 0x%x", __func__, flags);
}
/* Maybe sort out create mode too */
gpointer handle;
int flags;
-#ifdef DEBUG
- g_message("%s: creating standard handle type %s, fd %d", __func__,
+ DEBUG("%s: creating standard handle type %s, fd %d", __func__,
name, fd);
-#endif
#if !defined(__native_client__)
/* Check if fd is valid */
/* Invalid fd. Not really much point checking for EBADF
* specifically
*/
-#ifdef DEBUG
- g_message("%s: fcntl error on fd %d: %s", __func__, fd,
+ DEBUG("%s: fcntl error on fd %d: %s", __func__, fd,
strerror(errno));
-#endif
SetLastError (_wapi_get_win32_file_error (errno));
return(INVALID_HANDLE_VALUE);
return(INVALID_HANDLE_VALUE);
}
-#ifdef DEBUG
- g_message("%s: returning handle %p", __func__, handle);
-#endif
+ DEBUG("%s: returning handle %p", __func__, handle);
return(handle);
}
extern char **environ;
#endif
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#define DEBUG_ENABLED 1
+#else
+#define DEBUG(...)
+#endif
static guint32 process_wait (gpointer handle, guint32 timeout, gboolean alertable);
static void process_close (gpointer handle, gpointer data);
static const gunichar2 utf16_quote_bytes [2] = { 0x22, 0 };
static const gunichar2 *utf16_quote = utf16_quote_bytes;
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
/* Useful in gdb */
void
print_utf16 (gunichar2 *str)
if (appname != NULL) {
cmd = mono_unicode_to_external (appname);
if (cmd == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL",
+ DEBUG ("%s: unicode conversion returned NULL",
__func__);
-#endif
SetLastError (ERROR_PATH_NOT_FOUND);
goto free_strings;
if (cmdline != NULL) {
args = mono_unicode_to_external (cmdline);
if (args == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_PATH_NOT_FOUND);
goto free_strings;
if (cwd != NULL) {
dir = mono_unicode_to_external (cwd);
if (dir == NULL) {
-#ifdef DEBUG
- g_message ("%s: unicode conversion returned NULL", __func__);
-#endif
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_PATH_NOT_FOUND);
goto free_strings;
/* Executable existing ? */
if (!is_executable (prog)) {
-#ifdef DEBUG
- g_message ("%s: Couldn't find executable %s",
+ DEBUG ("%s: Couldn't find executable %s",
__func__, prog);
-#endif
g_free (unquoted);
SetLastError (ERROR_FILE_NOT_FOUND);
goto free_strings;
/* And make sure it's executable */
if (!is_executable (prog)) {
-#ifdef DEBUG
- g_message ("%s: Couldn't find executable %s",
+ DEBUG ("%s: Couldn't find executable %s",
__func__, prog);
-#endif
g_free (unquoted);
SetLastError (ERROR_FILE_NOT_FOUND);
goto free_strings;
if (token == NULL) {
/* Give up */
-#ifdef DEBUG
- g_message ("%s: Couldn't find what to exec", __func__);
-#endif
+ DEBUG ("%s: Couldn't find what to exec", __func__);
SetLastError (ERROR_PATH_NOT_FOUND);
goto free_strings;
/* Executable existing ? */
if (!is_executable (prog)) {
-#ifdef DEBUG
- g_message ("%s: Couldn't find executable %s",
+ DEBUG ("%s: Couldn't find executable %s",
__func__, token);
-#endif
g_free (token);
SetLastError (ERROR_FILE_NOT_FOUND);
goto free_strings;
g_free (prog);
prog = g_find_program_in_path (token);
if (prog == NULL) {
-#ifdef DEBUG
- g_message ("%s: Couldn't find executable %s", __func__, token);
-#endif
+ DEBUG ("%s: Couldn't find executable %s", __func__, token);
g_free (token);
SetLastError (ERROR_FILE_NOT_FOUND);
g_free (token);
}
-#ifdef DEBUG
- g_message ("%s: Exec prog [%s] args [%s]", __func__, prog,
+ DEBUG ("%s: Exec prog [%s] args [%s]", __func__, prog,
args_after_prog);
-#endif
/* Check for CLR binaries; if found, we will try to invoke
* them using the same mono binary that started us.
/* Could not create the pipe to synchroniz process startup. We'll just not synchronize.
* This is just for a very hard to hit race condition in the first place */
startup_pipe [0] = startup_pipe [1] = -1;
-#if DEBUG
- g_warning ("%s: new process startup not synchronized. We may not notice if the newly created process exits immediately.", __func__);
-#endif
+ DEBUG ("%s: new process startup not synchronized. We may not notice if the newly created process exits immediately.", __func__);
}
thr_ret = _wapi_handle_lock_shared_handles ();
if (startup_pipe [0] != -1) {
/* Wait until the parent has updated it's internal data */
read (startup_pipe [0], &dummy, 1);
-#if DEBUG
- g_warning ("%s: child: parent has completed its setup", __func__);
-#endif
+ DEBUG ("%s: child: parent has completed its setup", __func__);
close (startup_pipe [0]);
close (startup_pipe [1]);
}
close (i);
}
-#ifdef DEBUG
- g_message ("%s: exec()ing [%s] in dir [%s]", __func__, cmd,
+ DEBUG ("%s: exec()ing [%s] in dir [%s]", __func__, cmd,
dir==NULL?".":dir);
for (i = 0; argv[i] != NULL; i++) {
g_message ("arg %d: [%s]", i, argv[i]);
for (i = 0; env_strings[i] != NULL; i++) {
g_message ("env %d: [%s]", i, env_strings[i]);
}
-#endif
/* set cwd */
if (dir != NULL && chdir (dir) == -1) {
g_strfreev (argv);
}
-#ifdef DEBUG
- g_message ("%s: returning handle %p for pid %d", __func__, handle,
+ DEBUG ("%s: returning handle %p for pid %d", __func__, handle,
pid);
-#endif
/* Check if something needs to be cleaned up. */
mono_processes_cleanup ();
progname=g_get_prgname ();
utf8_progname=mono_utf8_from_external (progname);
-#ifdef DEBUG
- g_message ("%s: using [%s] as prog name", __func__, progname);
-#endif
+ DEBUG ("%s: using [%s] as prog name", __func__, progname);
if(utf8_progname!=NULL) {
slash=strrchr (utf8_progname, '/');
current_process = _wapi_handle_new_from_offset (WAPI_HANDLE_PROCESS, atoi (handle_env), TRUE);
-#ifdef DEBUG
- g_message ("%s: Found my process handle: %p (offset %d 0x%x)",
+ DEBUG ("%s: Found my process handle: %p (offset %d 0x%x)",
__func__, current_process, atoi (handle_env),
atoi (handle_env));
-#endif
ok = _wapi_lookup_handle (current_process, WAPI_HANDLE_PROCESS,
(gpointer *)&process_handlep);
procname = process_handlep->proc_name;
if (!strcmp (procname, "mono")) {
/* Set a better process name */
-#ifdef DEBUG
- g_message ("%s: Setting better process name", __func__);
-#endif
+ DEBUG ("%s: Setting better process name", __func__);
process_set_name (process_handlep);
} else {
-#ifdef DEBUG
- g_message ("%s: Leaving process name: %s", __func__, procname);
-#endif
+ DEBUG ("%s: Leaving process name: %s", __func__, procname);
}
return;
* child got a chance to attach it.)
*/
-#ifdef DEBUG
- g_message ("%s: Need to create my own process handle", __func__);
-#endif
+ DEBUG ("%s: Need to create my own process handle", __func__);
process_handle.id = pid;
return (0);
}
-#ifdef DEBUG
- g_message ("%s: looking at process %d", __func__, process_handle->id);
-#endif
+ DEBUG ("%s: looking at process %d", __func__, process_handle->id);
if (kill (process_handle->id, 0) == -1 &&
(errno == ESRCH ||
/* Ignore processes that have already exited (ie they are signalled) */
if (_wapi_handle_issignalled (handle) == FALSE) {
-#ifdef DEBUG
- g_message ("%s: process %d added to array", __func__, pid);
-#endif
+ DEBUG ("%s: process %d added to array", __func__, pid);
/* This ensures that duplicates aren't returned (see
* the comment above _wapi_search_handle () for why
mono_once (&process_current_once, process_set_current);
-#ifdef DEBUG
- g_message ("%s: looking for process %d", __func__, pid);
-#endif
+ DEBUG ("%s: looking for process %d", __func__, pid);
handle = _wapi_search_handle (WAPI_HANDLE_PROCESS,
process_open_compare,
*/
return GINT_TO_POINTER (_WAPI_PROCESS_UNHANDLED + pid);
} else {
-#ifdef DEBUG
- g_message ("%s: Can't find pid %d", __func__, pid);
-#endif
+ DEBUG ("%s: Can't find pid %d", __func__, pid);
SetLastError (ERROR_PROC_NOT_FOUND);
ok=_wapi_lookup_handle (process, WAPI_HANDLE_PROCESS,
(gpointer *)&process_handle);
if(ok==FALSE) {
-#ifdef DEBUG
- g_message ("%s: Can't find process %p", __func__, process);
-#endif
+ DEBUG ("%s: Can't find process %p", __func__, process);
return(FALSE);
}
ok=_wapi_lookup_handle (process, WAPI_HANDLE_PROCESS,
(gpointer *)&process_handle);
if(ok==FALSE) {
-#ifdef DEBUG
- g_message ("%s: Can't find process %p", __func__, process);
-#endif
+ DEBUG ("%s: Can't find process %p", __func__, process);
return(FALSE);
}
mod->inode = (ino_t) i;
mod->filename = g_strdup (info->dlpi_name);
-#ifdef DEBUG
- g_message ("%s: inode=%d, filename=%s, address_start=%p, address_end=%p", __func__,
+ DEBUG ("%s: inode=%d, filename=%s, address_start=%p, address_end=%p", __func__,
mod->inode, mod->filename, mod->address_start, mod->address_end);
-#endif
free(info);
ok = _wapi_lookup_handle (process, WAPI_HANDLE_PROCESS,
(gpointer *)&process_handle);
if (ok == FALSE) {
-#ifdef DEBUG
- g_message ("%s: Can't find process %p", __func__, process);
-#endif
+ DEBUG ("%s: Can't find process %p", __func__, process);
return(FALSE);
}
if (sysctl (mib, 4, pi, &size, NULL, 0) < 0) {
if (errno == ENOMEM) {
free(pi);
-#ifdef DEBUG
- g_message ("%s: Didn't allocate enough memory for kproc info", __func__);
-#endif
+ DEBUG ("%s: Didn't allocate enough memory for kproc info", __func__);
}
return(ret);
}
mono_once (&process_current_once, process_set_current);
-#ifdef DEBUG
- g_message ("%s: Getting module base name, process handle %p module %p",
+ DEBUG ("%s: Getting module base name, process handle %p module %p",
__func__, process, module);
-#endif
size = size*sizeof(gunichar2); /* adjust for unicode characters */
ok = _wapi_lookup_handle (process, WAPI_HANDLE_PROCESS,
(gpointer *)&process_handle);
if (ok == FALSE) {
-#ifdef DEBUG
- g_message ("%s: Can't find process %p", __func__,
+ DEBUG ("%s: Can't find process %p", __func__,
process);
-#endif
return(0);
}
}
if (procname_ext != NULL) {
-#ifdef DEBUG
- g_message ("%s: Process name is [%s]", __func__,
+ DEBUG ("%s: Process name is [%s]", __func__,
procname_ext);
-#endif
procname = mono_unicode_from_external (procname_ext, &bytes);
if (procname == NULL) {
bytes += 2;
if (size < bytes) {
-#ifdef DEBUG
- g_message ("%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
-#endif
+ DEBUG ("%s: Size %d smaller than needed (%ld); truncating", __func__, size, bytes);
memcpy (basename, procname, size);
} else {
-#ifdef DEBUG
- g_message ("%s: Size %d larger than needed (%ld)",
+ DEBUG ("%s: Size %d larger than needed (%ld)",
__func__, size, bytes);
-#endif
memcpy (basename, procname, bytes);
}
mono_once (&process_current_once, process_set_current);
-#ifdef DEBUG
- g_message ("%s: Getting module info, process handle %p module %p",
+ DEBUG ("%s: Getting module info, process handle %p module %p",
__func__, process, module);
-#endif
if (modinfo == NULL || size < sizeof(WapiModuleInfo)) {
return(FALSE);
ok = _wapi_lookup_handle (process, WAPI_HANDLE_PROCESS,
(gpointer *)&process_handle);
if (ok == FALSE) {
-#ifdef DEBUG
- g_message ("%s: Can't find process %p", __func__,
+ DEBUG ("%s: Can't find process %p", __func__,
process);
-#endif
return(FALSE);
}
ok=_wapi_lookup_handle (process, WAPI_HANDLE_PROCESS,
(gpointer *)&process_handle);
if(ok==FALSE) {
-#ifdef DEBUG
- g_message ("%s: Can't find process %p", __func__, process);
-#endif
+ DEBUG ("%s: Can't find process %p", __func__, process);
return(FALSE);
}
ok=_wapi_lookup_handle (process, WAPI_HANDLE_PROCESS,
(gpointer *)&process_handle);
if(ok==FALSE) {
-#ifdef DEBUG
- g_message ("%s: Can't find process %p", __func__, process);
-#endif
+ DEBUG ("%s: Can't find process %p", __func__, process);
return(FALSE);
}
(gpointer *) &process_handle);
if (ok == FALSE) {
-#ifdef DEBUG
- g_message ("%s: Can't find process %p", __func__,
+ DEBUG ("%s: Can't find process %p", __func__,
process);
-#endif
SetLastError (ERROR_INVALID_HANDLE);
return FALSE;
}
gpointer unref_handle;
int spin;
-#if DEBUG
- g_warning ("%s", __func__);
-#endif
+ DEBUG ("%s", __func__);
/* Ensure we're not in here in multiple threads at once, nor recursive. */
if (InterlockedCompareExchange (&mono_processes_cleaning_up, 1, 0) != 0)
/* We've modified the list of processes, and we know the sigchld handler
* isn't executing, so even if it executes at any moment, it'll see the
* new version of the list. So now we can free the candidate. */
-#if DEBUG
- g_warning ("%s: freeing candidate %p", __func__, candidate);
-#endif
+ DEBUG ("%s: freeing candidate %p", __func__, candidate);
mp = candidate->next;
MONO_SEM_DESTROY (&candidate->exit_sem);
g_free (candidate);
mp = mp->next;
}
-#if DEBUG
- g_warning ("%s done", __func__);
-#endif
+ DEBUG ("%s done", __func__);
InterlockedDecrement (&mono_processes_cleaning_up);
}
{
struct _WapiHandle_process *process_handle;
-#if DEBUG
- g_warning ("%s", __func__);
-#endif
+ DEBUG ("%s", __func__);
process_handle = (struct _WapiHandle_process *) data;
if (process_handle->mono_process && process_handle->self == _wapi_getpid ())
sigemptyset (&sa.sa_mask);
sa.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
g_assert (sigaction (SIGCHLD, &sa, &previous_chld_sa) != -1);
-#if DEBUG
- g_warning ("Added SIGCHLD handler");
-#endif
+ DEBUG ("Added SIGCHLD handler");
#endif
}
* but WaitFor*Object won't call us for pseudo handles. */
g_assert ((GPOINTER_TO_UINT (handle) & _WAPI_PROCESS_UNHANDLED) != _WAPI_PROCESS_UNHANDLED);
-#if DEBUG
- g_warning ("%s (%p, %u)", __func__, handle, timeout);
-#endif
+ DEBUG ("%s (%p, %u)", __func__, handle, timeout);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_PROCESS, (gpointer *)&process_handle);
if (ok == FALSE) {
if (process_handle->exited) {
/* We've already done this one */
-#if DEBUG
- g_warning ("%s (%p, %u): Process already exited", __func__, handle, timeout);
-#endif
+ DEBUG ("%s (%p, %u): Process already exited", __func__, handle, timeout);
return WAIT_OBJECT_0;
}
pid = process_handle->id;
-#if DEBUG
- g_warning ("%s (%p, %u): PID: %d", __func__, handle, timeout, pid);
-#endif
+ DEBUG ("%s (%p, %u): PID: %d", __func__, handle, timeout, pid);
/* We don't need to lock mono_processes here, the entry
* has a handle_count > 0 which means it will not be freed. */
if (mp != NULL) {
/* We have a semaphore we can wait on */
if (timeout != INFINITE) {
-#if DEBUG
- g_warning ("%s (%p, %u): waiting on semaphore for %li ms...",
+ DEBUG ("%s (%p, %u): waiting on semaphore for %li ms...",
__func__, handle, timeout, (timeout - (now - start)));
-#endif
ret = MONO_SEM_TIMEDWAIT_ALERTABLE (&mp->exit_sem, (timeout - (now - start)), alertable);
} else {
-#if DEBUG
- g_warning ("%s (%p, %u): waiting on semaphore forever...",
+ DEBUG ("%s (%p, %u): waiting on semaphore forever...",
__func__, handle, timeout);
-#endif
ret = MONO_SEM_WAIT_ALERTABLE (&mp->exit_sem, alertable);
}
if (ret == -1 && errno != EINTR && errno != ETIMEDOUT) {
-#if DEBUG
- g_warning ("%s (%p, %u): sem_timedwait failure: %s",
+ DEBUG ("%s (%p, %u): sem_timedwait failure: %s",
__func__, handle, timeout, g_strerror (errno));
-#endif
/* Should we return a failure here? */
}
} else {
/* We did not create this process, so we can't waidpid / sem_wait it.
* We need to poll for the pid existence */
-#if DEBUG
- g_warning ("%s (%p, %u): polling on pid...", __func__, handle, timeout);
-#endif
+ DEBUG ("%s (%p, %u): polling on pid...", __func__, handle, timeout);
if (!is_pid_valid (pid)) {
/* Success, process has exited */
break;
}
if (timeout == 0) {
-#if DEBUG
- g_warning ("%s (%p, %u): WAIT_TIMEOUT (timeout = 0)", __func__, handle, timeout);
-#endif
+ DEBUG ("%s (%p, %u): WAIT_TIMEOUT (timeout = 0)", __func__, handle, timeout);
return WAIT_TIMEOUT;
}
now = mono_msec_ticks ();
if (now - start >= timeout) {
-#if DEBUG
- g_warning ("%s (%p, %u): WAIT_TIMEOUT", __func__, handle, timeout);
-#endif
+ DEBUG ("%s (%p, %u): WAIT_TIMEOUT", __func__, handle, timeout);
return WAIT_TIMEOUT;
}
}
if (alertable && _wapi_thread_apc_pending (current_thread)) {
-#if DEBUG
- g_warning ("%s (%p, %u): WAIT_IO_COMPLETION", __func__, handle, timeout);
-#endif
+ DEBUG ("%s (%p, %u): WAIT_IO_COMPLETION", __func__, handle, timeout);
return WAIT_IO_COMPLETION;
}
}
/* Process must have exited */
-#if DEBUG
- g_warning ("%s (%p, %u): Waited successfully", __func__, handle, timeout);
-#endif
+ DEBUG ("%s (%p, %u): Waited successfully", __func__, handle, timeout);
ret = _wapi_handle_lock_shared_handles ();
g_assert (ret == 0);
process_handle->exited = TRUE;
-#if DEBUG
- g_warning ("%s (%p, %u): Setting pid %d signalled, exit status %d",
+ DEBUG ("%s (%p, %u): Setting pid %d signalled, exit status %d",
__func__, handle, timeout, process_handle->id, process_handle->exitstatus);
-#endif
_wapi_shared_handle_set_signal_state (handle, TRUE);
#include <mono/io-layer/mono-mutex.h>
#include <mono/io-layer/semaphore-private.h>
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
static void sema_signal(gpointer handle);
static gboolean sema_own (gpointer handle);
return(FALSE);
}
-#ifdef DEBUG
- g_message("%s: owning sem handle %p", __func__, handle);
-#endif
+ DEBUG("%s: owning sem handle %p", __func__, handle);
sem_handle->val--;
-#ifdef DEBUG
- g_message ("%s: sem %p val now %d", __func__, handle, sem_handle->val);
-#endif
+ DEBUG ("%s: sem %p val now %d", __func__, handle, sem_handle->val);
if(sem_handle->val==0) {
_wapi_handle_set_signal_state (handle, FALSE, FALSE);
struct _WapiHandle_namedsem *namedsem_handle;
gboolean ok;
-#ifdef DEBUG
- g_message ("%s: owning named sem handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: owning named sem handle %p", __func__, handle);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDSEM,
(gpointer *)&namedsem_handle);
namedsem_handle->val--;
-#ifdef DEBUG
- g_message ("%s: named sem %p val now %d", __func__, handle,
+ DEBUG ("%s: named sem %p val now %d", __func__, handle,
namedsem_handle->val);
-#endif
if (namedsem_handle->val == 0) {
_wapi_shared_handle_set_signal_state (handle, FALSE);
_wapi_handle_set_signal_state (handle, TRUE, FALSE);
}
-#ifdef DEBUG
- g_message ("%s: Created semaphore handle %p initial %d max %d",
+ DEBUG ("%s: Created semaphore handle %p initial %d max %d",
__func__, handle, initial, max);
-#endif
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-#ifdef DEBUG
- g_message ("%s: Creating named sem [%s]", __func__, utf8_name);
-#endif
+ DEBUG ("%s: Creating named sem [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDSEM,
utf8_name);
_wapi_handle_unlock_shared_handles ();
}
-#ifdef DEBUG
- g_message ("%s: returning named sem handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning named sem handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
mono_once (&sem_ops_once, sem_ops_init);
if (max <= 0) {
-#ifdef DEBUG
- g_message ("%s: max <= 0", __func__);
-#endif
+ DEBUG ("%s: max <= 0", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(NULL);
}
if (initial > max || initial < 0) {
-#ifdef DEBUG
- g_message ("%s: initial>max or < 0", __func__);
-#endif
+ DEBUG ("%s: initial>max or < 0", __func__);
SetLastError (ERROR_INVALID_PARAMETER);
return(NULL);
thr_ret = _wapi_handle_lock_handle (handle);
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message ("%s: sem %p val %d count %d", __func__, handle,
+ DEBUG ("%s: sem %p val %d count %d", __func__, handle,
sem_handle->val, count);
-#endif
/* Do this before checking for count overflow, because overflowing max
* is a listed technique for finding the current value
/* No idea why max is signed, but thats the spec :-( */
if (sem_handle->val + count > (guint32)sem_handle->max) {
-#ifdef DEBUG
- g_message ("%s: sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
-#endif
+ DEBUG ("%s: sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
goto end;
}
ret = TRUE;
-#ifdef DEBUG
- g_message ("%s: sem %p val now %d", __func__, handle, sem_handle->val);
-#endif
+ DEBUG ("%s: sem %p val now %d", __func__, handle, sem_handle->val);
end:
thr_ret = _wapi_handle_unlock_handle (handle);
thr_ret = _wapi_handle_lock_shared_handles ();
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message("%s: named sem %p val %d count %d", __func__, handle,
+ DEBUG("%s: named sem %p val %d count %d", __func__, handle,
sem_handle->val, count);
-#endif
/* Do this before checking for count overflow, because overflowing max
* is a listed technique for finding the current value
/* No idea why max is signed, but thats the spec :-( */
if (sem_handle->val + count > (guint32)sem_handle->max) {
-#ifdef DEBUG
- g_message ("%s: named sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
-#endif
+ DEBUG ("%s: named sem %p max value would be exceeded: max %d current %d count %d", __func__, handle, sem_handle->max, sem_handle->val, count);
goto end;
}
ret = TRUE;
-#ifdef DEBUG
- g_message("%s: named sem %p val now %d", __func__, handle,
+ DEBUG("%s: named sem %p val now %d", __func__, handle,
sem_handle->val);
-#endif
end:
_wapi_handle_unlock_shared_handles ();
utf8_name = g_utf16_to_utf8 (name, -1, NULL, NULL, NULL);
-#ifdef DEBUG
- g_message ("%s: Opening named sem [%s]", __func__, utf8_name);
-#endif
+ DEBUG ("%s: Opening named sem [%s]", __func__, utf8_name);
offset = _wapi_search_handle_namespace (WAPI_HANDLE_NAMEDSEM,
utf8_name);
}
ret = handle;
-#ifdef DEBUG
- g_message ("%s: returning named sem handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning named sem handle %p", __func__, handle);
cleanup:
g_free (utf8_name);
#include <sys/sendfile.h>
#endif
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
static guint32 startup_count=0;
static guint32 in_cleanup = 0;
int ret;
struct _WapiHandle_socket *socket_handle = (struct _WapiHandle_socket *)data;
-#ifdef DEBUG
- g_message ("%s: closing socket handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: closing socket handle %p", __func__, handle);
if (startup_count == 0 && !in_cleanup) {
WSASetLastError (WSANOTINITIALISED);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: close error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: close error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
if (!in_cleanup)
WSASetLastError (errnum);
data->wVersion = requested < data->wHighVersion? requested:
data->wHighVersion;
-#ifdef DEBUG
- g_message ("%s: high version 0x%x", __func__, data->wHighVersion);
-#endif
+ DEBUG ("%s: high version 0x%x", __func__, data->wHighVersion);
strncpy (data->szDescription, "WAPI", WSADESCRIPTION_LEN);
strncpy (data->szSystemStatus, "groovy", WSASYS_STATUS_LEN);
int WSACleanup(void)
{
-#ifdef DEBUG
- g_message ("%s: cleaning up", __func__);
-#endif
+ DEBUG ("%s: cleaning up", __func__);
if (--startup_count) {
/* Do nothing */
if (new_fd == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: accept error: %s", __func__, strerror(errno));
-#endif
+ DEBUG ("%s: accept error: %s", __func__, strerror(errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
}
if (new_fd >= _wapi_fd_reserve) {
-#ifdef DEBUG
- g_message ("%s: File descriptor is too big", __func__);
-#endif
+ DEBUG ("%s: File descriptor is too big", __func__);
WSASetLastError (WSASYSCALLFAILURE);
return(INVALID_SOCKET);
}
-#ifdef DEBUG
- g_message ("%s: returning newly accepted socket handle %p with",
+ DEBUG ("%s: returning newly accepted socket handle %p with",
__func__, new_handle);
-#endif
return(new_fd);
}
ret = bind (fd, my_addr, addrlen);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: bind error: %s", __func__, strerror(errno));
-#endif
+ DEBUG ("%s: bind error: %s", __func__, strerror(errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
errnum = errno;
if (errno != EINTR) {
-#ifdef DEBUG
- g_message ("%s: connect error: %s", __func__,
+ DEBUG ("%s: connect error: %s", __func__,
strerror (errnum));
-#endif
errnum = errno_to_WSA (errnum, __func__);
if (errnum == WSAEINPROGRESS)
if (errno != EINTR) {
errnum = errno_to_WSA (errno, __func__);
-#ifdef DEBUG
- g_message ("%s: connect poll error: %s",
+ DEBUG ("%s: connect poll error: %s",
__func__, strerror (errno));
-#endif
WSASetLastError (errnum);
return(SOCKET_ERROR);
&len) == -1) {
errnum = errno_to_WSA (errno, __func__);
-#ifdef DEBUG
- g_message ("%s: connect getsockopt error: %s",
+ DEBUG ("%s: connect getsockopt error: %s",
__func__, strerror (errno));
-#endif
WSASetLastError (errnum);
return(SOCKET_ERROR);
socket_handle->saved_error = errnum;
}
-#ifdef DEBUG
- g_message ("%s: connect getsockopt returned error: %s",
+ DEBUG ("%s: connect getsockopt returned error: %s",
__func__, strerror (so_error));
-#endif
WSASetLastError (errnum);
return(SOCKET_ERROR);
ret = getpeername (fd, name, namelen);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: getpeername error: %s", __func__,
+ DEBUG ("%s: getpeername error: %s", __func__,
strerror (errno));
-#endif
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
ret = getsockname (fd, name, namelen);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: getsockname error: %s", __func__,
+ DEBUG ("%s: getsockname error: %s", __func__,
strerror (errno));
-#endif
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
ret = getsockopt (fd, level, optname, tmp_val, optlen);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: getsockopt error: %s", __func__,
+ DEBUG ("%s: getsockopt error: %s", __func__,
strerror (errno));
-#endif
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
ret = listen (fd, backlog);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: listen error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: listen error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: recv error: %s", __func__, strerror(errno));
-#endif
+ DEBUG ("%s: recv error: %s", __func__, strerror(errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: recvmsg error: %s", __func__, strerror(errno));
-#endif
+ DEBUG ("%s: recvmsg error: %s", __func__, strerror(errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: send error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: send error: %s", __func__, strerror (errno));
#ifdef O_NONBLOCK
/* At least linux returns EAGAIN/EWOULDBLOCK when the timeout has been set on
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: send error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: send error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: sendmsg error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: sendmsg error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
ret = setsockopt (fd, level, optname, tmp_val, optlen);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: setsockopt error: %s", __func__,
+ DEBUG ("%s: setsockopt error: %s", __func__,
strerror (errno));
-#endif
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
ret = shutdown (fd, how);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: shutdown error: %s", __func__,
+ DEBUG ("%s: shutdown error: %s", __func__,
strerror (errno));
-#endif
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (fd == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: socket error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: socket error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
}
if (fd >= _wapi_fd_reserve) {
-#ifdef DEBUG
- g_message ("%s: File descriptor is too big (%d >= %d)",
+ DEBUG ("%s: File descriptor is too big (%d >= %d)",
__func__, fd, _wapi_fd_reserve);
-#endif
WSASetLastError (WSASYSCALLFAILURE);
close (fd);
if (ret == -1) {
int errnum = errno;
-#ifdef DEBUG
- g_message ("%s: Error setting SO_REUSEADDR", __func__);
-#endif
+ DEBUG ("%s: Error setting SO_REUSEADDR", __func__);
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
return(INVALID_SOCKET);
}
-#ifdef DEBUG
- g_message ("%s: returning socket handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: returning socket handle %p", __func__, handle);
return(fd);
}
he = gethostbyname (hostname);
if (he == NULL) {
-#ifdef DEBUG
- g_message ("%s: gethostbyname error: %s", __func__,
+ DEBUG ("%s: gethostbyname error: %s", __func__,
strerror (h_errno));
-#endif
switch(h_errno) {
case HOST_NOT_FOUND:
if (newsock == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: socket error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: socket error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: dup2 error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: dup2 error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
static gboolean wapi_disconnectex (guint32 fd, WapiOverlapped *overlapped,
guint32 flags, guint32 reserved)
{
-#ifdef DEBUG
- g_message ("%s: called on socket %d!", __func__, fd);
-#endif
+ DEBUG ("%s: called on socket %d!", __func__, fd);
if (reserved != 0) {
WSASetLastError (WSAEINVAL);
ret = ioctl (fd, command, buffer);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message("%s: WSAIoctl error: %s", __func__,
+ DEBUG("%s: WSAIoctl error: %s", __func__,
strerror (errno));
-#endif
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: ioctl error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: ioctl error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
if (ret == -1) {
gint errnum = errno;
-#ifdef DEBUG
- g_message ("%s: select error: %s", __func__, strerror (errno));
-#endif
+ DEBUG ("%s: select error: %s", __func__, strerror (errno));
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
#include <mono/utils/strenc.h>
#include <mono/utils/mono-mmap.h>
-#define LOGDEBUG(...)
-//define LOGDEBUG(...) g_message(__VA_ARGS__)
+#if 0
+// #define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
#define ALIGN32(ptr) ptr = (gpointer)((char *)ptr + 3); ptr = (gpointer)((char *)ptr - ((gsize)ptr & 3));
dos_header = (WapiImageDosHeader *)file_map;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
- LOGDEBUG ("%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
+ DEBUG ("%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(WapiImageNTHeaders32) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
- LOGDEBUG ("%s: File is too small: %d", __func__, map_size);
+ DEBUG ("%s: File is too small: %d", __func__, map_size);
SetLastError (ERROR_BAD_LENGTH);
return(NULL);
nt_headers = (WapiImageNTHeaders32 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
- LOGDEBUG ("%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
+ DEBUG ("%s: Bad NT signature 0x%x", __func__, nt_headers->Signature);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (resource_rva == 0) {
- LOGDEBUG ("%s: No resources in file!", __func__);
+ DEBUG ("%s: No resources in file!", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
if (resource_dir == NULL) {
- LOGDEBUG ("%s: Can't find resource directory", __func__);
+ DEBUG ("%s: Can't find resource directory", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
dos_header = (WapiImageDosHeader *)file_map;
if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) {
- LOGDEBUG ("%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
+ DEBUG ("%s: Bad dos signature 0x%x", __func__, dos_header->e_magic);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
}
if (map_size < sizeof(WapiImageNTHeaders64) + GUINT32_FROM_LE (dos_header->e_lfanew)) {
- LOGDEBUG ("%s: File is too small: %d", __func__, map_size);
+ DEBUG ("%s: File is too small: %d", __func__, map_size);
SetLastError (ERROR_BAD_LENGTH);
return(NULL);
nt_headers = (WapiImageNTHeaders64 *)((guint8 *)file_map + GUINT32_FROM_LE (dos_header->e_lfanew));
if (nt_headers->Signature != IMAGE_NT_SIGNATURE) {
- LOGDEBUG ("%s: Bad NT signature 0x%x", __func__,
+ DEBUG ("%s: Bad NT signature 0x%x", __func__,
nt_headers->Signature);
SetLastError (ERROR_INVALID_DATA);
}
if (resource_rva == 0) {
- LOGDEBUG ("%s: No resources in file!", __func__);
+ DEBUG ("%s: No resources in file!", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
resource_dir = (WapiImageResourceDirectory *)get_ptr_from_rva (resource_rva, (WapiImageNTHeaders32 *)nt_headers, file_map);
if (resource_dir == NULL) {
- LOGDEBUG ("%s: Can't find resource directory", __func__);
+ DEBUG ("%s: Can't find resource directory", __func__);
SetLastError (ERROR_INVALID_DATA);
return(NULL);
filename_ext = mono_unicode_to_external (filename);
if (filename_ext == NULL) {
- LOGDEBUG ("%s: unicode conversion returned NULL", __func__);
+ DEBUG ("%s: unicode conversion returned NULL", __func__);
SetLastError (ERROR_INVALID_NAME);
return(NULL);
fd = _wapi_open (filename_ext, O_RDONLY, 0);
if (fd == -1) {
- LOGDEBUG ("%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
+ DEBUG ("%s: Error opening file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
}
if (fstat (fd, &statbuf) == -1) {
- LOGDEBUG ("%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
+ DEBUG ("%s: Error stat()ing file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
/* Check basic file size */
if (statbuf.st_size < sizeof(WapiImageDosHeader)) {
- LOGDEBUG ("%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
+ DEBUG ("%s: File %s is too small: %lld", __func__, filename_ext, statbuf.st_size);
SetLastError (ERROR_BAD_LENGTH);
g_free (filename_ext);
file_map = mono_file_map (statbuf.st_size, MONO_MMAP_READ | MONO_MMAP_PRIVATE, fd, 0, handle);
if (file_map == NULL) {
- LOGDEBUG ("%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
+ DEBUG ("%s: Error mmap()int file %s: %s", __func__, filename_ext, strerror (errno));
SetLastError (_wapi_get_win32_file_error (errno));
g_free (filename_ext);
data_len = block->data_len;
if (block->value_len != sizeof(WapiFixedFileInfo)) {
- LOGDEBUG ("%s: FIXEDFILEINFO size mismatch", __func__);
+ DEBUG ("%s: FIXEDFILEINFO size mismatch", __func__);
return(NULL);
}
if (!unicode_string_equals (block->key, "VS_VERSION_INFO")) {
- LOGDEBUG ("%s: VS_VERSION_INFO mismatch", __func__);
+ DEBUG ("%s: VS_VERSION_INFO mismatch", __func__);
return(NULL);
}
ffi = ((WapiFixedFileInfo *)data_ptr);
if ((ffi->dwSignature != VS_FFI_SIGNATURE) ||
(ffi->dwStrucVersion != VS_FFI_STRUCVERSION)) {
- LOGDEBUG ("%s: FIXEDFILEINFO bad signature", __func__);
+ DEBUG ("%s: FIXEDFILEINFO bad signature", __func__);
return(NULL);
}
/* We must have hit padding, so give up
* processing now
*/
- LOGDEBUG ("%s: Hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
/* We must have hit padding, so give up
* processing now
*/
- LOGDEBUG ("%s: Hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
found_lang = g_utf16_to_utf8 (block->key, 8, NULL, NULL, NULL);
if (found_lang == NULL) {
- LOGDEBUG ("%s: Didn't find a valid language key, giving up", __func__);
+ DEBUG ("%s: Didn't find a valid language key, giving up", __func__);
return(NULL);
}
if (data_ptr == NULL) {
/* Child block hit padding */
- LOGDEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
return(NULL);
}
}
/* We must have hit padding, so give up
* processing now
*/
- LOGDEBUG ("%s: Hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
"UTF-16BE", "UTF-16LE", NULL, NULL,
NULL);
if (big_value == NULL) {
- LOGDEBUG ("%s: Didn't find a valid string, giving up", __func__);
+ DEBUG ("%s: Didn't find a valid string, giving up", __func__);
return(NULL);
}
"UTF-16BE", "UTF-16LE", NULL, NULL,
NULL);
if (big_value == NULL) {
- LOGDEBUG ("%s: Didn't find a valid data string, giving up", __func__);
+ DEBUG ("%s: Didn't find a valid data string, giving up", __func__);
return(NULL);
}
memcpy ((gpointer)data_ptr, big_value,
/* We must have hit padding, so give up
* processing now
*/
- LOGDEBUG ("%s: Hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Hit 0-length block, giving up", __func__);
return(NULL);
}
big_value = g_convert ((gchar *)block->key, 16, "UTF-16BE",
"UTF-16LE", NULL, NULL, NULL);
if (big_value == NULL) {
- LOGDEBUG ("%s: Didn't find a valid string, giving up", __func__);
+ DEBUG ("%s: Didn't find a valid string, giving up", __func__);
return(NULL);
}
if (data_ptr == NULL) {
/* Child block hit padding */
- LOGDEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
return(NULL);
}
}
/* We must have hit padding, so give
* up processing now
*/
- LOGDEBUG ("%s: Hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Hit 0-length block, giving up", __func__);
return;
}
&block);
} else {
/* Bogus data */
- LOGDEBUG ("%s: Not a valid VERSIONINFO child block", __func__);
+ DEBUG ("%s: Not a valid VERSIONINFO child block", __func__);
return;
}
if (data_ptr == NULL) {
/* Child block hit padding */
- LOGDEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
return;
}
}
/* We must have hit padding,
* so give up processing now
*/
- LOGDEBUG ("%s: Hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Hit 0-length block, giving up", __func__);
goto done;
}
}
} else {
/* Bogus data */
- LOGDEBUG ("%s: Not a valid VERSIONINFO child block", __func__);
+ DEBUG ("%s: Not a valid VERSIONINFO child block", __func__);
goto done;
}
if (data_ptr == NULL) {
/* Child block hit padding */
- LOGDEBUG ("%s: Child block hit 0-length block, giving up", __func__);
+ DEBUG ("%s: Child block hit 0-length block, giving up", __func__);
goto done;
}
}
#include <mono/io-layer/mono-mutex.h>
#include <mono/io-layer/misc-private.h>
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
static gboolean own_if_signalled(gpointer handle)
{
if (_wapi_handle_test_capabilities (handle,
WAPI_HANDLE_CAP_WAIT) == FALSE) {
-#ifdef DEBUG
- g_message ("%s: handle %p can't be waited for", __func__,
+ DEBUG ("%s: handle %p can't be waited for", __func__,
handle);
-#endif
return(WAIT_FAILED);
}
_wapi_handle_ops_prewait (handle);
if (_wapi_handle_test_capabilities (handle, WAPI_HANDLE_CAP_SPECIAL_WAIT) == TRUE) {
-#ifdef DEBUG
- g_message ("%s: handle %p has special wait", __func__, handle);
-#endif
+ DEBUG ("%s: handle %p has special wait", __func__, handle);
ret = _wapi_handle_ops_special_wait (handle, timeout, alertable);
}
-#ifdef DEBUG
- g_message ("%s: locking handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: locking handle %p", __func__, handle);
pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
handle);
if (_wapi_handle_test_capabilities (handle,
WAPI_HANDLE_CAP_OWN) == TRUE) {
if (own_if_owned (handle) == TRUE) {
-#ifdef DEBUG
- g_message ("%s: handle %p already owned", __func__,
+ DEBUG ("%s: handle %p already owned", __func__,
handle);
-#endif
ret = WAIT_OBJECT_0;
goto done;
}
}
if (own_if_signalled (handle) == TRUE) {
-#ifdef DEBUG
- g_message ("%s: handle %p already signalled", __func__,
+ DEBUG ("%s: handle %p already signalled", __func__,
handle);
-#endif
ret=WAIT_OBJECT_0;
goto done;
_wapi_handle_ops_prewait (handle);
if (own_if_signalled (handle)) {
-#ifdef DEBUG
- g_message ("%s: handle %p signalled", __func__,
+ DEBUG ("%s: handle %p signalled", __func__,
handle);
-#endif
ret = WAIT_OBJECT_0;
goto done;
* if someone else got in before us.)
*/
if (own_if_signalled (handle)) {
-#ifdef DEBUG
- g_message ("%s: handle %p signalled", __func__,
+ DEBUG ("%s: handle %p signalled", __func__,
handle);
-#endif
ret=WAIT_OBJECT_0;
goto done;
} while(waited == 0 && !apc_pending);
/* Timeout or other error */
-#ifdef DEBUG
- g_message ("%s: wait on handle %p error: %s", __func__, handle,
+ DEBUG ("%s: wait on handle %p error: %s", __func__, handle,
strerror (waited));
-#endif
ret = WAIT_TIMEOUT;
done:
-#ifdef DEBUG
- g_message ("%s: unlocking handle %p", __func__, handle);
-#endif
+ DEBUG ("%s: unlocking handle %p", __func__, handle);
thr_ret = _wapi_handle_unlock_handle (handle);
g_assert (thr_ret == 0);
return (WAIT_FAILED);
}
-#ifdef DEBUG
- g_message ("%s: locking handle %p", __func__, wait);
-#endif
+ DEBUG ("%s: locking handle %p", __func__, wait);
pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_handle,
wait);
if (_wapi_handle_test_capabilities (wait, WAPI_HANDLE_CAP_OWN)==TRUE) {
if (own_if_owned (wait)) {
-#ifdef DEBUG
- g_message ("%s: handle %p already owned", __func__,
+ DEBUG ("%s: handle %p already owned", __func__,
wait);
-#endif
ret = WAIT_OBJECT_0;
goto done;
}
}
if (own_if_signalled (wait)) {
-#ifdef DEBUG
- g_message ("%s: handle %p already signalled", __func__, wait);
-#endif
+ DEBUG ("%s: handle %p already signalled", __func__, wait);
ret = WAIT_OBJECT_0;
goto done;
_wapi_handle_ops_prewait (wait);
if (own_if_signalled (wait)) {
-#ifdef DEBUG
- g_message ("%s: handle %p signalled", __func__, wait);
-#endif
+ DEBUG ("%s: handle %p signalled", __func__, wait);
ret = WAIT_OBJECT_0;
goto done;
* if someone else got in before us.)
*/
if (own_if_signalled (wait)) {
-#ifdef DEBUG
- g_message ("%s: handle %p signalled", __func__,
+ DEBUG ("%s: handle %p signalled", __func__,
wait);
-#endif
ret = WAIT_OBJECT_0;
goto done;
} while(waited == 0 && !apc_pending);
/* Timeout or other error */
-#ifdef DEBUG
- g_message ("%s: wait on handle %p error: %s", __func__, wait,
+ DEBUG ("%s: wait on handle %p error: %s", __func__, wait,
strerror (ret));
-#endif
ret = WAIT_TIMEOUT;
done:
-#ifdef DEBUG
- g_message ("%s: unlocking handle %p", __func__, wait);
-#endif
+ DEBUG ("%s: unlocking handle %p", __func__, wait);
thr_ret = _wapi_handle_unlock_handle (wait);
g_assert (thr_ret == 0);
gboolean done;
int i;
-#ifdef DEBUG
- g_message ("%s: locking handles", __func__);
-#endif
+ DEBUG ("%s: locking handles", __func__);
cleanup_data.numobjects = numobjects;
cleanup_data.handles = handles;
}
}
-#ifdef DEBUG
- g_message ("%s: unlocking handles", __func__);
-#endif
+ DEBUG ("%s: unlocking handles", __func__);
/* calls the unlock function */
pthread_cleanup_pop (1);
}
if (numobjects > MAXIMUM_WAIT_OBJECTS) {
-#ifdef DEBUG
- g_message ("%s: Too many handles: %d", __func__, numobjects);
-#endif
+ DEBUG ("%s: Too many handles: %d", __func__, numobjects);
return(WAIT_FAILED);
}
handles[i] = _wapi_thread_handle_from_id (pthread_self ());
if (handles[i] == NULL) {
-#ifdef DEBUG
- g_message ("%s: Handle %d bogus", __func__, i);
-#endif
+ DEBUG ("%s: Handle %d bogus", __func__, i);
bogustype = TRUE;
break;
}
if ((GPOINTER_TO_UINT (handles[i]) & _WAPI_PROCESS_UNHANDLED) == _WAPI_PROCESS_UNHANDLED) {
-#ifdef DEBUG
- g_message ("%s: Handle %d pseudo process", __func__,
+ DEBUG ("%s: Handle %d pseudo process", __func__,
i);
-#endif
bogustype = TRUE;
break;
}
if (_wapi_handle_test_capabilities (handles[i], WAPI_HANDLE_CAP_WAIT) == FALSE) {
-#ifdef DEBUG
- g_message ("%s: Handle %p can't be waited for",
+ DEBUG ("%s: Handle %p can't be waited for",
__func__, handles[i]);
-#endif
bogustype = TRUE;
break;
}
if (duplicate == TRUE) {
-#ifdef DEBUG
- g_message ("%s: Returning due to duplicates", __func__);
-#endif
+ DEBUG ("%s: Returning due to duplicates", __func__);
return(WAIT_FAILED);
}
if (bogustype == TRUE) {
-#ifdef DEBUG
- g_message ("%s: Returning due to bogus type", __func__);
-#endif
+ DEBUG ("%s: Returning due to bogus type", __func__);
return(WAIT_FAILED);
}
}
}
-#ifdef DEBUG
- g_message ("%s: locking signal mutex", __func__);
-#endif
+ DEBUG ("%s: locking signal mutex", __func__);
pthread_cleanup_push ((void(*)(void *))_wapi_handle_unlock_signal_mutex, NULL);
thr_ret = _wapi_handle_lock_signal_mutex ();
ret = 0;
}
-#ifdef DEBUG
- g_message ("%s: unlocking signal mutex", __func__);
-#endif
+ DEBUG ("%s: unlocking signal mutex", __func__);
thr_ret = _wapi_handle_unlock_signal_mutex (NULL);
g_assert (thr_ret == 0);
/* Didn't get all handles, and there was a
* timeout or other error
*/
-#ifdef DEBUG
- g_message ("%s: wait returned error: %s", __func__,
+ DEBUG ("%s: wait returned error: %s", __func__,
strerror (ret));
-#endif
if(ret==ETIMEDOUT) {
retval = WAIT_TIMEOUT;
gboolean, gboolean);
static int globextend(const gchar *, wapi_glob_t *, size_t *);
static int match(const gchar *, gchar *, gchar *, gboolean);
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
static void qprintf(const char *, Char *);
#endif
}
}
*bufnext = EOS;
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
qprintf("glob0:", patbuf);
#endif
return (1);
}
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
static void
qprintf(const char *str, Char *s)
{
#include <valgrind/memcheck.h>
#endif
-#undef DEBUG
+#if 0
+#define DEBUG(...) g_message(__VA_ARGS__)
+#else
+#define DEBUG(...)
+#endif
#if 0
#define WAIT_DEBUG(code) do { code } while (0)
pid_t pid = _wapi_getpid ();
pthread_t tid = pthread_self ();
-#ifdef DEBUG
- g_message ("%s: Thread %p abandoning held mutexes", __func__, handle);
-#endif
+ DEBUG ("%s: Thread %p abandoning held mutexes", __func__, handle);
if (handle == NULL) {
handle = _wapi_thread_handle_from_id (pthread_self ());
return;
}
-#ifdef DEBUG
- g_message ("%s: Thread %p terminating", __func__, handle);
-#endif
+ DEBUG ("%s: Thread %p terminating", __func__, handle);
_wapi_thread_abandon_mutexes (handle);
g_assert (thr_ret == 0);
pthread_cleanup_pop (0);
-#ifdef DEBUG
- g_message("%s: Recording thread handle %p id %ld status as %d",
+ DEBUG("%s: Recording thread handle %p id %ld status as %d",
__func__, handle, thread_handle->id, exitstatus);
-#endif
/* The thread is no longer active, so unref it */
_wapi_handle_unref (handle);
mono_gc_pthread_exit (NULL);
}
-#ifdef DEBUG
- g_message ("%s: started thread id %ld", __func__, thread->id);
-#endif
+ DEBUG ("%s: started thread id %ld", __func__, thread->id);
/* We set it again here since passing &thread->id to pthread_create is racy
as the thread can start running before the value is set.*/
thread_start_routine, (void *)thread_handle_p);
if (ret != 0) {
-#ifdef DEBUG
- g_message ("%s: Thread create error: %s", __func__,
+ DEBUG ("%s: Thread create error: %s", __func__,
strerror(ret));
-#endif
/* Two, because of the reference we took above */
unrefs = 2;
}
ct_ret = handle;
-#ifdef DEBUG
- g_message("%s: Started thread handle %p ID %ld", __func__, handle,
+ DEBUG("%s: Started thread handle %p ID %ld", __func__, handle,
thread_handle_p->id);
-#endif
if (tid != NULL) {
#ifdef PTHREAD_POINTER_ID
(ret = pthread_getspecific (thread_hash_key)) != NULL) {
/* We know the handle */
-#ifdef DEBUG
- g_message ("%s: Returning %p for self thread %ld from TLS",
+ DEBUG ("%s: Returning %p for self thread %ld from TLS",
__func__, ret, tid);
-#endif
return(ret);
}
-#ifdef DEBUG
- g_message ("%s: Returning NULL for unknown or non-self thread %ld",
+ DEBUG ("%s: Returning NULL for unknown or non-self thread %ld",
__func__, tid);
-#endif
return(NULL);
return(FALSE);
}
-#ifdef DEBUG
- g_message ("%s: looking at thread %ld from process %d", __func__, thread_handle->id, 0);
-#endif
+ DEBUG ("%s: looking at thread %ld from process %d", __func__, thread_handle->id, 0);
if (pthread_equal (thread_handle->id, tid)) {
-#ifdef DEBUG
- g_message ("%s: found the thread we are looking for",
+ DEBUG ("%s: found the thread we are looking for",
__func__);
-#endif
return(TRUE);
}
}
-#ifdef DEBUG
- g_message ("%s: not found %ld, returning FALSE", __func__, tid);
-#endif
+ DEBUG ("%s: not found %ld, returning FALSE", __func__, tid);
return(FALSE);
}
mono_once (&thread_hash_once, thread_hash_init);
mono_once (&thread_ops_once, thread_ops_init);
-#ifdef DEBUG
- g_message ("%s: looking up thread %"G_GSIZE_FORMAT, __func__, tid);
-#endif
+ DEBUG ("%s: looking up thread %"G_GSIZE_FORMAT, __func__, tid);
ret = _wapi_thread_handle_from_id ((pthread_t)tid);
if (ret == NULL) {
_wapi_handle_ref (ret);
}
-#ifdef DEBUG
- g_message ("%s: returning thread handle %p", __func__, ret);
-#endif
+ DEBUG ("%s: returning thread handle %p", __func__, ret);
return(ret);
}
return (FALSE);
}
-#ifdef DEBUG
- g_message ("%s: Finding exit status for thread handle %p id %ld",
+ DEBUG ("%s: Finding exit status for thread handle %p id %ld",
__func__, handle, thread_handle->id);
-#endif
if (exitcode == NULL) {
-#ifdef DEBUG
- g_message ("%s: Nowhere to store exit code", __func__);
-#endif
+ DEBUG ("%s: Nowhere to store exit code", __func__);
return(FALSE);
}
if (thread_handle->state != THREAD_STATE_EXITED) {
-#ifdef DEBUG
- g_message ("%s: Thread still active (state %d, exited is %d)",
+ DEBUG ("%s: Thread still active (state %d, exited is %d)",
__func__, thread_handle->state,
THREAD_STATE_EXITED);
-#endif
*exitcode = STILL_ACTIVE;
return(TRUE);
}
thr_ret = pthread_setspecific (thread_attached_key, (void *)handle);
g_assert (thr_ret == 0);
-#ifdef DEBUG
- g_message("%s: Attached thread handle %p ID %ld", __func__, handle,
+ DEBUG("%s: Attached thread handle %p ID %ld", __func__, handle,
thread_handle_p->id);
-#endif
if (tid != NULL) {
#ifdef PTHREAD_POINTER_ID
int ret;
gpointer current_thread = NULL;
-#ifdef DEBUG
- g_message("%s: Sleeping for %d ms", __func__, ms);
-#endif
+ DEBUG("%s: Sleeping for %d ms", __func__, ms);
if (alertable) {
current_thread = _wapi_thread_handle_from_id (pthread_self ());
if(ret==-1) {
/* Sleep interrupted with rem time remaining */
-#ifdef DEBUG
+#ifdef DEBUG_ENABLED
guint32 rems=rem.tv_sec*1000 + rem.tv_nsec/1000000;
g_message("%s: Still got %d ms to go", __func__, rems);
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_THREAD,
(gpointer *)&thread);
if (ok == FALSE) {
-#ifdef DEBUG
/* This might happen at process shutdown, as all
* thread handles are forcibly closed. If a thread
* still has an alertable wait the final
* _wapi_thread_apc_pending check will probably fail
* to find the handle
*/
- g_warning ("%s: error looking up thread handle %p", __func__,
+ DEBUG ("%s: error looking up thread handle %p", __func__,
handle);
-#endif
return (FALSE);
}