Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConrad Scott <conrad.scott@dsl.pipex.com>2002-06-16 01:01:45 +0400
committerConrad Scott <conrad.scott@dsl.pipex.com>2002-06-16 01:01:45 +0400
commit18f2b940a113206d9a431d6747675c25730f5a26 (patch)
tree345bcaf9d82b2775f121ff8861a03ffcd715240a /winsup/cygserver
parent314c917a7c2a56906d0a22eb42e57abfbfe83c06 (diff)
* woutsup.h: New file.
* cygserver.cc: Use "woutsup.h" and new XXX_printf macros. (getfunc): New function, copied verbatim from "strace.cc". (__cygserver__printf): New function. * cygserver_client.cc: Use "woutsup.h" and new XXX_printf macros. * cygserver_process.cc: Ditto. * cygserver_shm.cc: Ditto. * cygserver_transport.cc: Ditto. * cygserver_transport_pipes.cc: Ditto. * cygserver_transport_sockets.cc: Ditto. * threaded_queue.cc: Ditto. * shm.cc: Remove trailing \n from XXX_printf format strings. * Makefile.in: Remove redundant __OUTSIDE_CYGWIN__ case for cygserver_shm.cc.
Diffstat (limited to 'winsup/cygserver')
-rw-r--r--winsup/cygserver/threaded_queue.cc41
-rw-r--r--winsup/cygserver/woutsup.h101
2 files changed, 121 insertions, 21 deletions
diff --git a/winsup/cygserver/threaded_queue.cc b/winsup/cygserver/threaded_queue.cc
index 321fa1612..d646bccbd 100644
--- a/winsup/cygserver/threaded_queue.cc
+++ b/winsup/cygserver/threaded_queue.cc
@@ -10,16 +10,14 @@
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#include "woutsup.h"
+
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
-#include <windows.h>
#include <sys/types.h>
#include <stdlib.h>
-#include "wincap.h"
#include "threaded_queue.h"
-#define DEBUG 1
-#define debug_printf if (DEBUG) printf
/* threaded_queue */
@@ -38,7 +36,7 @@ worker_function (LPVOID LpParam)
DWORD rc = WaitForSingleObject (queue->event, INFINITE);
if (rc == WAIT_FAILED)
{
- printf ("Wait for event failed\n");
+ system_printf ("Wait for event failed");
queue->running--;
ExitThread (0);
}
@@ -69,8 +67,8 @@ threaded_queue::create_workers ()
InitializeCriticalSection (&queuelock);
if ((event = CreateEvent (NULL, FALSE, FALSE, NULL)) == NULL)
{
- printf ("Failed to create event queue (%lu), terminating\n",
- GetLastError ());
+ system_printf ("Failed to create event queue (%lu), terminating",
+ GetLastError ());
exit (1);
}
active = true;
@@ -85,8 +83,8 @@ threaded_queue::create_workers ()
hThread = CreateThread (NULL, 0, worker_function, this, 0, &tid);
if (hThread == NULL)
{
- printf ("Failed to create thread (%lu), terminating\n",
- GetLastError ());
+ system_printf ("Failed to create thread (%lu), terminating",
+ GetLastError ());
exit (1);
}
CloseHandle (hThread);
@@ -114,7 +112,7 @@ threaded_queue::cleanup ()
LeaveCriticalSection (&queuelock);
if (!running)
return;
- printf ("Waiting for current queue threads to terminate\n");
+ system_printf ("Waiting for current queue threads to terminate");
for (int n = running; n; n--)
PulseEvent (event);
while (running)
@@ -132,7 +130,7 @@ threaded_queue::add (queue_request * therequest)
EnterCriticalSection (&queuelock);
if (!running)
{
- printf ("No worker threads to handle request!\n");
+ system_printf ("No worker threads to handle request!");
}
if (!request)
request = therequest;
@@ -169,11 +167,11 @@ interruptible
{
if (!interruptible)
return;
- debug_printf ("creating an interruptible processing thread\n");
+ debug_printf ("creating an interruptible processing thread");
if ((interrupt = CreateEvent (NULL, FALSE, FALSE, NULL)) == NULL)
{
- printf ("Failed to create interrupt event (%lu), terminating\n",
- GetLastError ());
+ system_printf ("Failed to create interrupt event (%lu), terminating",
+ GetLastError ());
exit (1);
}
}
@@ -198,7 +196,8 @@ bool
running = true;
return true;
}
- printf ("Failed to create thread (%lu), terminating\n", GetLastError ());
+ system_printf ("Failed to create thread (%lu), terminating",
+ GetLastError ());
return false;
}
@@ -217,7 +216,7 @@ queue_process_param::stop ()
while (n-- && WaitForSingleObject (hThread, 1000) == WAIT_TIMEOUT);
if (!n)
{
- printf ("Process thread didn't shutdown cleanly after 200ms!\n");
+ system_printf ("Process thread didn't shutdown cleanly after 200ms!");
exit (1);
}
else
@@ -225,11 +224,11 @@ queue_process_param::stop ()
}
else
{
- printf ("killing request loop thread %ld\n", tid);
+ system_printf ("killing request loop thread %ld", tid);
int rc;
if (!(rc = TerminateThread (hThread, 0)))
{
- printf ("error shutting down request loop worker thread\n");
+ system_printf ("error shutting down request loop worker thread");
}
running = false;
}
@@ -244,7 +243,7 @@ queue_request::queue_request ():next (NULL)
void
queue_request::process (void)
{
- printf ("\n**********************************************\n"
- "Oh no! we've hit the base queue_request process() function, and this indicates a coding\n"
- "fault !!!\n" "***********************************************\n");
+ system_printf ("**********************************************\n"
+ "Oh no! we've hit the base queue_request process() function, and this indicates a coding\n"
+ "fault !!!" "***********************************************");
}
diff --git a/winsup/cygserver/woutsup.h b/winsup/cygserver/woutsup.h
new file mode 100644
index 000000000..ae62ac63d
--- /dev/null
+++ b/winsup/cygserver/woutsup.h
@@ -0,0 +1,101 @@
+/* woutsup.h: for Cygwin code compiled outside the DLL (i.e. cygserver).
+
+ Copyright 2002 Red Hat, Inc.
+
+ This file is part of Cygwin.
+
+ This software is a copyrighted work licensed under the terms of the
+ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+ details. */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef __INSIDE_CYGWIN__
+#error "woutsup.h is not for code being compiled inside the dll"
+#endif
+
+#define WIN32_LEAN_AND_MEAN 1
+#define _WINGDI_H
+#define _WINUSER_H
+#define _WINNLS_H
+#define _WINVER_H
+#define _WINNETWK_H
+#define _WINSVC_H
+#include <windows.h>
+#include <wincrypt.h>
+#include <lmcons.h>
+#undef _WINGDI_H
+#undef _WINUSER_H
+#undef _WINNLS_H
+#undef _WINVER_H
+#undef _WINNETWK_H
+#undef _WINSVC_H
+
+#include "wincap.h"
+
+/* The one function we use from winuser.h most of the time */
+extern "C" DWORD WINAPI GetLastError (void);
+
+/* From "winsup.h". */
+
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
+#define NEW_MACRO_VARARGS
+#endif
+
+/*
+ * A reproduction of the api_fatal() and <sys/strace.h> macros. This
+ * allows code that runs both inside and outside the Cygwin DLL to use
+ * the same macros for logging messages.
+ */
+
+extern "C" void __cygserver__printf (const char *, const char *, ...);
+
+#ifdef NEW_MACRO_VARARGS
+
+#define system_printf(...) \
+ do \
+ { \
+ __cygserver__printf (__PRETTY_FUNCTION__, __VA_ARGS__); \
+ } while (false);
+
+#define __noop_printf(...) do {;} while (false)
+
+#else /* !NEW_MACRO_VARARGS */
+
+#define system_printf(args...) \
+ do \
+ { \
+ __cygserver__printf (__PRETTY_FUNCTION__, ## args); \
+ } while (false)
+
+#define __noop_printf(args...) do {;} while (false)
+
+#endif /* !NEW_MACRO_VARARGS */
+
+#define api_fatal system_printf
+
+#ifdef DEBUGGING
+#define debug_printf system_printf
+#define paranoid_printf system_printf
+#define select_printf system_printf
+#define sigproc_printf system_printf
+#define syscall_printf system_printf
+#define termios_printf system_printf
+#define wm_printf system_printf
+#define minimal_printf system_printf
+#define malloc_printf system_printf
+#define thread_printf system_printf
+#else
+#define debug_printf __noop_printf
+#define paranoid_printf __noop_printf
+#define select_printf __noop_printf
+#define sigproc_printf __noop_printf
+#define syscall_printf __noop_printf
+#define termios_printf __noop_printf
+#define wm_printf __noop_printf
+#define minimal_printf __noop_printf
+#define malloc_printf __noop_printf
+#define thread_printf __noop_printf
+#endif