diff options
-rw-r--r-- | libsimple-arg.h | 38 | ||||
-rw-r--r-- | libsimple.h | 6 | ||||
-rw-r--r-- | libsimple/aligned_alloc.h | 16 | ||||
-rw-r--r-- | libsimple/aligned_allocz.h | 18 | ||||
-rw-r--r-- | libsimple/aligned_memdup.h | 8 | ||||
-rw-r--r-- | libsimple/array.h | 27 | ||||
-rw-r--r-- | libsimple/calloc.h | 16 | ||||
-rw-r--r-- | libsimple/definitions.h | 28 | ||||
-rw-r--r-- | libsimple/env.h | 16 | ||||
-rw-r--r-- | libsimple/malloc.h | 16 | ||||
-rw-r--r-- | libsimple/mallocz.h | 18 | ||||
-rw-r--r-- | libsimple/mem.h | 92 | ||||
-rw-r--r-- | libsimple/memalign.h | 18 | ||||
-rw-r--r-- | libsimple/memalignz.h | 18 | ||||
-rw-r--r-- | libsimple/memalloc.h | 20 | ||||
-rw-r--r-- | libsimple/memdup.h | 8 | ||||
-rw-r--r-- | libsimple/memelem.h | 34 | ||||
-rw-r--r-- | libsimple/overflow.h | 64 | ||||
-rw-r--r-- | libsimple/posix_memalign.h | 16 | ||||
-rw-r--r-- | libsimple/posix_memalignz.h | 18 | ||||
-rw-r--r-- | libsimple/printf.h | 26 | ||||
-rw-r--r-- | libsimple/pvalloc.h | 18 | ||||
-rw-r--r-- | libsimple/pvallocz.h | 18 | ||||
-rw-r--r-- | libsimple/realloc.h | 16 | ||||
-rw-r--r-- | libsimple/str.h | 84 | ||||
-rw-r--r-- | libsimple/strdup.h | 6 | ||||
-rw-r--r-- | libsimple/strn.h | 86 | ||||
-rw-r--r-- | libsimple/strndup.h | 6 | ||||
-rw-r--r-- | libsimple/time.h | 38 | ||||
-rw-r--r-- | libsimple/valloc.h | 18 | ||||
-rw-r--r-- | libsimple/vallocz.h | 18 |
31 files changed, 826 insertions, 3 deletions
diff --git a/libsimple-arg.h b/libsimple-arg.h index 983f4c8..3ffc3ed 100644 --- a/libsimple-arg.h +++ b/libsimple-arg.h @@ -10,6 +10,8 @@ /** * The zeroth command line argument, the name of the process, * set by the command line parsing macros + * + * @since 1.0 */ extern char *argv0; @@ -23,6 +25,8 @@ extern char *argv0; * where `.long_flag` does not end with '=' and * `.with_arg` is zero. These *cannot* have the same * `.short_flag` + * + * @since 1.0 */ struct longopt { /** @@ -83,6 +87,8 @@ struct longopt { * // print usage information for other flags * usage(); * } ARGEND; + * + * @since 1.0 */ #define ARGBEGIN ARGBEGIN2(1, 0) @@ -91,6 +97,8 @@ struct longopt { * `ARGBEGIN {} ARGEND;`, however, `argv0` * is not set to `argv[0]`, instead `argv[0]` * is handled like any other element in `argv` + * + * @since 1.0 */ #define SUBARGBEGIN ARGBEGIN2(0, 0) @@ -102,6 +110,8 @@ struct longopt { * @param KEEP_DASHDASH If and only if 0, "--" is not removed * `argv` before parsing is stopped when it * is encountered + * + * @since 1.1 */ #define ARGBEGIN2(WITH_ARGV0, KEEP_DASHDASH)\ do {\ @@ -146,6 +156,8 @@ struct longopt { * * @param LONGOPTS:struct longopt * The options, list shall end * with `NULL` as `.long_flag` + * + * @since 1.0 */ #define ARGMAPLONG(LONGOPTS)\ for (i_ = 0; (LONGOPTS)[i_].long_flag; i_++) {\ @@ -180,6 +192,8 @@ struct longopt { * } ARGEND; * * @param SYMBOL:char The symbol flags should begin with + * + * @since 1.0 */ #define ARGALT(SYMBOL)\ }\ @@ -204,7 +218,9 @@ struct longopt { switch (flag_) { /** - * Refer to `ARGBEGIN`, `SUBARGBEGIN`, and `ARGBEGIN4` + * Refer to `ARGBEGIN`, `SUBARGBEGIN`, and `ARGBEGIN2` + * + * @since 1.0 */ #define ARGEND\ }\ @@ -225,6 +241,8 @@ struct longopt { /** * `case ARGNUM` creates a switch statement case for each digit + * + * @since 1.0 */ #define ARGNUM '0': case '1': case '2': case '3': case '4':\ case '5': case '6': case '7': case '8': case '9' @@ -234,6 +252,8 @@ struct longopt { * 'a' is returned * * @return :char The option's identifying character + * + * @since 1.0 */ #define FLAG() (flag_) @@ -245,6 +265,8 @@ struct longopt { * value can also be in the next argument * * @return :char * The current command line argument + * + * @since 1.0 */ #define LFLAG() (lflag_) @@ -257,6 +279,8 @@ struct longopt { * that the option has a value * * @return :char * The option's value, never `NULL` + * + * @since 1.0 */ #define ARG() (arg_ ? (brk_ = 1, arg_) : (usage(), NULL)) @@ -273,6 +297,8 @@ struct longopt { * * @return :char * The option's value, `NULL` if * the option does not have a value + * + * @since 1.1 */ #define ARGNULL() (arg_ ? (brk_ = 1, arg_) : NULL) @@ -308,6 +334,8 @@ struct longopt { * * @return :char * The option's value include the flag * character, never `NULL` or "" + * + * @since 1.0 */ #define ARGHERE() (brk_ = 1, argv[0]) @@ -337,6 +365,8 @@ struct longopt { * must not have side-effects * @param WARG:int Whether the option takes an argument, * should not have side-effects + * + * @since 1.0 */ #define TESTLONG(FLG, WARG)\ ((WARG)\ @@ -368,6 +398,8 @@ struct longopt { * * @param ... If non-zero, the `usage` function * will be called + * + * @since 1.0 */ #define NOFLAGS(...)\ do {\ @@ -394,6 +426,8 @@ struct longopt { * This macro also defines `char *argv0` * * @param SYNOPSIS:const char * Description of the command line argument syntax + * + * @since 1.0 */ #define USAGE(SYNOPSIS)\ NUSAGE(1, SYNOPSIS) @@ -422,6 +456,8 @@ struct longopt { * * @param SYNOPSIS:const char * Description of the command line argument syntax * @parma STATUS:int The exit value for the process + * + * @since 1.0 */ #define NUSAGE(STATUS, SYNOPSIS)\ static _LIBSIMPLE_NORETURN void\ diff --git a/libsimple.h b/libsimple.h index e97ac27..28d884c 100644 --- a/libsimple.h +++ b/libsimple.h @@ -139,6 +139,8 @@ * be update to -1 if it is non-negative * @return Return value of close(3) (0 on success, * -1 on error), 0 if `*fdp < 0` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline int @@ -163,6 +165,8 @@ libsimple_close(int *__fdp) * @param list:non-void pointer The list * @param i:size_t The index of the item to remove * @param n:size_t Pointer to the number of items in the list, will be updated + * + * @since 1.0 */ #define LIBSIMPLE_UNLIST(LIST, I, NP) libsimple_unlist((LIST), (I), (NP), sizeof(*(LIST))) #ifndef UNLIST @@ -177,6 +181,8 @@ libsimple_close(int *__fdp) * @param i The index of the item to remove * @param n Pointer to the number of items in the list, will be updated * @param width The width, in bytes, of each item in the list + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline void diff --git a/libsimple/aligned_alloc.h b/libsimple/aligned_alloc.h index b2a60f1..fd81053 100644 --- a/libsimple/aligned_alloc.h +++ b/libsimple/aligned_alloc.h @@ -18,6 +18,8 @@ * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __warn_unused_result__))) static inline void *libsimple_valigned_allocn(size_t __alignment, size_t __n, va_list __ap) @@ -37,6 +39,8 @@ static inline void *libsimple_valigned_allocn(size_t __alignment, size_t __n, va * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __warn_unused_result__))) static inline void * @@ -66,6 +70,8 @@ libsimple_aligned_allocn(size_t __alignment, size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_enaligned_alloc(int __status, size_t __alignment, size_t __n) @@ -95,6 +101,8 @@ static inline void *libsimple_enaligned_alloc(int __status, size_t __alignment, * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_envaligned_allocn(int __status, size_t __alignment, size_t __n, va_list __ap) @@ -124,6 +132,8 @@ static inline void *libsimple_envaligned_allocn(int __status, size_t __alignment * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -152,6 +162,8 @@ libsimple_enaligned_allocn(int __status, size_t __alignment, size_t __n, ... /*, * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_ealigned_alloc(size_t __alignment, size_t __n) @@ -180,6 +192,8 @@ static inline void *libsimple_ealigned_alloc(size_t __alignment, size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evaligned_allocn(size_t __alignment, size_t __n, va_list __ap) @@ -208,6 +222,8 @@ static inline void *libsimple_evaligned_allocn(size_t __alignment, size_t __n, v * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/aligned_allocz.h b/libsimple/aligned_allocz.h index 9380a50..be290d2 100644 --- a/libsimple/aligned_allocz.h +++ b/libsimple/aligned_allocz.h @@ -19,6 +19,8 @@ * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__))) void *libsimple_valigned_alloczn(int, size_t, size_t, va_list); @@ -39,6 +41,8 @@ void *libsimple_valigned_alloczn(int, size_t, size_t, va_list); * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __alloc_size__(3), __warn_unused_result__))) static inline void * @@ -72,6 +76,8 @@ libsimple_aligned_allocz(int __clear, size_t __alignment, size_t __n) * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__))) static inline void * @@ -102,6 +108,8 @@ libsimple_aligned_alloczn(int __clear, size_t __alignment, size_t __n, ... /*, ( * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __alloc_size__(4), __warn_unused_result__, __returns_nonnull__))) void *libsimple_enaligned_allocz(int, int, size_t, size_t); @@ -131,6 +139,8 @@ void *libsimple_enaligned_allocz(int, int, size_t, size_t); * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __warn_unused_result__, __returns_nonnull__))) void *libsimple_envaligned_alloczn(int, int, size_t, size_t, va_list); @@ -160,6 +170,8 @@ void *libsimple_envaligned_alloczn(int, int, size_t, size_t, va_list); * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -188,6 +200,8 @@ libsimple_enaligned_alloczn(int __status, int __clear, size_t __alignment, size_ * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_ealigned_allocz(int __clear, size_t __alignment, size_t __n) @@ -217,6 +231,8 @@ static inline void *libsimple_ealigned_allocz(int __clear, size_t __alignment, s * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evaligned_alloczn(int __clear, size_t __alignment, size_t __n, va_list __ap) @@ -246,6 +262,8 @@ static inline void *libsimple_evaligned_alloczn(int __clear, size_t __alignment, * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/aligned_memdup.h b/libsimple/aligned_memdup.h index 0192a14..36b085f 100644 --- a/libsimple/aligned_memdup.h +++ b/libsimple/aligned_memdup.h @@ -8,6 +8,8 @@ * @param alignment:size_t The alignment of the returned pointer * @param n:size_t The number of bytes to copy * @return :void * Duplicate of `s` with automatic storage + * + * @since 1.1 */ #if defined(__GNUC__) || defined(__clang__) # define libsimple_aligned_memdupa(s, alignment, n)\ @@ -39,6 +41,8 @@ * @param alignment The alignment of the returned pointer * @param n The number of bytes to copy * @return Duplicate of `s`, `NULL` on failure + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __alloc_size__(3), __nonnull__, __warn_unused_result__))) void *libsimple_aligned_memdup(const void *, size_t, size_t); @@ -55,6 +59,8 @@ void *libsimple_aligned_memdup(const void *, size_t, size_t); * @param alignment The alignment of the returned pointer * @param n The number of bytes to copy * @return Duplicate of `s` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(3), __alloc_size__(4), __warn_unused_result__, __returns_nonnull__))) void *libsimple_enaligned_memdup(int, const void *, size_t, size_t); @@ -70,6 +76,8 @@ void *libsimple_enaligned_memdup(int, const void *, size_t, size_t); * @param alignment The alignment of the returned pointer * @param n The number of bytes to copy * @return Duplicate of `s` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_ealigned_memdup(const void *__s, size_t __alignment, size_t __n) diff --git a/libsimple/array.h b/libsimple/array.h index b17966b..2016540 100644 --- a/libsimple/array.h +++ b/libsimple/array.h @@ -3,162 +3,189 @@ /* TODO test, doc, man */ +/* @since 1.1 */ #define libsimple_arraydupa(array, alignment, n) libsimple_aligned_memdupa(array, _Alignof(*(array)), n) #ifndef aligned_arraydupa # define aligned_arraydupa(...) libsimple_aligned_arraydupa(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arraydup(array, n) libsimple_aligned_memdup(array, _Alignof(*(array)), n) #ifndef arraydup # define arraydup(...) libsimple_arraydup(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_earraydup(array, n) libsimple_ealigned_memdup(array, _Alignof(*(array)), n) #ifndef earraydup # define earraydup(...) libsimple_earraydup(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_enarraydup(status, array, n) libsimple_enaligned_memdup(status, array, _Alignof(*(array)), n) #ifndef enarraydup # define enarraydup(...) libsimple_enarraydup(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_aligned_arraydupa(array, alignment, n) libsimple_aligned_memdupa(array, alignment, n) #ifndef aligned_arraydupa # define aligned_arraydupa(...) libsimple_aligned_arraydupa(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_aligned_arraydup(array, alignment, n) libsimple_aligned_memdup(array, alignment, n) #ifndef aligned_arraydup # define aligned_arraydup(...) libsimple_aligned_arraydup(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_ealigned_arraydup(array, alignment, n) libsimple_ealigned_memdup(array, alignment, n) #ifndef ealigned_arraydup # define ealigned_arraydup(...) libsimple_ealigned_arraydup(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_enaligned_arraydup(status, array, alignment, n) libsimple_enaligned_memdup(status, array, alignment, n) #ifndef enaligned_arraydup # define enaligned_arraydup(...) libsimple_enaligned_arraydup(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayelem(haystack, needle, n) libsimple_memelem(haystack, needle, sizeof *(haystack), n) #ifndef arrayelem # define arrayelem(...) libsimple_arrayelem(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_rawarrayelem(haystack, needle, n) libsimple_rawmemelem(haystack, needle, sizeof *(haystack), n) #ifndef rawarrayelem # define rawarrayelem(...) libsimple_rawarrayelem(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayscan(haystack, needle, n) libsimple_memelemscan(haystack, needle, sizeof *(haystack), n) #ifndef arrayscan # define arrayscan(...) libsimple_arrayscan(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayrelem(haystack, needle, n) libsimple_memrelem(haystack, needle, sizeof *(haystack), n) #ifndef arrayrelem # define arrayrelem(...) libsimple_arrayrelem(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_rawarrayrelem(haystack, needle, n) libsimple_rawmemrelem(haystack, needle, sizeof *(haystack), n) #ifndef rawarrayrelem # define rawarrayrelem(...) libsimple_rawarrayrelem(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayelem_inv(haystack, needle, n) libsimple_memelem_inv(haystack, needle, sizeof *(haystack), n) #ifndef arrayelem_inv # define arrayelem_inv(...) libsimple_arrayelem_inv(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_rawarrayelem_inv(haystack, needle, n) libsimple_rawmemelem_inv(haystack, needle, sizeof *(haystack), n) #ifndef rawarrayelem_inv # define rawarrayelem_inv(...) libsimple_rawarrayelem_inv(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayscan_inv(haystack, needle, n) libsimple_memelemscan_inv(haystack, needle, sizeof *(haystack), n) #ifndef arrayscan_inv # define arrayscan_inv(...) libsimple_arrayscan_inv(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayrelem_inv(haystack, needle, n) libsimple_memrelem_inv(haystack, needle, sizeof *(haystack), n) #ifndef arrayrelem_inv # define arrayrelem_inv(...) libsimple_arrayrelem_inv(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_rawarrayrelem_inv(haystack, needle, n) libsimple_rawmemrelem_inv(haystack, needle, sizeof *(haystack), n) #ifndef rawarrayrelem_inv # define rawarrayrelem_inv(...) libsimple_rawarrayrelem_inv(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayset(buf, item, n) libsimple_memsetelem(buf, item, (n) * sizeof *(buf)) #ifndef arrayset # define arrayset(...) libsimple_arrayset(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arraypset(buf, item, n) libsimple_mempsetelem(buf, item, (n) * sizeof *(buf)) #ifndef arraypset # define arraypset(...) libsimple_arraypset(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arraycpy(d, s, n) memcpy(d, s, (n) * sizeof *(s)) #ifndef arraycpy # define arraycpy(...) libsimple_arraycpy(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arraymove(d, s, n) memmove(d, s, (n) * sizeof *(s)) #ifndef arraymove # define arraymove(...) libsimple_arraymove(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayelemcpy(d, s, elem, n) libsimple_memelemcpy(d, s, elem, sizeof *(s), n) #ifndef arrayelemcpy # define arrayelemcpy(...) libsimple_arrayelemcpy(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayelemmove(d, s, elem, n) libsimple_memelemmove(d, s, elem, sizeof *(s), n) #ifndef arrayelemmove # define arrayelemmove(...) libsimple_arrayelemmove(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_rawarrayelemcpy(d, s, elem) libsimple_rawmemelemcpy(d, s, elem, sizeof *(s)) #ifndef rawarrayelemcpy # define rawarrayelemcpy(...) libsimple_rawarrayelemcpy(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_rawarrayelemmove(d, s, elem) libsimple_rawmemelemmove(d, s, elem, sizeof *(s)) #ifndef rawarrayelemmove # define rawarrayelemmove(...) libsimple_rawarrayelemmove(__VA_ARGS__) #endif +/* @since 1.1 */ #define libsimple_arrayreplace(s, old, new, n) libsimple_memreplaceelem(s, old, new, sizeof *(s), n) #ifndef arrayreplace # define arrayreplace(...) libsimple_arrayreplace(__VA_ARGS__) diff --git a/libsimple/calloc.h b/libsimple/calloc.h index 7b373e9..2f1bcc6 100644 --- a/libsimple/calloc.h +++ b/libsimple/calloc.h @@ -17,6 +17,8 @@ * `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void *libsimple_vcallocn(size_t __n, va_list __ap) @@ -42,6 +44,8 @@ static inline void *libsimple_vcallocn(size_t __n, va_list __ap) * `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -72,6 +76,8 @@ libsimple_callocn(size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the size `n * m` * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2, 3), __warn_unused_result__, __returns_nonnull__))) void *libsimple_encalloc(int, size_t, size_t); @@ -98,6 +104,8 @@ void *libsimple_encalloc(int, size_t, size_t); * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_envcallocn(int __status, size_t __n, va_list __ap) @@ -125,6 +133,8 @@ static inline void *libsimple_envcallocn(int __status, size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -154,6 +164,8 @@ libsimple_encallocn(int __status, size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the size `n * m` * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(1, 2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_ecalloc(size_t __n, size_t __m) @@ -180,6 +192,8 @@ static inline void *libsimple_ecalloc(size_t __n, size_t __m) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evcallocn(size_t __n, va_list __ap) @@ -206,6 +220,8 @@ static inline void *libsimple_evcallocn(size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/definitions.h b/libsimple/definitions.h index 67825f5..6fbc17f 100644 --- a/libsimple/definitions.h +++ b/libsimple/definitions.h @@ -112,6 +112,8 @@ /** * Defined if two's complement is used * for signed number representation + * + * @since 1.1 */ # ifndef TWOS_COMPLEMENT # define TWOS_COMPLEMENT @@ -120,6 +122,8 @@ /** * Defined if sign–magnitude is used * for signed number representation + * + * @since 1.1 */ # ifndef SIGN_MAGNITUDE # define SIGN_MAGNITUDE @@ -128,6 +132,8 @@ /** * Defined if ones' complement is used * for signed number representation + * + * @since 1.1 */ # ifndef ONES_COMPLEMENT # define ONES_COMPLEMENT @@ -141,6 +147,8 @@ * @param A One of the values * @param B The other value * @return The smallest of `A` and `B` + * + * @since 1.0 */ #ifndef MIN # define MIN(A, B) ((A) < (B) ? (A) : (B)) @@ -153,6 +161,8 @@ * @param A One of the values * @param B The other value * @return The largest of `A` and `B` + * + * @since 1.0 */ #ifndef MAX # define MAX(A, B) ((A) > (B) ? (A) : (B)) @@ -166,6 +176,8 @@ * @param B Another one of the values * @param C The last value * @return The smallest of `A`, `B`, and `C` + * + * @since 1.0 */ #ifndef MIN3 # define MIN3(A, B, C) MIN(MIN((A), (B)), (C)) @@ -179,6 +191,8 @@ * @param B Another one of the values * @param C The last value * @return The largest of `A`, `B`, and `C` + * + * @since 1.0 */ #ifndef MAX3 # define MAX3(A, B, C) MAX(MAX((A), (B)), (C)) @@ -191,6 +205,8 @@ * @param ARR The array, must not be a pointer * @return :size_t The number of elements in `ARR` (constant * expression, unless its size is dynamic) + * + * @since 1.0 */ #ifndef ELEMSOF # define ELEMSOF(ARR) (sizeof(ARR) / (sizeof(*(ARR)))) @@ -204,6 +220,8 @@ * * @param STR:const char [] The string, must be a literal * @return :size_t The value of `strlen(STR)` as a constant expression + * + * @since 1.0 */ #ifndef STRLEN # define STRLEN(STR) (sizeof(STR) - 1) @@ -225,6 +243,8 @@ * value of the type `TYPE` can be converted to without any * superfluous characters (such as explitict '+' or leading zeroes') * (constant expression) + * + * @since 1.0 */ #ifndef INTSTRLEN # define INTSTRLEN(TYPE) ((sizeof(TYPE) == 1 ? 3 : 5 * (sizeof(TYPE) / 2)) + ((TYPE)-1 < 0)) @@ -236,6 +256,8 @@ * * @param TYPE:integer type The type, must be an integer type, may be signed or unsigned * @return :TYPE The largest value that can be stored in `TYPE` (constant expression) + * + * @since 1.0 */ #ifndef TYPE_MAX # define TYPE_MAX(TYPE) ((TYPE)(((1ULL << (8 * sizeof(TYPE) - 1)) - 1) << ((TYPE)-1 > 0) | 1)) @@ -247,13 +269,15 @@ * * @param TYPE:integer type The type, must be an integer type, may be signed or unsigned * @return :TYPE The smallest value that can be stored in `TYPE` (constant expression) + * + * @since 1.0 */ #ifndef TYPE_MIN # define TYPE_MIN(TYPE) ((TYPE)((TYPE)-1 > 0 ? 0 : (TYPE)~0 < (TYPE)-1 ? (TYPE)~0 : (TYPE)(1ULL << (8 * sizeof(TYPE) - 1)))) #endif -/* --- Maximum values --- */ +/* --- Maximum values (since 1.0) --- */ #ifndef BLKCNT64_MAX # define BLKCNT64_MAX TYPE_MAX(blkcnt64_t) @@ -392,7 +416,7 @@ #endif -/* --- Minimum values --- */ +/* --- Minimum values (since 1.0) --- */ #ifndef BLKCNT64_MIN # define BLKCNT64_MIN TYPE_MIN(blkcnt64_t) diff --git a/libsimple/env.h b/libsimple/env.h index dc58276..b8ae988 100644 --- a/libsimple/env.h +++ b/libsimple/env.h @@ -6,6 +6,8 @@ * * @param var The environment variable's name * @return The environment variable's value, `NULL` if empty or not defined + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __warn_unused_result__))) static inline char * @@ -24,6 +26,8 @@ libsimple_getenv_ne(const char *__name) * * @param var The environment variable's name * @return The environment variable's value, "" if empty or not defined + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __warn_unused_result__, __returns_nonnull__))) static inline const char * @@ -49,6 +53,8 @@ libsimple_getenv_e(const char *__name) * @param fmt Format string, see vsprintf(3) * @param ap Format arguments, see vsprintf(3) * @return 0 on success, -1 on failure + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_vputenvf(const char *, va_list); @@ -69,6 +75,8 @@ int libsimple_vputenvf(const char *, va_list); * @param fmt Format string, see vsprintf(3) * @param ... Format arguments, see vsprintf(3) * @return 0 on success, -1 on failure + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __format__(__printf__, 1, 2)))) static inline int @@ -100,6 +108,8 @@ libsimple_putenvf(const char *__fmt, ...) * @param status The exit value for the process in case of failure * @param fmt Format string, see vsprintf(3) * @param ap Format arguments, see vsprintf(3) + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) void libsimple_envputenvf(int, const char *, va_list); @@ -124,6 +134,8 @@ void libsimple_envputenvf(int, const char *, va_list); * @param status The exit value for the process in case of failure * @param fmt Format string, see vsprintf(3) * @param ap Format arguments, see vsprintf(3) + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __format__(__printf__, 2, 3)))) static inline void @@ -154,6 +166,8 @@ libsimple_enputenvf(int __status, const char *__fmt, ...) * * @param fmt Format string, see vsprintf(3) * @param ap Format arguments, see vsprintf(3) + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline void libsimple_evputenvf(const char *__fmt, va_list __ap) @@ -178,6 +192,8 @@ static inline void libsimple_evputenvf(const char *__fmt, va_list __ap) * * @param fmt Format string, see vsprintf(3) * @param ap Format arguments, see vsprintf(3) + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __format__(__printf__, 1, 2)))) static inline void diff --git a/libsimple/malloc.h b/libsimple/malloc.h index b57f81f..4309c6d 100644 --- a/libsimple/malloc.h +++ b/libsimple/malloc.h @@ -17,6 +17,8 @@ * `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void *libsimple_vmallocn(size_t __n, va_list __ap) @@ -42,6 +44,8 @@ static inline void *libsimple_vmallocn(size_t __n, va_list __ap) * `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -70,6 +74,8 @@ libsimple_mallocn(size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) void *libsimple_enmalloc(int, size_t); @@ -96,6 +102,8 @@ void *libsimple_enmalloc(int, size_t); * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_envmallocn(int __status, size_t __n, va_list __ap) @@ -123,6 +131,8 @@ static inline void *libsimple_envmallocn(int __status, size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -150,6 +160,8 @@ libsimple_enmallocn(int __status, size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(1), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_emalloc(size_t __n) @@ -176,6 +188,8 @@ static inline void *libsimple_emalloc(size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evmallocn(size_t __n, va_list __ap) @@ -202,6 +216,8 @@ static inline void *libsimple_evmallocn(size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/mallocz.h b/libsimple/mallocz.h index 2bbd607..6932915 100644 --- a/libsimple/mallocz.h +++ b/libsimple/mallocz.h @@ -29,6 +29,8 @@ void *libsimple_enmalloc(int, size_t); * `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) void *libsimple_vmalloczn(int, size_t, va_list); @@ -48,6 +50,8 @@ void *libsimple_vmalloczn(int, size_t, va_list); * `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2), __warn_unused_result__))) static inline void *libsimple_mallocz(int __clear, size_t __n) @@ -74,6 +78,8 @@ static inline void *libsimple_mallocz(int __clear, size_t __n) * `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -102,6 +108,8 @@ libsimple_malloczn(int __clear, size_t __n, ... /*, (size_t)0 */) * @param n Th number of bytes to allocate * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_enmallocz(int __status, int __clear, size_t __n) @@ -131,6 +139,8 @@ static inline void *libsimple_enmallocz(int __status, int __clear, size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) void *libsimple_envmalloczn(int, int, size_t, va_list); @@ -159,6 +169,8 @@ void *libsimple_envmalloczn(int, int, size_t, va_list); * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -186,6 +198,8 @@ libsimple_enmalloczn(int __status, int __clear, size_t __n, ... /*, (size_t)0 */ * @param n Th number of bytes to allocate * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_emallocz(int __clear, size_t __n) @@ -213,6 +227,8 @@ static inline void *libsimple_emallocz(int __clear, size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evmalloczn(int __clear, size_t __n, va_list __ap) @@ -240,6 +256,8 @@ static inline void *libsimple_evmalloczn(int __clear, size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with the alignment `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/mem.h b/libsimple/mem.h index f4c01dc..718a99e 100644 --- a/libsimple/mem.h +++ b/libsimple/mem.h @@ -11,6 +11,8 @@ * @return `s` with a minimal offset such that `*r == c`, * where `r` is the returned pointer, `&s[n]` if * no such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_memscan(const void *, int, size_t); @@ -29,6 +31,8 @@ void *libsimple_memscan(const void *, int, size_t); * @return `s` with a minimal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer, `NULL` if * no such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memcasechr(const void *, int, size_t); @@ -47,6 +51,8 @@ void *libsimple_memcasechr(const void *, int, size_t); * @return `s` with a minimal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer, `&s[n]` if * no such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_memcasescan(const void *, int, size_t); @@ -68,6 +74,8 @@ void *libsimple_memcasescan(const void *, int, size_t); * @param c The byte value to search for * @return `s` with a miminal offset such that `*r == c`, * where `r` is the returned pointer + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemchr(const void *, int); @@ -89,6 +97,8 @@ void *libsimple_rawmemchr(const void *, int); * @param c The byte value to search for * @return `s` with a miminal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemcasechr(const void *, int); @@ -107,6 +117,8 @@ void *libsimple_rawmemcasechr(const void *, int); * @return `s` with a maximal offset such that `*r == c`, * where `r` is the returned pointer `NULL` if no * such offset exists within [s, &s[n]) + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memrchr(const void *, int, size_t); @@ -125,6 +137,8 @@ void *libsimple_memrchr(const void *, int, size_t); * @return `s` with a maximal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer `NULL` if no * such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memrcasechr(const void *, int, size_t); @@ -147,6 +161,8 @@ void *libsimple_memrcasechr(const void *, int, size_t); * @param n The number of bytes in the byte array * @return `s` with a maximal offset such that `*r == c`, * where `r` is the returned pointer + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemrchr(const void *, int, size_t); @@ -169,6 +185,8 @@ void *libsimple_rawmemrchr(const void *, int, size_t); * @param n The number of bytes in the byte array * @return `s` with a maximal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemrcasechr(const void *, int, size_t); @@ -187,6 +205,8 @@ void *libsimple_rawmemrcasechr(const void *, int, size_t); * @return `s` with a minimal offset such that `*r != c`, * where `r` is the returned pointer, `NULL` if * no such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memchr_inv(const void *, int, size_t); @@ -205,6 +225,8 @@ void *libsimple_memchr_inv(const void *, int, size_t); * @return `s` with a minimal offset such that `*r != c`, * where `r` is the returned pointer, `&s[n]` if * no such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_memscan_inv(const void *, int, size_t); @@ -223,6 +245,8 @@ void *libsimple_memscan_inv(const void *, int, size_t); * @return `s` with a minimal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer, `NULL` if * no such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memcasechr_inv(const void *, int, size_t); @@ -241,6 +265,8 @@ void *libsimple_memcasechr_inv(const void *, int, size_t); * @return `s` with a minimal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer, `&s[n]` if * no such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_memcasescan_inv(const void *, int, size_t); @@ -262,6 +288,8 @@ void *libsimple_memcasescan_inv(const void *, int, size_t); * @param c The byte value to search for * @return `s` with a miminal offset such that `*r != c`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemchr_inv(const void *, int); @@ -283,6 +311,8 @@ void *libsimple_rawmemchr_inv(const void *, int); * @param c The byte value to search for * @return `s` with a miminal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemcasechr_inv(const void *, int); @@ -301,6 +331,8 @@ void *libsimple_rawmemcasechr_inv(const void *, int); * @return `s` with a maximal offset such that `*r != c`, * where `r` is the returned pointer `NULL` if no * such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memrchr_inv(const void *, int, size_t); @@ -319,6 +351,8 @@ void *libsimple_memrchr_inv(const void *, int, size_t); * @return `s` with a maximal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer `NULL` if no * such offset exists within [s, &s[n]) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memrcasechr_inv(const void *, int, size_t); @@ -341,6 +375,8 @@ void *libsimple_memrcasechr_inv(const void *, int, size_t); * @param n The number of bytes in the byte array * @return `s` with a maximal offset such that `*r != c`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemrchr_inv(const void *, int, size_t); @@ -363,6 +399,8 @@ void *libsimple_rawmemrchr_inv(const void *, int, size_t); * @param n The number of bytes in the byte array * @return `s` with a maximal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemrcasechr_inv(const void *, int, size_t); @@ -381,6 +419,8 @@ void *libsimple_rawmemrcasechr_inv(const void *, int, size_t); * @return `haystack` with a minimal offset such that, * `!memcmp(r, needle, nneedle)` where `r` is the * returned pointer, `NULL` if no such offset exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memmem(const void *, size_t, const void *, size_t); @@ -399,6 +439,8 @@ void *libsimple_memmem(const void *, size_t, const void *, size_t); * @return `haystack` with a minimal offset such that, * `!memcasecmp(r, needle, nneedle)` where `r` is the * returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memcasemem(const void *, size_t, const void *, size_t); @@ -417,6 +459,8 @@ void *libsimple_memcasemem(const void *, size_t, const void *, size_t); * @return `haystack` with a maximal offset such that, * `!memcmp(r, needle, nneedle)` where `r` is the * returned pointer, `NULL` if no such offset exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memrmem(const void *, size_t, const void *, size_t); @@ -435,6 +479,8 @@ void *libsimple_memrmem(const void *, size_t, const void *, size_t); * @return `haystack` with a maximal offset such that, * `!memcasecmp(r, needle, nneedle)` where `r` is the * returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memrcasemem(const void *, size_t, const void *, size_t); @@ -451,6 +497,8 @@ void *libsimple_memrcasemem(const void *, size_t, const void *, size_t); * @param t The desired beginning of `s` * @param m The length of `t` * @return 1 if `s` begins with `t`, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) int libsimple_memstarts(const void *, size_t, const void *, size_t); @@ -467,6 +515,8 @@ int libsimple_memstarts(const void *, size_t, const void *, size_t); * @param t The desired beginning of `s` * @param m The length of `t` * @return 1 if `s` begins with `t`, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) int libsimple_memcasestarts(const void *, size_t, const void *, size_t); @@ -483,6 +533,8 @@ int libsimple_memcasestarts(const void *, size_t, const void *, size_t); * @param t The desired ending of `s` * @param m The length of `t` * @return 1 if `s` ends with `t`, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) int libsimple_memends(const void *, size_t, const void *, size_t); @@ -499,6 +551,8 @@ int libsimple_memends(const void *, size_t, const void *, size_t); * @param t The desired ending of `s` * @param m The length of `t` * @return 1 if `s` ends with `t`, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) int libsimple_memcaseends(const void *, size_t, const void *, size_t); @@ -514,6 +568,8 @@ int libsimple_memcaseends(const void *, size_t, const void *, size_t); * @param b The other arrays of bytes * @param n The lengths of the arrays * @return 1 if the arrays are equal, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) int libsimple_memcasecmp(const void *, const void *, size_t); @@ -529,6 +585,8 @@ int libsimple_memcasecmp(const void *, const void *, size_t); * @param b The other arrays of bytes * @param n The lengths of the arrays * @return 1 if the arrays are equal, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_memeq(const void *__a, const void *__b, size_t __n) @@ -545,6 +603,8 @@ static inline int libsimple_memeq(const void *__a, const void *__b, size_t __n) * @param b The other arrays of bytes * @param n The lengths of the arrays * @return 1 if the arrays are equal, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_memcaseeq(const void *__a, const void *__b, size_t __n) @@ -561,6 +621,8 @@ static inline int libsimple_memcaseeq(const void *__a, const void *__b, size_t _ * @param s The array of bytes that should be copied * @param n The number of bytes to copy * @return `&d[n]` + * + * @since 1.0 */ static inline void *libsimple_mempcpy(void *restrict __d, const void *restrict __s, size_t __n) { return &((char *)memcpy(__d, __s, __n))[__n]; } @@ -576,6 +638,8 @@ static inline void *libsimple_mempcpy(void *restrict __d, const void *restrict _ * @param s The bytes that should be moved * @param n The number of bytes to move * @return `&d[n]` + * + * @since 1.1 */ static inline void *libsimple_mempmove(void *__d, const void *__s, size_t __n) { return &((char *)memmove(__d, __s, __n))[__n]; } @@ -591,6 +655,8 @@ static inline void *libsimple_mempmove(void *__d, const void *__s, size_t __n) * @param c The byte to fill the array with * @param n The number of bytes to write to `s` * @return `&s[n]` + * + * @since 1.1 */ static inline void *libsimple_mempset(void *__s, int __c, size_t __n) { return &((char *)memset(__s, __c, __n))[__n]; } @@ -611,6 +677,8 @@ static inline void *libsimple_mempset(void *__s, int __c, size_t __n) * @param s The byte array to copy * @param c The byte that stops the copying * @return `&rawmemchr(d, c)[1]` (after copying) + * + * @since 1.1 */ static inline void * libsimple_rawmemccpy(void *restrict __d_, const void *restrict __s_, int __c_) @@ -635,6 +703,8 @@ libsimple_rawmemccpy(void *restrict __d_, const void *restrict __s_, int __c_) * @return `&rawmemchr(d, c)[1]` (after copying) if `c` can * be found within the first `n` bytes of `s` (before * copying), `NULL` otherwise + * + * @since 1.1 */ void *libsimple_memcmove(void *, const void *, int, size_t); #ifndef memcmove @@ -654,6 +724,8 @@ void *libsimple_memcmove(void *, const void *, int, size_t); * @param s The byte array to copy * @param c The byte that stops the copying * @return `&rawmemchr(d, c)[1]` (after copying) + * + * @since 1.1 */ static inline void * libsimple_rawmemcmove(void *__d_, const void *__s_, int __c_) @@ -688,6 +760,8 @@ libsimple_rawmemcmove(void *__d_, const void *__s_, int __c_) * @param new The value to replace the bytes with * @param n The length of `s` * @return `(void *)&((char *)s)[n]` + * + * @since 1.1 */ static inline void * libsimple_memreplace(void *__s_, int __old_, int __new_, size_t __n) @@ -716,6 +790,8 @@ libsimple_memreplace(void *__s_, int __old_, int __new_, size_t __n) * @param s The byte array to copy * @param n The number of bytes to copy or covert * @return `&d[n]` + * + * @since 1.1 */ void *libsimple_memptolower(void *, const void *, size_t); #ifndef memptolower @@ -735,6 +811,8 @@ void *libsimple_memptolower(void *, const void *, size_t); * @param s The byte array to copy * @param n The number of bytes to copy or covert * @return `&d[n]` + * + * @since 1.1 */ void *libsimple_memptoupper(void *, const void *, size_t); #ifndef memptoupper @@ -754,6 +832,8 @@ void *libsimple_memptoupper(void *, const void *, size_t); * @param s The byte array to copy * @param n The number of bytes to copy or covert * @return `d` + * + * @since 1.1 */ static inline void *libsimple_memtolower(void *__d, const void *__s, size_t __n) { libsimple_memptolower(__d, __s, __n); return __d; } @@ -774,6 +854,8 @@ static inline void *libsimple_memtolower(void *__d, const void *__s, size_t __n) * @param s The byte array to copy * @param n The number of bytes to copy or covert * @return `d` + * + * @since 1.1 */ static inline void *libsimple_memtoupper(void *__d, const void *__s, size_t __n) { libsimple_memptoupper(__d, __s, __n); return __d; } @@ -791,6 +873,8 @@ static inline void *libsimple_memtoupper(void *__d, const void *__s, size_t __n) * @param m The length of `b` * @return The number of bytes `a` and `b` have * in common in their beginnings + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) size_t libsimple_memeqlen(const void *, size_t, const void *, size_t); @@ -808,6 +892,8 @@ size_t libsimple_memeqlen(const void *, size_t, const void *, size_t); * @param m The length of `b` * @return The number of bytes `a` and `b` have * in common in their beginnings + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) size_t libsimple_memcaseeqlen(const void *, size_t, const void *, size_t); @@ -825,6 +911,8 @@ size_t libsimple_memcaseeqlen(const void *, size_t, const void *, size_t); * @param m The length of `b` * @return The number of bytes `a` and `b` have * in common in their ends + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) size_t libsimple_memreqlen(const void *, size_t, const void *, size_t); @@ -842,6 +930,8 @@ size_t libsimple_memreqlen(const void *, size_t, const void *, size_t); * @param m The length of `b` * @return The number of bytes `a` and `b` have * in common in their ends + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) size_t libsimple_memrcaseeqlen(const void *, size_t, const void *, size_t); @@ -858,6 +948,8 @@ size_t libsimple_memrcaseeqlen(const void *, size_t, const void *, size_t); * @param allow_modified_nul Whether Modified UTF-8 is allowed, which * allows a two-byte encoding for NUL * @return 1 if good, 0 on encoding error + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) int libsimple_memisutf8(const char *, size_t, int); diff --git a/libsimple/memalign.h b/libsimple/memalign.h index d533751..20dfebb 100644 --- a/libsimple/memalign.h +++ b/libsimple/memalign.h @@ -18,6 +18,8 @@ * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __warn_unused_result__))) static inline void *libsimple_vmemalignn(size_t __alignment, size_t __n, va_list __ap) @@ -37,6 +39,8 @@ static inline void *libsimple_vmemalignn(size_t __alignment, size_t __n, va_list * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __alloc_size__(2), __warn_unused_result__))) static inline void *libsimple_memalign(size_t __alignment, size_t __n) @@ -63,6 +67,8 @@ static inline void *libsimple_memalign(size_t __alignment, size_t __n) * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __warn_unused_result__))) static inline void * @@ -92,6 +98,8 @@ libsimple_memalignn(size_t __alignment, size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_enmemalign(int __status, size_t __alignment, size_t __n) @@ -121,6 +129,8 @@ static inline void *libsimple_enmemalign(int __status, size_t __alignment, size_ * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_envmemalignn(int __status, size_t __alignment, size_t __n, va_list __ap) @@ -150,6 +160,8 @@ static inline void *libsimple_envmemalignn(int __status, size_t __alignment, siz * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -178,6 +190,8 @@ libsimple_enmemalignn(int __status, size_t __alignment, size_t __n, ... /*, (siz * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_ememalign(size_t __alignment, size_t __n) @@ -207,6 +221,8 @@ static inline void *libsimple_ememalign(size_t __alignment, size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evmemalignn(size_t __alignment, size_t __n, va_list __ap) @@ -235,6 +251,8 @@ static inline void *libsimple_evmemalignn(size_t __alignment, size_t __n, va_lis * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(1), __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/memalignz.h b/libsimple/memalignz.h index 7eab805..387e568 100644 --- a/libsimple/memalignz.h +++ b/libsimple/memalignz.h @@ -19,6 +19,8 @@ * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__))) static inline void * @@ -49,6 +51,8 @@ libsimple_vmemalignzn(int __clear, size_t __alignment, size_t __n, va_list __ap) * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __alloc_size__(3), __warn_unused_result__))) static inline void * @@ -86,6 +90,8 @@ libsimple_memalignz(int __clear, size_t __alignment, size_t __n) * and alignment; `NULL` on failure * @throws EINVAL `n` is 0 or `alignment` is not a power of 2 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__))) static inline void * @@ -116,6 +122,8 @@ libsimple_memalignzn(int __clear, size_t __alignment, size_t __n, ... /*, (size_ * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __alloc_size__(4), __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -156,6 +164,8 @@ libsimple_enmemalignz(int __status, int __clear, size_t __alignment, size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -197,6 +207,8 @@ libsimple_envmemalignzn(int __status, int __clear, size_t __alignment, size_t __ * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -226,6 +238,8 @@ libsimple_enmemalignzn(int __status, int __clear, size_t __alignment, size_t __n * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_ememalignz(int __clear, size_t __alignment, size_t __n) @@ -255,6 +269,8 @@ static inline void *libsimple_ememalignz(int __clear, size_t __alignment, size_t * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evmemalignzn(int __clear, size_t __alignment, size_t __n, va_list __ap) @@ -284,6 +300,8 @@ static inline void *libsimple_evmemalignzn(int __clear, size_t __alignment, size * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/memalloc.h b/libsimple/memalloc.h index 5b91a64..13ef889 100644 --- a/libsimple/memalloc.h +++ b/libsimple/memalloc.h @@ -1,6 +1,8 @@ /* See LICENSE file for copyright and license details. */ +/* @since 1.1 */ enum libsimple_memalloc_option { + /* @since 1.1 { */ LIBSIMPLE_MEMALLOC_END, LIBSIMPLE_MEMALLOC_ZERO_INIT, LIBSIMPLE_MEMALLOC_CONDITIONAL_ZERO_INIT, @@ -16,9 +18,12 @@ enum libsimple_memalloc_option { LIBSIMPLE_MEMALLOC_VA_PRODUCT_SIZE, LIBSIMPLE_MEMALLOC_1_VA_PRODUCT_SIZE, LIBSIMPLE_MEMALLOC_VA_LIST + /* @since 1.1 } */ }; + /* @since 1.1 */ #define libsimple_arrayalloc_option libsimple_memalloc_option +/* @since 1.1 { */ #define LIBSIMPLE_MEMALLOC_END LIBSIMPLE_MEMALLOC_END #define LIBSIMPLE_MEMALLOC_ZERO_INIT LIBSIMPLE_MEMALLOC_ZERO_INIT #define LIBSIMPLE_MEMALLOC_CONDITIONAL_ZERO_INIT LIBSIMPLE_MEMALLOC_CONDITIONAL_ZERO_INIT @@ -34,7 +39,9 @@ enum libsimple_memalloc_option { #define LIBSIMPLE_MEMALLOC_VA_PRODUCT_SIZE LIBSIMPLE_MEMALLOC_VA_PRODUCT_SIZE #define LIBSIMPLE_MEMALLOC_1_VA_PRODUCT_SIZE LIBSIMPLE_MEMALLOC_1_VA_PRODUCT_SIZE #define LIBSIMPLE_MEMALLOC_VA_LIST LIBSIMPLE_MEMALLOC_VA_LIST +/* @since 1.1 } */ +/* @since 1.1 { */ #define LIBSIMPLE_ARRAYALLOC_END LIBSIMPLE_MEMALLOC_END #define LIBSIMPLE_ARRAYALLOC_ZERO_INIT LIBSIMPLE_MEMALLOC_ZERO_INIT #define LIBSIMPLE_ARRAYALLOC_CONDITIONAL_ZERO_INIT LIBSIMPLE_MEMALLOC_CONDITIONAL_ZERO_INIT @@ -47,47 +54,58 @@ enum libsimple_memalloc_option { #define LIBSIMPLE_ARRAYALLOC_VA_PRODUCT_SIZE LIBSIMPLE_MEMALLOC_VA_PRODUCT_SIZE #define LIBSIMPLE_ARRAYALLOC_1_VA_PRODUCT_SIZE LIBSIMPLE_MEMALLOC_1_VA_PRODUCT_SIZE #define LIBSIMPLE_ARRAYALLOC_VA_LIST LIBSIMPLE_MEMALLOC_VA_LIST +/* @since 1.1 } */ +/* @since 1.1 */ #define libsimple_varrayalloc(TYPE, N, AP)\ libsimple_memalloc(N, LIBSIMPLE_MEMALLOC_ELEMENT_SIZE, sizeof(TYPE),\ LIBSIMPLE_MEMALLOC_ALIGNMENT, _Alignof(TYPE),\ LIBSIMPLE_MEMALLOC_VA_LIST, AP, LIBSIMPLE_MEMALLOC_END) +/* @since 1.1 */ #define libsimple_evarrayalloc(TYPE, N, AP)\ libsimple_ememalloc(N, LIBSIMPLE_MEMALLOC_ELEMENT_SIZE, sizeof(TYPE),\ LIBSIMPLE_MEMALLOC_ALIGNMENT, _Alignof(TYPE),\ LIBSIMPLE_MEMALLOC_VA_LIST, AP, LIBSIMPLE_MEMALLOC_END) +/* @since 1.1 */ #define libsimple_envarrayalloc(STATUS, TYPE, N, AP)\ libsimple_enmemalloc(STATUS, N, LIBSIMPLE_MEMALLOC_ELEMENT_SIZE, sizeof(TYPE),\ LIBSIMPLE_MEMALLOC_ALIGNMENT, _Alignof(TYPE),\ LIBSIMPLE_MEMALLOC_VA_LIST, AP, LIBSIMPLE_MEMALLOC_END) +/* @since 1.1 */ #define libsimple_arrayalloc(TYPE, N, ... /*, LIBSIMPLE_ARRAYALLOC_END */)\ libsimple_memalloc(N, LIBSIMPLE_MEMALLOC_ELEMENT_SIZE, sizeof(TYPE),\ LIBSIMPLE_MEMALLOC_ALIGNMENT, _Alignof(TYPE),\ __VA_ARGS__) +/* @since 1.1 */ #define libsimple_earrayalloc(TYPE, N, ... /*, LIBSIMPLE_ARRAYALLOC_END */)\ libsimple_ememalloc(N, LIBSIMPLE_MEMALLOC_ELEMENT_SIZE, sizeof(TYPE),\ LIBSIMPLE_MEMALLOC_ALIGNMENT, _Alignof(TYPE),\ __VA_ARGS__) +/* @since 1.1 */ #define libsimple_enarrayalloc(STATUS, TYPE, N, ... /*, LIBSIMPLE_ARRAYALLOC_END */)\ libsimple_enmemalloc(STATUS, N, LIBSIMPLE_MEMALLOC_ELEMENT_SIZE, sizeof(TYPE),\ LIBSIMPLE_MEMALLOC_ALIGNMENT, _Alignof(TYPE),\ __VA_ARGS__) +/* @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) void *libsimple_vmemalloc(size_t, va_list); +/* @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) void *libsimple_envmemalloc(int, size_t, va_list); +/* @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void *libsimple_evmemalloc(size_t __n, va_list __ap) { return libsimple_envmemalloc(libsimple_default_failure_exit, __n, __ap); } +/* @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * libsimple_memalloc(size_t __n, ... /*, LIBSIMPLE_MEMALLOC_END */) @@ -98,6 +116,7 @@ libsimple_memalloc(size_t __n, ... /*, LIBSIMPLE_MEMALLOC_END */) va_end(__ap); } +/* @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * libsimple_enmemalloc(int __status, size_t __n, ... /*, LIBSIMPLE_MEMALLOC_END */) @@ -108,6 +127,7 @@ libsimple_enmemalloc(int __status, size_t __n, ... /*, LIBSIMPLE_MEMALLOC_END */ va_end(__ap); } +/* @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * libsimple_ememalloc(size_t __n, ... /*, LIBSIMPLE_MEMALLOC_END */) diff --git a/libsimple/memdup.h b/libsimple/memdup.h index 75353b8..8e5b41f 100644 --- a/libsimple/memdup.h +++ b/libsimple/memdup.h @@ -7,6 +7,8 @@ * @param s:const void * The bytes to copy * @param n:size_t The number of bytes to copy * @return :void * Duplicate of `s` with automatic storage + * + * @since 1.0 */ #if defined(__GNUC__) || defined(__clang__) # define libsimple_memdupa(s, n)\ @@ -28,6 +30,8 @@ * @param s The bytes to copy * @param n The number of bytes to copy * @return Duplicate of `s`, `NULL` on failure + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2), __nonnull__, __warn_unused_result__))) void *libsimple_memdup(const void *, size_t); @@ -43,6 +47,8 @@ void *libsimple_memdup(const void *, size_t); * @param s The bytes to copy * @param n The number of bytes to copy * @return Duplicate of `s` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) void *libsimple_enmemdup(int, const void *, size_t); @@ -57,6 +63,8 @@ void *libsimple_enmemdup(int, const void *, size_t); * @param s The bytes to copy * @param n The number of bytes to copy * @return Duplicate of `s` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_ememdup(const void *__s, size_t __n) diff --git a/libsimple/memelem.h b/libsimple/memelem.h index 29570f6..10aaef1 100644 --- a/libsimple/memelem.h +++ b/libsimple/memelem.h @@ -12,6 +12,8 @@ * `!memcmp(r, needle, width)` where `r` is the returned * pointer and such that `(r - haystack) % width == 0`, * `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memelem(const void *, const void *, size_t, size_t); @@ -34,6 +36,8 @@ void *libsimple_memelem(const void *, const void *, size_t, size_t); * @return `haystack` with a minimal offset such that, * `!memcmp(r, needle, width)` where `r` is the returned * pointer and such that `(r - haystack) % width == 0` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemelem(const void *, const void *, size_t); @@ -54,6 +58,8 @@ void *libsimple_rawmemelem(const void *, const void *, size_t); * pointer and such that `(r - haystack) % width == 0`, * `(void *)&((char *)haystack)[n * width]` if no such * offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memelemscan(const void *, const void *, size_t, size_t); @@ -73,6 +79,8 @@ void *libsimple_memelemscan(const void *, const void *, size_t, size_t); * `!memcmp(r, needle, width)` where `r` is the returned * pointer and such that `(r - haystack) % width == 0`, * `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memrelem(const void *, const void *, size_t, size_t); @@ -96,6 +104,8 @@ void *libsimple_memrelem(const void *, const void *, size_t, size_t); * @return `haystack` with a maximal offset such that, * `!memcmp(r, needle, width)` where `r` is the returned * pointer and such that `(r - haystack) % width == 0` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemrelem(const void *, const void *, size_t, size_t); @@ -116,6 +126,8 @@ void *libsimple_rawmemrelem(const void *, const void *, size_t, size_t); * `memcmp(r, needle, width)` where `r` is the returned * pointer and such that `(r - haystack) % width == 0`, * `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memelem_inv(const void *, const void *, size_t, size_t); @@ -139,6 +151,8 @@ void *libsimple_memelem_inv(const void *, const void *, size_t, size_t); * @return `haystack` with a minimal offset such that, * `memcmp(r, needle, width)` where `r` is the returned * pointer and such that `(r - haystack) % width == 0` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemelem_inv(const void *, const void *, size_t); @@ -160,6 +174,8 @@ void *libsimple_rawmemelem_inv(const void *, const void *, size_t); * pointer and such that `(r - haystack) % width == 0`, * `(void *)&((char *)haystack)[n * width]` if no such * offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memelemscan_inv(const void *, const void *, size_t, size_t); @@ -180,6 +196,8 @@ void *libsimple_memelemscan_inv(const void *, const void *, size_t, size_t); * `memcmp(r, needle, width)` where `r` is the returned * pointer and such that `(r - haystack) % width == 0`, * `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) void *libsimple_memrelem_inv(const void *, const void *, size_t, size_t); @@ -204,6 +222,8 @@ void *libsimple_memrelem_inv(const void *, const void *, size_t, size_t); * @return `haystack` with a maximal offset such that, * `memcmp(r, needle, width)` where `r` is the returned * pointer and such that `(r - haystack) % width == 0` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __returns_nonnull__, __warn_unused_result__))) void *libsimple_rawmemrelem_inv(const void *, const void *, size_t, size_t); @@ -220,6 +240,8 @@ void *libsimple_rawmemrelem_inv(const void *, const void *, size_t, size_t); * @param width The size of `item` * @param n The number of copies to fill `buf` with * @return `&buf[n * width]` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) void *libsimple_mempsetelem(void *, const void *, size_t, size_t); @@ -236,6 +258,8 @@ void *libsimple_mempsetelem(void *, const void *, size_t, size_t); * @param width The size of `item` * @param n The number of copies to fill `buf` with * @return `buf` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) static inline void *libsimple_memsetelem(void *__buf, const void *__item, size_t __width, size_t __n) @@ -256,6 +280,8 @@ static inline void *libsimple_memsetelem(void *__buf, const void *__item, size_t * @return `&rawmemelem(d, c, width)[width]` (after copying) if `elem` * can be found within the first `n` elements of `s` (before * copying), `NULL` otherwise + * + * @since 1.1 */ void *libsimple_memelemcpy(void *restrict, const void *restrict, const void *restrict, size_t, size_t); #ifndef memelemcpy @@ -274,6 +300,8 @@ void *libsimple_memelemcpy(void *restrict, const void *restrict, const void *res * @return `&rawmemelem(d, c, width)[width]` (after copying) if `elem` * can be found within the first `n` elements of `s` (before * copying), `NULL` otherwise + * + * @since 1.1 */ void *libsimple_memelemmove(void *, const void *, const void *restrict, size_t, size_t); #ifndef memelemmove @@ -294,6 +322,8 @@ void *libsimple_memelemmove(void *, const void *, const void *restrict, size_t, * @param elem The element that stops the copying * @param width The size of each element * @return `&rawmemelem(d, c, width)[width]` (after copying) + * + * @since 1.1 */ void *libsimple_rawmemelemcpy(void *restrict, const void *restrict, const void *restrict, size_t); #ifndef rawmemelemcpy @@ -314,6 +344,8 @@ void *libsimple_rawmemelemcpy(void *restrict, const void *restrict, const void * * @param elem The element that stops the copying * @param width The size of each element * @return `&rawmemelem(d, c, width)[width]` (after copying) + * + * @since 1.1 */ void *libsimple_rawmemelemmove(void *, const void *, const void *restrict, size_t); #ifndef rawmemelemmove @@ -331,6 +363,8 @@ void *libsimple_rawmemelemmove(void *, const void *, const void *restrict, size_ * @param width The size of each element * @param n The length of `s`, measured in elements * @return `(void *)&((char *)s)[n * width]` + * + * @since 1.1 */ void *libsimple_memreplaceelem(void *restrict, const void *, const void *, size_t, size_t); #ifndef memreplaceelem diff --git a/libsimple/overflow.h b/libsimple/overflow.h index 66ea6fa..a4857a8 100644 --- a/libsimple/overflow.h +++ b/libsimple/overflow.h @@ -149,258 +149,322 @@ #endif +/* @since 1.1 */ #ifndef UADD_WOULD_OVERFLOW # define UADD_WOULD_OVERFLOW(A, B, MAX) LIBSIMPLE_UADD_WOULD_OVERFLOW(A, B, MAX) #endif +/* @since 1.1 */ #ifndef USUB_WOULD_OVERFLOW # define USUB_WOULD_OVERFLOW(A, B) LIBSIMPLE_USUB_WOULD_OVERFLOW(A, B) #endif +/* @since 1.1 */ #ifndef UMUL_WOULD_OVERFLOW # define UMUL_WOULD_OVERFLOW(A, B, MAX) LIBSIMPLE_UMUL_WOULD_OVERFLOW(A, B, MAX) #endif +/* @since 1.1 */ #ifndef UMUL_WOULD_OVERFLOW_NONZERO # define UMUL_WOULD_OVERFLOW_NONZERO(A, B, MAX) LIBSIMPLE_UMUL_WOULD_OVERFLOW_NONZERO(A, B, MAX) #endif +/* @since 1.1 */ #ifndef UINCR_WOULD_OVERFLOW # define UINCR_WOULD_OVERFLOW(A, MAX) LIBSIMPLE_UINCR_WOULD_OVERFLOW(A, MAX) #endif +/* @since 1.1 */ #ifndef UDECR_WOULD_OVERFLOW # define UDECR_WOULD_OVERFLOW(A) LIBSIMPLE_UDECR_WOULD_OVERFLOW(A) #endif +/* @since 1.1 */ #ifndef UADD_OVERFLOW # define UADD_OVERFLOW(A, B, RES, MAX) LIBSIMPLE_UADD_OVERFLOW(A, B, RES, MAX) #endif +/* @since 1.1 */ #ifndef USUB_OVERFLOW # define USUB_OVERFLOW(A, B, RES) LIBSIMPLE_USUB_OVERFLOW(A, B, RES) #endif +/* @since 1.1 */ #ifndef UMUL_OVERFLOW # define UMUL_OVERFLOW(A, B, RES, MAX) LIBSIMPLE_UMUL_OVERFLOW(A, B, RES, MAX) #endif +/* @since 1.1 */ #ifndef UMUL_OVERFLOW_NONZERO # define UMUL_OVERFLOW_NONZERO(A, B, RES, MAX) LIBSIMPLE_UMUL_OVERFLOW_NONZERO(A, B, RES, MAX) #endif +/* @since 1.1 */ #ifndef UINCR_OVERFLOW # define UINCR_OVERFLOW(AP, MAX) LIBSIMPLE_UINCR_OVERFLOW(AP, MAX) #endif +/* @since 1.1 */ #ifndef UDECR_OVERFLOW # define UDECR_OVERFLOW(AP) LIBSIMPLE_UDECR_OVERFLOW(AP) #endif +/* @since 1.1 */ #ifndef SADD_WOULD_OVERFLOW # define SADD_WOULD_OVERFLOW(A, B, MIN, MAX) LIBSIMPLE_SADD_WOULD_OVERFLOW(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SADD_WOULD_OVERFLOW_A_NEG # define SADD_WOULD_OVERFLOW_A_NEG(A, B, MIN, MAX) LIBSIMPLE_SADD_WOULD_OVERFLOW_A_NEG(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SADD_WOULD_OVERFLOW_B_NEG # define SADD_WOULD_OVERFLOW_B_NEG(A, B, MIN, MAX) LIBSIMPLE_SADD_WOULD_OVERFLOW_B_NEG(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SADD_WOULD_OVERFLOW_NONNEG # define SADD_WOULD_OVERFLOW_NONNEG(A, B, MIN, MAX) LIBSIMPLE_SADD_WOULD_OVERFLOW_NONNEG(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SSUB_WOULD_OVERFLOW # define SSUB_WOULD_OVERFLOW(A, B, MIN, MAX) LIBSIMPLE_SSUB_WOULD_OVERFLOW(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SSUB_WOULD_OVERFLOW_B_NEG # define SSUB_WOULD_OVERFLOW_B_NEG(A, B, MIN, MAX) LIBSIMPLE_SSUB_WOULD_OVERFLOW_B_NEG(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SSUB_WOULD_OVERFLOW_B_POS # define SSUB_WOULD_OVERFLOW_B_POS(A, B, MIN, MAX) LIBSIMPLE_SSUB_WOULD_OVERFLOW_B_POS(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW # define SMUL_WOULD_OVERFLOW(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_NONZERO # define SMUL_WOULD_OVERFLOW_NONZERO(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_NONZERO(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_AN # define SMUL_WOULD_OVERFLOW_AN(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_AN(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_AN_BNZ # define SMUL_WOULD_OVERFLOW_AN_BNZ(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_AN_BNZ(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_AN_BN # define SMUL_WOULD_OVERFLOW_AN_BN(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_AN_BN(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_AN_BP # define SMUL_WOULD_OVERFLOW_AN_BP(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_AN_BP(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_AP # define SMUL_WOULD_OVERFLOW_AP(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_AP(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_AP_BNZ # define SMUL_WOULD_OVERFLOW_AP_BNZ(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_AP_BNZ(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_AP_BN # define SMUL_WOULD_OVERFLOW_AP_BN(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_AP_BN(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_AP_BP # define SMUL_WOULD_OVERFLOW_AP_BP(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_AP_BP(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_BN # define SMUL_WOULD_OVERFLOW_BN(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_BN(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_ANZ_BN # define SMUL_WOULD_OVERFLOW_ANZ_BN(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_ANZ_BN(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_BP # define SMUL_WOULD_OVERFLOW_BP(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_BP(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_WOULD_OVERFLOW_ANZ_BP # define SMUL_WOULD_OVERFLOW_ANZ_BP(A, B, MIN, MAX) LIBSIMPLE_SMUL_WOULD_OVERFLOW_ANZ_BP(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SDIV_WOULD_OVERFLOW # define SDIV_WOULD_OVERFLOW(A, B, MIN, MAX) LIBSIMPLE_SDIV_WOULD_OVERFLOW(A, B, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SINCR_WOULD_OVERFLOW # define SINCR_WOULD_OVERFLOW(A, MAX) LIBSIMPLE_SINCR_WOULD_OVERFLOW(A, MAX) #endif +/* @since 1.1 */ #ifndef SDECR_WOULD_OVERFLOW # define SDECR_WOULD_OVERFLOW(A, MIN) LIBSIMPLE_SDECR_WOULD_OVERFLOW(A, MIN) #endif +/* @since 1.1 */ #ifndef SADD_OVERFLOW # define SADD_OVERFLOW(A, B, RES, MIN, MAX) LIBSIMPLE_SADD_OVERFLOW(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SADD_OVERFLOW_A_NEG # define SADD_OVERFLOW_A_NEG(A, B, RES, MIN, MAX) LIBSIMPLE_SADD_OVERFLOW_A_NEG(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SADD_OVERFLOW_B_NEG # define SADD_OVERFLOW_B_NEG(A, B, RES, MIN, MAX) LIBSIMPLE_SADD_OVERFLOW_B_NEG(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SADD_OVERFLOW_NONNEG # define SADD_OVERFLOW_NONNEG(A, B, RES, MIN, MAX) LIBSIMPLE_SADD_OVERFLOW_NONNEG(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SSUB_OVERFLOW # define SSUB_OVERFLOW(A, B, RES, MIN, MAX) LIBSIMPLE_SSUB_OVERFLOW(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SSUB_OVERFLOW_B_NEG # define SSUB_OVERFLOW_B_NEG(A, B, RES, MIN, MAX) LIBSIMPLE_SSUB_OVERFLOW_B_NEG(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SSUB_OVERFLOW_B_POS # define SSUB_OVERFLOW_B_POS(A, B, RES, MIN, MAX) LIBSIMPLE_SSUB_OVERFLOW_B_POS(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW # define SMUL_OVERFLOW(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_NONZERO # define SMUL_OVERFLOW_NONZERO(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_NONZERO(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_AN # define SMUL_OVERFLOW_AN(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_AN(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_AN_BNZ # define SMUL_OVERFLOW_AN_BNZ(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_AN_BNZ(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_AN_BN # define SMUL_OVERFLOW_AN_BN(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_AN_BN(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_AN_BP # define SMUL_OVERFLOW_AN_BP(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_AN_BP(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_AP # define SMUL_OVERFLOW_AP(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_AP(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_AP_BNZ # define SMUL_OVERFLOW_AP_BNZ(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_AP_BNZ(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_AP_BN # define SMUL_OVERFLOW_AP_BN(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_AP_BN(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_AP_BP # define SMUL_OVERFLOW_AP_BP(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_AP_BP(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_BN # define SMUL_OVERFLOW_BN(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_BN(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_ANZ_BN # define SMUL_OVERFLOW_ANZ_BN(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_ANZ_BN(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_BP # define SMUL_OVERFLOW_BP(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_BP(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SMUL_OVERFLOW_ANZ_BP # define SMUL_OVERFLOW_ANZ_BP(A, B, RES, MIN, MAX) LIBSIMPLE_SMUL_OVERFLOW_ANZ_BP(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SDIV_OVERFLOW # define SDIV_OVERFLOW(A, B, RES, MIN, MAX) LIBSIMPLE_SDIV_OVERFLOW(A, B, RES, MIN, MAX) #endif +/* @since 1.1 */ #ifndef SINCR_OVERFLOW # define SINCR_OVERFLOW(AP, MAX) LIBSIMPLE_SINCR_OVERFLOW(AP, MAX) #endif +/* @since 1.1 */ #ifndef SDECR_OVERFLOW # define SDECR_OVERFLOW(AP, MIN) LIBSIMPLE_SDECR_OVERFLOW(AP, MIN) #endif +/* @since 1.1 */ #ifndef INCR_WOULD_OVERFLOW # define INCR_WOULD_OVERFLOW(A, MAX) LIBSIMPLE_INCR_WOULD_OVERFLOW(A, MAX) #endif +/* @since 1.1 */ #ifndef DECR_WOULD_OVERFLOW # define DECR_WOULD_OVERFLOW(A, MIN) LIBSIMPLE_DECR_WOULD_OVERFLOW(A, MIN) #endif +/* @since 1.1 */ #ifndef INCR_OVERFLOW # define INCR_OVERFLOW(AP, MAX) LIBSIMPLE_INCR_OVERFLOW(AP, MAX) #endif +/* @since 1.1 */ #ifndef DECR_OVERFLOW # define DECR_OVERFLOW(AP, MIN) LIBSIMPLE_DECR_OVERFLOW(AP, MIN) #endif diff --git a/libsimple/posix_memalign.h b/libsimple/posix_memalign.h index f656ea8..56e205f 100644 --- a/libsimple/posix_memalign.h +++ b/libsimple/posix_memalign.h @@ -24,6 +24,8 @@ * @throws EINVAL `n` is 0, `alignment` is not a power of 2, or * `alignment` is not a multiple of `sizeof(void *)` * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline int libsimple_vposix_memalignn(void **__memptr, size_t __alignment, size_t __n, va_list __ap) @@ -56,6 +58,8 @@ static inline int libsimple_vposix_memalignn(void **__memptr, size_t __alignment * @throws EINVAL `n` is 0, `alignment` is not a power of 2, or * `alignment` is not a multiple of `sizeof(void *)` * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline int @@ -87,6 +91,8 @@ libsimple_posix_memalignn(void **__memptr, size_t __alignment, size_t __n, ... / * of `sizeof(void *)` * @param n The number of bytes to allocate, the behaviour of * this function is unspecified for the value 0 + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) static inline void libsimple_enposix_memalign(int __status, void **__memptr, size_t __alignment, size_t __n) @@ -118,6 +124,8 @@ static inline void libsimple_enposix_memalign(int __status, void **__memptr, siz * @param ap The rest of the factors for the allocation size, * all arguments should have the type `size_t`, and * list must end with 0 (which is not factor) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) static inline void libsimple_envposix_memalignn(int __status, void **__memptr, size_t __alignment, size_t __n, va_list __ap) @@ -149,6 +157,8 @@ static inline void libsimple_envposix_memalignn(int __status, void **__memptr, s * @param ... The rest of the factors for the allocation size, * all arguments should have the type `size_t`, and * list must end with 0 (which is not factor) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) static inline void @@ -179,6 +189,8 @@ libsimple_enposix_memalignn(int __status, void **__memptr, size_t __alignment, s * of `sizeof(void *)` * @param n The number of bytes to allocate, the behaviour of * this function is unspecified for the value 0 + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline void libsimple_eposix_memalign(void **__memptr, size_t __alignment, size_t __n) @@ -209,6 +221,8 @@ static inline void libsimple_eposix_memalign(void **__memptr, size_t __alignment * @param ap The rest of the factors for the allocation size, * all arguments should have the type `size_t`, and * list must end with 0 (which is not factor) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline void libsimple_evposix_memalignn(void **__memptr, size_t __alignment, size_t __n, va_list __ap) @@ -239,6 +253,8 @@ static inline void libsimple_evposix_memalignn(void **__memptr, size_t __alignme * @param ... The rest of the factors for the allocation size, * all arguments should have the type `size_t`, and * list must end with 0 (which is not factor) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline void diff --git a/libsimple/posix_memalignz.h b/libsimple/posix_memalignz.h index 323863d..e604b7d 100644 --- a/libsimple/posix_memalignz.h +++ b/libsimple/posix_memalignz.h @@ -25,6 +25,8 @@ * @throws EINVAL `n` is 0, `alignment` is not a power of 2, or * `alignment` is not a multiple of `sizeof(void *)` * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) int libsimple_vposix_memalignzn(void **, int, size_t, size_t, va_list); @@ -51,6 +53,8 @@ int libsimple_vposix_memalignzn(void **, int, size_t, size_t, va_list); * @throws EINVAL `n` is 0, `alignment` is not a power of 2, or * `alignment` is not a multiple of `sizeof(void *)` * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline int @@ -90,6 +94,8 @@ libsimple_posix_memalignz(void **__memptr, int __clear, size_t __alignment, size * @throws EINVAL `n` is 0, `alignment` is not a power of 2, or * `alignment` is not a multiple of `sizeof(void *)` * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline int @@ -122,6 +128,8 @@ libsimple_posix_memalignzn(void **__memptr, int __clear, size_t __alignment, siz * of `sizeof(void *)` * @param n The number of bytes to allocate, the behaviour of * this function is unspecified for the value 0 + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) void libsimple_enposix_memalignz(int, void **, int, size_t, size_t); @@ -153,6 +161,8 @@ void libsimple_enposix_memalignz(int, void **, int, size_t, size_t); * @param ap The rest of the factors for the allocation size, * all arguments should have the type `size_t`, and * list must end with 0 (which is not factor) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) void libsimple_envposix_memalignzn(int, void **, int, size_t, size_t, va_list); @@ -184,6 +194,8 @@ void libsimple_envposix_memalignzn(int, void **, int, size_t, size_t, va_list); * @param ... The rest of the factors for the allocation size, * all arguments should have the type `size_t`, and * list must end with 0 (which is not factor) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) static inline void @@ -215,6 +227,8 @@ libsimple_enposix_memalignzn(int __status, void **__memptr, int __clear, size_t * of `sizeof(void *)` * @param n The number of bytes to allocate, the behaviour of * this function is unspecified for the value 0 + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline void libsimple_eposix_memalignz(void **__memptr, int __clear, size_t __alignment, size_t __n) @@ -246,6 +260,8 @@ static inline void libsimple_eposix_memalignz(void **__memptr, int __clear, size * @param ap The rest of the factors for the allocation size, * all arguments should have the type `size_t`, and * list must end with 0 (which is not factor) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline void libsimple_evposix_memalignzn(void **__memptr, int __clear, size_t __alignment, size_t __n, va_list __ap) @@ -277,6 +293,8 @@ static inline void libsimple_evposix_memalignzn(void **__memptr, int __clear, si * @param ... The rest of the factors for the allocation size, * all arguments should have the type `size_t`, and * list must end with 0 (which is not factor) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) static inline void diff --git a/libsimple/printf.h b/libsimple/printf.h index cf7192e..6bdab79 100644 --- a/libsimple/printf.h +++ b/libsimple/printf.h @@ -5,6 +5,8 @@ * Exit value for `libsimple_eprintf` * * Default value is 1 + * + * @since 1.0 */ extern int libsimple_default_failure_exit; @@ -18,6 +20,8 @@ extern int libsimple_default_failure_exit; * it was when `libsimple_vweprintf` was called. * * Default value is `NULL` + * + * @since 1.1 */ extern void (*libsimple_eprintf_preprint)(void); @@ -31,6 +35,8 @@ extern void (*libsimple_eprintf_preprint)(void); * it was when `libsimple_vweprintf` was called. * * Default value is `NULL` + * + * @since 1.1 */ extern void (*libsimple_eprintf_postprint)(void); @@ -50,6 +56,8 @@ extern void (*libsimple_eprintf_postprint)(void); * @throws EMFILE {FOPEN_MAX} streams are currently open in the calling process * @throws ENOMEM Could not allocate enough memory * @throws Any error specified for `fprintf` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1, 2), __format__(__printf__, 2, 3)))) int libsimple_asprintf(char **, const char *, ...); @@ -73,6 +81,8 @@ int libsimple_asprintf(char **, const char *, ...); * @throws EMFILE {FOPEN_MAX} streams are currently open in the calling process * @throws ENOMEM Could not allocate enough memory * @throws Any error specified for `fprintf` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1, 2)))) int libsimple_vasprintf(char **, const char *, va_list); @@ -93,6 +103,8 @@ int libsimple_vasprintf(char **, const char *, va_list); * @param ... The format argument * @return The formatted string, `NULL` on error * @throws Any error specified for `snprintf` + * + * @since 1.0 */ #if defined(__GNUC__) || defined(__clang__) # define libsimple_asprintfa(__fmt, ...)\ @@ -124,6 +136,8 @@ int libsimple_vasprintf(char **, const char *, va_list); * @param ap The format argument * @return The formatted string, `NULL` on error * @throws Any error specified for `snprintf` + * + * @since 1.0 */ #if defined(__GNUC__) || defined(__clang__) # define libsimple_vasprintfa(__fmt, __ap)\ @@ -166,6 +180,8 @@ int libsimple_vasprintf(char **, const char *, va_list); * * @param fmt The format string * @param ap The format argument + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) void libsimple_vweprintf(const char *, va_list); @@ -190,6 +206,8 @@ void libsimple_vweprintf(const char *, va_list); * * @param fmt The format string * @param ... The format argument + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1), __format__(__printf__, 1, 2)))) static inline void @@ -224,6 +242,8 @@ libsimple_weprintf(const char *__fmt, ...) * @param status Exit value for the process * @param fmt The format string * @param ap The format argument + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2), __noreturn__))) static inline void @@ -256,6 +276,8 @@ libsimple_venprintf(int __status, const char *__fmt, va_list __ap) * @param status Exit value for the process * @param fmt The format string * @param ... The format argument + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2), __format__(__printf__, 2, 3), __noreturn__))) static inline void @@ -290,6 +312,8 @@ libsimple_enprintf(int __status, const char *__fmt, ...) * * @param fmt The format string * @param ap The format argument + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1), __noreturn__))) static inline void @@ -322,6 +346,8 @@ libsimple_veprintf(const char *__fmt, va_list __ap) * * @param fmt The format string * @param ... The format argument + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1), __format__(__printf__, 1, 2), __noreturn__))) static inline void diff --git a/libsimple/pvalloc.h b/libsimple/pvalloc.h index 78deb1a..a858221 100644 --- a/libsimple/pvalloc.h +++ b/libsimple/pvalloc.h @@ -20,6 +20,8 @@ * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void *libsimple_vpvallocn(size_t __n, va_list __ap) @@ -42,6 +44,8 @@ static inline void *libsimple_vpvallocn(size_t __n, va_list __ap) * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void *libsimple_pvalloc(size_t __n) @@ -70,6 +74,8 @@ static inline void *libsimple_pvalloc(size_t __n) * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -102,6 +108,8 @@ libsimple_pvallocn(size_t __n, ... /*, (size_t)0 */) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_enpvalloc(int __status, size_t __n) @@ -133,6 +141,8 @@ static inline void *libsimple_enpvalloc(int __status, size_t __n) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_envpvallocn(int __status, size_t __n, va_list __ap) @@ -164,6 +174,8 @@ static inline void *libsimple_envpvallocn(int __status, size_t __n, va_list __ap * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -195,6 +207,8 @@ libsimple_enpvallocn(int __status, size_t __n, ... /*, (size_t)0 */) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_epvalloc(size_t __n) @@ -225,6 +239,8 @@ static inline void *libsimple_epvalloc(size_t __n) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evpvallocn(size_t __n, va_list __ap) @@ -255,6 +271,8 @@ static inline void *libsimple_evpvallocn(size_t __n, va_list __ap) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/pvallocz.h b/libsimple/pvallocz.h index a61f80b..5809df7 100644 --- a/libsimple/pvallocz.h +++ b/libsimple/pvallocz.h @@ -21,6 +21,8 @@ * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -51,6 +53,8 @@ libsimple_vpvalloczn(int __clear, size_t __n, va_list __ap) * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2), __warn_unused_result__))) static inline void * @@ -87,6 +91,8 @@ libsimple_pvallocz(int __clear, size_t __n) * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -120,6 +126,8 @@ libsimple_pvalloczn(int __clear, size_t __n, ... /*, (size_t)0 */) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -160,6 +168,8 @@ libsimple_enpvallocz(int __status, int __clear, size_t __n) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -201,6 +211,8 @@ libsimple_envpvalloczn(int __status, int __clear, size_t __n, va_list __ap) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -233,6 +245,8 @@ libsimple_enpvalloczn(int __status, int __clear, size_t __n, ... /*, (size_t)0 * * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_epvallocz(int __clear, size_t __n) @@ -264,6 +278,8 @@ static inline void *libsimple_epvallocz(int __clear, size_t __n) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evpvalloczn(int __clear, size_t __n, va_list __ap) @@ -295,6 +311,8 @@ static inline void *libsimple_evpvalloczn(int __clear, size_t __n, va_list __ap) * @return A unique pointer with at least the specified size, * rounded up to the next multiple of the page size, * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/realloc.h b/libsimple/realloc.h index b02c08a..32a5f59 100644 --- a/libsimple/realloc.h +++ b/libsimple/realloc.h @@ -25,6 +25,8 @@ * `alignof(max_align_t)`; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) void *libsimple_vreallocn(void *, size_t, va_list); @@ -57,6 +59,8 @@ void *libsimple_vreallocn(void *, size_t, va_list); * `alignof(max_align_t)`; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) static inline void * @@ -94,6 +98,8 @@ libsimple_reallocn(void *__ptr, size_t __n, ... /*, (size_t)0 */) * @return Either `ptr` or a unique pointer with at least * the specified size and with the alignment * `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) void *libsimple_enrealloc(int, void *, size_t); @@ -129,6 +135,8 @@ void *libsimple_enrealloc(int, void *, size_t); * @return Either `ptr` or a unique pointer with at least * the specified size and with the alignment * `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__, __returns_nonnull__))) void *libsimple_envreallocn(int, void *, size_t, va_list); @@ -164,6 +172,8 @@ void *libsimple_envreallocn(int, void *, size_t, va_list); * @return Either `ptr` or a unique pointer with at least * the specified size and with the alignment * `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__, __returns_nonnull__))) static inline void * @@ -200,6 +210,8 @@ libsimple_enreallocn(int __status, void *__ptr, size_t __n, ... /*, (size_t)0 */ * @return Either `ptr` or a unique pointer with at least * the specified size and with the alignment * `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_erealloc(void *__ptr, size_t __n) @@ -235,6 +247,8 @@ static inline void *libsimple_erealloc(void *__ptr, size_t __n) * @return Either `ptr` or a unique pointer with at least * the specified size and with the alignment * `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evreallocn(void *__ptr, size_t __n, va_list __ap) @@ -270,6 +284,8 @@ static inline void *libsimple_evreallocn(void *__ptr, size_t __n, va_list __ap) * @return Either `ptr` or a unique pointer with at least * the specified size and with the alignment * `alignof(max_align_t)` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/str.h b/libsimple/str.h index 4bf5793..4c17a0a 100644 --- a/libsimple/str.h +++ b/libsimple/str.h @@ -8,6 +8,8 @@ * @param c The character to scan for * @return `s` with a minimal offset such that `*r == c || !*r`, * where `r` is the returned pointer + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strchrnul(const char *, int); @@ -23,6 +25,8 @@ char *libsimple_strchrnul(const char *, int); * @param c The character to scan for * @return `s` with a minimal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strcasechr(const char *, int); @@ -38,6 +42,8 @@ char *libsimple_strcasechr(const char *, int); * @param c The character to scan for * @return `s` with a minimal offset such that `tolower(*r) == tolower(c) || !*r`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strcasechrnul(const char *, int); @@ -53,6 +59,8 @@ char *libsimple_strcasechrnul(const char *, int); * @param c The character to scan for * @return `s` with a maximal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrcasechr(const char *, int); @@ -69,6 +77,8 @@ char *libsimple_strrcasechr(const char *, int); * @param c The character to skip over * @return `s` with a minimal offset such that `*r != c`, where `r` * is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strchr_inv(const char *, int); @@ -85,6 +95,8 @@ char *libsimple_strchr_inv(const char *, int); * @param c The character to skip over * @return `s` with a minimal offset such that `*r != c || !*r`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strchrnul_inv(const char *, int); @@ -101,6 +113,8 @@ char *libsimple_strchrnul_inv(const char *, int); * @param c The character to skip over * @return `s` with a minimal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strcasechr_inv(const char *, int); @@ -117,6 +131,8 @@ char *libsimple_strcasechr_inv(const char *, int); * @param c The character to skip over * @return `s` with a minimal offset such that `tolower(*r) != tolower(c) || !*r`, * where `r` is the returned pointer + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strcasechrnul_inv(const char *, int); @@ -133,6 +149,8 @@ char *libsimple_strcasechrnul_inv(const char *, int); * @param c The character to skip over * @return `s` with a maximal offset such that `*r != c`, where `r` * is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrchr_inv(const char *, int); @@ -149,6 +167,8 @@ char *libsimple_strrchr_inv(const char *, int); * @param c The character to skip over * @return `s` with a maximal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrcasechr_inv(const char *, int); @@ -162,6 +182,8 @@ char *libsimple_strrcasechr_inv(const char *, int); * * @param s The string * @return `s` with an offset such `!*r`, where `r` is the returned pointer + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline char *libsimple_strend(const char *__s) @@ -177,6 +199,8 @@ static inline char *libsimple_strend(const char *__s) * @param s The string the check * @param t The string `s` should begin with * @return 1 if `s` starts with `t`, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) int libsimple_strstarts(const char *, const char *); @@ -191,6 +215,8 @@ int libsimple_strstarts(const char *, const char *); * @param s The string the check * @param t The string `s` should begin with * @return 1 if `s` starts with `t`, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_strcasestarts(const char *__s, const char *__t) @@ -206,6 +232,8 @@ static inline int libsimple_strcasestarts(const char *__s, const char *__t) * @param s The string the check * @param t The string `s` should begin with * @return 1 if `s` ends with `t`, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) int libsimple_strends(const char *, const char *); @@ -220,6 +248,8 @@ int libsimple_strends(const char *, const char *); * @param s The string the check * @param t The string `s` should begin with * @return 1 if `s` end with `t`, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) int libsimple_strcaseends(const char *, const char *); @@ -236,6 +266,8 @@ int libsimple_strcaseends(const char *, const char *); * @return `haystack` with a maximal offset such that the returned * pointer begins with `needle`, `NULL` if no such offset * exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrstr(const char *, const char *); @@ -252,6 +284,8 @@ char *libsimple_strrstr(const char *, const char *); * @return `haystack` with a minimal offset such that the returned * pointer begins with `needle`, `NULL` if no such offset * exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strcasestr(const char *, const char *); @@ -268,6 +302,8 @@ char *libsimple_strcasestr(const char *, const char *); * @return `haystack` with a maximal offset such that the returned * pointer begins with `needle`, `NULL` if no such offset * exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrcasestr(const char *, const char *); @@ -285,6 +321,8 @@ char *libsimple_strrcasestr(const char *, const char *); * @return A negative value if `a` is less than `b`, * a positive value if `a` is greater than `b`, * 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strcmpnul(const char *__a, const char *__b) @@ -303,6 +341,8 @@ static inline int libsimple_strcmpnul(const char *__a, const char *__b) * @return A negative value if `a` is less than `b`, * a positive value if `a` is greater than `b`, * 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strcasecmpnul(const char *__a, const char *__b) @@ -319,6 +359,8 @@ static inline int libsimple_strcasecmpnul(const char *__a, const char *__b) * @param a One of the strings, may not be `NULL` * @param b The other string, may not be `NULL` * @return 1 if the strings are equal, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_streq(const char *__a, const char *__b) @@ -335,6 +377,8 @@ static inline int libsimple_streq(const char *__a, const char *__b) * @param a One of the strings, may be `NULL` * @param b The other string, may be `NULL` * @return 1 if the strings are equal, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_streqnul(const char *__a, const char *__b) @@ -351,6 +395,8 @@ static inline int libsimple_streqnul(const char *__a, const char *__b) * @param a One of the strings, may not be `NULL` * @param b The other string, may not be `NULL` * @return 1 if the strings are equal, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_strcaseeq(const char *__a, const char *__b) @@ -367,6 +413,8 @@ static inline int libsimple_strcaseeq(const char *__a, const char *__b) * @param a One of the strings, may be `NULL` * @param b The other string, may be `NULL` * @return 1 if the strings are equal, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strcaseeqnul(const char *__a, const char *__b) @@ -383,6 +431,8 @@ static inline int libsimple_strcaseeqnul(const char *__a, const char *__b) * @param b The other string * @return The number of bytes `a` and `b` have * in common in their beginnings + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) size_t libsimple_streqlen(const char *, const char *); @@ -398,6 +448,8 @@ size_t libsimple_streqlen(const char *, const char *); * @param b The other string * @return The number of bytes `a` and `b` have * in common in their beginnings + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) size_t libsimple_strcaseeqlen(const char *, const char *); @@ -413,6 +465,8 @@ size_t libsimple_strcaseeqlen(const char *, const char *); * @param b The other string * @return The number of bytes `a` and `b` have * in common in their ends + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strreqlen(const char *__a, const char *__b) @@ -429,6 +483,8 @@ static inline size_t libsimple_strreqlen(const char *__a, const char *__b) * @param b The other string * @return The number of bytes `a` and `b` have * in common in their ends + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrcaseeqlen(const char *__a, const char *__b) @@ -445,6 +501,8 @@ static inline size_t libsimple_strrcaseeqlen(const char *__a, const char *__b) * @param s The string to look in * @return 1 if the byte `c` is not the NUL byte and can be found in `s`, * 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_inchrset(int __c, const char *__s) @@ -461,6 +519,8 @@ static inline int libsimple_inchrset(int __c, const char *__s) * @param s The string to look in * @return 1 if the byte `c` is not the NUL byte and can be found in `s`, * 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_inchrcaseset(int __c, const char *__s) @@ -477,6 +537,8 @@ static inline int libsimple_inchrcaseset(int __c, const char *__s) * string should be moved to * @param s The string to move * @return `d` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char *libsimple_strmove(char *__d, const char *__s) @@ -493,6 +555,8 @@ static inline char *libsimple_strmove(char *__d, const char *__s) * string should be moved to * @param s The string to move * @return `&d[strlen(s)]` (this byte will be a NUL byte) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char *libsimple_stpmove(char *__d, const char *__s) @@ -508,6 +572,8 @@ static inline char *libsimple_stpmove(char *__d, const char *__s) * @param s The string to fill * @param c The byte to replace all bytes in `s` with * @return `s` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char * @@ -528,6 +594,8 @@ libsimple_strset(char *__s, int __c_) * @param s The string to fill * @param c The byte to replace all bytes in `s` with * @return `&s[strlen(s)]` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char * @@ -551,6 +619,8 @@ libsimple_stpset(char *__s, int __c_) * @param c The character that stops the copying * @return `&strchr(d, c)[1]` (after copying) if `c` can be * found in `s`, `NULL` otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char * @@ -576,6 +646,8 @@ libsimple_strccpy(char *restrict __d, const char *restrict __s, int __c_) * @param c The character that stops the copying * @return `&strchr(d, c)[1]` (after copying) if `c` can be * found in `s` (before copying), `NULL` otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) char *libsimple_strcmove(char *, const char *, int); @@ -592,6 +664,8 @@ char *libsimple_strcmove(char *, const char *, int); * @param old The value of the characters to replace * @param new The value to replace the characters with * @return `strchr(s, '\0')` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) static inline char * @@ -619,6 +693,8 @@ libsimple_strreplace(char *__s, int __old_, int __new_) * @param d The location the string shall be copied to * @param s The string to copy * @return `strchr(d, '\0')` (after copying) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) char *libsimple_stptolower(char *, const char *); @@ -638,6 +714,8 @@ char *libsimple_stptolower(char *, const char *); * @param d The location the string shall be copied to * @param s The string to copy * @return `strchr(d, '\0')` (after copying) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) char *libsimple_stptoupper(char *, const char *); @@ -657,6 +735,8 @@ char *libsimple_stptoupper(char *, const char *); * @param d The location the string shall be copied to * @param s The string to copy * @return `d` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) static inline char *libsimple_strtolower(char *__d, const char *__s) @@ -677,6 +757,8 @@ static inline char *libsimple_strtolower(char *__d, const char *__s) * @param d The location the string shall be copied to * @param s The string to copy * @return `d` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) static inline char *libsimple_strtoupper(char *__d, const char *__s) @@ -693,6 +775,8 @@ static inline char *libsimple_strtoupper(char *__d, const char *__s) * @param allow_modified_nul Whether Modified UTF-8 is allowed, which * allows a two-byte encoding for NUL * @return 1 if good, 0 on encoding error + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_strisutf8(const char *__string, int __allow_modified_nul) diff --git a/libsimple/strdup.h b/libsimple/strdup.h index 74e689e..3db9d95 100644 --- a/libsimple/strdup.h +++ b/libsimple/strdup.h @@ -6,6 +6,8 @@ * * @param s:const char * The string to copy * @return :char * Duplicate of `s` with automatic storage + * + * @since 1.0 */ #if defined(__GNUC__) || defined(__clang__) # define libsimple_strdupa(s)\ @@ -27,6 +29,8 @@ * @param status Exit value in case of failure * @param s The string to copy * @return Duplicate of `s` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __assume_aligned__(1), __nonnull__, __warn_unused_result__, __returns_nonnull__))) char *libsimple_enstrdup(int, const char *); @@ -40,6 +44,8 @@ char *libsimple_enstrdup(int, const char *); * * @param s The string to copy * @return Duplicate of `s` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __assume_aligned__(1), __nonnull__, __warn_unused_result__, __returns_nonnull__))) static inline char *libsimple_estrdup(const char *__s) diff --git a/libsimple/strn.h b/libsimple/strn.h index aa8a889..dc6e695 100644 --- a/libsimple/strn.h +++ b/libsimple/strn.h @@ -10,6 +10,8 @@ * @return `s` with a minimal offset such that `*r == c`, * where `r` is the returned pointer, `NULL` if no such offset exists * within the first `n` bytes + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strnchr(const char *, int, size_t); @@ -27,6 +29,8 @@ char *libsimple_strnchr(const char *, int, size_t); * @return `s` with a minimal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer, `NULL` if no such offset exists * within the first `n` bytes + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strncasechr(const char *, int, size_t); @@ -44,6 +48,8 @@ char *libsimple_strncasechr(const char *, int, size_t); * @return `s` with a minimal offset such that `*r == c || !*r`, * where `r` is the returned pointer, however if no such * offset exists within the first `n` bytes, `&s[n]` is returned + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strnchrnul(const char *, int, size_t); @@ -61,6 +67,8 @@ char *libsimple_strnchrnul(const char *, int, size_t); * @return `s` with a minimal offset such that `tolower(*r) == tolower(c) || !*r`, * where `r` is the returned pointer, however if no such offset * exists within the first `n` bytes, `&s[n]` is returned + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strncasechrnul(const char *, int, size_t); @@ -77,6 +85,8 @@ char *libsimple_strncasechrnul(const char *, int, size_t); * @param n Truncate `s` to this length if it is longer * @return `s` with a maximal offset such that `*r == c`, * where `r` is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrnchr(const char *, int, size_t); @@ -94,6 +104,8 @@ char *libsimple_strrnchr(const char *, int, size_t); * @param n Truncate `s` to this length if it is longer * @return `s` with a maximal offset such that `tolower(*r) == tolower(c)`, * where `r` is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrncasechr(const char *, int, size_t); @@ -112,6 +124,8 @@ char *libsimple_strrncasechr(const char *, int, size_t); * @return `s` with a minimal offset such that `*r != c`, * where `r` is the returned pointer, `NULL` if no such offset exists * within the first `n` bytes + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strnchr_inv(const char *, int, size_t); @@ -130,6 +144,8 @@ char *libsimple_strnchr_inv(const char *, int, size_t); * @return `s` with a minimal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer, `NULL` if no such offset exists * within the first `n` bytes + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strncasechr_inv(const char *, int, size_t); @@ -148,6 +164,8 @@ char *libsimple_strncasechr_inv(const char *, int, size_t); * @return `s` with a minimal offset such that `*r != c || !*r`, * where `r` is the returned pointer, however if no such * offset exists within the first `n` bytes, `&s[n]` is returned + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strnchrnul_inv(const char *, int, size_t); @@ -166,6 +184,8 @@ char *libsimple_strnchrnul_inv(const char *, int, size_t); * @return `s` with a minimal offset such that `tolower(*r) != tolower(c) || !*r`, * where `r` is the returned pointer, however if no such offset * exists within the first `n` bytes, `&s[n]` is returned + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strncasechrnul_inv(const char *, int, size_t); @@ -183,6 +203,8 @@ char *libsimple_strncasechrnul_inv(const char *, int, size_t); * @param n Truncate `s` to this length if it is longer * @return `s` with a maximal offset such that `*r != c`, * where `r` is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrnchr_inv(const char *, int, size_t); @@ -200,6 +222,8 @@ char *libsimple_strrnchr_inv(const char *, int, size_t); * @param n Truncate `s` to this length if it is longer * @return `s` with a maximal offset such that `tolower(*r) != tolower(c)`, * where `r` is the returned pointer, `NULL` if no such offset exists + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrncasechr_inv(const char *, int, size_t); @@ -217,6 +241,8 @@ char *libsimple_strrncasechr_inv(const char *, int, size_t); * is the returned pointer, however if there * is not NUL byte within the first `n` bytes * if `s`, `&s[n]` is returned + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __returns_nonnull__, __warn_unused_result__))) char *libsimple_strnend(const char *, size_t); @@ -232,6 +258,8 @@ char *libsimple_strnend(const char *, size_t); * @param t The string `s` should begin with * @param n Truncate `s` to this length if it is longer * @return 1 if `s` starts with `t`, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) int libsimple_strnstarts(const char *, const char *, size_t); @@ -247,6 +275,8 @@ int libsimple_strnstarts(const char *, const char *, size_t); * @param t The string `s` should begin with * @param n Truncate `s` to this length if it is longer * @return 1 if `s` starts with `t`, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) int libsimple_strncasestarts(const char *, const char *, size_t); @@ -262,6 +292,8 @@ int libsimple_strncasestarts(const char *, const char *, size_t); * @param t The string `s` should begin with * @param n Truncate `s` to this length if it is longer * @return 1 if `s` ends with `t`, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) int libsimple_strnends(const char *, const char *, size_t); @@ -277,6 +309,8 @@ int libsimple_strnends(const char *, const char *, size_t); * @param t The string `s` should begin with * @param n Truncate `s` to this length if it is longer * @return 1 if `s` end with `t`, 0 otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) int libsimple_strncaseends(const char *, const char *, size_t); @@ -294,6 +328,8 @@ int libsimple_strncaseends(const char *, const char *, size_t); * @return `haystack` with a minimal offset such that the returned * pointer begins with `needle`, `NULL` if no such offset * exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strnstr(const char *, const char *, size_t); @@ -311,6 +347,8 @@ char *libsimple_strnstr(const char *, const char *, size_t); * @return `haystack` with a minimal offset such that the returned * pointer begins with `needle`, `NULL` if no such offset * exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strncasestr(const char *, const char *, size_t); @@ -328,6 +366,8 @@ char *libsimple_strncasestr(const char *, const char *, size_t); * @return `haystack` with a maximal offset such that the returned * pointer begins with `needle`, `NULL` if no such offset * exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrnstr(const char *, const char *, size_t); @@ -345,6 +385,8 @@ char *libsimple_strrnstr(const char *, const char *, size_t); * @return `haystack` with a maximal offset such that the returned * pointer begins with `needle`, `NULL` if no such offset * exists + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) char *libsimple_strrncasestr(const char *, const char *, size_t); @@ -364,6 +406,8 @@ char *libsimple_strrncasestr(const char *, const char *, size_t); * @return A negative value if `a` is less than `b`, * a positive value if `a` is greater than `b`, * 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strncmpnul(const char *__a, const char *__b, size_t __n) @@ -384,6 +428,8 @@ static inline int libsimple_strncmpnul(const char *__a, const char *__b, size_t * @return A negative value if `a` is less than `b`, * a positive value if `a` is greater than `b`, * 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strncasecmpnul(const char *__a, const char *__b, size_t __n) @@ -402,6 +448,8 @@ static inline int libsimple_strncasecmpnul(const char *__a, const char *__b, siz * @param n Truncate each input string that is * longer than this to this length * @return 1 if the strings are equal, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_strneq(const char *__a, const char *__b, size_t __n) @@ -420,6 +468,8 @@ static inline int libsimple_strneq(const char *__a, const char *__b, size_t __n) * @param n Truncate each input string that is * longer than this to this length * @return 1 if the strings are equal, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strneqnul(const char *__a, const char *__b, size_t __n) @@ -438,6 +488,8 @@ static inline int libsimple_strneqnul(const char *__a, const char *__b, size_t _ * @param n Truncate each input string that is * longer than this to this length * @return 1 if the strings are equal, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_strncaseeq(const char *__a, const char *__b, size_t __n) @@ -456,6 +508,8 @@ static inline int libsimple_strncaseeq(const char *__a, const char *__b, size_t * @param n Truncate each input string that is * longer than this to this length * @return 1 if the strings are equal, 0 otherwise + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strncaseeqnul(const char *__a, const char *__b, size_t __n) @@ -474,6 +528,8 @@ static inline int libsimple_strncaseeqnul(const char *__a, const char *__b, size * longer than this to this length * @return The number of bytes `a` and `b` have * in common in their beginnings + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) size_t libsimple_strneqlen(const char *, const char *, size_t); @@ -491,6 +547,8 @@ size_t libsimple_strneqlen(const char *, const char *, size_t); * longer than this to this length * @return The number of bytes `a` and `b` have * in common in their beginnings + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) size_t libsimple_strncaseeqlen(const char *, const char *, size_t); @@ -508,6 +566,8 @@ size_t libsimple_strncaseeqlen(const char *, const char *, size_t); * longer than this to this length * @return The number of bytes `a` and `b` have * in common in their ends + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrneqlen(const char *__a, const char *__b, size_t __n) @@ -526,6 +586,8 @@ static inline size_t libsimple_strrneqlen(const char *__a, const char *__b, size * longer than this to this length * @return The number of bytes `a` and `b` have * in common in their ends + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrncaseeqlen(const char *__a, const char *__b, size_t __n) @@ -543,6 +605,8 @@ static inline size_t libsimple_strrncaseeqlen(const char *__a, const char *__b, * @param s The string to move * @param n The maximum number of bytes to move * @return `d` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char *libsimple_strnmove(char *__d, const char *__s, size_t __n) @@ -560,6 +624,8 @@ static inline char *libsimple_strnmove(char *__d, const char *__s, size_t __n) * @param s The string to move * @param n The maximum number of bytes to move * @return `&d[strnlen(s, n)]` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char * @@ -581,6 +647,8 @@ libsimple_stpnmove(char *__d, const char *__s, size_t __n) * @param c The byte to replace all bytes in `s` with * @param n The maximum number of bytes to write * @return `s` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char * @@ -602,6 +670,8 @@ libsimple_strnset(char *__s, int __c_, size_t __n) * @param c The byte to replace all bytes in `s` with * @param n The maximum number of bytes to write * @return `&s[strnlen(s, n)]` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char * @@ -627,6 +697,8 @@ libsimple_stpnset(char *__s, int __c_, size_t __n) * @param n The maximum number of bytes to copy * @return `&strchr(d, c)[1]` (after copying) if `c` can be * found in `s`, `NULL` otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline char * @@ -660,6 +732,8 @@ libsimple_strnccpy(char *restrict __d, const char *restrict __s, int __c_, size_ * @return `&strchr(d, c)[1]` (after copying) if `c` can be * found within the first `n` bytes of `s` (before * copying), `NULL` otherwise + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) char *libsimple_strncmove(char *, const char *, int, size_t); @@ -677,6 +751,8 @@ char *libsimple_strncmove(char *, const char *, int, size_t); * @param new The value to replace the characters with * @param n The maximum length of `s` * @return `strnchr(s, '\0', n)` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) static inline char * @@ -705,6 +781,8 @@ libsimple_strnreplace(char *__s, int __old_, int __new_, size_t __n) * @param s The string to copy * @param n The maximum number of bytes to copy or convert * @return `strnchrnul(d, '\0', n)` (after copying) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) char *libsimple_stpntolower(char *, const char *, size_t); @@ -725,6 +803,8 @@ char *libsimple_stpntolower(char *, const char *, size_t); * @param s The string to copy * @param n The maximum number of bytes to copy or convert * @return `strnchrnul(d, '\0', n)` (after copying) + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) char *libsimple_stpntoupper(char *, const char *, size_t); @@ -745,6 +825,8 @@ char *libsimple_stpntoupper(char *, const char *, size_t); * @param s The string to copy * @param n The maximum number of bytes to copy or convert * @return `d` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) static inline char *libsimple_strntolower(char *__d, const char *__s, size_t __n) @@ -766,6 +848,8 @@ static inline char *libsimple_strntolower(char *__d, const char *__s, size_t __n * @param s The string to copy * @param n The maximum number of bytes to copy or convert * @return `d` + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __returns_nonnull__))) static inline char *libsimple_strntoupper(char *__d, const char *__s, size_t __n) @@ -786,6 +870,8 @@ static inline char *libsimple_strntoupper(char *__d, const char *__s, size_t __n * @param allow_modified_nul Whether Modified UTF-8 is allowed, which * allows a two-byte encoding for NUL * @return 1 if good, 0 on encoding error + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline int libsimple_strnisutf8(const char *__string, size_t __n, int __allow_modified_nul) diff --git a/libsimple/strndup.h b/libsimple/strndup.h index 174a10a..b3229d5 100644 --- a/libsimple/strndup.h +++ b/libsimple/strndup.h @@ -7,6 +7,8 @@ * @param s:const char * The string to copy * @param n:size_t The maximum number of bytes to copy * @return :char * Duplicate of `s` with automatic storage + * + * @since 1.0 */ #if defined(__GNUC__) || defined(__clang__) # define libsimple_strndupa(s, n)\ @@ -32,6 +34,8 @@ * @param s The string to copy * @param n The maximum number of bytes to copy * @return Duplicate of `s` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __assume_aligned__(1), __nonnull__, __warn_unused_result__, __returns_nonnull__))) char *libsimple_enstrndup(int, const char *, size_t); @@ -46,6 +50,8 @@ char *libsimple_enstrndup(int, const char *, size_t); * @param s The string to copy * @param n The maximum number of bytes to copy * @return Duplicate of `s` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __assume_aligned__(1), __nonnull__, __warn_unused_result__, __returns_nonnull__))) static inline char *libsimple_estrndup(const char *__s, size_t __n) diff --git a/libsimple/time.h b/libsimple/time.h index 71c19fe..aa92314 100644 --- a/libsimple/time.h +++ b/libsimple/time.h @@ -12,6 +12,8 @@ * will be `{.tv_sec = TIME_MAX, .tv_nsec = 999999999L}` if the * result too large and `{.tv_sec = TIME_MIN, .tv_nsec = 0L}` * if the result too small + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_sumtimespec(struct timespec *, const struct timespec *, const struct timespec *); @@ -31,6 +33,8 @@ int libsimple_sumtimespec(struct timespec *, const struct timespec *, const stru * will be `{.tv_sec = TIME_MAX, .tv_nsec = 999999999L}` if the * result too large and `{.tv_sec = TIME_MIN, .tv_nsec = 0L}` * if the result too small + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_difftimespec(struct timespec *, const struct timespec *, const struct timespec *); @@ -50,6 +54,8 @@ int libsimple_difftimespec(struct timespec *, const struct timespec *, const str * will be `{.tv_sec = TIME_MAX, .tv_nsec = 999999999L}` if the * result too large and `{.tv_sec = TIME_MIN, .tv_nsec = 0L}` * if the result too small + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_multimespec(struct timespec *, const struct timespec *, int); @@ -64,6 +70,8 @@ int libsimple_multimespec(struct timespec *, const struct timespec *, int); * @param a One of the `struct timespec`s * @param b The other `struct timespec` * @return -1 if `a` < `b`, 0 if `a` = `b`, and +1 if `a` > `b` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __warn_unused_result__))) static inline int @@ -89,6 +97,8 @@ libsimple_cmptimespec(const struct timespec *__a, const struct timespec *__b) * will be `{.tv_sec = TIME_MAX, .tv_usec = 999999L}` if the * result too large and `{.tv_sec = TIME_MIN, .tv_usec = 0L}` * if the result too small + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_sumtimeval(struct timeval *, const struct timeval *, const struct timeval *); @@ -108,6 +118,8 @@ int libsimple_sumtimeval(struct timeval *, const struct timeval *, const struct * will be `{.tv_sec = TIME_MAX, .tv_usec = 999999L}` if the * result too large and `{.tv_sec = TIME_MIN, .tv_usec = 0L}` * if the result too small + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_difftimeval(struct timeval *, const struct timeval *, const struct timeval *); @@ -127,6 +139,8 @@ int libsimple_difftimeval(struct timeval *, const struct timeval *, const struct * will be `{.tv_sec = TIME_MAX, .tv_usec = 999999L}` if the * result too large and `{.tv_sec = TIME_MIN, .tv_usec = 0L}` * if the result too small + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_multimeval(struct timeval *, const struct timeval *, int); @@ -141,6 +155,8 @@ int libsimple_multimeval(struct timeval *, const struct timeval *, int); * @param a One of the `struct timeval`s * @param b The other `struct timeval` * @return -1 if `a` < `b`, 0 if `a` = `b`, and +1 if `a` > `b` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__, __warn_unused_result__))) static inline int @@ -160,6 +176,8 @@ libsimple_cmptimeval(const struct timeval *__a, const struct timeval *__b) * * @param ts Output parameter for the result * @param tv The value to convert + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline void @@ -182,6 +200,8 @@ libsimple_timeval2timespec(struct timespec *restrict __ts, const struct timeval * @return 0 on success, -1 on error * @throws EOVERFLOW The value is too large to be convert, the value will be * truncated to `{.tv_sec = TIME_MAX, .tv_usec = 999999L}` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) int libsimple_timespec2timeval(struct timeval *restrict, const struct timespec *restrict); @@ -207,6 +227,8 @@ int libsimple_timespec2timeval(struct timeval *restrict, const struct timespec * * will be `{.tv_sec = TIME_MAX, .tv_nsec = 999999999L}` if the * result too large and `{.tv_sec = TIME_MIN, .tv_nsec = 0L}` * if the result too small (`*end` is set) + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1, 2)))) int libsimple_strtotimespec(struct timespec *restrict, const char *restrict, char **restrict); @@ -232,6 +254,8 @@ int libsimple_strtotimespec(struct timespec *restrict, const char *restrict, cha * will be `{.tv_sec = TIME_MAX, .tv_usec = 999999L}` if the * result too large and `{.tv_sec = TIME_MIN, .tv_usec = 0L}` * if the result too small (`*end` is set) + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1, 2)))) int libsimple_strtotimeval(struct timeval *restrict, const char *restrict, char **restrict); @@ -251,6 +275,8 @@ int libsimple_strtotimeval(struct timeval *restrict, const char *restrict, char * `NULL` on failure * @throws ENOMEM Output buffer could not be allocated (only if `buf == NULL`) * @throws EINVAL `ts->tv_nsec` is negative or greater than 999999999 + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) char *libsimple_timespectostr(char *restrict, const struct timespec *restrict); @@ -270,6 +296,8 @@ char *libsimple_timespectostr(char *restrict, const struct timespec *restrict); * `NULL` on failure * @throws ENOMEM Output buffer could not be allocated (only if `buf == NULL`) * @throws EINVAL `ts->tv_usec` is negative or greater than 999999 + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) char *libsimple_timevaltostr(char *restrict, const struct timeval *restrict); @@ -283,6 +311,8 @@ char *libsimple_timevaltostr(char *restrict, const struct timeval *restrict); * * @param ts The value to convert * @return The result + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline double @@ -303,6 +333,8 @@ libsimple_timespectodouble(const struct timespec *__ts) * * @param tv The value to convert * @return The result + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) static inline double @@ -325,6 +357,8 @@ libsimple_timevaltodouble(const struct timeval *__tv) * * @param ts Output parameter for the result * @param d The value to convert + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) void libsimple_doubletotimespec(struct timespec *, double); @@ -340,6 +374,8 @@ void libsimple_doubletotimespec(struct timespec *, double); * * @param tv Output parameter for the result * @param d The value to convert + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__))) void libsimple_doubletotimeval(struct timeval *, double); @@ -355,6 +391,8 @@ void libsimple_doubletotimeval(struct timeval *, double); * * @param s The string to minimise * @return `s` + * + * @since 1.0 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__returns_nonnull__, __nonnull__))) char *libsimple_minimise_number_string(char *); diff --git a/libsimple/valloc.h b/libsimple/valloc.h index c0fcd03..07e9b95 100644 --- a/libsimple/valloc.h +++ b/libsimple/valloc.h @@ -16,6 +16,8 @@ * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void *libsimple_vvallocn(size_t __n, va_list __ap) @@ -34,6 +36,8 @@ static inline void *libsimple_vvallocn(size_t __n, va_list __ap) * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(1), __warn_unused_result__))) static inline void *libsimple_valloc(size_t __n) @@ -58,6 +62,8 @@ static inline void *libsimple_valloc(size_t __n) * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -86,6 +92,8 @@ libsimple_vallocn(size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_envalloc(int __status, size_t __n) @@ -113,6 +121,8 @@ static inline void *libsimple_envalloc(int __status, size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_envvallocn(int __status, size_t __n, va_list __ap) @@ -140,6 +150,8 @@ static inline void *libsimple_envvallocn(int __status, size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -167,6 +179,8 @@ libsimple_envallocn(int __status, size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(1), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evalloc(size_t __n) @@ -193,6 +207,8 @@ static inline void *libsimple_evalloc(size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evvallocn(size_t __n, va_list __ap) @@ -219,6 +235,8 @@ static inline void *libsimple_evvallocn(size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * diff --git a/libsimple/vallocz.h b/libsimple/vallocz.h index 3d8b4ec..f651584 100644 --- a/libsimple/vallocz.h +++ b/libsimple/vallocz.h @@ -17,6 +17,8 @@ * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -42,6 +44,8 @@ libsimple_vvalloczn(int __clear, size_t __n, va_list __ap) * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2), __warn_unused_result__))) static inline void * @@ -73,6 +77,8 @@ libsimple_vallocz(int __clear, size_t __n) * and with page size alignment; `NULL` on failure * @throws EINVAL `n` is 0 * @throws ENOMEM Could not allocated enough memory + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) static inline void * @@ -102,6 +108,8 @@ libsimple_valloczn(int __clear, size_t __n, ... /*, (size_t)0 */) * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -137,6 +145,8 @@ libsimple_envallocz(int __status, int __clear, size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -173,6 +183,8 @@ libsimple_envvalloczn(int __status, int __clear, size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * @@ -201,6 +213,8 @@ libsimple_envalloczn(int __status, int __clear, size_t __n, ... /*, (size_t)0 */ * this function is unspecified for the value 0 * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evallocz(int __clear, size_t __n) @@ -228,6 +242,8 @@ static inline void *libsimple_evallocz(int __clear, size_t __n) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_evvalloczn(int __clear, size_t __n, va_list __ap) @@ -255,6 +271,8 @@ static inline void *libsimple_evvalloczn(int __clear, size_t __n, va_list __ap) * list must end with 0 (which is not factor) * @return A unique pointer with at least the specified size * and with page size alignment + * + * @since 1.1 */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__, __returns_nonnull__))) static inline void * |