Linux Perf
util.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <linux/compiler.h>
#include <sys/types.h>
Include dependency graph for util.h:

Go to the source code of this file.

Macros

#define _BSD_SOURCE   1
 
#define _DEFAULT_SOURCE   1
 
#define zfree(ptr)   ({ free(*ptr); *ptr = NULL; })
 
#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)
 
#define O_CLOEXEC   02000000
 

Functions

void usage (const char *err) __noreturn
 
void die (const char *err,...) __noreturn __printf(1
 
void static void * zalloc (size_t size)
 
int mkdir_p (char *path, mode_t mode)
 
int rm_rf (const char *path)
 
struct strlistlsdir (const char *name, bool(*filter)(const char *, struct dirent *))
 
bool lsdir_no_dot_filter (const char *name, struct dirent *d)
 
int copyfile (const char *from, const char *to)
 
int copyfile_mode (const char *from, const char *to, mode_t mode)
 
int copyfile_ns (const char *from, const char *to, struct nsinfo *nsi)
 
ssize_t readn (int fd, void *buf, size_t n)
 
ssize_t writen (int fd, const void *buf, size_t n)
 
size_t hex_width (u64 v)
 
int hex2u64 (const char *ptr, u64 *val)
 
int __pure cacheline_size (void)
 
int sysctl__max_stack (void)
 
int fetch_kernel_version (unsigned int *puint, char *str, size_t str_sz)
 
const char * perf_tip (const char *dirpath)
 
int sched_getcpu (void)
 
int setns (int fd, int nstype)
 
void perf_set_singlethreaded (void)
 
void perf_set_multithreaded (void)
 

Variables

unsigned int page_size
 
bool perf_singlethreaded
 

Macro Definition Documentation

◆ _BSD_SOURCE

#define _BSD_SOURCE   1

Definition at line 5 of file util.h.

◆ _DEFAULT_SOURCE

#define _DEFAULT_SOURCE   1

Definition at line 7 of file util.h.

◆ KVER_FMT

#define KVER_FMT   "%d.%d.%d"

Definition at line 55 of file util.h.

◆ KVER_PARAM

#define KVER_PARAM (   x)    KVER_VERSION(x), KVER_PATCHLEVEL(x), KVER_SUBLEVEL(x)

Definition at line 56 of file util.h.

◆ KVER_PATCHLEVEL

#define KVER_PATCHLEVEL (   x)    (((x) >> 8) & 0xff)

Definition at line 53 of file util.h.

◆ KVER_SUBLEVEL

#define KVER_SUBLEVEL (   x)    ((x) & 0xff)

Definition at line 54 of file util.h.

◆ KVER_VERSION

#define KVER_VERSION (   x)    (((x) >> 16) & 0xff)

Definition at line 52 of file util.h.

◆ O_CLOEXEC

#define O_CLOEXEC   02000000

Definition at line 79 of file util.h.

◆ zfree

#define zfree (   ptr)    ({ free(*ptr); *ptr = NULL; })

Definition at line 25 of file util.h.

Function Documentation

◆ cacheline_size()

int __pure cacheline_size ( void  )

Definition at line 52 of file util.c.

Here is the call graph for this function:

◆ copyfile()

int copyfile ( const char *  from,
const char *  to 
)

Definition at line 320 of file util.c.

Here is the call graph for this function:

◆ copyfile_mode()

int copyfile_mode ( const char *  from,
const char *  to,
mode_t  mode 
)

Definition at line 315 of file util.c.

Here is the call graph for this function:

◆ copyfile_ns()

int copyfile_ns ( const char *  from,
const char *  to,
struct nsinfo nsi 
)

Definition at line 310 of file util.c.

Here is the call graph for this function:

◆ die()

void die ( const char *  err,
  ... 
)

◆ fetch_kernel_version()

int fetch_kernel_version ( unsigned int *  puint,
char *  str,
size_t  str_sz 
)

Definition at line 447 of file util.c.

Here is the call graph for this function:

◆ hex2u64()

int hex2u64 ( const char *  ptr,
u64 *  val 
)

Definition at line 379 of file util.c.

◆ hex_width()

size_t hex_width ( u64  v)

Definition at line 365 of file util.c.

◆ lsdir()

struct strlist* lsdir ( const char *  name,
bool(*)(const char *, struct dirent *)  filter 
)

Definition at line 166 of file util.c.

Here is the call graph for this function:

◆ lsdir_no_dot_filter()

bool lsdir_no_dot_filter ( const char *  name,
struct dirent *  d 
)

◆ mkdir_p()

int mkdir_p ( char *  path,
mode_t  mode 
)

Definition at line 93 of file util.c.

◆ perf_set_multithreaded()

void perf_set_multithreaded ( void  )

Definition at line 35 of file util.c.

◆ perf_set_singlethreaded()

void perf_set_singlethreaded ( void  )

Definition at line 30 of file util.c.

◆ perf_tip()

const char* perf_tip ( const char *  dirpath)

Definition at line 482 of file util.c.

Here is the call graph for this function:

◆ readn()

ssize_t readn ( int  fd,
void *  buf,
size_t  n 
)

Definition at line 351 of file util.c.

Here is the call graph for this function:

◆ rm_rf()

int rm_rf ( const char *  path)

Definition at line 119 of file util.c.

Here is the call graph for this function:

◆ sched_getcpu()

int sched_getcpu ( void  )

Definition at line 15 of file cloexec.c.

◆ setns()

int setns ( int  fd,
int  nstype 
)

Definition at line 5 of file setns.c.

◆ sysctl__max_stack()

int sysctl__max_stack ( void  )

Definition at line 65 of file util.c.

◆ usage()

void usage ( const char *  err)

Definition at line 23 of file usage.c.

◆ writen()

ssize_t writen ( int  fd,
const void *  buf,
size_t  n 
)

Definition at line 359 of file util.c.

Here is the call graph for this function:

◆ zalloc()

void static void* zalloc ( size_t  size)
inlinestatic

Definition at line 20 of file util.h.

Variable Documentation

◆ page_size

unsigned int page_size

Definition at line 40 of file util.c.

◆ perf_singlethreaded

bool perf_singlethreaded

Definition at line 28 of file util.c.