2009-04-20 21:00:56 +08:00
|
|
|
#ifndef GIT_COMPAT_UTIL_H
|
|
|
|
#define GIT_COMPAT_UTIL_H
|
|
|
|
|
|
|
|
#define _BSD_SOURCE 1
|
2014-09-12 10:10:17 +08:00
|
|
|
/* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */
|
|
|
|
#define _DEFAULT_SOURCE 1
|
2009-04-20 21:00:56 +08:00
|
|
|
|
|
|
|
#include <fcntl.h>
|
2010-04-03 21:19:26 +08:00
|
|
|
#include <stdbool.h>
|
2009-04-20 21:00:56 +08:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
2017-06-16 22:39:15 +08:00
|
|
|
#include <linux/compiler.h>
|
2014-04-26 03:31:02 +08:00
|
|
|
#include <linux/types.h>
|
2017-07-06 09:48:11 +08:00
|
|
|
#include "namespaces.h"
|
2009-08-12 16:19:53 +08:00
|
|
|
|
2009-04-20 21:00:56 +08:00
|
|
|
/* General helper functions */
|
2017-06-16 22:39:15 +08:00
|
|
|
void usage(const char *err) __noreturn;
|
2017-06-16 22:57:54 +08:00
|
|
|
void die(const char *err, ...) __noreturn __printf(1, 2);
|
2009-04-20 21:00:56 +08:00
|
|
|
|
2009-11-24 22:05:16 +08:00
|
|
|
static inline void *zalloc(size_t size)
|
|
|
|
{
|
|
|
|
return calloc(1, size);
|
|
|
|
}
|
|
|
|
|
2013-12-27 04:41:15 +08:00
|
|
|
#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
|
|
|
|
|
2017-04-18 23:26:44 +08:00
|
|
|
struct dirent;
|
2017-04-18 21:57:25 +08:00
|
|
|
struct strlist;
|
|
|
|
|
perf record: Introduce a symtab cache
Now a cache will be created in a ~/.debug debuginfo like
hierarchy, so that at the end of a 'perf record' session all the
binaries (with build-ids) involved get collected and indexed by
their build-ids, so that perf report can find them.
This is interesting when developing software where you want to
do a 'perf diff' with the previous build and opens avenues for
lots more interesting tools, like a 'perf diff --graph' that
takes more than two binaries into account.
Tunables for collecting just the symtabs can be added if one
doesn't want to have the full binary, but having the full binary
allows things like 'perf rerecord' or other tools that can
re-run the tests by having access to the exact binary in some
perf.data file, so it may well be interesting to keep the full
binary there.
Space consumption is minimised by trying to use hard links, a
'perf cache' tool to manage the space used, a la ccache is
required to purge older entries.
With this in place it will be possible also to introduce new
commands, 'perf archive' and 'perf restore' (or some more
suitable and future proof names) to create a cpio/tar file with
the perf data and the files in the cache that _had_ perf hits of
interest.
There are more aspects to polish, like finding the right vmlinux
file to cache, etc, but this is enough for a first step.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1261957026-15580-10-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-12-28 07:37:06 +08:00
|
|
|
int mkdir_p(char *path, mode_t mode);
|
2017-01-27 05:19:59 +08:00
|
|
|
int rm_rf(const char *path);
|
2016-04-26 17:02:42 +08:00
|
|
|
struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *));
|
|
|
|
bool lsdir_no_dot_filter(const char *name, struct dirent *d);
|
perf record: Introduce a symtab cache
Now a cache will be created in a ~/.debug debuginfo like
hierarchy, so that at the end of a 'perf record' session all the
binaries (with build-ids) involved get collected and indexed by
their build-ids, so that perf report can find them.
This is interesting when developing software where you want to
do a 'perf diff' with the previous build and opens avenues for
lots more interesting tools, like a 'perf diff --graph' that
takes more than two binaries into account.
Tunables for collecting just the symtabs can be added if one
doesn't want to have the full binary, but having the full binary
allows things like 'perf rerecord' or other tools that can
re-run the tests by having access to the exact binary in some
perf.data file, so it may well be interesting to keep the full
binary there.
Space consumption is minimised by trying to use hard links, a
'perf cache' tool to manage the space used, a la ccache is
required to purge older entries.
With this in place it will be possible also to introduce new
commands, 'perf archive' and 'perf restore' (or some more
suitable and future proof names) to create a cpio/tar file with
the perf data and the files in the cache that _had_ perf hits of
interest.
There are more aspects to polish, like finding the right vmlinux
file to cache, etc, but this is enough for a first step.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1261957026-15580-10-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-12-28 07:37:06 +08:00
|
|
|
int copyfile(const char *from, const char *to);
|
2013-10-14 18:43:41 +08:00
|
|
|
int copyfile_mode(const char *from, const char *to, mode_t mode);
|
2017-07-06 09:48:11 +08:00
|
|
|
int copyfile_ns(const char *from, const char *to, struct nsinfo *nsi);
|
2015-05-18 08:30:18 +08:00
|
|
|
int copyfile_offset(int fromfd, loff_t from_ofs, int tofd, loff_t to_ofs, u64 size);
|
perf record: Introduce a symtab cache
Now a cache will be created in a ~/.debug debuginfo like
hierarchy, so that at the end of a 'perf record' session all the
binaries (with build-ids) involved get collected and indexed by
their build-ids, so that perf report can find them.
This is interesting when developing software where you want to
do a 'perf diff' with the previous build and opens avenues for
lots more interesting tools, like a 'perf diff --graph' that
takes more than two binaries into account.
Tunables for collecting just the symtabs can be added if one
doesn't want to have the full binary, but having the full binary
allows things like 'perf rerecord' or other tools that can
re-run the tests by having access to the exact binary in some
perf.data file, so it may well be interesting to keep the full
binary there.
Space consumption is minimised by trying to use hard links, a
'perf cache' tool to manage the space used, a la ccache is
required to purge older entries.
With this in place it will be possible also to introduce new
commands, 'perf archive' and 'perf restore' (or some more
suitable and future proof names) to create a cpio/tar file with
the perf data and the files in the cache that _had_ perf hits of
interest.
There are more aspects to polish, like finding the right vmlinux
file to cache, etc, but this is enough for a first step.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1261957026-15580-10-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-12-28 07:37:06 +08:00
|
|
|
|
2013-11-28 18:30:14 +08:00
|
|
|
ssize_t readn(int fd, void *buf, size_t n);
|
2017-07-18 12:25:37 +08:00
|
|
|
ssize_t writen(int fd, const void *buf, size_t n);
|
2010-04-03 21:19:26 +08:00
|
|
|
|
2012-04-20 00:15:24 +08:00
|
|
|
size_t hex_width(u64 v);
|
2012-10-28 05:18:30 +08:00
|
|
|
int hex2u64(const char *ptr, u64 *val);
|
2012-04-20 00:15:24 +08:00
|
|
|
|
2012-10-07 01:57:10 +08:00
|
|
|
extern unsigned int page_size;
|
2014-05-31 04:10:05 +08:00
|
|
|
extern int cacheline_size;
|
2012-10-07 01:57:10 +08:00
|
|
|
|
2015-11-06 21:55:35 +08:00
|
|
|
int fetch_kernel_version(unsigned int *puint,
|
|
|
|
char *str, size_t str_sz);
|
2015-11-06 21:58:09 +08:00
|
|
|
#define KVER_VERSION(x) (((x) >> 16) & 0xff)
|
|
|
|
#define KVER_PATCHLEVEL(x) (((x) >> 8) & 0xff)
|
|
|
|
#define KVER_SUBLEVEL(x) ((x) & 0xff)
|
|
|
|
#define KVER_FMT "%d.%d.%d"
|
|
|
|
#define KVER_PARAM(x) KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)
|
2015-11-06 21:55:35 +08:00
|
|
|
|
2016-01-07 19:41:53 +08:00
|
|
|
const char *perf_tip(const char *dirpath);
|
|
|
|
|
2017-03-02 23:55:49 +08:00
|
|
|
#ifndef HAVE_SCHED_GETCPU_SUPPORT
|
|
|
|
int sched_getcpu(void);
|
2016-07-12 21:29:31 +08:00
|
|
|
#endif
|
|
|
|
|
2017-07-19 04:15:29 +08:00
|
|
|
#ifndef HAVE_SETNS_SUPPORT
|
|
|
|
int setns(int fd, int nstype);
|
|
|
|
#endif
|
|
|
|
|
2013-02-20 23:32:31 +08:00
|
|
|
#endif /* GIT_COMPAT_UTIL_H */
|