Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
util.h File Reference
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <sys/param.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h>
#include <time.h>
#include <signal.h>
#include <fnmatch.h>
#include <assert.h>
#include <regex.h>
#include <utime.h>
#include <sys/wait.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <inttypes.h>
#include <linux/magic.h>
#include "types.h"
#include <sys/ttydefaults.h>
#include "../../../include/linux/stringify.h"

Go to the source code of this file.

Macros

#define _FILE_OFFSET_BITS   64
 
#define FLEX_ARRAY   1
 
#define ARRAY_SIZE(x)   (sizeof(x)/sizeof(x[0]))
 
#define TYPEOF(x)
 
#define MSB(x, bits)   ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits))))
 
#define HAS_MULTI_BITS(i)   ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */
 
#define decimal_length(x)   ((int)(sizeof(x) * 2.56 + 0.5) + 1)
 
#define _ALL_SOURCE   1
 
#define _BSD_SOURCE   1
 
#define HAS_BOOL
 
#define PATH_MAX   4096
 
#define PRIuMAX   "llu"
 
#define PRIu32   "u"
 
#define PRIx32   "x"
 
#define PATH_SEP   ':'
 
#define STRIP_EXTENSION   ""
 
#define has_dos_drive_prefix(path)   0
 
#define is_dir_sep(c)   ((c) == '/')
 
#define NORETURN
 
#define __attribute__(x)
 
#define DIE_IF(cnd)
 
#define strchrnul   gitstrchrnul
 
#define GIT_SPACE   0x01
 
#define GIT_DIGIT   0x02
 
#define GIT_ALPHA   0x04
 
#define GIT_GLOB_SPECIAL   0x08
 
#define GIT_REGEX_SPECIAL   0x10
 
#define GIT_PRINT_EXTRA   0x20
 
#define GIT_PRINT   0x3E
 
#define sane_istest(x, mask)   ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
 
#define isascii(x)   (((x) & ~0x7f) == 0)
 
#define isspace(x)   sane_istest(x,GIT_SPACE)
 
#define isdigit(x)   sane_istest(x,GIT_DIGIT)
 
#define isxdigit(x)   (sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G')
 
#define isalpha(x)   sane_istest(x,GIT_ALPHA)
 
#define isalnum(x)   sane_istest(x,GIT_ALPHA | GIT_DIGIT)
 
#define isprint(x)   sane_istest(x,GIT_PRINT)
 
#define islower(x)   (sane_istest(x,GIT_ALPHA) && sane_istest(x,0x20))
 
#define isupper(x)   (sane_istest(x,GIT_ALPHA) && !sane_istest(x,0x20))
 
#define tolower(x)   sane_case((unsigned char)(x), 0x20)
 
#define toupper(x)   sane_case((unsigned char)(x), 0)
 
#define _STR(x)   #x
 
#define STR(x)   _STR(x)
 

Functions

void usage (const char *err) NORETURN
 
