* external.cc (cygwin_internal): Change CW_STRACE_ON to CW_STRACE_TOGGLE.
* strace.cc (strace::hello): Toggle strace on and off.
* sync.cc (muto::init): Renamed from constructor.
* sync.h (muto::new): Delete.
(muto::delete): Ditto.
(new_muto): Simplify. Use muto.init for nearly everything.
* uinfo.cc (uinfo_init): Avoid closing a NULL handle.
* include/sys/cygwin.h (cygwin_getinfo_types): Rename CW_STRACE_OFF to
CW_STRACE_TOGGLE. Delete CW_STRACE_OFF.
* include/sys/strace.h (strace): Add "inited" field.
+2002-02-14 Christopher Faylor <cgf@redhat.com>
+
+ * exceptions.cc (unused_sig_wrapper): Eliminate unused parameter to
+ asm.
+ * external.cc (cygwin_internal): Change CW_STRACE_ON to
+ CW_STRACE_TOGGLE.
+ * strace.cc (strace::hello): Toggle strace on and off.
+ * sync.cc (muto::init): Renamed from constructor.
+ * sync.h (muto::new): Delete.
+ (muto::delete): Ditto.
+ (new_muto): Simplify. Use muto.init for nearly everything.
+ * uinfo.cc (uinfo_init): Avoid closing a NULL handle.
+ * include/sys/cygwin.h (cygwin_getinfo_types): Rename CW_STRACE_OFF to
+ CW_STRACE_TOGGLE. Delete CW_STRACE_OFF.
+ * include/sys/strace.h (strace): Add "inited" field.
+
2001-02-12 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/acl.h: Fix definition of aclent_t.
pushl %%ecx \n\
pushl %%ebx \n\
pushl %%eax \n\
- pushl %7 # saved errno \n\
+ pushl %6 # saved errno \n\
pushl %3 # oldmask \n\
pushl %4 # signal argument \n\
pushl $_sigreturn \n\
\n\
call _reset_signal_arrived@0 \n\
pushl %5 # signal number \n\
- pushl %8 # newmask \n\
+ pushl %7 # newmask \n\
movl $0,%0 # zero the signal number as a \n\
# flag to the signal handler thread\n\
# that it is ok to set up sigsave\n\
__no_sig_end: \n\
" : "=m" (sigsave.sig) : "m" (&_impure_ptr->_errno),
"g" (sigsave.retaddr), "g" (sigsave.oldmask), "g" (sigsave.sig),
- "g" (sigsave.func), "o" (pid_offset), "g" (sigsave.saved_errno), "g" (sigsave.newmask)
+ "g" (sigsave.func), "g" (sigsave.saved_errno), "g" (sigsave.newmask)
);
}
}
# undef cr
}
- case CW_STRACE_ON:
+ case CW_STRACE_TOGGLE:
{
pid_t pid = va_arg (arg, pid_t);
pinfo p (pid);
return (DWORD) -1;
}
}
+
case CW_CYGWIN_PID_TO_WINPID:
{
pinfo p (va_arg (arg, pid_t));
strncpy (group_name, "Administrators", sizeof (group_name));
- static NO_COPY group_lock here;
+ static NO_COPY group_lock here = group_lock();
if (cygwin_finished_initializing)
here.arm ();
CW_GET_CYGDRIVE_INFO,
CW_SET_CYGWIN_REGISTRY_NAME,
CW_GET_CYGWIN_REGISTRY_NAME,
- CW_STRACE_ON,
- CW_STRACE_OFF,
+ CW_STRACE_TOGGLE,
CW_CYGWIN_PID_TO_WINPID
} cygwin_getinfo_types;
int active;
int lmicrosec;
int execing;
+ int inited;
strace() : version(1) {}
void hello ();
void prntf (unsigned, const char *func, const char *, ...) /*__attribute__ ((regparm(3)))*/;
n = -1;
}
else if (!n || !guard_mutex)
- /* no guard mutex or nothing to read fromt he pipe. */;
+ /* no guard mutex or nothing to read from the pipe. */;
else if (WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
{
select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
/* just forcing the loop */
break;
- /* Internal signal to force a flush of strace data to disk. */
+ /* Internal signal to turn on stracing. */
case __SIGSTRACE:
strace.hello ();
break;
strace::hello()
{
char buf[30];
+
+ if (inited)
+ {
+ active ^= 1;
+ return;
+ }
+
__small_sprintf (buf, "cYg%8x %x", _STRACE_INTERFACE_ACTIVATE_ADDR, &active);
OutputDebugString (buf);
#undef WaitForSingleObject
/* Constructor */
-muto::muto (int inh, const char *s) : sync (0), visits(0), waiters(-1), tid (0), next (NULL)
+muto *
+muto::init (int inh, const char *s)
{
+ waiters = -1;
/* Create event which is used in the fallback case when blocking is necessary */
- if (!(bruteforce = CreateEvent (inh ? &sec_all_nih : &sec_none_nih, FALSE, FALSE, name)))
+ if (!(bruteforce = CreateEvent (inh ? &sec_all_nih : &sec_none_nih, FALSE, FALSE, NULL)))
{
DWORD oerr = GetLastError ();
SetLastError (oerr);
- return;
+ return NULL;
}
name = s;
+ next = muto_start.next;
+ muto_start.next = this;
+ return this;
}
+#if 0 /* FIXME: Do we need this? mutos aren't destroyed until process exit */
/* Destructor (racy?) */
muto::~muto ()
{
if (h)
CloseHandle (h);
}
+#endif
/* Acquire the lock. Argument is the number of milliseconds to wait for
the lock. Multiple visits from the same thread are allowed and should
class muto *next;
const char *name;
- muto() {}
/* The real constructor. */
- muto(int inh, const char *name);
+ muto *init(int inh, const char *name) __attribute__ ((regparm (3)));
- void *operator new (size_t, void *p) {return p;}
- void *operator new (size_t) {return ::new muto; }
- void operator delete (void *) {;} /* can't handle allocated mutos
- currently */
-
- ~muto ();
- int acquire (DWORD ms = INFINITE) __attribute__ ((regparm(1))); /* Acquire the lock. */
+#if 0 /* FIXME: See comment in sync.cc */
+ ~muto ()
+#endif
+ int acquire (DWORD ms = INFINITE) __attribute__ ((regparm (1))); /* Acquire the lock. */
int release (); /* Release the lock. */
/* Return true if caller thread owns the lock. */
/* Use a statically allocated buffer as the storage for a muto */
#define new_muto(__inh, __name) \
({ \
- static volatile __attribute__((section(".data_cygwin_nocopy"))) muto __mbuf; \
- (void) new ((void *) &__mbuf) muto (__inh, __name); \
- __mbuf.next = muto_start.next; \
- muto_start.next = (muto *) &__mbuf; \
- (muto *) &__mbuf; \
+ static muto __mbuf __attribute__((section(".data_cygwin_nocopy"))); \
+ __mbuf.init (__inh, __name); \
})
Setting `impersonated' to TRUE seems to be wrong but it
isn't. Impersonated is thought as "Current User and `token'
are coincident". See seteuid() for the mechanism behind that. */
- if (cygheap->user.token != INVALID_HANDLE_VALUE)
+ if (cygheap->user.token != INVALID_HANDLE_VALUE && cygheap->user.token != NULL)
CloseHandle (cygheap->user.token);
cygheap->user.token = INVALID_HANDLE_VALUE;
cygheap->user.impersonated = TRUE;