defs.h | defs.h | |||
---|---|---|---|---|
skipping to change at line 143 | skipping to change at line 143 | |||
# define offsetof(type, member) \ | # define offsetof(type, member) \ | |||
reinterpret_cast(long, &(static_cast(type *, NULL)-> member)) | reinterpret_cast(long, &(static_cast(type *, NULL)-> member)) | |||
# endif | # endif | |||
# ifndef containerof | # ifndef containerof | |||
# define containerof(var, type, member) reinterpret_cast(type *, \ | # define containerof(var, type, member) reinterpret_cast(type *, \ | |||
reinterpret_cast(char *, var) - offsetof(type, membe r)) | reinterpret_cast(char *, var) - offsetof(type, membe r)) | |||
# endif | # endif | |||
#endif | #endif | |||
#if defined(__GNUC__) && !defined(__cplusplus) | #if defined(__GNUC__) && !defined(__cplusplus) | |||
/* | ||||
* If typeof @a stays the same through a demotion to pointer, | ||||
* @a cannot be an array. | ||||
*/ | ||||
# define __array_size_check(a) BUILD_BUG_ON_EXPR(\ | # define __array_size_check(a) BUILD_BUG_ON_EXPR(\ | |||
__builtin_types_compatible_p(__typeof__(a), __typeof__(&*(a) ))) | __builtin_types_compatible_p(__typeof__(a), \ | |||
__typeof__(DEMOTE_TO_PTR(a)))) | ||||
#else | #else | |||
# define __array_size_check(a) 0 | # define __array_size_check(a) 0 | |||
#endif | #endif | |||
#ifndef ARRAY_SIZE | #ifndef ARRAY_SIZE | |||
# define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)) + __array_size_check( x)) | # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)) + __array_size_check( x)) | |||
#endif | #endif | |||
#ifndef BUILD_BUG_ON_EXPR | #ifndef BUILD_BUG_ON_EXPR | |||
# define BUILD_BUG_ON_EXPR(condition) (sizeof(char[1 - 2 * !!(conditio n)]) - 1) | # define BUILD_BUG_ON_EXPR(condition) (sizeof(char[1 - 2 * !!(conditio n)]) - 1) | |||
#endif | #endif | |||
#ifndef BUILD_BUG_ON | #ifndef BUILD_BUG_ON | |||
# define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_EXPR(condition)) | # define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_EXPR(condition)) | |||
#endif | #endif | |||
#ifndef DEMOTE_TO_PTR | ||||
/* | ||||
* An alternative approach is also (p+0), but that does not ensure t hat | ||||
* @p is a pointer. Since functions "support" infinite dereferencing , | ||||
* "&*" also works on them. | ||||
*/ | ||||
# define DEMOTE_TO_PTR(p) (&*(p)) | ||||
#endif | ||||
#ifndef O_BINARY | #ifndef O_BINARY | |||
# define O_BINARY 0 | # define O_BINARY 0 | |||
#endif | #endif | |||
#ifndef S_IRUGO | #ifndef S_IRUGO | |||
# define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) | # define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) | |||
#endif | #endif | |||
#ifndef S_IWUGO | #ifndef S_IWUGO | |||
# define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH) | # define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH) | |||
#endif | #endif | |||
#ifndef S_IXUGO | #ifndef S_IXUGO | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 14 lines changed or added | |||
io.h | io.h | |||
---|---|---|---|---|
skipping to change at line 23 | skipping to change at line 23 | |||
#endif | #endif | |||
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, | |||
HX_REALPATH_NOFLAGS = 0, | HX_REALPATH_NOFLAGS = 0, | |||
HX_REALPATH_ABSOLUTE = 1 << 0, | HX_REALPATH_ABSOLUTE = 1 << 0, | |||
HX_REALPATH_SELF = 1 << 1, | HX_REALPATH_SELF = 1 << 1, | |||
HX_REALPATH_PARENT = 1 << 2, | HX_REALPATH_PARENT = 1 << 2, | |||
HX_REALPATH_SYMLINK = 1 << 3, | /* HX_REALPATH_SYMLINK = 1 << 3, removed in v3.13, thus blocked */ | |||
HX_REALPATH_DEFAULT = | HX_REALPATH_DEFAULT = HX_REALPATH_SELF | HX_REALPATH_PARENT, | |||
HX_REALPATH_SELF | HX_REALPATH_PARENT | HX_REALPATH_SYMLINK, | ||||
}; | }; | |||
struct HXdir; | struct HXdir; | |||
extern struct HXdir *HXdir_open(const char *); | extern struct HXdir *HXdir_open(const char *); | |||
extern const char *HXdir_read(struct HXdir *); | extern const char *HXdir_read(struct HXdir *); | |||
extern void HXdir_close(struct HXdir *); | extern void HXdir_close(struct HXdir *); | |||
extern int HX_copy_dir(const char *, const char *, unsigned int, ...); | 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_copy_file(const char *, const char *, unsigned int, ...); | |||
extern int HX_mkdir(const char *, unsigned int); | extern int HX_mkdir(const char *, unsigned int); | |||
End of changes. 1 change blocks. | ||||
3 lines changed or deleted | 2 lines changed or added | |||
misc.h | misc.h | |||
---|---|---|---|---|
#ifndef _LIBHX_MISC_H | #ifndef _LIBHX_MISC_H | |||
#define _LIBHX_MISC_H 1 | #define _LIBHX_MISC_H 1 | |||
#ifndef __cplusplus | #ifndef __cplusplus | |||
# include <limits.h> | # include <limits.h> | |||
# include <stdarg.h> | # include <stdarg.h> | |||
# include <stdbool.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/defs.h> | ||||
#include <libHX/io.h> | #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) \ | |||
skipping to change at line 35 | skipping to change at line 37 | |||
(((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) % __HXbitm ap_bpq(*(map)))))) | ((void)(__HXbitmap_quant((map), (bit)) |= (1ULL << ((bit) % __HXbitm ap_bpq(*(map)))))) | |||
#define HXbitmap_clear(map, bit) \ | #define HXbitmap_clear(map, bit) \ | |||
((void)(__HXbitmap_quant((map), (bit)) &= ~(1ULL << ((bit) % __HXbit map_bpq(*(map)))))) | ((void)(__HXbitmap_quant((map), (bit)) &= ~(1ULL << ((bit) % __HXbit map_bpq(*(map)))))) | |||
#define HXbitmap_test(map, bit) \ | #define HXbitmap_test(map, bit) \ | |||
((bool)(__HXbitmap_quant((map), (bit)) & (1ULL << ((bit) % __HXbitma p_bpq(*(map)))))) | ((bool)(__HXbitmap_quant((map), (bit)) & (1ULL << ((bit) % __HXbitma p_bpq(*(map)))))) | |||
#define HX_TIMESPEC_EXP(p) static_cast(long, (p)->tv_sec), (p)->tv_nsec | ||||
#define HX_TIMESPEC_FMT "%ld.%09ld" | ||||
#define HX_TIMEVAL_EXP(p) static_cast(long, (p)->tv_sec), (p)->tv_usec | ||||
#define HX_TIMEVAL_FMT "%ld.%06ld" | ||||
struct stat; | struct stat; | |||
struct timespec; | struct timespec; | |||
struct timeval; | struct timeval; | |||
/* | /* | |||
* 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 | |||
*/ | */ | |||
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 *, | extern bool HX_timespec_isneg(const struct timespec *); | |||
extern struct timespec *HX_timespec_neg(struct timespec *, | ||||
const struct timespec *); | ||||
extern struct timespec *HX_timespec_add(struct timespec *, | ||||
const struct timespec *, const struct timespec *); | ||||
extern struct timespec *HX_timespec_sub(struct timespec *, | ||||
const struct timespec *, const struct timespec *); | const struct timespec *, const struct timespec *); | |||
extern void HX_diff_timeval(struct timeval *, | extern struct timespec *HX_timespec_mul(struct timespec *, | |||
const struct timespec *, int); | ||||
extern struct timespec *HX_timespec_mulf(struct timespec *, | ||||
const struct timespec *, double); | ||||
extern struct timeval *HX_timeval_sub(struct timeval *, | ||||
const struct timeval *, const 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); | |||
extern double HX_drand(double, double); | extern double HX_drand(double, double); | |||
End of changes. 5 change blocks. | ||||
2 lines changed or deleted | 18 lines changed or added | |||
option.h | option.h | |||
---|---|---|---|---|
skipping to change at line 75 | skipping to change at line 75 | |||
* %HXTYPE_UINT16: [-o] (uint8_t *) An integer. | * %HXTYPE_UINT16: [-o] (uint8_t *) An integer. | |||
* %HXTYPE_UINT32: [-o] (uint8_t *) An integer. | * %HXTYPE_UINT32: [-o] (uint8_t *) An integer. | |||
* %HXTYPE_UINT64: [-o] (uint8_t *) An integer. | * %HXTYPE_UINT64: [-o] (uint8_t *) An integer. | |||
* %HXTYPE_INT8: [-o] (uint8_t *) An integer. | * %HXTYPE_INT8: [-o] (uint8_t *) An integer. | |||
* %HXTYPE_INT16: [-o] (uint8_t *) An integer. | * %HXTYPE_INT16: [-o] (uint8_t *) An integer. | |||
* %HXTYPE_INT32: [-o] (uint8_t *) An integer. | * %HXTYPE_INT32: [-o] (uint8_t *) An integer. | |||
* %HXTYPE_INT64: [-o] (uint8_t *) An integer. | * %HXTYPE_INT64: [-o] (uint8_t *) An integer. | |||
* %HXTYPE_MCSTR: [-o] (hxmc_t *) A string. | * %HXTYPE_MCSTR: [-o] (hxmc_t *) A string. | |||
* %HXTYPE_XSNTMARK: [-o] Internal sentinal marker (used in HXOPT_TABLEEN D) | * %HXTYPE_XSNTMARK: [-o] Internal sentinal marker (used in HXOPT_TABLEEN D) | |||
* %HXTYPE_XHELP: [-o] Internal helper marker (used in HXOPT_AUTOHELP) | * %HXTYPE_XHELP: [-o] Internal helper marker (used in HXOPT_AUTOHELP) | |||
* %HXTYPE_SIZE_T: [-o] (size_t *) An integer. | ||||
* | * | |||
* Type expected of struct HXoption.ptr is given in (). | * Type expected of struct HXoption.ptr is given in (). | |||
* HX_getopt (o) and HXformat_* (f) support different sets, marked with []. | * HX_getopt (o) and HXformat_* (f) support different sets, marked with []. | |||
*/ | */ | |||
enum HX_option_type { | enum HX_option_type { | |||
HXTYPE_NONE = 0, | HXTYPE_NONE = 0, | |||
HXTYPE_VAL, | HXTYPE_VAL, | |||
HXTYPE_SVAL, | HXTYPE_SVAL, | |||
HXTYPE_BOOL, | HXTYPE_BOOL, | |||
HXTYPE_BYTE, | HXTYPE_BYTE, | |||
skipping to change at line 111 | skipping to change at line 112 | |||
HXTYPE_UINT16, | HXTYPE_UINT16, | |||
HXTYPE_UINT32, | HXTYPE_UINT32, | |||
HXTYPE_UINT64, | HXTYPE_UINT64, | |||
HXTYPE_INT8, | HXTYPE_INT8, | |||
HXTYPE_INT16, /* 25 */ | HXTYPE_INT16, /* 25 */ | |||
HXTYPE_INT32, | HXTYPE_INT32, | |||
HXTYPE_INT64, | HXTYPE_INT64, | |||
HXTYPE_MCSTR, | HXTYPE_MCSTR, | |||
HXTYPE_XSNTMARK, | HXTYPE_XSNTMARK, | |||
HXTYPE_XHELP, /* 30 */ | HXTYPE_XHELP, /* 30 */ | |||
HXTYPE_SIZE_T, | ||||
}; | }; | |||
/** | /** | |||
* Extra flags to be OR'ed into struct HXoption.type. | * Extra flags to be OR'ed into struct HXoption.type. | |||
* %HXOPT_OPTIONAL: argument to option is optional | * %HXOPT_OPTIONAL: argument to option is optional | |||
* (it's bad taste to use this) | * (it's bad taste to use this) | |||
* %HXOPT_INC: increase variable pointed to by .ptr. | * %HXOPT_INC: increase variable pointed to by .ptr. | |||
* (only applies to %HXTYPE_NONE) | * (only applies to %HXTYPE_NONE) | |||
* %HXOPT_DEC: increase variable pointed to by .ptr. | * %HXOPT_DEC: increase variable pointed to by .ptr. | |||
* (only applies to %HXTYPE_NONE) | * (only applies to %HXTYPE_NONE) | |||
skipping to change at line 143 | skipping to change at line 145 | |||
HXOPT_XOR = 1 << 12, | HXOPT_XOR = 1 << 12, | |||
}; | }; | |||
/** | /** | |||
* Flags (4th arg) to HX_getopt. | * Flags (4th arg) to HX_getopt. | |||
* %HXOPT_PTHRU: pass-through unknown options to new argv | * %HXOPT_PTHRU: pass-through unknown options to new argv | |||
* %HXOPT_DESTROY_OLD: destroy old argv after parsing is successful | * %HXOPT_DESTROY_OLD: destroy old argv after parsing is successful | |||
* %HXOPT_QUIET: do not output any warnings to stderr | * %HXOPT_QUIET: do not output any warnings to stderr | |||
* %HXOPT_HELPONERR: print out help when a parsing error occurs | * %HXOPT_HELPONERR: print out help when a parsing error occurs | |||
* %HXOPT_USAGEONERR: print out short usage when a parsing error occurs | * %HXOPT_USAGEONERR: print out short usage when a parsing error occurs | |||
* %HXOPT_RQ_ORDER: require option order/POSIX mode: | ||||
* first non-option terminates option processing | ||||
*/ | */ | |||
enum { | enum { | |||
HXOPT_PTHRU = 1 << 0, | HXOPT_PTHRU = 1 << 0, | |||
HXOPT_DESTROY_OLD = 1 << 1, | HXOPT_DESTROY_OLD = 1 << 1, | |||
HXOPT_QUIET = 1 << 2, | HXOPT_QUIET = 1 << 2, | |||
HXOPT_HELPONERR = 1 << 3, | HXOPT_HELPONERR = 1 << 3, | |||
HXOPT_USAGEONERR = 1 << 4, | HXOPT_USAGEONERR = 1 << 4, | |||
HXOPT_RQ_ORDER = 1 << 5, | ||||
}; | }; | |||
/** | /** | |||
* (Positive-ranged) return values for HX_getopt. | * (Positive-ranged) return values for HX_getopt. | |||
* %HXOPT_ERR_SUCCESS: success | * %HXOPT_ERR_SUCCESS: success | |||
* %HXOPT_ERR_UNKN: unknown option was encountered | * %HXOPT_ERR_UNKN: unknown option was encountered | |||
* %HXOPT_ERR_VOID: long option takes no value | * %HXOPT_ERR_VOID: long option takes no value | |||
* %HXOPT_ERR_MIS: option requires a value argument | * %HXOPT_ERR_MIS: option requires a value argument | |||
*/ | */ | |||
enum { | enum { | |||
End of changes. 4 change blocks. | ||||
0 lines changed or deleted | 5 lines changed or added | |||