OSDN Git Service

* tree-flow-inline.h (next_readonly_imm_use): Return
[pf3gnuchains/gcc-fork.git] / libiberty / pex-common.h
index c0b47fe..5b7bfcc 100644 (file)
@@ -16,8 +16,8 @@ Library General Public License for more details.
 
 You should have received a copy of the GNU Library General Public
 License along with libiberty; see the file COPYING.LIB.  If not,
-write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #ifndef PEX_COMMON_H
 #define PEX_COMMON_H
@@ -26,6 +26,12 @@ Boston, MA 02111-1307, USA.  */
 #include "libiberty.h"
 #include <stdio.h>
 
+/* pid_t is may defined by config.h or sys/types.h needs to be
+   included.  */
+#if !defined(pid_t) && defined(HAVE_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
 #define install_error_msg "installation problem, cannot exec `%s'"
 
 /* stdin file number.  */
@@ -59,9 +65,11 @@ struct pex_obj
   char *next_input_name;
   /* Whether next_input_name was allocated using malloc.  */
   int next_input_name_allocated;
+  /* If not -1, stderr pipe from the last process.  */
+  int stderr_pipe;
   /* Number of child processes.  */
   int count;
-  /* PIDs of child processes; array allocated using maloc.  */
+  /* PIDs of child processes; array allocated using malloc.  */
   long *children;
   /* Exit statuses of child processes; array allocated using malloc.  */
   int *status;
@@ -69,8 +77,12 @@ struct pex_obj
   struct pex_time *time;
   /* Number of children we have already waited for.  */
   int number_waited;
+  /* FILE created by pex_input_file.  */
+  FILE *input_file;
   /* FILE created by pex_read_output.  */
   FILE *read_output;
+  /* FILE created by pex_read_err.  */
+  FILE *read_err;
   /* Number of temporary files to remove.  */
   int remove_count;
   /* List of temporary files to remove; array allocated using malloc
@@ -88,36 +100,48 @@ struct pex_funcs
 {
   /* Open file NAME for reading.  If BINARY is non-zero, open in
      binary mode.  Return >= 0 on success, -1 on error.  */
-  int (*open_read) (struct pex_obj *, const char *name, int binary);
+  int (*open_read) (struct pex_obj *, const char */* name */, int /* binary */);
   /* 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 (*open_write) (struct pex_obj *, const char */* name */,
+                     int /* binary */);
   /* Execute a child process.  FLAGS, EXECUTABLE, ARGV, ERR are from
-     pex_run.  IN, OUT, ERRDES are each a descriptor, from open_read,
-     open_write, or pipe, or they are one of STDIN_FILE_NO,
-     STDOUT_FILE_NO or STDERR_FILE_NO; if not STD*_FILE_NO, they
-     should be closed.  The function should handle the
+     pex_run.  IN, OUT, ERRDES, TOCLOSE are all descriptors, from
+     open_read, open_write, or pipe, or they are one of STDIN_FILE_NO,
+     STDOUT_FILE_NO or STDERR_FILE_NO; if IN, OUT, and ERRDES are not
+     STD*_FILE_NO, they should be closed.  If the descriptor TOCLOSE
+     is not -1, and the system supports pipes, TOCLOSE should be
+     closed in the child process.  The function should handle the
      PEX_STDERR_TO_STDOUT flag.  Return >= 0 on success, or -1 on
      error and set *ERRMSG and *ERR.  */
-  long (*exec_child) (struct pex_obj *, int flags, const char *executable,
-                     char * const * argv, int in, int out, int errdes,
-                     const char **errmsg, int *err);
+  pid_t (*exec_child) (struct pex_obj *, int /* flags */,
+                      const char */* executable */, char * const * /* argv */,
+                      char * const * /* env */,
+                      int /* in */, int /* out */, int /* errdes */,
+                     int /* toclose */, const char **/* errmsg */,
+                     int */* err */);
   /* Close a descriptor.  Return 0 on success, -1 on error.  */
   int (*close) (struct pex_obj *, int);
   /* Wait for a child to complete, returning exit status in *STATUS
      and time in *TIME (if it is not null).  CHILD is from fork.  DONE
      is 1 if this is called via pex_free.  ERRMSG and ERR are as in
      fork.  Return 0 on success, -1 on error.  */
-  int (*wait) (struct pex_obj *, long, int *status, struct pex_time *time,
-              int done, const char **errmsg, int *err);
+  int (*wait) (struct pex_obj *, pid_t /* child */, int * /* status */,
+               struct pex_time * /* time */, int /* done */,
+               const char ** /* errmsg */, int * /* err */);
   /* Create a pipe (only called if PEX_USE_PIPES is set) storing two
-     descriptin in *P.  If BINARY is non-zero, open in binary mode.
-     Return 0 on success, -1 on error.  */
-  int (*pipe) (struct pex_obj *, int *p, int binary);
+     descriptors in P[0] and P[1].  If BINARY is non-zero, open in
+     binary mode.  Return 0 on success, -1 on error.  */
+  int (*pipe) (struct pex_obj *, int * /* p */, int /* binary */);
   /* Get a FILE pointer to read from a file descriptor (only called if
      PEX_USE_PIPES is set).  If BINARY is non-zero, open in binary
      mode.  Return pointer on success, NULL on error.  */
-  FILE * (*fdopenr) (struct pex_obj *, int fd, int binary);
+  FILE * (*fdopenr) (struct pex_obj *, int /* fd */, int /* binary */);
+  /* Get a FILE pointer to write to the file descriptor FD (only
+     called if PEX_USE_PIPES is set).  If BINARY is non-zero, open in
+     binary mode.  Arrange for FD not to be inherited by the child
+     processes.  Return pointer on success, NULL on error.  */
+  FILE * (*fdopenw) (struct pex_obj *, int /* fd */, int /* binary */);
   /* Free any system dependent data associated with OBJ.  May be
      NULL if there is nothing to do.  */
   void (*cleanup) (struct pex_obj *);