PERFORCE change 96625 for review
John Birrell
jb at FreeBSD.org
Wed May 3 22:36:53 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=96625
Change 96625 by jb at jb_freebsd2 on 2006/05/03 22:36:17
Don't use the Solaris file descriptor inheritance. That's not exactly
portable Unix code. Do it in a POSIX compatible way instead.
This lets us run the pre-processor which is needed to run Sun's DTrace
test suite. We actually pass some of the tests! 8-)
Affected files ...
.. //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_cc.c#3 edit
Differences ...
==== //depot/projects/dtrace/src/contrib/opensolaris/lib/libdtrace/common/dt_cc.c#3 (text) ====
@@ -1579,7 +1579,9 @@
char **argv = malloc(sizeof (char *) * (argc + 5));
FILE *ofp = tmpfile();
+#if defined(sun)
char ipath[20], opath[20]; /* big enough for /dev/fd/ + INT_MAX + \0 */
+#endif
char verdef[32]; /* big enough for -D__SUNW_D_VERSION=0x%08x + \0 */
struct sigaction act, oact;
@@ -1587,7 +1589,11 @@
int wstat, estat;
pid_t pid;
+#if defined(sun)
off64_t off;
+#else
+ off_t off = 0;
+#endif
int c;
if (argv == NULL || ofp == NULL) {
@@ -1614,8 +1620,10 @@
(void) fseeko64(ifp, off, SEEK_SET);
}
+#if defined(sun)
(void) snprintf(ipath, sizeof (ipath), "/dev/fd/%d", fileno(ifp));
(void) snprintf(opath, sizeof (opath), "/dev/fd/%d", fileno(ofp));
+#endif
bcopy(dtp->dt_cpp_argv, argv, sizeof (char *) * argc);
@@ -1623,6 +1631,7 @@
"-D__SUNW_D_VERSION=0x%08x", dtp->dt_vmax);
argv[argc++] = verdef;
+#if defined(sun)
switch (dtp->dt_stdcmode) {
case DT_STDC_XA:
case DT_STDC_XT:
@@ -1635,6 +1644,9 @@
argv[argc++] = ipath;
argv[argc++] = opath;
+#else
+ argv[argc++] = "-P";
+#endif
argv[argc] = NULL;
/*
@@ -1661,6 +1673,12 @@
}
if (pid == 0) {
+#if !defined(sun)
+ if (isatty(fileno(ifp)) == 0)
+ lseek(fileno(ifp), off, SEEK_SET);
+ dup2(fileno(ifp), 0);
+ dup2(fileno(ofp), 1);
+#endif
(void) execvp(dtp->dt_cpp_path, argv);
_exit(errno == ENOENT ? 127 : 126);
}
More information about the p4-projects
mailing list