delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2005/04/18/12:28:24

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
From: Andris Pavenis <pavenis AT latnet DOT lv>
To: gcc-patches AT gcc DOT gnu DOT org, djgpp-workers AT delorie DOT com
Subject: [libiberty] [PATCH] Fix breakage of pex-djgpp.c in HEAD branch
Date: Mon, 18 Apr 2005 19:01:29 +0300
User-Agent: KMail/1.8
MIME-Version: 1.0
Message-Id: <200504181901.29986.pavenis@latnet.lv>
X-Virus-Scanned: amavisd-new at fgi.fi
Reply-To: djgpp-workers AT delorie DOT com

After last rewrite libiberty/pex-djgpp.c in HEAD branch is broken for DJGPP and 
doesn't even compile. The following patch fixes this breakage. 

Bootstrapped HEAD branch (2005/04/14) for i586-pc-msdos-djgpp after this patch
(some other not related patches in different places were needed)

Andris


2004-04-18  Andris Pavenis  <pavenis AT latnet DOT lv>

 * pex-djgpp.c: Add missing includes
 (pex_init) Add missing ; for last parameter in call to pex_init_common
 (pex_djgpp_exec_child) Use dup(), dup2(), close() instead of _dup(), _dup2(), _close().


Index: gcc/libiberty/pex-djgpp.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/pex-djgpp.c,v
retrieving revision 1.3
diff -u -p -3 -r1.3 pex-djgpp.c
--- gcc/libiberty/pex-djgpp.c 29 Mar 2005 02:08:42 -0000 1.3
+++ gcc/libiberty/pex-djgpp.c 18 Apr 2005 15:18:03 -0000
@@ -30,6 +30,10 @@ extern int errno;
 #include <stdlib.h>
 #endif
 #include <process.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
 
 /* Use ECHILD if available, otherwise use EINVAL.  */
 #ifdef ECHILD
@@ -68,7 +72,7 @@ pex_init (int flags, const char *pname, 
 {
   /* DJGPP does not support pipes.  */
   flags &= ~ PEX_USE_PIPES;
-  return pex_init_common (flags, pname, tempbase, funcs);
+  return pex_init_common (flags, pname, tempbase, &funcs);
 }
 
 /* Open a file for reading.  */
@@ -119,46 +123,46 @@ pex_djgpp_exec_child (struct pex_obj *ob
 
   if (in != STDIN_FILE_NO)
     {
-      org_in = _dup (STDIN_FILE_NO);
+      org_in = dup (STDIN_FILE_NO);
       if (org_in < 0)
  {
    *err = errno;
-   *errmsg = "_dup";
+   *errmsg = "dup";
    return -1;
  }
-      if (_dup2 (in, STDIN_FILE_NO) < 0)
+      if (dup2 (in, STDIN_FILE_NO) < 0)
  {
    *err = errno;
-   *errmsg = "_dup2";
+   *errmsg = "dup2";
    return -1;
  }
-      if (_close (in) < 0)
+      if (close (in) < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_close";
+	  *errmsg = "close";
 	  return -1;
 	}
     }
 
   if (out != STDOUT_FILE_NO)
     {
-      org_out = _dup (STDOUT_FILE_NO);
+      org_out = dup (STDOUT_FILE_NO);
       if (org_out < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_dup";
+	  *errmsg = "dup";
 	  return -1;
 	}
-      if (_dup2 (out, STDOUT_FILE_NO) < 0)
+      if (dup2 (out, STDOUT_FILE_NO) < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_dup2";
+	  *errmsg = "dup2";
 	  return -1;
 	}
-      if (_close (out) < 0)
+      if (close (out) < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_close";
+	  *errmsg = "close";
 	  return -1;
 	}
     }
@@ -166,70 +170,68 @@ pex_djgpp_exec_child (struct pex_obj *ob
   if (errdes != STDERR_FILE_NO
       || (flags & PEX_STDERR_TO_STDOUT) != 0)
     {
-      int e;
-
-      org_errdes = _dup (STDERR_FILE_NO);
+      org_errdes = dup (STDERR_FILE_NO);
       if (org_errdes < 0)
  {
    *err = errno;
-   *errmsg = "_dup";
+   *errmsg = "dup";
    return -1;
 	}
-      if (_dup2 ((flags & PEX_STDERR_TO_STDOUT) != 0 ? STDOUT_FILE_NO : errdes,
+      if (dup2 ((flags & PEX_STDERR_TO_STDOUT) != 0 ? STDOUT_FILE_NO : errdes,
 		 STDERR_FILE_NO) < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_dup2";
+	  *errmsg = "dup2";
 	  return -1;
 	}
       if (errdes != STDERR_FILE_NO)
 	{
-	  if (_close (errdes) < 0)
+	  if (close (errdes) < 0)
 	    {
 	      *err = errno;
-	      *errmsg = "_close";
+	      *errmsg = "close";
 	      return -1;
 	    }
 	}
     }
 
-  status = (((flags & PEX_SEARCH) != 0 ? _spawnvp : _spawnv)
-	    (P_WAIT, program, (const char **) argv));
+  status = (((flags & PEX_SEARCH) != 0 ? spawnvp : spawnv)
+	    (P_WAIT, executable, (const char **) argv));
 
   if (status == -1)
     {
       *err = errno;
-      *errmsg = ((flags & PEX_SEARCH) != 0) ? "_spawnvp" : "_spawnv";
+      *errmsg = ((flags & PEX_SEARCH) != 0) ? "spawnvp" : "spawnv";
     }
 
   if (in != STDIN_FILE_NO)
     {
-      if (_dup2 (org_in, STDIN_FILE_NO) < 0)
+      if (dup2 (org_in, STDIN_FILE_NO) < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_dup2";
+	  *errmsg = "dup2";
 	  return -1;
 	}
-      if (_close (org_in) < 0)
+      if (close (org_in) < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_close";
+	  *errmsg = "close";
 	  return -1;
 	}
     }
 
   if (out != STDOUT_FILE_NO)
     {
-      if (_dup2 (org_out, STDOUT_FILE_NO) < 0)
+      if (dup2 (org_out, STDOUT_FILE_NO) < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_dup2";
+	  *errmsg = "dup2";
 	  return -1;
 	}
-      if (_close (org_out) < 0)
+      if (close (org_out) < 0)
 	{
 	  *err = errno;
-	  *errmsg = "_close";
+	  *errmsg = "close";
 	  return -1;
 	}
     }
@@ -237,16 +239,16 @@ pex_djgpp_exec_child (struct pex_obj *ob
   if (errdes != STDERR_FILE_NO
       || (flags & PEX_STDERR_TO_STDOUT) != 0)
     {
-      if (_dup2 (org_errdes, STDERR_FILE_NO) < 0)
+      if (dup2 (org_errdes, STDERR_FILE_NO) < 0)
  {
    *err = errno;
-   *errmsg = "_dup2";
+   *errmsg = "dup2";
    return -1;
  }
-      if (_close (org_errdes) < 0)
+      if (close (org_errdes) < 0)
  {
    *err = errno;
-   *errmsg = "_close";
+   *errmsg = "close";
    return -1;
  }
     }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019