]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
pex-common.h (struct pex_funcs): Add new parameter for open_write field.
authorMax Ostapenko <m.ostapenko@partner.samsung.com>
Fri, 26 Sep 2014 07:58:04 +0000 (10:58 +0300)
committerMaxim Ostapenko <chefmax@gcc.gnu.org>
Fri, 26 Sep 2014 07:58:04 +0000 (10:58 +0300)
libiberty/

2014-09-26  Max Ostapenko  <m.ostapenko@partner.samsung.com>

* pex-common.h (struct pex_funcs): Add new parameter for open_write field.
* pex-unix.c (pex_unix_open_write): Add support for new parameter.
* pex-djgpp.c (pex_djgpp_open_write): Likewise.
* pex-win32.c (pex_win32_open_write): Likewise.
* pex-common.c (pex_run_in_environment): Likewise.

include/

2014-09-26  Max Ostapenko  <m.ostapenko@partner.samsung.com>

* libiberty.h (PEX_STDOUT_APPEND): New flag.
(PEX_STDERR_APPEND): Likewise.

From-SVN: r215632

include/ChangeLog
include/libiberty.h
libiberty/ChangeLog
libiberty/pex-common.c
libiberty/pex-common.h
libiberty/pex-djgpp.c
libiberty/pex-unix.c
libiberty/pex-win32.c

index 88176beda1987c48af0f3fc1dcd9a0c1c614c038..e282aed0494a16889c8b2ae25b25a6ef55db9e3b 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-26  Max Ostapenko  <m.ostapenko@partner.samsung.com>
+
+       * libiberty.h (PEX_STDOUT_APPEND): New flag.
+       (PEX_STDERR_APPEND): Likewise.
+
 2014-09-23  Iain Buclaw  <ibuclaw@gdcproject.org>
 
        * demangle.h (DMGL_DLANG): New macro.
index 56b8b43cb887a845141d99e218f8626a426d3bdc..bcc1f9afaf7b731f486b752f0f42578e44455223 100644 (file)
@@ -445,6 +445,11 @@ extern struct pex_obj *pex_init (int flags, const char *pname,
    on Unix.  */
 #define PEX_BINARY_ERROR       0x80
 
+/* Append stdout to existing file instead of truncating it.  */
+#define PEX_STDOUT_APPEND      0x100
+
+/* Thes same as PEX_STDOUT_APPEND, but for STDERR.  */
+#define PEX_STDERR_APPEND      0x200
 
 /* Execute one program.  Returns NULL on success.  On error returns an
    error string (typically just the name of a system call); the error
index d47b8730ea5734d6a232858c768426e190cd133d..53d967e6d70c7ac6c4125807bc8c0375400a865b 100644 (file)
@@ -1,3 +1,11 @@
+2014-09-26  Max Ostapenko  <m.ostapenko@partner.samsung.com>
+
+       * pex-common.h (struct pex_funcs): Add new parameter for open_write field.
+       * pex-unix.c (pex_unix_open_write): Add support for new parameter.
+       * pex-djgpp.c (pex_djgpp_open_write): Likewise.
+       * pex-win32.c (pex_win32_open_write): Likewise.
+       * pex-common.c (pex_run_in_environment): Likewise.
+
 2014-09-23  Iain Buclaw  <ibuclaw@gdcproject.org>
 
        * Makefile.in (CFILES): Add d-demangle.c.
index 6fd3fdecd808b38ad024a7db14163795eb99a91f..146010a6fcac85bb7bf6964daed37321c4b30d3d 100644 (file)
@@ -267,7 +267,8 @@ pex_run_in_environment (struct pex_obj *obj, int flags, const char *executable,
   if (out < 0)
     {
       out = obj->funcs->open_write (obj, outname,
-                                   (flags & PEX_BINARY_OUTPUT) != 0);
+                                   (flags & PEX_BINARY_OUTPUT) != 0,
+                                   (flags & PEX_STDOUT_APPEND) != 0);
       if (out < 0)
        {
          *err = errno;
@@ -319,8 +320,9 @@ pex_run_in_environment (struct pex_obj *obj, int flags, const char *executable,
     }
   else
     {
-      errdes = obj->funcs->open_write (obj, errname, 
-                                      (flags & PEX_BINARY_ERROR) != 0);
+      errdes = obj->funcs->open_write (obj, errname,
+                                      (flags & PEX_BINARY_ERROR) != 0,
+                                      (flags & PEX_STDERR_APPEND) != 0);
       if (errdes < 0)
        {
          *err = errno;
index af338e6a34b0b6cc26304906e2930b2269c948c8..b6db248f692e57d42b99002b4cdfe6b85fc8c236 100644 (file)
@@ -104,7 +104,7 @@ struct pex_funcs
   /* Open file NAME for writing.  If BINARY is non-zero, open in
      binary mode.  Return >= 0 on success, -1 on error.  */
   int (*open_write) (struct pex_obj *, const char */* name */,
-                     int /* binary */);
+                     int /* binary */, int /* append */);
   /* Execute a child process.  FLAGS, EXECUTABLE, ARGV, ERR are from
      pex_run.  IN, OUT, ERRDES, TOCLOSE are all descriptors, from
      open_read, open_write, or pipe, or they are one of STDIN_FILE_NO,
index 0721139954ff993a0c872a5697b4d9c8bdba9eeb..b014ffa33177a20b9669e465771b8a0fbd866b37 100644 (file)
@@ -43,7 +43,7 @@ extern int errno;
 #endif
 
 static int pex_djgpp_open_read (struct pex_obj *, const char *, int);
-static int pex_djgpp_open_write (struct pex_obj *, const char *, int);
+static int pex_djgpp_open_write (struct pex_obj *, const char *, int, int);
 static pid_t pex_djgpp_exec_child (struct pex_obj *, int, const char *,
                                  char * const *, char * const *,
                                  int, int, int, int,
@@ -90,10 +90,12 @@ pex_djgpp_open_read (struct pex_obj *obj ATTRIBUTE_UNUSED,
 
 static int
 pex_djgpp_open_write (struct pex_obj *obj ATTRIBUTE_UNUSED,
-                     const char *name, int binary)
+                     const char *name, int binary, int append)
 {
   /* Note that we can't use O_EXCL here because gcc may have already
      created the temporary file via make_temp_file.  */
