[llvm-commits] [llvm-gcc-4.2] r50401 - in /llvm-gcc-4.2/trunk/libiberty: pex-common.h pex-djgpp.c pex-msdos.c pex-unix.c pex-win32.c
Anton Korobeynikov
asl at math.spbu.ru
Mon Apr 28 23:21:42 PDT 2008
Author: asl
Date: Tue Apr 29 01:21:42 2008
New Revision: 50401
URL: http://llvm.org/viewvc/llvm-project?rev=50401&view=rev
Log:
Backport from mainline.
Win64-related changes to libiberty.
Modified:
llvm-gcc-4.2/trunk/libiberty/pex-common.h
llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c
llvm-gcc-4.2/trunk/libiberty/pex-msdos.c
llvm-gcc-4.2/trunk/libiberty/pex-unix.c
llvm-gcc-4.2/trunk/libiberty/pex-win32.c
Modified: llvm-gcc-4.2/trunk/libiberty/pex-common.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-common.h?rev=50401&r1=50400&r2=50401&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/libiberty/pex-common.h (original)
+++ llvm-gcc-4.2/trunk/libiberty/pex-common.h Tue Apr 29 01:21:42 2008
@@ -26,6 +26,14 @@
#include "libiberty.h"
#include <stdio.h>
+/* LLVM LOCAL begin mainline */
+/* 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
+/* LLVM LOCAL end mainline */
+
#define install_error_msg "installation problem, cannot exec `%s'"
/* stdin file number. */
@@ -104,7 +112,9 @@
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 */,
+/* LLVM LOCAL begin mainline */
+ pid_t (*exec_child) (struct pex_obj *, int /* flags */,
+/* LLVM LOCAL end mainline */
const char */* executable */, char * const * /* argv */,
char * const * /* env */,
int /* in */, int /* out */, int /* errdes */,
@@ -116,7 +126,9 @@
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 /* child */, int * /* status */,
+/* LLVM LOCAL begin mainline */
+ int (*wait) (struct pex_obj *, pid_t /* child */, int * /* status */,
+/* LLVM LOCAL end mainline */
struct pex_time * /* time */, int /* done */,
const char ** /* errmsg */, int * /* err */);
/* Create a pipe (only called if PEX_USE_PIPES is set) storing two
Modified: llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c?rev=50401&r1=50400&r2=50401&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c (original)
+++ llvm-gcc-4.2/trunk/libiberty/pex-djgpp.c Tue Apr 29 01:21:42 2008
@@ -44,12 +44,16 @@
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 long pex_djgpp_exec_child (struct pex_obj *, int, const char *,
+/* LLVM LOCAL begin mainline */
+static pid_t pex_djgpp_exec_child (struct pex_obj *, int, const char *,
+/* LLVM LOCAL end mainline */
char * const *, char * const *,
int, int, int, int,
const char **, int *);
static int pex_djgpp_close (struct pex_obj *, int);
-static int pex_djgpp_wait (struct pex_obj *, long, int *, struct pex_time *,
+/* LLVM LOCAL begin mainline */
+static int pex_djgpp_wait (struct pex_obj *, pid_t, int *, struct pex_time *,
+/* LLVM LOCAL end mainline */
int, const char **, int *);
/* The list of functions we pass to the common routines. */
@@ -110,7 +114,9 @@
/* Execute a child. */
-static long
+/* LLVM LOCAL begin mainline */
+static pid_t
+/* LLVM LOCAL end mainline */
pex_djgpp_exec_child (struct pex_obj *obj, int flags, const char *executable,
char * const * argv, char * const * env,
int in, int out, int errdes,
@@ -132,19 +138,25 @@
{
*err = errno;
*errmsg = "dup";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (dup2 (in, STDIN_FILE_NO) < 0)
{
*err = errno;
*errmsg = "dup2";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (close (in) < 0)
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
@@ -155,19 +167,25 @@
{
*err = errno;
*errmsg = "dup";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (dup2 (out, STDOUT_FILE_NO) < 0)
{
*err = errno;
*errmsg = "dup2";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (close (out) < 0)
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
@@ -179,14 +197,18 @@
{
*err = errno;
*errmsg = "dup";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (dup2 ((flags & PEX_STDERR_TO_STDOUT) != 0 ? STDOUT_FILE_NO : errdes,
STDERR_FILE_NO) < 0)
{
*err = errno;
*errmsg = "dup2";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (errdes != STDERR_FILE_NO)
{
@@ -194,7 +216,9 @@
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
}
@@ -218,13 +242,17 @@
{
*err = errno;
*errmsg = "dup2";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (close (org_in) < 0)
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
@@ -234,13 +262,17 @@
{
*err = errno;
*errmsg = "dup2";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (close (org_out) < 0)
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
@@ -251,13 +283,17 @@
{
*err = errno;
*errmsg = "dup2";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
if (close (org_errdes) < 0)
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
@@ -269,7 +305,9 @@
statuses[obj->count] = status;
obj->sysdep = (void *) statuses;
- return obj->count;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) obj->count;
+ /* LLVM LOCAL end mainline */
}
/* Wait for a child process to complete. Actually the child process
@@ -277,7 +315,9 @@
status. */
static int
-pex_djgpp_wait (struct pex_obj *obj, long pid, int *status,
+/* LLVM LOCAL begin mainline */
+pex_djgpp_wait (struct pex_obj *obj, pid_t pid, int *status,
+/* LLVM LOCAL end mainline */
struct pex_time *time, int done ATTRIBUTE_UNUSED,
const char **errmsg ATTRIBUTE_UNUSED,
int *err ATTRIBUTE_UNUSED)
Modified: llvm-gcc-4.2/trunk/libiberty/pex-msdos.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-msdos.c?rev=50401&r1=50400&r2=50401&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/libiberty/pex-msdos.c (original)
+++ llvm-gcc-4.2/trunk/libiberty/pex-msdos.c Tue Apr 29 01:21:42 2008
@@ -54,12 +54,16 @@
static int pex_msdos_open (struct pex_obj *, const char *, int);
static int pex_msdos_open (struct pex_obj *, const char *, int);
static int pex_msdos_fdindex (struct pex_msdos *, int);
-static long pex_msdos_exec_child (struct pex_obj *, int, const char *,
+/* LLVM LOCAL begin mainline */
+static pid_t pex_msdos_exec_child (struct pex_obj *, int, const char *,
+/* LLVM LOCAL end mainline */
char * const *, char * const *,
int, int, int, int,
int, const char **, int *);
static int pex_msdos_close (struct pex_obj *, int);
-static int pex_msdos_wait (struct pex_obj *, long, int *, struct pex_time *,
+/* LLVM LOCAL begin mainline */
+static int pex_msdos_wait (struct pex_obj *, pid_t, int *, struct pex_time *,
+/* LLVM LOCAL end mainline */
int, const char **, int *);
static void pex_msdos_cleanup (struct pex_obj *);
@@ -152,7 +156,9 @@
/* Execute a child. */
-static long
+/* LLVM LOCAL begin mainline */
+static pid_t
+/* LLVM LOCAL end mainline */
pex_msdos_exec_child (struct pex_obj *obj, int flags, const char *executable,
char * const * argv, char * const * env, int in, int out,
int toclose ATTRIBUTE_UNUSED,
@@ -235,7 +241,9 @@
free (scmd);
free (rf);
*errmsg = "cannot open temporary command file";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
for (i = 1; argv[i] != NULL; ++i)
@@ -262,7 +270,9 @@
free (scmd);
free (rf);
*errmsg = "system";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
remove (rf);
@@ -275,7 +285,9 @@
ms->statuses = XRESIZEVEC(int, ms->statuses, obj->count + 1);
ms->statuses[obj->count] = status;
- return obj->count;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) obj->count;
+ /* LLVM LOCAL end mainline */
}
/* Wait for a child process to complete. Actually the child process
@@ -283,7 +295,9 @@
status. */
static int
-pex_msdos_wait (struct pex_obj *obj, long pid, int *status,
+/* LLVM LOCAL begin mainline */
+pex_msdos_wait (struct pex_obj *obj, pid_t pid, int *status,
+/* LLVM LOCAL end mainline */
struct pex_time *time, int done ATTRIBUTE_UNUSED,
const char **errmsg ATTRIBUTE_UNUSED,
int *err ATTRIBUTE_UNUSED)
Modified: llvm-gcc-4.2/trunk/libiberty/pex-unix.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-unix.c?rev=50401&r1=50400&r2=50401&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/libiberty/pex-unix.c (original)
+++ llvm-gcc-4.2/trunk/libiberty/pex-unix.c Tue Apr 29 01:21:42 2008
@@ -84,15 +84,21 @@
time that it took. This is simple if we have wait4, slightly
harder if we have waitpid, and is a pain if we only have wait. */
+/* LLVM LOCAL begin mainline */
static pid_t pex_wait (struct pex_obj *, pid_t, int *, struct pex_time *);
+/* LLVM LOCAL end mainline */
#ifdef HAVE_WAIT4
+/* LLVM LOCAL begin mainline */
static pid_t
pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status,
+/* LLVM LOCAL end mainline */
struct pex_time *time)
{
+ /* LLVM LOCAL begin mainline */
pid_t ret;
+ /* LLVM LOCAL end mainline */
struct rusage r;
#ifdef HAVE_WAITPID
@@ -119,8 +125,10 @@
#ifndef HAVE_GETRUSAGE
+/* LLVM LOCAL begin mainline */
static pid_t
pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status,
+/* LLVM LOCAL end mainline */
struct pex_time *time)
{
if (time != NULL)
@@ -130,12 +138,16 @@
#else /* defined (HAVE_GETRUSAGE) */
+/* LLVM LOCAL begin mainline */
static pid_t
pex_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid, int *status,
+/* LLVM LOCAL end mainline */
struct pex_time *time)
{
struct rusage r1, r2;
+ /* LLVM LOCAL begin mainline */
pid_t ret;
+ /* LLVM LOCAL end mainline */
if (time == NULL)
return waitpid (pid, status, 0);
@@ -174,13 +186,17 @@
struct status_list
{
struct status_list *next;
+ /* LLVM LOCAL begin mainline */
pid_t pid;
+ /* LLVM LOCAL end mainline */
int status;
struct pex_time time;
};
+/* LLVM LOCAL begin mainline */
static pid_t
pex_wait (struct pex_obj *obj, pid_t pid, int *status, struct pex_time *time)
+/* LLVM LOCAL end mainline */
{
struct status_list **pp;
@@ -204,7 +220,9 @@
while (1)
{
+ /* LLVM LOCAL begin mainline */
pid_t cpid;
+ /* LLVM LOCAL end mainline */
struct status_list *psl;
struct pex_time pt;
#ifdef HAVE_GETRUSAGE
@@ -269,12 +287,16 @@
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 long pex_unix_exec_child (struct pex_obj *, int, const char *,
+/* LLVM LOCAL begin mainline */
+static pid_t pex_unix_exec_child (struct pex_obj *, int, const char *,
+/* LLVM LOCAL end mainline */
char * const *, char * const *,
int, int, int, int,
const char **, int *);
static int pex_unix_close (struct pex_obj *, int);
-static int pex_unix_wait (struct pex_obj *, long, int *, struct pex_time *,
+/* LLVM LOCAL begin mainline */
+static int pex_unix_wait (struct pex_obj *, pid_t, int *, struct pex_time *,
+/* LLVM LOCAL end mainline */
int, const char **, int *);
static int pex_unix_pipe (struct pex_obj *, int *, int);
static FILE *pex_unix_fdopenr (struct pex_obj *, int, int);
@@ -355,13 +377,17 @@
extern char **environ;
-static long
+/* LLVM LOCAL begin mainline */
+static pid_t
pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
+/* LLVM LOCAL end mainline */
char * const * argv, char * const * env,
int in, int out, int errdes,
int toclose, const char **errmsg, int *err)
{
+ /* LLVM LOCAL begin mainline */
pid_t pid;
+ /* LLVM LOCAL end mainline */
/* We declare these to be volatile to avoid warnings from gcc about
them being clobbered by vfork. */
@@ -384,7 +410,9 @@
case -1:
*err = errno;
*errmsg = VFORK_STRING;
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
case 0:
/* Child process. */
@@ -435,7 +463,9 @@
}
/* NOTREACHED */
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
default:
/* Parent process. */
@@ -445,7 +475,9 @@
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
if (out != STDOUT_FILE_NO)
@@ -454,7 +486,9 @@
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
if (errdes != STDERR_FILE_NO)
@@ -463,18 +497,22 @@
{
*err = errno;
*errmsg = "close";
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
}
- return (long) pid;
+ return pid;
}
}
/* Wait for a child process to complete. */
static int
-pex_unix_wait (struct pex_obj *obj, long pid, int *status,
+/* LLVM LOCAL begin mainline */
+pex_unix_wait (struct pex_obj *obj, pid_t pid, int *status,
+/* LLVM LOCAL end mainline */
struct pex_time *time, int done, const char **errmsg,
int *err)
{
Modified: llvm-gcc-4.2/trunk/libiberty/pex-win32.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/libiberty/pex-win32.c?rev=50401&r1=50400&r2=50401&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/libiberty/pex-win32.c (original)
+++ llvm-gcc-4.2/trunk/libiberty/pex-win32.c Tue Apr 29 01:21:42 2008
@@ -79,12 +79,16 @@
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 long pex_win32_exec_child (struct pex_obj *, int, const char *,
+/* LLVM LOCAL begin mainline */
+static pid_t pex_win32_exec_child (struct pex_obj *, int, const char *,
+/* LLVM LOCAL end mainline */
char * const *, char * const *,
int, int, int, int,
const char **, int *);
static int pex_win32_close (struct pex_obj *, int);
-static int pex_win32_wait (struct pex_obj *, long, int *,
+/* LLVM LOCAL begin mainline */
+static int pex_win32_wait (struct pex_obj *, pid_t, int *,
+/* LLVM LOCAL end mainline */
struct pex_time *, int, const char **, int *);
static int pex_win32_pipe (struct pex_obj *, int *, int);
static FILE *pex_win32_fdopenr (struct pex_obj *, int, int);
@@ -521,7 +525,9 @@
return c1 - c2;
}
-static long
+/* LLVM LOCAL begin mainline */
+static pid_t
+/* LLVM LOCAL end mainline */
win32_spawn (const char *executable,
BOOL search,
char *const *argv,
@@ -596,7 +602,9 @@
free (full_executable);
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
/* Clean up. */
@@ -605,7 +613,9 @@
if (env_block)
free (env_block);
- return (long) pi->hProcess;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) pi->hProcess;
+ /* LLVM LOCAL end mainline */
error:
if (env_block)
@@ -615,17 +625,23 @@
if (full_executable)
free (full_executable);
- return -1;
+ /* LLVM LOCAL begin mainline */
+ return (pid_t) -1;
+ /* LLVM LOCAL end mainline */
}
-static long
+/* LLVM LOCAL begin mainline */
+static pid_t
+/* LLVM LOCAL end mainline */
spawn_script (const char *executable, char *const *argv,
char* const *env,
DWORD dwCreationFlags,
LPSTARTUPINFO si,
LPPROCESS_INFORMATION pi)
{
- int pid = -1;
+ /* LLVM LOCAL begin mainline */
+ pid_t pid = (pid_t) -1;
+ /* LLVM LOCAL end mainline */
int save_errno = errno;
int fd = _open (executable, _O_RDONLY);
@@ -672,7 +688,7 @@
dwCreationFlags, si, pi);
if (executable1 != newex)
free ((char *) newex);
- if (pid < 0)
+ if ((long) pid < 0)
{
newex = msys_rootify (executable1);
if (newex != executable1)
@@ -688,14 +704,16 @@
}
}
}
- if (pid < 0)
+ if ((long) pid < 0)
errno = save_errno;
return pid;
}
/* Execute a child. */
-static long
+/* LLVM LOCAL begin mainline */
+static pid_t
+/* LLVM LOCAL end mainline */
pex_win32_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, int flags,
const char *executable, char * const * argv,
char* const* env,
@@ -704,7 +722,9 @@
const char **errmsg,
int *err)
{
- long pid;
+ /* LLVM LOCAL begin mainline */
+ pid_t pid;
+ /* LLVM LOCAL end mainline */
HANDLE stdin_handle;
HANDLE stdout_handle;
HANDLE stderr_handle;
@@ -779,10 +799,14 @@
/* Create the child process. */
pid = win32_spawn (executable, (flags & PEX_SEARCH) != 0,
argv, env, dwCreationFlags, &si, &pi);
- if (pid == -1)
+ /* LLVM LOCAL begin mainline */
+ if (pid == (pid_t) -1)
+ /* LLVM LOCAL end mainline */
pid = spawn_script (executable, argv, env, dwCreationFlags,
&si, &pi);
- if (pid == -1)
+ /* LLVM LOCAL begin mainline */
+ if (pid == (pid_t) -1)
+ /* LLVM LOCAL end mainline */
{
*err = ENOENT;
*errmsg = "CreateProcess";
@@ -807,7 +831,9 @@
macros. Note that WIFSIGNALED will never be true under CRTDLL. */
static int
-pex_win32_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, long pid,
+/* LLVM LOCAL begin mainline */
+pex_win32_wait (struct pex_obj *obj ATTRIBUTE_UNUSED, pid_t pid,
+/* LLVM LOCAL end mainline */
int *status, struct pex_time *time, int done ATTRIBUTE_UNUSED,
const char **errmsg, int *err)
{
@@ -882,7 +908,9 @@
char const *errmsg;
int err;
argv++;
- printf ("%ld\n", pex_win32_exec_child (NULL, PEX_SEARCH, argv[0], argv, NULL, 0, 0, 1, 2, &errmsg, &err));
+ /* LLVM LOCAL begin mainline */
+ printf ("%ld\n", (long) pex_win32_exec_child (NULL, PEX_SEARCH, argv[0], argv, NULL, 0, 0, 1, 2, &errmsg, &err));
+ /* LLVM LOCAL end mainline */
exit (0);
}
#endif
More information about the llvm-commits
mailing list