X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Futil.h;h=82fc5fb4e9640629a291837bdb2193fbdace6703;hb=d04a25a537201b46832cac28725a45bf559dc318;hp=40f6294e3d80e232832228e4968bc1e71ce948a2;hpb=f1c07e953597e3f6a809d35d7d5160af1ff67ed3;p=wimlib diff --git a/include/wimlib/util.h b/include/wimlib/util.h index 40f6294e..82fc5fb4 100644 --- a/include/wimlib/util.h +++ b/include/wimlib/util.h @@ -24,6 +24,10 @@ /* Get the number of elements of an array type. */ #define ARRAY_LEN(array) (sizeof(array) / sizeof((array)[0])) +/* Round 'v' up to the next 'alignment'-byte aligned boundary. 'alignment' must + * be a power of 2. */ +#define ALIGN(v, alignment) (((v) + ((alignment) - 1)) & ~((alignment) - 1)) + /* Maximum number of bytes that can be allocated on the stack. * * Note: this isn't a hard bound on the stack space used, since this is just for @@ -84,9 +88,6 @@ extern void * mempcpy(void *dst, const void *src, size_t n); #endif -extern size_t -utf16le_strlen(const utf16lechar *s); - extern void randomize_byte_array(u8 *p, size_t n); @@ -110,6 +111,16 @@ hash_u64(u64 n) return n * 0x9e37fffffffc0001ULL; } +static inline int +cmp_u32(u32 n1, u32 n2) +{ + if (n1 < n2) + return -1; + if (n1 > n2) + return 1; + return 0; +} + static inline int cmp_u64(u64 n1, u64 n2) { @@ -120,4 +131,14 @@ cmp_u64(u64 n1, u64 n2) return 0; } +/************************ + * System information + ************************/ + +unsigned +get_available_cpus(void); + +u64 +get_available_memory(void); + #endif /* _WIMLIB_UTIL_H */