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:
authorChristopher Faylor <me@cgf.cx>2001-05-05 01:02:15 +0400
committerChristopher Faylor <me@cgf.cx>2001-05-05 01:02:15 +0400
commit63b61cd19ff1ae741a8c3403c1c3fa12bea1c893 (patch)
treec6ca5e70cf2fce1f7793c55d141a732fc0e2d15f
parent17743fbc49ebb23300e0a36d8c5a27ed63e2bf41 (diff)
Revert much of previous erroneous checkin. Add ChangeLog entry.
* pinfo.h: Correctly set __SIGOFFSET. * path.cc (hash_path_name): Avoid calling library functions for simple copying of characters. * shortcut.c: Use WIN32_LEAN_AND_MEAN. * smallprint.c: Ditto. * environ.cc (getwinenv): Minor clarity fix. * localtime.c: No need to include windows.h * string.h: New file.
-rw-r--r--winsup/cygwin/ChangeLog16
-rw-r--r--winsup/cygwin/autoload.cc6
-rw-r--r--winsup/cygwin/debug.cc4
-rw-r--r--winsup/cygwin/exceptions.cc6
-rw-r--r--winsup/cygwin/net.cc6
-rw-r--r--winsup/cygwin/pinfo.h2
-rw-r--r--winsup/cygwin/shortcut.c3
-rw-r--r--winsup/cygwin/sigproc.cc12
-rw-r--r--winsup/cygwin/string.h44
-rw-r--r--winsup/cygwin/sync.cc14
-rw-r--r--winsup/cygwin/thread.cc34
-rw-r--r--winsup/cygwin/winsup.h3
12 files changed, 103 insertions, 47 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 3031f4926..e495e2163 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,19 @@
+Fri May 4 16:49:34 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * pinfo.h: Correctly set __SIGOFFSET.
+
+ * path.cc (hash_path_name): Avoid calling library functions for simple
+ copying of characters.
+
+ * shortcut.c: Use WIN32_LEAN_AND_MEAN.
+ * smallprint.c: Ditto.
+
+ * environ.cc (getwinenv): Minor clarity fix.
+
+ * localtime.c: No need to include windows.h
+
+ * string.h: New file.
+
Fri May 4 16:37:30 2001 Christopher Faylor <cgf@cygnus.com>
* exceptions.cc (ctrl_c_handler): Always send signal to process if it
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 995563ac9..633d91a51 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -70,9 +70,9 @@ std_dll_init (HANDLE &dll_handle, const char *dll_name, LONG &here)
{
HANDLE h;
- while (ilockincr (&here))
+ while (InterlockedIncrement (&here))
{
- ilockdecr (&here);
+ InterlockedDecrement (&here);
Sleep (0);
}
@@ -83,7 +83,7 @@ std_dll_init (HANDLE &dll_handle, const char *dll_name, LONG &here)
else
api_fatal ("could not load %s, %E", dll_name);
- ilockdecr (&here);
+ InterlockedDecrement (&here);
return 0;
}
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index 4ddc8b841..bd58e47b4 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -87,7 +87,7 @@ thread_stub (VOID *arg)
exception_list except_entry;
/* Give up our slot in the start_buf array */
- (void) ilockexch (&((thread_start *) arg)->notavail, 0);
+ (void) InterlockedExchange (&((thread_start *) arg)->notavail, 0);
/* Initialize this thread's ability to respond to things like
SIGSEGV or SIGFPE. */
@@ -112,7 +112,7 @@ makethread (LPTHREAD_START_ROUTINE start, LPVOID param, DWORD flags,
{
/* Search the start_buf array for an empty slot to use */
for (info = start_buf; info < start_buf + NTHREADS; info++)
- if (!ilockexch (&info->notavail, 1))
+ if (!InterlockedExchange (&info->notavail, 1))
goto out;
/* Should never hit here, but be defensive anyway. */
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 9f37b00da..422f349d3 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -632,11 +632,11 @@ bool
sigthread::get_winapi_lock (int test)
{
if (test)
- return !ilockexch (&winapi_lock, 1);
+ return !InterlockedExchange (&winapi_lock, 1);
/* Need to do a busy loop because we can't block or a potential SuspendThread
will hang. */
- while (ilockexch (&winapi_lock, 1))
+ while (InterlockedExchange (&winapi_lock, 1))
Sleep (1);
return 1;
}
@@ -645,7 +645,7 @@ void
sigthread::release_winapi_lock ()
{
/* Assumes that we have the lock. */
- ilockexch (&winapi_lock, 0);
+ InterlockedExchange (&winapi_lock, 0);
}
static void __stdcall interrupt_setup (int sig, void *handler, DWORD retaddr,
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 235ea7e91..56848877b 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -1931,9 +1931,9 @@ wsock_init ()
static LONG NO_COPY here = -1L;
static int NO_COPY wsock_started = 0;
- while (ilockincr (&here))
+ while (InterlockedIncrement (&here))
{
- ilockdecr (&here);
+ InterlockedDecrement (&here);
Sleep (0);
}
if (!wsock_started && (wsock32_handle || ws2_32_handle))
@@ -1960,6 +1960,6 @@ wsock_init ()
wsock_started = 1;
}
}
- ilockdecr (&here);
+ InterlockedDecrement (&here);
}
diff --git a/winsup/cygwin/pinfo.h b/winsup/cygwin/pinfo.h
index 6e54845f7..89ed5468c 100644
--- a/winsup/cygwin/pinfo.h
+++ b/winsup/cygwin/pinfo.h
@@ -15,7 +15,7 @@ enum
__SIGFLUSH = -2,
__SIGSTRACE = -1,
__SIGUNUSED = 0,
- __SIGOFFSET = 2
+ __SIGOFFSET = 3
};
#define PSIZE 63
diff --git a/winsup/cygwin/shortcut.c b/winsup/cygwin/shortcut.c
index 2f7c1e18a..b47cec52a 100644
--- a/winsup/cygwin/shortcut.c
+++ b/winsup/cygwin/shortcut.c
@@ -10,9 +10,8 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
-#define WIN32_LEAN_AND_MEAN
-#include <shlobj.h>
#include "winsup.h"
+#include <shlobj.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/mount.h>
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 0d2c4f7a8..a44e31611 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -473,7 +473,7 @@ proc_terminate (void)
void __stdcall
sig_clear (int sig)
{
- (void) ilockexch (myself->getsigtodo (sig), 0L);
+ (void) InterlockedExchange (myself->getsigtodo (sig), 0L);
return;
}
@@ -696,7 +696,7 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
/* Increment the sigtodo array to signify which signal to assert.
*/
- (void) ilockincr (p->getsigtodo (sig));
+ (void) InterlockedIncrement (p->getsigtodo (sig));
/* Notify the process that a signal has arrived.
*/
@@ -783,7 +783,7 @@ out:
void __stdcall
sig_set_pending (int sig)
{
- (void) ilockincr (myself->getsigtodo (sig));
+ (void) InterlockedIncrement (myself->getsigtodo (sig));
return;
}
@@ -1137,7 +1137,7 @@ wait_sig (VOID *)
int dispatched_sigchld = 0;
for (int sig = -__SIGOFFSET; sig < NSIG; sig++)
{
- while (ilockdecr (myself->getsigtodo (sig)) >= 0)
+ while (InterlockedDecrement (myself->getsigtodo (sig)) >= 0)
{
if (sig == SIGCHLD)
saw_sigchld = 1;
@@ -1171,14 +1171,14 @@ wait_sig (VOID *)
dispatched_sigchld = 1;
/* Need to decrement again to offset increment below since
we really do want to decrement in this case. */
- ilockdecr (myself->getsigtodo (sig));
+ InterlockedDecrement (myself->getsigtodo (sig));
goto nextsig; /* FIXME: shouldn't this allow the loop to continue? */
}
}
nextsig:
/* Decremented too far. */
- if (ilockincr (myself->getsigtodo (sig)) > 0)
+ if (InterlockedIncrement (myself->getsigtodo (sig)) > 0)
saw_pending_signals = 1;
}
diff --git a/winsup/cygwin/string.h b/winsup/cygwin/string.h
new file mode 100644
index 000000000..20bf6fdba
--- /dev/null
+++ b/winsup/cygwin/string.h
@@ -0,0 +1,44 @@
+/* string.h: Extra string defs
+
+ Copyright 2001 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. */
+
+#ifndef _CYGWIN_STRING_H
+#define _CYGWIN_STRING_H
+
+#include_next <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#undef strchr
+#define strchr cygwin_strchr
+extern inline __stdcall char *
+strchr (const char *s, int c)
+{
+ register char * res;
+ __asm__ __volatile__ ("
+ movb %%al,%%ah\n\
+ 1: movb (%1),%%al\n\
+ cmpb %%ah,%%al\n\
+ je 2f\n\
+ incl %1\n\
+ testb %%al,%%al\n\
+ jne 1b\n\
+ xorl %1,%1\n\
+ 2: movl %1,%0\n\
+ ":"=a" (__res), "=r" (s)
+ :"0" (c), "1" (s));
+ return res;
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _CYGWIN_STRING_H */
diff --git a/winsup/cygwin/sync.cc b/winsup/cygwin/sync.cc
index 85162f417..5aa798e69 100644
--- a/winsup/cygwin/sync.cc
+++ b/winsup/cygwin/sync.cc
@@ -58,7 +58,7 @@ muto::~muto ()
be handled correctly.
Note: The goal here is to minimize, as much as possible, calls to the
- OS. Hence the use of ilockincr, etc., rather than (much) more
+ OS. Hence the use of InterlockedIncrement, etc., rather than (much) more
expensive OS mutexes. */
int
muto::acquire (DWORD ms)
@@ -69,7 +69,7 @@ muto::acquire (DWORD ms)
{
/* Increment the waiters part of the class. Need to do this first to
avoid potential races. */
- LONG was_waiting = ilockincr (&waiters);
+ LONG was_waiting = InterlockedIncrement (&waiters);
/* This is deceptively simple. Basically, it allows multiple attempts to
lock the same muto to succeed without attempting to manipulate sync.
@@ -82,7 +82,7 @@ muto::acquire (DWORD ms)
case, it is possible for a thread which is going to wait for bruteforce
to wake up immediately. It will then attempt to grab sync but will fail
and go back to waiting. */
- while (tid != this_tid && (was_waiting || ilockexch (&sync, 1) != 0))
+ while (tid != this_tid && (was_waiting || InterlockedExchange (&sync, 1) != 0))
{
switch (WaitForSingleObject (bruteforce, ms))
{
@@ -90,7 +90,7 @@ muto::acquire (DWORD ms)
goto gotit;
break;
default:
- ilockdecr (&waiters);
+ InterlockedDecrement (&waiters);
return 0; /* failed. */
}
}
@@ -117,11 +117,11 @@ muto::release ()
if (!--visits)
{
tid = 0; /* We were the last unlocker. */
- (void) ilockexch (&sync, 0); /* Reset trigger. */
+ (void) InterlockedExchange (&sync, 0); /* Reset trigger. */
/* This thread had incremented waiters but had never decremented it.
Decrement it now. If it is >= 0 then there are possibly other
threads waiting for the lock, so trigger bruteforce. */
- if (ilockdecr (&waiters) >= 0)
+ if (InterlockedDecrement (&waiters) >= 0)
(void) SetEvent (bruteforce); /* Wake up one of the waiting threads */
}
@@ -133,7 +133,7 @@ void
muto::reset ()
{
visits = sync = tid = 0;
- ilockexch (&waiters, -1);
+ InterlockedExchange (&waiters, -1);
if (bruteforce)
{
CloseHandle (bruteforce);
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index a040b4b28..deedcae42 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -412,7 +412,7 @@ pthread_cond::BroadCast ()
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
return;
PulseEvent (win32_obj_id);
- while (ilockdecr (&waiting) != 0)
+ while (InterlockedDecrement (&waiting) != 0)
PulseEvent (win32_obj_id);
mutex = NULL;
}
@@ -798,7 +798,7 @@ __pthread_create (pthread_t * thread, const pthread_attr_t * attr,
*thread = NULL;
return EAGAIN;
}
- ilockincr (&MT_INTERFACE->threadcount);
+ InterlockedIncrement (&MT_INTERFACE->threadcount);
return 0;
}
@@ -1073,7 +1073,7 @@ __pthread_testcancel (void)
/*
* Races in pthread_atfork:
* We are race safe in that any additions to the lists are made via
- * ilockexch.
+ * InterlockedExchangePointer.
* However, if the user application doesn't perform syncronisation of some sort
* It's not guaranteed that a near simultaneous call to pthread_atfork and fork
* will result in the new atfork handlers being calls.
@@ -1084,7 +1084,7 @@ __pthread_testcancel (void)
* will result in an indeterminate order for parent and child calls (what gets inserted
* first isn't guaranteed.)
*
- * There is one potential race... Does the result of ilockexch
+ * There is one potential race... Does the result of InterlockedExchangePointer
* get committed to the return location _before_ any context switches can occur?
* If yes, we're safe, if no, we're not.
*/
@@ -1123,7 +1123,7 @@ __pthread_atforkchild (void)
/* FIXME: implement InterlockExchangePointer and get rid of the silly typecasts below
*/
-/*#define ilockexch ilockExchange */
+#define InterlockedExchangePointer InterlockedExchange
/* Register a set of functions to run before and after fork.
* prepare calls are called in LI-FC order.
@@ -1165,7 +1165,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
if (prepcb)
{
prepcb->cb = prepare;
- prepcb->next=(callback *)ilockexch ((LONG *) &MT_INTERFACE->pthread_prepare, (long int) prepcb);
+ prepcb->next=(callback *)InterlockedExchangePointer ((LONG *) &MT_INTERFACE->pthread_prepare, (long int) prepcb);
}
if (parentcb)
{
@@ -1174,7 +1174,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
while (*t)
t = &(*t)->next;
/* t = pointer to last next in the list */
- parentcb->next=(callback *)ilockexch ((LONG *) t, (long int) parentcb);
+ parentcb->next=(callback *)InterlockedExchangePointer ((LONG *) t, (long int) parentcb);
}
if (childcb)
{
@@ -1183,7 +1183,7 @@ __pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(voi
while (*t)
t = &(*t)->next;
/* t = pointer to last next in the list */
- childcb->next=(callback *)ilockexch ((LONG *) t, (long int) childcb);
+ childcb->next=(callback *)InterlockedExchangePointer ((LONG *) t, (long int) childcb);
}
return 0;
}
@@ -1351,7 +1351,7 @@ __pthread_exit (void *value_ptr)
MT_INTERFACE->destructors.IterateNull ();
thread->return_ptr = value_ptr;
- if (ilockdecr (&MT_INTERFACE->threadcount) == 0)
+ if (InterlockedDecrement (&MT_INTERFACE->threadcount) == 0)
exit (0);
else
ExitThread (0);
@@ -1626,15 +1626,15 @@ __pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
if ((*cond)->waiting)
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
return EINVAL;
- ilockincr (&((*cond)->waiting));
+ InterlockedIncrement (&((*cond)->waiting));
(*cond)->mutex = (*themutex);
- ilockincr (&((*themutex)->condwaits));
+ InterlockedIncrement (&((*themutex)->condwaits));
rv = (*cond)->TimedWait (abstime->tv_sec * 1000);
(*cond)->mutex->Lock ();
- if (ilockdecr (&((*cond)->waiting)) == 0)
+ if (InterlockedDecrement (&((*cond)->waiting)) == 0)
(*cond)->mutex = NULL;
- ilockdecr (&((*themutex)->condwaits));
+ InterlockedDecrement (&((*themutex)->condwaits));
return rv;
}
@@ -1657,15 +1657,15 @@ __pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex)
if ((*cond)->waiting)
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
return EINVAL;
- ilockincr (&((*cond)->waiting));
+ InterlockedIncrement (&((*cond)->waiting));
(*cond)->mutex = (*themutex);
- ilockincr (&((*themutex)->condwaits));
+ InterlockedIncrement (&((*themutex)->condwaits));
rv = (*cond)->TimedWait (INFINITE);
(*cond)->mutex->Lock ();
- if (ilockdecr (&((*cond)->waiting)) == 0)
+ if (InterlockedDecrement (&((*cond)->waiting)) == 0)
(*cond)->mutex = NULL;
- ilockdecr (&((*themutex)->condwaits));
+ InterlockedDecrement (&((*themutex)->condwaits));
return rv;
}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 0cb6665af..8eb8519f8 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -14,8 +14,6 @@ details. */
#define __INSIDE_CYGWIN__
-#include "interlock.h"
-
#define alloca __builtin_alloca
#define strlen __builtin_strlen
#define strcmp __builtin_strcmp
@@ -35,7 +33,6 @@ details. */
#include <sys/types.h>
#include <sys/strace.h>
-
extern char case_folded_lower[];
#define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)])
extern char case_folded_upper[];