+  if (append)
+    return -1;
   return open (name,
               (O_WRONLY | O_CREAT | O_TRUNC
                | (binary ? O_BINARY : O_TEXT)),
index addf8ee23dfa82bce2a172ce6b40eb15689dd0ca..0715115747826d510a960ae772cccc052012ee5a 100644 (file)
@@ -301,7 +301,7 @@ pex_wait (struct pex_obj *obj, pid_t pid, int *status, struct pex_time *time)
 static void pex_child_error (struct pex_obj *, const char *, const char *, int)
      ATTRIBUTE_NORETURN;
 static int pex_unix_open_read (struct pex_obj *, const char *, int);
-static int pex_unix_open_write (struct pex_obj *, const char *, int);
+static int pex_unix_open_write (struct pex_obj *, const char *, int, int);
 static pid_t pex_unix_exec_child (struct pex_obj *, int, const char *,
                                 char * const *, char * const *,
                                 int, int, int, int,
@@ -350,11 +350,12 @@ pex_unix_open_read (struct pex_obj *obj ATTRIBUTE_UNUSED, const char *name,
 
 static int
 pex_unix_open_write (struct pex_obj *obj ATTRIBUTE_UNUSED, const char *name,
-                    int binary ATTRIBUTE_UNUSED)
+                    int binary ATTRIBUTE_UNUSED, int append)
 {
   /* Note that we can't use O_EXCL here because gcc may have already
      created the temporary file via make_temp_file.  */
-  return open (name, O_WRONLY | O_CREAT | O_TRUNC, PUBLIC_MODE);
+  return open (name, O_WRONLY | O_CREAT
+                    | (append ? O_APPEND : O_TRUNC), PUBLIC_MODE);
 }
 
 /* Close a file.  */
index 8b9d4f04900c5ef556fe6f0a6ce089ae7121e32f..66d2f1157c730ae99e62a2e2b4be20437c43af52 100644 (file)
@@ -78,7 +78,7 @@ backslashify (char *s)
 }
 
 static int pex_win32_open_read (struct pex_obj *, const char *, int);
-static int pex_win32_open_write (struct pex_obj *, const char *, int);
+static int pex_win32_open_write (struct pex_obj *, const char *, int, int);
 static pid_t pex_win32_exec_child (struct pex_obj *, int, const char *,
                                  char * const *, char * const *,
                                   int, int, int, int,
@@ -126,10 +126,12 @@ pex_win32_open_read (struct pex_obj *obj ATTRIBUTE_UNUSED, const char *name,
 
 static int
 pex_win32_open_write (struct pex_obj *obj ATTRIBUTE_UNUSED, const char *name,
-                     int binary)
+                     int binary, int append)
 {
   /* Note that we can't use O_EXCL here because gcc may have already
      created the temporary file via make_temp_file.  */
+  if (append)
+    return -1;
   return _open (name,
                (_O_WRONLY | _O_CREAT | _O_TRUNC
                 | (binary ? _O_BINARY : _O_TEXT)),