| 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) \ | | # define HXsizeof_member(type, member) \ | |
| sizeof(static_cast<type *>(NULL)->member) | | sizeof(static_cast<type *>(NULL)->member) | |
| # define HXtypeof_member(type, member) \ | | # define HXtypeof_member(type, member) \ | |
|
| typeof(static_cast<type *>(NULL)->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 62 | | skipping to change at line 62 | |
| 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 HXsizeof_member(type, member) sizeof(((type *)NULL)->member) | |
|
| # define HXtypeof_member(type, member) typeof(((type *)NULL)->member) | | # define HXtypeof_member(type, member) __typeof__(((type *)NULL)->memb
er) | |
| /* 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
*), \ | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| __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
*) || \ | |
| __builtin_types_compatible_p(a, char *) || \ | | __builtin_types_compatible_p(a, char *) || \ | |
| __builtin_types_compatible_p(a, signed char *) || \ | | __builtin_types_compatible_p(a, signed char *) || \ | |
| __builtin_types_compatible_p(a, unsigned char *) \ | | __builtin_types_compatible_p(a, unsigned char *) \ | |
| ) | | ) | |
| | | | |
| # if defined(__GNUC__) && !defined(signed_cast) | | # if defined(__GNUC__) && !defined(signed_cast) | |
| # define signed_cast(type, expr) ({ \ | | # define signed_cast(type, expr) ({ \ | |
|
| BUILD_BUG_ON(!__signed_cast_compatible(typeof(type),
typeof(expr))); \ | | BUILD_BUG_ON(!__signed_cast_compatible(__typeof__(ty
pe), __typeof__(expr))); \ | |
| (type)(expr); \ | | (type)(expr); \ | |
| }) | | }) | |
| # endif | | # endif | |
| # if defined(__GNUC__) && !defined(static_cast) | | # if defined(__GNUC__) && !defined(static_cast) | |
| # define static_cast(type, expr) \ | | # define static_cast(type, expr) \ | |
| ((struct { type x; }){(expr)}.x) | | ((struct { type x; }){(expr)}.x) | |
| # endif | | # endif | |
| # if defined(__GNUC__) && !defined(const_cast1) | | # if defined(__GNUC__) && !defined(const_cast1) | |
| # define __const_cast_strip1(expr) \ | | # define __const_cast_strip1(expr) \ | |
|
| typeof(*(struct { int z; typeof(expr) x; }){0}.x) | | __typeof__(*(struct { int z; __typeof__(expr) x; }){
0}.x) | |
| # define __const_cast_strip2(expr) \ | | # define __const_cast_strip2(expr) \ | |
|
| typeof(**(struct { int z; typeof(expr) x; }){0}.x) | | __typeof__(**(struct { int z; __typeof__(expr) x; })
{0}.x) | |
| # define __const_cast_strip3(expr) \ | | # define __const_cast_strip3(expr) \ | |
|
| typeof(***(struct { int z; typeof(expr) x; }){0}.x) | | __typeof__(***(struct { int z; __typeof__(expr) x; }
){0}.x) | |
| # define const_cast1(new_type, expr) ({ \ | | # define const_cast1(new_type, expr) ({ \ | |
| BUILD_BUG_ON(!__builtin_types_compatible_p(__const_c
ast_strip1(expr), __const_cast_strip1(new_type))); \ | | BUILD_BUG_ON(!__builtin_types_compatible_p(__const_c
ast_strip1(expr), __const_cast_strip1(new_type))); \ | |
| (new_type)(expr); \ | | (new_type)(expr); \ | |
| }) | | }) | |
| # define const_cast2(new_type, expr) ({ \ | | # define const_cast2(new_type, expr) ({ \ | |
| BUILD_BUG_ON(!__builtin_types_compatible_p(__const_c
ast_strip2(expr), __const_cast_strip2(new_type))); \ | | BUILD_BUG_ON(!__builtin_types_compatible_p(__const_c
ast_strip2(expr), __const_cast_strip2(new_type))); \ | |
| (new_type)(expr); \ | | (new_type)(expr); \ | |
| }) | | }) | |
| # define const_cast3(new_type, expr) ({ \ | | # define const_cast3(new_type, expr) ({ \ | |
| BUILD_BUG_ON(!__builtin_types_compatible_p(__const_c
ast_strip3(expr), __const_cast_strip3(new_type))); \ | | BUILD_BUG_ON(!__builtin_types_compatible_p(__const_c
ast_strip3(expr), __const_cast_strip3(new_type))); \ | |
| | | | |
End of changes. 6 change blocks. |
| 6 lines changed or deleted | | 6 lines changed or added | |
|
| libHX.h | | libHX.h | |
| #ifndef _LIBHX_H | | #ifndef _LIBHX_H | |
|
| #define _LIBHX_H 20090101 | | #define _LIBHX_H 20110115 | |
| | | | |
| /* | | /* | |
| * 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/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/init.h> | | #include <libHX/init.h> | |
|
| | | #include <libHX/io.h> | |
| #include <libHX/map.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. |
| 1 lines changed or deleted | | 2 lines changed or added | |
|
| list.h | | list.h | |
| | | | |
| skipping to change at line 82 | | skipping to change at line 82 | |
| | | | |
| #define HXlist_for_each_safe(pos, n, head) \ | | #define HXlist_for_each_safe(pos, n, head) \ | |
| for ((pos) = (head)->next, (n) = (pos)->next; (pos) != (void *)(head
); \ | | for ((pos) = (head)->next, (n) = (pos)->next; (pos) != (void *)(head
); \ | |
| (pos) = (n), (n) = (pos)->next) | | (pos) = (n), (n) = (pos)->next) | |
| | | | |
| #define HXlist_for_each_rev_safe(pos, n, head) \ | | #define HXlist_for_each_rev_safe(pos, n, head) \ | |
| for ((pos) = (head)->prev, (n) = (pos)->prev; (pos) != (void *)(head
); \ | | for ((pos) = (head)->prev, (n) = (pos)->prev; (pos) != (void *)(head
); \ | |
| (pos) = (n), (n) = (pos)->prev) | | (pos) = (n), (n) = (pos)->prev) | |
| | | | |
| #define HXlist_for_each_entry(pos, head, member) \ | | #define HXlist_for_each_entry(pos, head, member) \ | |
|
| for ((pos) = HXlist_entry((head)->next, typeof(*(pos)), member); \ | | for ((pos) = HXlist_entry((head)->next, __typeof__(*(pos)), member);
\ | |
| &(pos)->member != (void *)(head); \ | | &(pos)->member != (void *)(head); \ | |
|
| (pos) = HXlist_entry((pos)->member.next, typeof(*(pos)), member
)) | | (pos) = HXlist_entry((pos)->member.next, __typeof__(*(pos)), me
mber)) | |
| | | | |
| #define HXlist_for_each_entry_rev(pos, head, member) \ | | #define HXlist_for_each_entry_rev(pos, head, member) \ | |
|
| for ((pos) = HXlist_entry((head)->prev, typeof(*(pos)), member); \ | | for ((pos) = HXlist_entry((head)->prev, __typeof__(*(pos)), member);
\ | |
| &(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)), me
mber)) | |
| | | | |
| #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)), memb | |
| | | er); \ | |
| &(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 { | | struct HXclist_head { | |
| union { | | union { | |
| struct HXlist_head list; | | struct HXlist_head list; | |
| struct { | | struct { | |
| struct HXlist_head *next, *prev; | | struct HXlist_head *next, *prev; | |
| }; | | }; | |
| }; | | }; | |
| unsigned int items; | | unsigned int items; | |
| | | | |
End of changes. 6 change blocks. |
| 8 lines changed or deleted | | 9 lines changed or added | |
|
| map.h | | map.h | |
| | | | |
| skipping to change at line 39 | | skipping to change at line 39 | |
| HXMAPT_DEFAULT = HXMAPT_HASH, | | HXMAPT_DEFAULT = HXMAPT_HASH, | |
| HXMAPT_ORDERED = HXMAPT_RBTREE, | | HXMAPT_ORDERED = HXMAPT_RBTREE, | |
| }; | | }; | |
| | | | |
| /** | | /** | |
| * Flags changable at runtime: | | * Flags changable at runtime: | |
| * %HXMAP_NOREPLACE: Calling HXmap_add() for an already existing key will | | * %HXMAP_NOREPLACE: Calling HXmap_add() for an already existing key will | |
| * throw an error (no-overwrite semantics) | | * throw an error (no-overwrite semantics) | |
| * | | * | |
| * Initialization-time flags only: | | * Initialization-time flags only: | |
|
| | | * %HXMAP_NONE: mnemonic for no flags | |
| * %HXMAP_SINGULAR: Instead of an associative map, provide a set | | * %HXMAP_SINGULAR: Instead of an associative map, provide a set | |
| * %HXMAP_SKEY: Key will be a C-style string (sets ops->k_*) | | * %HXMAP_SKEY: Key will be a C-style string (sets ops->k_*) | |
| * %HXMAP_CKEY: Make a copy of the key on HXmap_add | | * %HXMAP_CKEY: Make a copy of the key on HXmap_add | |
| * %HXMAP_SDATA: Data will be a C-style string (presets ops->d_*) | | * %HXMAP_SDATA: Data will be a C-style string (presets ops->d_*) | |
| * %HXMAP_CDATA: Make a copy of the data on HXmap_add | | * %HXMAP_CDATA: Make a copy of the data on HXmap_add | |
| */ | | */ | |
| enum { | | enum { | |
|
| | | HXMAP_NONE = 0, | |
| HXMAP_NOREPLACE = 1 << 0, | | HXMAP_NOREPLACE = 1 << 0, | |
| HXMAP_SINGULAR = 1 << 27, | | HXMAP_SINGULAR = 1 << 27, | |
| HXMAP_SKEY = 1 << 28, | | HXMAP_SKEY = 1 << 28, | |
| HXMAP_CKEY = 1 << 29, | | HXMAP_CKEY = 1 << 29, | |
| HXMAP_SDATA = 1 << 30, | | HXMAP_SDATA = 1 << 30, | |
| HXMAP_CDATA = 1 << 31, | | HXMAP_CDATA = 1 << 31, | |
| | | | |
| HXMAP_SCKEY = HXMAP_SKEY | HXMAP_CKEY, | | HXMAP_SCKEY = HXMAP_SKEY | HXMAP_CKEY, | |
| HXMAP_SCDATA = HXMAP_SDATA | HXMAP_CDATA, | | HXMAP_SCDATA = HXMAP_SDATA | HXMAP_CDATA, | |
| }; | | }; | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 2 lines changed or added | |
|
| misc.h | | misc.h | |
| | | | |
| skipping to change at line 13 | | skipping to change at line 13 | |
| | | | |
| #ifndef __cplusplus | | #ifndef __cplusplus | |
| # include <limits.h> | | # include <limits.h> | |
| # include <stdarg.h> | | # include <stdarg.h> | |
| # include <stdio.h> | | # include <stdio.h> | |
| #else | | #else | |
| # include <climits> | | # include <climits> | |
| # include <cstdarg> | | # include <cstdarg> | |
| # include <cstdio> | | # include <cstdio> | |
| #endif | | #endif | |
|
| | | #include <libHX/io.h> | |
| | | | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| extern "C" { | | extern "C" { | |
| #endif | | #endif | |
| | | | |
| /* | | /* | |
| * BITMAP.H | | * BITMAP.H | |
| */ | | */ | |
| #define __HXbitmap_bpq(type) \ | | #define __HXbitmap_bpq(type) \ | |
| (sizeof(type) * CHAR_BIT) | | (sizeof(type) * CHAR_BIT) | |
| | | | |
| skipping to change at line 34 | | skipping to change at line 35 | |
| ((bits + __HXbitmap_bpq(type) - 1) / __HXbitmap_bpq(type)) | | ((bits + __HXbitmap_bpq(type) - 1) / __HXbitmap_bpq(type)) | |
| #define __HXbitmap_quant(map, bit) \ | | #define __HXbitmap_quant(map, bit) \ | |
| ((map)[bit / __HXbitmap_bpq(*(map))]) | | ((map)[bit / __HXbitmap_bpq(*(map))]) | |
| #define HXbitmap_set(map, bit) \ | | #define HXbitmap_set(map, bit) \ | |
| ((void)(__HXbitmap_quant(map, bit) |= (1ULL << (bit % __HXbitmap_bpq
(*(map)))))) | | ((void)(__HXbitmap_quant(map, bit) |= (1ULL << (bit % __HXbitmap_bpq
(*(map)))))) | |
| #define HXbitmap_clear(map, bit) \ | | #define HXbitmap_clear(map, bit) \ | |
| ((void)(__HXbitmap_quant(map, bit) &= ~(1ULL << (bit % __HXbitmap_bp
q(*(map)))))) | | ((void)(__HXbitmap_quant(map, bit) &= ~(1ULL << (bit % __HXbitmap_bp
q(*(map)))))) | |
| #define HXbitmap_test(map, bit) \ | | #define HXbitmap_test(map, bit) \ | |
| ((bool)(__HXbitmap_quant(map, bit) & (1ULL << (bit % __HXbitmap_bpq(
*(map)))))) | | ((bool)(__HXbitmap_quant(map, bit) & (1ULL << (bit % __HXbitmap_bpq(
*(map)))))) | |
| | | | |
|
| struct HXdir; | | | |
| struct stat; | | struct stat; | |
| struct timespec; | | struct timespec; | |
| struct timeval; | | struct timeval; | |
| | | | |
| /* | | /* | |
|
| * DIR.C | | | |
| */ | | | |
| enum { | | | |
| HXF_UID = 1 << 0, | | | |
| HXF_GID = 1 << 1, | | | |
| HXF_KEEP = 1 << 2, | | | |
| }; | | | |
| | | | |
| extern struct HXdir *HXdir_open(const char *); | | | |
| extern const char *HXdir_read(struct HXdir *); | | | |
| extern void HXdir_close(struct HXdir *); | | | |
| extern int HX_copy_dir(const char *, const char *, unsigned int, ...); | | | |
| extern int HX_copy_file(const char *, const char *, unsigned int, ...); | | | |
| extern int HX_mkdir(const char *); | | | |
| extern int HX_rrmdir(const char *); | | | |
| | | | |
| /* | | | |
| * DL.C | | * DL.C | |
| */ | | */ | |
| extern void *HX_dlopen(const char *); | | extern void *HX_dlopen(const char *); | |
| extern void *HX_dlsym(void *, const char *); | | extern void *HX_dlsym(void *, const char *); | |
| extern void HX_dlclose(void *); | | extern void HX_dlclose(void *); | |
| extern const char *HX_dlerror(void); | | extern const char *HX_dlerror(void); | |
| | | | |
| /* | | /* | |
| * MISC.C | | * MISC.C | |
| */ | | */ | |
| | | | |
End of changes. 3 change blocks. |
| 18 lines changed or deleted | | 1 lines changed or added | |
|