cache.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /* pager.c */
  23. extern void setup_pager(void);
  24. extern const char *pager_program;
  25. extern int pager_in_use(void);
  26. extern int pager_use_color;
  27. extern int use_browser;
  28. #ifdef NO_NEWT_SUPPORT
  29. static inline void setup_browser(void)
  30. {
  31. setup_pager();
  32. }
  33. static inline void exit_browser(bool wait_for_ok __used) {}
  34. #else
  35. void setup_browser(void);
  36. void exit_browser(bool wait_for_ok);
  37. #endif
  38. char *alias_lookup(const char *alias);
  39. int split_cmdline(char *cmdline, const char ***argv);
  40. #define alloc_nr(x) (((x)+16)*3/2)
  41. /*
  42. * Realloc the buffer pointed at by variable 'x' so that it can hold
  43. * at least 'nr' entries; the number of entries currently allocated
  44. * is 'alloc', using the standard growing factor alloc_nr() macro.
  45. *
  46. * DO NOT USE any expression with side-effect for 'x' or 'alloc'.
  47. */
  48. #define ALLOC_GROW(x, nr, alloc) \
  49. do { \
  50. if ((nr) > alloc) { \
  51. if (alloc_nr(alloc) < (nr)) \
  52. alloc = (nr); \
  53. else \
  54. alloc = alloc_nr(alloc); \
  55. x = xrealloc((x), alloc * sizeof(*(x))); \
  56. } \
  57. } while(0)
  58. static inline int is_absolute_path(const char *path)
  59. {
  60. return path[0] == '/';
  61. }
  62. const char *make_nonrelative_path(const char *path);
  63. char *strip_path_suffix(const char *path, const char *suffix);
  64. extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
  65. extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
  66. extern char *perf_pathdup(const char *fmt, ...)
  67. __attribute__((format (printf, 1, 2)));
  68. extern size_t strlcpy(char *dest, const char *src, size_t size);
  69. #endif /* __PERF_CACHE_H */