void die (const char *err,...) NORETURN __attribute__((format(printf
 
void int error (const char *err,...) __attribute__((format(printf
 
void int void warning (const char *err,...) __attribute__((format(printf
 
void set_die_routine (void(*routine)(const char *err, va_list params) NORETURN)
 
int prefixcmp (const char *str, const char *prefix)
 
void set_buildid_dir (void)
 
void disable_buildid_cache (void)
 
charxstrdup (const char *str)
 
voidxrealloc (void *ptr, size_t size) __attribute__((weak))
 
int mkdir_p (char *path, mode_t mode)
 
int copyfile (const char *from, const char *to)
 
s64 perf_atoll (const char *str)
 
char ** argv_split (const char *str, int *argcp)
 
void argv_free (char **argv)
 
bool strglobmatch (const char *str, const char *pat)
 
bool strlazymatch (const char *str, const char *pat)
 
int strtailcmp (const char *s1, const char *s2)
 
unsigned long convert_unit (unsigned long value, char *unit)
 
int readn (int fd, void *buf, size_t size)
 
void event_attr_init (struct perf_event_attr *attr)
 
size_t hex_width (u64 v)
 
charrtrim (char *s)
 
void dump_stack (void)
 

Variables

const chargraph_line
 
const chargraph_dotted_line
 
char buildid_dir []
 
unsigned char sane_ctype [256]
 

Macro Definition Documentation

#define __attribute__ (   x)

Definition at line 121 of file util.h.

#define _ALL_SOURCE   1

Definition at line 42 of file util.h.

#define _BSD_SOURCE   1

Definition at line 43 of file util.h.

#define _FILE_OFFSET_BITS   64

Definition at line 4 of file util.h.

#define _STR (   x)    #x

Definition at line 246 of file util.h.

#define ARRAY_SIZE (   x)    (sizeof(x)/sizeof(x[0]))

Definition at line 28 of file util.h.

#define decimal_length (   x)    ((int)(sizeof(x) * 2.56 + 0.5) + 1)

Definition at line 40 of file util.h.

#define DIE_IF (   cnd)
Value:
do { if (cnd) \
die(" at (" __FILE__ ":" __stringify(__LINE__) "): " \
__stringify(cnd) "\n"); \
} while (0)

Definition at line 133 of file util.h.

#define FLEX_ARRAY   1

Definition at line 24 of file util.h.

#define GIT_ALPHA   0x04

Definition at line 204 of file util.h.

#define GIT_DIGIT   0x02

Definition at line 203 of file util.h.

#define GIT_GLOB_SPECIAL   0x08

Definition at line 205 of file util.h.

#define GIT_PRINT   0x3E

Definition at line 208 of file util.h.

#define GIT_PRINT_EXTRA   0x20

Definition at line 207 of file util.h.

#define GIT_REGEX_SPECIAL   0x10

Definition at line 206 of file util.h.

#define GIT_SPACE   0x01

Definition at line 202 of file util.h.

#define HAS_BOOL

Definition at line 44 of file util.h.

#define has_dos_drive_prefix (   path)    0

Definition at line 109 of file util.h.

#define HAS_MULTI_BITS (   i)    ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */

Definition at line 37 of file util.h.

#define is_dir_sep (   c)    ((c) == '/')

Definition at line 113 of file util.h.

#define isalnum (   x)    sane_istest(x,GIT_ALPHA | GIT_DIGIT)

Definition at line 216 of file util.h.

#define isalpha (   x)    sane_istest(x,GIT_ALPHA)

Definition at line 215 of file util.h.

#define isascii (   x)    (((x) & ~0x7f) == 0)

Definition at line 210 of file util.h.

#define isdigit (   x)    sane_istest(x,GIT_DIGIT)

Definition at line 212 of file util.h.

#define islower (   x)    (sane_istest(x,GIT_ALPHA) && sane_istest(x,0x20))

Definition at line 218 of file util.h.

#define isprint (   x)    sane_istest(x,GIT_PRINT)

Definition at line 217 of file util.h.

#define isspace (   x)    sane_istest(x,GIT_SPACE)

Definition at line 211 of file util.h.

#define isupper (   x)    (sane_istest(x,GIT_ALPHA) && !sane_istest(x,0x20))

Definition at line 219 of file util.h.

#define isxdigit (   x)    (sane_istest(toupper(x), GIT_ALPHA | GIT_DIGIT) && toupper(x) < 'G')

Definition at line 213 of file util.h.

#define MSB (   x,
  bits 
)    ((x) & TYPEOF(x)(~0ULL << (sizeof(x) * 8 - (bits))))

Definition at line 36 of file util.h.

#define NORETURN

Definition at line 119 of file util.h.

#define PATH_MAX   4096

Definition at line 85 of file util.h.

#define PATH_SEP   ':'

Definition at line 101 of file util.h.

#define PRIu32   "u"

Definition at line 93 of file util.h.

#define PRIuMAX   "llu"

Definition at line 89 of file util.h.

#define PRIx32   "x"

Definition at line 97 of file util.h.

#define sane_istest (   x,
  mask 
)    ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)

Definition at line 209 of file util.h.

#define STR (   x)    _STR(x)

Definition at line 247 of file util.h.

#define strchrnul   gitstrchrnul

Definition at line 159 of file util.h.

#define STRIP_EXTENSION   ""

Definition at line 105 of file util.h.

#define tolower (   x)    sane_case((unsigned char)(x), 0x20)

Definition at line 220 of file util.h.

#define toupper (   x)    sane_case((unsigned char)(x), 0)

Definition at line 221 of file util.h.

#define TYPEOF (   x)

Definition at line 33 of file util.h.

Function Documentation

void argv_free ( char **  argv)

argv_free - free an argv - the argument vector to be freed

Frees an argv and the strings it points to.

Definition at line 40 of file argv_split.c.

char** argv_split ( const char str,
int argcp 
)

argv_split - split a string at whitespace, returning an argv : the string to be split : returned argument count

Returns an array of pointers to strings which are split out from . This is performed by strictly splitting on white-space; no quote processing is performed. Multiple whitespace characters are considered to be a single argument separator. The returned array is always NULL-terminated. Returns NULL on memory allocation failure.

Definition at line 148 of file string.c.

unsigned long convert_unit ( unsigned long  value,
char unit 
)

Definition at line 118 of file util.c.

int copyfile ( const char from,
const char to 
)

Definition at line 79 of file util.c.

void die ( const char err,
  ... 
)

Definition at line 34 of file parse-utils.c.

void disable_buildid_cache ( void  )

Definition at line 2959 of file header.c.

void dump_stack ( void  )

Definition at line 172 of file traps.c.

void int error ( const char err,
  ... 
)
void event_attr_init ( struct perf_event_attr attr)

Definition at line 16 of file util.c.

size_t hex_width ( u64  v)

Definition at line 157 of file util.c.

int mkdir_p ( char path,
mode_t  mode 
)

Definition at line 26 of file util.c.

s64 perf_atoll ( const char str)

Definition at line 10 of file string.c.

int prefixcmp ( const char str,
const char prefix 
)

Definition at line 4 of file strbuf.c.

int readn ( int  fd,
void buf,
size_t  size 
)

Definition at line 140 of file util.c.

char* rtrim ( char s)

rtrim - Removes trailing whitespace from . : The string to be stripped.

Note that the first trailing whitespace is replaced with a NUL-terminator in the given string . Returns .

Definition at line 323 of file string.c.

void set_buildid_dir ( void  )

Definition at line 489 of file config.c.

void set_die_routine ( void(*)(const char *err, va_list params) NORETURN  routine)

Definition at line 48 of file usage.c.

bool strglobmatch ( const char str,
const char pat 
)

strglobmatch - glob expression pattern matching : the target string to match : the pattern string to match

This returns true if the matches . can includes wildcards ('*','?') and character classes ([CHARS], complementation and ranges are also supported). Also, this supports escape character ('\') to use special characters as normal character.

Note: if syntax is broken, this always returns false.

Definition at line 280 of file string.c.

bool strlazymatch ( const char str,
const char pat 
)

strlazymatch - matching pattern strings lazily with glob pattern : the target string to match : the pattern string to match

This is similar to strglobmatch, except this ignores spaces in the target string.

Definition at line 293 of file string.c.

int strtailcmp ( const char s1,
const char s2 
)

strtailcmp - Compare the tail of two strings : 1st string to be compared : 2nd string to be compared

Return 0 if whole of either string is same as another's tail part.

Definition at line 305 of file string.c.

void usage ( const char err)

Definition at line 53 of file usage.c.

void int void warning ( const char err,
  ... 
)

Definition at line 64 of file parse-utils.c.

void* xrealloc ( void ptr,
size_t  size 
)

Definition at line 27 of file wrapper.c.

char* xstrdup ( const char str)

Definition at line 38 of file util.c.

Variable Documentation

char buildid_dir[]

Definition at line 20 of file config.c.

const char* graph_dotted_line

Definition at line 36 of file ctype.c.

const char* graph_line

Definition at line 33 of file ctype.c.

unsigned char sane_ctype[256]

Definition at line 19 of file ctype.c.