Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Vince 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: Ingo Molnar <mingo@elte.hu>

+3 -132
-15
tools/perf/util/help.c
··· 126 126 !S_ISREG(st.st_mode)) 127 127 return 0; 128 128 129 - #ifdef __MINGW32__ 130 - /* cannot trust the executable bit, peek into the file instead */ 131 - char buf[3] = { 0 }; 132 - int n; 133 - int fd = open(name, O_RDONLY); 134 - st.st_mode &= ~S_IXUSR; 135 - if (fd >= 0) { 136 - n = read(fd, buf, 2); 137 - if (n == 2) 138 - /* DOS executables start with "MZ" */ 139 - if (!strcmp(buf, "#!") || !strcmp(buf, "MZ")) 140 - st.st_mode |= S_IXUSR; 141 - close(fd); 142 - } 143 - #endif 144 129 return st.st_mode & S_IXUSR; 145 130 } 146 131
+1 -4
tools/perf/util/pager.c
··· 9 9 10 10 static int spawned_pager; 11 11 12 - #ifndef __MINGW32__ 13 12 static void pager_preexec(void) 14 13 { 15 14 /* ··· 23 24 24 25 setenv("LESS", "FRSX", 0); 25 26 } 26 - #endif 27 27 28 28 static const char *pager_argv[] = { "sh", "-c", NULL, NULL }; 29 29 static struct child_process pager_process; ··· 68 70 pager_argv[2] = pager; 69 71 pager_process.argv = pager_argv; 70 72 pager_process.in = -1; 71 - #ifndef __MINGW32__ 72 73 pager_process.preexec_cb = pager_preexec; 73 - #endif 74 + 74 75 if (start_command(&pager_process)) 75 76 return; 76 77
+2 -93
tools/perf/util/run-command.c
··· 65 65 cmd->err = fderr[0]; 66 66 } 67 67 68 - #ifndef __MINGW32__ 69 68 fflush(NULL); 70 69 cmd->pid = fork(); 71 70 if (!cmd->pid) { ··· 117 118 } 118 119 exit(127); 119 120 } 120 - #else 121 - int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */ 122 - const char **sargv = cmd->argv; 123 - char **env = environ; 124 - 125 - if (cmd->no_stdin) { 126 - s0 = dup(0); 127 - dup_devnull(0); 128 - } else if (need_in) { 129 - s0 = dup(0); 130 - dup2(fdin[0], 0); 131 - } else if (cmd->in) { 132 - s0 = dup(0); 133 - dup2(cmd->in, 0); 134 - } 135 - 136 - if (cmd->no_stderr) { 137 - s2 = dup(2); 138 - dup_devnull(2); 139 - } else if (need_err) { 140 - s2 = dup(2); 141 - dup2(fderr[1], 2); 142 - } 143 - 144 - if (cmd->no_stdout) { 145 - s1 = dup(1); 146 - dup_devnull(1); 147 - } else if (cmd->stdout_to_stderr) { 148 - s1 = dup(1); 149 - dup2(2, 1); 150 - } else if (need_out) { 151 - s1 = dup(1); 152 - dup2(fdout[1], 1); 153 - } else if (cmd->out > 1) { 154 - s1 = dup(1); 155 - dup2(cmd->out, 1); 156 - } 157 - 158 - if (cmd->dir) 159 - die("chdir in start_command() not implemented"); 160 - if (cmd->env) { 161 - env = copy_environ(); 162 - for (; *cmd->env; cmd->env++) 163 - env = env_setenv(env, *cmd->env); 164 - } 165 - 166 - if (cmd->perf_cmd) { 167 - cmd->argv = prepare_perf_cmd(cmd->argv); 168 - } 169 - 170 - cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env); 171 - 172 - if (cmd->env) 173 - free_environ(env); 174 - if (cmd->perf_cmd) 175 - free(cmd->argv); 176 - 177 - cmd->argv = sargv; 178 - if (s0 >= 0) 179 - dup2(s0, 0), close(s0); 180 - if (s1 >= 0) 181 - dup2(s1, 1), close(s1); 182 - if (s2 >= 0) 183 - dup2(s2, 2), close(s2); 184 - #endif 185 121 186 122 if (cmd->pid < 0) { 187 123 int err = errno; ··· 222 288 return run_command(&cmd); 223 289 } 224 290 225 - #ifdef __MINGW32__ 226 - static __stdcall unsigned run_thread(void *data) 227 - { 228 - struct async *async = data; 229 - return async->proc(async->fd_for_proc, async->data); 230 - } 231 - #endif 232 - 233 291 int start_async(struct async *async) 234 292 { 235 293 int pipe_out[2]; ··· 230 304 return error("cannot create pipe: %s", strerror(errno)); 231 305 async->out = pipe_out[0]; 232 306 233 - #ifndef __MINGW32__ 234 307 /* Flush stdio before fork() to avoid cloning buffers */ 235 308 fflush(NULL); 236 309 ··· 244 319 exit(!!async->proc(pipe_out[1], async->data)); 245 320 } 246 321 close(pipe_out[1]); 247 - #else 248 - async->fd_for_proc = pipe_out[1]; 249 - async->tid = (HANDLE) _beginthreadex(NULL, 0, run_thread, async, 0, NULL); 250 - if (!async->tid) { 251 - error("cannot create thread: %s", strerror(errno)); 252 - close_pair(pipe_out); 253 - return -1; 254 - } 255 - #endif 322 + 256 323 return 0; 257 324 } 258 325 259 326 int finish_async(struct async *async) 260 327 { 261 - #ifndef __MINGW32__ 262 328 int ret = 0; 263 329 264 330 if (wait_or_whine(async->pid)) 265 331 ret = error("waitpid (async) failed"); 266 - #else 267 - DWORD ret = 0; 268 - if (WaitForSingleObject(async->tid, INFINITE) != WAIT_OBJECT_0) 269 - ret = error("waiting for thread failed: %lu", GetLastError()); 270 - else if (!GetExitCodeThread(async->tid, &ret)) 271 - ret = error("cannot get thread exit code: %lu", GetLastError()); 272 - CloseHandle(async->tid); 273 - #endif 332 + 274 333 return ret; 275 334 } 276 335
-5
tools/perf/util/run-command.h
··· 79 79 int (*proc)(int fd, void *data); 80 80 void *data; 81 81 int out; /* caller reads from here and closes it */ 82 - #ifndef __MINGW32__ 83 82 pid_t pid; 84 - #else 85 - HANDLE tid; 86 - int fd_for_proc; 87 - #endif 88 83 }; 89 84 90 85 int start_async(struct async *async);
-15
tools/perf/util/util.h
··· 67 67 #include <assert.h> 68 68 #include <regex.h> 69 69 #include <utime.h> 70 - #ifndef __MINGW32__ 71 70 #include <sys/wait.h> 72 71 #include <sys/poll.h> 73 72 #include <sys/socket.h> ··· 80 81 #include <netdb.h> 81 82 #include <pwd.h> 82 83 #include <inttypes.h> 83 - #if defined(__CYGWIN__) 84 - #undef _XOPEN_SOURCE 85 - #include <grp.h> 86 - #define _XOPEN_SOURCE 600 87 - #include "compat/cygwin.h" 88 - #else 89 - #undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */ 90 - #include <grp.h> 91 - #define _ALL_SOURCE 1 92 - #endif 93 - #else /* __MINGW32__ */ 94 - /* pull in Windows compatibility stuff */ 95 - #include "compat/mingw.h" 96 - #endif /* __MINGW32__ */ 97 84 98 85 #ifndef NO_ICONV 99 86 #include <iconv.h>