aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-08-22 17:50:22 +0000
committerChristopher Faylor <me@cgf.cx>2001-08-22 17:50:22 +0000
commit0a047e8f321216f24140ee18135bbe9ea4461f0a (patch)
treee8bc85a9d7a597f57dccb8ec64e0ff8a479c2249 /winsup/cygwin
parent1fdc8df95d7723d278daf4c3ce2f856d8d1db276 (diff)
downloadnewlib-0a047e8f321216f24140ee18135bbe9ea4461f0a.zip
newlib-0a047e8f321216f24140ee18135bbe9ea4461f0a.tar.gz
newlib-0a047e8f321216f24140ee18135bbe9ea4461f0a.tar.bz2
* smallprint.c (console_printf): New function.
* dcrt0.cc (dll_crt0_1): Use console_printf for debugging output. * debug.cc (debug_mark_closed): New function. (close_handle): Use debug_mark_closed. * debug.h: Declare new functions. * dtable.cc (dtable::build_fhandler): Remove unneeded extern. * spawn.cc: Cosmetic changes. * winsup.h: Define NO_COPY for C files, too. Declare a global.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog11
-rw-r--r--winsup/cygwin/dcrt0.cc2
-rw-r--r--winsup/cygwin/debug.cc27
-rw-r--r--winsup/cygwin/debug.h6
-rw-r--r--winsup/cygwin/dtable.cc1
-rw-r--r--winsup/cygwin/smallprint.c27
-rw-r--r--winsup/cygwin/spawn.cc37
-rw-r--r--winsup/cygwin/winsup.h6
8 files changed, 81 insertions, 36 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e2c3f86..ec406ed 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,14 @@
+Wed Aug 22 13:41:09 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * smallprint.c (console_printf): New function.
+ * dcrt0.cc (dll_crt0_1): Use console_printf for debugging output.
+ * debug.cc (debug_mark_closed): New function.
+ (close_handle): Use debug_mark_closed.
+ * debug.h: Declare new functions.
+ * dtable.cc (dtable::build_fhandler): Remove unneeded extern.
+ * spawn.cc: Cosmetic changes.
+ * winsup.h: Define NO_COPY for C files, too. Declare a global.
+
Wed Aug 22 17:31:00 2001 Corinna Vinschen <corinna@vinschen.de>
* net.cc (free_char_list): New static function.
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 3a7417c..bdaa312 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -876,7 +876,7 @@ _dll_crt0 ()
char buf[80];
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf)))
{
- small_printf ("Sleeping %d, pid %u\n", atoi (buf), GetCurrentProcessId ());
+ console_printf ("Sleeping %d, pid %u\n", atoi (buf), GetCurrentProcessId ());
Sleep (atoi (buf));
}
#endif
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index bd58e47..551a12d 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -275,15 +275,11 @@ out:
unlock_debug ();
}
-/* Close a known handle. Complain if !force and closing a known handle or
- if the name of the handle being closed does not match the registered name. */
-BOOL __stdcall
-close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
+bool __stdcall
+debug_mark_closed (const char *func, int ln, HANDLE h, const char *name, BOOL force)
{
- BOOL ret;
handle_list *hl;
lock_debug ();
-
if ((hl = find_handle (h)) && !force)
{
hl = hl->next;
@@ -301,7 +297,7 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
hln->func, hln->ln, hln->name, hln->h);
system_printf (" by %s:%d(%s<%p>)", func, ln, name, h);
}
- ret = CloseHandle (h);
+
if (hl)
{
handle_list *hnuke = hl->next;
@@ -313,6 +309,23 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
}
unlock_debug ();
+ return TRUE;
+}
+
+/* Close a known handle. Complain if !force and closing a known handle or
+ if the name of the handle being closed does not match the registered name. */
+BOOL __stdcall
+close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
+{
+ BOOL ret;
+ lock_debug ();
+
+ if (!debug_mark_closed (func, ln, h, name, force))
+ return FALSE;
+
+ ret = CloseHandle (h);
+
+ unlock_debug ();
#if 0 /* Uncomment to see CloseHandle failures */
if (!ret)
small_printf ("CloseHandle(%s) failed %s:%d\n", name, func, ln);
diff --git a/winsup/cygwin/debug.h b/winsup/cygwin/debug.h
index 9491b60..015627f 100644
--- a/winsup/cygwin/debug.h
+++ b/winsup/cygwin/debug.h
@@ -43,6 +43,8 @@ int __stdcall iscygthread ();
# define ProtectHandle1(h,n) do {} while (0)
# define ProtectHandle2(h,n) do {} while (0)
# define debug_init() do {} while (0)
+# define MarkCLosed(h) do {} while (0)
+# define debug_mark_closed(func, ln, h, name, force) (1)
#else
@@ -57,6 +59,8 @@ int __stdcall iscygthread ();
close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, TRUE)
# define ForceCloseHandle2(h,n) \
close_handle (__PRETTY_FUNCTION__, __LINE__, (h), n, TRUE)
+# define MarkClosed(h) \
+ debug_mark_closed (__PRETTY_FUNCTION__, __LINE__, (h), #h, TRUE)
# define lock_pinfo_for_update(n) lpfu(__PRETTY_FUNCTION__, __LINE__, n)
# endif
@@ -70,6 +74,8 @@ BOOL __stdcall close_handle (const char *, int, HANDLE, const char *, BOOL);
int __stdcall lpfu (const char *, int, DWORD timeout);
void __stdcall cygbench (const char *s);
extern int pinger;
+extern "C" void console_printf (const char *fmt,...);
+bool debug_mark_closed (const char *, int, HANDLE, const char *, BOOL);
#endif /*DEBUGGING*/
#endif /*_DEBUG_H_*/
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index c581169..4583a3f 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -232,7 +232,6 @@ dtable::build_fhandler (int fd, const char *name, HANDLE handle)
{
int unit;
DWORD devn;
- extern bool wsock_started;
if ((devn = get_device_number (name, unit)) == FH_BAD)
{
diff --git a/winsup/cygwin/smallprint.c b/winsup/cygwin/smallprint.c
index 54ae9b0..7e23d1a 100644
--- a/winsup/cygwin/smallprint.c
+++ b/winsup/cygwin/smallprint.c
@@ -181,7 +181,7 @@ __small_sprintf (char *dst, const char *fmt,...)
void
small_printf (const char *fmt,...)
{
- char buf[2000];
+ char buf[16384];
va_list ap;
DWORD done;
int count;
@@ -199,6 +199,29 @@ small_printf (const char *fmt,...)
count = __small_vsprintf (buf, fmt, ap);
va_end (ap);
- WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, count, &done, 0);
+ WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, count, &done, NULL);
FlushFileBuffers (GetStdHandle (STD_ERROR_HANDLE));
}
+
+#ifdef DEBUGGING
+static HANDLE NO_COPY console_handle = NULL;
+void
+console_printf (const char *fmt,...)
+{
+ char buf[16384];
+ va_list ap;
+ DWORD done;
+ int count;
+ extern SECURITY_ATTRIBUTES sec_none;
+
+ if (!console_handle)
+ console_handle = CreateFileA ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE,
+ &sec_none, OPEN_EXISTING, 0, 0);
+ va_start (ap, fmt);
+ count = __small_vsprintf (buf, fmt, ap);
+ va_end (ap);
+
+ WriteFile (console_handle, buf, count, &done, NULL);
+ FlushFileBuffers (console_handle);
+}
+#endif
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 73df3f3..110efa3 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -131,7 +131,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
}
while (*path && *++path);
-errout:
+ errout:
/* Couldn't find anything in the given path.
Take the appropriate action based on null_if_not_found. */
if (null_if_notfound)
@@ -139,7 +139,7 @@ errout:
else
buf.check (name);
-out:
+ out:
debug_printf ("%s = find_exec (%s)", (char *) buf, name);
if (known_suffix)
*known_suffix = suffix ?: strchr (buf, '\0');
@@ -175,7 +175,7 @@ iscmd (const char *argv0, const char *what)
class linebuf
{
-public:
+ public:
size_t ix;
char *buf;
size_t alloced;
@@ -223,7 +223,7 @@ class av
{
char **argv;
int calloced;
-public:
+ public:
int argc;
av (int ac, const char * const *av) : calloced (0), argc (ac)
{
@@ -547,7 +547,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
TRUE, DUPLICATE_SAME_ACCESS))
ciresrv.moreinfo->myself_pinfo = NULL;
-skip_arg_parsing:
+ skip_arg_parsing:
PROCESS_INFORMATION pi = {NULL, 0, 0, 0};
si.lpReserved = NULL;
si.lpDesktop = NULL;
@@ -861,8 +861,7 @@ skip_arg_parsing:
return (int) res;
}
-extern "C"
-int
+extern "C" int
cwait (int *result, int pid, int)
{
return waitpid (pid, result, 0);
@@ -923,8 +922,7 @@ _spawnve (HANDLE hToken, int mode, const char *path, const char *const *argv,
* Most of these based on (and copied from) newlib/libc/posix/execXX.c
*/
-extern "C"
-int
+extern "C" int
spawnl (int mode, const char *path, const char *arg0, ...)
{
int i;
@@ -944,8 +942,7 @@ spawnl (int mode, const char *path, const char *arg0, ...)
return _spawnve (NULL, mode, path, (char * const *) argv, cur_environ ());
}
-extern "C"
-int
+extern "C" int
spawnle (int mode, const char *path, const char *arg0, ...)
{
int i;
@@ -968,8 +965,7 @@ spawnle (int mode, const char *path, const char *arg0, ...)
(char * const *) envp);
}
-extern "C"
-int
+extern "C" int
spawnlp (int mode, const char *path, const char *arg0, ...)
{
int i;
@@ -989,8 +985,7 @@ spawnlp (int mode, const char *path, const char *arg0, ...)
return spawnvpe (mode, path, (char * const *) argv, cur_environ ());
}
-extern "C"
-int
+extern "C" int
spawnlpe (int mode, const char *path, const char *arg0, ...)
{
int i;
@@ -1012,30 +1007,26 @@ spawnlpe (int mode, const char *path, const char *arg0, ...)
return spawnvpe (mode, path, (char * const *) argv, envp);
}
-extern "C"
-int
+extern "C" int
spawnv (int mode, const char *path, const char * const *argv)
{
return _spawnve (NULL, mode, path, argv, cur_environ ());
}
-extern "C"
-int
+extern "C" int
spawnve (int mode, const char *path, char * const *argv,
const char * const *envp)
{
return _spawnve (NULL, mode, path, argv, envp);
}
-extern "C"
-int
+extern "C" int
spawnvp (int mode, const char *path, const char * const *argv)
{
return spawnvpe (mode, path, argv, cur_environ ());
}
-extern "C"
-int
+extern "C" int
spawnvpe (int mode, const char *file, const char * const *argv,
const char * const *envp)
{
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index d0b2548..1b73a2f 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -24,6 +24,8 @@ details. */
# define memset __builtin_memset
#endif
+#define NO_COPY __attribute__((section(".data_cygwin_nocopy")))
+
#ifdef __cplusplus
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
@@ -97,8 +99,6 @@ extern HANDLE title_mutex;
/**************************** Convenience ******************************/
-#define NO_COPY __attribute__((section(".data_cygwin_nocopy")))
-
/* Used when treating / and \ as equivalent. */
#define SLASH_P(ch) \
({ \
@@ -204,6 +204,8 @@ int __stdcall __check_null_invalid_struct_errno (const void *s, unsigned sz) __a
#define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__)
void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2)));
+extern bool wsock_started;
+
/* Printf type functions */
extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/;