2009-04-20 20:00:56 +07:00
|
|
|
#ifndef GIT_COMPAT_UTIL_H
|
|
|
|
#define GIT_COMPAT_UTIL_H
|
|
|
|
|
|
|
|
#define _BSD_SOURCE 1
|
2014-09-12 09:10:17 +07:00
|
|
|
/* glibc 2.20 deprecates _BSD_SOURCE in favour of _DEFAULT_SOURCE */
|
|
|
|
#define _DEFAULT_SOURCE 1
|
2009-04-20 20:00:56 +07:00
|
|
|
|
|
|
|
#include <fcntl.h>
|
2010-04-03 20:19:26 +07:00
|
|
|
#include <stdbool.h>
|
2009-04-20 20:00:56 +07:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
2017-06-16 21:39:15 +07:00
|
|
|
#include <linux/compiler.h>
|
2014-04-26 02:31:02 +07:00
|
|
|
#include <linux/types.h>
|
2017-07-06 08:48:11 +07:00
|
|
|
#include "namespaces.h"
|
2009-08-12 15:19:53 +07:00
|
|
|
|
2009-04-20 20:00:56 +07:00
|
|
|
/* General helper functions */
|
2017-06-16 21:39:15 +07:00
|
|
|
void usage(const char *err) __noreturn;
|
2017-06-16 21:57:54 +07:00
|
|
|
void die(const char *err, ...) __noreturn __printf(1, 2);
|
2009-04-20 20:00:56 +07:00
|
|
|
|
2009-11-24 21:05:16 +07:00
|
|
|
static inline void *zalloc(size_t size)
|
|
|
|
{
|
|
|
|
return calloc(1, size);
|
|
|
|
}
|
|
|
|
|
2013-12-27 03:41:15 +07:00
|
|
|
#define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
|
|
|
|
|
2017-04-18 22:26:44 +07:00
|
|
|
struct dirent;
|
2017-04-18 20:57:25 +07: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 06:37:06 +07:00
|
|
|
int mkdir_p(char *path, mode_t mode);
|
2017-01-27 04:19:59 +07:00
|
|
|
int rm_rf(const char *path);
|
2016-04-26 16:02:42 +07: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 06:37:06 +07:00
|
|
|
int copyfile(const char *from, const char *to);
|
2013-10-14 17:43:41 +07:00
|
|
|
int copyfile_mode(const char *from, const char *to, mode_t mode);
|
2017-07-06 08:48:11 +07:00
|
|
|
int copyfile_ns(const char *from, const char *to, struct nsinfo *nsi);
|
2015-05-18 07:30:18 +07: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 06:37:06 +07:00
|
|
|
|
2013-11-28 17:30:14 +07:00
|
|
|
ssize_t readn(int fd, void *buf, size_t n);
|
2013-11-28 17:30:16 +07:00
|
|
|
ssize_t writen(int fd, void *buf, size_t n);
|
2010-04-03 20:19:26 +07:00
|
|
|
|
2012-04-19 23:15:24 +07:00
|
|
|
size_t hex_width(u64 v);
|
2012-10-28 04:18:30 +07:00
|
|
|
int hex2u64(const char *ptr, u64 *val);
|
2012-04-19 23:15:24 +07:00
|
|
|
|
2012-10-07 00:57:10 +07:00
|
|
|
extern unsigned int page_size;
|
2014-05-31 03:10:05 +07:00
|
|
|
extern int cacheline_size;
|
2012-10-07 00:57:10 +07:00
|
|
|
|
2015-11-06 20:55:35 +07:00
|
|
|
int fetch_kernel_version(unsigned int *puint,
|
|
|
|
char *str, size_t str_sz);
|
2015-11-06 20:58:09 +07: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 20:55:35 +07:00
|
|
|
|
2016-01-07 18:41:53 +07:00
|
|
|
const char *perf_tip(const char *dirpath);
|
|
|
|
|
2017-03-02 22:55:49 +07:00
|
|
|
#ifndef HAVE_SCHED_GETCPU_SUPPORT
|
|
|
|
int sched_getcpu(void);
|
2016-07-12 20:29:31 +07:00
|
|
|
#endif
|
|
|
|
|
2017-07-19 03:15:29 +07:00
|
|
|
#ifndef HAVE_SETNS_SUPPORT
|
|
|
|
int setns(int fd, int nstype);
|
|
|
|
#endif
|
|
|
|
|
2013-02-20 22:32:31 +07:00
|
|
|
#endif /* GIT_COMPAT_UTIL_H */
|