Commit fde953c1 authored by Ingo Molnar's avatar Ingo Molnar

perf_counter tools: Remove dead code

Vince Weaver reported that there's a handful of #ifdef __MINGW32__
sections in the code.

Remove them as they are in essence dead code - as unlike upstream
Git, the perf tool is unlikely to be ported to Windows.
Reported-by: default avatarVince Weaver <vince@deater.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 19d2e755
...@@ -126,21 +126,6 @@ static int is_executable(const char *name) ...@@ -126,21 +126,6 @@ static int is_executable(const char *name)
!S_ISREG(st.st_mode)) !S_ISREG(st.st_mode))
return 0; return 0;
#ifdef __MINGW32__
/* cannot trust the executable bit, peek into the file instead */
char buf[3] = { 0 };
int n;
int fd = open(name, O_RDONLY);
st.st_mode &= ~S_IXUSR;
if (fd >= 0) {
n = read(fd, buf, 2);
if (n == 2)
/* DOS executables start with "MZ" */
if (!strcmp(buf, "#!") || !strcmp(buf, "MZ"))
st.st_mode |= S_IXUSR;
close(fd);
}
#endif
return st.st_mode & S_IXUSR; return st.st_mode & S_IXUSR;
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
static int spawned_pager; static int spawned_pager;
#ifndef __MINGW32__
static void pager_preexec(void) static void pager_preexec(void)
{ {
/* /*
...@@ -24,7 +23,6 @@ static void pager_preexec(void) ...@@ -24,7 +23,6 @@ static void pager_preexec(void)
setenv("LESS", "FRSX", 0); setenv("LESS", "FRSX", 0);
} }
#endif
static const char *pager_argv[] = { "sh", "-c", NULL, NULL }; static const char *pager_argv[] = { "sh", "-c", NULL, NULL };
static struct child_process pager_process; static struct child_process pager_process;
...@@ -70,9 +68,8 @@ void setup_pager(void) ...@@ -70,9 +68,8 @@ void setup_pager(void)
pager_argv[2] = pager; pager_argv[2] = pager;
pager_process.argv = pager_argv; pager_process.argv = pager_argv;
pager_process.in = -1; pager_process.in = -1;
#ifndef __MINGW32__
pager_process.preexec_cb = pager_preexec; pager_process.preexec_cb = pager_preexec;
#endif
if (start_command(&pager_process)) if (start_command(&pager_process))
return; return;
......
...@@ -65,7 +65,6 @@ int start_command(struct child_process *cmd) ...@@ -65,7 +65,6 @@ int start_command(struct child_process *cmd)
cmd->err = fderr[0]; cmd->err = fderr[0];
} }
#ifndef __MINGW32__
fflush(NULL); fflush(NULL);
cmd->pid = fork(); cmd->pid = fork();
if (!cmd->pid) { if (!cmd->pid) {
...@@ -118,71 +117,6 @@ int start_command(struct child_process *cmd) ...@@ -118,71 +117,6 @@ int start_command(struct child_process *cmd)
} }
exit(127); exit(127);
} }
#else
int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
const char **sargv = cmd->argv;
char **env = environ;
if (cmd->no_stdin) {
s0 = dup(0);
dup_devnull(0);
} else if (need_in) {
s0 = dup(0);
dup2(fdin[0], 0);
} else if (cmd->in) {
s0 = dup(0);
dup2(cmd->in, 0);
}
if (cmd->no_stderr) {
s2 = dup(2);
dup_devnull(2);
} else if (need_err) {
s2 = dup(2);
dup2(fderr[1], 2);
}
if (cmd->no_stdout) {
s1 = dup(1);
dup_devnull(1);
} else if (cmd->stdout_to_stderr) {
s1 = dup(1);
dup2(2, 1);
} else if (need_out) {
s1 = dup(1);
dup2(fdout[1], 1);
} else if (cmd->out > 1) {
s1 = dup(1);
dup2(cmd->out, 1);
}
if (cmd->dir)
die("chdir in start_command() not implemented");
if (cmd->env) {
env = copy_environ();
for (; *cmd->env; cmd->env++)
env = env_setenv(env, *cmd->env);
}
if (cmd->perf_cmd) {
cmd->argv = prepare_perf_cmd(cmd->argv);
}
cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env);
if (cmd->env)
free_environ(env);
if (cmd->perf_cmd)
free(cmd->argv);
cmd->argv = sargv;
if (s0 >= 0)
dup2(s0, 0), close(s0);
if (s1 >= 0)
dup2(s1, 1), close(s1);
if (s2 >= 0)
dup2(s2, 2), close(s2);
#endif
if (cmd->pid < 0) { if (cmd->pid < 0) {
int err = errno; int err = errno;
...@@ -288,14 +222,6 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const ...@@ -288,14 +222,6 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
return run_command(&cmd); return run_command(&cmd);
} }
#ifdef __MINGW32__
static __stdcall unsigned run_thread(void *data)
{
struct async *async = data;
return async->proc(async->fd_for_proc, async->data);
}
#endif
int start_async(struct async *async) int start_async(struct async *async)
{ {
int pipe_out[2]; int pipe_out[2];
...@@ -304,7 +230,6 @@ int start_async(struct async *async) ...@@ -304,7 +230,6 @@ int start_async(struct async *async)
return error("cannot create pipe: %s", strerror(errno)); return error("cannot create pipe: %s", strerror(errno));
async->out = pipe_out[0]; async->out = pipe_out[0];
#ifndef __MINGW32__
/* Flush stdio before fork() to avoid cloning buffers */ /* Flush stdio before fork() to avoid cloning buffers */
fflush(NULL); fflush(NULL);
...@@ -319,33 +244,17 @@ int start_async(struct async *async) ...@@ -319,33 +244,17 @@ int start_async(struct async *async)
exit(!!async->proc(pipe_out[1], async->data)); exit(!!async->proc(pipe_out[1], async->data));
} }
close(pipe_out[1]); close(pipe_out[1]);
#else
async->fd_for_proc = pipe_out[1];
async->tid = (HANDLE) _beginthreadex(NULL, 0, run_thread, async, 0, NULL);
if (!async->tid) {
error("cannot create thread: %s", strerror(errno));
close_pair(pipe_out);
return -1;
}
#endif
return 0; return 0;
} }
int finish_async(struct async *async) int finish_async(struct async *async)
{ {
#ifndef __MINGW32__
int ret = 0; int ret = 0;
if (wait_or_whine(async->pid)) if (wait_or_whine(async->pid))
ret = error("waitpid (async) failed"); ret = error("waitpid (async) failed");
#else
DWORD ret = 0;
if (WaitForSingleObject(async->tid, INFINITE) != WAIT_OBJECT_0)
ret = error("waiting for thread failed: %lu", GetLastError());
else if (!GetExitCodeThread(async->tid, &ret))
ret = error("cannot get thread exit code: %lu", GetLastError());
CloseHandle(async->tid);
#endif
return ret; return ret;
} }
......
...@@ -79,12 +79,7 @@ struct async { ...@@ -79,12 +79,7 @@ struct async {
int (*proc)(int fd, void *data); int (*proc)(int fd, void *data);
void *data; void *data;
int out; /* caller reads from here and closes it */ int out; /* caller reads from here and closes it */
#ifndef __MINGW32__
pid_t pid; pid_t pid;
#else
HANDLE tid;
int fd_for_proc;
#endif
}; };
int start_async(struct async *async); int start_async(struct async *async);
......
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
#include <assert.h> #include <assert.h>
#include <regex.h> #include <regex.h>
#include <utime.h> #include <utime.h>
#ifndef __MINGW32__
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <sys/socket.h> #include <sys/socket.h>
...@@ -81,20 +80,6 @@ ...@@ -81,20 +80,6 @@
#include <netdb.h> #include <netdb.h>
#include <pwd.h> #include <pwd.h>
#include <inttypes.h> #include <inttypes.h>
#if defined(__CYGWIN__)
#undef _XOPEN_SOURCE
#include <grp.h>
#define _XOPEN_SOURCE 600
#include "compat/cygwin.h"
#else
#undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
#include <grp.h>
#define _ALL_SOURCE 1
#endif
#else /* __MINGW32__ */
/* pull in Windows compatibility stuff */
#include "compat/mingw.h"
#endif /* __MINGW32__ */
#ifndef NO_ICONV #ifndef NO_ICONV
#include <iconv.h> #include <iconv.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment