4
Copyright (C) 2007 Arnaldo Carvalho de Melo <acme@redhat.com>
6
This program is free software; you can redistribute it and/or modify it
7
under the terms of version 2 of the GNU General Public License as
8
published by the Free Software Foundation.
16
struct fstrlist *fstrlist__new(const char *filename);
17
void fstrlist__delete(struct fstrlist *self);
19
int fstrlist__has_entry(const struct fstrlist *self, const char *entry);
4
* Copyright (C) 2007..2009 Arnaldo Carvalho de Melo <acme@redhat.com>
6
* This program is free software; you can redistribute it and/or modify it
7
* under the terms of version 2 of the GNU General Public License as
8
* published by the Free Software Foundation.
10
* Some functions came from the Linux Kernel sources, copyrighted by a
11
* cast of dozens, please see the Linux Kernel git history for details.
21
#define __unused __attribute__ ((unused))
25
#define __pure __attribute__ ((pure))
28
#define roundup(x,y) ((((x) + ((y) - 1)) / (y)) * (y))
30
static inline __attribute__((const)) bool is_power_of_2(unsigned long n)
32
return (n != 0 && ((n & (n - 1)) == 0));
35
/* We need define two variables, argp_program_version_hook and
36
argp_program_bug_address, in all programs. argp.h declares these
37
variables as non-const (which is correct in general). But we can
38
do better, it is not going to change. So we want to move them into
39
the .rodata section. Define macros to do the trick. */
40
#define ARGP_PROGRAM_VERSION_HOOK_DEF \
41
void (*const apvh) (FILE *, struct argp_state *) \
42
__asm ("argp_program_version_hook")
43
#define ARGP_PROGRAM_BUG_ADDRESS_DEF \
44
const char *const apba__ __asm ("argp_program_bug_address")
47
struct rb_node rb_node;
52
struct rb_root entries;
56
struct strlist *strlist__new(bool dupstr);
57
void strlist__delete(struct strlist *self);
59
void strlist__remove(struct strlist *self, struct str_node *sn);
60
int strlist__load(struct strlist *self, const char *filename);
61
int strlist__add(struct strlist *self, const char *str);
63
bool strlist__has_entry(struct strlist *self, const char *entry);
65
static inline bool strlist__empty(const struct strlist *self)
67
return rb_first(&self->entries) == NULL;
70
void *zalloc(const size_t size);
72
Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
73
GElf_Shdr *shp, const char *name, size_t *index);
21
75
#endif /* _DUTIL_H_ */