defs.h | defs.h | |||
---|---|---|---|---|
#ifndef _LIBHX_DEFS_H | #ifndef _LIBHX_DEFS_H | |||
#define _LIBHX_DEFS_H 1 | #define _LIBHX_DEFS_H 1 | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
# define HXsizeof_member(type, member) \ | ||||
sizeof(static_cast<type *>(NULL)->member) | ||||
# define HXtypeof_member(type, member) \ | ||||
typeof(static_cast<type *>(NULL)->member) | ||||
# if defined(__GNUC__) && __GNUC__ >= 4 && !defined(offsetof) | # if defined(__GNUC__) && __GNUC__ >= 4 && !defined(offsetof) | |||
/* | /* | |||
* This is here so most programs can skip inclusion | * This is here so most programs can skip inclusion | |||
* of stddef.h just to get offsetof. | * of stddef.h just to get offsetof. | |||
*/ | */ | |||
# define offsetof(type, member) __builtin_offsetof(type, membe r) | # define offsetof(type, member) __builtin_offsetof(type, membe r) | |||
# endif | # endif | |||
# ifndef offsetof | # ifndef offsetof | |||
# define offsetof(type, member) \ | # define offsetof(type, member) \ | |||
reinterpret_cast<long>(&(static_cast<type *>(NULL)-> member)) | reinterpret_cast<long>(&(static_cast<type *>(NULL)-> member)) | |||
skipping to change at line 57 | skipping to change at line 61 | |||
{ | { | |||
return reinterpret_cast<new_type>(expr); | return reinterpret_cast<new_type>(expr); | |||
} | } | |||
template<typename new_type> | template<typename new_type> | |||
static inline new_type signed_cast(unsigned char *expr) | static inline new_type signed_cast(unsigned char *expr) | |||
{ | { | |||
return reinterpret_cast<new_type>(expr); | return reinterpret_cast<new_type>(expr); | |||
} | } | |||
#else | #else | |||
# define HXsizeof_member(type, member) sizeof(((type *)NULL)->member) | ||||
# define HXtypeof_member(type, member) typeof(((type *)NULL)->member) | ||||
/* N.B. signed_cast<> does not exist in C++. */ | /* N.B. signed_cast<> does not exist in C++. */ | |||
# define __signed_cast_compatible(a, b) \ | # define __signed_cast_compatible(a, b) \ | |||
__builtin_choose_expr( \ | __builtin_choose_expr( \ | |||
__builtin_types_compatible_p(b, const char *) || \ | __builtin_types_compatible_p(b, const char *) || \ | |||
__builtin_types_compatible_p(b, const signed char *) || \ | __builtin_types_compatible_p(b, const signed char *) || \ | |||
__builtin_types_compatible_p(b, const unsigned char *), \ | __builtin_types_compatible_p(b, const unsigned char *), \ | |||
/* if src has a const qualifier */ \ | /* if src has a const qualifier */ \ | |||
__builtin_types_compatible_p(a, const char *) || \ | __builtin_types_compatible_p(a, const char *) || \ | |||
__builtin_types_compatible_p(a, const signed char *) || \ | __builtin_types_compatible_p(a, const signed char *) || \ | |||
__builtin_types_compatible_p(a, const unsigned char *), \ | __builtin_types_compatible_p(a, const unsigned char *), \ | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 6 lines changed or added | |||
libHX.h | libHX.h | |||
---|---|---|---|---|
skipping to change at line 13 | skipping to change at line 13 | |||
/* | /* | |||
* This file is for programs that really need about everything. The presenc e of | * This file is for programs that really need about everything. The presenc e of | |||
* this file is undocumented, but you can rely on its presence and that it | * this file is undocumented, but you can rely on its presence and that it | |||
* always includes a given feature set. (Once an "#include" is added, it sh all | * always includes a given feature set. (Once an "#include" is added, it sh all | |||
* be considered documented behavior that feature xyz is available merely b y | * be considered documented behavior that feature xyz is available merely b y | |||
* inclusion of this file. Henceforth, "#includes" may not be removed from here | * inclusion of this file. Henceforth, "#includes" may not be removed from here | |||
* unless the implementation really went away. | * unless the implementation really went away. | |||
*/ | */ | |||
#include <libHX/arbtree.h> | ||||
#include <libHX/clist.h> | ||||
#include <libHX/ctype_helper.h> | #include <libHX/ctype_helper.h> | |||
#include <libHX/defs.h> | #include <libHX/defs.h> | |||
#include <libHX/deque.h> | #include <libHX/deque.h> | |||
#include <libHX/list.h> | #include <libHX/list.h> | |||
#include <libHX/map.h> | ||||
#include <libHX/misc.h> | #include <libHX/misc.h> | |||
#include <libHX/option.h> | #include <libHX/option.h> | |||
#include <libHX/proc.h> | #include <libHX/proc.h> | |||
#include <libHX/string.h> | #include <libHX/string.h> | |||
/* not libxml_helper, because that requires libxml2 */ | /* not libxml_helper, because that requires libxml2 */ | |||
#endif /* _LIBHX_H */ | #endif /* _LIBHX_H */ | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 1 lines changed or added | |||
list.h | list.h | |||
---|---|---|---|---|
skipping to change at line 92 | skipping to change at line 92 | |||
&(pos)->member != (void *)(head); \ | &(pos)->member != (void *)(head); \ | |||
(pos) = HXlist_entry((pos)->member.prev, typeof(*(pos)), member )) | (pos) = HXlist_entry((pos)->member.prev, typeof(*(pos)), member )) | |||
#define HXlist_for_each_entry_safe(pos, n, head, member) \ | #define HXlist_for_each_entry_safe(pos, n, head, member) \ | |||
for ((pos) = HXlist_entry((head)->next, typeof(*(pos)), member), \ | for ((pos) = HXlist_entry((head)->next, typeof(*(pos)), member), \ | |||
(n) = HXlist_entry((pos)->member.next, typeof(*(pos)), member); \ | (n) = HXlist_entry((pos)->member.next, typeof(*(pos)), member); \ | |||
&(pos)->member != (void *)(head); \ | &(pos)->member != (void *)(head); \ | |||
(pos) = (n), (n) = HXlist_entry((n)->member.next, typeof(*(n)), \ | (pos) = (n), (n) = HXlist_entry((n)->member.next, typeof(*(n)), \ | |||
member)) | member)) | |||
struct HXclist_head { | ||||
union { | ||||
struct HXlist_head list; | ||||
struct { | ||||
struct HXlist_head *next, *prev; | ||||
}; | ||||
}; | ||||
unsigned int items; | ||||
}; | ||||
#define HXCLIST_HEAD_INIT(name) {{{&(name).list, &(name).list}}, 0} | ||||
#define HXCLIST_HEAD(name) \ | ||||
struct HXclist_head name = HXCLIST_HEAD_INIT(name) | ||||
static inline void HXclist_init(struct HXclist_head *head) | ||||
{ | ||||
head->list.next = head->list.prev = &head->list; | ||||
head->items = 0; | ||||
} | ||||
static inline void HXclist_del(struct HXclist_head *head, | ||||
struct HXlist_head *node) | ||||
{ | ||||
--head->items; | ||||
HXlist_del(node); | ||||
} | ||||
static inline void HXclist_unshift(struct HXclist_head *head, | ||||
struct HXlist_head *nu) | ||||
{ | ||||
++head->items; | ||||
__HXlist_add(nu, &head->list, head->list.next); | ||||
} | ||||
static inline void HXclist_push(struct HXclist_head *head, | ||||
struct HXlist_head *nu) | ||||
{ | ||||
++head->items; | ||||
__HXlist_add(nu, head->list.prev, &head->list); | ||||
} | ||||
static inline struct HXlist_head *__HXclist_pop(struct HXclist_head *head) | ||||
{ | ||||
struct HXlist_head *p; | ||||
if ((const void *)head == head->list.next) | ||||
return NULL; | ||||
p = head->list.prev; | ||||
HXlist_del(p); | ||||
--head->items; | ||||
return p; | ||||
} | ||||
#define HXclist_pop(head, type, member) ({ \ | ||||
struct HXlist_head *x = __HXclist_pop(head); \ | ||||
HXlist_entry(x, type, member); \ | ||||
}) | ||||
static inline struct HXlist_head *__HXclist_shift(struct HXclist_head *head | ||||
) | ||||
{ | ||||
struct HXlist_head *p; | ||||
if ((const void *)head == head->list.next) | ||||
return NULL; | ||||
p = head->list.next; | ||||
HXlist_del(p); | ||||
--head->items; | ||||
return p; | ||||
} | ||||
#define HXclist_shift(head, type, member) ({ \ | ||||
struct HXlist_head *x = __HXclist_shift(head); \ | ||||
HXlist_entry(x, type, member); \ | ||||
}) | ||||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} /* extern "C" */ | } /* extern "C" */ | |||
#endif | #endif | |||
#endif /* _LIBHX_LIST_H */ | #endif /* _LIBHX_LIST_H */ | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 74 lines changed or added | |||
misc.h | misc.h | |||
---|---|---|---|---|
skipping to change at line 17 | skipping to change at line 17 | |||
#else | #else | |||
# include <cstdarg> | # include <cstdarg> | |||
# include <cstdio> | # include <cstdio> | |||
#endif | #endif | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
struct stat; | struct stat; | |||
struct timespec; | ||||
struct timeval; | ||||
/* | /* | |||
* DIR.C | * DIR.C | |||
*/ | */ | |||
enum { | enum { | |||
HXF_UID = 1 << 0, | HXF_UID = 1 << 0, | |||
HXF_GID = 1 << 1, | HXF_GID = 1 << 1, | |||
HXF_KEEP = 1 << 2, | HXF_KEEP = 1 << 2, | |||
}; | }; | |||
skipping to change at line 55 | skipping to change at line 57 | |||
*/ | */ | |||
enum { | enum { | |||
HX_FSYSTEM_ARGV = 1 << 0, | HX_FSYSTEM_ARGV = 1 << 0, | |||
HX_FSYSTEM_EXEC = 1 << 1, | HX_FSYSTEM_EXEC = 1 << 1, | |||
HX_FSYSTEM_ARGV1 = 1 << 2, | HX_FSYSTEM_ARGV1 = 1 << 2, | |||
}; | }; | |||
extern int HX_ffs(unsigned long); | extern int HX_ffs(unsigned long); | |||
extern int HX_fls(unsigned long); | extern int HX_fls(unsigned long); | |||
extern void HX_hexdump(FILE *, const void *, unsigned int); | extern void HX_hexdump(FILE *, const void *, unsigned int); | |||
extern void HX_diff_timespec(struct timespec *, | ||||
const struct timespec *, const struct timespec *); | ||||
extern void HX_diff_timeval(struct timeval *, | ||||
const struct timeval *, const struct timeval *); | ||||
extern long HX_time_compare(const struct stat *, const struct stat *, char) ; | extern long HX_time_compare(const struct stat *, const struct stat *, char) ; | |||
extern void HX_zvecfree(char **); | extern void HX_zvecfree(char **); | |||
/* | /* | |||
* RAND.C | * RAND.C | |||
*/ | */ | |||
extern int HX_rand(void); | extern int HX_rand(void); | |||
extern unsigned int HX_irand(unsigned int, unsigned int); | extern unsigned int HX_irand(unsigned int, unsigned int); | |||
/* | /* | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 6 lines changed or added | |||
option.h | option.h | |||
---|---|---|---|---|
skipping to change at line 20 | skipping to change at line 20 | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
#ifndef __libhx_internal_hxmc_t_defined | #ifndef __libhx_internal_hxmc_t_defined | |||
#define __libhx_internal_hxmc_t_defined 1 | #define __libhx_internal_hxmc_t_defined 1 | |||
typedef char hxmc_t; | typedef char hxmc_t; | |||
#endif | #endif | |||
struct HXbtree; | struct HXformat_map; | |||
struct HXoption; | struct HXoption; | |||
/* | /* | |||
* FORMAT.C | * FORMAT.C | |||
*/ | */ | |||
extern struct HXbtree *HXformat_init(void); | extern struct HXformat_map *HXformat_init(void); | |||
extern void HXformat_free(struct HXbtree *); | extern void HXformat_free(struct HXformat_map *); | |||
extern int HXformat_add(struct HXbtree *, const char *, const void *, | extern int HXformat_add(struct HXformat_map *, const char *, const void *, | |||
unsigned int); | unsigned int); | |||
extern int HXformat_aprintf(const struct HXbtree *, hxmc_t **, const char * | extern int HXformat_aprintf(const struct HXformat_map *, | |||
); | hxmc_t **, const char *); | |||
extern int HXformat_sprintf(const struct HXbtree *, char *, size_t, const c | extern int HXformat_sprintf(const struct HXformat_map *, | |||
har *); | char *, size_t, const char *); | |||
extern int HXformat_fprintf(const struct HXbtree *, FILE *, const char *); | extern int HXformat_fprintf(const struct HXformat_map *, | |||
FILE *, const char *); | ||||
/* | /* | |||
* OPT.C | * OPT.C | |||
*/ | */ | |||
enum { | enum { | |||
/* .type */ | /* .type */ | |||
HXTYPE_NONE = 0, | HXTYPE_NONE = 0, | |||
/* for opt: set specific integer value */ | /* for opt: set specific integer value */ | |||
HXTYPE_VAL, | HXTYPE_VAL, | |||
/* for opt: set specific string value */ | /* for opt: set specific string value */ | |||
End of changes. 3 change blocks. | ||||
9 lines changed or deleted | 10 lines changed or added | |||