cache.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef __PERF_CACHE_H
  2. #define __PERF_CACHE_H
  3. #include <stdbool.h>
  4. #include "util.h"
  5. #include "strbuf.h"
  6. #include "../perf.h"
  7. #define CMD_EXEC_PATH "--exec-path"
  8. #define CMD_PERF_DIR "--perf-dir="
  9. #define CMD_WORK_TREE "--work-tree="
  10. #define CMD_DEBUGFS_DIR "--debugfs-dir="
  11. #define PERF_DIR_ENVIRONMENT "PERF_DIR"
  12. #define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"
  13. #define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
  14. #define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
  15. #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
  16. typedef int (*config_fn_t)(const char *, const char *, void *);
  17. extern int perf_default_config(const char *, const char *, void *);
  18. extern int perf_config(config_fn_t fn, void *);
  19. extern int perf_config_int(const char *, const char *);
  20. extern int perf_config_bool(const char *, const char *);
  21. extern int config_error_nonbool(const char *);
  22. extern const char *perf_config_dirname(const char *, const char *);
  23. /* pager.c */
  24. extern void setup_pager(void);
  25. extern const char *pager_program;
  26. extern int pager_in_use(void);
  27. extern int pager_use_color;
  28. extern int use_browser;
  29. #ifdef NO_NEWT_SUPPORT
  30. static inline void setup_browser(void)
  31. {
  32. setup_pager();
  33. }
  34. static inline void exit_browser(bool wait_for_ok __used) {}
  35. #else
  36. void setup_browser(void);
  37. void exit_browser(bool wait_for_ok);
  38. #endif
  39. char *alias_lookup(const char *alias);
  40. int split_cmdline(char *cmdline, const char ***argv);
  41. #define alloc_nr(x) (((x)+16)*3/2)
  42. /*
  43. * Realloc the buffer pointed at by variable 'x' so that it can hold
  44. * at least 'nr' entries; the number of entries currently allocated
  45. * is 'alloc', using the standard growing factor alloc_nr() macro.
  46. *
  47. * DO NOT USE any expression with side-effect for 'x' or 'alloc'.
  48. */
  49. #define ALLOC_GROW(x, nr, alloc) \
  50. do { \
  51. if ((nr) > alloc) { \
  52. if (alloc_nr(alloc) < (nr)) \
  53. alloc = (nr); \
  54. else \
  55. alloc = alloc_nr(alloc); \
  56. x = xrealloc((x), alloc * sizeof(*(x))); \
  57. } \
  58. } while(0)
  59. static inline int is_absolute_path(const char *path)
  60. {
  61. return path[0] == '/';
  62. }
  63. const char *make_nonrelative_path(const char *path);
  64. char *strip_path_suffix(const char *path, const char *suffix);
  65. extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
  66. extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
  67. extern char *perf_pathdup(const char *fmt, ...)
  68. __attribute__((format (printf, 1, 2)));
  69. extern size_t strlcpy(char *dest, const char *src, size_t size);
  70. #endif /* __PERF_CACHE_H */