4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-21 16:26:12 +08:00

* mmap.cc: Clean up *ResourceLock calls throughout.

* thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well as
WAIT_ABANDONED.
(__pthread_cond_timedwait): Calculate a relative wait from the abstime
parameter.
This commit is contained in:
Christopher Faylor 2001-06-26 14:47:48 +00:00
parent d006404dae
commit 462f4effb1
15 changed files with 473 additions and 449 deletions

View File

@ -1,3 +1,14 @@
Tue Jun 26 10:47:24 2001 Christopher Faylor <cgf@cygnus.com>
* mmap.cc: Clean up *ResourceLock calls throughout.
Tue Jun 26 22:10:00 2001 Robert Collins rbtcollins@hotmail.com
* thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well
as WAIT_ABANDONED.
(__pthread_cond_timedwait): Calculate a relative wait from the abstime
parameter.
Sun Jun 24 17:38:19 2001 Christopher Faylor <cgf@cygnus.com>
* exceptions.cc (interrupt_setup): Move actions from setup_handler to

View File

@ -68,7 +68,6 @@ public:
return 1;
return strncasematch (m->native_path, path, m->native_pathlen)
&& (path[m->native_pathlen] == '\\' || !path[m->native_pathlen]);
}
const char *unchroot (const char *path)
{

View File

@ -28,6 +28,13 @@
* malloc_usable_size(P) is equivalent to realloc(P, malloc_usable_size(P))
*
* $Log$
* Revision 1.3 2001/06/26 14:47:48 cgf
* * mmap.cc: Clean up *ResourceLock calls throughout.
* * thread.cc (pthread_cond::TimedWait): Check for WAIT_TIMEOUT as well as
* WAIT_ABANDONED.
* (__pthread_cond_timedwait): Calculate a relative wait from the abstime
* parameter.
*
* Revision 1.2 2001/06/24 22:26:49 cgf
* forced commit
*

View File

@ -974,7 +974,6 @@ private:
int audiobits_;
int audiochannels_;
bool setupwav(const char *pData, int nBytes);
public:
fhandler_dev_dsp (const char *name = 0);
~fhandler_dev_dsp();

View File

@ -428,7 +428,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
if ((flags & MAP_PRIVATE) && (os_being_run == winNT || (prot & ~PROT_READ)))
access = FILE_MAP_COPY;
SetResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
SetResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
#if 0
/* Windows 95 does not have fixed addresses */
@ -452,7 +452,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
{
set_errno (ENOMEM);
syscall_printf ("-1 = mmap(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED;
}
}
@ -475,7 +475,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
{
set_errno (EBADF);
syscall_printf ("-1 = mmap(): EBADF");
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED;
}
fh = cygheap->fdtab[fd];
@ -509,7 +509,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
off = rec->map_map (off, len);
caddr_t ret = rec->get_address () + off;
syscall_printf ("%x = mmap() succeeded", ret);
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return ret;
}
}
@ -518,7 +518,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
if (h == INVALID_HANDLE_VALUE)
{
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED;
}
@ -541,7 +541,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
fh->munmap (h, base, gran_len);
set_errno (ENOMEM);
syscall_printf ("-1 = mmap(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED;
}
l = mmapped_areas->add_list (l, fd);
@ -552,7 +552,7 @@ mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t off)
off = rec->map_map (off, len);
caddr_t ret = rec->get_address () + off;
syscall_printf ("%x = mmap() succeeded", ret);
ReleaseResourceLock(LOCK_MMAP_LIST,READ_LOCK|WRITE_LOCK," mmap");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return ret;
}
@ -573,13 +573,13 @@ munmap (caddr_t addr, size_t len)
return -1;
}
SetResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
SetResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
/* Check if a mmap'ed area was ever created */
if (mmapped_areas == NULL)
{
syscall_printf ("-1 = munmap(): mmapped_areas == NULL");
set_errno (EINVAL);
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
return -1;
}
@ -605,7 +605,7 @@ munmap (caddr_t addr, size_t len)
l->erase (li);
}
syscall_printf ("0 = munmap(): %x", addr);
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
return 0;
}
}
@ -614,7 +614,7 @@ munmap (caddr_t addr, size_t len)
set_errno (EINVAL);
syscall_printf ("-1 = munmap(): EINVAL");
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," munmap");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
return -1;
}
@ -636,13 +636,13 @@ msync (caddr_t addr, size_t len, int flags)
return -1;
}
SetResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
SetResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
/* Check if a mmap'ed area was ever created */
if (mmapped_areas == NULL)
{
syscall_printf ("-1 = msync(): mmapped_areas == NULL");
set_errno (EINVAL);
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
return -1;
}
@ -668,7 +668,7 @@ msync (caddr_t addr, size_t len, int flags)
else
syscall_printf ("0 = msync()");
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
return 0;
}
}
@ -679,7 +679,7 @@ msync (caddr_t addr, size_t len, int flags)
set_errno (ENOMEM);
syscall_printf ("-1 = msync(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST,WRITE_LOCK|READ_LOCK," msync");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
return -1;
}

View File

@ -27,7 +27,6 @@
/* for getpid */
#include <unistd.h>
/* Win32 priority to UNIX priority Mapping.
For now, I'm just following the spec: any range of priorities is ok.
There are probably many many issues with this...

View File

@ -44,6 +44,7 @@ details. */
#include "security.h"
#include <semaphore.h>
#include <stdio.h>
#include <sys/timeb.h>
extern int threadsafe;
@ -472,6 +473,7 @@ pthread_cond::TimedWait (DWORD dwMilliseconds)
case WAIT_FAILED:
return 0; /* POSIX doesn't allow errors after we modify the mutex state */
case WAIT_ABANDONED:
case WAIT_TIMEOUT:
return ETIMEDOUT;
case WAIT_OBJECT_0:
return 0; /* we have been signaled */
@ -1654,7 +1656,14 @@ __pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
return EINVAL;
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))
return EINVAL;
struct timeb currSysTime;
long waitlength;
ftime(&currSysTime);
waitlength = (abstime->tv_sec - currSysTime.time) * 1000;
if (waitlength < 0)
return ETIMEDOUT;
/* if the cond variable is blocked, then the above timer test maybe wrong. *shrug* */
if (pthread_mutex_lock (&(*cond)->cond_access))
system_printf ("Failed to lock condition variable access mutex, this %0p\n", *cond);
@ -1671,7 +1680,7 @@ __pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
InterlockedIncrement (&((*themutex)->condwaits));
if (pthread_mutex_unlock (&(*cond)->cond_access))
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
rv = (*cond)->TimedWait (abstime->tv_sec * 1000);
rv = (*cond)->TimedWait (waitlength);
(*cond)->mutex->Lock ();
if (pthread_mutex_lock (&(*cond)->cond_access))
system_printf ("Failed to lock condition variable access mutex, this %0p\n", *cond);