at v2.6.31 4.7 kB view raw
1#ifndef CACHE_H 2#define CACHE_H 3 4#include "util.h" 5#include "strbuf.h" 6#include "../perf.h" 7 8#define PERF_DIR_ENVIRONMENT "PERF_DIR" 9#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE" 10#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf" 11#define DB_ENVIRONMENT "PERF_OBJECT_DIRECTORY" 12#define INDEX_ENVIRONMENT "PERF_INDEX_FILE" 13#define GRAFT_ENVIRONMENT "PERF_GRAFT_FILE" 14#define TEMPLATE_DIR_ENVIRONMENT "PERF_TEMPLATE_DIR" 15#define CONFIG_ENVIRONMENT "PERF_CONFIG" 16#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH" 17#define CEILING_DIRECTORIES_ENVIRONMENT "PERF_CEILING_DIRECTORIES" 18#define PERFATTRIBUTES_FILE ".perfattributes" 19#define INFOATTRIBUTES_FILE "info/attributes" 20#define ATTRIBUTE_MACRO_PREFIX "[attr]" 21#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" 22 23typedef int (*config_fn_t)(const char *, const char *, void *); 24extern int perf_default_config(const char *, const char *, void *); 25extern int perf_config_from_file(config_fn_t fn, const char *, void *); 26extern int perf_config(config_fn_t fn, void *); 27extern int perf_parse_ulong(const char *, unsigned long *); 28extern int perf_config_int(const char *, const char *); 29extern unsigned long perf_config_ulong(const char *, const char *); 30extern int perf_config_bool_or_int(const char *, const char *, int *); 31extern int perf_config_bool(const char *, const char *); 32extern int perf_config_string(const char **, const char *, const char *); 33extern int perf_config_set(const char *, const char *); 34extern int perf_config_set_multivar(const char *, const char *, const char *, int); 35extern int perf_config_rename_section(const char *, const char *); 36extern const char *perf_etc_perfconfig(void); 37extern int check_repository_format_version(const char *var, const char *value, void *cb); 38extern int perf_config_system(void); 39extern int perf_config_global(void); 40extern int config_error_nonbool(const char *); 41extern const char *config_exclusive_filename; 42 43#define MAX_PERFNAME (1000) 44extern char perf_default_email[MAX_PERFNAME]; 45extern char perf_default_name[MAX_PERFNAME]; 46extern int user_ident_explicitly_given; 47 48extern const char *perf_log_output_encoding; 49extern const char *perf_mailmap_file; 50 51/* IO helper functions */ 52extern void maybe_flush_or_die(FILE *, const char *); 53extern int copy_fd(int ifd, int ofd); 54extern int copy_file(const char *dst, const char *src, int mode); 55extern ssize_t read_in_full(int fd, void *buf, size_t count); 56extern ssize_t write_in_full(int fd, const void *buf, size_t count); 57extern void write_or_die(int fd, const void *buf, size_t count); 58extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg); 59extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg); 60extern void fsync_or_die(int fd, const char *); 61 62/* pager.c */ 63extern void setup_pager(void); 64extern const char *pager_program; 65extern int pager_in_use(void); 66extern int pager_use_color; 67 68extern const char *editor_program; 69extern const char *excludes_file; 70 71char *alias_lookup(const char *alias); 72int split_cmdline(char *cmdline, const char ***argv); 73 74#define alloc_nr(x) (((x)+16)*3/2) 75 76/* 77 * Realloc the buffer pointed at by variable 'x' so that it can hold 78 * at least 'nr' entries; the number of entries currently allocated 79 * is 'alloc', using the standard growing factor alloc_nr() macro. 80 * 81 * DO NOT USE any expression with side-effect for 'x' or 'alloc'. 82 */ 83#define ALLOC_GROW(x, nr, alloc) \ 84 do { \ 85 if ((nr) > alloc) { \ 86 if (alloc_nr(alloc) < (nr)) \ 87 alloc = (nr); \ 88 else \ 89 alloc = alloc_nr(alloc); \ 90 x = xrealloc((x), alloc * sizeof(*(x))); \ 91 } \ 92 } while(0) 93 94 95static inline int is_absolute_path(const char *path) 96{ 97 return path[0] == '/'; 98} 99 100const char *make_absolute_path(const char *path); 101const char *make_nonrelative_path(const char *path); 102const char *make_relative_path(const char *abs, const char *base); 103int normalize_path_copy(char *dst, const char *src); 104int longest_ancestor_length(const char *path, const char *prefix_list); 105char *strip_path_suffix(const char *path, const char *suffix); 106 107extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2))); 108extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2))); 109/* perf_mkstemp() - create tmp file honoring TMPDIR variable */ 110extern int perf_mkstemp(char *path, size_t len, const char *template); 111 112extern char *mksnpath(char *buf, size_t n, const char *fmt, ...) 113 __attribute__((format (printf, 3, 4))); 114extern char *perf_snpath(char *buf, size_t n, const char *fmt, ...) 115 __attribute__((format (printf, 3, 4))); 116extern char *perf_pathdup(const char *fmt, ...) 117 __attribute__((format (printf, 1, 2))); 118 119extern size_t strlcpy(char *dest, const char *src, size_t size); 120 121#endif /* CACHE_H */