* 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.
This commit is contained in:
parent
1fdc8df95d
commit
0a047e8f32
@ -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>
|
Wed Aug 22 17:31:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* net.cc (free_char_list): New static function.
|
* net.cc (free_char_list): New static function.
|
||||||
|
@ -876,7 +876,7 @@ _dll_crt0 ()
|
|||||||
char buf[80];
|
char buf[80];
|
||||||
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf)))
|
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));
|
Sleep (atoi (buf));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -275,15 +275,11 @@ out:
|
|||||||
unlock_debug ();
|
unlock_debug ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close a known handle. Complain if !force and closing a known handle or
|
bool __stdcall
|
||||||
if the name of the handle being closed does not match the registered name. */
|
debug_mark_closed (const char *func, int ln, HANDLE h, const char *name, BOOL force)
|
||||||
BOOL __stdcall
|
|
||||||
close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
|
|
||||||
{
|
{
|
||||||
BOOL ret;
|
|
||||||
handle_list *hl;
|
handle_list *hl;
|
||||||
lock_debug ();
|
lock_debug ();
|
||||||
|
|
||||||
if ((hl = find_handle (h)) && !force)
|
if ((hl = find_handle (h)) && !force)
|
||||||
{
|
{
|
||||||
hl = hl->next;
|
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);
|
hln->func, hln->ln, hln->name, hln->h);
|
||||||
system_printf (" by %s:%d(%s<%p>)", func, ln, name, h);
|
system_printf (" by %s:%d(%s<%p>)", func, ln, name, h);
|
||||||
}
|
}
|
||||||
ret = CloseHandle (h);
|
|
||||||
if (hl)
|
if (hl)
|
||||||
{
|
{
|
||||||
handle_list *hnuke = hl->next;
|
handle_list *hnuke = hl->next;
|
||||||
@ -312,6 +308,23 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
|
|||||||
memset (hnuke, 0, sizeof (*hnuke));
|
memset (hnuke, 0, sizeof (*hnuke));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ();
|
unlock_debug ();
|
||||||
#if 0 /* Uncomment to see CloseHandle failures */
|
#if 0 /* Uncomment to see CloseHandle failures */
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
@ -43,6 +43,8 @@ int __stdcall iscygthread ();
|
|||||||
# define ProtectHandle1(h,n) do {} while (0)
|
# define ProtectHandle1(h,n) do {} while (0)
|
||||||
# define ProtectHandle2(h,n) do {} while (0)
|
# define ProtectHandle2(h,n) do {} while (0)
|
||||||
# define debug_init() 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
|
#else
|
||||||
|
|
||||||
@ -57,6 +59,8 @@ int __stdcall iscygthread ();
|
|||||||
close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, TRUE)
|
close_handle (__PRETTY_FUNCTION__, __LINE__, (h), #n, TRUE)
|
||||||
# define ForceCloseHandle2(h,n) \
|
# define ForceCloseHandle2(h,n) \
|
||||||
close_handle (__PRETTY_FUNCTION__, __LINE__, (h), n, TRUE)
|
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)
|
# define lock_pinfo_for_update(n) lpfu(__PRETTY_FUNCTION__, __LINE__, n)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -70,6 +74,8 @@ BOOL __stdcall close_handle (const char *, int, HANDLE, const char *, BOOL);
|
|||||||
int __stdcall lpfu (const char *, int, DWORD timeout);
|
int __stdcall lpfu (const char *, int, DWORD timeout);
|
||||||
void __stdcall cygbench (const char *s);
|
void __stdcall cygbench (const char *s);
|
||||||
extern int pinger;
|
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 /*DEBUGGING*/
|
||||||
#endif /*_DEBUG_H_*/
|
#endif /*_DEBUG_H_*/
|
||||||
|
@ -232,7 +232,6 @@ dtable::build_fhandler (int fd, const char *name, HANDLE handle)
|
|||||||
{
|
{
|
||||||
int unit;
|
int unit;
|
||||||
DWORD devn;
|
DWORD devn;
|
||||||
extern bool wsock_started;
|
|
||||||
|
|
||||||
if ((devn = get_device_number (name, unit)) == FH_BAD)
|
if ((devn = get_device_number (name, unit)) == FH_BAD)
|
||||||
{
|
{
|
||||||
|
@ -181,7 +181,7 @@ __small_sprintf (char *dst, const char *fmt,...)
|
|||||||
void
|
void
|
||||||
small_printf (const char *fmt,...)
|
small_printf (const char *fmt,...)
|
||||||
{
|
{
|
||||||
char buf[2000];
|
char buf[16384];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
DWORD done;
|
DWORD done;
|
||||||
int count;
|
int count;
|
||||||
@ -199,6 +199,29 @@ small_printf (const char *fmt,...)
|
|||||||
count = __small_vsprintf (buf, fmt, ap);
|
count = __small_vsprintf (buf, fmt, ap);
|
||||||
va_end (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));
|
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
|
||||||
|
@ -131,7 +131,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
|
|||||||
}
|
}
|
||||||
while (*path && *++path);
|
while (*path && *++path);
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
/* Couldn't find anything in the given path.
|
/* Couldn't find anything in the given path.
|
||||||
Take the appropriate action based on null_if_not_found. */
|
Take the appropriate action based on null_if_not_found. */
|
||||||
if (null_if_notfound)
|
if (null_if_notfound)
|
||||||
@ -139,7 +139,7 @@ errout:
|
|||||||
else
|
else
|
||||||
buf.check (name);
|
buf.check (name);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
debug_printf ("%s = find_exec (%s)", (char *) buf, name);
|
debug_printf ("%s = find_exec (%s)", (char *) buf, name);
|
||||||
if (known_suffix)
|
if (known_suffix)
|
||||||
*known_suffix = suffix ?: strchr (buf, '\0');
|
*known_suffix = suffix ?: strchr (buf, '\0');
|
||||||
@ -175,7 +175,7 @@ iscmd (const char *argv0, const char *what)
|
|||||||
|
|
||||||
class linebuf
|
class linebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
size_t ix;
|
size_t ix;
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t alloced;
|
size_t alloced;
|
||||||
@ -223,7 +223,7 @@ class av
|
|||||||
{
|
{
|
||||||
char **argv;
|
char **argv;
|
||||||
int calloced;
|
int calloced;
|
||||||
public:
|
public:
|
||||||
int argc;
|
int argc;
|
||||||
av (int ac, const char * const *av) : calloced (0), argc (ac)
|
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))
|
TRUE, DUPLICATE_SAME_ACCESS))
|
||||||
ciresrv.moreinfo->myself_pinfo = NULL;
|
ciresrv.moreinfo->myself_pinfo = NULL;
|
||||||
|
|
||||||
skip_arg_parsing:
|
skip_arg_parsing:
|
||||||
PROCESS_INFORMATION pi = {NULL, 0, 0, 0};
|
PROCESS_INFORMATION pi = {NULL, 0, 0, 0};
|
||||||
si.lpReserved = NULL;
|
si.lpReserved = NULL;
|
||||||
si.lpDesktop = NULL;
|
si.lpDesktop = NULL;
|
||||||
@ -861,8 +861,7 @@ skip_arg_parsing:
|
|||||||
return (int) res;
|
return (int) res;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
cwait (int *result, int pid, int)
|
cwait (int *result, int pid, int)
|
||||||
{
|
{
|
||||||
return waitpid (pid, result, 0);
|
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
|
* Most of these based on (and copied from) newlib/libc/posix/execXX.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
spawnl (int mode, const char *path, const char *arg0, ...)
|
spawnl (int mode, const char *path, const char *arg0, ...)
|
||||||
{
|
{
|
||||||
int i;
|
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 ());
|
return _spawnve (NULL, mode, path, (char * const *) argv, cur_environ ());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
spawnle (int mode, const char *path, const char *arg0, ...)
|
spawnle (int mode, const char *path, const char *arg0, ...)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -968,8 +965,7 @@ spawnle (int mode, const char *path, const char *arg0, ...)
|
|||||||
(char * const *) envp);
|
(char * const *) envp);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
spawnlp (int mode, const char *path, const char *arg0, ...)
|
spawnlp (int mode, const char *path, const char *arg0, ...)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -989,8 +985,7 @@ spawnlp (int mode, const char *path, const char *arg0, ...)
|
|||||||
return spawnvpe (mode, path, (char * const *) argv, cur_environ ());
|
return spawnvpe (mode, path, (char * const *) argv, cur_environ ());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
spawnlpe (int mode, const char *path, const char *arg0, ...)
|
spawnlpe (int mode, const char *path, const char *arg0, ...)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -1012,30 +1007,26 @@ spawnlpe (int mode, const char *path, const char *arg0, ...)
|
|||||||
return spawnvpe (mode, path, (char * const *) argv, envp);
|
return spawnvpe (mode, path, (char * const *) argv, envp);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
spawnv (int mode, const char *path, const char * const *argv)
|
spawnv (int mode, const char *path, const char * const *argv)
|
||||||
{
|
{
|
||||||
return _spawnve (NULL, mode, path, argv, cur_environ ());
|
return _spawnve (NULL, mode, path, argv, cur_environ ());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
spawnve (int mode, const char *path, char * const *argv,
|
spawnve (int mode, const char *path, char * const *argv,
|
||||||
const char * const *envp)
|
const char * const *envp)
|
||||||
{
|
{
|
||||||
return _spawnve (NULL, mode, path, argv, envp);
|
return _spawnve (NULL, mode, path, argv, envp);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
spawnvp (int mode, const char *path, const char * const *argv)
|
spawnvp (int mode, const char *path, const char * const *argv)
|
||||||
{
|
{
|
||||||
return spawnvpe (mode, path, argv, cur_environ ());
|
return spawnvpe (mode, path, argv, cur_environ ());
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C" int
|
||||||
int
|
|
||||||
spawnvpe (int mode, const char *file, const char * const *argv,
|
spawnvpe (int mode, const char *file, const char * const *argv,
|
||||||
const char * const *envp)
|
const char * const *envp)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,8 @@ details. */
|
|||||||
# define memset __builtin_memset
|
# define memset __builtin_memset
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NO_COPY __attribute__((section(".data_cygwin_nocopy")))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
|
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
|
||||||
@ -97,8 +99,6 @@ extern HANDLE title_mutex;
|
|||||||
|
|
||||||
/**************************** Convenience ******************************/
|
/**************************** Convenience ******************************/
|
||||||
|
|
||||||
#define NO_COPY __attribute__((section(".data_cygwin_nocopy")))
|
|
||||||
|
|
||||||
/* Used when treating / and \ as equivalent. */
|
/* Used when treating / and \ as equivalent. */
|
||||||
#define SLASH_P(ch) \
|
#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__)
|
#define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__)
|
||||||
void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2)));
|
void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2)));
|
||||||
|
|
||||||
|
extern bool wsock_started;
|
||||||
|
|
||||||
/* Printf type functions */
|
/* Printf type functions */
|
||||||
extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
|
extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
|
||||||
extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/;
|
extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user