aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/util.h')
-rw-r--r--tools/perf/util/util.h154
1 files changed, 0 insertions, 154 deletions
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 0795bf304b19..52118a0c0bad 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -152,7 +152,6 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)))
152extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN); 152extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);
153 153
154extern int prefixcmp(const char *str, const char *prefix); 154extern int prefixcmp(const char *str, const char *prefix);
155extern time_t tm_to_time_t(const struct tm *tm);
156 155
157static inline const char *skip_prefix(const char *str, const char *prefix) 156static inline const char *skip_prefix(const char *str, const char *prefix)
158{ 157{
@@ -160,119 +159,6 @@ static inline const char *skip_prefix(const char *str, const char *prefix)
160 return strncmp(str, prefix, len) ? NULL : str + len; 159 return strncmp(str, prefix, len) ? NULL : str + len;
161} 160}
162 161
163#if defined(NO_MMAP) || defined(USE_WIN32_MMAP)
164
165#ifndef PROT_READ
166#define PROT_READ 1
167#define PROT_WRITE 2
168#define MAP_PRIVATE 1
169#define MAP_FAILED ((void*)-1)
170#endif
171
172#define mmap git_mmap
173#define munmap git_munmap
174extern void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
175extern int git_munmap(void *start, size_t length);
176
177#else /* NO_MMAP || USE_WIN32_MMAP */
178
179#include <sys/mman.h>
180
181#endif /* NO_MMAP || USE_WIN32_MMAP */
182
183#ifdef NO_MMAP
184
185/* This value must be multiple of (pagesize * 2) */
186#define DEFAULT_PACKED_GIT_WINDOW_SIZE (1 * 1024 * 1024)
187
188#else /* NO_MMAP */
189
190/* This value must be multiple of (pagesize * 2) */
191#define DEFAULT_PACKED_GIT_WINDOW_SIZE \
192 (sizeof(void*) >= 8 \
193 ? 1 * 1024 * 1024 * 1024 \
194 : 32 * 1024 * 1024)
195
196#endif /* NO_MMAP */
197
198#ifdef NO_ST_BLOCKS_IN_STRUCT_STAT
199#define on_disk_bytes(st) ((st).st_size)
200#else
201#define on_disk_bytes(st) ((st).st_blocks * 512)
202#endif
203
204#define DEFAULT_PACKED_GIT_LIMIT \
205 ((1024L * 1024L) * (sizeof(void*) >= 8 ? 8192 : 256))
206
207#ifdef NO_PREAD
208#define pread git_pread
209extern ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
210#endif
211/*
212 * Forward decl that will remind us if its twin in cache.h changes.
213 * This function is used in compat/pread.c. But we can't include
214 * cache.h there.
215 */
216extern ssize_t read_in_full(int fd, void *buf, size_t count);
217
218#ifdef NO_SETENV
219#define setenv gitsetenv
220extern int gitsetenv(const char *, const char *, int);
221#endif
222
223#ifdef NO_MKDTEMP
224#define mkdtemp gitmkdtemp
225extern char *gitmkdtemp(char *);
226#endif
227
228#ifdef NO_UNSETENV
229#define unsetenv gitunsetenv
230extern void gitunsetenv(const char *);
231#endif
232
233#ifdef NO_STRCASESTR
234#define strcasestr gitstrcasestr
235extern char *gitstrcasestr(const char *haystack, const char *needle);
236#endif
237
238#ifdef NO_STRLCPY
239#define strlcpy gitstrlcpy
240extern size_t gitstrlcpy(char *, const char *, size_t);
241#endif
242
243#ifdef NO_STRTOUMAX
244#define strtoumax gitstrtoumax
245extern uintmax_t gitstrtoumax(const char *, char **, int);
246#endif
247
248#ifdef NO_HSTRERROR
249#define hstrerror githstrerror
250extern const char *githstrerror(int herror);
251#endif
252
253#ifdef NO_MEMMEM
254#define memmem gitmemmem
255void *gitmemmem(const void *haystack, size_t haystacklen,
256 const void *needle, size_t needlelen);
257#endif
258
259#ifdef FREAD_READS_DIRECTORIES
260#ifdef fopen
261#undef fopen
262#endif
263#define fopen(a,b) git_fopen(a,b)
264extern FILE *git_fopen(const char*, const char*);
265#endif
266
267#ifdef SNPRINTF_RETURNS_BOGUS
268#define snprintf git_snprintf
269extern int git_snprintf(char *str, size_t maxsize,
270 const char *format, ...);
271#define vsnprintf git_vsnprintf
272extern int git_vsnprintf(char *str, size_t maxsize,
273 const char *format, va_list ap);
274#endif
275
276#ifdef __GLIBC_PREREQ 162#ifdef __GLIBC_PREREQ
277#if __GLIBC_PREREQ(2, 1) 163#if __GLIBC_PREREQ(2, 1)
278#define HAVE_STRCHRNUL 164#define HAVE_STRCHRNUL
@@ -294,7 +180,6 @@ static inline char *gitstrchrnul(const char *s, int c)
294 */ 180 */
295extern char *xstrdup(const char *str); 181extern char *xstrdup(const char *str);
296extern void *xmalloc(size_t size) __attribute__((weak)); 182extern void *xmalloc(size_t size) __attribute__((weak));
297extern void *xmemdupz(const void *data, size_t len);
298extern char *xstrndup(const char *str, size_t len); 183extern char *xstrndup(const char *str, size_t len);
299extern void *xrealloc(void *ptr, size_t size) __attribute__((weak)); 184extern void *xrealloc(void *ptr, size_t size) __attribute__((weak));
300 185
@@ -310,11 +195,6 @@ static inline void *zalloc(size_t size)
310 return calloc(1, size); 195 return calloc(1, size);
311} 196}
312 197
313static inline size_t xsize_t(off_t len)
314{
315 return (size_t)len;
316}
317
318static inline int has_extension(const char *filename, const char *ext) 198static inline int has_extension(const char *filename, const char *ext)
319{ 199{
320 size_t len = strlen(filename); 200 size_t len = strlen(filename);
@@ -351,8 +231,6 @@ extern unsigned char sane_ctype[256];
351#define isalpha(x) sane_istest(x,GIT_ALPHA) 231#define isalpha(x) sane_istest(x,GIT_ALPHA)
352#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) 232#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT)
353#define isprint(x) sane_istest(x,GIT_PRINT) 233#define isprint(x) sane_istest(x,GIT_PRINT)
354#define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)
355#define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL)
356#define tolower(x) sane_case((unsigned char)(x), 0x20) 234#define tolower(x) sane_case((unsigned char)(x), 0x20)
357#define toupper(x) sane_case((unsigned char)(x), 0) 235#define toupper(x) sane_case((unsigned char)(x), 0)
358 236
@@ -363,38 +241,6 @@ static inline int sane_case(int x, int high)
363 return x; 241 return x;
364} 242}
365 243
366static inline int strtoul_ui(char const *s, int base, unsigned int *result)
367{
368 unsigned long ul;
369 char *p;
370
371 errno = 0;
372 ul = strtoul(s, &p, base);
373 if (errno || *p || p == s || (unsigned int) ul != ul)
374 return -1;
375 *result = ul;
376 return 0;
377}
378
379static inline int strtol_i(char const *s, int base, int *result)
380{
381 long ul;
382 char *p;
383
384 errno = 0;
385 ul = strtol(s, &p, base);
386 if (errno || *p || p == s || (int) ul != ul)
387 return -1;
388 *result = ul;
389 return 0;
390}
391
392#ifdef INTERNAL_QSORT
393void git_qsort(void *base, size_t nmemb, size_t size,
394 int(*compar)(const void *, const void *));
395#define qsort git_qsort
396#endif
397
398#ifndef DIR_HAS_BSD_GROUP_SEMANTICS 244#ifndef DIR_HAS_BSD_GROUP_SEMANTICS
399# define FORCE_DIR_SET_GID S_ISGID 245# define FORCE_DIR_SET_GID S_ISGID
400#else 246#else