]> sourceware.org Git - newlib-cygwin.git/commitdiff
* winsup.h: Turn on DEBUGGING by default for now.
authorChristopher Faylor <me@cgf.cx>
Thu, 10 Aug 2006 14:15:00 +0000 (14:15 +0000)
committerChristopher Faylor <me@cgf.cx>
Thu, 10 Aug 2006 14:15:00 +0000 (14:15 +0000)
winsup/cygwin/ChangeLog
winsup/cygwin/fhandler.cc
winsup/cygwin/fhandler_socket.cc
winsup/cygwin/mmap_helper.h [new file with mode: 0644]
winsup/cygwin/winsup.h

index 4b60bc953d737ffb01da24df6b531738f4066ace..b01b31aeef5d1b07fd61c50038c0d83180acee44 100644 (file)
@@ -1,3 +1,7 @@
+2006-08-10  Christopher Faylor  <cgf@timesys.com>
+
+       * winsup.h: Turn on DEBUGGING by default for now.
+
 2006-08-10  Corinna Vinschen  <corinna@vinschen.de>
 
        * fhandler_disk_file.cc (fhandler_disk_file::lock): Handle
index 00e9875873977e29f78c5e1f1eb0d928118ab157..ae5edcb62524d94689609730fcf4c8368767bff0 100644 (file)
@@ -31,6 +31,7 @@ details. */
 #include <winioctl.h>
 #include <ntdef.h>
 #include "ntdll.h"
+#include "mmap_helper.h"
 
 static NO_COPY const int CHUNK_SIZE = 1024; /* Used for crlf conversions */
 
@@ -223,10 +224,8 @@ fhandler_base::raw_read (void *ptr, size_t& ulen)
 
   HANDLE h = NULL;     /* grumble */
   int prio = 0;                /* ditto */
-  int try_noreserve = 1;
   DWORD len = ulen;
 
-retry:
   ulen = (size_t) -1;
   if (read_state)
     {
@@ -235,7 +234,7 @@ retry:
       SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL);
       signal_read_state (1);
     }
-  BOOL res = ReadFile (get_handle (), ptr, len, (DWORD *) &ulen, 0);
+  BOOL res = mmReadFile (get_handle (), ptr, len, (DWORD *) &ulen, 0);
   if (read_state)
     {
       signal_read_state (1);
@@ -261,19 +260,6 @@ retry:
              bytes_read = 0;
              break;
            }
-         if (try_noreserve)
-           {
-             try_noreserve = 0;
-             switch (mmap_is_attached_or_noreserve (ptr, len))
-               {
-               case MMAP_NORESERVE_COMMITED:
-                 goto retry;
-               case MMAP_RAISE_SIGBUS:
-                 raise(SIGBUS);
-               case MMAP_NONE:
-                 break;
-               }
-           }
          /*FALLTHRU*/
        case ERROR_INVALID_FUNCTION:
        case ERROR_INVALID_PARAMETER:
index 0fecdaaac7374231a3db5985d182dcf5297d99ed..5feb9a69c87d8051f28d48a4c80ca897f450b373 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/acl.h>
 #include "cygtls.h"
 #include "cygwin/in6.h"
+#include "mmap_helper.h"
 
 #define ASYNC_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT)
 #define EVENT_MASK (FD_READ|FD_WRITE|FD_OOB|FD_ACCEPT|FD_CONNECT|FD_CLOSE)
@@ -1163,8 +1164,8 @@ fhandler_socket::recv_internal (WSABUF *wsabuf, DWORD wsacnt, DWORD flags,
   while (!(res = wait_for_events (evt_mask | FD_CLOSE))
         || saw_shutdown_read ())
     {
-      res = WSARecvFrom (get_socket (), wsabuf, wsacnt, &ret,
-                        &flags, from, fromlen, NULL, NULL);
+      res = mmWSARecvFrom (get_socket (), wsabuf, wsacnt, &ret,
+                          &flags, from, fromlen, NULL, NULL);
       if (!res || WSAGetLastError () != WSAEWOULDBLOCK)
        break;
     }
diff --git a/winsup/cygwin/mmap_helper.h b/winsup/cygwin/mmap_helper.h
new file mode 100644 (file)
index 0000000..23a03ff
--- /dev/null
@@ -0,0 +1,91 @@
+/* mmap_helper.h
+
+   Copyright 2006 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 _MMAP_HELPER_H
+#define _MMAP_HELPER_H
+#define _MMIOWRAP(__ptr, __len, __func) \
+({ \
+  BOOL __res; \
+  for (int __i = 0; __i < 2; __i++) \
+    { \
+      __res = __func; \
+      if (__res || __i > 0) \
+       break; \
+      DWORD __errcode = GetLastError (); \
+      if (__errcode != ERROR_NOACCESS) \
+       break; \
+      switch (mmap_is_attached_or_noreserve (__ptr, __len)) \
+       { \
+       case MMAP_NORESERVE_COMMITED: \
+         continue; \
+       case MMAP_RAISE_SIGBUS: \
+         raise(SIGBUS); \
+       default: \
+         break; \
+       } \
+      break; \
+    } \
+  __res; \
+})
+
+#define _MMSOCKWRAP(__ptr, __count, __func) \
+({ \
+  int __res; \
+  for (int __i = 0; __i < 2; __i++) \
+    { \
+      __res = __func; \
+      if (!__res || __i > 0) \
+       break; \
+      DWORD __errcode = WSAGetLastError (); \
+      if (__errcode != WSAEFAULT) \
+       break; \
+      for (unsigned __j = 0; __j < __count; __j++) \
+       switch (mmap_is_attached_or_noreserve (__ptr[__j].buf, __ptr[__j].len)) \
+         { \
+         case MMAP_NORESERVE_COMMITED: \
+           goto keeptrying; \
+         case MMAP_RAISE_SIGBUS: \
+           raise(SIGBUS); \
+         default: \
+           break; \
+         } \
+      break; \
+    keeptrying: \
+      continue; \
+    } \
+  __res; \
+})
+
+extern inline BOOL
+mmReadFile (HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
+           LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
+{
+  return _MMIOWRAP (lpBuffer, nNumberOfBytesToRead,
+                   (ReadFile (hFile, lpBuffer, nNumberOfBytesToRead,
+                              lpNumberOfBytesRead, lpOverlapped)));
+}
+
+#ifdef _WINSOCK_H
+extern inline int
+mmWSARecvFrom (SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
+           LPDWORD lpNumberOfBytesRecvd, LPDWORD lpFlags,
+           struct sockaddr* lpFrom,
+           LPINT lpFromlen, LPWSAOVERLAPPED lpOverlapped,
+           LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
+{
+  return _MMSOCKWRAP (lpBuffers, dwBufferCount,
+                     (mmWSARecvFrom(s, lpBuffers, dwBufferCount,
+                                    lpNumberOfBytesRecvd, lpFlags, lpFrom,
+                                    lpFromlen, lpOverlapped,
+                                    lpCompletionRoutine)));
+}
+#endif /*_WINSOCK_H*/
+
+#endif /*_MMAP_HELPER_H*/
index ff7037a6555920fb61a4afa4482ceb3589072d7c..175bbee85de2dd0d6d323266ae62b2b10909c15e 100644 (file)
@@ -19,6 +19,9 @@ details. */
 # include "config.h"
 #endif
 
+#undef DEBUGGING
+#define DEBUGGING 1            /* CGF: FIXME: TEMPORARY */
+
 #define __INSIDE_CYGWIN__
 
 #define strlen __builtin_strlen
This page took 0.042896 seconds and 5 git commands to generate.