diff options
author | Christopher Faylor <me@cgf.cx> | 2001-09-04 20:48:45 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-09-04 20:48:45 +0000 |
commit | c729f22799bcd93a8524619242ce34a2d4fc6edd (patch) | |
tree | fd25a8d024fb1a1cd96a8dbf78fdec32b84976ef /winsup | |
parent | 37f75da24dfd63f71025233f1a139b05f0de0904 (diff) | |
download | newlib-c729f22799bcd93a8524619242ce34a2d4fc6edd.zip newlib-c729f22799bcd93a8524619242ce34a2d4fc6edd.tar.gz newlib-c729f22799bcd93a8524619242ce34a2d4fc6edd.tar.bz2 |
* thread.cc (InterlockedExchangePointer): Don't define if it already exists.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 37 | ||||
-rw-r--r-- | winsup/cygwin/thread.cc | 2 |
3 files changed, 26 insertions, 18 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2140aec..95d999f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +Tue Sep 4 16:48:14 2001 Christopher Faylor <cgf@cygnus.com> + + * thread.cc (InterlockedExchangePointer): Don't define if it already + exists. + Tue Sep 4 22:14:00 2001 Corinna Vinschen <corinna@vinschen.de> * uname.cc (uname): Eliminate os specific retrieving of x86 diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index bde0f37..8e4d40b 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -33,14 +33,14 @@ details. */ #include "cygheap.h" static DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, - STD_ERROR_HANDLE}; + STD_ERROR_HANDLE}; /* Set aside space for the table of fds */ void dtable_init (void) { if (!cygheap->fdtab.size) - cygheap->fdtab.extend(NOFILE_INCR); + cygheap->fdtab.extend (NOFILE_INCR); } void __stdcall @@ -68,7 +68,7 @@ dtable::extend (int howmuch) if (howmuch <= 0) return 0; - /* Try to allocate more space for fd table. We can't call realloc() + /* Try to allocate more space for fd table. We can't call realloc () here to preserve old table if memory allocation fails */ if (!(newfds = (fhandler_base **) ccalloc (HEAP_ARGV, new_size, sizeof newfds[0]))) @@ -100,7 +100,7 @@ stdio_init (void) Also, always set them even if we're to pick up our parent's fds in case they're missed. */ - if (!myself->ppid_handle && NOTSTATE(myself, PID_CYGPARENT)) + if (!myself->ppid_handle && NOTSTATE (myself, PID_CYGPARENT)) { HANDLE in = GetStdHandle (STD_INPUT_HANDLE); HANDLE out = GetStdHandle (STD_OUTPUT_HANDLE); @@ -136,7 +136,7 @@ stdio_init (void) int dtable::find_unused_handle (int start) { - AssertResourceOwner(LOCK_FD_LIST, READ_LOCK); + AssertResourceOwner (LOCK_FD_LIST, READ_LOCK); do { @@ -221,7 +221,7 @@ cygwin_attach_handle_to_fd (char *name, int fd, HANDLE handle, mode_t bin, DWORD myaccess) { if (fd == -1) - fd = cygheap->fdtab.find_unused_handle(); + fd = cygheap->fdtab.find_unused_handle (); fhandler_base *res = cygheap->fdtab.build_fhandler (fd, name, handle); res->init (handle, myaccess, bin); return fd; @@ -384,7 +384,7 @@ dtable::dup2 (int oldfd, int newfd) goto done; } - SetResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup"); + SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); if (newfd < 0) { @@ -408,7 +408,7 @@ dtable::dup2 (int oldfd, int newfd) if ((fds[newfd]->get_device () & FH_DEVMASK) == FH_SOCKET) inc_need_fixup_before (); - ReleaseResourceLock(LOCK_FD_LIST,WRITE_LOCK|READ_LOCK,"dup"); + ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); MALLOC_CHECK; if ((res = newfd) <= 2) @@ -477,15 +477,15 @@ dtable::select_except (int fd, select_record *s) void dtable::fixup_before_fork (DWORD target_proc_id) { - SetResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_fork"); + SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_fork"); fhandler_base *fh; for (size_t i = 0; i < size; i++) if ((fh = fds[i]) != NULL) { - debug_printf ("fd %d(%s)", i, fh->get_name ()); + debug_printf ("fd %d (%s)", i, fh->get_name ()); fh->fixup_before_fork_exec (target_proc_id); } - ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_fork"); + ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_fork"); } void @@ -496,7 +496,7 @@ dtable::fixup_before_exec (DWORD target_proc_id) for (size_t i = 0; i < size; i++) if ((fh = fds[i]) != NULL && !fh->get_close_on_exec ()) { - debug_printf ("fd %d(%s)", i, fh->get_name ()); + debug_printf ("fd %d (%s)", i, fh->get_name ()); fh->fixup_before_fork_exec (target_proc_id); } ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "fixup_before_exec"); @@ -533,7 +533,7 @@ dtable::fixup_after_fork (HANDLE parent) { if (fh->get_close_on_exec () || fh->get_need_fork_fixup ()) { - debug_printf ("fd %d(%s)", i, fh->get_name ()); + debug_printf ("fd %d (%s)", i, fh->get_name ()); fh->fixup_after_fork (parent); } } @@ -543,10 +543,10 @@ int dtable::vfork_child_dup () { fhandler_base **newtable; - newtable = (fhandler_base **) ccalloc (HEAP_ARGV, size, sizeof(fds[0])); + SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); + newtable = (fhandler_base **) ccalloc (HEAP_ARGV, size, sizeof (fds[0])); int res = 1; - SetResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); for (size_t i = 0; i < size; i++) if (not_open (i)) continue; @@ -561,15 +561,16 @@ dtable::vfork_child_dup () fds_on_hold = fds; fds = newtable; + out: - ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); + ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "dup"); return 1; } void dtable::vfork_parent_restore () { - SetResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "restore"); + SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "restore"); close_all_files (); fhandler_base **deleteme = fds; @@ -577,7 +578,7 @@ dtable::vfork_parent_restore () fds_on_hold = NULL; cfree (deleteme); - ReleaseResourceLock(LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "restore"); + ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "restore"); return; } diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index be7505f..543d727 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -1150,7 +1150,9 @@ __pthread_atforkchild (void) /*FIXME: implement InterlockExchangePointer and get rid of the silly typecasts below */ +#ifndef InterlockedExchangePointer #define InterlockedExchangePointer InterlockedExchange +#endif /*Register a set of functions to run before and after fork. *prepare calls are called in LI-FC order. |