* 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
*
@ -3662,9 +3669,9 @@ static void malloc_update_mallinfo(void)
check_free_chunk(p);
check_freefill(p, chunksize(p), chunksize(p));
for (q = next_chunk(p);
q < top && inuse(q) && chunksize(q) >= MINSIZE;
q = next_chunk(q))
check_inuse_chunk(q);
q < top && inuse(q) && chunksize(q) >= MINSIZE;
q = next_chunk(q))
check_inuse_chunk(q);
#endif
avail += chunksize(p);
navail++;
@ -3701,14 +3708,14 @@ void malloc_stats(void)
{
malloc_update_mallinfo();
fprintf(stderr, "max system bytes = %10u\n",
(unsigned int)(max_total_mem));
(unsigned int)(max_total_mem));
fprintf(stderr, "system bytes = %10u\n",
(unsigned int)(sbrked_mem + mmapped_mem));
(unsigned int)(sbrked_mem + mmapped_mem));
fprintf(stderr, "in use bytes = %10u\n",
(unsigned int)(current_mallinfo.uordblks + mmapped_mem));
(unsigned int)(current_mallinfo.uordblks + mmapped_mem));
#if HAVE_MMAP
fprintf(stderr, "max mmap regions = %10u\n",
(unsigned int)max_n_mmaps);
(unsigned int)max_n_mmaps);
#endif
}
@ -3779,13 +3786,13 @@ History:
* Added anonymously donated WIN32 sbrk emulation
* Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen
* malloc_extend_top: fix mask error that caused wastage after
foreign sbrks
foreign sbrks
* Add linux mremap support code from HJ Liu
V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee)
* Integrated most documentation with the code.
* Add support for mmap, with help from
Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
* Use last_remainder in more cases.
* Pack bins using idea from colin@nyx10.cs.du.edu
* Use ordered bins instead of best-fit threshhold
@ -3793,34 +3800,34 @@ History:
* Support another case of realloc via move into top
* Fix error occuring when initial sbrk_base not word-aligned.
* Rely on page size for units instead of SBRK_UNIT to
avoid surprises about sbrk alignment conventions.
avoid surprises about sbrk alignment conventions.
* Add mallinfo, mallopt. Thanks to Raymond Nijssen
(raymond@es.ele.tue.nl) for the suggestion.
(raymond@es.ele.tue.nl) for the suggestion.
* Add `pad' argument to malloc_trim and top_pad mallopt parameter.
* More precautions for cases where other routines call sbrk,
courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
* Added macros etc., allowing use in linux libc from
H.J. Lu (hjl@gnu.ai.mit.edu)
H.J. Lu (hjl@gnu.ai.mit.edu)
* Inverted this history list
V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee)
* Re-tuned and fixed to behave more nicely with V2.6.0 changes.
* Removed all preallocation code since under current scheme
the work required to undo bad preallocations exceeds
the work saved in good cases for most test programs.
the work required to undo bad preallocations exceeds
the work saved in good cases for most test programs.
* No longer use return list or unconsolidated bins since
no scheme using them consistently outperforms those that don't
given above changes.
no scheme using them consistently outperforms those that don't
given above changes.
* Use best fit for very large chunks to prevent some worst-cases.
* Added some support for debugging
V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee)
* Removed footers when chunks are in use. Thanks to
Paul Wilson (wilson@cs.texas.edu) for the suggestion.
Paul Wilson (wilson@cs.texas.edu) for the suggestion.
V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee)
* Added malloc_trim, with help from Wolfram Gloger
(wmglo@Dent.MED.Uni-Muenchen.DE).
(wmglo@Dent.MED.Uni-Muenchen.DE).
V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g)
@ -3836,11 +3843,11 @@ History:
V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g)
* faster bin computation & slightly different binning
* merged all consolidations to one part of malloc proper
(eliminating old malloc_find_space & malloc_clean_bin)
(eliminating old malloc_find_space & malloc_clean_bin)
* Scan 2 returns chunks (not just 1)
* Propagate failure in realloc if malloc returns 0
* Add stuff to allow compilation on non-ANSI compilers
from kpv@research.att.com
from kpv@research.att.com
V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu)
* removed potential for odd address access in prev_chunk
@ -3848,11 +3855,11 @@ History:
* misc cosmetics and a bit more internal documentation
* anticosmetics: mangled names in macros to evade debugger strangeness
* tested on sparc, hp-700, dec-mips, rs6000
with gcc & native cc (hp, dec only) allowing
Detlefs & Zorn comparison study (in SIGPLAN Notices.)
with gcc & native cc (hp, dec only) allowing
Detlefs & Zorn comparison study (in SIGPLAN Notices.)
Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu)
* Based loosely on libg++-1.2X malloc. (It retains some of the overall
structure of old version, but most details differ.)
structure of old version, but most details differ.)
*/

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

@ -55,7 +55,7 @@ public:
~wsock_event ()
{
if (event)
WSACloseEvent (event);
WSACloseEvent (event);
event = NULL;
};
@ -100,9 +100,9 @@ wsock_event::wait (int socket, LPDWORD flags)
{
debug_printf ("CancelIo() %E, fallback to blocking io");
WSAGetOverlappedResult(socket, &ovr, &len, TRUE, flags);
}
}
else
WSASetLastError (WSAEINTR);
WSASetLastError (WSAEINTR);
break;
case WSA_WAIT_FAILED:
break;
@ -470,7 +470,7 @@ static int get_inet_addr (const struct sockaddr *in, int inlen,
char buf[128];
memset (buf, 0, sizeof buf);
if (read (fd, buf, sizeof buf) != -1)
{
{
sockaddr_in sin;
sin.sin_family = AF_INET;
sscanf (buf + strlen (SOCKET_COOKIE), "%hu %08x-%08x-%08x-%08x",
@ -481,7 +481,7 @@ static int get_inet_addr (const struct sockaddr *in, int inlen,
*out = sin;
*outlen = sizeof sin;
ret = 1;
}
}
_close (fd);
return ret;
}
@ -526,15 +526,15 @@ cygwin_sendto (int fd,
WSABUF wsabuf = { len, (char *) buf };
DWORD ret = 0;
if (WSASendTo (h->get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
to, tolen, ovr, NULL) != SOCKET_ERROR)
res = ret;
to, tolen, ovr, NULL) != SOCKET_ERROR)
res = ret;
else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
{
set_winsock_errno ();
res = -1;
}
{
set_winsock_errno ();
res = -1;
}
else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
set_winsock_errno ();
set_winsock_errno ();
}
syscall_printf ("%d = sendto (%d, %x, %x, %x)", res, fd, buf, len, flags);
@ -561,7 +561,7 @@ cygwin_recvfrom (int fd,
{
debug_printf ("Fallback to winsock 1 recvfrom call");
if ((res = recvfrom (h->get_socket (), buf, len, flags, from, fromlen))
== SOCKET_ERROR)
== SOCKET_ERROR)
{
set_winsock_errno ();
res = -1;
@ -572,15 +572,15 @@ cygwin_recvfrom (int fd,
WSABUF wsabuf = { len, (char *) buf };
DWORD ret = 0;
if (WSARecvFrom (h->get_socket (), &wsabuf, 1, &ret, (DWORD *)&flags,
from, fromlen, ovr, NULL) != SOCKET_ERROR)
res = ret;
from, fromlen, ovr, NULL) != SOCKET_ERROR)
res = ret;
else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
{
set_winsock_errno ();
res = -1;
}
{
set_winsock_errno ();
res = -1;
}
else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
set_winsock_errno ();
set_winsock_errno ();
}
syscall_printf ("%d = recvfrom (%d, %x, %x, %x)", res, fd, buf, len, flags);
@ -756,7 +756,7 @@ cygwin_connect (int fd,
{
res = connect (sock->get_socket (), (sockaddr *) &sin, namelen);
if (res)
{
{
/* Special handling for connect to return the correct error code
when called to early on a non-blocking socket. */
if (WSAGetLastError () == WSAEWOULDBLOCK)
@ -766,37 +766,37 @@ cygwin_connect (int fd,
}
set_winsock_errno ();
}
}
if (sock->get_addr_family () == AF_UNIX)
{
if (!res || in_progress)
{
if (!sock->create_secret_event (secret))
{
{
if (!res || in_progress)
{
if (!sock->create_secret_event (secret))
{
secret_check_failed = TRUE;
}
else if (in_progress)
sock->signal_secret_event ();
}
}
if (!secret_check_failed && !res)
{
if (!secret_check_failed && !res)
{
if (!sock->check_peer_secret_event (&sin, secret))
{
debug_printf ( "accept from unauthorized server" );
secret_check_failed = TRUE;
}
}
}
if (secret_check_failed)
{
if (secret_check_failed)
{
sock->close_secret_event ();
if (res)
closesocket (res);
if (res)
closesocket (res);
set_errno (ECONNREFUSED);
res = -1;
}
}
}
}
}
return res;
}
@ -913,7 +913,7 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
in_progress = TRUE;
if (sock->get_addr_family () == AF_UNIX)
{
{
if ((SOCKET) res != (SOCKET) INVALID_SOCKET || in_progress)
{
if (!sock->create_secret_event ())
@ -923,25 +923,25 @@ cygwin_accept (int fd, struct sockaddr *peer, int *len)
}
if (!secret_check_failed &&
(SOCKET) res != (SOCKET) INVALID_SOCKET)
{
(SOCKET) res != (SOCKET) INVALID_SOCKET)
{
if (!sock->check_peer_secret_event ((struct sockaddr_in*) peer))
{
debug_printf ("connect from unauthorized client");
secret_check_failed = TRUE;
}
}
}
}
if (secret_check_failed)
{
sock->close_secret_event ();
if ((SOCKET) res != (SOCKET) INVALID_SOCKET)
closesocket (res);
if (secret_check_failed)
{
sock->close_secret_event ();
if ((SOCKET) res != (SOCKET) INVALID_SOCKET)
closesocket (res);
set_errno (ECONNABORTED);
res = -1;
goto done;
}
}
res = -1;
goto done;
}
}
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK|READ_LOCK, "accept");
@ -1020,11 +1020,11 @@ cygwin_bind (int fd, const struct sockaddr *my_addr, int addrlen)
goto out;
}
sock->set_connect_secret ();
sock->set_connect_secret ();
char buf[sizeof (SOCKET_COOKIE) + 80];
__small_sprintf (buf, "%s%u ", SOCKET_COOKIE, sin.sin_port);
sock->get_connect_secret (strchr (buf, '\0'));
sock->get_connect_secret (strchr (buf, '\0'));
len = strlen (buf) + 1;
/* Note that the terminating nul is written. */
@ -1158,14 +1158,14 @@ cygwin_herror (const char *s)
switch (h_errno)
{
case NETDB_INTERNAL:
h_errstr = "Resolver internal error";
break;
h_errstr = "Resolver internal error";
break;
case NETDB_SUCCESS:
h_errstr = "Resolver error 0 (no error)";
break;
h_errstr = "Resolver error 0 (no error)";
break;
default:
h_errstr = "Unknown resolver error";
break;
h_errstr = "Unknown resolver error";
break;
}
write (2, h_errstr, strlen (h_errstr));
write (2, "\n", 1);
@ -1200,7 +1200,7 @@ cygwin_recv (int fd, void *buf, int len, unsigned int flags)
{
debug_printf ("Fallback to winsock 1 recv call");
if ((res = recv (h->get_socket (), (char *) buf, len, flags))
== SOCKET_ERROR)
== SOCKET_ERROR)
{
set_winsock_errno ();
res = -1;
@ -1252,15 +1252,15 @@ cygwin_send (int fd, const void *buf, int len, unsigned int flags)
WSABUF wsabuf = { len, (char *) buf };
DWORD ret = 0;
if (WSASend (h->get_socket (), &wsabuf, 1, &ret, (DWORD)flags,
ovr, NULL) != SOCKET_ERROR)
res = ret;
ovr, NULL) != SOCKET_ERROR)
res = ret;
else if ((res = WSAGetLastError ()) != WSA_IO_PENDING)
{
set_winsock_errno ();
res = -1;
}
{
set_winsock_errno ();
res = -1;
}
else if ((res = wsock_evt.wait (h->get_socket (), (DWORD *)&flags)) == -1)
set_winsock_errno ();
set_winsock_errno ();
}
syscall_printf ("%d = send (%d, %x, %d, %x)", res, fd, buf, len, flags);
@ -1327,7 +1327,7 @@ get_2k_ifconf (struct ifconf *ifc, int what)
!GetIpAddrTable(ipt, &siz_ip_table, TRUE))
{
for (if_cnt = 0; if_cnt < ift->dwNumEntries; ++if_cnt)
{
{
switch (ift->table[if_cnt].dwType)
{
case MIB_IF_TYPE_ETHERNET:
@ -1351,44 +1351,44 @@ get_2k_ifconf (struct ifconf *ifc, int what)
default:
continue;
}
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
if (ipt->table[ip_cnt].dwIndex == ift->table[if_cnt].dwIndex)
for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
if (ipt->table[ip_cnt].dwIndex == ift->table[if_cnt].dwIndex)
{
switch (what)
{
case SIOCGIFCONF:
case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr;
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
switch (what)
{
case SIOCGIFCONF:
case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr;
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFBRDADDR:
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
break;
case SIOCGIFBRDADDR:
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
#if 0
/* Unfortunately, the field returns only crap. */
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
#else
lip = ipt->table[ip_cnt].dwAddr;
lnp = ipt->table[ip_cnt].dwMask;
sa->sin_addr.s_addr = lip & lnp | ~lnp;
lip = ipt->table[ip_cnt].dwAddr;
lnp = ipt->table[ip_cnt].dwMask;
sa->sin_addr.s_addr = lip & lnp | ~lnp;
sa->sin_family = AF_INET;
sa->sin_port = 0;
#endif
break;
case SIOCGIFNETMASK:
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
break;
case SIOCGIFNETMASK:
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
sa->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
break;
case SIOCGIFHWADDR:
so = &ifr->ifr_hwaddr;
so = &ifr->ifr_hwaddr;
for (UINT i = 0; i < IFHWADDRLEN; ++i)
if (i >= ift->table[if_cnt].dwPhysAddrLen)
so->sa_data[i] = '\0';
so->sa_data[i] = '\0';
else
so->sa_data[i] = ift->table[if_cnt].bPhysAddr[i];
so->sa_data[i] = ift->table[if_cnt].bPhysAddr[i];
so->sa_family = AF_INET;
break;
case SIOCGIFMETRIC:
@ -1397,13 +1397,13 @@ get_2k_ifconf (struct ifconf *ifc, int what)
case SIOCGIFMTU:
ifr->ifr_mtu = ift->table[if_cnt].dwMtu;
break;
}
++cnt;
if ((caddr_t) ++ifr >
}
++cnt;
if ((caddr_t) ++ifr >
ifc->ifc_buf + ifc->ifc_len - sizeof (struct ifreq))
goto done;
break;
}
break;
}
}
}
done:
@ -1438,26 +1438,26 @@ get_nt_ifconf (struct ifconf *ifc, int what)
struct ifreq *ifr = ifc->ifc_req;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE,
"SYSTEM\\"
"CurrentControlSet\\"
"Services\\"
"Tcpip\\"
"Linkage",
0, KEY_READ, &key) == ERROR_SUCCESS)
"SYSTEM\\"
"CurrentControlSet\\"
"Services\\"
"Tcpip\\"
"Linkage",
0, KEY_READ, &key) == ERROR_SUCCESS)
{
if (RegQueryValueEx (key, "Bind",
NULL, NULL,
NULL, &size) == ERROR_SUCCESS)
{
binding = (char *) alloca (size);
if (RegQueryValueEx (key, "Bind",
NULL, NULL,
(unsigned char *) binding,
&size) != ERROR_SUCCESS)
{
binding = NULL;
}
}
NULL, NULL,
NULL, &size) == ERROR_SUCCESS)
{
binding = (char *) alloca (size);
if (RegQueryValueEx (key, "Bind",
NULL, NULL,
(unsigned char *) binding,
&size) != ERROR_SUCCESS)
{
binding = NULL;
}
}
RegCloseKey (key);
}
@ -1467,141 +1467,141 @@ get_nt_ifconf (struct ifconf *ifc, int what)
char cardkey[256], ipaddress[256], netmask[256];
for (bp = binding; *bp; bp += strlen (bp) + 1)
{
bp += strlen ("\\Device\\");
strcpy (cardkey, "SYSTEM\\CurrentControlSet\\Services\\");
strcat (cardkey, bp);
strcat (cardkey, "\\Parameters\\Tcpip");
{
bp += strlen ("\\Device\\");
strcpy (cardkey, "SYSTEM\\CurrentControlSet\\Services\\");
strcat (cardkey, bp);
strcat (cardkey, "\\Parameters\\Tcpip");
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, cardkey,
0, KEY_READ, &key) != ERROR_SUCCESS)
continue;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, cardkey,
0, KEY_READ, &key) != ERROR_SUCCESS)
continue;
if (RegQueryValueEx (key, "IPAddress",
NULL, NULL,
(unsigned char *) ipaddress,
(size = 256, &size)) == ERROR_SUCCESS
&& RegQueryValueEx (key, "SubnetMask",
NULL, NULL,
(unsigned char *) netmask,
(size = 256, &size)) == ERROR_SUCCESS)
{
char *ip, *np;
char dhcpaddress[256], dhcpnetmask[256];
if (RegQueryValueEx (key, "IPAddress",
NULL, NULL,
(unsigned char *) ipaddress,
(size = 256, &size)) == ERROR_SUCCESS
&& RegQueryValueEx (key, "SubnetMask",
NULL, NULL,
(unsigned char *) netmask,
(size = 256, &size)) == ERROR_SUCCESS)
{
char *ip, *np;
char dhcpaddress[256], dhcpnetmask[256];
for (ip = ipaddress, np = netmask;
*ip && *np;
ip += strlen (ip) + 1, np += strlen (np) + 1)
{
if ((caddr_t) ++ifr > ifc->ifc_buf
+ ifc->ifc_len
- sizeof (struct ifreq))
break;
for (ip = ipaddress, np = netmask;
*ip && *np;
ip += strlen (ip) + 1, np += strlen (np) + 1)
{
if ((caddr_t) ++ifr > ifc->ifc_buf
+ ifc->ifc_len
- sizeof (struct ifreq))
break;
if (! strncmp (bp, "NdisWan", 7))
{
strcpy (ifr->ifr_name, "ppp");
strcat (ifr->ifr_name, bp + 7);
}
else
{
++*eth;
strcpy (ifr->ifr_name, "eth");
strcat (ifr->ifr_name, eth);
}
memset (&ifr->ifr_addr, '\0', sizeof ifr->ifr_addr);
if (cygwin_inet_addr (ip) == 0L
&& RegQueryValueEx (key, "DhcpIPAddress",
NULL, NULL,
(unsigned char *) dhcpaddress,
(size = 256, &size))
== ERROR_SUCCESS
&& RegQueryValueEx (key, "DhcpSubnetMask",
NULL, NULL,
(unsigned char *) dhcpnetmask,
(size = 256, &size))
== ERROR_SUCCESS)
{
switch (what)
{
case SIOCGIFCONF:
case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr;
sa->sin_addr.s_addr = cygwin_inet_addr (dhcpaddress);
if (! strncmp (bp, "NdisWan", 7))
{
strcpy (ifr->ifr_name, "ppp");
strcat (ifr->ifr_name, bp + 7);
}
else
{
++*eth;
strcpy (ifr->ifr_name, "eth");
strcat (ifr->ifr_name, eth);
}
memset (&ifr->ifr_addr, '\0', sizeof ifr->ifr_addr);
if (cygwin_inet_addr (ip) == 0L
&& RegQueryValueEx (key, "DhcpIPAddress",
NULL, NULL,
(unsigned char *) dhcpaddress,
(size = 256, &size))
== ERROR_SUCCESS
&& RegQueryValueEx (key, "DhcpSubnetMask",
NULL, NULL,
(unsigned char *) dhcpnetmask,
(size = 256, &size))
== ERROR_SUCCESS)
{
switch (what)
{
case SIOCGIFCONF:
case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr;
sa->sin_addr.s_addr = cygwin_inet_addr (dhcpaddress);
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFBRDADDR:
lip = cygwin_inet_addr (dhcpaddress);
lnp = cygwin_inet_addr (dhcpnetmask);
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
sa->sin_addr.s_addr = lip & lnp | ~lnp;
break;
case SIOCGIFBRDADDR:
lip = cygwin_inet_addr (dhcpaddress);
lnp = cygwin_inet_addr (dhcpnetmask);
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
sa->sin_addr.s_addr = lip & lnp | ~lnp;
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFNETMASK:
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
sa->sin_addr.s_addr =
cygwin_inet_addr (dhcpnetmask);
break;
case SIOCGIFNETMASK:
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
sa->sin_addr.s_addr =
cygwin_inet_addr (dhcpnetmask);
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFHWADDR:
break;
case SIOCGIFHWADDR:
so = &ifr->ifr_hwaddr;
memset (so->sa_data, 0, IFHWADDRLEN);
so->sa_family = AF_INET;
break;
case SIOCGIFMETRIC:
case SIOCGIFMETRIC:
ifr->ifr_metric = 1;
break;
case SIOCGIFMTU:
ifr->ifr_mtu = 1500;
break;
}
}
else
{
switch (what)
{
case SIOCGIFCONF:
case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr;
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
}
}
else
{
switch (what)
{
case SIOCGIFCONF:
case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr;
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFBRDADDR:
lip = cygwin_inet_addr (ip);
lnp = cygwin_inet_addr (np);
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
sa->sin_addr.s_addr = lip & lnp | ~lnp;
break;
case SIOCGIFBRDADDR:
lip = cygwin_inet_addr (ip);
lnp = cygwin_inet_addr (np);
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
sa->sin_addr.s_addr = lip & lnp | ~lnp;
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFNETMASK:
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
sa->sin_addr.s_addr = cygwin_inet_addr (np);
break;
case SIOCGIFNETMASK:
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
sa->sin_addr.s_addr = cygwin_inet_addr (np);
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFHWADDR:
break;
case SIOCGIFHWADDR:
so = &ifr->ifr_hwaddr;
memset (so->sa_data, 0, IFHWADDRLEN);
so->sa_family = AF_INET;
break;
case SIOCGIFMETRIC:
case SIOCGIFMETRIC:
ifr->ifr_metric = 1;
break;
case SIOCGIFMTU:
ifr->ifr_mtu = 1500;
break;
}
}
++cnt;
}
}
RegCloseKey (key);
}
}
}
++cnt;
}
}
RegCloseKey (key);
}
}
/* Set the correct length */
@ -1644,7 +1644,7 @@ get_95_ifconf (struct ifconf *ifc, int what)
struct ifreq *ifr = ifc->ifc_req;
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Enum\\Network\\MSTCP",
0, KEY_READ, &key) != ERROR_SUCCESS)
0, KEY_READ, &key) != ERROR_SUCCESS)
{
/* Set the correct length */
ifc->ifc_len = cnt * sizeof (struct ifreq);
@ -1653,8 +1653,8 @@ get_95_ifconf (struct ifconf *ifc, int what)
for (int i = 0;
(res = RegEnumKeyEx (key, i, ifname,
(size = sizeof ifname, &size),
0, 0, 0, &update)) != ERROR_NO_MORE_ITEMS;
(size = sizeof ifname, &size),
0, 0, 0, &update)) != ERROR_NO_MORE_ITEMS;
++i)
{
HKEY ifkey, subkey;
@ -1662,62 +1662,62 @@ get_95_ifconf (struct ifconf *ifc, int what)
char adapter[256], ip[256], np[256];
if (res != ERROR_SUCCESS
|| RegOpenKeyEx (key, ifname, 0,
KEY_READ, &ifkey) != ERROR_SUCCESS)
continue;
|| RegOpenKeyEx (key, ifname, 0,
KEY_READ, &ifkey) != ERROR_SUCCESS)
continue;
if (RegQueryValueEx (ifkey, "Driver", 0,
NULL, (unsigned char *) driver,
(size = sizeof driver, &size)) != ERROR_SUCCESS)
{
RegCloseKey (ifkey);
continue;
}
NULL, (unsigned char *) driver,
(size = sizeof driver, &size)) != ERROR_SUCCESS)
{
RegCloseKey (ifkey);
continue;
}
strcpy (classname, "System\\CurrentControlSet\\Services\\Class\\");
strcat (classname, driver);
if ((res = RegOpenKeyEx (HKEY_LOCAL_MACHINE, classname,
0, KEY_READ, &subkey)) != ERROR_SUCCESS)
{
RegCloseKey (ifkey);
continue;
}
0, KEY_READ, &subkey)) != ERROR_SUCCESS)
{
RegCloseKey (ifkey);
continue;
}
if (RegQueryValueEx (subkey, "IPAddress", 0,
NULL, (unsigned char *) ip,
(size = sizeof ip, &size)) == ERROR_SUCCESS
&& RegQueryValueEx (subkey, "IPMask", 0,
NULL, (unsigned char *) np,
(size = sizeof np, &size)) == ERROR_SUCCESS)
{
if ((caddr_t)++ifr > ifc->ifc_buf
+ ifc->ifc_len
- sizeof (struct ifreq))
goto out;
NULL, (unsigned char *) ip,
(size = sizeof ip, &size)) == ERROR_SUCCESS
&& RegQueryValueEx (subkey, "IPMask", 0,
NULL, (unsigned char *) np,
(size = sizeof np, &size)) == ERROR_SUCCESS)
{
if ((caddr_t)++ifr > ifc->ifc_buf
+ ifc->ifc_len
- sizeof (struct ifreq))
goto out;
switch (what)
{
case SIOCGIFCONF:
case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr;
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
switch (what)
{
case SIOCGIFCONF:
case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr;
sa->sin_addr.s_addr = cygwin_inet_addr (ip);
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFBRDADDR:
lip = cygwin_inet_addr (ip);
lnp = cygwin_inet_addr (np);
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
sa->sin_addr.s_addr = lip & lnp | ~lnp;
break;
case SIOCGIFBRDADDR:
lip = cygwin_inet_addr (ip);
lnp = cygwin_inet_addr (np);
sa = (struct sockaddr_in *) &ifr->ifr_broadaddr;
sa->sin_addr.s_addr = lip & lnp | ~lnp;
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
case SIOCGIFNETMASK:
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
sa->sin_addr.s_addr = cygwin_inet_addr (np);
break;
case SIOCGIFNETMASK:
sa = (struct sockaddr_in *) &ifr->ifr_netmask;
sa->sin_addr.s_addr = cygwin_inet_addr (np);
sa->sin_family = AF_INET;
sa->sin_port = 0;
break;
break;
case SIOCGIFHWADDR:
so = &ifr->ifr_hwaddr;
memset (so->sa_data, 0, IFHWADDRLEN);
@ -1729,61 +1729,61 @@ get_95_ifconf (struct ifconf *ifc, int what)
case SIOCGIFMTU:
ifr->ifr_mtu = 1500;
break;
}
}
}
}
RegCloseKey (subkey);
if (RegOpenKeyEx (ifkey, "Bindings",
0, KEY_READ, &subkey) != ERROR_SUCCESS)
{
RegCloseKey (ifkey);
--ifr;
continue;
}
0, KEY_READ, &subkey) != ERROR_SUCCESS)
{
RegCloseKey (ifkey);
--ifr;
continue;
}
for (int j = 0;
(res = RegEnumValue (subkey, j, bindname,
(size = sizeof bindname, &size),
0, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS;
++j)
if (!strncasecmp (bindname, "VREDIR\\", 7))
break;
(res = RegEnumValue (subkey, j, bindname,
(size = sizeof bindname, &size),
0, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS;
++j)
if (!strncasecmp (bindname, "VREDIR\\", 7))
break;
RegCloseKey (subkey);
if (res == ERROR_SUCCESS)
{
strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
strcat (netname, bindname + 7);
{
strcpy (netname, "System\\CurrentControlSet\\Services\\Class\\Net\\");
strcat (netname, bindname + 7);
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
0, KEY_READ, &subkey) != ERROR_SUCCESS)
{
RegCloseKey (ifkey);
--ifr;
continue;
}
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, netname,
0, KEY_READ, &subkey) != ERROR_SUCCESS)
{
RegCloseKey (ifkey);
--ifr;
continue;
}
if (RegQueryValueEx (subkey, "AdapterName", 0,
NULL, (unsigned char *) adapter,
(size = sizeof adapter, &size)) == ERROR_SUCCESS
&& strcasematch (adapter, "MS$PPP"))
{
++*ppp;
strcpy (ifr->ifr_name, "ppp");
strcat (ifr->ifr_name, ppp);
}
else
{
++*eth;
strcpy (ifr->ifr_name, "eth");
strcat (ifr->ifr_name, eth);
}
if (RegQueryValueEx (subkey, "AdapterName", 0,
NULL, (unsigned char *) adapter,
(size = sizeof adapter, &size)) == ERROR_SUCCESS
&& strcasematch (adapter, "MS$PPP"))
{
++*ppp;
strcpy (ifr->ifr_name, "ppp");
strcat (ifr->ifr_name, ppp);
}
else
{
++*eth;
strcpy (ifr->ifr_name, "eth");
strcat (ifr->ifr_name, eth);
}
RegCloseKey (subkey);
RegCloseKey (subkey);
}
}
RegCloseKey (ifkey);
@ -1863,14 +1863,14 @@ get_ifconf (struct ifconf *ifc, int what)
/* We have a win95 version... */
if (os_version_info.dwPlatformId != VER_PLATFORM_WIN32_NT
&& (os_version_info.dwMajorVersion < 4
|| (os_version_info.dwMajorVersion == 4
&& os_version_info.dwMinorVersion == 0)))
|| (os_version_info.dwMajorVersion == 4
&& os_version_info.dwMinorVersion == 0)))
get_95_ifconf (ifc, what);
/* ...and a NT <= SP3 version... */
else if (os_version_info.dwPlatformId == VER_PLATFORM_WIN32_NT
&& (os_version_info.dwMajorVersion < 4
&& (os_version_info.dwMajorVersion < 4
|| (os_version_info.dwMajorVersion == 4
&& strcmp (os_version_info.szCSDVersion, "Service Pack 4") < 0)))
&& strcmp (os_version_info.szCSDVersion, "Service Pack 4") < 0)))
get_nt_ifconf (ifc, what);
/* ...and finally a "modern" version for win98/ME, NT >= SP4 and W2K! */
else

View File

@ -133,8 +133,8 @@ read_etc_passwd ()
/* if we got blocked by the mutex, then etc_passwd may have been processed */
if (passwd_state != uninitialized)
{
pthread_mutex_unlock(&etc_passwd_mutex);
return;
pthread_mutex_unlock(&etc_passwd_mutex);
return;
}
if (passwd_state != initializing)
@ -232,7 +232,7 @@ getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct
/* check needed buffer size. */
size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) +
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
strlen (temppw->pw_passwd) + 5;
if (needsize > bufsize)
return ERANGE;
@ -290,7 +290,7 @@ getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, s
/* check needed buffer size. */
size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) +
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
strlen (temppw->pw_passwd) + 5;
if (needsize > bufsize)
return ERANGE;

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

@ -710,7 +710,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
else
{
/* Switching user context to SYSTEM doesn't inherit the authentication
id of the user account running current process. */
id of the user account running current process. */
if (usersid != well_known_system_sid)
if (!GetTokenInformation (my_token, TokenStatistics,
&stats, sizeof stats, &size))
@ -719,9 +719,9 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
auth_luid = stats.AuthenticationId;
/* Retrieving current processes group list to be able to inherit
some important well known group sids. */
some important well known group sids. */
if (!GetTokenInformation (my_token, TokenGroups, NULL, 0, &size) &&
GetLastError () != ERROR_INSUFFICIENT_BUFFER)
GetLastError () != ERROR_INSUFFICIENT_BUFFER)
debug_printf ("GetTokenInformation(my_token, TokenGroups): %E\n");
else if (!(my_grps = (PTOKEN_GROUPS) malloc (size)))
debug_printf ("malloc (my_grps) failed.");
@ -751,10 +751,10 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
{
grps->Groups[i].Sid = grpsids.sids[i];
grps->Groups[i].Attributes = SE_GROUP_MANDATORY |
SE_GROUP_ENABLED_BY_DEFAULT |
SE_GROUP_ENABLED;
SE_GROUP_ENABLED_BY_DEFAULT |
SE_GROUP_ENABLED;
if (auth_pos >= 0 && i == (DWORD) auth_pos)
grps->Groups[i].Attributes |= SE_GROUP_LOGON_ID;
grps->Groups[i].Attributes |= SE_GROUP_LOGON_ID;
}
/* Retrieve list of privileges of that user. */
@ -780,7 +780,7 @@ create_token (cygsid &usersid, cygsid &pgrpsid)
/* Convert to primary token. */
if (!DuplicateTokenEx (token, TOKEN_ALL_ACCESS, &sa,
SecurityImpersonation, TokenPrimary,
SecurityImpersonation, TokenPrimary,
&primary_token))
__seterrno ();
@ -879,7 +879,7 @@ subauth (struct passwd *pw)
subbuf.auth.ParameterControl = 0 | (subauth_id << 24);
/* Try to logon... */
ret = LsaLogonUser(lsa_hdl, (PLSA_STRING) &origin, Network,
package_id, &subbuf, sizeof subbuf,
package_id, &subbuf, sizeof subbuf,
NULL, &ts, (PVOID *)&profile, &size,
&luid, &user_token, &quota, &ret2);
if (ret != STATUS_SUCCESS)
@ -892,7 +892,7 @@ subauth (struct passwd *pw)
LsaFreeReturnBuffer(profile);
/* Convert to primary token. */
if (!DuplicateTokenEx (user_token, TOKEN_ALL_ACCESS, &sa,
SecurityImpersonation, TokenPrimary,
SecurityImpersonation, TokenPrimary,
&primary_token))
__seterrno ();
@ -943,7 +943,7 @@ read_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, LPDWORD sd_size)
}
if (!GetFileSecurity (pfile,
OWNER_SECURITY_INFORMATION
OWNER_SECURITY_INFORMATION
| GROUP_SECURITY_INFORMATION
| DACL_SECURITY_INFORMATION,
sd_buf, *sd_size, &len))

View File

@ -44,6 +44,7 @@ details. */
#include "security.h"
#include <semaphore.h>
#include <stdio.h>
#include <sys/timeb.h>
extern int threadsafe;
@ -423,7 +424,7 @@ pthread_cond::BroadCast ()
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
{
if (pthread_mutex_unlock (&cond_access))
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
/* This isn't and API error - users are allowed to call this when no threads
are waiting
system_printf ("Broadcast called with invalid mutex\n");
@ -444,8 +445,8 @@ pthread_cond::Signal ()
if (!verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC))
{
if (pthread_mutex_unlock (&cond_access))
system_printf ("Failed to unlock condition variable access mutex, this %0p\n",
this);
system_printf ("Failed to unlock condition variable access mutex, this %0p\n",
this);
return;
}
PulseEvent (win32_obj_id);
@ -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 */
@ -580,23 +582,23 @@ pthread_mutex::pthread_mutex (pthread_mutex_t *mutex, pthread_mutexattr * attr):
char stringbuf[29];
unsigned short id = 1;
while (id < 256)
{
snprintf (stringbuf, 29, "CYGWINMUTEX0x%0x", id & 0x000f);
system_printf ("name of mutex to create %s\n",stringbuf);
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, stringbuf);
if (this->win32_obj_id && GetLastError () != ERROR_ALREADY_EXISTS)
{
MT_INTERFACE->pshared_mutexs[id] = this;
{
snprintf (stringbuf, 29, "CYGWINMUTEX0x%0x", id & 0x000f);
system_printf ("name of mutex to create %s\n",stringbuf);
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, stringbuf);
if (this->win32_obj_id && GetLastError () != ERROR_ALREADY_EXISTS)
{
MT_INTERFACE->pshared_mutexs[id] = this;
pshared_mutex *pmutex=(pshared_mutex *)(mutex);
pmutex->id = id;
pmutex->flags = SYS_BASE;
pmutex->flags = SYS_BASE;
pshared = PTHREAD_PROCESS_SHARED;
condwaits = 0;
return;
}
id++;
CloseHandle (win32_obj_id);
}
}
magic = 0;
win32_obj_id = NULL;
}
@ -605,7 +607,7 @@ pthread_mutex::pthread_mutex (pthread_mutex_t *mutex, pthread_mutexattr * attr):
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL);
if (!win32_obj_id)
magic = 0;
magic = 0;
condwaits = 0;
pshared = PTHREAD_PROCESS_PRIVATE;
}
@ -1654,16 +1656,23 @@ __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);
if ((*cond)->waiting)
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
{
if (pthread_mutex_unlock (&(*cond)->cond_access))
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
return EINVAL;
if (pthread_mutex_unlock (&(*cond)->cond_access))
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
return EINVAL;
}
InterlockedIncrement (&((*cond)->waiting));
@ -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);
@ -1708,9 +1717,9 @@ __pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex)
if ((*cond)->waiting)
if ((*cond)->mutex && ((*cond)->mutex != (*themutex)))
{
if (pthread_mutex_unlock (&(*cond)->cond_access))
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
return EINVAL;
if (pthread_mutex_unlock (&(*cond)->cond_access))
system_printf ("Failed to unlock condition variable access mutex, this %0p\n", *cond);
return EINVAL;
}
InterlockedIncrement (&((*cond)->waiting));
@ -1856,11 +1865,11 @@ __pthread_mutex_init (pthread_mutex_t * mutex,
mutex = __pthread_mutex_getpshared ((pthread_mutex_t *) mutex);
if (!verifyable_object_isvalid (*mutex, PTHREAD_MUTEX_MAGIC))
{
delete throwaway;
*mutex = NULL;
return EAGAIN;
}
{
delete throwaway;
*mutex = NULL;
return EAGAIN;
}
return 0;
}
*mutex = new pthread_mutex (attr ? (*attr) : NULL);

View File

@ -269,10 +269,10 @@ public:
int TryLock ();
int UnLock ();
pthread_mutex (unsigned short);
pthread_mutex (pthread_mutexattr *);
pthread_mutex (pthread_mutex_t *, pthread_mutexattr *);
~pthread_mutex ();
pthread_mutex (unsigned short);
pthread_mutex (pthread_mutexattr *);
pthread_mutex (pthread_mutex_t *, pthread_mutexattr *);
~pthread_mutex ();
};
class pthread_condattr:public verifyable_object
@ -280,8 +280,8 @@ class pthread_condattr:public verifyable_object
public:
int shared;
pthread_condattr ();
~pthread_condattr ();
pthread_condattr ();
~pthread_condattr ();
};
class pthread_cond:public verifyable_object