]> sourceware.org Git - newlib-cygwin.git/commitdiff
* dllfixdbg: Eliminate extra objcopy step.
authorChristopher Faylor <me@cgf.cx>
Thu, 8 Nov 2007 14:36:49 +0000 (14:36 +0000)
committerChristopher Faylor <me@cgf.cx>
Thu, 8 Nov 2007 14:36:49 +0000 (14:36 +0000)
winsup/cygwin/ChangeLog
winsup/cygwin/dllfixdbg
winsup/cygwin/dtable.cc
winsup/cygwin/fhandler.cc
winsup/cygwin/fhandler.h
winsup/cygwin/path.cc
winsup/cygwin/pipe.cc
winsup/cygwin/syscalls.cc

index 05f0f114f811d94755f1e57f91bd2fc7da0afcca..1e5c7cd4f353bd947056ec8ba4fbf6729d53dd89 100644 (file)
@@ -1,3 +1,7 @@
+2007-11-08  Christopher Faylor  <me+cygwin@cgf.cx>
+
+       * dllfixdbg: Eliminate extra objcopy step.
+
 2007-11-07  Pedro Alves  <pedro_alves@portugalmail.pt>
 
        * dllfixdbg: Pass --only-keep-debug to objcopy, instead of
index 47ec271695a79862a5a205636955b2ae003296f2..f97be0ca6b1b2fa08df3a52f7baaef0b4c560586 100755 (executable)
@@ -16,8 +16,7 @@ my $objdump = shift;
 my @objcopy = ((shift));
 my $dll = shift;
 my $dbg = shift;
-xit 0, @objcopy, '--only-keep-debug', $dll, $dbg;
-xit 0, @objcopy, '-R', '.gnu_debuglink_overlay', $dbg;
+xit 0, @objcopy, '-R', '.gnu_debuglink_overlay', '--only-keep-debug', $dll, $dbg;
 xit 0, @objcopy, '-g', '--add-gnu-debuglink=' . $dbg, $dll;
 open(OBJDUMP, '-|', "$objdump --headers $dll");
 my %section;
index f130a2ef7cef32a2f860f611d7f944900c404026..019f8a1a685652d818396ec863e16100b2c7f9e4 100644 (file)
@@ -41,6 +41,17 @@ static const NO_COPY DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
 
 static const char *handle_to_fn (HANDLE, char *);
 
+#define DEVICE_PREFIX "\\device\\"
+#define DEVICE_PREFIX_LEN sizeof (DEVICE_PREFIX) - 1
+#define REMOTE "\\Device\\LanmanRedirector\\"
+#define REMOTE_LEN sizeof (REMOTE) - 1
+#define REMOTE1 "\\Device\\WinDfs\\Root\\"
+#define REMOTE1_LEN sizeof (REMOTE1) - 1
+#define NAMED_PIPE "\\Device\\NamedPipe\\"
+#define NAMED_PIPE_LEN sizeof (NAMED_PIPE) - 1
+#define POSIX_NAMED_PIPE "/Device/NamedPipe/"
+#define POSIX_NAMED_PIPE_LEN sizeof (POSIX_NAMED_PIPE) - 1
+
 /* Set aside space for the table of fds */
 void
 dtable_init ()
@@ -283,7 +294,7 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
          else
            dev = *console_dev;
        }
-      else if (ft == FILE_TYPE_PIPE)
+      else if (0 && ft == FILE_TYPE_PIPE)
        {
          if (fd == 0)
            dev = *piper_dev;
@@ -297,7 +308,12 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
       else
        {
          name = handle_to_fn (handle, (char *) alloca (CYG_MAX_PATH + 100));
-         bin = 0;
+         if (!strncasematch (name, POSIX_NAMED_PIPE, POSIX_NAMED_PIPE_LEN))
+           /* nothing */;
+         else if (fd == 0)
+           dev = *piper_dev;
+         else
+           dev = *pipew_dev;
        }
     }
 
@@ -308,25 +324,31 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
       fhandler_base *fh;
 
       if (dev)
-       fh = build_fh_dev (dev);
+       fh = build_fh_dev (dev, name);
       else
        fh = build_fh_name (name);
 
       if (fh)
        cygheap->fdtab[fd] = fh;
 
-      if (!bin)
+      if (name)
        {
-         bin = fh->get_default_fmode (O_RDWR);
-         if (bin)
-           /* nothing */;
-         else if (dev)
-           bin = O_BINARY;
-         else if (name != unknown_file)
-           bin = fh->pc_binmode ();
+         bin = fh->pc_binmode ();
+         if (!bin)
+           {
+             bin = fh->get_default_fmode (O_RDWR);
+             if (!bin && dev)
+               bin = O_BINARY;
+           }
        }
 
