Skip to content

Commit a41794c

Browse files
committed
perf tools: Remove some unused functions
Without the bloated cplus_demangle from binutils, i.e building with: $ make NO_DEMANGLE=1 O=~acme/git/build/perf -j3 -C tools/perf/ install Before: text data bss dec hex filename 471851 29280 4025056 4526187 45106b /home/acme/bin/perf After: [acme@doppio linux-2.6-tip]$ size ~/bin/perf text data bss dec hex filename 446886 29232 4008576 4484694 446e56 /home/acme/bin/perf So its a 5.3% size reduction in code, but the interesting part is in the git diff --stat output: 19 files changed, 20 insertions(+), 1909 deletions(-) If we ever need some of the things we got from git but weren't using, we just have to go to the git repo and get fresh, uptodate source code bits. Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 5af52b5 commit a41794c

19 files changed

Lines changed: 20 additions & 1909 deletions

‎tools/perf/builtin-record.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <unistd.h>
2727
#include <sched.h>
28+
#include <sys/mman.h>
2829

2930
enum write_mode_t {
3031
WRITE_FORCE,

‎tools/perf/util/abspath.c‎

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,5 @@
11
#include "cache.h"
22

3-
/*
4-
* Do not use this for inspecting *tracked* content. When path is a
5-
* symlink to a directory, we do not want to say it is a directory when
6-
* dealing with tracked content in the working tree.
7-
*/
8-
static int is_directory(const char *path)
9-
{
10-
struct stat st;
11-
return (!stat(path, &st) && S_ISDIR(st.st_mode));
12-
}
13-
14-
/* We allow "recursive" symbolic links. Only within reason, though. */
15-
#define MAXDEPTH 5
16-
17-
const char *make_absolute_path(const char *path)
18-
{
19-
static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
20-
char cwd[1024] = "";
21-
int buf_index = 1, len;
22-
23-
int depth = MAXDEPTH;
24-
char *last_elem = NULL;
25-
struct stat st;
26-
27-
if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
28-
die ("Too long path: %.*s", 60, path);
29-
30-
while (depth--) {
31-
if (!is_directory(buf)) {
32-
char *last_slash = strrchr(buf, '/');
33-
if (last_slash) {
34-
*last_slash = '\0';
35-
last_elem = xstrdup(last_slash + 1);
36-
} else {
37-
last_elem = xstrdup(buf);
38-
*buf = '\0';
39-
}
40-
}
41-
42-
if (*buf) {
43-
if (!*cwd && !getcwd(cwd, sizeof(cwd)))
44-
die ("Could not get current working directory");
45-
46-
if (chdir(buf))
47-
die ("Could not switch to '%s'", buf);
48-
}
49-
if (!getcwd(buf, PATH_MAX))
50-
die ("Could not get current working directory");
51-
52-
if (last_elem) {
53-
len = strlen(buf);
54-
55-
if (len + strlen(last_elem) + 2 > PATH_MAX)
56-
die ("Too long path name: '%s/%s'",
57-
buf, last_elem);
58-
buf[len] = '/';
59-
strcpy(buf + len + 1, last_elem);
60-
free(last_elem);
61-
last_elem = NULL;
62-
}
63-
64-
if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
65-
len = readlink(buf, next_buf, PATH_MAX);
66-
if (len < 0)
67-
die ("Invalid symlink: %s", buf);
68-
if (PATH_MAX <= len)
69-
die("symbolic link too long: %s", buf);
70-
next_buf[len] = '\0';
71-
buf = next_buf;
72-
buf_index = 1 - buf_index;
73-
next_buf = bufs[buf_index];
74-
} else
75-
break;
76-
}
77-
78-
if (*cwd && chdir(cwd))
79-
die ("Could not change back to '%s'", cwd);
80-
81-
return buf;
82-
}
83-
843
static const char *get_pwd_cwd(void)
854
{
865
static char cwd[PATH_MAX + 1];

‎tools/perf/util/cache.h‎

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,16 @@
1313

1414
#define PERF_DIR_ENVIRONMENT "PERF_DIR"
1515
#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"
16-
#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
17-
#define DB_ENVIRONMENT "PERF_OBJECT_DIRECTORY"
18-
#define INDEX_ENVIRONMENT "PERF_INDEX_FILE"
19-
#define GRAFT_ENVIRONMENT "PERF_GRAFT_FILE"
20-
#define TEMPLATE_DIR_ENVIRONMENT "PERF_TEMPLATE_DIR"
21-
#define CONFIG_ENVIRONMENT "PERF_CONFIG"
2216
#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
23-
#define CEILING_DIRECTORIES_ENVIRONMENT "PERF_CEILING_DIRECTORIES"
24-
#define PERFATTRIBUTES_FILE ".perfattributes"
25-
#define INFOATTRIBUTES_FILE "info/attributes"
26-
#define ATTRIBUTE_MACRO_PREFIX "[attr]"
17+
#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
2718
#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
2819

2920
typedef int (*config_fn_t)(const char *, const char *, void *);
3021
extern int perf_default_config(const char *, const char *, void *);
31-
extern int perf_config_from_file(config_fn_t fn, const char *, void *);
3222
extern int perf_config(config_fn_t fn, void *);
33-
extern int perf_parse_ulong(const char *, unsigned long *);
3423
extern int perf_config_int(const char *, const char *);
35-
extern unsigned long perf_config_ulong(const char *, const char *);
36-
extern int perf_config_bool_or_int(const char *, const char *, int *);
3724
extern int perf_config_bool(const char *, const char *);
38-
extern int perf_config_string(const char **, const char *, const char *);
39-
extern int perf_config_set(const char *, const char *);
40-
extern int perf_config_set_multivar(const char *, const char *, const char *, int);
41-
extern int perf_config_rename_section(const char *, const char *);
42-
extern const char *perf_etc_perfconfig(void);
43-
extern int check_repository_format_version(const char *var, const char *value, void *cb);
44-
extern int perf_config_system(void);
45-
extern int perf_config_global(void);
4625
extern int config_error_nonbool(const char *);
47-
extern const char *config_exclusive_filename;
48-
49-
#define MAX_PERFNAME (1000)
50-
extern char perf_default_email[MAX_PERFNAME];
51-
extern char perf_default_name[MAX_PERFNAME];
52-
extern int user_ident_explicitly_given;
53-
54-
extern const char *perf_log_output_encoding;
55-
extern const char *perf_mailmap_file;
56-
57-
/* IO helper functions */
58-
extern void maybe_flush_or_die(FILE *, const char *);
59-
extern int copy_fd(int ifd, int ofd);
60-
extern int copy_file(const char *dst, const char *src, int mode);
61-
extern ssize_t write_in_full(int fd, const void *buf, size_t count);
62-
extern void write_or_die(int fd, const void *buf, size_t count);
63-
extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
64-
extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
65-
extern void fsync_or_die(int fd, const char *);
6626

6727
/* pager.c */
6828
extern void setup_pager(void);
@@ -83,9 +43,6 @@ void setup_browser(void);
8343
void exit_browser(bool wait_for_ok);
8444
#endif
8545

86-
extern const char *editor_program;
87-
extern const char *excludes_file;
88-
8946
char *alias_lookup(const char *alias);
9047
int split_cmdline(char *cmdline, const char ***argv);
9148

@@ -115,22 +72,12 @@ static inline int is_absolute_path(const char *path)
11572
return path[0] == '/';
11673
}
11774

118-
const char *make_absolute_path(const char *path);
11975
const char *make_nonrelative_path(const char *path);
120-
const char *make_relative_path(const char *abs, const char *base);
121-
int normalize_path_copy(char *dst, const char *src);
122-
int longest_ancestor_length(const char *path, const char *prefix_list);
12376
char *strip_path_suffix(const char *path, const char *suffix);
12477

12578
extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
12679
extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
127-
/* perf_mkstemp() - create tmp file honoring TMPDIR variable */
128-
extern int perf_mkstemp(char *path, size_t len, const char *template);
12980

130-
extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
131-
__attribute__((format (printf, 3, 4)));
132-
extern char *perf_snpath(char *buf, size_t n, const char *fmt, ...)
133-
__attribute__((format (printf, 3, 4)));
13481
extern char *perf_pathdup(const char *fmt, ...)
13582
__attribute__((format (printf, 1, 2)));
13683

0 commit comments

Comments
 (0)