X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Futil.h;h=b97731b56730936c68077197a60fe6125fa141a4;hp=083ddb2e14e4b6ed8d7344bf7bc77a069a4a6dc9;hb=a6f5add5e9811584ebd75591a6a25cb9686da9a8;hpb=36a737d734cdc6c6eb0ce9da3183a1f8fa4288e6 diff --git a/src/util.h b/src/util.h index 083ddb2e..b97731b5 100644 --- a/src/util.h +++ b/src/util.h @@ -10,24 +10,21 @@ #ifdef __GNUC__ # define WIMLIBAPI __attribute__((visibility("default"))) -# define NOINLINE __attribute__((noinline)) # define ALWAYS_INLINE inline __attribute__((always_inline)) +# define PACKED __attribute__((packed)) # define FORMAT(type, format_str, args_start) \ __attribute__((format(type, format_str, args_start))) # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) # define COLD __attribute__((cold)) -# define HOT __attribute__((hot)) # else # define COLD -# define HOT # endif #else # define WIMLIBAPI -# define NOINLINE # define ALWAYS_INLINE inline # define FORMAT(type, format_str, args_start) # define COLD -# define HOT +# define PACKED #endif /* __GNUC__ */ @@ -47,7 +44,6 @@ typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; #endif -typedef unsigned uint; #ifndef min #define min(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); \ @@ -135,6 +131,12 @@ extern void wimlib_warning(const char *format, ...) # define wimlib_assert(expr) #endif +#ifdef ENABLE_MORE_ASSERTIONS +#define wimlib_assert2(expr) wimlib_assert(expr) +#else +#define wimlib_assert2(expr) +#endif + #ifdef ENABLE_CUSTOM_MEMORY_ALLOCATOR extern void *(*wimlib_malloc_func)(size_t); @@ -158,12 +160,14 @@ extern char *wimlib_strdup(const char *str); #endif /* ENABLE_CUSTOM_MEMORY_ALLOCATOR */ -extern char *utf16_to_utf8(const char *utf16_str, size_t utf16_len, - size_t *utf8_len_ret); +/* encoding.c */ +extern int utf16_to_utf8(const char *utf16_str, size_t utf16_nbytes, + char **utf8_str_ret, size_t *utf8_nbytes_ret); -extern char *utf8_to_utf16(const char *utf8_str, size_t utf8_len, - size_t *utf16_len_ret); +extern int utf8_to_utf16(const char *utf8_str, size_t utf8_nbytes, + char **utf16_str_ret, size_t *utf16_nbytes_ret); +/* util.c */ extern void randomize_byte_array(u8 *p, size_t n); extern void randomize_char_array_with_alnum(char p[], size_t n);