-      fh->init (handle, GENERIC_READ | GENERIC_WRITE, bin);
+      DWORD access;
+      if (fd == 0)
+       access = GENERIC_READ;
+      else 
+       access = GENERIC_WRITE;  /* Should be rdwr for stderr but not sure that's
+                                   possible for some versions of handles */
+      fh->init (handle, access, bin);
       set_std_handle (fd);
       paranoid_printf ("fd %d, handle %p", fd, handle);
     }
@@ -825,11 +847,6 @@ dtable::vfork_child_fixup ()
 }
 #endif /*NEWVFORK*/
 
-#define DEVICE_PREFIX "\\device\\"
-#define DEVICE_PREFIX_LEN sizeof (DEVICE_PREFIX) - 1
-#define REMOTE "\\Device\\LanmanRedirector\\"
-#define REMOTE_LEN sizeof (REMOTE) - 1
-
 static const char *
 handle_to_fn (HANDLE h, char *posix_fn)
 {
@@ -844,7 +861,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
   NTSTATUS res = NtQueryObject (h, ObjectNameInformation, ntfn, sizeof (fnbuf),
                                NULL);
 
-  if (NT_SUCCESS (res))
+  if (!NT_SUCCESS (res))
     {
       strcpy (posix_fn, unknown_file);
       debug_printf ("NtQueryObject failed");
@@ -901,6 +918,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
     }
 
   char *w32 = win32_fn;
+  bool justslash = false;
   if (maxmatchlen)
     {
       n = strlen (maxmatchdos);
@@ -910,15 +928,38 @@ handle_to_fn (HANDLE h, char *posix_fn)
       memcpy (w32, maxmatchdos, n);
       w32[n] = '\\';
     }
+  else if (strncasematch (w32, NAMED_PIPE, NAMED_PIPE_LEN))
+    {
+      debug_printf ("pipe");
+      justslash = true;
+    }
   else if (strncasematch (w32, REMOTE, REMOTE_LEN))
     {
       w32 += REMOTE_LEN - 2;
       *w32 = '\\';
       debug_printf ("remote drive");
+      justslash = true;
+    }
+  else if (strncasematch (w32, REMOTE1, REMOTE1_LEN))
+    {
+      w32 += REMOTE1_LEN - 2;
+      *w32 = '\\';
+      debug_printf ("remote drive");
+      justslash = true;
     }
 
+  if (!justslash)
+    cygwin_conv_to_full_posix_path (w32, posix_fn);
+  else
+    {
+      char *s, *d;
+      for (s = w32, d = posix_fn; *s; s++, d++)
+       if (*s == '\\')
+         *d = '/';
+       else
+         *d = *s;
+    }
 
-  debug_printf ("derived path '%s'", w32);
-  cygwin_conv_to_full_posix_path (w32, posix_fn);
+  debug_printf ("derived path '%s', posix '%s'", w32, posix_fn);
   return posix_fn;
 }
index bc30a396cddf1dc65924c656686659a29fc22c33..a479d1b28e37ba004d6effd3fc38fd0102b022ec 100644 (file)
@@ -1639,6 +1639,7 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
       switch (WaitForMultipleObjects (n, w4, false, INFINITE))
        {
        case WAIT_OBJECT_0:
+         debug_printf ("normal read");
          if (!bytes ||
              GetOverlappedResult (h, get_overlapped (), bytes, false))
            res = 1;
@@ -1649,12 +1650,14 @@ fhandler_base::wait_overlapped (bool& res, bool writing, DWORD *bytes)
            }
          break;
        case WAIT_OBJECT_0 + 1:
+         debug_printf ("got a signal");
          CancelIo (h);
          set_errno (EINTR);
          res = 0;
          break;
        default:
          err = GetLastError ();
+         debug_printf ("WFMO error, %E");
          goto err;
          break;
        }
index 665dd51e1f19a08575d8614195e8dc34354fad9b..45588fef904be702f6bc76ecfcc9a1a7a1382c31 100644 (file)
@@ -149,6 +149,7 @@ class fhandler_base
   path_conv pc;
 
   virtual void set_name (path_conv &pc);
+  virtual void set_name (const char *s) {pc.set_normalized_path (s, false);}
   int error () const {return pc.error;}
   void set_error (int error) {pc.error = error;}
   bool exists () const {return pc.exists ();}
@@ -546,6 +547,7 @@ public:
   int __stdcall fadvise (_off64_t, _off64_t, int) __attribute__ ((regparm (3)));
   int __stdcall ftruncate (_off64_t, bool) __attribute__ ((regparm (3)));
   int ready_for_read (int fd, DWORD howlong);
+  void init (HANDLE, DWORD, mode_t);
   static int create (fhandler_pipe *[2], unsigned, int);
   static int create_selectable (LPSECURITY_ATTRIBUTES, HANDLE&, HANDLE&, DWORD);
 };
