Skip to content

Commit

Permalink
perf tools: Remove some unused functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed May 19, 2010
1 parent 5af52b5 commit a41794c
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 1,909 deletions.
1 change: 1 addition & 0 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <unistd.h>
#include <sched.h>
#include <sys/mman.h>

enum write_mode_t {
WRITE_FORCE,
Expand Down
81 changes: 0 additions & 81 deletions tools/perf/util/abspath.c
Original file line number Diff line number Diff line change
@@ -1,86 +1,5 @@
#include "cache.h"

/*
* Do not use this for inspecting *tracked* content. When path is a
* symlink to a directory, we do not want to say it is a directory when
* dealing with tracked content in the working tree.
*/
static int is_directory(const char *path)
{
struct stat st;
return (!stat(path, &st) && S_ISDIR(st.st_mode));
}

/* We allow "recursive" symbolic links. Only within reason, though. */
#define MAXDEPTH 5

const char *make_absolute_path(const char *path)
{
static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
char cwd[1024] = "";
int buf_index = 1, len;

int depth = MAXDEPTH;
char *last_elem = NULL;
struct stat st;

if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
die ("Too long path: %.*s", 60, path);

while (depth--) {
if (!is_directory(buf)) {
char *last_slash = strrchr(buf, '/');
if (last_slash) {
*last_slash = '\0';
last_elem = xstrdup(last_slash + 1);
} else {
last_elem = xstrdup(buf);
*buf = '\0';
}
}

if (*buf) {
if (!*cwd && !getcwd(cwd, sizeof(cwd)))
die ("Could not get current working directory");

if (chdir(buf))
die ("Could not switch to '%s'", buf);
}
if (!getcwd(buf, PATH_MAX))
die ("Could not get current working directory");

if (last_elem) {
len = strlen(buf);

if (len + strlen(last_elem) + 2 > PATH_MAX)
die ("Too long path name: '%s/%s'",
buf, last_elem);
buf[len] = '/';
strcpy(buf + len + 1, last_elem);
free(last_elem);
last_elem = NULL;
}

if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
len = readlink(buf, next_buf, PATH_MAX);
if (len < 0)
die ("Invalid symlink: %s", buf);
if (PATH_MAX <= len)
die("symbolic link too long: %s", buf);
next_buf[len] = '\0';
buf = next_buf;
buf_index = 1 - buf_index;
next_buf = bufs[buf_index];
} else
break;
}

if (*cwd && chdir(cwd))
die ("Could not change back to '%s'", cwd);

return buf;
}

static const char *get_pwd_cwd(void)
{
static char cwd[PATH_MAX + 1];
Expand Down
55 changes: 1 addition & 54 deletions tools/perf/util/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,16 @@

#define PERF_DIR_ENVIRONMENT "PERF_DIR"
#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"
#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
#define DB_ENVIRONMENT "PERF_OBJECT_DIRECTORY"
#define INDEX_ENVIRONMENT "PERF_INDEX_FILE"
#define GRAFT_ENVIRONMENT "PERF_GRAFT_FILE"
#define TEMPLATE_DIR_ENVIRONMENT "PERF_TEMPLATE_DIR"
#define CONFIG_ENVIRONMENT "PERF_CONFIG"
#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
#define CEILING_DIRECTORIES_ENVIRONMENT "PERF_CEILING_DIRECTORIES"
#define PERFATTRIBUTES_FILE ".perfattributes"
#define INFOATTRIBUTES_FILE "info/attributes"
#define ATTRIBUTE_MACRO_PREFIX "[attr]"
#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"

typedef int (*config_fn_t)(const char *, const char *, void *);
extern int perf_default_config(const char *, const char *, void *);
extern int perf_config_from_file(config_fn_t fn, const char *, void *);
extern int perf_config(config_fn_t fn, void *);
extern int perf_parse_ulong(const char *, unsigned long *);
extern int perf_config_int(const char *, const char *);
extern unsigned long perf_config_ulong(const char *, const char *);
extern int perf_config_bool_or_int(const char *, const char *, int *);
extern int perf_config_bool(const char *, const char *);
extern int perf_config_string(const char **, const char *, const char *);
extern int perf_config_set(const char *, const char *);
extern int perf_config_set_multivar(const char *, const char *, const char *, int);
extern int perf_config_rename_section(const char *, const char *);
extern const char *perf_etc_perfconfig(void);
extern int check_repository_format_version(const char *var, const char *value, void *cb);
extern int perf_config_system(void);
extern int perf_config_global(void);
extern int config_error_nonbool(const char *);
extern const char *config_exclusive_filename;

#define MAX_PERFNAME (1000)
extern char perf_default_email[MAX_PERFNAME];
extern char perf_default_name[MAX_PERFNAME];
extern int user_ident_explicitly_given;

extern const char *perf_log_output_encoding;
extern const char *perf_mailmap_file;

/* IO helper functions */
extern void maybe_flush_or_die(FILE *, const char *);
extern int copy_fd(int ifd, int ofd);
extern int copy_file(const char *dst, const char *src, int mode);
extern ssize_t write_in_full(int fd, const void *buf, size_t count);
extern void write_or_die(int fd, const void *buf, size_t count);
extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
extern void fsync_or_die(int fd, const char *);

/* pager.c */
extern void setup_pager(void);
Expand All @@ -83,9 +43,6 @@ void setup_browser(void);
void exit_browser(bool wait_for_ok);
#endif

extern const char *editor_program;
extern const char *excludes_file;

char *alias_lookup(const char *alias);
int split_cmdline(char *cmdline, const char ***argv);

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

const char *make_absolute_path(const char *path);
const char *make_nonrelative_path(const char *path);
const char *make_relative_path(const char *abs, const char *base);
int normalize_path_copy(char *dst, const char *src);
int longest_ancestor_length(const char *path, const char *prefix_list);
char *strip_path_suffix(const char *path, const char *suffix);

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

extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
extern char *perf_snpath(char *buf, size_t n, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
extern char *perf_pathdup(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));

Expand Down
Loading

0 comments on commit a41794c

Please sign in to comment.