index a10a29339c10a8611b91de9a44a31ddb5db8c694..d0de90ec3142b83044b1c08a9b9da3a4806e0f5f 100644 (file)
@@ -543,7 +543,7 @@ path_conv::set_normalized_path (const char *path_copy, bool strip_tail)
 }
 
 PUNICODE_STRING
-get_nt_native_path (const char *path, UNICODE_STRING &upath)
+get_nt_native_path (const char *path, UNICODE_STRINGupath)
 {
   upath.Length = 0;
   if (path[0] == '/')          /* special path w/o NT path representation. */
index b9314aa4f8cb69bfc794d3ce73120f6e5cca9df2..4bf1d32d13f5e34e6bc28826a97efb41c94cb618 100644 (file)
@@ -34,6 +34,53 @@ fhandler_pipe::fhandler_pipe ()
   need_fork_fixup (true);
 }
 
+void
+fhandler_pipe::init (HANDLE f, DWORD a, mode_t bin)
+{
+  // FIXME: Have to clean this up someday
+  if (!*get_win32_name () && get_name ())
+    {
+      char *hold_normalized_name = (char *) alloca (strlen (get_name ()) + 1);
+      strcpy (hold_normalized_name, get_name ());
+      char *s, *d;
+      for (s = hold_normalized_name, d = (char *) get_win32_name (); *s; s++, d++)
+       if (*s == '/')
+         *d = '\\';
+       else
+         *d = *s;
+      set_name (hold_normalized_name);
+    }
+
+  bool opened_properly = a & FILE_CREATE_PIPE_INSTANCE;
+  a &= ~FILE_CREATE_PIPE_INSTANCE;
+  if (!opened_properly)
+    {
+      NTSTATUS status;
+      IO_STATUS_BLOCK io;
+      HANDLE h = NULL;
+      DWORD access = SYNCHRONIZE;
+      if (a & GENERIC_READ)
+       access |= FILE_READ_DATA | FILE_READ_ATTRIBUTES;
+      if (a & GENERIC_WRITE)
+       access |= FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES;
+      OBJECT_ATTRIBUTES attr;
+      static UNICODE_STRING fname;
+      InitializeObjectAttributes (&attr, &fname, OBJ_CASE_INSENSITIVE, f, NULL);
+small_printf ("f %p, h %p\n", f, h);
+      status = NtOpenFile (&h, a | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ | FILE_SHARE_WRITE,
+                          FILE_SEQUENTIAL_ONLY | FILE_SYNCHRONOUS_IO_ALERT);
+      if (!NT_SUCCESS (status))
+       system_printf ("Unable to reopen pipe %s, attributes %p, NT error: %p win32: %lu",
+                      get_win32_name (), access, status, RtlNtStatusToDosError (status));
+small_printf ("f %p, h %p\n", f, h);
+      CloseHandle (f);
+      f = h;
+    }
+
+  fhandler_base::init (f, a, bin);
+  setup_overlapped ();
+}
+
 extern "C" int sscanf (const char *, const char *, ...);
 
 int
@@ -284,16 +331,14 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode)
       fhs[1] = (fhandler_pipe *) build_fh_dev (*pipew_dev);
 
       int binmode = mode & O_TEXT ?: O_BINARY;
-      fhs[0]->init (r, GENERIC_READ, binmode);
-      fhs[1]->init (w, GENERIC_WRITE, binmode);
+      fhs[0]->init (r, FILE_CREATE_PIPE_INSTANCE | GENERIC_READ, binmode);
+      fhs[1]->init (w, FILE_CREATE_PIPE_INSTANCE | GENERIC_WRITE, binmode);
       if (mode & O_NOINHERIT)
        {
         fhs[0]->close_on_exec (true);
         fhs[1]->close_on_exec (true);
        }
 
-      fhs[0]->setup_overlapped ();
-      fhs[1]->setup_overlapped ();
       res = 0;
     }
 
index f3fa10d26779104cc198b476c38a9e8096a56e7c..899745f605caeca6cf912417f5731e119206669f 100644 (file)
@@ -743,8 +743,6 @@ readv (int fd, const struct iovec *const iov, const int iovcnt)
 
   while (1)
     {
-      sig_dispatch_pending ();
-
       cygheap_fdget cfd (fd);
       if (cfd < 0)
        break;
@@ -814,7 +812,6 @@ extern "C" ssize_t
 writev (const int fd, const struct iovec *const iov, const int iovcnt)
 {
   int res = -1;
-  sig_dispatch_pending ();
   const ssize_t tot = check_iovec_for_write (iov, iovcnt);
 
   cygheap_fdget cfd (fd);
This page took 0.042233 seconds and 5 git commands to generate.