diff options
author | Mattias Andrée <maandree@kth.se> | 2024-08-18 09:43:16 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-08-18 09:43:16 +0200 |
commit | 715b59e5002b971a987c3c8a2e1b3e61d80388f7 (patch) | |
tree | aa64aa9fed94388056432f0f4a2180d5c03523fd | |
parent | Add @since for definitions added in version 1.0 and 1.1 (diff) | |
parent | Fix tests and libsimple_arraycpy and libsimple_arraymove (diff) | |
download | libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.gz libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.bz2 libsimple-715b59e5002b971a987c3c8a2e1b3e61d80388f7.tar.xz |
Merge tag '1.2' into since
Version 1.2
359 files changed, 10621 insertions, 853 deletions
@@ -7,6 +7,12 @@ SUBHDR =\ libsimple/aligned_alloc.h\ libsimple/aligned_allocz.h\ libsimple/aligned_memdup.h\ + libsimple/aligned_realloc.h\ + libsimple/aligned_strdup.h\ + libsimple/aligned_strndup.h\ + libsimple/aligned_wcsdup.h\ + libsimple/aligned_wcsndup.h\ + libsimple/aligned_wmemdup.h\ libsimple/array.h\ libsimple/calloc.h\ libsimple/definitions.h\ @@ -32,7 +38,10 @@ SUBHDR =\ libsimple/strndup.h\ libsimple/time.h\ libsimple/valloc.h\ - libsimple/vallocz.h + libsimple/vallocz.h\ + libsimple/wcsdup.h\ + libsimple/wcsndup.h\ + libsimple/wmemdup.h HDR =\ $(SUBHDR)\ @@ -40,6 +49,9 @@ HDR =\ OBJ =\ aligned_memdup.o\ + aligned_strndup.o\ + aligned_wcsndup.o\ + aligned_wmemdup.o\ allocn.o\ asprintf.o\ difftimespec.o\ @@ -48,19 +60,35 @@ OBJ =\ doubletotimeval.o\ enaligned_allocz.o\ enaligned_memdup.o\ + enaligned_realloc.o\ + enaligned_reallocarray.o\ + enaligned_strdup.o\ + enaligned_strndup.o\ + enaligned_wcsdup.o\ + enaligned_wcsndup.o\ + enaligned_wmemdup.o\ encalloc.o\ + engmtime.o\ + enlocaltime.o\ enmalloc.o\ enmemdup.o\ enposix_memalignz.o\ enrealloc.o\ + enreallocarray.o\ enstrdup.o\ enstrndup.o\ envaligned_alloczn.o\ + envaligned_reallocn.o\ envmalloczn.o\ envmemalloc.o\ envposix_memalignzn.o\ envputenvf.o\ envreallocn.o\ + enwcsdup.o\ + enwcsndup.o\ + enwmemdup.o\ + gmtime.o\ + localtime.o\ memcasechr.o\ memcasechr_inv.o\ memcasecmp.o\ @@ -175,6 +203,8 @@ OBJ =\ vmemalloc.o\ vputenvf.o\ vweprintf.o\ + wcsndup.o\ + wmemdup.o\ libsimple.o MAN0 =\ @@ -192,7 +222,9 @@ all: libsimple.a $(TESTS) $(OBJ): $(@:.o=.c) $(HDR) $(TESTS): $(@:=.o) test.o libsimple.a $(TESTS:=.o): $(@:.test.o=.c) $(HDR) test.h + test.o: test.c $(HDR) test.h + $(CC) -c -o $@ test.c $(CFLAGS) -DTEST -O0 -ffreestanding libsimple.a: $(OBJ) $(AR) rc $@ $? @@ -21,10 +21,10 @@ and <strings.h>, the naming scheme of these functions is: = wcsn for wide-character strings that may not be NUL-terminated = wmem for wide-character arrays - <str> = str if <base> is str, wsc, strn, or wscn + <str> = str if <base> is str, wcs, strn, or wcsn = mem if <base> is mem or wmem - <scan> = chrnul if <base> is str, wsc, strn, or wscn + <scan> = chrnul if <base> is str, wcs, strn, or wcsn = scan if <base> is mem or wmem [case] = if case-sensitive diff --git a/aligned_enmemdup.c b/aligned_enmemdup.c deleted file mode 100644 index fced863..0000000 --- a/aligned_enmemdup.c +++ /dev/null @@ -1,64 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include "libsimple.h" -#ifndef TEST - - -void * -libsimple_enaligned_memdup(int status, const void *s, size_t alignment, size_t n) -{ - void *ret = aligned_memdup(s, aligned, n); - if (!ret) - enprintf(status, "aligned_memdup:"); - return ret; -} - - -#else -#include "test.h" - -int -main(void) -{ - struct allocinfo *info; - void *s; - - assert((s = libsimple_enaligned_memdup(1, "hello", 3, 5))); - if (have_custom_malloc()) { - assert((info = get_allocinfo(s))); - assert(info->size == 6); - assert(info->alignment == 3); - assert(!info->zeroed); - } - assert(!memcmp(s, "hello", 5)); - free(s); - - assert((s = libsimple_ealigned_memdup("test", 7, 5))); - if (have_custom_malloc()) { - assert((info = get_allocinfo(s))); - assert(info->size == 14); - assert(info->alignment == 7); - assert(!info->zeroed); - } - assert(!memcmp(s, "test", 5)); - free(s); - - if (have_custom_malloc()) { - alloc_fail_in = 1; - assert_exit_ptr(libsimple_enaligned_memdup(44, "hello", 3, 2)); - assert(exit_status == 44); - assert_stderr("%s: memdup: %s\n", argv0, strerror(ENOMEM)); - assert(!alloc_fail_in); - - libsimple_default_failure_exit = 55; - alloc_fail_in = 1; - assert_exit_ptr(libsimple_ealigned_memdup("test", 7, 2)); - assert(exit_status == 55); - assert_stderr("%s: memdup: %s\n", argv0, strerror(ENOMEM)); - assert(!alloc_fail_in); - libsimple_default_failure_exit = 1; - } - - return 0; -} - -#endif diff --git a/aligned_memdup.c b/aligned_memdup.c index d66a846..7b2ca71 100644 --- a/aligned_memdup.c +++ b/aligned_memdup.c @@ -6,9 +6,9 @@ void * libsimple_aligned_memdup(const void *s, size_t alignment, size_t n) { + size_t size = n + (alignment - n % alignment) % alignment; void *ret; - n = n ? n : 1; - ret = aligned_alloc(alignment, n + (alignment - n % alignment) % alignment); + ret = aligned_alloc(alignment, size ? size : alignment); if (!ret) return NULL; return memcpy(ret, s, n); @@ -17,6 +17,7 @@ libsimple_aligned_memdup(const void *s, size_t alignment, size_t n) #else #include "test.h" +#undef memset int main(void) @@ -26,7 +27,7 @@ main(void) void *p = libsimple_aligned_memdup(s, 4, 5); assert(p); assert(p != s); - assert(!((uintptr_t)s % 4)); + assert(!((uintptr_t)p % 4)); if (have_custom_malloc()) { assert((info = get_allocinfo(p))); assert(info->size == 8); diff --git a/aligned_strndup.c b/aligned_strndup.c new file mode 100644 index 0000000..f41fa8c --- /dev/null +++ b/aligned_strndup.c @@ -0,0 +1,108 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +char * +libsimple_aligned_strndup(const char *s, size_t alignment, size_t n) +{ + char *ret; + n = strnlen(s, n); + ret = aligned_alloc(alignment, (n + 1) + (alignment - (n + 1) % alignment) % alignment); + if (!ret) + return NULL; + memcpy(ret, s, n); + ret[n] = '\0'; + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + void *s; + + assert((s = libsimple_aligned_strndup("hello", 2, SIZE_MAX))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_aligned_strndup("hello", 2, 100))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_aligned_strndup("hello", 4, 6))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 4); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_aligned_strndup("hello", 8, 6))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_aligned_strndup("hello", 16, 6))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 16); + assert(info->alignment == 16); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_aligned_strndup("hello", 2, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_aligned_strndup("hello", 2, 4))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hell", 5)); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert(!libsimple_aligned_strndup("hello", 2, 10) && errno == ENOMEM); + assert(!alloc_fail_in); + } + + return 0; +} + +#endif diff --git a/aligned_wcsndup.c b/aligned_wcsndup.c new file mode 100644 index 0000000..90ce7f7 --- /dev/null +++ b/aligned_wcsndup.c @@ -0,0 +1,32 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_aligned_wcsndup(const wchar_t *s, size_t alignment, size_t n) +{ + size_t size; + wchar_t *ret; + n = wcsnlen(s, n); + size = (n + 1) * sizeof(wchar_t); + size = size + (alignment - size % alignment) % alignment; + ret = aligned_alloc(alignment, size); + if (!ret) + return NULL; + wmemcpy(ret, s, n); + ret[n] = 0; + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + return 0; +} + +#endif diff --git a/aligned_wmemdup.c b/aligned_wmemdup.c new file mode 100644 index 0000000..c92e17f --- /dev/null +++ b/aligned_wmemdup.c @@ -0,0 +1,32 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_aligned_wmemdup(const wchar_t *s, size_t alignment, size_t n) +{ + size_t size; + void *ret; + if (LIBSIMPLE_UMUL_OVERFLOW_NONZERO(n, sizeof(wchar_t), &size, SIZE_MAX)) { + errno = ENOMEM; + return NULL; + } + size = size + (alignment - size % alignment) % alignment; + ret = aligned_alloc(alignment, size ? size : alignment); + if (!ret) + return NULL; + return wmemcpy(ret, s, n); +} + + +#else +#include "test.h" + +int +main(void) +{ + return 0; +} + +#endif @@ -15,11 +15,10 @@ alloc_size_product(int *errp, size_t n, va_list ap) n = va_arg(ap, size_t); if (!n) break; - if (n >= SIZE_MAX / prod) { + if (LIBSIMPLE_UMUL_OVERFLOW_NONZERO(n, prod, &prod, SIZE_MAX)) { *errp = ENOMEM; return 0; } - prod *= n; } return prod; } @@ -62,6 +61,15 @@ libsimple_vposix_memalignzn(void **memptr, int clear, size_t alignment, size_t n return ret; } +#ifdef LIBSIMPLE_HAVE_ALIGNED_REALLOC +void * +libsimple_valigned_reallocn(void *ptr, size_t alignment, size_t n, va_list ap) /* TODO test (aligned_reallocn) */ +{ + n = alloc_size_product(&errno, n, ap); + return !n ? NULL : aligned_realloc(ptr, alignment, n); +} +#endif + #else #include "test.h" diff --git a/enaligned_realloc.c b/enaligned_realloc.c new file mode 100644 index 0000000..6d5ac4e --- /dev/null +++ b/enaligned_realloc.c @@ -0,0 +1,105 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +void * +libsimple_enaligned_realloc(int status, void *ptr, size_t alignment, size_t n) +{ + void *ret = aligned_realloc(ptr, alignment, n); + if (!ret) + enprintf(status, "aligned_realloc:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ +#ifdef LIBSIMPLE_HAVE_ALIGNED_REALLOC + + struct allocinfo *info; + void *ptr, *old; + DEFINE_CACHELINE; + + assert((ptr = libsimple_enaligned_realloc(1, NULL, 16, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 5 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 16); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_enaligned_realloc(1, old = ptr, 32, 10))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 10 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 32); + assert(ptr != old); + free(old); + } + free(ptr); + + assert((ptr = libsimple_ealigned_realloc(NULL, 8, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 5 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 8); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_ealigned_realloc(old = ptr, 64, 10))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 10 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 64); + assert(ptr != old); + free(old); + } + free(ptr); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enaligned_realloc(2, NULL, 8, 1)); + assert(exit_status == 2); + assert_stderr("%s: aligned_realloc: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 104; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_realloc(NULL, 16, 1)); + assert(exit_status == 104); + assert_stderr("%s: aligned_realloc: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + } + +#else + + assert_exit_ptr(libsimple_enaligned_realloc(2, NULL, 8, 1)); + assert(exit_status == 2); + assert_stderr("%s: aligned_realloc: %s\n", argv0, strerror(ENOSYS)); + + libsimple_default_failure_exit = 104; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_realloc(NULL, 16, 1)); + assert(exit_status == 104); + assert_stderr("%s: aligned_realloc: %s\n", argv0, strerror(ENOSYS)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + +#endif + + return 0; +} + +#endif diff --git a/enaligned_reallocarray.c b/enaligned_reallocarray.c new file mode 100644 index 0000000..5a71207 --- /dev/null +++ b/enaligned_reallocarray.c @@ -0,0 +1,105 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +void * +libsimple_enaligned_reallocarray(int status, void *ptr, size_t alignment, size_t n, size_t m) +{ + void *ret = aligned_reallocarray(ptr, alignment, n, m); + if (!ret) + enprintf(status, "aligned_reallocarray:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ +#ifdef LIBSIMPLE_HAVE_ALIGNED_REALLOC + + struct allocinfo *info; + void *ptr, *old; + DEFINE_CACHELINE; + + assert((ptr = libsimple_enaligned_reallocarray(1, NULL, 16, 5, 2))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 10 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 16); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_enaligned_reallocarray(1, old = ptr, 32, 10, 3))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 30 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 32); + assert(ptr != old); + free(old); + } + free(ptr); + + assert((ptr = libsimple_ealigned_reallocarray(NULL, 8, 5, 3))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 15 || info->size == 16); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 8); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_ealigned_reallocarray(old = ptr, 64, 10, 4))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 40 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 64); + assert(ptr != old); + free(old); + } + free(ptr); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enaligned_reallocarray(2, NULL, 8, 1, 2)); + assert(exit_status == 2); + assert_stderr("%s: aligned_reallocarray: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 104; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_reallocarray(NULL, 16, 1, 2)); + assert(exit_status == 104); + assert_stderr("%s: aligned_reallocarray: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + } + +#else + + assert_exit_ptr(libsimple_enaligned_reallocarray(2, NULL, 8, 1, 2)); + assert(exit_status == 2); + assert_stderr("%s: aligned_reallocarray: %s\n", argv0, strerror(ENOSYS)); + + libsimple_default_failure_exit = 104; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_reallocarray(NULL, 16, 1, 2)); + assert(exit_status == 104); + assert_stderr("%s: aligned_reallocarray: %s\n", argv0, strerror(ENOSYS)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + +#endif + + return 0; +} + +#endif diff --git a/enaligned_strdup.c b/enaligned_strdup.c new file mode 100644 index 0000000..533ff56 --- /dev/null +++ b/enaligned_strdup.c @@ -0,0 +1,78 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +char * +libsimple_enaligned_strdup(int status, const char *s, size_t alignment) +{ + void *ret = aligned_strdup(s, alignment); + if (!ret) + enprintf(status, "aligned_strdup:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + void *s; + + assert((s = libsimple_enaligned_strdup(1, "hello", 2))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_ealigned_strdup("test", 8))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!memcmp(s, "test", 5)); + free(s); + + assert((s = libsimple_aligned_strdup("test", 4))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 4); + assert(!info->zeroed); + } + assert(!memcmp(s, "test", 5)); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enaligned_strdup(44, "hello", 2)); + assert(exit_status == 44); + assert_stderr("%s: aligned_strdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 55; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_strdup("test", 8)); + assert(exit_status == 55); + assert_stderr("%s: aligned_strdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + + alloc_fail_in = 1; + assert(!libsimple_aligned_strdup("test", 16) && errno == ENOMEM); + assert(!alloc_fail_in); + } + + return 0; +} + +#endif diff --git a/enaligned_strndup.c b/enaligned_strndup.c new file mode 100644 index 0000000..6812d1c --- /dev/null +++ b/enaligned_strndup.c @@ -0,0 +1,134 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +char * +libsimple_enaligned_strndup(int status, const char *s, size_t alignment, size_t n) +{ + void *ret = aligned_strndup(s, alignment, n); + if (!ret) + enprintf(status, "aligned_strndup:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + void *s; + + assert((s = libsimple_enaligned_strndup(1, "hello", 2, SIZE_MAX))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_ealigned_strndup("test", 8, SIZE_MAX))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!memcmp(s, "test", 5)); + free(s); + + assert((s = libsimple_enaligned_strndup(1, "hello", 2, 100))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_ealigned_strndup("test", 8, 100))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!memcmp(s, "test", 5)); + free(s); + + assert((s = libsimple_enaligned_strndup(1, "hello", 2, 6))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_ealigned_strndup("test", 8, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!memcmp(s, "test", 5)); + free(s); + + assert((s = libsimple_enaligned_strndup(1, "hello", 2, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hello", 6)); + free(s); + + assert((s = libsimple_ealigned_strndup("test", 8, 4))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!memcmp(s, "test", 5)); + free(s); + + assert((s = libsimple_enaligned_strndup(1, "hello", 2, 4))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!memcmp(s, "hell", 5)); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enaligned_strndup(44, "hello", 2, 10)); + assert(exit_status == 44); + assert_stderr("%s: aligned_strndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 55; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_strndup("test", 8, 10)); + assert(exit_status == 55); + assert_stderr("%s: aligned_strndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + } + + return 0; +} + +#endif diff --git a/enaligned_wcsdup.c b/enaligned_wcsdup.c new file mode 100644 index 0000000..10d9669 --- /dev/null +++ b/enaligned_wcsdup.c @@ -0,0 +1,78 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_enaligned_wcsdup(int status, const wchar_t *s, size_t alignment) +{ + void *ret = aligned_wcsdup(s, alignment); + if (!ret) + enprintf(status, "aligned_wcsdup:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + void *s; + + assert((s = libsimple_enaligned_wcsdup(1, L"hello", 2))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6 * sizeof(wchar_t)); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"hello", 6)); + free(s); + + assert((s = libsimple_ealigned_wcsdup(L"test", 8))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t) + (8 - 5 * sizeof(wchar_t) % 8) % 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"test", 5)); + free(s); + + assert((s = libsimple_aligned_wcsdup(L"test", 4))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t) + (4 - 5 * sizeof(wchar_t) % 4) % 4); + assert(info->alignment == 4); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"test", 5)); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enaligned_wcsdup(44, L"hello", 2)); + assert(exit_status == 44); + assert_stderr("%s: aligned_wcsdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 55; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_wcsdup(L"test", 8)); + assert(exit_status == 55); + assert_stderr("%s: aligned_wcsdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + + alloc_fail_in = 1; + assert(!libsimple_aligned_wcsdup(L"test", 16) && errno == ENOMEM); + assert(!alloc_fail_in); + } + + return 0; +} + +#endif diff --git a/enaligned_wcsndup.c b/enaligned_wcsndup.c new file mode 100644 index 0000000..32cce57 --- /dev/null +++ b/enaligned_wcsndup.c @@ -0,0 +1,134 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_enaligned_wcsndup(int status, const wchar_t *s, size_t alignment, size_t n) +{ + void *ret = aligned_wcsndup(s, alignment, n); + if (!ret) + enprintf(status, "aligned_wcsndup:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + void *s; + + assert((s = libsimple_enaligned_wcsndup(1, L"hello", 2, SIZE_MAX))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6 * sizeof(wchar_t)); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"hello", 6)); + free(s); + + assert((s = libsimple_ealigned_wcsndup(L"test", 8, SIZE_MAX))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t) + (8 - 5 * sizeof(wchar_t) % 8) % 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"test", 5)); + free(s); + + assert((s = libsimple_enaligned_wcsndup(1, L"hello", 2, 100))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6 * sizeof(wchar_t)); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"hello", 6)); + free(s); + + assert((s = libsimple_ealigned_wcsndup(L"test", 8, 100))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t) + (8 - 5 * sizeof(wchar_t) % 8) % 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"test", 5)); + free(s); + + assert((s = libsimple_enaligned_wcsndup(1, L"hello", 2, 6))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6 * sizeof(wchar_t)); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"hello", 6)); + free(s); + + assert((s = libsimple_ealigned_wcsndup(L"test", 8, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t) + (8 - 5 * sizeof(wchar_t) % 8) % 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"test", 5)); + free(s); + + assert((s = libsimple_enaligned_wcsndup(1, L"hello", 2, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6 * sizeof(wchar_t)); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"hello", 6)); + free(s); + + assert((s = libsimple_ealigned_wcsndup(L"test", 8, 4))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t) + (8 - 5 * sizeof(wchar_t) % 8) % 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"test", 5)); + free(s); + + assert((s = libsimple_enaligned_wcsndup(1, L"hello", 2, 4))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"hell", 5)); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enaligned_wcsndup(44, L"hello", 2, 10)); + assert(exit_status == 44); + assert_stderr("%s: aligned_wcsndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 55; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_wcsndup(L"test", 8, 10)); + assert(exit_status == 55); + assert_stderr("%s: aligned_wcsndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + } + + return 0; +} + +#endif diff --git a/enaligned_wmemdup.c b/enaligned_wmemdup.c new file mode 100644 index 0000000..ad36238 --- /dev/null +++ b/enaligned_wmemdup.c @@ -0,0 +1,64 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_enaligned_wmemdup(int status, const wchar_t *s, size_t alignment, size_t n) +{ + void *ret = aligned_wmemdup(s, alignment, n); + if (!ret) + enprintf(status, "aligned_wmemdup:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + void *s; + + assert((s = libsimple_enaligned_wmemdup(1, L"hello", 2, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == 2); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"hello", 5)); + free(s); + + assert((s = libsimple_ealigned_wmemdup(L"test", 8, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t) + (8 - 5 * sizeof(wchar_t) % 8) % 8); + assert(info->alignment == 8); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"test", 5)); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enaligned_wmemdup(44, L"hello", 2, 2)); + assert(exit_status == 44); + assert_stderr("%s: aligned_wmemdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 55; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ealigned_wmemdup(L"test", 8, 2)); + assert(exit_status == 55); + assert_stderr("%s: aligned_wmemdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + } + + return 0; +} + +#endif diff --git a/engmtime.c b/engmtime.c new file mode 100644 index 0000000..55e6c9c --- /dev/null +++ b/engmtime.c @@ -0,0 +1,24 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +void +libsimple_engmtime(int status, struct tm *tm, struct timespec *ts) +{ + if (libsimple_gmtime(tm, ts)) + enprintf(status, "libsimple_gmtime:"); +} + + +#else +#include "test.h" + +int +main(void) +{ + /* TODO test */ + return 0; +} + +#endif diff --git a/enlocaltime.c b/enlocaltime.c new file mode 100644 index 0000000..af8907e --- /dev/null +++ b/enlocaltime.c @@ -0,0 +1,24 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +void +libsimple_enlocaltime(int status, struct tm *tm, struct timespec *ts) +{ + if (libsimple_localtime(tm, ts)) + enprintf(status, "libsimple_localtime:"); +} + + +#else +#include "test.h" + +int +main(void) +{ + /* TODO test */ + return 0; +} + +#endif diff --git a/enrealloc.c b/enrealloc.c index 878674c..b27cb18 100644 --- a/enrealloc.c +++ b/enrealloc.c @@ -6,7 +6,7 @@ void * libsimple_enrealloc(int status, void *ptr, size_t n) { - char *ret = realloc(ptr, n); + void *ret = realloc(ptr, n); if (!ret) enprintf(status, "realloc:"); return ret; diff --git a/enreallocarray.c b/enreallocarray.c new file mode 100644 index 0000000..c208626 --- /dev/null +++ b/enreallocarray.c @@ -0,0 +1,132 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +void * +libsimple_enreallocarray(int status, void *ptr, size_t n, size_t m) +{ + void *ret = reallocarray(ptr, n, m); + if (!ret) + enprintf(status, "reallocarray:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + void *ptr, *old; + + assert((ptr = libsimple_enreallocarray(1, NULL, 5, 3))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 15); + assert(!info->zeroed); + assert(!((uintptr_t)ptr % (uintptr_t)(info->alignment))); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_enreallocarray(1, old = ptr, 10, 2))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 20); + assert(!info->zeroed); + assert(!((uintptr_t)ptr % (uintptr_t)(info->alignment))); + assert(ptr != old); + free(old); + } + free(ptr); + + assert((ptr = libsimple_ereallocarray(NULL, 1, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 5); + assert(!info->zeroed); + assert(!((uintptr_t)ptr % (uintptr_t)(info->alignment))); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_ereallocarray(old = ptr, 10, 10))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 100); + assert(!info->zeroed); + assert(!((uintptr_t)ptr % (uintptr_t)(info->alignment))); + assert(ptr != old); + free(old); + } + free(ptr); + + assert((ptr = libsimple_reallocarray(NULL, 1, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 5); + assert(!info->zeroed); + assert(!((uintptr_t)ptr % (uintptr_t)(info->alignment))); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_reallocarray(old = ptr, 10, 10))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 100); + assert(!info->zeroed); + assert(!((uintptr_t)ptr % (uintptr_t)(info->alignment))); + assert(ptr != old); + free(old); + } + free(ptr); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enreallocarray(2, NULL, 1, 1)); + assert(exit_status == 2); + assert_stderr("%s: reallocarray: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 104; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ereallocarray(NULL, 1, 1)); + assert(exit_status == 104); + assert_stderr("%s: reallocarray: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + + alloc_fail_in = 1; + assert(!libsimple_reallocarray(NULL, 1, 1) && errno == ENOMEM); + assert(!alloc_fail_in); + } + +#if defined(__GNUC__) && !defined(__clang) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Walloc-size-larger-than=" +#endif + + assert_exit_ptr(libsimple_enreallocarray(3, NULL, SIZE_MAX, SIZE_MAX)); + assert(exit_status == 3); + assert_stderr("%s: reallocarray: %s\n", argv0, strerror(ENOMEM)); + + libsimple_default_failure_exit = 4; + assert_exit_ptr(libsimple_ereallocarray(NULL, SIZE_MAX, SIZE_MAX)); + assert(exit_status == 4); + assert_stderr("%s: reallocarray: %s\n", argv0, strerror(ENOMEM)); + libsimple_default_failure_exit = 1; + + assert(!libsimple_reallocarray(NULL, SIZE_MAX, SIZE_MAX) && errno == ENOMEM); + +#if defined(__GNUC__) && !defined(__clang) +# pragma GCC diagnostic pop +#endif + + return 0; +} + +#endif diff --git a/envaligned_reallocn.c b/envaligned_reallocn.c new file mode 100644 index 0000000..747e8c8 --- /dev/null +++ b/envaligned_reallocn.c @@ -0,0 +1,25 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +void * +libsimple_envaligned_reallocn(int status, void *ptr, size_t alignment, size_t n, va_list ap) /* TODO test (evaligned_reallocn, aligned_reallocn, enaligned_reallocn, ealigned_reallocn) */ +{ + void *ret = valigned_reallocn(ptr, alignment, n, ap); + if (!ret) + enprintf(status, "valigned_reallocn:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + return 0; +} + +#endif diff --git a/enwcsdup.c b/enwcsdup.c new file mode 100644 index 0000000..1fa27c0 --- /dev/null +++ b/enwcsdup.c @@ -0,0 +1,71 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_enwcsdup(int status, const wchar_t *s) +{ + size_t n = wcslen(s) + 1, size; + wchar_t *ret; + if (LIBSIMPLE_UMUL_OVERFLOW_NONZERO(n, sizeof(wchar_t), &size, SIZE_MAX)) { + errno = ENOMEM; + enprintf(status, "wcsdup:"); + } + ret = aligned_alloc(_Alignof(wchar_t), size); + if (!ret) + enprintf(status, "wcsdup:"); + wmemcpy(ret, s, n); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + wchar_t *s; + + assert((s = libsimple_enwcsdup(1, L"hello"))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + assert(!info->zeroed); + } + assert(!wcscmp(s, L"hello")); + free(s); + + assert((s = libsimple_ewcsdup(L"test"))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + assert(!info->zeroed); + } + assert(!wcscmp(s, L"test")); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enwcsdup(18, L"hello")); + assert(exit_status == 18); + assert_stderr("%s: wcsdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 5; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ewcsdup(L"test")); + assert(exit_status == 5); + assert_stderr("%s: wcsdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + } + + return 0; +} + +#endif diff --git a/enwcsndup.c b/enwcsndup.c new file mode 100644 index 0000000..105542c --- /dev/null +++ b/enwcsndup.c @@ -0,0 +1,132 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_enwcsndup(int status, const wchar_t *s, size_t n) +{ + wchar_t *ret = libsimple_wcsndup(s, n); + if (!ret) + enprintf(status, "wcsndup:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + wchar_t *s; + + assert((s = libsimple_enwcsndup(1, L"hello", 10))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 6 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + assert(!info->zeroed); + } + assert(!wcscmp(s, L"hello")); + free(s); + + assert((s = libsimple_ewcsndup(L"test", 10))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + assert(!info->zeroed); + } + assert(!wcscmp(s, L"test")); + free(s); + + assert((s = libsimple_enwcsndup(1, L"hello", 2))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 3 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + assert(!info->zeroed); + } + assert(!wcscmp(s, L"he")); + free(s); + + assert((s = libsimple_ewcsndup(L"test", 3))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 4 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + assert(!info->zeroed); + } + assert(!wcscmp(s, L"tes")); + free(s); + + assert((s = libsimple_enwcsndup(1, L"hello", 0))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 1 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + assert(!info->zeroed); + } + assert(!wcscmp(s, L"")); + free(s); + + assert((s = libsimple_ewcsndup(L"test", 0))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 1 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + assert(!info->zeroed); + } + assert(!wcscmp(s, L"")); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enwcsndup(24, L"hello", 10)); + assert(exit_status == 24); + assert_stderr("%s: wcsndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 25; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ewcsndup(L"test", 10)); + assert(exit_status == 25); + assert_stderr("%s: wcsndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enwcsndup(26, L"hello", 1)); + assert(exit_status == 26); + assert_stderr("%s: wcsndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 27; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ewcsndup(L"test", 2)); + assert(exit_status == 27); + assert_stderr("%s: wcsndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enwcsndup(28, L"hello", 0)); + assert(exit_status == 28); + assert_stderr("%s: wcsndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 29; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ewcsndup(L"test", 0)); + assert(exit_status == 29); + assert_stderr("%s: wcsndup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + } + + return 0; +} + +#endif diff --git a/enwmemdup.c b/enwmemdup.c new file mode 100644 index 0000000..243c99e --- /dev/null +++ b/enwmemdup.c @@ -0,0 +1,72 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_enwmemdup(int status, const wchar_t *s, size_t n) +{ + wchar_t *ret = libsimple_wmemdup(s, n); + if (!ret) + enprintf(status, "wmemdup:"); + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + wchar_t *s; + + assert((s = libsimple_enwmemdup(1, L"hello", 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"hello", 5)); + free(s); + + assert((s = libsimple_ewmemdup(L"test", 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(s))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(!info->zeroed); + } + assert(!wmemcmp(s, L"test", 5)); + free(s); + + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert_exit_ptr(libsimple_enwmemdup(44, L"hello", 2)); + assert(exit_status == 44); + assert_stderr("%s: wmemdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + + libsimple_default_failure_exit = 55; + alloc_fail_in = 1; + assert_exit_ptr(libsimple_ewmemdup(L"test", 2)); + assert(exit_status == 55); + assert_stderr("%s: wmemdup: %s\n", argv0, strerror(ENOMEM)); + assert(!alloc_fail_in); + libsimple_default_failure_exit = 1; + + assert_exit_ptr(libsimple_enwmemdup(41, NULL, SSIZE_MAX)); + assert(exit_status == 41); + assert_stderr("%s: wmemdup: %s\n", argv0, strerror(ENOMEM)); + + libsimple_default_failure_exit = 51; + assert_exit_ptr(libsimple_ewmemdup(NULL, SSIZE_MAX)); + assert(exit_status == 51); + assert_stderr("%s: wmemdup: %s\n", argv0, strerror(ENOMEM)); + libsimple_default_failure_exit = 1; + } + + return 0; +} + +#endif diff --git a/gmtime.c b/gmtime.c new file mode 100644 index 0000000..5868e8a --- /dev/null +++ b/gmtime.c @@ -0,0 +1,61 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#include <sys/timex.h> +#ifndef TEST + + +int +libsimple_gmtime(struct tm *tm, struct timespec *ts) +{ + struct timex timex; + int r; + + memset(&timex, 0, sizeof(timex)); + timex.status = ADJ_NANO; + r = adjtimex(&timex); + if (r == -1) + return -1; + if (ts) { + ts->tv_sec = timex.time.tv_sec; + ts->tv_nsec = timex.time.tv_usec; + } + + if (timex.time.tv_sec % (24 * 60 * 60) == 0) { + if (r == TIME_INS) { + timex.time.tv_sec -= 1; + if (!gmtime_r(&timex.time.tv_sec, tm)) + return -1; + tm->tm_sec += 1; + return 1; + } else if (r == TIME_DEL) { + timex.time.tv_sec += 1; + if (!gmtime_r(&timex.time.tv_sec, tm)) + return -1; + } else { + if (!gmtime_r(&timex.time.tv_sec, tm)) + return -1; + } + } else if (r == TIME_OOP) { + if (!gmtime_r(&timex.time.tv_sec, tm)) + return -1; + tm->tm_sec += 1; + } else { + if (!gmtime_r(&timex.time.tv_sec, tm)) + return -1; + } + + return 0; +} + + +#else +#include "test.h" + +int +main(void) +{ + /* TODO test */ + return 0; +} + +#endif diff --git a/libsimple-arg.h b/libsimple-arg.h index 25d4c72..3ffc3ed 100644 --- a/libsimple-arg.h +++ b/libsimple-arg.h @@ -432,8 +432,19 @@ struct longopt { #define USAGE(SYNOPSIS)\ NUSAGE(1, SYNOPSIS) + +/* Intended for internal use only */ +#if __STDC_VERSION__ >= 201112L +# define _LIBSIMPLE_NORETURN _Noreturn +#elif defined(__GNUC__) || defined(__clang__) +# define _LIBSIMPLE_NORETURN __attribute__((noreturn)) +#else +# define _LIBSIMPLE_NORETURN +#endif + + /** - * Define the function `static void usage(void)` + * Define the function `static _Noreturn void usage(void)` * that prints the error message * "usage: %s %s\n", argv0, SYNOPSIS * or @@ -448,26 +459,15 @@ struct longopt { * * @since 1.0 */ -#if defined(__GNUC__) || defined(__clang__) -# define NUSAGE(STATUS, SYNOPSIS)\ - __attribute__((noreturn))\ - static void usage(void)\ - {\ - const char *syn = SYNOPSIS ? SYNOPSIS : "";\ - fprintf(stderr, "usage: %s%s%s\n", argv0, *syn ? " " : "", syn);\ - exit(STATUS);\ - }\ - char *argv0 = NULL -#else -# define NUSAGE(STATUS, SYNOPSIS)\ - static void usage(void)\ +#define NUSAGE(STATUS, SYNOPSIS)\ + static _LIBSIMPLE_NORETURN void\ + usage(void)\ {\ const char *syn = SYNOPSIS ? SYNOPSIS : "";\ fprintf(stderr, "usage: %s%s%s\n", argv0, *syn ? " " : "", syn);\ exit(STATUS);\ }\ char *argv0 = NULL -#endif #endif diff --git a/libsimple.c b/libsimple.c index 4ef6ec2..5232833 100644 --- a/libsimple.c +++ b/libsimple.c @@ -6,27 +6,6 @@ #else #include "test.h" -static size_t -gcd(size_t u, size_t v) -{ - size_t t; - int shift = 0; - /* Not needed because u>0, v>0: if (!(u | v)) return u + v; */ - while (!((u | v) & 1)) u >>= 1, v >>= 1, shift++; - while (!(u & 1)) u >>= 1; - do { - while (!(v & 1)) v >>= 1; - if (u > v) t = u, u = v, v = t; - } while (v -= u); - return u << shift; -} - -static size_t -lcm(size_t u, size_t v) -{ - return u / gcd(u, v) * v; -} - static int test_timespec(double d, time_t sec, long int nsec, double rd, const char *s, const char *ss) { @@ -109,22 +88,17 @@ int main(void) { struct allocinfo *volatile info; - void *ptr; + void *ptr, *old; struct timespec ts, ts1, ts2; struct timeval tv1, tv2; const char *cs; + const wchar_t *cws; char buf[1024], *s; + wchar_t *ws; int intarray[10]; size_t i, j, n; - size_t pagesize, cacheline; - - pagesize = (size_t)sysconf(_SC_PAGESIZE); - -#ifdef _SC_LEVEL1_DCACHE_LINESIZE - cacheline = (size_t)sysconf(_SC_LEVEL1_DCACHE_LINESIZE); -#else - cacheline = 64; -#endif + DEFINE_PAGESIZE; + DEFINE_CACHELINE; assert(libsimple_default_failure_exit == 1); @@ -734,6 +708,7 @@ main(void) s = libsimple_memdupa(cs, n); assert(s); assert(s != cs); + assert(!((uintptr_t)s % _Alignof(max_align_t))); assert(!memcmp(s, cs, n)); } #else @@ -743,14 +718,253 @@ main(void) #ifdef libsimple_aligned_memdupa cs = "xyz"; for (n = 1; n < 4; n++) { - s = libsimple_aligned_memdupa(cs, 4 + i, n); + for (i = 1; i < 5; i++) { + s = libsimple_aligned_memdupa(cs, i, n); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!memcmp(s, cs, n)); + } + } +#else + fprintf(stderr, "warning: libsimple_aligned_memdupa missing\n"); +#endif + +#ifdef libsimple_aligned_strdupa + for (i = 1; i < 5; i++) { + cs = ""; + s = libsimple_aligned_strdupa(cs, i); assert(s); assert(s != cs); - assert(!((uintptr_t)s % (4 + i))); - assert(!memcmp(s, cs, n)); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, cs)); + + cs = "xyz"; + s = libsimple_aligned_strdupa(cs, i); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, cs)); } #else - fprintf(stderr, "warning: libsimple_aligned_memdupa missing\n"); + fprintf(stderr, "warning: libsimple_aligned_strdupa missing\n"); +#endif + +#ifdef libsimple_aligned_strndupa + for (i = 1; i < 5; i++) { + cs = ""; + s = libsimple_aligned_strndupa(cs, i, 5); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, "")); + + cs = "xyz"; + + s = libsimple_aligned_strndupa(cs, i, 5); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, "xyz")); + + s = libsimple_aligned_strndupa(cs, i, 4); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, "xyz")); + + s = libsimple_aligned_strndupa(cs, i, 3); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, "xyz")); + + s = libsimple_aligned_strndupa(cs, i, 2); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, "xy")); + + s = libsimple_aligned_strndupa(cs, i, 1); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, "x")); + + s = libsimple_aligned_strndupa(cs, i, 0); + assert(s); + assert(s != cs); + assert(!((uintptr_t)s % i)); + assert(!strcmp(s, "")); + } +#else + fprintf(stderr, "warning: libsimple_aligned_strndupa missing\n"); +#endif + +#ifdef libsimple_wcsdupa + cws = L""; + ws = libsimple_wcsdupa(cws); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, cws)); + + cws = L"xyz"; + ws = libsimple_wcsdupa(cws); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, cws)); +#else + fprintf(stderr, "warning: libsimple_wcsdupa missing\n"); +#endif + +#ifdef libsimple_wcsndupa + cws = L""; + ws = libsimple_wcsndupa(cws, 5); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, L"")); + + cws = L"xyz"; + + ws = libsimple_wcsndupa(cws, 5); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, L"xyz")); + + ws = libsimple_wcsndupa(cws, 4); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, L"xyz")); + + ws = libsimple_wcsndupa(cws, 3); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, L"xyz")); + + ws = libsimple_wcsndupa(cws, 2); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, L"xy")); + + ws = libsimple_wcsndupa(cws, 1); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, L"x")); + + ws = libsimple_wcsndupa(cws, 0); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wcscmp(ws, L"")); +#else + fprintf(stderr, "warning: libsimple_wcsndupa missing\n"); +#endif + +#ifdef libsimple_wmemdupa + cws = L"xyz"; + for (n = 1; n < 4; n++) { + ws = libsimple_wmemdupa(cws, n); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % _Alignof(wchar_t))); + assert(!wmemcmp(ws, cws, n)); + } +#else + fprintf(stderr, "warning: libsimple_wmemdupa missing\n"); +#endif + +#ifdef libsimple_aligned_wmemdupa + cws = L"xyz"; + for (n = 1; n < 4; n++) { + for (i = 1; i < 5; i++) { + ws = libsimple_aligned_wmemdupa(cws, i, n); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wmemcmp(ws, cws, n)); + } + } +#else + fprintf(stderr, "warning: libsimple_aligned_wmemdupa missing\n"); +#endif + +#ifdef libsimple_aligned_wcsdupa + for (i = 1; i < 5; i++) { + cws = L""; + ws = libsimple_aligned_wcsdupa(cws, i); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, cws)); + + cws = L"xyz"; + ws = libsimple_aligned_wcsdupa(cws, i); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, cws)); + } +#else + fprintf(stderr, "warning: libsimple_aligned_wcsdupa missing\n"); +#endif + +#ifdef libsimple_aligned_wcsndupa + for (i = 1; i < 5; i++) { + cws = L""; + ws = libsimple_aligned_wcsndupa(cws, i, 5); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, L"")); + + cws = L"xyz"; + + ws = libsimple_aligned_wcsndupa(cws, i, 5); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, L"xyz")); + + ws = libsimple_aligned_wcsndupa(cws, i, 4); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, L"xyz")); + + ws = libsimple_aligned_wcsndupa(cws, i, 3); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, L"xyz")); + + ws = libsimple_aligned_wcsndupa(cws, i, 2); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, L"xy")); + + ws = libsimple_aligned_wcsndupa(cws, i, 1); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, L"x")); + + ws = libsimple_aligned_wcsndupa(cws, i, 0); + assert(ws); + assert(ws != cws); + assert(!((uintptr_t)ws % i)); + assert(!wcscmp(ws, L"")); + } +#else + fprintf(stderr, "warning: libsimple_aligned_wcsndupa missing\n"); #endif unsetenv("X"); @@ -1049,14 +1263,6 @@ main(void) tv2.tv_sec = 1, tv2.tv_usec = 0L; assert(libsimple_cmptimeval(&tv1, &tv2) == -1); -#define ASSERT_ALIGNMENT(INFO, ALIGN)\ - do {\ - assert((INFO)->alignment <= lcm(cacheline, ALIGN));\ - assert(!((INFO)->alignment % (ALIGN)));\ - if ((cacheline - (ALIGN) % cacheline) % cacheline + (INFO)->size % (ALIGN) > cacheline)\ - assert(!((INFO)->alignment % cacheline));\ - } while (0) - assert((ptr = libsimple_mallocz(0, 11))); if (have_custom_malloc()) { assert((info = get_allocinfo(ptr))); @@ -2042,6 +2248,66 @@ main(void) assert_stderr("%s: libsimple_vmemalignz: %s\n", argv0, strerror(EINVAL)); libsimple_default_failure_exit = 1; +#ifdef LIBSIMPLE_HAVE_ALIGNED_REALLOC + assert((ptr = libsimple_aligned_realloc(NULL, 16, 5))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 5 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 16); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_aligned_realloc(old = ptr, 32, 10))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 10 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 32); + assert(ptr != old); + free(old); + } + free(ptr); + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert(!libsimple_aligned_realloc(NULL, 8, 1) && errno == ENOMEM); + assert(!alloc_fail_in); + } +#else + assert(libsimple_aligned_realloc(NULL, 8, 1) && errno == ENOSYS); +#endif + +#ifdef LIBSIMPLE_HAVE_ALIGNED_REALLOC + assert((ptr = libsimple_aligned_reallocarray(NULL, 16, 5, 3))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 15 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 16); + info->refcount += 1; + } + stpcpy(ptr, "test"); + assert((ptr = libsimple_aligned_reallocarray(old = ptr, 32, 10, 2))); + assert(!strcmp(ptr, "test")); + if (have_custom_malloc()) { + assert((info = get_allocinfo(ptr))); + assert(info->size == 20 || info->size == info->alignment); + assert(!info->zeroed); + ASSERT_ALIGNMENT(info, 32); + assert(ptr != old); + free(old); + } + free(ptr); + if (have_custom_malloc()) { + alloc_fail_in = 1; + assert(!libsimple_aligned_reallocarray(NULL, 8, 1, 1) && errno == ENOMEM); + assert(!alloc_fail_in); + } +#else + assert(libsimple_aligned_reallocarray(NULL, 8, 1, 1) && errno == ENOSYS); +#endif + assert(libsimple_memeq("abcxyz", "abc123", 3)); assert(!libsimple_memeq("abcxyz", "abc123", 4)); assert(libsimple_memeq("abcxyz", "abcx23", 4)); diff --git a/libsimple.h b/libsimple.h index 2c68fba..28d884c 100644 --- a/libsimple.h +++ b/libsimple.h @@ -39,26 +39,78 @@ #include <strings.h> #include <time.h> #include <unistd.h> +#include <wchar.h> +#include <wctype.h> + #if defined(__GNUC__) && !defined(__clang__) # define _LIBSIMPLE_GCC_ONLY(x) x +# define _LIBSIMPLE_NON_GCC_ONLY(x) #else # define _LIBSIMPLE_GCC_ONLY(x) +# define _LIBSIMPLE_NON_GCC_ONLY(x) x +#endif + +#if __STDC_VERSION__ >= 199409L +# define _LIBSIMPLE_C95_ONLY(x) x +# define _LIBSIMPLE_PRE_C95_ONLY(x) +#else +# define _LIBSIMPLE_C95_ONLY(x) +# define _LIBSIMPLE_PRE_C95_ONLY(x) x +#endif + +#if __STDC_VERSION__ >= 199901L +# define _LIBSIMPLE_C99_ONLY(x) x +# define _LIBSIMPLE_PRE_C99_ONLY(x) +#else +# define _LIBSIMPLE_C99_ONLY(x) +# define _LIBSIMPLE_PRE_C99_ONLY(x) x +#endif + +#if __STDC_VERSION__ >= 201112L +# define _LIBSIMPLE_C11_ONLY(x) x +# define _LIBSIMPLE_PRE_C11_ONLY(x) +#else +# define _LIBSIMPLE_C11_ONLY(x) +# define _LIBSIMPLE_PRE_C11_ONLY(x) x #endif +#if __STDC_VERSION__ >= 201710L +# define _LIBSIMPLE_C17_ONLY(x) x +# define _LIBSIMPLE_PRE_C17_ONLY(x) +#else +# define _LIBSIMPLE_C17_ONLY(x) +# define _LIBSIMPLE_PRE_C17_ONLY(x) x +#endif + +#define _libsimple_assume_aligned_as(TYPE)\ + _LIBSIMPLE_C11_ONLY(__assume_aligned__(_Alignof(TYPE)))\ + _LIBSIMPLE_PRE_C11_ONLY(_LIBSIMPLE_GCC_ONLY__assume_aligned__(__alignof(TYPE))) + + +#include "libsimple/overflow.h" #include "libsimple/printf.h" #include "libsimple/definitions.h" #include "libsimple/memalloc.h" -#include "libsimple/strdup.h" -#include "libsimple/strndup.h" #include "libsimple/memdup.h" #include "libsimple/aligned_memdup.h" +#include "libsimple/strdup.h" +#include "libsimple/aligned_strdup.h" +#include "libsimple/strndup.h" +#include "libsimple/aligned_strndup.h" +#include "libsimple/wmemdup.h" +#include "libsimple/aligned_wmemdup.h" +#include "libsimple/wcsdup.h" +#include "libsimple/aligned_wcsdup.h" +#include "libsimple/wcsndup.h" +#include "libsimple/aligned_wcsndup.h" #include "libsimple/mallocz.h" #include "libsimple/malloc.h" #include "libsimple/calloc.h" #include "libsimple/realloc.h" +#include "libsimple/aligned_realloc.h" #include "libsimple/memalignz.h" #include "libsimple/memalign.h" #include "libsimple/vallocz.h" @@ -76,7 +128,6 @@ #include "libsimple/array.h" #include "libsimple/str.h" #include "libsimple/strn.h" -#include "libsimple/overflow.h" /** @@ -145,4 +196,58 @@ libsimple_unlist(void *__list, size_t __i, size_t *__np, size_t __width) #endif +#define _LIBSIMPLE_REMOVE_CONST(X, TYPE, ...) (*(TYPE *)(void *)&(X)) +#define LIBSIMPLE_REMOVE_CONST(...) _LIBSIMPLE_REMOVE_CONST(__VA_ARGS__, void *) /* TODO test, doc, man */ +#ifndef REMOVE_CONST +# define REMOVE_CONST(...) LIBSIMPLE_REMOVE_CONST(__VA_ARGS__) +#endif + + +#define LIBSIMPLE_PREFETCH_RDONLY(ADDRESS, LOCALITY) /* void */ /* TODO test, doc, man */\ + _LIBSIMPLE_GCC_ONLY(__builtin_prefetch(ADDRESS, 0, LOCALITY)) +#ifndef PREFETCH_RDONLY +# define PREFETCH_RDONLY(...) LIBSIMPLE_PREFETCH_RDONLY(__VA_ARGS__) +#endif + + +#define LIBSIMPLE_PREFETCH_RDWR(ADDRESS, LOCALITY) /* void */ /* TODO test, doc, man */\ + _LIBSIMPLE_GCC_ONLY(__builtin_prefetch(ADDRESS, 1, LOCALITY)) +#ifndef PREFETCH_RDWR +# define PREFETCH_RDWR(...) LIBSIMPLE_PREFETCH_RDWR(__VA_ARGS__) +#endif + + +#define _LIBSIMPLE_ASSUME_ALIGNED(PTR, ALIGNMENT, ...)\ + _LIBSIMPLE_GCC_ONLY(__builtin_assume_aligned(PTR, ALIGNMENT)) +#if defined(__GNUC__) && !defined(__clang__) +# define LIBSIMPLE_ASSUME_ALIGNED(PTR, ...) /* returns PTR */ /* TODO test, doc, man */\ + _LIBSIMPLE_GCC_ONLY(__builtin_assume_aligned(PTR, ##__VA_ARGS__,\ + _LIBSIMPLE_C11_ONLY(_Alignof(PTR))\ + _LIBSIMPLE_PREC11_ONLY(__alignof(PTR)))) +#endif +#ifndef ASSUME_ALIGNED +# define ASSUME_ALIGNED(...) LIBSIMPLE_ASSUME_ALIGNED(__VA_ARGS__) +#endif + + +#define LIBSIMPLE_ASSUME_MISALIGNED(PTR, ALIGNMENT, OFFSET) /* returns PTR */ /* TODO test, doc, man */\ + __builtin_assume_aligned(PTR, ALIGNMENT, OFFSET) +#ifndef ASSUME_MISALIGNED +# define ASSUME_MISALIGNED(...) LIBSIMPLE_ASSUME_MISALIGNED(__VA_ARGS__) +#endif + + +#define LIBSIMPLE_UNROLLED(N) _LIBSIMPLE_GCC_ONLY(_LIBSIMPLE_C11_ONLY(_Pragma("GCC unroll "#N))) /* TODO test, doc, man */ +#ifndef UNROLLED +# define UNROLLED(N) LIBSIMPLE_UNROLLED(N) +#endif + + +#define LIBSIMPLE_SIMDLOOP _LIBSIMPLE_GCC_ONLY(_LIBSIMPLE_C11_ONLY(_Pragma("GCC ivdep"))) /* TODO test, doc, man */ +#ifndef SIMDLOOP +# define SIMDLOOP LIBSIMPLE_SIMDLOOP +#endif + + + #endif diff --git a/libsimple/aligned_memdup.h b/libsimple/aligned_memdup.h index b0650a7..36b085f 100644 --- a/libsimple/aligned_memdup.h +++ b/libsimple/aligned_memdup.h @@ -17,10 +17,12 @@ const char *__s = (s);\ size_t __n = (n);\ size_t __a = (alignment);\ + size_t __size;\ uintptr_t __misalignment;\ char *__r;\ __a += !__a;\ - __r = alloca(__n + (__a - 1));\ + __size = __n + (__a - 1);\ + __r = alloca(__size + !__size);\ __misalignment = (uintptr_t)__r % (uintptr_t)__a;\ if (__misalignment)\ __r += (uintptr_t)__a - __misalignment;\ @@ -79,7 +81,7 @@ void *libsimple_enaligned_memdup(int, const void *, size_t, size_t); */ _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) -{ return enaligned_memdup(libsimple_default_failure_exit, __s, __alignment, __n); } +{ return libsimple_enaligned_memdup(libsimple_default_failure_exit, __s, __alignment, __n); } #ifndef ealigned_memdup # define ealigned_memdup libsimple_ealigned_memdup #endif diff --git a/libsimple/aligned_realloc.h b/libsimple/aligned_realloc.h new file mode 100644 index 0000000..1da7ba7 --- /dev/null +++ b/libsimple/aligned_realloc.h @@ -0,0 +1,655 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param status The exit value for the process in case of failure + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n The number of bytes to allocate, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws EINVAL `alignment` is not a valid alignment + * @throws ENOMEM Could not allocated enough memory + * @throws ENOSYS Not implemented (requires non-standard libc functions) + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __alloc_size__(3), __warn_unused_result__))) +#if defined(__GLIBC__) +# define LIBSIMPLE_HAVE_ALIGNED_REALLOC +# include <malloc.h> +static inline void * +libsimple_aligned_realloc(void *__ptr, size_t __alignment, size_t __n) /* TODO musl */ +{ + size_t __old = malloc_usable_size(__ptr); +#if __STDC_VERSION__ >= 201112L || defined(_ISOC11_SOURCE) + size_t __extra = (__alignment - __n % __alignment) % __alignment; + void *__new = aligned_alloc(__alignment, __n + __extra); +#else + void *__new = memalign(__alignment, __n); +#endif + if (__new) { + memcpy(__new, __ptr, __old < __n ? __old : __n); + free(__ptr); + } + return __new; +} +#else +static inline void * +libsimple_aligned_realloc(void *__ptr, size_t __alignment, size_t __n) +{ + (void) __ptr; + (void) __alignment; + (void) __n; + errno = ENOSYS; + return NULL; +} +#endif +#ifndef aligned_realloc +# define aligned_realloc libsimple_aligned_realloc +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_enprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_enprintf` for more information + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param status The exit value for the process in case of failure + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n The number of bytes to allocate, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(3), __alloc_size__(4), __warn_unused_result__, __returns_nonnull__))) +void *libsimple_enaligned_realloc(int, void *, size_t, size_t); +#ifndef enaligned_realloc +# define enaligned_realloc libsimple_enaligned_realloc +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_eprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_eprintf` for more information + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n The number of bytes to allocate, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) +static inline void *libsimple_ealigned_realloc(void *__ptr, size_t __alignment, size_t __n) +{ return libsimple_enaligned_realloc(libsimple_default_failure_exit, __ptr, __alignment, __n); } +#ifndef ealigned_realloc +# define ealigned_realloc libsimple_ealigned_realloc +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is deallocated. If `ptr` + * is `NULL` a new allocation is made. + * + * The allocation size will be at least `n * m` + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n The number of bytes to allocate, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws EINVAL `alignment` is not a valid alignment + * @throws ENOMEM Could not allocated enough memory + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __alloc_size__(3), __warn_unused_result__))) +static inline void * +libsimple_aligned_reallocf(void *__ptr, size_t __alignment, size_t __n) /* TODO test */ +{ + void *__new = __n ? libsimple_aligned_realloc(__ptr, __alignment, __n) : NULL; + if (!__new) + free(__ptr); + return NULL; +} +#ifndef aligned_reallocf +# define aligned_reallocf libsimple_aligned_reallocf +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * The allocation size will be at least `n * m` + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n The number of elements to allocate, the behaviour of + * this function is unspecified for the value 0 + * @param m Size, in bytes, of each element, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size; `NULL` on failure + * @throws EINVAL `n` or `m` is 0 + * @throws EINVAL `alignment` is not a valid alignment + * @throws ENOMEM Could not allocated enough memory + * @throws ENOSYS Not implemented (requires non-standard libc functions) + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __alloc_size__(3, 4), __warn_unused_result__))) +static inline void * +libsimple_aligned_reallocarray(void *__ptr, size_t __alignment, size_t __n, size_t __m) +{ + if (LIBSIMPLE_UMUL_OVERFLOW(__n, __m, &__n, SIZE_MAX)) { + errno = ENOMEM; + return NULL; + } + return libsimple_aligned_realloc(__ptr, __alignment, __n); +} +#ifndef aligned_reallocarray +# define aligned_reallocarray libsimple_aligned_reallocarray +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_enprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_enprintf` for more information + * + * The allocation size will be at least `n * m` + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n The number of elements to allocate, the behaviour of + * this function is unspecified for the value 0 + * @param m Size, in bytes, of each element, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(3), __alloc_size__(4, 5), __warn_unused_result__, __returns_nonnull__))) +void *libsimple_enaligned_reallocarray(int, void *, size_t, size_t, size_t); +#ifndef enaligned_reallocarray +# define enaligned_reallocarray libsimple_enaligned_reallocarray +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_eprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_eprintf` for more information + * + * The allocation size will be at least `n * m` + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n The number of elements to allocate, the behaviour of + * this function is unspecified for the value 0 + * @param m Size, in bytes, of each element, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __alloc_size__(3, 4), __warn_unused_result__, __returns_nonnull__))) +static inline void *libsimple_ealigned_reallocarray(void *__ptr, size_t __alignment, size_t __n, size_t __m) +{ return libsimple_enaligned_reallocarray(libsimple_default_failure_exit, __ptr, __alignment, __n, __m); } +#ifndef ealigned_reallocarray +# define ealigned_reallocarray libsimple_ealigned_reallocarray +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is deallocated. If `ptr` + * is `NULL` a new allocation is made. + * + * The allocation size will be at least `n * m` + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n The number of elements to allocate, the behaviour of + * this function is unspecified for the value 0 + * @param m Size, in bytes, of each element, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size; `NULL` on failure + * @throws EINVAL `n` or `m` is 0 + * @throws EINVAL `alignment` is not a valid alignment + * @throws ENOMEM Could not allocated enough memory + * @throws ENOSYS Not implemented (requires non-standard libc functions) + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __alloc_size__(3, 4), __warn_unused_result__))) +static inline void * +libsimple_aligned_reallocarrayf(void *__ptr, size_t __alignment, size_t __n, size_t __m) /* TODO test */ +{ + void *__new = (__n && __m) ? libsimple_aligned_reallocarray(__ptr, __alignment, __n, __m) : NULL; + if (!__new) + free(__ptr); + return NULL; +} +#ifndef aligned_reallocarrayf +# define aligned_reallocarrayf libsimple_aligned_reallocarrayf +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * The product of all arguments, up to the first 0, + * will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws EINVAL `alignment` is not a valid alignment + * @throws ENOMEM Could not allocated enough memory + * @throws ENOSYS Not implemented (requires non-standard libc functions) + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __warn_unused_result__))) +void *libsimple_valigned_reallocn(void *, size_t, size_t, va_list); +#ifndef valigned_reallocn +# define valigned_reallocn libsimple_valigned_reallocn +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * The product of all arguments except `status`, up to the + * first 0, will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_enprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_enprintf` for more information + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param status The exit value for the process in case of failure + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(3), __warn_unused_result__, __returns_nonnull__))) +void *libsimple_envaligned_reallocn(int, void *, size_t, size_t, va_list); +#ifndef envaligned_reallocn +# define envaligned_reallocn libsimple_envaligned_reallocn +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * The product of all arguments, up to the first 0, + * will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_eprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_eprintf` for more information + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) +static inline void *libsimple_evaligned_reallocn(void *__ptr, size_t __alignment, size_t __n, va_list __ap) +{ return libsimple_envaligned_reallocn(libsimple_default_failure_exit, __ptr, __alignment, __n, __ap); } +#ifndef evaligned_reallocn +# define evaligned_reallocn libsimple_evaligned_reallocn +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * The product of all arguments, up to the first 0, + * will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is deallocated. If `ptr` + * is `NULL` a new allocation is made. + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws EINVAL `alignment` is not a valid alignment + * @throws ENOMEM Could not allocated enough memory + * @throws ENOSYS Not implemented (requires non-standard libc functions) + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __warn_unused_result__))) +static inline void * +libsimple_valigned_reallocfn(void *__ptr, size_t __alignment, size_t __n, va_list __ap) /* TODO test (aligned_reallocfn) */ +{ + void *__new = libsimple_valigned_reallocn(__ptr, __alignment, __n, __ap); + if (!__new) + free(__ptr); + return __new; +} +#ifndef valigned_reallocfn +# define valigned_reallocfn libsimple_aligned_reallocnf +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * The product of all arguments, up to the first 0, + * will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws EINVAL `alignment` is not a valid alignment + * @throws ENOMEM Could not allocated enough memory + * @throws ENOSYS Not implemented (requires non-standard libc functions) + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __warn_unused_result__))) +static inline void * +libsimple_aligned_reallocn(void *__ptr, size_t __alignment, size_t __n, ... /*, (size_t)0 */) +{ + va_list __ap; + va_start(__ap, __n); + return libsimple_valigned_reallocn(__ptr, __alignment, __n, __ap); + va_end(__ap); +} +#ifndef aligned_reallocn +# define aligned_reallocn libsimple_aligned_reallocn +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * The product of all arguments except `status`, up to the + * first 0, will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_enprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_enprintf` for more information + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param status The exit value for the process in case of failure + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(3), __warn_unused_result__, __returns_nonnull__))) +static inline void * +libsimple_enaligned_reallocn(int __status, void *__ptr, size_t __alignment, size_t __n, ... /*, (size_t)0 */) +{ + va_list __ap; + va_start(__ap, __n); + return libsimple_envaligned_reallocn(__status, __ptr, __alignment, __n, __ap); + va_end(__ap); +} +#ifndef enaligned_reallocn +# define enaligned_reallocn libsimple_enaligned_reallocn +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * The product of all arguments, up to the first 0, + * will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_eprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_eprintf` for more information + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __warn_unused_result__, __returns_nonnull__))) +static inline void * +libsimple_ealigned_reallocn(void *__ptr, size_t __alignment, size_t __n, ... /*, (size_t)0 */) +{ + va_list __ap; + va_start(__ap, __n); + return libsimple_evaligned_reallocn(__ptr, __alignment, __n, __ap); + va_end(__ap); +} +#ifndef ealigned_reallocn +# define ealigned_reallocn libsimple_ealigned_reallocn +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with custom alignment as the new alignment + * + * The product of all arguments, up to the first 0, + * will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is deallocated. If `ptr` + * is `NULL` a new allocation is made. + * + * This function may not be supported, check for the + * existance of the macro `LIBSIMPLE_HAVE_ALIGNED_REALLOC` + * to determine if it is supported + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param alignment The alignment of the new pointer + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws EINVAL `alignment` is not a valid alignment + * @throws ENOMEM Could not allocated enough memory + * @throws ENOSYS Not implemented (requires non-standard libc functions) + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_align__(2), __warn_unused_result__))) +static inline void * +libsimple_aligned_reallocfn(void *__ptr, size_t __alignment, size_t __n, ... /*, (size_t)0 */) +{ + va_list __ap; + va_start(__ap, __n); + return libsimple_valigned_reallocfn(__ptr, __alignment, __n, __ap); + va_end(__ap); +} +#ifndef aligned_reallocfn +# define aligned_reallocfn libsimple_aligned_reallocfn +#endif diff --git a/libsimple/aligned_strdup.h b/libsimple/aligned_strdup.h new file mode 100644 index 0000000..07b7edf --- /dev/null +++ b/libsimple/aligned_strdup.h @@ -0,0 +1,74 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Stack allocation version of `libsimple_aligned_strdup` + * + * @param s:const char * The string to copy + * @param alignment:size_t The alignment of the returned pointer + * @return :char * Duplicate of `s` with automatic storage + */ +#if defined(__GNUC__) || defined(__clang__) +# define libsimple_aligned_strdupa(s, alignment)\ + ({\ + const char *__s = (s);\ + size_t __n = strlen(__s) + 1;\ + size_t __a = (alignment);\ + uintptr_t __misalignment;\ + char *__r;\ + __a += !__a;\ + __r = alloca(__n + (__a - 1));\ + __misalignment = (uintptr_t)__r % (uintptr_t)__a;\ + if (__misalignment)\ + __r += (uintptr_t)__a - __misalignment;\ + memcpy(__r, __s, __n);\ + }) +# ifndef aligned_strdupa +# define aligned_strdupa(s, alignment) libsimple_aligned_strdupa(s, alignment) +# endif +#endif + + +/** + * Version of strdup(3) that returns a pointer with a custom alignment + * + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @return Duplicate of `s`, `NULL` on failure + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __nonnull__, __warn_unused_result__))) +static inline char *libsimple_aligned_strdup(const char * __s, size_t __alignment) +{ return libsimple_aligned_memdup(__s, __alignment, strlen(__s) + 1); } +#ifndef aligned_strdup +# define aligned_strdup libsimple_aligned_strdup +#endif + + +/** + * Version of `libsimple_aligned_strdup` that calls `libsimple_enprintf` on error + * + * @param status Exit value in case of failure + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __nonnull__, __warn_unused_result__, __returns_nonnull__))) +char *libsimple_enaligned_strdup(int, const char *, size_t); +#ifndef enaligned_strdup +# define enaligned_strdup libsimple_enaligned_strdup +#endif + + +/** + * Version of `libsimple_aligned_strdup` that calls `libsimple_eprintf` on error + * + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __nonnull__, __warn_unused_result__, __returns_nonnull__))) +static inline char *libsimple_ealigned_strdup(const char *__s, size_t __alignment) +{ return libsimple_enaligned_strdup(libsimple_default_failure_exit, __s, __alignment); } +#ifndef ealigned_strdup +# define ealigned_strdup libsimple_ealigned_strdup +#endif diff --git a/libsimple/aligned_strndup.h b/libsimple/aligned_strndup.h new file mode 100644 index 0000000..16a3aac --- /dev/null +++ b/libsimple/aligned_strndup.h @@ -0,0 +1,79 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Stack allocation version of `libsimple_aligned_strndup` + * + * @param s:const char * The string to copy + * @param alignment:size_t The alignment of the returned pointer + * @param n:size_t The maximum number of bytes to copy + * @return :char * Duplicate of `s` with automatic storage + */ +#if defined(__GNUC__) || defined(__clang__) +# define libsimple_aligned_strndupa(s, alignment, n)\ + ({\ + const char *__s = (s);\ + size_t __n = strnlen(__s, n);\ + size_t __a = (alignment);\ + uintptr_t __misalignment;\ + char *__r;\ + __a += !__a;\ + __r = alloca(__n + 1 + (__a - 1));\ + __misalignment = (uintptr_t)__r % (uintptr_t)__a;\ + if (__misalignment)\ + __r += (uintptr_t)__a - __misalignment;\ + memcpy(__r, __s, __n);\ + __r[__n] = '\0';\ + __r;\ + }) +# ifndef aligned_strndupa +# define aligned_strndupa(s, alignment, n) libsimple_aligned_strndupa(s, alignment, n) +# endif +#endif + + +/** + * Version of strndup(3) that returns a pointer with a custom alignment + * + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @param n The maximum number of bytes to copy + * @return Duplicate of `s`, `NULL` on failure + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __nonnull__, __warn_unused_result__))) +char *libsimple_aligned_strndup(const char * __s, size_t __alignment, size_t __n); +#ifndef aligned_strndup +# define aligned_strndup libsimple_aligned_strndup +#endif + + +/** + * Version of `libsimple_aligned_strndup` that calls `libsimple_enprintf` on error + * + * @param status Exit value in case of failure + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @param n The maximum number of bytes to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __nonnull__, __warn_unused_result__, __returns_nonnull__))) +char *libsimple_enaligned_strndup(int, const char *, size_t, size_t); +#ifndef enaligned_strndup +# define enaligned_strndup libsimple_enaligned_strndup +#endif + + +/** + * Version of `libsimple_aligned_strndup` that calls `libsimple_eprintf` on error + * + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @param n The maximum number of bytes to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __nonnull__, __warn_unused_result__, __returns_nonnull__))) +static inline char *libsimple_ealigned_strndup(const char *__s, size_t __alignment, size_t __n) +{ return libsimple_enaligned_strndup(libsimple_default_failure_exit, __s, __alignment, __n); } +#ifndef ealigned_strndup +# define ealigned_strndup libsimple_ealigned_strndup +#endif diff --git a/libsimple/aligned_wcsdup.h b/libsimple/aligned_wcsdup.h new file mode 100644 index 0000000..527d210 --- /dev/null +++ b/libsimple/aligned_wcsdup.h @@ -0,0 +1,74 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Stack allocation version of `libsimple_aligned_wcsdup` + * + * @param s:const wchar_t * The string to copy + * @param alignment:size_t The alignment of the returned pointer + * @return :wchar_t * Duplicate of `s` with automatic storage + */ +#if defined(__GNUC__) || defined(__clang__) +# define libsimple_aligned_wcsdupa(s, alignment)\ + ({\ + const wchar_t *__s = (s);\ + size_t __n = wcslen(__s) + 1;\ + size_t __a = (alignment);\ + uintptr_t __misalignment;\ + wchar_t *__r;\ + __a += !__a;\ + __r = alloca(__n * sizeof(wchar_t) + (__a - 1));\ + __misalignment = (uintptr_t)__r % (uintptr_t)__a;\ + if (__misalignment)\ + __r += (uintptr_t)__a - __misalignment;\ + wmemcpy(__r, __s, __n);\ + }) +# ifndef aligned_wcsdupa +# define aligned_wcsdupa(s, alignment) libsimple_aligned_wcsdupa(s, alignment) +# endif +#endif + + +/** + * Version of wcsdup(3) that returns a pointer with a custom alignment + * + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @return Duplicate of `s`, `NULL` on failure + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __nonnull__, __warn_unused_result__))) +static inline wchar_t *libsimple_aligned_wcsdup(const wchar_t * __s, size_t __alignment) +{ return libsimple_aligned_wmemdup(__s, __alignment, wcslen(__s) + 1); } +#ifndef aligned_wcsdup +# define aligned_wcsdup libsimple_aligned_wcsdup +#endif + + +/** + * Version of `libsimple_aligned_wcsdup` that calls `libsimple_enprintf` on error + * + * @param status Exit value in case of failure + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __nonnull__, __warn_unused_result__, __returns_nonnull__))) +wchar_t *libsimple_enaligned_wcsdup(int, const wchar_t *, size_t); +#ifndef enaligned_wcsdup +# define enaligned_wcsdup libsimple_enaligned_wcsdup +#endif + + +/** + * Version of `libsimple_aligned_wcsdup` that calls `libsimple_eprintf` on error + * + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __nonnull__, __warn_unused_result__, __returns_nonnull__))) +static inline wchar_t *libsimple_ealigned_wcsdup(const wchar_t *__s, size_t __alignment) +{ return libsimple_enaligned_wcsdup(libsimple_default_failure_exit, __s, __alignment); } +#ifndef ealigned_wcsdup +# define ealigned_wcsdup libsimple_ealigned_wcsdup +#endif diff --git a/libsimple/aligned_wcsndup.h b/libsimple/aligned_wcsndup.h new file mode 100644 index 0000000..015d1dc --- /dev/null +++ b/libsimple/aligned_wcsndup.h @@ -0,0 +1,79 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Stack allocation version of `libsimple_aligned_wcsndup` + * + * @param s:const wchar_t * The string to copy + * @param alignment:size_t The alignment of the returned pointer + * @param n:size_t The maximum number of wide characters to copy + * @return :wchar_t * Duplicate of `s` with automatic storage + */ +#if defined(__GNUC__) || defined(__clang__) +# define libsimple_aligned_wcsndupa(s, alignment, n)\ + ({\ + const wchar_t *__s = (s);\ + size_t __n = wcsnlen(__s, n);\ + size_t __a = (alignment);\ + uintptr_t __misalignment;\ + wchar_t *__r;\ + __a += !__a;\ + __r = alloca((__n + 1) * sizeof(wchar_t) + (__a - 1));\ + __misalignment = (uintptr_t)__r % (uintptr_t)__a;\ + if (__misalignment)\ + __r += (uintptr_t)__a - __misalignment;\ + wmemcpy(__r, __s, __n);\ + __r[__n] = 0;\ + __r;\ + }) +# ifndef aligned_wcsndupa +# define aligned_wcsndupa(s, alignment, n) libsimple_aligned_wcsndupa(s, alignment, n) +# endif +#endif + + +/** + * Version of wcsndup(3) that returns a pointer with a custom alignment + * + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @param n The maximum number of wide characters to copy + * @return Duplicate of `s`, `NULL` on failure + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __nonnull__, __warn_unused_result__))) +wchar_t *libsimple_aligned_wcsndup(const wchar_t * __s, size_t __alignment, size_t __n); +#ifndef aligned_wcsndup +# define aligned_wcsndup libsimple_aligned_wcsndup +#endif + + +/** + * Version of `libsimple_aligned_wcsndup` that calls `libsimple_enprintf` on error + * + * @param status Exit value in case of failure + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @param n The maximum number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __nonnull__, __warn_unused_result__, __returns_nonnull__))) +wchar_t *libsimple_enaligned_wcsndup(int, const wchar_t *, size_t, size_t); +#ifndef enaligned_wcsndup +# define enaligned_wcsndup libsimple_enaligned_wcsndup +#endif + + +/** + * Version of `libsimple_aligned_wcsndup` that calls `libsimple_eprintf` on error + * + * @param s The string to copy + * @param alignment The alignment of the returned pointer + * @param n The maximum number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __nonnull__, __warn_unused_result__, __returns_nonnull__))) +static inline wchar_t *libsimple_ealigned_wcsndup(const wchar_t *__s, size_t __alignment, size_t __n) +{ return libsimple_enaligned_wcsndup(libsimple_default_failure_exit, __s, __alignment, __n); } +#ifndef ealigned_wcsndup +# define ealigned_wcsndup libsimple_ealigned_wcsndup +#endif diff --git a/libsimple/aligned_wmemdup.h b/libsimple/aligned_wmemdup.h new file mode 100644 index 0000000..63a9d40 --- /dev/null +++ b/libsimple/aligned_wmemdup.h @@ -0,0 +1,79 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Stack allocation version of `libsimple_aligned_wmemdup` + * + * @param s:const wchar_t * The wide characters to copy + * @param alignment:size_t The alignment of the returned pointer + * @param n:size_t The number of wide characters to copy + * @return :wchar_t * Duplicate of `s` with automatic storage + */ +#if defined(__GNUC__) || defined(__clang__) +# define libsimple_aligned_wmemdupa(s, alignment, n)\ + ({\ + const wchar_t *__s = (s);\ + size_t __n = (n);\ + size_t __a = (alignment);\ + size_t __size;\ + uintptr_t __misalignment;\ + wchar_t *__r;\ + __a += !__a;\ + __size = __n * sizeof(wchar_t) + (__a - 1);\ + __r = alloca(__size + !__size);\ + __misalignment = (uintptr_t)__r % (uintptr_t)__a;\ + if (__misalignment)\ + __r += (uintptr_t)__a - __misalignment;\ + wmemcpy(__r, __s, __n);\ + }) +# ifndef aligned_wmemdupa +# define aligned_wmemdupa(s, alignment, n) libsimple_aligned_wmemdupa(s, alignment, n) +# endif +#endif + + +/** + * Create a new allocation, with custom alignment, and copy wide characters into it + * + * @param s The wide characters to copy + * @param alignment The alignment of the returned pointer + * @param n The number of wide characters to copy + * @return Duplicate of `s`, `NULL` on failure + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __alloc_size__(3), __nonnull__, __warn_unused_result__))) +wchar_t *libsimple_aligned_wmemdup(const wchar_t *, size_t, size_t); +#ifndef aligned_wmemdup +# define aligned_wmemdup libsimple_aligned_wmemdup +#endif + + +/** + * Version of `libsimple_aligned_wmemdup` that calls `libsimple_enprintf` on error + * + * @param status Exit value in case of failure + * @param s The wide characters to copy + * @param alignment The alignment of the returned pointer + * @param n The number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(3), __alloc_size__(4), __warn_unused_result__, __returns_nonnull__))) +wchar_t *libsimple_enaligned_wmemdup(int, const wchar_t *, size_t, size_t); +#ifndef enaligned_wmemdup +# define enaligned_wmemdup libsimple_enaligned_wmemdup +#endif + + +/** + * Version of `libsimple_aligned_wmemdup` that calls `libsimple_eprintf` on error + * + * @param s The wide characters to copy + * @param alignment The alignment of the returned pointer + * @param n The number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __alloc_align__(2), __alloc_size__(3), __warn_unused_result__, __returns_nonnull__))) +static inline wchar_t *libsimple_ealigned_wmemdup(const wchar_t *__s, size_t __alignment, size_t __n) +{ return libsimple_enaligned_wmemdup(libsimple_default_failure_exit, __s, __alignment, __n); } +#ifndef ealigned_wmemdup +# define ealigned_wmemdup libsimple_ealigned_wmemdup +#endif diff --git a/libsimple/array.h b/libsimple/array.h index 2eea727..2016540 100644 --- a/libsimple/array.h +++ b/libsimple/array.h @@ -144,14 +144,14 @@ /* @since 1.1 */ -#define libsimple_arraycpy(d, s, n) libsimple_memcpy(d, s, (n) * sizeof *(s)) +#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) libsimple_memmove(d, s, (n) * sizeof *(s)) +#define libsimple_arraymove(d, s, n) memmove(d, s, (n) * sizeof *(s)) #ifndef arraymove # define arraymove(...) libsimple_arraymove(__VA_ARGS__) #endif diff --git a/libsimple/memdup.h b/libsimple/memdup.h index 6125a0d..8e5b41f 100644 --- a/libsimple/memdup.h +++ b/libsimple/memdup.h @@ -15,7 +15,7 @@ ({\ const char *__s = (s);\ size_t __n = (n);\ - char *__r = alloca(__n);\ + char *__r = alloca(__n + !__n);\ memcpy(__r, __s, __n);\ }) # ifndef memdupa @@ -68,7 +68,7 @@ void *libsimple_enmemdup(int, const void *, size_t); */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_ememdup(const void *__s, size_t __n) -{ return enmemdup(libsimple_default_failure_exit, __s, __n); } +{ return libsimple_enmemdup(libsimple_default_failure_exit, __s, __n); } #ifndef ememdup # define ememdup libsimple_ememdup #endif diff --git a/libsimple/realloc.h b/libsimple/realloc.h index 2d8af2e..32a5f59 100644 --- a/libsimple/realloc.h +++ b/libsimple/realloc.h @@ -215,7 +215,7 @@ libsimple_enreallocn(int __status, void *__ptr, size_t __n, ... /*, (size_t)0 */ */ _LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2), __warn_unused_result__, __returns_nonnull__))) static inline void *libsimple_erealloc(void *__ptr, size_t __n) -{ return enrealloc(libsimple_default_failure_exit, __ptr, __n); } +{ return libsimple_enrealloc(libsimple_default_failure_exit, __ptr, __n); } #ifndef erealloc # define erealloc libsimple_erealloc #endif @@ -299,3 +299,261 @@ libsimple_ereallocn(void *__ptr, size_t __n, ... /*, (size_t)0 */) #ifndef ereallocn # define ereallocn libsimple_ereallocn #endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with default alignment (`alignof(max_align_t)`) + * as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is deallocated. If `ptr` + * is `NULL` a new allocation is made. + * + * The allocation size will be at least `n * m` + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param n The number of bytes to allocate, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size and with the alignment + * `alignof(max_align_t)`; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws ENOMEM Could not allocated enough memory + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2), __warn_unused_result__))) +static inline void * +libsimple_reallocf(void *__ptr, size_t __n) /* TODO test */ +{ + void *__new = __n ? realloc(__ptr, __n) : NULL; + if (!__new) + free(__ptr); + return __new; +} +#ifndef reallocf +# define reallocf libsimple_reallocf +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with default alignment (`alignof(max_align_t)`) + * as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * The allocation size will be at least `n * m` + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param n The number of elements to allocate, the behaviour of + * this function is unspecified for the value 0 + * @param m Size, in bytes, of each element, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size and with the alignment + * `alignof(max_align_t)`; `NULL` on failure + * @throws EINVAL `n` or `m` is 0 + * @throws ENOMEM Could not allocated enough memory + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2, 3), __warn_unused_result__))) +static inline void * +libsimple_reallocarray(void *__ptr, size_t __n, size_t __m) +{ + if (LIBSIMPLE_UMUL_OVERFLOW(__n, __m, &__n, SIZE_MAX)) { + errno = ENOMEM; + return NULL; + } + return realloc(__ptr, __n); +} +#ifndef reallocarray +# define reallocarray libsimple_reallocarray +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with default alignment (`alignof(max_align_t)`) + * as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_enprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_enprintf` for more information + * + * The allocation size will be at least `n * m` + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param n The number of elements to allocate, the behaviour of + * this function is unspecified for the value 0 + * @param m Size, in bytes, of each element, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size and with the alignment + * `alignof(max_align_t)` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(3, 4), __warn_unused_result__, __returns_nonnull__))) +void *libsimple_enreallocarray(int, void *, size_t, size_t); +#ifndef enreallocarray +# define enreallocarray libsimple_enreallocarray +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with default alignment (`alignof(max_align_t)`) + * as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is still valid. If `ptr` + * is `NULL` a new allocation is made. + * + * On failure, the `libsimple_eprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_eprintf` for more information + * + * The allocation size will be at least `n * m` + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param n The number of elements to allocate, the behaviour of + * this function is unspecified for the value 0 + * @param m Size, in bytes, of each element, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size and with the alignment + * `alignof(max_align_t)` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2, 3), __warn_unused_result__, __returns_nonnull__))) +static inline void *libsimple_ereallocarray(void *__ptr, size_t __n, size_t __m) +{ return libsimple_enreallocarray(libsimple_default_failure_exit, __ptr, __n, __m); } +#ifndef ereallocarray +# define ereallocarray libsimple_ereallocarray +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with default alignment (`alignof(max_align_t)`) + * as the new alignment + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is deallocated. If `ptr` + * is `NULL` a new allocation is made. + * + * The allocation size will be at least `n * m` + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param n The number of elements to allocate, the behaviour of + * this function is unspecified for the value 0 + * @param m Size, in bytes, of each element, the behaviour of + * this function is unspecified for the value 0 + * @return Either `ptr` or a unique pointer with at least + * the specified size and with the alignment + * `alignof(max_align_t)`; `NULL` on failure + * @throws EINVAL `n` or `m` is 0 + * @throws ENOMEM Could not allocated enough memory + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__alloc_size__(2, 3), __warn_unused_result__))) +static inline void * +libsimple_reallocarrayf(void *__ptr, size_t __n, size_t __m) /* TODO test */ +{ + void *__new = __n ? libsimple_reallocarray(__ptr, __n, __m) : NULL; + if (!__new) + free(__ptr); + return __new; +} +#ifndef reallocarrayf +# define reallocarrayf libsimple_reallocarrayf +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with default alignment (`alignof(max_align_t)`) + * as the new alignment + * + * The product of all arguments, up to the first 0, + * will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is deallocated. If `ptr` + * is `NULL` a new allocation is made. + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size and with the alignment + * `alignof(max_align_t)`; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws ENOMEM Could not allocated enough memory + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) +static inline void * +libsimple_vreallocfn(void *__ptr, size_t __n, va_list __ap) /* TODO test (reallocfn) */ +{ + void *__new = libsimple_vreallocn(__ptr, __n, __ap); + if (!__new) + free(__ptr); + return __new; +} +#ifndef vreallocfn +# define vreallocfn libsimple_vreallocfn +#endif + + +/** + * Dynamically reallocates heap allocated, uninitialised, + * memory with default alignment (`alignof(max_align_t)`) + * as the new alignment + * + * The product of all arguments, up to the first 0, + * will be used as the number of bytes to allocated + * + * On success, either `ptr` is returned, or a new non-null + * pointer is returned with the same content (truncated to + * `n` bytes if size shrunk), in which case `ptr` is + * deallocated. On failure `ptr` is deallocated. If `ptr` + * is `NULL` a new allocation is made. + * + * @param ptr Pointer to reallocated, `NULL` for a new allocation + * @param n First factor for the allocation size, must not be 0 + * @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) + * @return Either `ptr` or a unique pointer with at least + * the specified size and with the alignment + * `alignof(max_align_t)`; `NULL` on failure + * @throws EINVAL `n` is 0 + * @throws ENOMEM Could not allocated enough memory + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__warn_unused_result__))) +static inline void * +libsimple_reallocfn(void *__ptr, size_t __n, ... /*, (size_t)0 */) +{ + va_list __ap; + va_start(__ap, __n); + return libsimple_vreallocfn(__ptr, __n, __ap); + va_end(__ap); +} +#ifndef reallocfn +# define reallocfn libsimple_reallocfn +#endif diff --git a/libsimple/str.h b/libsimple/str.h index 3e321e1..4c17a0a 100644 --- a/libsimple/str.h +++ b/libsimple/str.h @@ -382,7 +382,7 @@ static inline int libsimple_streq(const char *__a, const char *__b) */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_streqnul(const char *__a, const char *__b) -{ return !strcmpnul(__a, __b); } +{ return !libsimple_strcmpnul(__a, __b); } #ifndef streqnul # define streqnul libsimple_streqnul #endif @@ -418,7 +418,7 @@ static inline int libsimple_strcaseeq(const char *__a, const char *__b) */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strcaseeqnul(const char *__a, const char *__b) -{ return !strcasecmpnul(__a, __b); } +{ return !libsimple_strcasecmpnul(__a, __b); } #ifndef strcaseeqnul # define strcaseeqnul libsimple_strcaseeqnul #endif @@ -470,7 +470,7 @@ size_t libsimple_strcaseeqlen(const char *, const char *); */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strreqlen(const char *__a, const char *__b) -{ return memreqlen(__a, strlen(__a), __b, strlen(__b)); } +{ return libsimple_memreqlen(__a, strlen(__a), __b, strlen(__b)); } #ifndef strreqlen # define strreqlen libsimple_strreqlen #endif @@ -488,7 +488,7 @@ static inline size_t libsimple_strreqlen(const char *__a, const char *__b) */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrcaseeqlen(const char *__a, const char *__b) -{ return memrcaseeqlen(__a, strlen(__a), __b, strlen(__b)); } +{ return libsimple_memrcaseeqlen(__a, strlen(__a), __b, strlen(__b)); } #ifndef strrcaseeqlen # define strrcaseeqlen libsimple_strrcaseeqlen #endif diff --git a/libsimple/strdup.h b/libsimple/strdup.h index 1d23b24..3db9d95 100644 --- a/libsimple/strdup.h +++ b/libsimple/strdup.h @@ -49,7 +49,7 @@ char *libsimple_enstrdup(int, const char *); */ _LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, __assume_aligned__(1), __nonnull__, __warn_unused_result__, __returns_nonnull__))) static inline char *libsimple_estrdup(const char *__s) -{ return enstrdup(libsimple_default_failure_exit, __s); } +{ return libsimple_enstrdup(libsimple_default_failure_exit, __s); } #ifndef estrdup # define estrdup libsimple_estrdup #endif diff --git a/libsimple/strn.h b/libsimple/strn.h index 5f5740e..dc6e695 100644 --- a/libsimple/strn.h +++ b/libsimple/strn.h @@ -513,7 +513,7 @@ static inline int libsimple_strncaseeq(const char *__a, const char *__b, size_t */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __warn_unused_result__))) static inline int libsimple_strncaseeqnul(const char *__a, const char *__b, size_t __n) -{ return !strncasecmpnul(__a, __b, __n); } +{ return !libsimple_strncasecmpnul(__a, __b, __n); } #ifndef strncaseeqnul # define strncaseeqnul libsimple_strncaseeqnul #endif @@ -571,7 +571,7 @@ size_t libsimple_strncaseeqlen(const char *, const char *, size_t); */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrneqlen(const char *__a, const char *__b, size_t __n) -{ return memreqlen(__a, strnlen(__a, __n), __b, strnlen(__b, __n)); } +{ return libsimple_memreqlen(__a, strnlen(__a, __n), __b, strnlen(__b, __n)); } #ifndef strrneqlen # define strrneqlen libsimple_strrneqlen #endif @@ -591,7 +591,7 @@ static inline size_t libsimple_strrneqlen(const char *__a, const char *__b, size */ _LIBSIMPLE_GCC_ONLY(__attribute__((__pure__, __nonnull__, __warn_unused_result__))) static inline size_t libsimple_strrncaseeqlen(const char *__a, const char *__b, size_t __n) -{ return memrcaseeqlen(__a, strnlen(__a, __n), __b, strnlen(__b, __n)); } +{ return libsimple_memrcaseeqlen(__a, strnlen(__a, __n), __b, strnlen(__b, __n)); } #ifndef strrncaseeqlen # define strrncaseeqlen libsimple_strrncaseeqlen #endif diff --git a/libsimple/strndup.h b/libsimple/strndup.h index c7d0b3a..b3229d5 100644 --- a/libsimple/strndup.h +++ b/libsimple/strndup.h @@ -55,7 +55,7 @@ char *libsimple_enstrndup(int, const char *, size_t); */ _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) -{ return enstrndup(libsimple_default_failure_exit, __s, __n); } +{ return libsimple_enstrndup(libsimple_default_failure_exit, __s, __n); } #ifndef estrndup # define estrndup libsimple_estrndup #endif diff --git a/libsimple/time.h b/libsimple/time.h index b6eb923..aa92314 100644 --- a/libsimple/time.h +++ b/libsimple/time.h @@ -399,3 +399,105 @@ char *libsimple_minimise_number_string(char *); #ifndef minimise_number_string # define minimise_number_string libsimple_minimise_number_string #endif + + +/** + * Get the current time in the local timezone + * + * This function is leap-second aware + * + * @param tm Output parameter for the local time + * @param ts Output parameter for the POSIX time, may be NULL + * @return 0 on success, -1 on failure + * + * @since 1.2 + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) +int libsimple_localtime(struct tm *, struct timespec *); + +/** + * Get the current time in the local timezone + * + * This function is leap-second aware + * + * On failure, the `libsimple_enprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_enprintf` for more information + * + * @param status The exit value for the process in case of failure + * @param tm Output parameter for the local time + * @param ts Output parameter for the POSIX time, may be NULL + * + * @since 1.2 + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) +void libsimple_enlocaltime(int, struct tm *, struct timespec *); + +/** + * Get the current time in the local timezone + * + * This function is leap-second aware + * + * On failure, the `libsimple_eprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_eprintf` for more information + * + * @param tm Output parameter for the local time + * @param ts Output parameter for the POSIX time, may be NULL + * + * @since 1.2 + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) +static inline void libsimple_elocaltime(struct tm *__tm, struct timespec *__ts) +{ libsimple_enlocaltime(libsimple_default_failure_exit, __tm, __ts); } + + +/** + * Get the current time in the UTC timezone + * + * This function is leap-second aware + * + * @param tm Output parameter for the UTC time + * @param ts Output parameter for the POSIX time, may be NULL + * @return 0 on success, -1 on failure + * + * @since 1.2 + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) +int libsimple_gmtime(struct tm *, struct timespec *); + +/** + * Get the current time in the UTC timezone + * + * This function is leap-second aware + * + * On failure, the `libsimple_enprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_enprintf` for more information + * + * @param status The exit value for the process in case of failure + * @param tm Output parameter for the UTC time + * @param ts Output parameter for the POSIX time, may be NULL + * + * @since 1.2 + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(2)))) +void libsimple_engmtime(int, struct tm *, struct timespec *); + +/** + * Get the current time in the UTC timezone + * + * This function is leap-second aware + * + * On failure, the `libsimple_eprintf` function is called, + * cause the program to print an error message and exit, + * see `libsimple_eprintf` for more information + * + * @param tm Output parameter for the UTC time + * @param ts Output parameter for the POSIX time, may be NULL + * + * @since 1.2 + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__nonnull__(1)))) +static inline void libsimple_egmtime(struct tm *__tm, struct timespec *__ts) +{ libsimple_engmtime(libsimple_default_failure_exit, __tm, __ts); } diff --git a/libsimple/wcsdup.h b/libsimple/wcsdup.h new file mode 100644 index 0000000..b85d265 --- /dev/null +++ b/libsimple/wcsdup.h @@ -0,0 +1,51 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Stack allocation version of wcsdup(3) + * + * @param s:const wchar_t * The string to copy + * @return :wchar_t * Duplicate of `s` with automatic storage + */ +#if defined(__GNUC__) || defined(__clang__) +# define libsimple_wcsdupa(s)\ + ({\ + const wchar_t *__s = (s);\ + size_t __n = wcslen(__s) + 1;\ + wchar_t *__r = alloca(__n * sizeof(wchar_t));\ + wmemcpy(__r, __s, __n);\ + }) +# ifndef wcsdupa +# define wcsdupa(s) libsimple_wcsdupa(s) +# endif +#endif + + +/** + * Version of wcsdup(3) that calls `libsimple_enprintf` on error + * + * @param status Exit value in case of failure + * @param s The string to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, _libsimple_assume_aligned_as(wchar_t), __nonnull__, + __warn_unused_result__, __returns_nonnull__))) +wchar_t *libsimple_enwcsdup(int, const wchar_t *); +#ifndef enwcsdup +# define enwcsdup libsimple_enwcsdup +#endif + + +/** + * Version of wcsdup(3) that calls `libsimple_eprintf` on error + * + * @param s The string to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, _libsimple_assume_aligned_as(wchar_t), + __nonnull__, __warn_unused_result__, __returns_nonnull__))) +static inline wchar_t *libsimple_ewcsdup(const wchar_t *__s) +{ return enwcsdup(libsimple_default_failure_exit, __s); } +#ifndef ewcsdup +# define ewcsdup libsimple_ewcsdup +#endif diff --git a/libsimple/wcsndup.h b/libsimple/wcsndup.h new file mode 100644 index 0000000..31e9118 --- /dev/null +++ b/libsimple/wcsndup.h @@ -0,0 +1,72 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Stack allocation version of `libsimple_wcsndup` + * + * @param s:const wchar_t * The string to copy + * @param n:size_t The maximum number of wide characters to copy + * @return :wchar_t * Duplicate of `s` with automatic storage + */ +#if defined(__GNUC__) || defined(__clang__) +# define libsimple_wcsndupa(s, n)\ + ({\ + const wchar_t *__s = (s);\ + size_t __n = wcsnlen(__s, n);\ + wchar_t *__r;\ + __r = alloca((__n + 1) * sizeof(wchar_t));\ + wmemcpy(__r, __s, __n);\ + __r[__n] = 0;\ + __r;\ + }) +# ifndef wcsndupa +# define wcsndupa(s, n) libsimple_wcsndupa(s, n) +# endif +#endif + + +/** + * Create a new allocation and copy a wide-character string into it + * + * @param s The string to copy + * @param n The maximum number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, _libsimple_assume_aligned_as(wchar_t), __nonnull__, + __warn_unused_result__))) +wchar_t *libsimple_wcsndup(const wchar_t *, size_t); +#ifndef wcsndup +# define wcsndup libsimple_wcsndup +#endif + + +/** + * Version of `libsimple_wcsndup` that calls `libsimple_enprintf` on error + * + * @param status Exit value in case of failure + * @param s The string to copy + * @param n The maximum number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, _libsimple_assume_aligned_as(wchar_t), __nonnull__, + __warn_unused_result__, __returns_nonnull__))) +wchar_t *libsimple_enwcsndup(int, const wchar_t *, size_t); +#ifndef enwcsndup +# define enwcsndup libsimple_enwcsndup +#endif + + +/** + * Version of `libsimple_wcsndup` that calls `libsimple_eprintf` on error + * + * @param s The string to copy + * @param n The maximum number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, _libsimple_assume_aligned_as(wchar_t), + __nonnull__, __warn_unused_result__, __returns_nonnull__))) +static inline wchar_t *libsimple_ewcsndup(const wchar_t *__s, size_t __n) +{ return libsimple_enwcsndup(libsimple_default_failure_exit, __s, __n); } +#ifndef ewcsndup +# define ewcsndup libsimple_ewcsndup +#endif diff --git a/libsimple/wmemdup.h b/libsimple/wmemdup.h new file mode 100644 index 0000000..2c1f899 --- /dev/null +++ b/libsimple/wmemdup.h @@ -0,0 +1,68 @@ +/* See LICENSE file for copyright and license details. */ + + +/** + * Stack allocation version of `libsimple_wmemdup` + * + * @param s:const wchar_t * The wide characters to copy + * @param n:size_t The number of wide characters to copy + * @return :wchar_t * Duplicate of `s` with automatic storage + */ +#if defined(__GNUC__) || defined(__clang__) +# define libsimple_wmemdupa(s, n)\ + ({\ + const wchar_t *__s = (s);\ + size_t __n = (n);\ + wchar_t *__r = alloca(__n * sizeof(wchar_t) + !__n);\ + wmemcpy(__r, __s, __n);\ + }) +# ifndef wmemdupa +# define wmemdupa(s, n) libsimple_wmemdupa(s, n) +# endif +#endif + + +/** + * Create a new allocation and copy wide characters into it + * + * @param s The wide characters to copy + * @param n The number of wide characters to copy + * @return Duplicate of `s`, `NULL` on failure + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, _libsimple_assume_aligned_as(wchar_t), __alloc_size__(2), __warn_unused_result__))) +wchar_t *libsimple_wmemdup(const wchar_t *, size_t); +#ifndef wmemdup +# define wmemdup libsimple_wmemdup +#endif + + +/** + * Version of `libsimple_wmemdup` that calls `libsimple_enprintf` on error + * + * @param status Exit value in case of failure + * @param s The wide characters to copy + * @param n The number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, _libsimple_assume_aligned_as(wchar_t), __alloc_size__(3), + __warn_unused_result__, __returns_nonnull__))) +wchar_t *libsimple_enwmemdup(int, const wchar_t *, size_t); +#ifndef enwmemdup +# define enwmemdup libsimple_enwmemdup +#endif + + +/** + * Version of `libsimple_wmemdup` that calls `libsimple_eprintf` on error + * + * @param s The wide characters to copy + * @param n The number of wide characters to copy + * @return Duplicate of `s` + */ +_LIBSIMPLE_GCC_ONLY(__attribute__((__malloc__, _libsimple_assume_aligned_as(wchar_t), __alloc_size__(2), + __warn_unused_result__, __returns_nonnull__))) +static inline wchar_t *libsimple_ewmemdup(const wchar_t *__s, size_t __n) +{ return libsimple_enwmemdup(libsimple_default_failure_exit, __s, __n); } +#ifndef ewmemdup +# define ewmemdup libsimple_ewmemdup +#endif diff --git a/localtime.c b/localtime.c new file mode 100644 index 0000000..0b075a0 --- /dev/null +++ b/localtime.c @@ -0,0 +1,61 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#include <sys/timex.h> +#ifndef TEST + + +int +libsimple_localtime(struct tm *tm, struct timespec *ts) +{ + struct timex timex; + int r; + + memset(&timex, 0, sizeof(timex)); + timex.status = ADJ_NANO; + r = adjtimex(&timex); + if (r == -1) + return -1; + if (ts) { + ts->tv_sec = timex.time.tv_sec; + ts->tv_nsec = timex.time.tv_usec; + } + + if (timex.time.tv_sec % (24 * 60 * 60) == 0) { + if (r == TIME_INS) { + timex.time.tv_sec -= 1; + if (!localtime_r(&timex.time.tv_sec, tm)) + return -1; + tm->tm_sec += 1; + return 1; + } else if (r == TIME_DEL) { + timex.time.tv_sec += 1; + if (!localtime_r(&timex.time.tv_sec, tm)) + return -1; + } else { + if (!localtime_r(&timex.time.tv_sec, tm)) + return -1; + } + } else if (r == TIME_OOP) { + if (!localtime_r(&timex.time.tv_sec, tm)) + return -1; + tm->tm_sec += 1; + } else { + if (!localtime_r(&timex.time.tv_sec, tm)) + return -1; + } + + return 0; +} + + +#else +#include "test.h" + +int +main(void) +{ + /* TODO test */ + return 0; +} + +#endif diff --git a/man0/libsimple-arg.h.0 b/man0/libsimple-arg.h.0 index d60e59e..abc8619 100644 --- a/man0/libsimple-arg.h.0 +++ b/man0/libsimple-arg.h.0 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE\-ARG.H 0 2018-11-15 libsimple +.TH LIBSIMPLE\-ARG.H 0 libsimple .SH NAME libsimple\-arg.h \- command line argument parsing header for libsimple + .SH SYNOPSIS .nf #include <libsimple\-arg.h> @@ -29,6 +30,7 @@ struct longopt { #define USAGE(\fISYNOPSIS\fP) /* implementation omitted */ #define NUSAGE(\fISTATUS\fP, \fISYNOPSIS\fP) /* implementation omitted */ .fi + .SH DESCRIPTION The .I <libsimple\-arg.h> @@ -467,13 +469,18 @@ once, or if flags are used, never. So if your application should not have any options or operands, .I NOFLAGS(argc) can be used. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH SEE ALSO .BR libsimple.h (0) diff --git a/man0/libsimple.h.0 b/man0/libsimple.h.0 index c9055d5..36e4f71 100644 --- a/man0/libsimple.h.0 +++ b/man0/libsimple.h.0 @@ -1,10 +1,12 @@ -.TH LIBSIMPLE.H 0 2018-11-24 libsimple +.TH LIBSIMPLE.H 0 libsimple .SH NAME libsimple.h \- main header for libsimple + .SH SYNOPSIS .nf #include <libsimple.h> .fi + .SH DESCRIPTION The header .I <libsimple.h> @@ -43,8 +45,10 @@ includes the following header files: .IR <string.h> , .IR <strings.h> , .IR <time.h> , +.IR <unistd.h> , +.IR <wchar.h> , and -.IR <unistd.h> . +.IR <wctype.h> . .PP The header .I <libsimple.h> @@ -139,20 +143,17 @@ are defined only with namespacing: .TP .BR libsimple_arrayalloc (3), -.RS 0 +.TQ .BR libsimple_earrayalloc (3), -.br +.TQ .BR libsimple_enarrayalloc (3), -.br +.TQ .BR libsimple_varrayalloc (3), -.br +.TQ .BR libsimple_evarrayalloc (3), -.br +.TQ .BR libsimple_envarrayalloc (3) -.RE -.RS Flexible allocation of memory suitable for allocating arrays. -.RE .TP .BR libsimple_close (3) @@ -168,20 +169,17 @@ Function called after printing error messages. Function called before printing error messages. .TP .BR libsimple_memalloc (3), -.RS 0 +.TQ .BR libsimple_ememalloc (3), -.br +.TQ .BR libsimple_enmemalloc (3), -.br +.TQ .BR libsimple_vmemalloc (3), -.br +.TQ .BR libsimple_evmemalloc (3), -.br +.TQ .BR libsimple_envmemalloc (3) -.RE -.RS Flexible allocation of memory. -.RE .PP The following functions and macros are @@ -189,177 +187,309 @@ defined both with and without namespacing: .TP .BR libsimple_ealigned_alloc (3), -.RS 0 +.TQ .BR libsimple_enaligned_alloc (3) -.RE -.RS Wrappers for .BR aligned_alloc (3) that terminate the process on failure. -.RE .TP .BR libsimple_aligned_allocn (3), -.RS 0 +.TQ .BR libsimple_ealigned_allocn (3), -.br +.TQ .BR libsimple_enaligned_allocn (3), -.br +.TQ .BR libsimple_valigned_allocn (3), -.br +.TQ .BR libsimple_evaligned_allocn (3), -.br +.TQ .BR libsimple_envaligned_allocn (3) -.RE -.RS Wrappers for .BR aligned_alloc (3) that take the product of multiple arguments as the allocation size. -.RE .TP .BR libsimple_aligned_allocz (3), -.RS 0 +.TQ .BR libsimple_ealigned_allocz (3), -.br +.TQ .BR libsimple_enaligned_allocz (3) -.RE -.RS Wrappers for .BR aligned_alloc (3) that conditionally initialises the memory. -.RE .TP .BR libsimple_aligned_alloczn (3), -.RS 0 +.TQ .BR libsimple_ealigned_alloczn (3), -.br +.TQ .BR libsimple_enaligned_alloczn (3), -.br +.TQ .BR libsimple_valigned_alloczn (3), -.br +.TQ .BR libsimple_evaligned_alloczn (3), -.br +.TQ .BR libsimple_envaligned_alloczn (3) -.RE -.RS Wrappers for .BR aligned_alloc (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. -.RE .TP .BR libsimple_aligned_memdup (3), -.RS 0 +.TQ .BR libsimple_ealigned_memdup (3), -.br +.TQ .BR libsimple_enaligned_memdup (3) -.RE -.RS Duplicate an array of bytes into a new pointer with a custom alignment. -.RE .TP .BR libsimple_aligned_memdupa (3) -Duplicate an array of bytes onto the stack. +Duplicate an array of bytes onto the stack, +with custom alignment. + +.TP +.BR libsimple_aligned_realloc (3), +.TQ +.BR libsimple_ealigned_realloc (3), +.TQ +.BR libsimple_enaligned_realloc (3) +Version of +.BR realloc (3) +with custom alignment. + +.TP +.BR libsimple_aligned_reallocf (3) +Version of +.BR realloc (3) +with custom alignment that deallocates +the pointer on failure. + +.TP +.BR libsimple_aligned_reallocarray (3), +.TQ +.BR libsimple_ealigned_reallocarray (3), +.TQ +.BR libsimple_enaligned_reallocarray (3) +Version of +.BR realloc (3) +with custom alignment that, like +.BR calloc (3), +takes two size arguments. + +.TP +.BR libsimple_aligned_reallocarrayf (3) +Version of +.BR realloc (3) +with custom alignment that, like +.BR calloc (3), +takes two size arguments, and that +deallocates the pointer on failure. + +.TP +.BR libsimple_aligned_reallocfn (3), +.TQ +.BR libsimple_valigned_reallocfn (3) +Version of +.BR realloc (3) +that take the product of multiple arguments +as the allocation size, and that +deallocates the pointer on failure. + +.TP +.BR libsimple_aligned_reallocn (3), +.TQ +.BR libsimple_ealigned_reallocn (3), +.TQ +.BR libsimple_enaligned_reallocn (3), +.TQ +.BR libsimple_valigned_reallocn (3), +.TQ +.BR libsimple_evaligned_reallocn (3), +.TQ +.BR libsimple_envaligned_reallocn (3) +Version of +.BR realloc (3) +that take the product of multiple arguments +as the allocation size. + +.TP +.BR libsimple_reallocarray (3), +.TQ +.BR libsimple_ereallocarray (3), +.TQ +.BR libsimple_enreallocarray (3) +Version of +.BR realloc (3) +that, like +.BR calloc (3), +takes to size arguments. + +.TP +.BR libsimple_reallocarrayf (3) +Version of +.BR realloc (3) +that, like +.BR calloc (3), +takes to size arguments, and that +deallocates the pointer on failure. + +.TP +.BR libsimple_reallocf (3) +Version of +.BR realloc (3) +that deallocates the pointer on failure. + +.TP +.BR libsimple_reallocfn (3), +.TQ +.BR libsimple_vreallocfn (3) +Version of +.BR realloc (3) +that take the product of multiple arguments +as the allocation size, and that +deallocates the pointer on failure. + +.TP +.BR libsimple_aligned_strdup (3), +.TQ +.BR libsimple_ealigned_strdup (3), +.TQ +.BR libsimple_enaligned_strdup (3), +.TQ +.BR libsimple_aligned_strndup (3), +.TQ +.BR libsimple_ealigned_strndup (3), +.TQ +.BR libsimple_enaligned_strndup (3) +Duplicate a string into a new pointer +with a custom alignment. + +.TP +.BR libsimple_aligned_strdupa (3), +.TQ +.BR libsimple_aligned_strndupa (3) +Duplicate a string onto the stack, +with custom alignment. + +.TP +.BR libsimple_aligned_wcsdup (3), +.TQ +.BR libsimple_ealigned_wcsdup (3), +.TQ +.BR libsimple_enaligned_wcsdup (3), +.TQ +.BR libsimple_aligned_wcsndup (3), +.TQ +.BR libsimple_ealigned_wcsndup (3), +.TQ +.BR libsimple_enaligned_wcsndup (3) +Duplicate a wide-character string into a +new pointer with a custom alignment. + +.TP +.BR libsimple_aligned_wcsdupa (3), +.TQ +.BR libsimple_aligned_wcsndupa (3) +Duplicate a wide-character string onto +the stack, with custom alignment. + +.TP +.BR libsimple_aligned_wmemdup (3), +.TQ +.BR libsimple_ealigned_wmemdup (3), +.TQ +.BR libsimple_enaligned_wmemdup (3) +Duplicate an array of wide characters into +a new pointer with a custom alignment. + +.TP +.BR libsimple_aligned_wmemdupa (3) +Duplicate an array of wide characters onto +the stack, with custom alignment. .TP .BR libsimple_asprintf (3), -.RS 0 +.TQ .BR libsimple_vasprintf (3) -.RE -.RS Format a string and allocate a sufficient large string. -.RE .TP .BR libsimple_asprintfa (3), -.RS 0 +.TQ .BR libsimple_vasprintfa (3) -.RE -.RS -Format a string and allocate a sufficient large string onto the stack. -.RE +Format a string and allocate a sufficient large +string onto the stack. .TP .BR libsimple_ecalloc (3), -.RS 0 +.TQ .BR libsimple_encalloc (3) -.RE -.RS Wrappers for .BR calloc (3) that terminate the process on failure. -.RE .TP .BR libsimple_callocn (3), -.RS 0 +.TQ .BR libsimple_ecallocn (3), -.br +.TQ .BR libsimple_encallocn (3), -.br +.TQ .BR libsimple_vcallocn (3), -.br +.TQ .BR libsimple_evcallocn (3), -.br +.TQ .BR libsimple_envcallocn (3) -.RE -.RS Wrappers for .BR calloc (3) that take the product of multiple arguments as the allocation size. -.RE .TP .BR libsimple_cmptimespec (3), -.RS 0 +.TQ .BR libsimple_cmptimeval (3) -.RE -.RS Compare two durations. -.RE .TP .BR libsimple_difftimespec (3), -.RS 0 +.TQ .BR libsimple_difftimeval (3) -.RE -.RS Calculate the difference of two durations. -.RE .TP .BR libsimple_doubletotimespec (3), -.RS 0 +.TQ .BR libsimple_doubletotimeval (3) -.RE -.RS Convert a real value to a duration data structure. -.RE .TP .BR libsimple_eprintf (3), -.RS 0 +.TQ .BR libsimple_enprintf (3), -.br +.TQ .BR libsimple_veprintf (3), -.br +.TQ .BR libsimple_venprintf (3), -.br +.TQ .BR libsimple_weprintf (3), -.br +.TQ .BR libsimple_vweprintf (3) -.RE -.RS Print an error message and (except for the two last functions) terminate the process. -.RE + +.TP +.BR libsimple_gmtime (3), +.TQ +.BR libsimple_egmtime (3), +.TQ +.BR libsimple_engmtime (3) +Get the current time in the UTC timezone, and adjust +for leapsecond insertions and delections. .TP .BR libsimple_getenv_e (3) @@ -372,142 +502,124 @@ Get the value of a non-empty environment value or .TP .BR libsimple_inchrset (3) -.RS 0 +.TQ .BR libsimple_inchrcaseset (3) -.RE -.RS Test if a byte belongs to set of byte. -.RE + +.TP +.BR libsimple_localtime (3), +.TQ +.BR libsimple_elocaltime (3), +.TQ +.BR libsimple_enlocaltime (3) +Get the current time in the UTC timezone, and adjust +for leapsecond insertions and delections. .TP .BR libsimple_emalloc (3), -.RS 0 +.TQ .BR libsimple_enmalloc (3) -.RE -.RS Wrappers for .BR malloc (3) that terminate the process on failure. -.RE .TP .BR libsimple_mallocn (3), -.RS 0 +.TQ .BR libsimple_emallocn (3), -.br +.TQ .BR libsimple_enmallocn (3), -.br +.TQ .BR libsimple_vmallocn (3), -.br +.TQ .BR libsimple_evmallocn (3), -.br +.TQ .BR libsimple_envmallocn (3) -.RE -.RS Wrappers for .BR malloc (3) that take the product of multiple arguments as the allocation size. -.RE .TP .BR libsimple_mallocz (3), -.RS 0 +.TQ .BR libsimple_emallocz (3), -.br +.TQ .BR libsimple_enmallocz (3) -.RE -.RS Wrappers for .BR aligned_alloc (3) that conditionally initialises the memory. -.RE .TP .BR libsimple_malloczn (3), -.RS 0 +.TQ .BR libsimple_emalloczn (3), -.br +.TQ .BR libsimple_enmalloczn (3), -.br +.TQ .BR libsimple_vmalloczn (3), -.br +.TQ .BR libsimple_evmalloczn (3), -.br +.TQ .BR libsimple_envmalloczn (3) -.RE -.RS Wrappers for .BR malloc (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. -.RE .TP .BR libsimple_memalign (3), -.RS 0 +.TQ .BR libsimple_ememalign (3), -.br +.TQ .BR libsimple_enmemalign (3) -.RE -.RS Implementation of the nonstandard .BR memalign (3) function. -.RE .TP .BR libsimple_memalignn (3), -.RS 0 +.TQ .BR libsimple_ememalignn (3), -.br +.TQ .BR libsimple_enmemalignn (3), -.br +.TQ .BR libsimple_vmemalignn (3), -.br +.TQ .BR libsimple_evmemalignn (3), -.br +.TQ .BR libsimple_envmemalignn (3) -.RE -.RS Versions of .BR libsimple_memalign (3) that take the product of multiple arguments as the allocation size. -.RE .TP .BR libsimple_memalignz (3), -.RS 0 +.TQ .BR libsimple_ememalignz (3), -.br +.TQ .BR libsimple_enmemalignz (3) -.RE -.RS Versions of .BR libsimple_memalign (3) that conditionally initialises the memory. -.RE .TP .BR libsimple_memalignzn (3), -.RS 0 +.TQ .BR libsimple_ememalignzn (3), -.br +.TQ .BR libsimple_enmemalignzn (3), -.br +.TQ .BR libsimple_vmemalignzn (3), -.br +.TQ .BR libsimple_evmemalignzn (3), -.br +.TQ .BR libsimple_envmemalignzn (3) -.RE -.RS Versions of .BR libsimple_memalign (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. -.RE .TP .BR libsimple_memcasechr (3) @@ -521,36 +633,27 @@ Case-insensitive version of .TP .BR libsimple_memchr_inv (3), -.RS 0 +.TQ .BR libsimple_memcasechr_inv (3) -.RE -.RS Find first byte that is different from a specified byte. -.RE .TP .BR libsimple_memcmove (3), -.RS 0 +.TQ .BR libsimple_rawmemcmove (3) -.RE -.RS Versions of .BR memccpy (3) and .BR libsimple_rawmemccpy (3) that allow overlap of the arrays. -.RE .TP .BR libsimple_memdup (3), -.RS 0 +.TQ .BR libsimple_ememdup (3), -.br +.TQ .BR libsimple_enmemdup (3) -.RE -.RS Duplicate an array of bytes into a new pointer. -.RE .TP .BR libsimple_memdupa (3) @@ -572,14 +675,12 @@ rather than simple bytes. .TP .BR libsimple_memelemcpy (3), -.RS 0 +.TQ .BR libsimple_rawmemelemcpy (3), -.br +.TQ .BR libsimple_memelemmove (3), -.br +.TQ .BR libsimple_rawmemelemmove (3) -.RE -.RS Versions of .BR memccpy (3), .BR libsimple_rawmemccpy (3), @@ -588,7 +689,6 @@ and .BR libsimple_rawmemcmove (3) that that operate on multibyte units rather than simple bytes. -.RE .TP .BR libsimple_memelemscan (3) @@ -606,40 +706,28 @@ rather than simple bytes. .TP .BR libsimple_memends (3), -.RS 0 +.TQ .BR libsimple_memcaseends (3) -.RE -.RS Check the end if an array of bytes. -.RE .TP .BR libsimple_memeq (3), -.RS 0 +.TQ .BR libsimple_memcaseeq (3) -.RE -.RS Compare two arrays of bytes for equality. -.RE .TP .BR libsimple_memeqlen (3), -.RS 0 +.TQ .BR libsimple_memcaseeqlen (3) -.RE -.RS Get the number if bytes two arrays of bytes have in common at their beginning. -.RE .TP .BR libsimple_memmem (3), -.RS 0 +.TQ .BR libsimple_memcasemem (3) -.RE -.RS Find a substring of bytes in an array of bytes. -.RE .TP .BR libsimple_mempcpy (3) @@ -667,23 +755,17 @@ that returns the end of the written array. .TP .BR libsimple_memrchr (3), -.RS 0 +.TQ .BR libsimple_memrcasechr (3) -.RE -.RS Find the last occurrence of a specific byte in an array of bytes. -.RE .TP .BR libsimple_memrchr_inv (3), -.RS 0 +.TQ .BR libsimple_memrcasechr_inv (3) -.RE -.RS Find the last byte that is different from a specified byte. -.RE .TP .BR libsimple_memrelem_inv (3) @@ -709,46 +791,34 @@ another element. .TP .BR libsimple_memreqlen (3), -.RS 0 +.TQ .BR libsimple_memrcaseeqlen (3) -.RE -.RS Get the number if bytes two arrays of bytes have in common at their end. -.RE .TP .BR libsimple_memrmem (3), -.RS 0 +.TQ .BR libsimple_memrcasemem (3) -.RE -.RS Find the last occurrence of string of byte in an array of bytes. -.RE .TP .BR libsimple_memscan (3), -.RS 0 +.TQ .BR libsimple_memcasescan (3) -.RE -.RS Versions of .BR memchr (3) and .BR libsimple_memcasechr (3) that return the end of the array if the byte is not found. -.RE .TP .BR libsimple_memscan_inv (3), -.RS 0 +.TQ .BR libsimple_memcasescan_inv (3) -.RE -.RS Skip leading bytes. -.RE .TP .BR libsimple_memsetelem (3) @@ -756,171 +826,138 @@ Fill en array. .TP .BR libsimple_memstarts (3), -.RS 0 +.TQ .BR libsimple_memcasestarts (3) -.RE -.RS Check the beginning if an array of bytes. -.RE .TP .BR libsimple_multimespec (3), -.RS 0 +.TQ .BR libsimple_multimeval (3) -.RE -.RS Multiple a duration with an integer. -.RE .TP .BR libsimple_eposix_memalign (3), -.RS 0 +.TQ .BR libsimple_enposix_memalign (3) -.RE -.RS Wrappers for .BR posix_memalign (3) that terminate the process on failure. -.RE .TP .BR libsimple_posix_memalignn (3), -.RS 0 +.TQ .BR libsimple_eposix_memalignn (3), -.br +.TQ .BR libsimple_enposix_memalignn (3), -.br +.TQ .BR libsimple_vposix_memalignn (3), -.br +.TQ .BR libsimple_evposix_memalignn (3), -.br +.TQ .BR libsimple_envposix_memalignn (3) -.RE -.RS Wrappers for .BR posix_memalign (3) that take the product of multiple arguments as the allocation size. -.RE .TP .BR libsimple_posix_memalignz (3), -.RS 0 +.TQ .BR libsimple_eposix_memalignz (3), -.br +.TQ .BR libsimple_enposix_memalignz (3) -.RE -.RS Wrappers for .BR posix_memalign (3) that conditionally initialises the memory. -.RE .TP .BR libsimple_posix_memalignzn (3), -.RS 0 +.TQ .BR libsimple_eposix_memalignzn (3), -.br +.TQ .BR libsimple_enposix_memalignzn (3), -.br +.TQ .BR libsimple_vposix_memalignzn (3), -.br +.TQ .BR libsimple_evposix_memalignzn (3), -.br +.TQ .BR libsimple_envposix_memalignzn (3) -.RE -.RS Wrappers for .BR posix_memalign (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. -.RE .TP .BR libsimple_putenvf (3), -.RS 0 +.TQ .BR libsimple_eputenvf (3), -.br +.TQ .BR libsimple_enputenvf (3), -.br +.TQ .BR libsimple_vputenvf (3), -.br +.TQ .BR libsimple_evputenvf (3), -.br +.TQ .BR libsimple_envputenvf (3) -.RE -.RS Verion of .BR putenv (3) that formats the string. -.RE .TP .BR libsimple_pvalloc (3), -.RS 0 +.TQ .BR libsimple_epvalloc (3), -.br +.TQ .BR libsimple_enpvalloc (3) -.RE -.RS Implementation of the nonstandard .BR pvalloc (3) function. -.RE .TP .BR libsimple_pvallocn (3), -.RS 0 +.TQ .BR libsimple_epvallocn (3), -.br +.TQ .BR libsimple_enpvallocn (3), -.br +.TQ .BR libsimple_vpvallocn (3), -.br +.TQ .BR libsimple_evpvallocn (3), -.br +.TQ .BR libsimple_envpvallocn (3) -.RE -.RS Versions of .BR libsimple_pvalloc (3) that take the product of multiple arguments as the allocation size. -.RE .TP .BR libsimple_pvallocz (3), -.RS 0 +.TQ .BR libsimple_epvallocz (3), -.br +.TQ .BR libsimple_enpvallocz (3) -.RE -.RS Versions of .BR libsimple_pvalloc (3) that conditionally initialises the memory. -.RE .TP .BR libsimple_pvalloczn (3), -.RS 0 +.TQ .BR libsimple_epvalloczn (3), -.br +.TQ .BR libsimple_enpvalloczn (3), -.br +.TQ .BR libsimple_vpvalloczn (3), -.br +.TQ .BR libsimple_evpvalloczn (3), -.br +.TQ .BR libsimple_envpvalloczn (3) -.RE -.RS Versions of .BR libsimple_pvalloc (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. -.RE .TP .BR libsimple_rawmemccpy (3) @@ -931,25 +968,19 @@ byte actually exists in the array. .TP .BR libsimple_rawmemchr (3), -.RS 0 +.TQ .BR libsimple_rawmemcasechr (3) -.RE -.RS Find the first occurrence of a specific byte in an array of bytes, with the optimising assumption that it actually exists in the array. -.RE .TP .BR libsimple_rawmemchr_inv (3), -.RS 0 +.TQ .BR libsimple_rawmemcasechr_inv (3) -.RE -.RS Find first byte that is different from a specified byte, with the optimising assumption that such a byte actually exists in the array. -.RE .TP .BR libsimple_rawmemelem (3) @@ -967,21 +998,16 @@ element actually exists in the array. .TP .BR libsimple_rawmemrchr (3) -.RS 0 +.TQ .BR libsimple_rawmemrcasechr (3) -.RE -.RS Find the last occurrence of a specific byte in an array of bytes, with the optimising assumption that it actually exists in the array. -.RE .TP .BR libsimple_rawmemrchr_inv (3), -.RS 0 +.TQ .BR libsimple_rawmemrcasechr_inv (3) -.RE -.RS Find last byte that is different from a specified byte, with the optimising assumption that such a byte actually exists in the array. @@ -999,38 +1025,31 @@ Version of .BR libsimple_memrelem_inv (3), with the optimising assumption that such a element actually exists in the array. -.RE .TP .BR libsimple_erealloc (3), -.RS 0 +.TQ .BR libsimple_enrealloc (3) -.RE -.RS Wrappers for .BR realloc (3) that terminate the process on failure. -.RE .TP .BR libsimple_reallocn (3), -.RS 0 +.TQ .BR libsimple_ereallocn (3), -.br +.TQ .BR libsimple_enreallocn (3), -.br +.TQ .BR libsimple_vreallocn (3), -.br +.TQ .BR libsimple_evreallocn (3), -.br +.TQ .BR libsimple_envreallocn (3) -.RE -.RS Wrappers for .BR realloc (3) that take the product of multiple arguments as the allocation size. -.RE .TP .BR libsimple_strcasechr (3) @@ -1044,38 +1063,30 @@ Case-insensitive version of .TP .BR libsimple_strccpy (3), -.RS 0 +.TQ .BR libsimple_strnccpy (3) -.RE -.RS Copy a string but stop after the first occurrence of a specified character. -.RE .TP .BR libsimple_strchr_inv (3), -.RS 0 +.TQ .BR libsimple_strcasechr_inv (3), -.br +.TQ .BR libsimple_strnchr_inv (3), -.br +.TQ .BR libsimple_strncasechr_inv (3) -.RE -.RS Find the first character that is different from a specified character. -.RE .TP .BR libsimple_strchrnul (3), -.RS 0 +.TQ .BR libsimple_strcasechrnul (3), -.br +.TQ .BR libsimple_strnchrnul (3), -.br +.TQ .BR libsimple_strncasechrnul (3) -.RE -.RS Versions of .BR strchr (3), .BR libsimple_strcasechr (3), @@ -1084,41 +1095,32 @@ and .BR libsimple_strncasechr (3) that return the end of the string if the byte is not found. -.RE .TP .BR libsimple_strchrnul_inv (3), -.RS 0 +.TQ .BR libsimple_strcasechrnul_inv (3), -.br +.TQ .BR libsimple_strnchrnul_inv (3), -.br +.TQ .BR libsimple_strncasechrnul_inv (3) -.RE -.RS Skip leading characters. -.RE .TP .BR libsimple_strcmove (3), -.RS 0 +.TQ .BR libsimple_strncmove (3) -.RE -.RS Move a string but stop after the first occurrence of a specified character. -.RE .TP .BR libsimple_strcmpnul (3), -.RS 0 +.TQ .BR libsimple_strcasecmpnul (3), -.br +.TQ .BR libsimple_strncmpnul (3), -.br +.TQ .BR libsimple_strncasecmpnul (3) -.RE -.RS Versions of .BR strcmp (3), .BR strcasecmp (3), @@ -1127,158 +1129,124 @@ and .BR strncasecmp (3) that support .BR NULL . -.RE .TP .BR libsimple_estrdup (3), -.RS 0 +.TQ .BR libsimple_enstrdup (3), -.br +.TQ .BR libsimple_estrndup (3), -.br +.TQ .BR libsimple_enstrndup (3) -.RE -.RS Wrappers of .BR strdup (3) and .BR strndup (3) that terminate the process on failure. -.RE .TP .BR libsimple_strdupa (3), -.RS 0 +.TQ .BR libsimple_strndupa (3) -.RE -.RS Versions of .BR strdup (3), and .BR strndup (3) that allocate the string on the stack. -.RE .TP .BR libsimple_strend (3), -.RS 0 +.TQ .BR libsimple_strnend (3) -.RE -.RS Locate end of string. -.RE .TP .BR libsimple_strends (3), -.RS 0 +.TQ .BR libsimple_strcaseends (3), -.br +.TQ .BR libsimple_strnends (3), -.br +.TQ .BR libsimple_strncaseends (3) -.RE -.RS Check the end if a string. -.RE .TP .BR libsimple_streq (3), -.RS 0 +.TQ .BR libsimple_strcaseeq (3), -.br +.TQ .BR libsimple_strneq (3), -.br +.TQ .BR libsimple_strncaseeq (3) -.RE -.RS Compare two strings for equality. -.RE .TP .BR libsimple_streqlen (3), -.RS 0 +.TQ .BR libsimple_strcaseeqlen (3), -.br +.TQ .BR libsimple_strneqlen (3), -.br +.TQ .BR libsimple_strncaseeqlen (3) -.RE -.RS Get the number if bytes two strings have in common at their beginning. -.RE .TP .BR libsimple_streqnul (3), -.RS 0 +.TQ .BR libsimple_strcaseeqnul (3), -.br +.TQ .BR libsimple_strneqnul (3), -.br +.TQ .BR libsimple_strncaseeqnul (3) -.RE -.RS Verions of .BR libsimple_streq (3) and .BR libsimple_strcaseeq (3) that support .BR NULL . -.RE .TP .BR libsimple_strisutf8 (3), -.RS 0 +.TQ .BR libsimple_strnisutf8 (3), -.br +.TQ .BR libsimple_memisutf8 (3) -.RE -.RS Check if a string is valid UTF-8. -.RE .TP .BR libsimple_strmove (3), -.RS 0 +.TQ .BR libsimple_strnmove (3), -.br +.TQ .BR libsimple_stpmove (3), -.br +.TQ .BR libsimple_stpnmove (3) -.RE -.RS Versions of .BR memmove (3) and .BR libsimple_mempmove (3) that moves an entire string. -.RE .TP .BR libsimple_strnchr (3), -.RS 0 +.TQ .BR libsimple_strncasechr (3) -.RE -.RS Versions of .BR strchr (3) and .BR libsimple_strcasechr (3) that support strings without NUL-termination. -.RE .TP .BR libsimple_strnstr (3), -.RS 0 +.TQ .BR libsimple_strncasestr (3) -.RE -.RS Versions of .BR strstr (3) and .BR libsimple_strcasestr (3) that support strings without NUL-termination. -.RE .TP .BR libsimple_strrcasechr (3) @@ -1287,260 +1255,243 @@ Case-insensitive version of the .TP .BR libsimple_strrchrnul_inv (3), -.RS 0 +.TQ .BR libsimple_strrcasechrnul_inv (3), -.br +.TQ .BR libsimple_strrnchrnul_inv (3), -.br +.TQ .BR libsimple_strrncasechrnul_inv (3) -.RE -.RS Skip trailing characters. -.RE .TP .BR libsimple_strreplace (3), -.RS 0 +.TQ .BR libsimple_strnreplace (3) -.RE -.RS Replace all occurrences of a character with another character. -.RE .TP .BR libsimple_strreqlen (3), -.RS 0 +.TQ .BR libsimple_strrcaseeqlen (3), -.br +.TQ .BR libsimple_strrneqlen (3), -.br +.TQ .BR libsimple_strrncaseeqlen (3) -.RE -.RS Get the number if bytes two strings have in common at their end. -.RE .TP .BR libsimple_strrnchr (3), -.RS 0 +.TQ .BR libsimple_strrncasechr (3) -.RE -.RS Versions of .BR strrchr (3) and .BR libsimple_strrcasechr (3) that support strings without NUL-termination. -.RE .TP .BR libsimple_strrstr (3), -.RS 0 +.TQ .BR libsimple_strrcasestr (3), -.br +.TQ .BR libsimple_strrnstr (3), -.br +.TQ .BR libsimple_strrncasestr (3) -.RE -.RS Find the last occurrence of a substring. -.RE .TP .BR libsimple_stpnset (3), -.RS 0 +.TQ .BR libsimple_stpset (3), -.br +.TQ .BR libsimple_strnset (3), -.br +.TQ .BR libsimple_strset (3) -.RE -.RS Fill a string a with character. -.RE .TP .BR libsimple_strstarts (3), -.RS 0 +.TQ .BR libsimple_strcasestarts (3), -.br +.TQ .BR libsimple_strnstarts (3), -.br +.TQ .BR libsimple_strncasestarts (3) -.RE -.RS Check the beginning if a string. -.RE .TP .BR libsimple_strtolower (3), -.RS 0 +.TQ .BR libsimple_strntolower (3), -.br +.TQ .BR libsimple_memtolower (3), -.br +.TQ .BR libsimple_stptolower (3), -.br +.TQ .BR libsimple_stpntolower (3), -.br +.TQ .BR libsimple_memptolower (3) -.RE -.RS Convert a string to lower case. -.RE .TP .BR libsimple_strtotimespec (3), -.RS 0 +.TQ .BR libsimple_strtotimeval (3) -.RE -.RS Convert a string, with a real value representing a number of seconds, to a duration. -.RE .TP .BR libsimple_strtoupper (3), -.RS 0 +.TQ .BR libsimple_strntoupper (3), -.br +.TQ .BR libsimple_memtoupper (3), -.br +.TQ .BR libsimple_stptoupper (3), -.br +.TQ .BR libsimple_stpntoupper (3), -.br +.TQ .BR libsimple_memptoupper (3) -.RE -.RS Convert a string to upper case. -.RE .TP .BR libsimple_sumtimespec (3), -.RS 0 +.TQ .BR libsimple_sumtimeval (3) -.RE -.RS Calculate the sum of two durations. -.RE .TP .BR libsimple_timespec2timeval (3), -.RS 0 +.TQ .BR libsimple_timeval2timespec (3) -.RE -.RS Convert a duration between to storage formats. -.RE .TP .BR libsimple_timespectodouble (3), -.RS 0 +.TQ .BR libsimple_timevaltodouble (3) -.RE -.RS Convert a duration stored in a duration specific format to a double. -.RE .TP .BR libsimple_timespectostr (3), -.RS 0 +.TQ .BR libsimple_timevaltostr (3), -.br +.TQ .BR libsimple_minimise_number_string (3) -.RE -.RS Convert a duration stored in a duration specific format to a string. -.RE .TP .BR libsimple_unlist (3), -.RS 0 +.TQ .BR LIBSIMPLE_UNLIST (3) -.RE -.RS Remove an item from an array without changing the order of the items in the array. -.RE .TP .BR libsimple_valloc (3), -.RS 0 +.TQ .BR libsimple_evalloc (3), -.br +.TQ .BR libsimple_envalloc (3) -.RE -.RS Implementation of the nonstandard .BR valloc (3) function. -.RE .TP .BR libsimple_vallocn (3), -.RS 0 +.TQ .BR libsimple_evallocn (3), -.br +.TQ .BR libsimple_envallocn (3), -.br +.TQ .BR libsimple_vvallocn (3), -.br +.TQ .BR libsimple_evvallocn (3), -.br +.TQ .BR libsimple_envvallocn (3) -.RE -.RS Versions of .BR libsimple_valloc (3) that take the product of multiple arguments as the allocation size. -.RE .TP .BR libsimple_vallocz (3), -.RS 0 +.TQ .BR libsimple_evallocz (3), -.br +.TQ .BR libsimple_envallocz (3) -.RE -.RS Versions of .BR libsimple_valloc (3) that conditionally initialises the memory. -.RE .TP .BR libsimple_valloczn (3), -.RS 0 +.TQ .BR libsimple_evalloczn (3), -.br +.TQ .BR libsimple_envalloczn (3), -.br +.TQ .BR libsimple_vvalloczn (3), -.br +.TQ .BR libsimple_evvalloczn (3), -.br +.TQ .BR libsimple_envvalloczn (3) -.RE -.RS Versions of .BR libsimple_valloc (3) that take the product of multiple arguments as the allocation size and conditionally initialises the memory. -.RE + +.TP +.BR libsimple_ewcsdup (3), +.TQ +.BR libsimple_enwcsdup (3), +.TQ +.BR libsimple_wcsndup (3), +.TQ +.BR libsimple_ewcsndup (3), +.TQ +.BR libsimple_enwcsndup (3) +Duplicate a wide-character string. + +.TP +.BR libsimple_wcsdupa (3), +.TQ +.BR libsimple_wcsndupa (3) +Versions of +.BR wcsdup (3), +and +.BR libsimple_wcsndup (3) +that allocate the string on the stack. + +.TP +.BR libsimple_wmemdup (3), +.TQ +.BR libsimple_ewmemdup (3), +.TQ +.BR libsimple_enwmemdup (3) +Duplicate an array of wide character. + +.TP +.BR libsimple_wmemdupa (3) +Version of +.BR libsimple_wmemdup (3) +that allocate the string on the stack. .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH SEE ALSO .BR libsimple-arg.h (0) diff --git a/man3/ELEMSOF.3libsimple b/man3/ELEMSOF.3libsimple index b40d563..9391607 100644 --- a/man3/ELEMSOF.3libsimple +++ b/man3/ELEMSOF.3libsimple @@ -1,6 +1,7 @@ -.TH ELEMSOF 3 2018-11-05 libsimple +.TH ELEMSOF 3 libsimple .SH NAME ELEMSOF \- get the size of an array + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ ELEMSOF \- get the size of an array # define ELEMSOF(arr) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR ELEMSOF () @@ -18,17 +20,24 @@ is an array (not a pointer) and expands, as a constant expression. The type of the expression the macro expands to is .BR size_t . + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR STRLEN (3libsimple) diff --git a/man3/INTSTRLEN.3libsimple b/man3/INTSTRLEN.3libsimple index 63c1485..9477eb6 100644 --- a/man3/INTSTRLEN.3libsimple +++ b/man3/INTSTRLEN.3libsimple @@ -1,6 +1,7 @@ -.TH INTSTRLEN 3 2018-11-05 libsimple +.TH INTSTRLEN 3 libsimple .SH NAME INTSTRLEN \- get the maximum length of an integer string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ INTSTRLEN \- get the maximum length of an integer string # define INTSTRLEN(type) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR INTSTRLEN () @@ -29,18 +31,25 @@ signed or unsigned, and can be slightly larger than necessary, it can however not be smaller. (For integers up to 64 bits, the result is only off by one for signed 64-bit integer types.) + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR TYPE_MIN (3libsimple) .BR TYPE_MAX (3libsimple) diff --git a/man3/MAX.3libsimple b/man3/MAX.3libsimple index e4a4d62..ac374d0 100644 --- a/man3/MAX.3libsimple +++ b/man3/MAX.3libsimple @@ -1,6 +1,7 @@ -.TH MAX 3 2018-11-05 libsimple +.TH MAX 3 libsimple .SH NAME MAX \- get the greater of two values + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ MAX \- get the greater of two values # define MAX(a, b) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR MAX () @@ -30,28 +32,37 @@ and .I b parameters are constants expressions, the return value is also a constant expression. + .SH RETURN VALUE The .BR MAX () macro returns to the greater value. + .SH ERRORS The .BR libsimple_close () function fail for the reasons specified for the .BR close (3) function. + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR MIN (3libsimple), .BR MIN3 (3libsimple), diff --git a/man3/MAX3.3libsimple b/man3/MAX3.3libsimple index 103169a..d0171f8 100644 --- a/man3/MAX3.3libsimple +++ b/man3/MAX3.3libsimple @@ -1,6 +1,7 @@ -.TH MAX3 3 2018-11-05 libsimple +.TH MAX3 3 libsimple .SH NAME MAX3 \- get the greatest of three values + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ MAX3 \- get the greatest of three values # define MAX3(a, b, c) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR MAX3 () @@ -33,28 +35,37 @@ and .I c parameters are constants expressions, the return value is also a constant expression. + .SH RETURN VALUE The .BR MAX3 () macro returns to the greatest of value. + .SH ERRORS The .BR libsimple_close () function fail for the reasons specified for the .BR close (3) function. + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR MIN (3libsimple), .BR MAX (3libsimple), diff --git a/man3/MIN.3libsimple b/man3/MIN.3libsimple index d88216e..552b334 100644 --- a/man3/MIN.3libsimple +++ b/man3/MIN.3libsimple @@ -1,6 +1,7 @@ -.TH MIN 3 2018-11-05 libsimple +.TH MIN 3 libsimple .SH NAME MIN \- get the lesser of two values + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ MIN \- get the lesser of two values # define MIN(a, b) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR MIN () @@ -30,28 +32,37 @@ and .I b parameters are constants expressions, the return value is also a constant expression. + .SH RETURN VALUE The .BR MIN () macro returns to the lesser value. + .SH ERRORS The .BR libsimple_close () function fail for the reasons specified for the .BR close (3) function. + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR MAX (3libsimple), .BR MIN3 (3libsimple), diff --git a/man3/MIN3.3libsimple b/man3/MIN3.3libsimple index c915781..19eeae9 100644 --- a/man3/MIN3.3libsimple +++ b/man3/MIN3.3libsimple @@ -1,6 +1,7 @@ -.TH MIN3 3 2018-11-05 libsimple +.TH MIN3 3 libsimple .SH NAME MIN3 \- get the smallest of three values + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ MIN3 \- get the smallest of three values # define MIN3(a, b, c) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR MIN3 () @@ -33,28 +35,37 @@ and .I c parameters are constants expressions, the return value is also a constant expression. + .SH RETURN VALUE The .BR MIN3 () macro returns to the smallest of value. + .SH ERRORS The .BR libsimple_close () function fail for the reasons specified for the .BR close (3) function. + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR MIN (3libsimple), .BR MAX (3libsimple), diff --git a/man3/STRLEN.3libsimple b/man3/STRLEN.3libsimple index 06ccecf..4d48e66 100644 --- a/man3/STRLEN.3libsimple +++ b/man3/STRLEN.3libsimple @@ -1,6 +1,7 @@ -.TH STRLEN 3 2018-11-05 libsimple +.TH STRLEN 3 libsimple .SH NAME STRLEN \- get the length of a string literal + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ STRLEN \- get the length of a string literal # define STRLEN(str) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR STRLEN () @@ -25,17 +27,24 @@ however it is not suitable for .BR #if . The type of the expression the macro expands to is .BR size_t . + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR ELEMSOF (3libsimple) diff --git a/man3/TYPE_MAX.3libsimple b/man3/TYPE_MAX.3libsimple index c132ec9..158f189 100644 --- a/man3/TYPE_MAX.3libsimple +++ b/man3/TYPE_MAX.3libsimple @@ -1,6 +1,7 @@ -.TH TYPE_MAX 3 2018-11-05 libsimple +.TH TYPE_MAX 3 libsimple .SH NAME TYPE_MAX \- get largest value for an integer type + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ TYPE_MAX \- get largest value for an integer type # define TYPE_MAX(type) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR TYPE_MAX () @@ -60,18 +62,25 @@ macro, for the maximum value for multiple integer types: .BR USECONDS_MAX , and .BR U_QUAD_MAX . + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR TYPE_MIN (3libsimple) .BR INTSTRLEN (3libsimple) diff --git a/man3/TYPE_MIN.3libsimple b/man3/TYPE_MIN.3libsimple index 6720465..0ec8fac 100644 --- a/man3/TYPE_MIN.3libsimple +++ b/man3/TYPE_MIN.3libsimple @@ -1,6 +1,7 @@ -.TH TYPE_MIN 3 2018-11-05 libsimple +.TH TYPE_MIN 3 libsimple .SH NAME TYPE_MIN \- get smallest value for an integer type + .SH SYNOPSIS .nf #include <libsimple.h> @@ -9,6 +10,7 @@ TYPE_MIN \- get smallest value for an integer type # define TYPE_MIN(type) /* implementation omitted */ #endif .fi + .SH DESCRIPTION The .BR TYPE_MIN () @@ -60,18 +62,25 @@ macro, for the minimum value for multiple integer types: .BR USECONDS_MIN , and .BR U_QUAD_MIN . + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR TYPE_MAX (3libsimple) .BR INTSTRLEN (3libsimple) diff --git a/man3/aligned_realloc.3libsimple b/man3/aligned_realloc.3libsimple new file mode 120000 index 0000000..45a72de --- /dev/null +++ b/man3/aligned_realloc.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_realloc.3
\ No newline at end of file diff --git a/man3/aligned_reallocarray.3libsimple b/man3/aligned_reallocarray.3libsimple new file mode 120000 index 0000000..fb3f8b9 --- /dev/null +++ b/man3/aligned_reallocarray.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_reallocarray.3
\ No newline at end of file diff --git a/man3/aligned_reallocarrayf.3libsimple b/man3/aligned_reallocarrayf.3libsimple new file mode 120000 index 0000000..8670b37 --- /dev/null +++ b/man3/aligned_reallocarrayf.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_reallocarrayf.3
\ No newline at end of file diff --git a/man3/aligned_reallocf.3libsimple b/man3/aligned_reallocf.3libsimple new file mode 120000 index 0000000..656041f --- /dev/null +++ b/man3/aligned_reallocf.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_reallocf.3
\ No newline at end of file diff --git a/man3/aligned_reallocfn.3libsimple b/man3/aligned_reallocfn.3libsimple new file mode 120000 index 0000000..73c5a60 --- /dev/null +++ b/man3/aligned_reallocfn.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_reallocfn.3
\ No newline at end of file diff --git a/man3/aligned_reallocn.3libsimple b/man3/aligned_reallocn.3libsimple new file mode 120000 index 0000000..3a6b8aa --- /dev/null +++ b/man3/aligned_reallocn.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_reallocn.3
\ No newline at end of file diff --git a/man3/aligned_strdup.3libsimple b/man3/aligned_strdup.3libsimple new file mode 120000 index 0000000..005dc6f --- /dev/null +++ b/man3/aligned_strdup.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_strdup.3
\ No newline at end of file diff --git a/man3/aligned_strdupa.3libsimple b/man3/aligned_strdupa.3libsimple new file mode 120000 index 0000000..1cc07db --- /dev/null +++ b/man3/aligned_strdupa.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_strdupa.3
\ No newline at end of file diff --git a/man3/aligned_strndup.3libsimple b/man3/aligned_strndup.3libsimple new file mode 120000 index 0000000..4be204c --- /dev/null +++ b/man3/aligned_strndup.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_strndup.3
\ No newline at end of file diff --git a/man3/aligned_strndupa.3libsimple b/man3/aligned_strndupa.3libsimple new file mode 120000 index 0000000..40eec87 --- /dev/null +++ b/man3/aligned_strndupa.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_strndupa.3
\ No newline at end of file diff --git a/man3/aligned_wcsdup.3libsimple b/man3/aligned_wcsdup.3libsimple new file mode 120000 index 0000000..cb194a0 --- /dev/null +++ b/man3/aligned_wcsdup.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_wcsdup.3
\ No newline at end of file diff --git a/man3/aligned_wcsdupa.3libsimple b/man3/aligned_wcsdupa.3libsimple new file mode 120000 index 0000000..1e2225d --- /dev/null +++ b/man3/aligned_wcsdupa.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_wcsdupa.3
\ No newline at end of file diff --git a/man3/aligned_wcsndup.3libsimple b/man3/aligned_wcsndup.3libsimple new file mode 120000 index 0000000..043dad0 --- /dev/null +++ b/man3/aligned_wcsndup.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_wcsndup.3
\ No newline at end of file diff --git a/man3/aligned_wcsndupa.3libsimple b/man3/aligned_wcsndupa.3libsimple new file mode 120000 index 0000000..d24f553 --- /dev/null +++ b/man3/aligned_wcsndupa.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_wcsndupa.3
\ No newline at end of file diff --git a/man3/aligned_wmemdup.3libsimple b/man3/aligned_wmemdup.3libsimple new file mode 120000 index 0000000..264a7e1 --- /dev/null +++ b/man3/aligned_wmemdup.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_wmemdup.3
\ No newline at end of file diff --git a/man3/aligned_wmemdupa.3libsimple b/man3/aligned_wmemdupa.3libsimple new file mode 120000 index 0000000..567563a --- /dev/null +++ b/man3/aligned_wmemdupa.3libsimple @@ -0,0 +1 @@ +libsimple_aligned_wmemdupa.3
\ No newline at end of file diff --git a/man3/ealigned_realloc.3libsimple b/man3/ealigned_realloc.3libsimple new file mode 120000 index 0000000..dbb92ec --- /dev/null +++ b/man3/ealigned_realloc.3libsimple @@ -0,0 +1 @@ +libsimple_ealigned_realloc.3
\ No newline at end of file diff --git a/man3/ealigned_reallocarray.3libsimple b/man3/ealigned_reallocarray.3libsimple new file mode 120000 index 0000000..2d830d6 --- /dev/null +++ b/man3/ealigned_reallocarray.3libsimple @@ -0,0 +1 @@ +libsimple_ealigned_reallocarray.3
\ No newline at end of file diff --git a/man3/ealigned_reallocn.3libsimple b/man3/ealigned_reallocn.3libsimple new file mode 120000 index 0000000..d61ddf8 --- /dev/null +++ b/man3/ealigned_reallocn.3libsimple @@ -0,0 +1 @@ +libsimple_ealigned_reallocn.3
\ No newline at end of file diff --git a/man3/ealigned_strdup.3libsimple b/man3/ealigned_strdup.3libsimple new file mode 120000 index 0000000..eb5cf8d --- /dev/null +++ b/man3/ealigned_strdup.3libsimple @@ -0,0 +1 @@ +libsimple_ealigned_strdup.3
\ No newline at end of file diff --git a/man3/ealigned_strndup.3libsimple b/man3/ealigned_strndup.3libsimple new file mode 120000 index 0000000..50b1c4a --- /dev/null +++ b/man3/ealigned_strndup.3libsimple @@ -0,0 +1 @@ +libsimple_ealigned_strndup.3
\ No newline at end of file diff --git a/man3/ealigned_wcsdup.3libsimple b/man3/ealigned_wcsdup.3libsimple new file mode 120000 index 0000000..01ef193 --- /dev/null +++ b/man3/ealigned_wcsdup.3libsimple @@ -0,0 +1 @@ +libsimple_ealigned_wcsdup.3
\ No newline at end of file diff --git a/man3/ealigned_wcsndup.3libsimple b/man3/ealigned_wcsndup.3libsimple new file mode 120000 index 0000000..87cfe1b --- /dev/null +++ b/man3/ealigned_wcsndup.3libsimple @@ -0,0 +1 @@ +libsimple_ealigned_wcsndup.3
\ No newline at end of file diff --git a/man3/ealigned_wmemdup.3libsimple b/man3/ealigned_wmemdup.3libsimple new file mode 120000 index 0000000..0029c68 --- /dev/null +++ b/man3/ealigned_wmemdup.3libsimple @@ -0,0 +1 @@ +libsimple_ealigned_wmemdup.3
\ No newline at end of file diff --git a/man3/enaligned_realloc.3libsimple b/man3/enaligned_realloc.3libsimple new file mode 120000 index 0000000..2d95e24 --- /dev/null +++ b/man3/enaligned_realloc.3libsimple @@ -0,0 +1 @@ +libsimple_enaligned_realloc.3
\ No newline at end of file diff --git a/man3/enaligned_reallocarray.3libsimple b/man3/enaligned_reallocarray.3libsimple new file mode 120000 index 0000000..1b2e0f8 --- /dev/null +++ b/man3/enaligned_reallocarray.3libsimple @@ -0,0 +1 @@ +libsimple_enaligned_reallocarray.3
\ No newline at end of file diff --git a/man3/enaligned_reallocn.3libsimple b/man3/enaligned_reallocn.3libsimple new file mode 120000 index 0000000..ce4ea5d --- /dev/null +++ b/man3/enaligned_reallocn.3libsimple @@ -0,0 +1 @@ +libsimple_enaligned_reallocn.3
\ No newline at end of file diff --git a/man3/enaligned_strdup.3libsimple b/man3/enaligned_strdup.3libsimple new file mode 120000 index 0000000..83e40a2 --- /dev/null +++ b/man3/enaligned_strdup.3libsimple @@ -0,0 +1 @@ +libsimple_enaligned_strdup.3
\ No newline at end of file diff --git a/man3/enaligned_strndup.3libsimple b/man3/enaligned_strndup.3libsimple new file mode 120000 index 0000000..2b79c93 --- /dev/null +++ b/man3/enaligned_strndup.3libsimple @@ -0,0 +1 @@ +libsimple_enaligned_strndup.3
\ No newline at end of file diff --git a/man3/enaligned_wcsdup.3libsimple b/man3/enaligned_wcsdup.3libsimple new file mode 120000 index 0000000..c52f2c8 --- /dev/null +++ b/man3/enaligned_wcsdup.3libsimple @@ -0,0 +1 @@ +libsimple_enaligned_wcsdup.3
\ No newline at end of file diff --git a/man3/enaligned_wcsndup.3libsimple b/man3/enaligned_wcsndup.3libsimple new file mode 120000 index 0000000..f5772b1 --- /dev/null +++ b/man3/enaligned_wcsndup.3libsimple @@ -0,0 +1 @@ +libsimple_enaligned_wcsndup.3
\ No newline at end of file diff --git a/man3/enaligned_wmemdup.3libsimple b/man3/enaligned_wmemdup.3libsimple new file mode 120000 index 0000000..07321e1 --- /dev/null +++ b/man3/enaligned_wmemdup.3libsimple @@ -0,0 +1 @@ +libsimple_enaligned_wmemdup.3
\ No newline at end of file diff --git a/man3/enreallocarray.3libsimple b/man3/enreallocarray.3libsimple new file mode 120000 index 0000000..5f83973 --- /dev/null +++ b/man3/enreallocarray.3libsimple @@ -0,0 +1 @@ +libsimple_enreallocarray.3
\ No newline at end of file diff --git a/man3/envaligned_reallocn.3libsimple b/man3/envaligned_reallocn.3libsimple new file mode 120000 index 0000000..36205a3 --- /dev/null +++ b/man3/envaligned_reallocn.3libsimple @@ -0,0 +1 @@ +libsimple_envaligned_reallocn.3
\ No newline at end of file diff --git a/man3/enwcsdup.3libsimple b/man3/enwcsdup.3libsimple new file mode 120000 index 0000000..85a85a6 --- /dev/null +++ b/man3/enwcsdup.3libsimple @@ -0,0 +1 @@ +libsimple_enwcsdup.3
\ No newline at end of file diff --git a/man3/enwcsndup.3libsimple b/man3/enwcsndup.3libsimple new file mode 120000 index 0000000..801d72f --- /dev/null +++ b/man3/enwcsndup.3libsimple @@ -0,0 +1 @@ +libsimple_enwcsndup.3
\ No newline at end of file diff --git a/man3/enwmemdup.3libsimple b/man3/enwmemdup.3libsimple new file mode 120000 index 0000000..b2983f6 --- /dev/null +++ b/man3/enwmemdup.3libsimple @@ -0,0 +1 @@ +libsimple_enwmemdup.3
\ No newline at end of file diff --git a/man3/ereallocarray.3libsimple b/man3/ereallocarray.3libsimple new file mode 120000 index 0000000..3e43375 --- /dev/null +++ b/man3/ereallocarray.3libsimple @@ -0,0 +1 @@ +libsimple_ereallocarray.3
\ No newline at end of file diff --git a/man3/evaligned_reallocn.3libsimple b/man3/evaligned_reallocn.3libsimple new file mode 120000 index 0000000..b7dde1d --- /dev/null +++ b/man3/evaligned_reallocn.3libsimple @@ -0,0 +1 @@ +libsimple_evaligned_reallocn.3
\ No newline at end of file diff --git a/man3/ewcsdup.3libsimple b/man3/ewcsdup.3libsimple new file mode 120000 index 0000000..5c84dbe --- /dev/null +++ b/man3/ewcsdup.3libsimple @@ -0,0 +1 @@ +libsimple_ewcsdup.3
\ No newline at end of file diff --git a/man3/ewcsndup.3libsimple b/man3/ewcsndup.3libsimple new file mode 120000 index 0000000..09026d6 --- /dev/null +++ b/man3/ewcsndup.3libsimple @@ -0,0 +1 @@ +libsimple_ewcsndup.3
\ No newline at end of file diff --git a/man3/ewmemdup.3libsimple b/man3/ewmemdup.3libsimple new file mode 120000 index 0000000..3cbe8cf --- /dev/null +++ b/man3/ewmemdup.3libsimple @@ -0,0 +1 @@ +libsimple_ewmemdup.3
\ No newline at end of file diff --git a/man3/libsimple_aligned_allocz.3 b/man3/libsimple_aligned_allocz.3 index 751cf4f..0bee4d9 100644 --- a/man3/libsimple_aligned_allocz.3 +++ b/man3/libsimple_aligned_allocz.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ALIGNED_ALLOCZ 3 2018-11-03 libsimple +.TH LIBSIMPLE_ALIGNED_ALLOCZ 3 libsimple .SH NAME libsimple_aligned_allocz \- allocate optionally initialised memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void *libsimple_ealigned_allocz(int \fIclear\fP, size_t \fIalignme .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_aligned_allocz (), @@ -69,6 +71,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_aligned_allocz (), @@ -87,6 +90,7 @@ it indicate the error, and the and .BR libsimple_ealigned_allocz () functions terminated the process. + .SH ERRORS The .BR libsimple_aligned_allocz () @@ -113,6 +117,7 @@ The and .BR libsimple_ealigned_allocz () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -143,18 +148,25 @@ T{ .BR libsimple_ealigned_allocz () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -163,7 +175,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_aligned_memdup.3 b/man3/libsimple_aligned_memdup.3 index 6cd287a..cff094d 100644 --- a/man3/libsimple_aligned_memdup.3 +++ b/man3/libsimple_aligned_memdup.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ALIGNED_MEMDUP 3 2018-10-27 libsimple +.TH LIBSIMPLE_ALIGNED_MEMDUP 3 libsimple .SH NAME libsimple_aligned_memdup, libsimple_aligned_memdupa \- duplicate bytes in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -26,10 +27,11 @@ static inline void *libsimple_ealigned_memdup(const void *\fIs\fP, size_t \fIali .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_aligned_memdup () -function constructs allocates memory with the alignment +function allocates memory with the alignment specified in the .I alignment parameter and copies @@ -60,6 +62,7 @@ function that uses allocates the memory on the stack rather than on the heap, causing the return pointer to become invalid when the calling function returns. It is only available when compling with GCC or Clang. + .SH RETURN VALUE Upon successful completion, the .BR libsimple_aligned_memdupa (), @@ -90,12 +93,14 @@ by the .BR libsimple_aligned_memdupa () function, it is automatically deallocated when the calling function returns. + .SH ERRORS The .BR libsimple_aligned_memdup () function may fail for any reason specified for the .BR aligned_alloc (3) function. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -132,21 +137,29 @@ T{ .BR libsimple_ealigned_memdup (), T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memdup (3), -.BR libsimple_enstrndup (3), -.BR libsimple_enstrdup (3), -.BR strndup (3), -.BR strdup (3) +.BR libsimple_aligned_strndup (3), +.BR libsimple_aligned_strdup (3), +.BR libsimple_aligned_wcsdup (3), +.BR libsimple_aligned_wcsndup (3), +.BR libsimple_aligned_wmemdup (3) diff --git a/man3/libsimple_aligned_realloc.3 b/man3/libsimple_aligned_realloc.3 new file mode 100644 index 0000000..1845408 --- /dev/null +++ b/man3/libsimple_aligned_realloc.3 @@ -0,0 +1,212 @@ +.TH LIBSIMPLE_ALIGNED_REALLOC 3 libsimple +.SH NAME +libsimple_aligned_realloc \- reallocate memory and customise alignment + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_aligned_realloc(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP); +void *libsimple_enaligned_realloc(int \fIstatus\fP, void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP); +static inline void *libsimple_ealigned_realloc(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP); + +#ifndef aligned_realloc +# define aligned_realloc libsimple_aligned_realloc +#endif +#ifndef enaligned_realloc +# define enaligned_realloc libsimple_enaligned_realloc +#endif +#ifndef ealigned_realloc +# define ealigned_realloc libsimple_ealigned_realloc +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_realloc (), +.BR libsimple_enaligned_realloc (), +and +.BR libsimple_ealigned_realloc () +functions reallocate memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignment +to the allocated memory of +.I n +bytes. The behaviour is unspecified if +.I n +is 0. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I n +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is not deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +The +.BR libsimple_enaligned_realloc () +and +.BR libsimple_ealigned_realloc () +functions will terminate the process if the memory +cannot be allocated, by calling the +.BR libsimple_enprintf () +and +.BR libsimple_eprintf () +functions, respectively. +On failure, the process's exit value will be +.I status +if the +.BR libsimple_enaligned_realloc () +function is used or +.IR libsimple_default_failure_exit (3) +if the +.BR libsimple_ealigned_realloc () +function is used. + +.SH RETURN VALUE +The +.BR libsimple_aligned_realloc (), +.BR libsimple_enaligned_realloc (), +and +.BR libsimple_ealigned_realloc () +functions return a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_aligned_realloc () +function returns +.B NULL +and set +.I errno +it indicate the error, and the +.BR libsimple_enaligned_realloc () +and +.BR libsimple_ealigned_realloc () +functions terminated the process. + +.SH ERRORS +The +.BR libsimple_aligned_realloc () +function will fail for the reasons specified for the +.BR realloc (3) +function, and if: +.TP +.B EINVAL +.I alignment +is an invalid alignment (usually it needs to be an power of 2). +.TP +.B ENOSYS +The function is not implemented. The function requires +non-standard libc functions, and is therefore not supported +for all libc implementations. + +The function is implemented if and only if the macro +.B LIBSIMPLE_HAVE_ALIGNED_REALLOC +is defined by the library. +.PP +The +.BR libsimple_enaligned_realloc () +and +.BR libsimple_ealigned_realloc () +functions will terminate the process on failure. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_realloc (), +.br +.BR libsimple_enaligned_realloc (), +.br +.BR libsimple_ealigned_realloc () +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_realloc (), +.br +.BR libsimple_enaligned_realloc (), +.br +.BR libsimple_ealigned_realloc () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_realloc (), +.br +.BR libsimple_enaligned_realloc (), +.br +.BR libsimple_ealigned_realloc () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_aligned_reallocarray.3 b/man3/libsimple_aligned_reallocarray.3 new file mode 100644 index 0000000..e056c72 --- /dev/null +++ b/man3/libsimple_aligned_reallocarray.3 @@ -0,0 +1,214 @@ +.TH LIBSIMPLE_ALIGNED_REALLOCARRAY 3 libsimple +.SH NAME +libsimple_aligned_reallocarray \- reallocate memory and customise alignment + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_aligned_reallocarray(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, size_t \fIm\fP); +void *libsimple_enaligned_reallocarray(int \fIstatus\fP, void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, size_t \fIm\fP); +static inline void *libsimple_ealigned_reallocarray(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, size_t \fIm\fP); + +#ifndef aligned_reallocarray +# define aligned_reallocarray libsimple_aligned_reallocarray +#endif +#ifndef enaligned_reallocarray +# define enaligned_reallocarray libsimple_enaligned_reallocarray +#endif +#ifndef ealigned_reallocarray +# define ealigned_reallocarray libsimple_ealigned_reallocarray +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_reallocarray (), +.BR libsimple_enaligned_reallocarray (), +and +.BR libsimple_ealigned_reallocarray () +functions reallocate memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignment +to the allocated memory of +.I n*m +bytes. The behaviour is unspecified if +.I n +or +.I m +is 0. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I n*m +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is not deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +The +.BR libsimple_enaligned_reallocarray () +and +.BR libsimple_ealigned_reallocarray () +functions will terminate the process if the memory +cannot be allocated, by calling the +.BR libsimple_enprintf () +and +.BR libsimple_eprintf () +functions, respectively. +On failure, the process's exit value will be +.I status +if the +.BR libsimple_enaligned_reallocarray () +function is used or +.IR libsimple_default_failure_exit (3) +if the +.BR libsimple_ealigned_reallocarray () +function is used. + +.SH RETURN VALUE +The +.BR libsimple_aligned_reallocarray (), +.BR libsimple_enaligned_reallocarray (), +and +.BR libsimple_ealigned_reallocarray () +functions return a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_aligned_reallocarray () +function returns +.B NULL +and set +.I errno +it indicate the error, and the +.BR libsimple_enaligned_reallocarray () +and +.BR libsimple_ealigned_reallocarray () +functions terminated the process. + +.SH ERRORS +The +.BR libsimple_aligned_reallocarray () +function will fail for the reasons specified for the +.BR realloc (3) +function, and if: +.TP +.B EINVAL +.I alignment +is an invalid alignment (usually it needs to be an power of 2). +.TP +.B ENOSYS +The function is not implemented. The function requires +non-standard libc functions, and is therefore not supported +for all libc implementations. + +The function is implemented if and only if the macro +.B LIBSIMPLE_HAVE_ALIGNED_REALLOC +is defined by the library. +.PP +The +.BR libsimple_enaligned_reallocarray () +and +.BR libsimple_ealigned_reallocarray () +functions will terminate the process on failure. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_reallocarray (), +.br +.BR libsimple_enaligned_reallocarray (), +.br +.BR libsimple_ealigned_reallocarray () +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_reallocarray (), +.br +.BR libsimple_enaligned_reallocarray (), +.br +.BR libsimple_ealigned_reallocarray () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_reallocarray (), +.br +.BR libsimple_enaligned_reallocarray (), +.br +.BR libsimple_ealigned_reallocarray () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_aligned_reallocarrayf.3 b/man3/libsimple_aligned_reallocarrayf.3 new file mode 100644 index 0000000..998d49a --- /dev/null +++ b/man3/libsimple_aligned_reallocarrayf.3 @@ -0,0 +1,166 @@ +.TH LIBSIMPLE_ALIGNED_REALLOCARRAYF 3 libsimple +.SH NAME +libsimple_aligned_reallocarrayf \- reallocate memory and customise alignment + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_aligned_reallocarrayf(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, size_t \fIm\fP); + +#ifndef aligned_reallocarrayf +# define aligned_reallocarrayf libsimple_aligned_reallocarrayf +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_reallocarrayf () +function reallocates memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignment +to the allocated memory of +.I n*m +bytes. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I n*m +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +If +.I n +or +.I m +is 0, +.I ptr +is deallocaed and +.B NULL +is returned, however portable applications should, +unless the namespaced alias is used, assume the +behaviour is unspecifed in this case. + +.SH RETURN VALUE +The +.BR libsimple_aligned_reallocarrayf (), +function returns a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_aligned_reallocarrayf () +function returns +.B NULL +and set +.I errno +it indicate the error. + +.SH ERRORS +The +.BR libsimple_aligned_reallocarrayf () +function will fail for the reasons specified for the +.BR realloc (3) +function, and if: +.TP +.B EINVAL +.I alignment +is an invalid alignment (usually it needs to be an power of 2). +.TP +.B ENOSYS +The function is not implemented. The function requires +non-standard libc functions, and is therefore not supported +for all libc implementations. + +The function is implemented if and only if the macro +.B LIBSIMPLE_HAVE_ALIGNED_REALLOC +is defined by the library. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_reallocarrayf () +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_reallocarrayf () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_reallocarrayf () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_aligned_reallocf.3 b/man3/libsimple_aligned_reallocf.3 new file mode 100644 index 0000000..97d6dff --- /dev/null +++ b/man3/libsimple_aligned_reallocf.3 @@ -0,0 +1,164 @@ +.TH LIBSIMPLE_ALIGNED_REALLOCF 3 libsimple +.SH NAME +libsimple_aligned_reallocf \- reallocate memory and customise alignment + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_aligned_reallocf(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP); + +#ifndef aligned_reallocf +# define aligned_reallocf libsimple_aligned_reallocf +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_reallocf () +function reallocates memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignment +to the allocated memory of +.I n +bytes. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I n +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +If +.I n +is 0, +.I ptr +is deallocaed and +.B NULL +is returned, however portable applications should, +unless the namespaced alias is used, assume the +behaviour is unspecifed in this case. + +.SH RETURN VALUE +The +.BR libsimple_aligned_reallocf (), +function returns a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_aligned_reallocf () +function returns +.B NULL +and set +.I errno +it indicate the error. + +.SH ERRORS +The +.BR libsimple_aligned_reallocf () +function will fail for the reasons specified for the +.BR realloc (3) +function, and if: +.TP +.B EINVAL +.I alignment +is an invalid alignment (usually it needs to be an power of 2). +.TP +.B ENOSYS +The function is not implemented. The function requires +non-standard libc functions, and is therefore not supported +for all libc implementations. + +The function is implemented if and only if the macro +.B LIBSIMPLE_HAVE_ALIGNED_REALLOC +is defined by the library. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_reallocf () +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_reallocf () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_reallocf () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_aligned_reallocfn.3 b/man3/libsimple_aligned_reallocfn.3 new file mode 120000 index 0000000..1ba44a5 --- /dev/null +++ b/man3/libsimple_aligned_reallocfn.3 @@ -0,0 +1 @@ +libsimple_valigned_reallocfn.3
\ No newline at end of file diff --git a/man3/libsimple_aligned_reallocn.3 b/man3/libsimple_aligned_reallocn.3 new file mode 120000 index 0000000..7c3a84f --- /dev/null +++ b/man3/libsimple_aligned_reallocn.3 @@ -0,0 +1 @@ +libsimple_valigned_reallocn.3
\ No newline at end of file diff --git a/man3/libsimple_aligned_strdup.3 b/man3/libsimple_aligned_strdup.3 new file mode 100644 index 0000000..1570e68 --- /dev/null +++ b/man3/libsimple_aligned_strdup.3 @@ -0,0 +1,163 @@ +.TH LIBSIMPLE_ALIGNED_STRDUP 3 libsimple +.SH NAME +libsimple_aligned_strdup, libsimple_aligned_strdupa \- duplicate a string + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +char *libsimple_aligned_strdupa(const char *\fIs\fP, size_t \fIn\fP); +char *libsimple_aligned_strdup(const char *\fIs\fP, size_t \fIn\fP); +char *libsimple_enaligned_strdup(int \fIstatus\fP, const char *\fIs\fP, size_t \fIn\fP); +static inline char *libsimple_ealigned_strdup(const char *\fIs\fP, size_t \fIn\fP); + +#ifndef aligned_strdupa +# define aligned_strdupa libsimple_aligned_strdupa +#endif +#ifndef aligned_strdup +# define aligned_strdup libsimple_aligned_strdup +#endif +#ifndef enaligned_strdup +# define enaligned_strdup libsimple_enaligned_strdup +#endif +#ifndef ealigned_strdup +# define ealigned_strdup libsimple_ealigned_strdup +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_strdup () +function allocates memory with the alignment +specified in the +.I alignment +parameter and copies the string +.I s +into the new allocation. +.PP +The +.BR libsimple_enaligned_strdup () +and +.BR libsimple_ealigned_strdup () +functions are versions of the +.BR libsimple_aligned_strdup () +function that call the +.BR libsimple_enprintf (3) +function on failure, causing the process to print +an error message and exit. See +.BR libsimple_enprintf (3) +for more information. +.PP +The +.BR libsimple_strdupa () +function is implemented as a macro and is a version +of the +.BR libsimple_strdup () +function that uses allocates the memory on the stack +rather than on the heap, causing the return pointer +to become invalid when the calling function returns. +It is only available when compling with GCC or Clang. + +.SH RETURN VALUE +Upon successful completion, the +.BR libsimple_aligned_strdupa (), +.BR libsimple_aligned_strdup (), +.BR libsimple_enaligned_strdup (), +and +.BR libsimple_ealigned_strdup () +functions return a non-null pointer, on failure the +.BR libsimple_aligned_strdup () +function returns +.B NULL +and set +.I errno +to indicate the error, and the +.BR libsimple_enaligned_strdup (), +and +.BR libsimple_ealigned_strdup () +functions exit the process. The +.BR libsimple_aligned_strdupa () +function cannot fail, however the kernel +can kill the thread, and possibly the process, with a +.B SIGSEGV +signal if the memory cannot be allocated. +.PP +The returned pointer should be deallocated when it +is no longer needed, except for the pointer returned +by the +.BR libsimple_aligned_strdupa () +function, it is automatically deallocated when the +calling function returns. + +.SH ERRORS +The +.BR libsimple_aligned_strdup () +function may fail for any reason specified for the +.BR aligned_alloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_strdupa (), +.br +.BR libsimple_aligned_strdup (), +.br +.BR libsimple_enaligned_strdup (), +.br +.BR libsimple_ealigned_strdup (), +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_strdupa (), +.br +.BR libsimple_aligned_strdup (), +.br +.BR libsimple_enaligned_strdup (), +.br +.BR libsimple_ealigned_strdup (), +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_strdupa (), +.br +.BR libsimple_aligned_strdup (), +.br +.BR libsimple_enaligned_strdup (), +.br +.BR libsimple_ealigned_strdup (), +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_aligned_strndup (3), +.BR libsimple_aligned_memdup (3), +.BR libsimple_aligned_wcsdup (3), +.BR libsimple_aligned_wcsndup (3), +.BR libsimple_aligned_wmemdup (3), +.BR strdup (3) diff --git a/man3/libsimple_aligned_strdupa.3 b/man3/libsimple_aligned_strdupa.3 new file mode 120000 index 0000000..005dc6f --- /dev/null +++ b/man3/libsimple_aligned_strdupa.3 @@ -0,0 +1 @@ +libsimple_aligned_strdup.3
\ No newline at end of file diff --git a/man3/libsimple_aligned_strndup.3 b/man3/libsimple_aligned_strndup.3 new file mode 100644 index 0000000..05c6d3a --- /dev/null +++ b/man3/libsimple_aligned_strndup.3 @@ -0,0 +1,166 @@ +.TH LIBSIMPLE_ALIGNED_STRNDUP 3 libsimple +.SH NAME +libsimple_aligned_strndup, libsimple_aligned_strndupa \- duplicate a string + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +char *libsimple_aligned_strndupa(const char *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +char *libsimple_aligned_strndup(const char *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +char *libsimple_enaligned_strndup(int \fIstatus\fP, const char *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +static inline char *libsimple_ealigned_strndup(const char *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); + +#ifndef aligned_strndupa +# define aligned_strndupa libsimple_aligned_strndupa +#endif +#ifndef aligned_strndup +# define aligned_strndup libsimple_aligned_strndup +#endif +#ifndef enaligned_strndup +# define enaligned_strndup libsimple_enaligned_strndup +#endif +#ifndef ealigned_strndup +# define ealigned_strndup libsimple_ealigned_strndup +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_strndup () +function allocates memory with the alignment +specified in the +.I alignment +parameter and copies the string +.I s +into the new allocation, up to the +.IR n th +byte. A NUL byte will always be written +to the end of the new string. +.PP +The +.BR libsimple_enaligned_strndup () +and +.BR libsimple_ealigned_strndup () +functions are versions of the +.BR libsimple_aligned_strndup () +function that call the +.BR libsimple_enprintf (3) +function on failure, causing the process to print +an error message and exit. See +.BR libsimple_enprintf (3) +for more information. +.PP +The +.BR libsimple_strndupa () +function is implemented as a macro and is a version +of the +.BR libsimple_strndup () +function that uses allocates the memory on the stack +rather than on the heap, causing the return pointer +to become invalid when the calling function returns. +It is only available when compling with GCC or Clang. + +.SH RETURN VALUE +Upon successful completion, the +.BR libsimple_aligned_strndupa (), +.BR libsimple_aligned_strndup (), +.BR libsimple_enaligned_strndup (), +and +.BR libsimple_ealigned_strndup () +functions return a non-null pointer, on failure the +.BR libsimple_aligned_strndup () +function returns +.B NULL +and set +.I errno +to indicate the error, and the +.BR libsimple_enaligned_strndup (), +and +.BR libsimple_ealigned_strndup () +functions exit the process. The +.BR libsimple_aligned_strndupa () +function cannot fail, however the kernel +can kill the thread, and possibly the process, with a +.B SIGSEGV +signal if the memory cannot be allocated. +.PP +The returned pointer should be deallocated when it +is no longer needed, except for the pointer returned +by the +.BR libsimple_aligned_strndupa () +function, it is automatically deallocated when the +calling function returns. + +.SH ERRORS +The +.BR libsimple_aligned_strndup () +function may fail for any reason specified for the +.BR aligned_alloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_strndupa (), +.br +.BR libsimple_aligned_strndup (), +.br +.BR libsimple_enaligned_strndup (), +.br +.BR libsimple_ealigned_strndup (), +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_strndupa (), +.br +.BR libsimple_aligned_strndup (), +.br +.BR libsimple_enaligned_strndup (), +.br +.BR libsimple_ealigned_strndup (), +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_strndupa (), +.br +.BR libsimple_aligned_strndup (), +.br +.BR libsimple_enaligned_strndup (), +.br +.BR libsimple_ealigned_strndup (), +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_aligned_strdup (3), +.BR libsimple_aligned_memdup (3), +.BR libsimple_aligned_wcsdup (3), +.BR libsimple_aligned_wcsndup (3), +.BR libsimple_aligned_wmemdup (3), +.BR strndup (3) diff --git a/man3/libsimple_aligned_strndupa.3 b/man3/libsimple_aligned_strndupa.3 new file mode 120000 index 0000000..4be204c --- /dev/null +++ b/man3/libsimple_aligned_strndupa.3 @@ -0,0 +1 @@ +libsimple_aligned_strndup.3
\ No newline at end of file diff --git a/man3/libsimple_aligned_wcsdup.3 b/man3/libsimple_aligned_wcsdup.3 new file mode 100644 index 0000000..42f9cd9 --- /dev/null +++ b/man3/libsimple_aligned_wcsdup.3 @@ -0,0 +1,163 @@ +.TH LIBSIMPLE_ALIGNED_WCSDUP 3 libsimple +.SH NAME +libsimple_aligned_wcsdup, libsimple_aligned_wcsdupa \- duplicate a wide-character string + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +wchar_t *libsimple_aligned_wcsdupa(const wchar_t *\fIs\fP, size_t \fIalignment\fP); +wchar_t *libsimple_aligned_wcsdup(const wchar_t *\fIs\fP, size_t \fIalignment\fP); +wchar_t *libsimple_enaligned_wcsdup(int \fIstatus\fP, const wchar_t *\fIs\fP, size_t \fIalignment\fP); +static inline wchar_t *libsimple_ealigned_wcsdup(const wchar_t *\fIs\fP, size_t \fIalignment\fP); + +#ifndef aligned_wcsdupa +# define aligned_wcsdupa libsimple_aligned_wcsdupa +#endif +#ifndef aligned_wcsdup +# define aligned_wcsdup libsimple_aligned_wcsdup +#endif +#ifndef enaligned_wcsdup +# define enaligned_wcsdup libsimple_enaligned_wcsdup +#endif +#ifndef ealigned_wcsdup +# define ealigned_wcsdup libsimple_ealigned_wcsdup +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_wcsdup () +function allocates memory with the alignment +specified in the +.I alignment +parameter and copies the wide-character string +.I s +into the new allocation. +.PP +The +.BR libsimple_enaligned_wcsdup () +and +.BR libsimple_ealigned_wcsdup () +functions are versions of the +.BR libsimple_aligned_wcsdup () +function that call the +.BR libsimple_enprintf (3) +function on failure, causing the process to print +an error message and exit. See +.BR libsimple_enprintf (3) +for more information. +.PP +The +.BR libsimple_wcsdupa () +function is implemented as a macro and is a version +of the +.BR libsimple_wcsdup () +function that uses allocates the memory on the stack +rather than on the heap, causing the return pointer +to become invalid when the calling function returns. +It is only available when compling with GCC or Clang. + +.SH RETURN VALUE +Upon successful completion, the +.BR libsimple_aligned_wcsdupa (), +.BR libsimple_aligned_wcsdup (), +.BR libsimple_enaligned_wcsdup (), +and +.BR libsimple_ealigned_wcsdup () +functions return a non-null pointer, on failure the +.BR libsimple_aligned_wcsdup () +function returns +.B NULL +and set +.I errno +to indicate the error, and the +.BR libsimple_enaligned_wcsdup (), +and +.BR libsimple_ealigned_wcsdup () +functions exit the process. The +.BR libsimple_aligned_wcsdupa () +function cannot fail, however the kernel +can kill the thread, and possibly the process, with a +.B SIGSEGV +signal if the memory cannot be allocated. +.PP +The returned pointer should be deallocated when it +is no longer needed, except for the pointer returned +by the +.BR libsimple_aligned_wcsdupa () +function, it is automatically deallocated when the +calling function returns. + +.SH ERRORS +The +.BR libsimple_aligned_wcsdup () +function may fail for any reason specified for the +.BR aligned_alloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_wcsdupa (), +.br +.BR libsimple_aligned_wcsdup (), +.br +.BR libsimple_enaligned_wcsdup (), +.br +.BR libsimple_ealigned_wcsdup (), +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_wcsdupa (), +.br +.BR libsimple_aligned_wcsdup (), +.br +.BR libsimple_enaligned_wcsdup (), +.br +.BR libsimple_ealigned_wcsdup (), +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_wcsdupa (), +.br +.BR libsimple_aligned_wcsdup (), +.br +.BR libsimple_enaligned_wcsdup (), +.br +.BR libsimple_ealigned_wcsdup (), +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_aligned_strndup (3), +.BR libsimple_aligned_strdup (3), +.BR libsimple_aligned_memdup (3), +.BR libsimple_aligned_wcsndup (3), +.BR libsimple_aligned_wmemdup (3), +.BR wcsdup (3) diff --git a/man3/libsimple_aligned_wcsdupa.3 b/man3/libsimple_aligned_wcsdupa.3 new file mode 120000 index 0000000..cb194a0 --- /dev/null +++ b/man3/libsimple_aligned_wcsdupa.3 @@ -0,0 +1 @@ +libsimple_aligned_wcsdup.3
\ No newline at end of file diff --git a/man3/libsimple_aligned_wcsndup.3 b/man3/libsimple_aligned_wcsndup.3 new file mode 100644 index 0000000..669b790 --- /dev/null +++ b/man3/libsimple_aligned_wcsndup.3 @@ -0,0 +1,168 @@ +.TH LIBSIMPLE_ALIGNED_WCSNDUP 3 libsimple +.SH NAME +libsimple_aligned_wcsndup, libsimple_aligned_wcsndupa \- duplicate a wide-character string + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +wchar_t *libsimple_aligned_wcsndupa(const wchar_t *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +wchar_t *libsimple_aligned_wcsndup(const wchar_t *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +wchar_t *libsimple_enaligned_wcsndup(int \fIstatus\fP, const wchar_t *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +static inline wchar_t *libsimple_ealigned_wcsndup(const wchar_t *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); + +#ifndef aligned_wcsndupa +# define aligned_wcsndupa libsimple_aligned_wcsndupa +#endif +#ifndef aligned_wcsndup +# define aligned_wcsndup libsimple_aligned_wcsndup +#endif +#ifndef enaligned_wcsndup +# define enaligned_wcsndup libsimple_enaligned_wcsndup +#endif +#ifndef ealigned_wcsndup +# define ealigned_wcsndup libsimple_ealigned_wcsndup +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_wcsndup () +function allocates memory with the alignment +specified in the +.I alignment +parameter and copies the wide-character string +.I s +into the new allocation, up to the +.IR n th +wide character +.RB ( wchar_t ). +A NUL wide-character will always be written +to the end of the new string. +.PP +The +.BR libsimple_enaligned_wcsndup () +and +.BR libsimple_ealigned_wcsndup () +functions are versions of the +.BR libsimple_aligned_wcsndup () +function that call the +.BR libsimple_enprintf (3) +function on failure, causing the process to print +an error message and exit. See +.BR libsimple_enprintf (3) +for more information. +.PP +The +.BR libsimple_wcsndupa () +function is implemented as a macro and is a version +of the +.BR libsimple_wcsndup () +function that uses allocates the memory on the stack +rather than on the heap, causing the return pointer +to become invalid when the calling function returns. +It is only available when compling with GCC or Clang. + +.SH RETURN VALUE +Upon successful completion, the +.BR libsimple_aligned_wcsndupa (), +.BR libsimple_aligned_wcsndup (), +.BR libsimple_enaligned_wcsndup (), +and +.BR libsimple_ealigned_wcsndup () +functions return a non-null pointer, on failure the +.BR libsimple_aligned_wcsndup () +function returns +.B NULL +and set +.I errno +to indicate the error, and the +.BR libsimple_enaligned_wcsndup (), +and +.BR libsimple_ealigned_wcsndup () +functions exit the process. The +.BR libsimple_aligned_wcsndupa () +function cannot fail, however the kernel +can kill the thread, and possibly the process, with a +.B SIGSEGV +signal if the memory cannot be allocated. +.PP +The returned pointer should be deallocated when it +is no longer needed, except for the pointer returned +by the +.BR libsimple_aligned_wcsndupa () +function, it is automatically deallocated when the +calling function returns. + +.SH ERRORS +The +.BR libsimple_aligned_wcsndup () +function may fail for any reason specified for the +.BR aligned_alloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_wcsndupa (), +.br +.BR libsimple_aligned_wcsndup (), +.br +.BR libsimple_enaligned_wcsndup (), +.br +.BR libsimple_ealigned_wcsndup (), +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_wcsndupa (), +.br +.BR libsimple_aligned_wcsndup (), +.br +.BR libsimple_enaligned_wcsndup (), +.br +.BR libsimple_ealigned_wcsndup (), +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_wcsndupa (), +.br +.BR libsimple_aligned_wcsndup (), +.br +.BR libsimple_enaligned_wcsndup (), +.br +.BR libsimple_ealigned_wcsndup (), +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_wcsndup (3), +.BR libsimple_aligned_strndup (3), +.BR libsimple_aligned_strdup (3), +.BR libsimple_aligned_memdup (3), +.BR libsimple_aligned_wcsdup (3), +.BR libsimple_aligned_wmemdup (3) diff --git a/man3/libsimple_aligned_wcsndupa.3 b/man3/libsimple_aligned_wcsndupa.3 new file mode 120000 index 0000000..043dad0 --- /dev/null +++ b/man3/libsimple_aligned_wcsndupa.3 @@ -0,0 +1 @@ +libsimple_aligned_wcsndup.3
\ No newline at end of file diff --git a/man3/libsimple_aligned_wmemdup.3 b/man3/libsimple_aligned_wmemdup.3 new file mode 100644 index 0000000..a269082 --- /dev/null +++ b/man3/libsimple_aligned_wmemdup.3 @@ -0,0 +1,167 @@ +.TH LIBSIMPLE_ALIGNED_WMEMDUP 3 libsimple +.SH NAME +libsimple_aligned_wmemdup, libsimple_aligned_wmemdupa \- duplicate a wide-character array + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +wchar_t *libsimple_aligned_wmemdupa(const wchar_t *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +wchar_t *libsimple_aligned_wmemdup(const wchar_t *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +wchar_t *libsimple_enaligned_wmemdup(int \fIstatus\fP, const wchar_t *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); +static inline wchar_t *libsimple_ealigned_wmemdup(const wchar_t *\fIs\fP, size_t \fIalignment\fP, size_t \fIn\fP); + +#ifndef aligned_wmemdupa +# define aligned_wmemdupa libsimple_aligned_wmemdupa +#endif +#ifndef aligned_wmemdup +# define aligned_wmemdup libsimple_aligned_wmemdup +#endif +#ifndef enaligned_wmemdup +# define enaligned_wmemdup libsimple_enaligned_wmemdup +#endif +#ifndef ealigned_wmemdup +# define ealigned_wmemdup libsimple_ealigned_wmemdup +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_wmemdup () +function allocates memory with the alignment +specified in the +.I alignment +parameter and copies +.I n +first wide characters +.RB ( wchar_t ) +from +.I s +into the new allocation. +.PP +The +.BR libsimple_enaligned_wmemdup () +and +.BR libsimple_ealigned_wmemdup () +functions are versions of the +.BR libsimple_aligned_wmemdup () +function that call the +.BR libsimple_enprintf (3) +function on failure, causing the process to print +an error message and exit. See +.BR libsimple_enprintf (3) +for more information. +.PP +The +.BR libsimple_wmemdupa () +function is implemented as a macro and is a version +of the +.BR libsimple_wmemdup () +function that uses allocates the memory on the stack +rather than on the heap, causing the return pointer +to become invalid when the calling function returns. +It is only available when compling with GCC or Clang. + +.SH RETURN VALUE +Upon successful completion, the +.BR libsimple_aligned_wmemdupa (), +.BR libsimple_aligned_wmemdup (), +.BR libsimple_enaligned_wmemdup (), +and +.BR libsimple_ealigned_wmemdup () +functions return a non-null pointer, on failure the +.BR libsimple_aligned_wmemdup () +function returns +.B NULL +and set +.I errno +to indicate the error, and the +.BR libsimple_enaligned_wmemdup (), +and +.BR libsimple_ealigned_wmemdup () +functions exit the process. The +.BR libsimple_aligned_wmemdupa () +function cannot fail, however the kernel +can kill the thread, and possibly the process, with a +.B SIGSEGV +signal if the memory cannot be allocated. +.PP +The returned pointer should be deallocated when it +is no longer needed, except for the pointer returned +by the +.BR libsimple_aligned_wmemdupa () +function, it is automatically deallocated when the +calling function returns. + +.SH ERRORS +The +.BR libsimple_aligned_wmemdup () +function may fail for any reason specified for the +.BR aligned_alloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_aligned_wmemdupa (), +.br +.BR libsimple_aligned_wmemdup (), +.br +.BR libsimple_enaligned_wmemdup (), +.br +.BR libsimple_ealigned_wmemdup (), +T} Thread safety MT-Safe +T{ +.BR libsimple_aligned_wmemdupa (), +.br +.BR libsimple_aligned_wmemdup (), +.br +.BR libsimple_enaligned_wmemdup (), +.br +.BR libsimple_ealigned_wmemdup (), +T} Async-signal safety AS-Safe +T{ +.BR libsimple_aligned_wmemdupa (), +.br +.BR libsimple_aligned_wmemdup (), +.br +.BR libsimple_enaligned_wmemdup (), +.br +.BR libsimple_ealigned_wmemdup (), +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_wmemdup (3), +.BR libsimple_aligned_strndup (3), +.BR libsimple_aligned_strdup (3), +.BR libsimple_aligned_memdup (3), +.BR libsimple_aligned_wcsdup (3), +.BR libsimple_aligned_wcsndup (3) diff --git a/man3/libsimple_aligned_wmemdupa.3 b/man3/libsimple_aligned_wmemdupa.3 new file mode 120000 index 0000000..264a7e1 --- /dev/null +++ b/man3/libsimple_aligned_wmemdupa.3 @@ -0,0 +1 @@ +libsimple_aligned_wmemdup.3
\ No newline at end of file diff --git a/man3/libsimple_close.3 b/man3/libsimple_close.3 index d5e18c6..d9fb852 100644 --- a/man3/libsimple_close.3 +++ b/man3/libsimple_close.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_CLOSE 3 2018-11-05 libsimple +.TH LIBSIMPLE_CLOSE 3 libsimple .SH NAME libsimple_close \- close file descriptor and mark it as closed + .SH SYNOPSIS .nf #include <libsimple.h> @@ -10,6 +11,7 @@ static inline int libsimple_close(int *\fIfdp\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_close () @@ -22,28 +24,37 @@ to However if .IR *fdp<0 , does not except return 0. + .SH RETURN VALUE The .BR libsimple_close () function returns 0 upon successful completion; otherwise \-1 is returned. + .SH ERRORS The .BR libsimple_close () function fail for the reasons specified for the .BR close (3) function. + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR close (3) diff --git a/man3/libsimple_cmptimespec.3 b/man3/libsimple_cmptimespec.3 index 14873ea..9d6869a 100644 --- a/man3/libsimple_cmptimespec.3 +++ b/man3/libsimple_cmptimespec.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_CMPTIMESPEC 3 2018-10-29 libsimple +.TH LIBSIMPLE_CMPTIMESPEC 3 libsimple .SH NAME libsimple_cmptimespec, libsimple_cmptimeval \- calculate the sum of two durations + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline int libsimple_cmptimeval(const struct timeval *\fIa\fP, const stru .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_cmptimespec () @@ -28,6 +30,7 @@ functions compares the values of and .IR b , returning a value indicating which is larger, if any. + .SH RETURN VALUE The .BR libsimple_cmptimespec () @@ -42,12 +45,14 @@ is less than is greater than .IR b , and 0 otherwise. + .SH ERRORS The .BR libsimple_cmptimespec () and .BR libsimple_cmptimeval () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -72,18 +77,25 @@ T{ .BR libsimple_cmptimeval () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_sumtimespec (3), .BR libsimple_difftimespec (3), diff --git a/man3/libsimple_difftimespec.3 b/man3/libsimple_difftimespec.3 index bf26446..91df8e9 100644 --- a/man3/libsimple_difftimespec.3 +++ b/man3/libsimple_difftimespec.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_DIFFTIMESPEC 3 2018-10-29 libsimple +.TH LIBSIMPLE_DIFFTIMESPEC 3 libsimple .SH NAME libsimple_difftimespec, libsimple_difftimeval \- calculate the difference of two durations + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ int libsimple_difftimeval(struct timeval *\fIdiff\fP, const struct timeval *\fIm .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_difftimespec () @@ -41,6 +43,7 @@ are in thier valid range ([0, 1000000000) for .BR libsimple_sumtimespec () and [0, 1000000) for .BR libsimple_sumtimeval ()) + .SH RETURN VALUE The .BR libsimple_difftimespec () @@ -50,6 +53,7 @@ functions return 0 on successful completion; otherwise, \-1 is returned and .I errno is set to indicate the error. + .SH ERRORS The .BR libsimple_difftimespec () @@ -80,6 +84,7 @@ function and to for the .BR libsimple_difftimeval () function. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -104,18 +109,25 @@ T{ .BR libsimple_difftimeval () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_sumtimespec (3), .BR libsimple_multimespec (3), diff --git a/man3/libsimple_doubletotimespec.3 b/man3/libsimple_doubletotimespec.3 index 1d8790c..1fddc74 100644 --- a/man3/libsimple_doubletotimespec.3 +++ b/man3/libsimple_doubletotimespec.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_DOUBLETOTIMESPEC 3 2018-10-30 libsimple +.TH LIBSIMPLE_DOUBLETOTIMESPEC 3 libsimple .SH NAME libsimple_doubletotimespec, libsimple_doubletotimeval \- convert a double to a duration data structure + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ void libsimple_doubletotimeval(struct timeval *\fItv\fP, double \fId\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_doubletotimespec () @@ -37,10 +39,13 @@ and stores the result in .IR tv . .PP Neither of these functions perform an overflow check. + .SH RETURN VALUE None. + .SH ERRORS No error checks are made. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -65,18 +70,25 @@ T{ .BR libsimple_doubletotimeval () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_sumtimespec (3), .BR libsimple_difftimespec (3), diff --git a/man3/libsimple_ealigned_realloc.3 b/man3/libsimple_ealigned_realloc.3 new file mode 120000 index 0000000..2d95e24 --- /dev/null +++ b/man3/libsimple_ealigned_realloc.3 @@ -0,0 +1 @@ +libsimple_enaligned_realloc.3
\ No newline at end of file diff --git a/man3/libsimple_ealigned_reallocarray.3 b/man3/libsimple_ealigned_reallocarray.3 new file mode 120000 index 0000000..1b2e0f8 --- /dev/null +++ b/man3/libsimple_ealigned_reallocarray.3 @@ -0,0 +1 @@ +libsimple_enaligned_reallocarray.3
\ No newline at end of file diff --git a/man3/libsimple_ealigned_reallocn.3 b/man3/libsimple_ealigned_reallocn.3 new file mode 120000 index 0000000..b7dde1d --- /dev/null +++ b/man3/libsimple_ealigned_reallocn.3 @@ -0,0 +1 @@ +libsimple_evaligned_reallocn.3
\ No newline at end of file diff --git a/man3/libsimple_ealigned_strdup.3 b/man3/libsimple_ealigned_strdup.3 new file mode 120000 index 0000000..83e40a2 --- /dev/null +++ b/man3/libsimple_ealigned_strdup.3 @@ -0,0 +1 @@ +libsimple_enaligned_strdup.3
\ No newline at end of file diff --git a/man3/libsimple_ealigned_strndup.3 b/man3/libsimple_ealigned_strndup.3 new file mode 120000 index 0000000..2b79c93 --- /dev/null +++ b/man3/libsimple_ealigned_strndup.3 @@ -0,0 +1 @@ +libsimple_enaligned_strndup.3
\ No newline at end of file diff --git a/man3/libsimple_ealigned_wcsdup.3 b/man3/libsimple_ealigned_wcsdup.3 new file mode 120000 index 0000000..c52f2c8 --- /dev/null +++ b/man3/libsimple_ealigned_wcsdup.3 @@ -0,0 +1 @@ +libsimple_enaligned_wcsdup.3
\ No newline at end of file diff --git a/man3/libsimple_ealigned_wcsndup.3 b/man3/libsimple_ealigned_wcsndup.3 new file mode 120000 index 0000000..f5772b1 --- /dev/null +++ b/man3/libsimple_ealigned_wcsndup.3 @@ -0,0 +1 @@ +libsimple_enaligned_wcsndup.3
\ No newline at end of file diff --git a/man3/libsimple_ealigned_wmemdup.3 b/man3/libsimple_ealigned_wmemdup.3 new file mode 120000 index 0000000..07321e1 --- /dev/null +++ b/man3/libsimple_ealigned_wmemdup.3 @@ -0,0 +1 @@ +libsimple_enaligned_wmemdup.3
\ No newline at end of file diff --git a/man3/libsimple_egmtime.3 b/man3/libsimple_egmtime.3 new file mode 120000 index 0000000..b670cdd --- /dev/null +++ b/man3/libsimple_egmtime.3 @@ -0,0 +1 @@ +libsimple_gmtime.3
\ No newline at end of file diff --git a/man3/libsimple_elocaltime.3 b/man3/libsimple_elocaltime.3 new file mode 120000 index 0000000..0b426b9 --- /dev/null +++ b/man3/libsimple_elocaltime.3 @@ -0,0 +1 @@ +libsimple_localtime.3
\ No newline at end of file diff --git a/man3/libsimple_enaligned_alloc.3 b/man3/libsimple_enaligned_alloc.3 index 1ea36cb..27abe3d 100644 --- a/man3/libsimple_enaligned_alloc.3 +++ b/man3/libsimple_enaligned_alloc.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ENALIGNED_ALLOC 3 2018-11-03 libsimple +.TH LIBSIMPLE_ENALIGNED_ALLOC 3 libsimple .SH NAME libsimple_enaligned_alloc \- allocate memory with custom alignment or die + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline void *libsimple_ealigned_alloc(size_t \fIalignment\fP, size_t \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_enaligned_alloc () @@ -66,6 +68,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_enaligned_alloc () @@ -74,12 +77,14 @@ and functions return a pointer to the allocated memory upon success completion; otherwise the process is terminated. + .SH ERRORS The .BR libsimple_enaligned_alloc () and .BR libsimple_ealigned_alloc () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -104,18 +109,25 @@ T{ .BR libsimple_ealigned_alloc () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -124,7 +136,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_enaligned_realloc.3 b/man3/libsimple_enaligned_realloc.3 new file mode 120000 index 0000000..45a72de --- /dev/null +++ b/man3/libsimple_enaligned_realloc.3 @@ -0,0 +1 @@ +libsimple_aligned_realloc.3
\ No newline at end of file diff --git a/man3/libsimple_enaligned_reallocarray.3 b/man3/libsimple_enaligned_reallocarray.3 new file mode 120000 index 0000000..fb3f8b9 --- /dev/null +++ b/man3/libsimple_enaligned_reallocarray.3 @@ -0,0 +1 @@ +libsimple_aligned_reallocarray.3
\ No newline at end of file diff --git a/man3/libsimple_enaligned_reallocn.3 b/man3/libsimple_enaligned_reallocn.3 new file mode 120000 index 0000000..36205a3 --- /dev/null +++ b/man3/libsimple_enaligned_reallocn.3 @@ -0,0 +1 @@ +libsimple_envaligned_reallocn.3
\ No newline at end of file diff --git a/man3/libsimple_enaligned_strdup.3 b/man3/libsimple_enaligned_strdup.3 new file mode 120000 index 0000000..005dc6f --- /dev/null +++ b/man3/libsimple_enaligned_strdup.3 @@ -0,0 +1 @@ +libsimple_aligned_strdup.3
\ No newline at end of file diff --git a/man3/libsimple_enaligned_strndup.3 b/man3/libsimple_enaligned_strndup.3 new file mode 120000 index 0000000..4be204c --- /dev/null +++ b/man3/libsimple_enaligned_strndup.3 @@ -0,0 +1 @@ +libsimple_aligned_strndup.3
\ No newline at end of file diff --git a/man3/libsimple_enaligned_wcsdup.3 b/man3/libsimple_enaligned_wcsdup.3 new file mode 120000 index 0000000..cb194a0 --- /dev/null +++ b/man3/libsimple_enaligned_wcsdup.3 @@ -0,0 +1 @@ +libsimple_aligned_wcsdup.3
\ No newline at end of file diff --git a/man3/libsimple_enaligned_wcsndup.3 b/man3/libsimple_enaligned_wcsndup.3 new file mode 120000 index 0000000..043dad0 --- /dev/null +++ b/man3/libsimple_enaligned_wcsndup.3 @@ -0,0 +1 @@ +libsimple_aligned_wcsndup.3
\ No newline at end of file diff --git a/man3/libsimple_enaligned_wmemdup.3 b/man3/libsimple_enaligned_wmemdup.3 new file mode 120000 index 0000000..264a7e1 --- /dev/null +++ b/man3/libsimple_enaligned_wmemdup.3 @@ -0,0 +1 @@ +libsimple_aligned_wmemdup.3
\ No newline at end of file diff --git a/man3/libsimple_encalloc.3 b/man3/libsimple_encalloc.3 index a8696e6..905bdd2 100644 --- a/man3/libsimple_encalloc.3 +++ b/man3/libsimple_encalloc.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ENCALLOC 3 2018-11-03 libsimple +.TH LIBSIMPLE_ENCALLOC 3 libsimple .SH NAME libsimple_encalloc \- allocate initialised memory or die + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline void *libsimple_ecalloc(size_t \fIn\fP, size_t \fIm\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_encalloc () @@ -72,6 +74,7 @@ functions behaviour is unspecified if or .I m is 0. + .SH RETURN VALUE The .BR libsimple_encalloc () @@ -79,12 +82,14 @@ and .BR libsimple_ecalloc () functions return a pointer to the allocated memory upon success completion; otherwise the process is terminated. + .SH ERRORS The .BR libsimple_encalloc () and .BR libsimple_ecalloc () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -109,18 +114,25 @@ T{ .BR libsimple_ecalloc () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -128,7 +140,17 @@ None. .BR libsimple_vmalloczn (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_engmtime.3 b/man3/libsimple_engmtime.3 new file mode 120000 index 0000000..b670cdd --- /dev/null +++ b/man3/libsimple_engmtime.3 @@ -0,0 +1 @@ +libsimple_gmtime.3
\ No newline at end of file diff --git a/man3/libsimple_enlocaltime.3 b/man3/libsimple_enlocaltime.3 new file mode 120000 index 0000000..0b426b9 --- /dev/null +++ b/man3/libsimple_enlocaltime.3 @@ -0,0 +1 @@ +libsimple_localtime.3
\ No newline at end of file diff --git a/man3/libsimple_enmalloc.3 b/man3/libsimple_enmalloc.3 index 796eafd..975f44c 100644 --- a/man3/libsimple_enmalloc.3 +++ b/man3/libsimple_enmalloc.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ENMALLOC 3 2018-11-03 libsimple +.TH LIBSIMPLE_ENMALLOC 3 libsimple .SH NAME libsimple_enmalloc \- allocate memory or die + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline void *libsimple_emalloc(size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_enmalloc () @@ -68,6 +70,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_enmalloc () @@ -75,12 +78,14 @@ and .BR libsimple_emalloc () functions return a pointer to the allocated memory upon success completion; otherwise the process is terminated. + .SH ERRORS The .BR libsimple_enmalloc () and .BR libsimple_emalloc () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -105,18 +110,25 @@ T{ .BR libsimple_emalloc () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_mallocz (3), .BR libsimple_vmallocn (3), @@ -124,7 +136,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_enposix_memalign.3 b/man3/libsimple_enposix_memalign.3 index c1157f3..1d8ec20 100644 --- a/man3/libsimple_enposix_memalign.3 +++ b/man3/libsimple_enposix_memalign.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ENPOSIX_MEMALIGN 3 2018-11-03 libsimple +.TH LIBSIMPLE_ENPOSIX_MEMALIGN 3 libsimple .SH NAME libsimple_enposix_memalign \- allocate memory with custom alignment or die + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline void libsimple_eposix_memalign(void **\fImemptr\fP, size_t \fIalig .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_enposix_memalign () @@ -71,6 +73,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_enposix_memalign () @@ -78,12 +81,14 @@ and .BR libsimple_eposix_memalign () functions do not return a value, but terminated the process on failure. + .SH ERRORS The .BR libsimple_enposix_memalign () and .BR libsimple_eposix_memalign () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -108,18 +113,25 @@ T{ .BR libsimple_eposix_memalign () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -128,7 +140,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_enrealloc.3 b/man3/libsimple_enrealloc.3 index 5262193..829a0f5 100644 --- a/man3/libsimple_enrealloc.3 +++ b/man3/libsimple_enrealloc.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ENREALLOC 3 2018-11-03 libsimple +.TH LIBSIMPLE_ENREALLOC 3 libsimple .SH NAME libsimple_enrealloc \- reallocate memory or die + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline void *libsimple_erealloc(void *\fIptr\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_enrealloc () @@ -79,6 +81,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_enrealloc () @@ -86,12 +89,14 @@ and .BR libsimple_erealloc () functions return a pointer to the allocated memory upon success completion; otherwise the process is terminated. + .SH ERRORS The .BR libsimple_enrealloc () and .BR libsimple_erealloc () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -116,18 +121,25 @@ T{ .BR libsimple_erealloc () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -135,7 +147,17 @@ None. .BR libsimple_vmalloczn (3), .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_enreallocarray.3 b/man3/libsimple_enreallocarray.3 new file mode 120000 index 0000000..9cb5fe4 --- /dev/null +++ b/man3/libsimple_enreallocarray.3 @@ -0,0 +1 @@ +libsimple_reallocarray.3
\ No newline at end of file diff --git a/man3/libsimple_enstrdup.3 b/man3/libsimple_enstrdup.3 index 4a2aa4f..33cc6c7 100644 --- a/man3/libsimple_enstrdup.3 +++ b/man3/libsimple_enstrdup.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ENSTRDUP 3 2018-10-27 libsimple +.TH LIBSIMPLE_ENSTRDUP 3 libsimple .SH NAME libsimple_enstrdup, libsimple_strdupa \- duplicate a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline char *libsimple_estrdup(const char *\fIs\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_enstrdup () @@ -45,6 +47,7 @@ function that uses allocates the memory on the stack rather than on the heap, causing the return pointer to become invalid when the calling function returns. It is only available when compling with GCC or Clang. + .SH RETURN VALUE Upon successful completion, the .BR libsimple_strdupa (), @@ -68,8 +71,10 @@ by the .BR libsimple_strdupa () function, it is automatically deallocated when the calling function returns. + .SH ERRORS None. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -100,21 +105,32 @@ T{ .BR libsimple_estrdup (), T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO +.BR libsimple_aligned_strdup (3), .BR libsimple_enstrndup (3), .BR libsimple_memdup (3), -.BR libsimple_aligned_memdup (3), +.BR libsimple_enwcsdup (3), +.BR libsimple_wcsndup (3), +.BR libsimple_wmemdup (3), .BR strndup (3), -.BR strdup (3) +.BR strdup (3), +.BR wcsdup (3) diff --git a/man3/libsimple_enstrndup.3 b/man3/libsimple_enstrndup.3 index 66272b0..2c62600 100644 --- a/man3/libsimple_enstrndup.3 +++ b/man3/libsimple_enstrndup.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_ENSTRNDUP 3 2018-10-27 libsimple +.TH LIBSIMPLE_ENSTRNDUP 3 libsimple .SH NAME libsimple_enstrndup, libsimple_strndupa \- duplicate the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline char *libsimple_estrndup(const char *\fIs\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_enstrndup () @@ -45,6 +47,7 @@ function that uses allocates the memory on the stack rather than on the heap, causing the return pointer to become invalid when the calling function returns. It is only available when compling with GCC or Clang. + .SH RETURN VALUE Upon successful completion, the .BR libsimple_strndupa (), @@ -68,8 +71,10 @@ by the .BR libsimple_strndupa () function, it is automatically deallocated when the calling function returns. + .SH ERRORS None. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -100,21 +105,32 @@ T{ .BR libsimple_estrndup (), T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO +.BR libsimple_aligned_strndup (3), .BR libsimple_enstrdup (3), .BR libsimple_memdup (3), -.BR libsimple_aligned_memdup (3), +.BR libsimple_enwcsdup (3), +.BR libsimple_wcsndup (3), +.BR libsimple_wmemdup (3), .BR strndup (3), -.BR strdup (3) +.BR strdup (3), +.BR wcsdup (3) diff --git a/man3/libsimple_envaligned_reallocn.3 b/man3/libsimple_envaligned_reallocn.3 new file mode 120000 index 0000000..7c3a84f --- /dev/null +++ b/man3/libsimple_envaligned_reallocn.3 @@ -0,0 +1 @@ +libsimple_valigned_reallocn.3
\ No newline at end of file diff --git a/man3/libsimple_enwcsdup.3 b/man3/libsimple_enwcsdup.3 new file mode 100644 index 0000000..df013a8 --- /dev/null +++ b/man3/libsimple_enwcsdup.3 @@ -0,0 +1,136 @@ +.TH LIBSIMPLE_ENWCSDUP 3 libsimple +.SH NAME +libsimple_enwcsdup, libsimple_wcsdupa \- duplicate a wide-character string + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +wchar_t *libsimple_wcsdupa(const wchar_t *\fIs\fP); +wchar_t *libsimple_enwcsdup(int \fIstatus\fP, const wchar_t *\fIs\fP); +static inline char *libsimple_ewcsdup(const wchar_t *\fIs\fP); + +#ifndef wcsdupa +# define wcsdupa libsimple_wcsdupa +#endif +#ifndef enwcsdup +# define enwcsdup libsimple_enwcsdup +#endif +#ifndef ewcsdup +# define ewcsdup libsimple_ewcsdup +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_enwcsdup () +and +.BR libsimple_ewcsdup () +functions are versions of the +.BR wcsdup (3) +function that call the +.BR libsimple_enprintf (3) +function on failure, causing the process to print +an error message and exit. See +.BR libsimple_enprintf (3) +for more information. +.PP +The +.BR libsimple_wcsdupa () +function is implemented as a macro and is a version +of the +.BR wcsdup (3) +function that uses allocates the memory on the stack +rather than on the heap, causing the return pointer +to become invalid when the calling function returns. +It is only available when compling with GCC or Clang. + +.SH RETURN VALUE +Upon successful completion, the +.BR libsimple_wcsdupa (), +.BR libsimple_enwcsdup (), +and +.BR libsimple_ewcsdup () +functions return a non-null pointer, on failure the +.BR libsimple_enwcsdup (), +and +.BR libsimple_ewcsdup () +functions exit the process. The +.BR libsimple_wcsdupa () +function cannot fail, however the kernel +can kill the thread, and possibly the process, with a +.B SIGSEGV +signal if the memory cannot be allocated. +.PP +The returned pointer should be deallocated when it +is no longer needed, except for the pointer returned +by the +.BR libsimple_wcsdupa () +function, it is automatically deallocated when the +calling function returns. + +.SH ERRORS +None. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_wcsdupa (), +.br +.BR libsimple_enwcsdup (), +.br +.BR libsimple_ewcsdup (), +T} Thread safety MT-Safe +T{ +.BR libsimple_wcsdupa (), +.br +.BR libsimple_enwcsdup (), +.br +.BR libsimple_ewcsdup (), +T} Async-signal safety AS-Safe +T{ +.BR libsimple_wcsdupa (), +.br +.BR libsimple_enwcsdup (), +.br +.BR libsimple_ewcsdup (), +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_aligned_wcsdup (3), +.BR libsimple_enstrdup (3), +.BR libsimple_enstrndup (3), +.BR libsimple_memdup (3), +.BR libsimple_wcsndup (3), +.BR libsimple_wmemdup (3), +.BR strndup (3), +.BR strdup (3), +.BR wcsdup (3) diff --git a/man3/libsimple_enwcsndup.3 b/man3/libsimple_enwcsndup.3 new file mode 120000 index 0000000..57c8250 --- /dev/null +++ b/man3/libsimple_enwcsndup.3 @@ -0,0 +1 @@ +libsimple_wcsndup.3
\ No newline at end of file diff --git a/man3/libsimple_enwmemdup.3 b/man3/libsimple_enwmemdup.3 new file mode 120000 index 0000000..93381ef --- /dev/null +++ b/man3/libsimple_enwmemdup.3 @@ -0,0 +1 @@ +libsimple_wmemdup.3
\ No newline at end of file diff --git a/man3/libsimple_ereallocarray.3 b/man3/libsimple_ereallocarray.3 new file mode 120000 index 0000000..5f83973 --- /dev/null +++ b/man3/libsimple_ereallocarray.3 @@ -0,0 +1 @@ +libsimple_enreallocarray.3
\ No newline at end of file diff --git a/man3/libsimple_evaligned_reallocn.3 b/man3/libsimple_evaligned_reallocn.3 new file mode 120000 index 0000000..36205a3 --- /dev/null +++ b/man3/libsimple_evaligned_reallocn.3 @@ -0,0 +1 @@ +libsimple_envaligned_reallocn.3
\ No newline at end of file diff --git a/man3/libsimple_ewcsdup.3 b/man3/libsimple_ewcsdup.3 new file mode 120000 index 0000000..85a85a6 --- /dev/null +++ b/man3/libsimple_ewcsdup.3 @@ -0,0 +1 @@ +libsimple_enwcsdup.3
\ No newline at end of file diff --git a/man3/libsimple_ewcsndup.3 b/man3/libsimple_ewcsndup.3 new file mode 120000 index 0000000..801d72f --- /dev/null +++ b/man3/libsimple_ewcsndup.3 @@ -0,0 +1 @@ +libsimple_enwcsndup.3
\ No newline at end of file diff --git a/man3/libsimple_ewmemdup.3 b/man3/libsimple_ewmemdup.3 new file mode 120000 index 0000000..b2983f6 --- /dev/null +++ b/man3/libsimple_ewmemdup.3 @@ -0,0 +1 @@ +libsimple_enwmemdup.3
\ No newline at end of file diff --git a/man3/libsimple_getenv_e.3 b/man3/libsimple_getenv_e.3 index 7e3a3ca..0ed445b 100644 --- a/man3/libsimple_getenv_e.3 +++ b/man3/libsimple_getenv_e.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_GETENV_E 3 2018-10-20 libsimple +.TH LIBSIMPLE_GETENV_E 3 libsimple .SH NAME libsimple_getenv_e \- get value of an environment variable or the empty string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline const char *libsimple_getenv_e(const char *\fIname\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_getenv_e () @@ -29,15 +31,18 @@ that have not be come visible to other process via replacement of the process image, are visible to the .BR libsimple_getenv_e () function. + .SH RETURN VALUE If the environment variable .I name is defined, its value is returned, otherwise the empty string is returned. + .SH ERRORS The .BR libsimple_getenv_e () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -56,18 +61,25 @@ T{ .BR libsimple_getenv_e () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_getenv_ne (3), .BR getenv (3) diff --git a/man3/libsimple_getenv_ne.3 b/man3/libsimple_getenv_ne.3 index cd788d3..69c7de8 100644 --- a/man3/libsimple_getenv_ne.3 +++ b/man3/libsimple_getenv_ne.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_GETENV_NE 3 2018-10-20 libsimple +.TH LIBSIMPLE_GETENV_NE 3 libsimple .SH NAME libsimple_getenv_ne \- get non-empty value of an environment variable + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline char *libsimple_getenv_ne(const char *\fIname\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_getenv_ne () @@ -29,6 +31,7 @@ that have not be come visible to other process via replacement of the process image, are visible to the .BR libsimple_getenv_ne () function. + .SH RETURN VALUE If the environment variable .I name @@ -42,10 +45,12 @@ its content should not be modified. The returned pointer becomes invalid when the environment variable .I name is unset or modified. + .SH ERRORS The .BR libsimple_getenv_ne () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -64,18 +69,25 @@ T{ .BR libsimple_getenv_ne () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_getenv_e (3), .BR getenv (3) diff --git a/man3/libsimple_gmtime.3 b/man3/libsimple_gmtime.3 new file mode 100644 index 0000000..be050f2 --- /dev/null +++ b/man3/libsimple_gmtime.3 @@ -0,0 +1,133 @@ +.TH LIBSIMPLE_GMTIME 3 libsimple +.SH NAME +libsimple_gmtime \- get the current UTC time with leap second adjustment + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +int libsimple_gmtime(struct tm *\fItm\fP, struct timespec *\fIts\fP); +static inline void libsimple_engmtime(int \fIstatus\fPstruct tm *\fItm\fP, struct timespec *\fIts\fP); +static inline void libsimple_egmtime(struct tm *\fItm\fP, struct timespec *\fIts\fP); +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_gmtime (), +.BR libsimple_engmtime (), +and +.BR libsimple_egmtime () +functions get the current UTC time, with adjustments +for leap seconds insertions and deletions. +.PP +The +.BR libsimple_engmtime () +and +.BR libsimple_egmtime () +functions will terminate the process on failure. +On failure, the process's exit value will be +.I status +if the +.BR libsimple_engmtime () +function is used or +.IR libsimple_default_failure_exit (3) +if the +.BR libsimple_egmtime () +fucntion is used. +.PP +The local time is stored in +.IR *tm , +and the POSIX time (not timezone adjusted), +with leap second adjustments, is stored in +.I *ts +unless +.I ts +is +.IR NULL . +.I tm +may +.I not +be +.RI NULL . + +.SH RETURN VALUE +The +.BR libsimple_gmtime () +function return a 0 upon successful completion; +otherwise the they return -1 and set +.I errno +to indicate the error. The +.BR libsimple_engmtime () +and +.BR libsimple_egmtime () +functions terminate the processes on failure. + +.SH ERRORS +The +.BR libsimple_gmtime () +function will fail for the reasons specified for the +.BR gmtime_r (3) +function. +.PP +The +.BR libsimple_engmtime () +and +.BR libsimple_egmtime () +functions will terminate the process on failure. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_gmtime (), +.br +.BR libsimple_engmtime (), +.br +.BR libsimple_egmtime () +T} Thread safety MT-Safe +T{ +.BR libsimple_gmtime (), +.br +.BR libsimple_engmtime (), +.br +.BR libsimple_egmtime () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_gmtime (), +.br +.BR libsimple_engmtime (), +.br +.BR libsimple_egmtime () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_gmtime (3), +.BR ntp_adjtime (2), +.BR gmtime_r (3) diff --git a/man3/libsimple_inchrset.3 b/man3/libsimple_inchrset.3 index f07263c..44a3eb1 100644 --- a/man3/libsimple_inchrset.3 +++ b/man3/libsimple_inchrset.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_INCHRSET 3 2018-11-05 libsimple +.TH LIBSIMPLE_INCHRSET 3 libsimple .SH NAME libsimple_inchrset, libsimple_inchrcaseset \- the whether a character belongs to a set + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline int libsimple_inchrcaseset(int \fIc\fP, const char *\fIs\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_inchrset () @@ -39,6 +41,7 @@ The comparison is case-sensitive for the function, and case-insensitive for the .BR libsimple_inchrcaseset () function. + .SH RETURN VALUE The .BR libsimple_inchrset () @@ -49,12 +52,14 @@ functions returns 1 if is not the NUL byte but can be found in .IR s ; otherwise 0 is returned. + .SH ERRORS The .BR libsimple_inchrset () and .BR libsimple_inchrcaseset () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -79,18 +84,25 @@ T{ .BR libsimple_strchrnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcasechr (3), .BR strchr (3) diff --git a/man3/libsimple_localtime.3 b/man3/libsimple_localtime.3 new file mode 100644 index 0000000..0f6aa19 --- /dev/null +++ b/man3/libsimple_localtime.3 @@ -0,0 +1,133 @@ +.TH LIBSIMPLE_LOCALTIME 3 libsimple +.SH NAME +libsimple_localtime \- get the current local time with leap second adjustment + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +int libsimple_localtime(struct tm *\fItm\fP, struct timespec *\fIts\fP); +static inline void libsimple_enlocaltime(int \fIstatus\fPstruct tm *\fItm\fP, struct timespec *\fIts\fP); +static inline void libsimple_elocaltime(struct tm *\fItm\fP, struct timespec *\fIts\fP); +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_localtime (), +.BR libsimple_enlocaltime (), +and +.BR libsimple_elocaltime () +functions get the current local time, with adjustments +for leap seconds insertions and deletions. +.PP +The +.BR libsimple_enlocaltime () +and +.BR libsimple_elocaltime () +functions will terminate the process on failure. +On failure, the process's exit value will be +.I status +if the +.BR libsimple_enlocaltime () +function is used or +.IR libsimple_default_failure_exit (3) +if the +.BR libsimple_elocaltime () +fucntion is used. +.PP +The local time is stored in +.IR *tm , +and the POSIX time (not timezone adjusted), +with leap second adjustments, is stored in +.I *ts +unless +.I ts +is +.IR NULL . +.I tm +may +.I not +be +.RI NULL . + +.SH RETURN VALUE +The +.BR libsimple_localtime () +function return a 0 upon successful completion; +otherwise the they return -1 and set +.I errno +to indicate the error. The +.BR libsimple_enlocaltime () +and +.BR libsimple_elocaltime () +functions terminate the processes on failure. + +.SH ERRORS +The +.BR libsimple_localtime () +function will fail for the reasons specified for the +.BR localtime_r (3) +function. +.PP +The +.BR libsimple_enlocaltime () +and +.BR libsimple_elocaltime () +functions will terminate the process on failure. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_localtime (), +.br +.BR libsimple_enlocaltime (), +.br +.BR libsimple_elocaltime () +T} Thread safety MT-Safe +T{ +.BR libsimple_localtime (), +.br +.BR libsimple_enlocaltime (), +.br +.BR libsimple_elocaltime () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_localtime (), +.br +.BR libsimple_enlocaltime (), +.br +.BR libsimple_elocaltime () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_gmtime (3), +.BR ntp_adjtime (2), +.BR localtime_r (3) diff --git a/man3/libsimple_mallocz.3 b/man3/libsimple_mallocz.3 index 86254ec..54ca3e7 100644 --- a/man3/libsimple_mallocz.3 +++ b/man3/libsimple_mallocz.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MALLOCZ 3 2018-11-03 libsimple +.TH LIBSIMPLE_MALLOCZ 3 libsimple .SH NAME libsimple_mallocz \- allocate optionally initialised memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void *libsimple_emallocz(int \fIclear\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_mallocz (), @@ -80,6 +82,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_mallocz (), @@ -98,6 +101,7 @@ it indicate the error, and the and .BR libsimple_emallocz () functions terminated the process. + .SH ERRORS The .BR libsimple_mallocz () @@ -112,6 +116,7 @@ The and .BR libsimple_emallocz () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -142,18 +147,25 @@ T{ .BR libsimple_emallocz () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_vmallocn (3), @@ -161,7 +173,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_memalign.3 b/man3/libsimple_memalign.3 index 8bf04a1..8bbf57e 100644 --- a/man3/libsimple_memalign.3 +++ b/man3/libsimple_memalign.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMALIGN 3 2018-11-03 libsimple +.TH LIBSIMPLE_MEMALIGN 3 libsimple .SH NAME libsimple_memalign \- allocate memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void *libsimple_ememalign(size_t \fIalignment\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memalign (), @@ -68,6 +70,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_memalign (), @@ -86,6 +89,7 @@ it indicate the error, and the and .BR libsimple_ememalign () functions terminated the process. + .SH ERRORS The .BR libsimple_memalign () @@ -107,6 +111,7 @@ The and .BR libsimple_ememalign () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -137,14 +142,19 @@ T{ .BR libsimple_ememalign () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES Portable applications shall assume that pointer returned by the @@ -154,8 +164,10 @@ function can be deallocated with the functon, unless the namespaced alias .BR libsimple_memalign () is used explicitly. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -164,7 +176,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), .BR libsimple_vmemalignzn (3), diff --git a/man3/libsimple_memalignz.3 b/man3/libsimple_memalignz.3 index 11a70d7..f756539 100644 --- a/man3/libsimple_memalignz.3 +++ b/man3/libsimple_memalignz.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMALIGNZ 3 2018-11-03 libsimple +.TH LIBSIMPLE_MEMALIGNZ 3 libsimple .SH NAME libsimple_memalignz \- allocate optionally initialised memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void *libsimple_ememalignz(int \fIclear\fP, size_t \fIalignment\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memalignz (), @@ -69,6 +71,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_memalignz (), @@ -87,6 +90,7 @@ it indicate the error, and the and .BR libsimple_ememalignz () functions terminated the process. + .SH ERRORS The .BR libsimple_memalignz () @@ -108,6 +112,7 @@ The and .BR libsimple_ememalignz () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -138,18 +143,25 @@ T{ .BR libsimple_ememalignz () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -158,7 +170,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_vmemalignn (3), .BR libsimple_vmemalignzn (3), diff --git a/man3/libsimple_memcasechr.3 b/man3/libsimple_memcasechr.3 index d06a6d8..bfbea2f 100644 --- a/man3/libsimple_memcasechr.3 +++ b/man3/libsimple_memcasechr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASECHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMCASECHR 3 libsimple .SH NAME libsimple_memcasechr \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memcasechr(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcasechr () @@ -27,6 +29,7 @@ for the first occurence of the byte .BR char ). .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcasechr () @@ -40,10 +43,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memcasechr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_memcasechr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcasechr_inv (3), .BR libsimple_memrcasechr (3), diff --git a/man3/libsimple_memcasechr_inv.3 b/man3/libsimple_memcasechr_inv.3 index e14d7d4..c547403 100644 --- a/man3/libsimple_memcasechr_inv.3 +++ b/man3/libsimple_memcasechr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASECHR_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_MEMCASECHR_INV 3 libsimple .SH NAME libsimple_memcasechr_inv \- find different byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memcasechr_inv(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP) .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcasechr_inv () @@ -28,6 +30,7 @@ other than .BR char ). .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcasechr_inv () @@ -41,10 +44,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memcasechr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_memcasechr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcasechr (3), .BR libsimple_memchr_inv (3), diff --git a/man3/libsimple_memcasecmp.3 b/man3/libsimple_memcasecmp.3 index 63e0e27..a7ccf79 100644 --- a/man3/libsimple_memcasecmp.3 +++ b/man3/libsimple_memcasecmp.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASECMP 3 2018-10-21 libsimple +.TH LIBSIMPLE_MEMCASECMP 3 libsimple .SH NAME libsimple_memcasecmp \- compare two memory segments + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_memcasecmp(const void *\fIa\fP, const void *\fIb\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcasecmp () @@ -27,6 +29,7 @@ and The comparison is case-insensitive and made as if the strings were converted to lowercase and as .BR "unsigned char *" s. + .SH RETURN VALUE The .BR libsimple_memcasecmp () @@ -39,10 +42,12 @@ a positive value if is greater than .IR b , and 0 otherwise. + .SH ERRORS The .BR libsimple_memcasecmp () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -61,18 +66,25 @@ T{ .BR libsimple_memcasecmp () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcaseeq (3), .BR libsimple_memcaseeqlen (3), diff --git a/man3/libsimple_memcaseends.3 b/man3/libsimple_memcaseends.3 index 6605f79..1357f7b 100644 --- a/man3/libsimple_memcaseends.3 +++ b/man3/libsimple_memcaseends.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASEENDS 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMCASEENDS 3 libsimple .SH NAME libsimple_memcaseends \- checks end of memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_memcaseends(const void *\fIs\fP, size_t \fIn\fP, const void *\fIt\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcaseends () @@ -33,6 +35,7 @@ first bytes of .IR t . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcaseends () @@ -41,10 +44,12 @@ function returns 1 if ends with .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_memcaseends () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_memcaseends () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memends (3), .BR libsimple_memcasestarts (3), diff --git a/man3/libsimple_memcaseeq.3 b/man3/libsimple_memcaseeq.3 index 6e30970..c48b7c5 100644 --- a/man3/libsimple_memcaseeq.3 +++ b/man3/libsimple_memcaseeq.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASEEQ 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMCASEEQ 3 libsimple .SH NAME libsimple_memcaseeq \- check two memory segments for equality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_memcaseeq(const void *\fIa\fP, const void *\fIb\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcaseeq () @@ -26,6 +28,7 @@ and are equal. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcaseeq () @@ -35,10 +38,12 @@ and .I b are equal, with the possible exception if their case, otherwise it returns 0. + .SH ERRORS The .BR libsimple_memcaseeq () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -57,18 +62,25 @@ T{ .BR libsimple_memcaseeq () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memeq (3), .BR libsimple_memcaseeqlen (3), diff --git a/man3/libsimple_memcaseeqlen.3 b/man3/libsimple_memcaseeqlen.3 index f8779c8..341725a 100644 --- a/man3/libsimple_memcaseeqlen.3 +++ b/man3/libsimple_memcaseeqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASEEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMCASEEQLEN 3 libsimple .SH NAME libsimple_memcaseeqlen \- check initial commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ size_t libsimple_memcaseeqlen(const void *\fIa\fP, size_t \fIn\fP, const void *\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcaseeqlen () @@ -28,6 +30,7 @@ with size at their beginnings. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcaseeqlen () @@ -36,10 +39,12 @@ function returns the number of bytes and .I b have in common at their beginnings. + .SH ERRORS The .BR libsimple_memcaseeqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -58,18 +63,25 @@ T{ .BR libsimple_memcaseeqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcaseeq (3), .BR libsimple_memeqlen (3), diff --git a/man3/libsimple_memcasemem.3 b/man3/libsimple_memcasemem.3 index 37c6cda..ce4de17 100644 --- a/man3/libsimple_memcasemem.3 +++ b/man3/libsimple_memcasemem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASEMEM 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMCASEMEM 3 libsimple .SH NAME libsimple_memcasemem \- find byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memcasemem(const void *\fIhaystack\fP, size_t \fInhaystack\fP, c .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcasemem () @@ -27,6 +29,7 @@ with the size .IR nneedle . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcasemem () @@ -40,10 +43,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memcasemem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_memcasemem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memmem (3), .BR libsimple_memrcasemem (3), diff --git a/man3/libsimple_memcasescan.3 b/man3/libsimple_memcasescan.3 index 7479a05..ef2a6ec 100644 --- a/man3/libsimple_memcasescan.3 +++ b/man3/libsimple_memcasescan.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASESCAN 3 2018-11-17 libsimple +.TH LIBSIMPLE_MEMCASESCAN 3 libsimple .SH NAME libsimple_memcasescan \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memcasescan(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcasescan () @@ -29,6 +31,7 @@ If no such character exist in the memory segment, the memory segment's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcasescan () @@ -42,10 +45,12 @@ is the returned pointer. If no such offset exists, .I &s[n] is returned. + .SH ERRORS The .BR libsimple_memcasescan () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -64,18 +69,25 @@ T{ .BR libsimple_memcasescan () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcasescan_inv (3), .BR libsimple_memscan (3), diff --git a/man3/libsimple_memcasescan_inv.3 b/man3/libsimple_memcasescan_inv.3 index f58c222..d43529f 100644 --- a/man3/libsimple_memcasescan_inv.3 +++ b/man3/libsimple_memcasescan_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASESCAN_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_MEMCASESCAN_INV 3 libsimple .SH NAME libsimple_memcasescan_inv \- skip byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memcasescan_inv(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcasescan_inv () @@ -30,6 +32,7 @@ If no such character exist in the memory segment, the memory segment's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcasescan_inv () @@ -43,10 +46,12 @@ is the returned pointer. If no such offset exists, .I &s[n] is returned. + .SH ERRORS The .BR libsimple_memcasescan_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -65,18 +70,25 @@ T{ .BR libsimple_memcasescan_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcasescan (3), .BR libsimple_memscan_inv (3), diff --git a/man3/libsimple_memcasestarts.3 b/man3/libsimple_memcasestarts.3 index d8a7259..9e93a5f 100644 --- a/man3/libsimple_memcasestarts.3 +++ b/man3/libsimple_memcasestarts.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCASESTARTS 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMCASESTARTS 3 libsimple .SH NAME libsimple_memcasestarts \- checks beginning of memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_memcasestarts(const void *\fIs\fP, size_t \fIn\fP, const void *\fI .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcasestarts () @@ -31,6 +33,7 @@ first bytes of .IR t . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memcasestarts () @@ -39,10 +42,12 @@ function returns 1 if begins with .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_memcasestarts () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -61,18 +66,25 @@ T{ .BR libsimple_memcasestarts () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memstarts (3), .BR libsimple_memcaseends (3), diff --git a/man3/libsimple_memchr_inv.3 b/man3/libsimple_memchr_inv.3 index 23c8271..8003aa9 100644 --- a/man3/libsimple_memchr_inv.3 +++ b/man3/libsimple_memchr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCHR_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_MEMCHR_INV 3 libsimple .SH NAME libsimple_memchr_inv \- find different byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memchr_inv(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memchr_inv () @@ -28,6 +30,7 @@ other than .BR char ). .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memchr_inv () @@ -41,10 +44,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memchr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_memchr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcasechr_inv (3), .BR libsimple_memrchr_inv (3), diff --git a/man3/libsimple_memcmove.3 b/man3/libsimple_memcmove.3 index 0079e28..88d7e4f 100644 --- a/man3/libsimple_memcmove.3 +++ b/man3/libsimple_memcmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMCMOVE 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMCMOVE 3 libsimple .SH NAME libsimple_memcmove \- move bytes within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memcmove(void *\fIdest\fP, const void *\fIsrc\fP, int \fIc\fP, s .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memcmove () @@ -30,6 +32,7 @@ However the move stops after the character is moved. The arrays may overlap in the. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memcmove () @@ -43,10 +46,12 @@ after it was move, if the character was not moved .I NULL is returned. + .SH ERRORS The .BR libsimple_memcmove () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -65,18 +70,25 @@ T{ .BR libsimple_memcmove () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemcmove (3), .BR libsimple_mempmove (3), diff --git a/man3/libsimple_memdup.3 b/man3/libsimple_memdup.3 index e111574..8a6903d 100644 --- a/man3/libsimple_memdup.3 +++ b/man3/libsimple_memdup.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMDUP 3 2018-10-27 libsimple +.TH LIBSIMPLE_MEMDUP 3 libsimple .SH NAME libsimple_memdup \- duplicate bytes in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -26,10 +27,11 @@ static inline void *libsimple_ememdup(const void *\fIs\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memdup () -function constructs allocates memory and copies +function allocates memory and copies .I n first bytes from .I s @@ -57,6 +59,7 @@ function that uses allocates the memory on the stack rather than on the heap, causing the return pointer to become invalid when the calling function returns. It is only available when compling with GCC or Clang. + .SH RETURN VALUE Upon successful completion, the .BR libsimple_memdupa (), @@ -87,12 +90,14 @@ by the .BR libsimple_memdupa () function, it is automatically deallocated when the calling function returns. + .SH ERRORS The .BR libsimple_memdup () function may fail for any reason specified for the -.BR alloc (3) +.BR malloc (3) function. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -129,21 +134,32 @@ T{ .BR libsimple_ememdup (), T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_aligned_memdup (3), .BR libsimple_enstrndup (3), .BR libsimple_enstrdup (3), +.BR libsimple_enwcsdup (3), +.BR libsimple_wcsndup (3), +.BR libsimple_wmemdup (3), .BR strndup (3), -.BR strdup (3) +.BR strdup (3), +.BR wcsdup (3) diff --git a/man3/libsimple_memelem.3 b/man3/libsimple_memelem.3 index 4ccdb3a..cdab273 100644 --- a/man3/libsimple_memelem.3 +++ b/man3/libsimple_memelem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMELEM 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMELEM 3 libsimple .SH NAME libsimple_memelem \- find aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memelem(const void *\fIhaystack\fP, const void *\fIneedle\fP, si .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memelem () @@ -29,6 +31,7 @@ and with an offset equivalent to zero modulo .IR width . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memelem () @@ -44,10 +47,12 @@ the offset is equivalent to zero modulo If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memelem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_memelem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memelem_inv (3), .BR libsimple_memelemscan (3), diff --git a/man3/libsimple_memelem_inv.3 b/man3/libsimple_memelem_inv.3 index c3b3208..c87e590 100644 --- a/man3/libsimple_memelem_inv.3 +++ b/man3/libsimple_memelem_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMELEM_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMELEM_INV 3 libsimple .SH NAME libsimple_memelem_inv \- find different aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memelem_inv(const void *\fIhaystack\fP, const void *\fIneedle\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memelem_inv () @@ -30,6 +32,7 @@ and with an offset equivalent to zero modulo .IR width . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memelem_inv () @@ -45,10 +48,12 @@ the offset is equivalent to zero modulo If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memelem_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_memelem_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memelem (3), .BR libsimple_memelemscan_inv (3), diff --git a/man3/libsimple_memelemmove.3 b/man3/libsimple_memelemmove.3 index d566b5d..194ff79 100644 --- a/man3/libsimple_memelemmove.3 +++ b/man3/libsimple_memelemmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMELEMMOVE 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMELEMMOVE 3 libsimple .SH NAME libsimple_memelemmove, libsimple_memelemcpy \- copy or move elements within an array + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline void *libsimple_memelemcpy(void *\fIdest\fP, const void *\fIsrc\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memelemmove () @@ -43,6 +45,7 @@ The arrays may overlap in the function but not in the .BR libsimple_memelemcpy () function. + .SH RETURN VALUE The .BR libsimple_memelemmove () @@ -58,12 +61,14 @@ after it was copied. If the element was not copied .I NULL is returned. + .SH ERRORS The .BR libsimple_memelemmove () and .BR libsimple_memelemcpy () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -88,18 +93,25 @@ and .BR libsimple_memelemcpy () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemelemmove (3), .BR libsimple_mempmove (3), diff --git a/man3/libsimple_memelemscan.3 b/man3/libsimple_memelemscan.3 index 092508e..67b96cb 100644 --- a/man3/libsimple_memelemscan.3 +++ b/man3/libsimple_memelemscan.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMELEMSCAN 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMELEMSCAN 3 libsimple .SH NAME libsimple_memelemscan \- find aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memelemscan(const void *\fIhaystack\fP, const void *\fIneedle\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memelemscan () @@ -31,6 +33,7 @@ If no such character exist in the memory segment, the memory segment's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memelemscan () @@ -46,10 +49,12 @@ the offset is equivalent to zero modulo If no such offset exists, .I (void *)&((char *)haystack)[n*width] is returned. + .SH ERRORS The .BR libsimple_memelemscan () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -68,18 +73,25 @@ T{ .BR libsimple_memelemscan () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memelemscan_inv (3), .BR libsimple_memelem (3), diff --git a/man3/libsimple_memelemscan_inv.3 b/man3/libsimple_memelemscan_inv.3 index 3fdd8f8..24eb8ac 100644 --- a/man3/libsimple_memelemscan_inv.3 +++ b/man3/libsimple_memelemscan_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMELEMSCAN_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMELEMSCAN_INV 3 libsimple .SH NAME libsimple_memelemscan_inv \- skip aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memelemscan_inv(const void *\fIhaystack\fP, const void *\fIneedl .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memelemscan_inv () @@ -32,6 +34,7 @@ If no such character exist in the memory segment, the memory segment's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memelemscan_inv () @@ -47,10 +50,12 @@ the offset is equivalent to zero modulo If no such offset exists, .I (void *)&((char *)haystack)[n*width] is returned. + .SH ERRORS The .BR libsimple_memelemscan_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -69,18 +74,25 @@ T{ .BR libsimple_memelemscan_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memelemscan (3), .BR libsimple_memelem_inv (3), diff --git a/man3/libsimple_memends.3 b/man3/libsimple_memends.3 index 34db568..2529370 100644 --- a/man3/libsimple_memends.3 +++ b/man3/libsimple_memends.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMENDS 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMENDS 3 libsimple .SH NAME libsimple_memends \- checks end of memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_memends(const void *\fIs\fP, size_t \fIn\fP, const void *\fIt\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memends () @@ -33,6 +35,7 @@ first bytes of .IR t . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memends () @@ -41,10 +44,12 @@ function returns 1 if ends with .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_memends () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_memends () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcaseends (3), .BR libsimple_memstarts (3), diff --git a/man3/libsimple_memeq.3 b/man3/libsimple_memeq.3 index 6631328..a5683e5 100644 --- a/man3/libsimple_memeq.3 +++ b/man3/libsimple_memeq.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMEQ 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMEQ 3 libsimple .SH NAME libsimple_memeq \- check two memory segments for equality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_memeq(const void *\fIa\fP, const void *\fIb\fP, size .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memeq () @@ -26,6 +28,7 @@ and are equal. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memeq () @@ -34,10 +37,12 @@ function returns 1 one if and .I b are equal, otherwise it returns 0. + .SH ERRORS The .BR libsimple_memeq () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -56,18 +61,25 @@ T{ .BR libsimple_memeq () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcaseeq (3), .BR libsimple_memeqlen (3), diff --git a/man3/libsimple_memeqlen.3 b/man3/libsimple_memeqlen.3 index 6a03808..4344a39 100644 --- a/man3/libsimple_memeqlen.3 +++ b/man3/libsimple_memeqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMEQLEN 3 libsimple .SH NAME libsimple_memeqlen \- check initial commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ size_t libsimple_memeqlen(const void *\fIa\fP, size_t \fIn\fP, const void *\fIb\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memeqlen () @@ -28,6 +30,7 @@ with size at their beginnings. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memeqlen () @@ -36,10 +39,12 @@ function returns the number of bytes and .I b have in common at their beginnings. + .SH ERRORS The .BR libsimple_memeqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -58,18 +63,25 @@ T{ .BR libsimple_memeqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memeq (3), .BR libsimple_memcaseeqlen (3), diff --git a/man3/libsimple_memmem.3 b/man3/libsimple_memmem.3 index 30dea44..cb24cc4 100644 --- a/man3/libsimple_memmem.3 +++ b/man3/libsimple_memmem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMMEM 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMMEM 3 libsimple .SH NAME libsimple_memmem \- find byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memmem(const void *\fIhaystack\fP, size_t \fInhaystack\fP, const .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memmem () @@ -27,6 +29,7 @@ with the size .IR nneedle . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memmem () @@ -40,10 +43,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memmem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_memmem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrcasemem (3), .BR libsimple_memrmem (3), diff --git a/man3/libsimple_mempcpy.3 b/man3/libsimple_mempcpy.3 index c23a041..a10bba0 100644 --- a/man3/libsimple_mempcpy.3 +++ b/man3/libsimple_mempcpy.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMPCPY 3 2018-11-16 libsimple +.TH LIBSIMPLE_MEMPCPY 3 libsimple .SH NAME libsimple_mempcpy \- copy an array of bytes into another + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline void *libsimple_mempcpy(void *restrict \fIdest\fP, const void *res .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_mempcpy () @@ -31,6 +33,7 @@ must not overlap with the first .I n bytes of .IR src . + .SH RETURN VALUE The .BR libsimple_mempcpy () @@ -39,10 +42,12 @@ function returns the pointer with the offset .I n (the byte where the copy stopped). + .SH ERRORS The .BR libsimple_mempcpy () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -61,18 +66,25 @@ T{ .BR libsimple_mempcpy () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_mempmove (3), .BR libsimple_mempset (3), diff --git a/man3/libsimple_mempmove.3 b/man3/libsimple_mempmove.3 index 3545412..29b7e4e 100644 --- a/man3/libsimple_mempmove.3 +++ b/man3/libsimple_mempmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMPMOVE 3 2018-11-16 libsimple +.TH LIBSIMPLE_MEMPMOVE 3 libsimple .SH NAME libsimple_mempmove \- move bytes within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline void *libsimple_mempmove(void *\fIdest\fP, const void *\fIsrc\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_mempmove () @@ -24,6 +26,7 @@ bytes of into .IR dest . The arrays may overlap. + .SH RETURN VALUE The .BR libsimple_mempmove () @@ -32,10 +35,12 @@ function returns the pointer with the offset .I n (the byte where the copy stopped). + .SH ERRORS The .BR libsimple_mempmove () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -54,18 +59,25 @@ T{ .BR libsimple_mempmove () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_mempcpy (3), .BR libsimple_mempset (3), diff --git a/man3/libsimple_mempset.3 b/man3/libsimple_mempset.3 index e6ce289..31ebd06 100644 --- a/man3/libsimple_mempset.3 +++ b/man3/libsimple_mempset.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMPSET 3 2018-10-20 libsimple +.TH LIBSIMPLE_MEMPSET 3 libsimple .SH NAME libsimple_mempset \- fill an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline void *libsimple_mempset(void *\fIs\fP, int \fIc\fP, size_t \fIn\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_mempset () @@ -25,6 +27,7 @@ with the value .I c coverted to a .BR char . + .SH RETURN VALUE The .BR libsimple_mempset () @@ -33,10 +36,12 @@ function returns the pointer with the offset .I n (the byte where the copy stopped). + .SH ERRORS The .BR libsimple_mempset () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -55,18 +60,25 @@ T{ .BR libsimple_mempset () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_mempsetelem (3), .BR libsimple_mempcpy (3), diff --git a/man3/libsimple_mempsetelem.3 b/man3/libsimple_mempsetelem.3 index e10a252..805b3cd 100644 --- a/man3/libsimple_mempsetelem.3 +++ b/man3/libsimple_mempsetelem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMPSETELEM 3 2018-10-20 libsimple +.TH LIBSIMPLE_MEMPSETELEM 3 libsimple .SH NAME libsimple_mempsetelem \- fill an array with a value + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_mempsetelem(void *\fIbuf\fP, const void *\fIitem\fP, size_t \fIw .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_mempsetelem () @@ -25,6 +27,7 @@ copies of the element .I item with the size .IR width . + .SH RETURN VALUE The .BR libsimple_mempsetelem () @@ -33,10 +36,12 @@ function returns the pointer with the offset .I n*width (the byte where the copy stopped). + .SH ERRORS The .BR libsimple_mempsetelem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -55,18 +60,25 @@ T{ .BR libsimple_mempsetelem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memsetelem (3), .BR libsimple_mempset (3) diff --git a/man3/libsimple_memrcasechr.3 b/man3/libsimple_memrcasechr.3 index 5bb60b4..77322d5 100644 --- a/man3/libsimple_memrcasechr.3 +++ b/man3/libsimple_memrcasechr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRCASECHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMRCASECHR 3 libsimple .SH NAME libsimple_memrcasechr \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memrcasechr(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrcasechr () @@ -27,6 +29,7 @@ for the last occurence of the byte .BR char ). .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memrcasechr () @@ -40,10 +43,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memrcasechr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_memrcasechr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrcasechr_inv (3), .BR libsimple_memcasechr (3), diff --git a/man3/libsimple_memrcasechr_inv.3 b/man3/libsimple_memrcasechr_inv.3 index c5936a7..c9e5068 100644 --- a/man3/libsimple_memrcasechr_inv.3 +++ b/man3/libsimple_memrcasechr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRCASECHR_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_MEMRCASECHR_INV 3 libsimple .SH NAME libsimple_memrcasechr_inv \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memrcasechr_inv(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrcasechr_inv () @@ -28,6 +30,7 @@ other than .BR char ). .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memrcasechr_inv () @@ -41,10 +44,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memrcasechr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_memrcasechr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrcasechr (3), .BR libsimple_memcasechr_inv (3), diff --git a/man3/libsimple_memrcaseeqlen.3 b/man3/libsimple_memrcaseeqlen.3 index 9991e05..cf3734b 100644 --- a/man3/libsimple_memrcaseeqlen.3 +++ b/man3/libsimple_memrcaseeqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRCASEEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMRCASEEQLEN 3 libsimple .SH NAME libsimple_memrcaseeqlen \- check terminal commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ size_t libsimple_memrcaseeqlen(const void *\fIa\fP, size_t \fIn\fP, const void * .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrcaseeqlen () @@ -28,6 +30,7 @@ with size at their ends. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memrcaseeqlen () @@ -36,10 +39,12 @@ function returns the number of bytes and .I b have in common at their ends. + .SH ERRORS The .BR libsimple_memrcaseeqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -58,18 +63,25 @@ T{ .BR libsimple_memrcaseeqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memreqlen (3), .BR libsimple_memcaseeqlen (3), diff --git a/man3/libsimple_memrcasemem.3 b/man3/libsimple_memrcasemem.3 index 76b6ea5..e10fd9e 100644 --- a/man3/libsimple_memrcasemem.3 +++ b/man3/libsimple_memrcasemem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRCASEMEM 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMRCASEMEM 3 libsimple .SH NAME libsimple_memrcasemem \- find byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memrcasemem(const void *\fIhaystack\fP, size_t \fInhaystack\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrcasemem () @@ -27,6 +29,7 @@ with the size .IR nneedle . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_memrcasemem () @@ -40,10 +43,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memrcasemem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_memrcasemem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrmem (3), .BR libsimple_memcasemem (3), diff --git a/man3/libsimple_memrchr.3 b/man3/libsimple_memrchr.3 index 71d0c0a..b75e797 100644 --- a/man3/libsimple_memrchr.3 +++ b/man3/libsimple_memrchr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRCHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMRCHR 3 libsimple .SH NAME libsimple_memrchr \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memrchr(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrchr () @@ -27,6 +29,7 @@ for the last occurence of the byte .BR char ). .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memrchr () @@ -40,10 +43,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memrchr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_memrchr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrchr_inv (3), .BR libsimple_memrcasechr (3), diff --git a/man3/libsimple_memrchr_inv.3 b/man3/libsimple_memrchr_inv.3 index d498245..80af59c 100644 --- a/man3/libsimple_memrchr_inv.3 +++ b/man3/libsimple_memrchr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRCHR_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_MEMRCHR_INV 3 libsimple .SH NAME libsimple_memrchr_inv \- find different byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memrchr_inv(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrchr_inv () @@ -28,6 +30,7 @@ other than .BR char ). .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memrchr_inv () @@ -41,10 +44,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memrchr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_memrchr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrchr (3), .BR libsimple_memchr_inv (3), diff --git a/man3/libsimple_memrelem.3 b/man3/libsimple_memrelem.3 index 26bcfb8..8cbfba2 100644 --- a/man3/libsimple_memrelem.3 +++ b/man3/libsimple_memrelem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRELEM 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMRELEM 3 libsimple .SH NAME libsimple_memrelem \- find aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memrelem(const void *\fIhaystack\fP, const void *\fIneedle\fP, s .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrelem () @@ -29,6 +31,7 @@ and with an offset equivalent to zero modulo .IR width . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memrelem () @@ -44,10 +47,12 @@ the offset is equivalent to zero modulo If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memrelem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_memrelem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrelem_inv (3), .BR libsimple_rawmemrelem (3), diff --git a/man3/libsimple_memrelem_inv.3 b/man3/libsimple_memrelem_inv.3 index f3d5736..b2e7680 100644 --- a/man3/libsimple_memrelem_inv.3 +++ b/man3/libsimple_memrelem_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRELEM_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMRELEM_INV 3 libsimple .SH NAME libsimple_memrelem_inv \- find different aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memrelem_inv(const void *\fIhaystack\fP, const void *\fIneedle\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrelem_inv () @@ -30,6 +32,7 @@ and with an offset equivalent to zero modulo .IR width . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memrelem_inv () @@ -45,10 +48,12 @@ the offset is equivalent to zero modulo If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memrelem_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_memrelem_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrelem (3), .BR libsimple_rawmemrelem_inv (3), diff --git a/man3/libsimple_memreplace.3 b/man3/libsimple_memreplace.3 index 25fd6d1..45800bb 100644 --- a/man3/libsimple_memreplace.3 +++ b/man3/libsimple_memreplace.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMREPLACE 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMREPLACE 3 libsimple .SH NAME libsimple_memreplace \- replace bytes in an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline void *libsimple_memreplace(void *\fIs\fP, int \fIold\fP, int \fIne .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memreplace () @@ -29,15 +31,18 @@ with the byte .IR new . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memreplace () function returns .IR &s[n] . + .SH ERRORS The .BR libsimple_memreplace () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -56,18 +61,25 @@ T{ .BR libsimple_memreplace () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memtolower (3), .BR libsimple_memtoupper (3), diff --git a/man3/libsimple_memreplaceelem.3 b/man3/libsimple_memreplaceelem.3 index 6ad5c6c..63ffbef 100644 --- a/man3/libsimple_memreplaceelem.3 +++ b/man3/libsimple_memreplaceelem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMREPLACEELEM 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMREPLACEELEM 3 libsimple .SH NAME libsimple_memreplaceelem \- replace elements in an array + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memreplaceelem(void *\fIs\fP, int \fIold\fP, int \fInew\fP, size .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memreplaceelem () @@ -37,15 +39,18 @@ are aligned by .I width bytes in .IR s . + .SH RETURN VALUE The .BR libsimple_memreplaceelem () function returns .IR &s[n*width] . + .SH ERRORS The .BR libsimple_memreplaceelem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -64,18 +69,25 @@ T{ .BR libsimple_memreplaceelem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memreplace (3), .BR libsimple_strreplace (3), diff --git a/man3/libsimple_memreqlen.3 b/man3/libsimple_memreqlen.3 index 93b49b4..d4ef7d0 100644 --- a/man3/libsimple_memreqlen.3 +++ b/man3/libsimple_memreqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMREQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMREQLEN 3 libsimple .SH NAME libsimple_memreqlen \- check terminal commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ size_t libsimple_memreqlen(const void *\fIa\fP, size_t \fIn\fP, const void *\fIb .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memreqlen () @@ -28,6 +30,7 @@ with size at their ends. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memreqlen () @@ -36,10 +39,12 @@ function returns the number of bytes and .I b have in common at their ends. + .SH ERRORS The .BR libsimple_memreqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -58,18 +63,25 @@ T{ .BR libsimple_memreqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memrcaseeqlen (3), .BR libsimple_memeqlen (3), diff --git a/man3/libsimple_memrmem.3 b/man3/libsimple_memrmem.3 index 706fc03..95ebccd 100644 --- a/man3/libsimple_memrmem.3 +++ b/man3/libsimple_memrmem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMRMEM 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMRMEM 3 libsimple .SH NAME libsimple_memrmem \- find byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memrmem(const void *\fIhaystack\fP, size_t \fInhaystack\fP, cons .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memrmem () @@ -27,6 +29,7 @@ with the size .IR nneedle . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memrmem () @@ -40,10 +43,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_memrmem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_memrmem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcasemem (3), .BR libsimple_memmem (3), diff --git a/man3/libsimple_memscan.3 b/man3/libsimple_memscan.3 index 1d85c6a..b79677a 100644 --- a/man3/libsimple_memscan.3 +++ b/man3/libsimple_memscan.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMSCAN 3 2018-11-17 libsimple +.TH LIBSIMPLE_MEMSCAN 3 libsimple .SH NAME libsimple_memscan \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memscan(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memscan () @@ -29,6 +31,7 @@ If no such character exist in the memory segment, the memory segment's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memscan () @@ -42,10 +45,12 @@ is the returned pointer. If no such offset exists, .I &r[n] is returned. + .SH ERRORS The .BR libsimple_memscan () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -64,18 +69,25 @@ T{ .BR libsimple_memscan () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memscan_inv (3), .BR libsimple_memcasescan (3), diff --git a/man3/libsimple_memscan_inv.3 b/man3/libsimple_memscan_inv.3 index 39a6071..805e42f 100644 --- a/man3/libsimple_memscan_inv.3 +++ b/man3/libsimple_memscan_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMSCAN_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_MEMSCAN_INV 3 libsimple .SH NAME libsimple_memscan_inv \- skip byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_memscan_inv(const void *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memscan_inv () @@ -30,6 +32,7 @@ If no such character exist in the memory segment, the memory segment's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memscan_inv () @@ -43,10 +46,12 @@ is the returned pointer. If no such offset exists, .I &r[n] is returned. + .SH ERRORS The .BR libsimple_memscan_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -65,18 +70,25 @@ T{ .BR libsimple_memscan_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memscan (3), .BR libsimple_memchr_inv (3), diff --git a/man3/libsimple_memsetelem.3 b/man3/libsimple_memsetelem.3 index 91e5b63..37e7022 100644 --- a/man3/libsimple_memsetelem.3 +++ b/man3/libsimple_memsetelem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMSETELEM 3 2018-10-20 libsimple +.TH LIBSIMPLE_MEMSETELEM 3 libsimple .SH NAME libsimple_memsetelem \- fill an array with a value + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline void *libsimple_memsetelem(void *\fIbuf\fP, const void *\fIitem\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memsetelem () @@ -25,15 +27,18 @@ copies of the element .I item with the size .IR width . + .SH RETURN VALUE The .BR libsimple_memsetelem () function returns the pointer .IR buf . + .SH ERRORS The .BR libsimple_memsetelem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -52,18 +57,25 @@ T{ .BR libsimple_memsetelem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_mempsetelem (3), .BR memset (3) diff --git a/man3/libsimple_memstarts.3 b/man3/libsimple_memstarts.3 index 527397b..9c6b0ef 100644 --- a/man3/libsimple_memstarts.3 +++ b/man3/libsimple_memstarts.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMSTARTS 3 2018-10-23 libsimple +.TH LIBSIMPLE_MEMSTARTS 3 libsimple .SH NAME libsimple_memstarts \- checks beginning of memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_memstarts(const void *\fIs\fP, size_t \fIn\fP, const void *\fIt\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memstarts () @@ -31,6 +33,7 @@ first bytes of .IR t . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_memstarts () @@ -39,10 +42,12 @@ function returns 1 if begins with .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_memstarts () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -61,18 +66,25 @@ T{ .BR libsimple_memstarts () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcasestarts (3), .BR libsimple_memends (3), diff --git a/man3/libsimple_memtolower.3 b/man3/libsimple_memtolower.3 index be09689..facb09d 100644 --- a/man3/libsimple_memtolower.3 +++ b/man3/libsimple_memtolower.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMTOLOWER 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMTOLOWER 3 libsimple .SH NAME libsimple_memtolower, libsimple_memptolower \- convert a character array to lower case + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ void *libsimple_memptolower(void *\fIdest\fP, const void *\fIsrc\fP, size_t \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memtolower () @@ -33,6 +35,7 @@ All upper case ASCII characters will be converted to lower case. The arrays may overlap, and there is an optimisation for the case where .IR dest==src . + .SH RETURN VALUE The .BR libsimple_memtolower () @@ -43,12 +46,14 @@ The .BR libsimple_memptolower () function returns .IR &dest[n] . + .SH ERRORS The .BR libsimple_memtolower () and .BR libsimple_memptolower () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -73,18 +78,25 @@ T{ .BR libsimple_memptolower () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memtoupper (3), .BR libsimple_memreplace (3), diff --git a/man3/libsimple_memtoupper.3 b/man3/libsimple_memtoupper.3 index 6f45d54..17a747c 100644 --- a/man3/libsimple_memtoupper.3 +++ b/man3/libsimple_memtoupper.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MEMTOUPPER 3 2018-11-25 libsimple +.TH LIBSIMPLE_MEMTOUPPER 3 libsimple .SH NAME libsimple_memtoupper, libsimple_memptoupper \- convert a character array to upper case + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ void *libsimple_memptoupper(void *\fIdest\fP, const void *\fIsrc\fP, size_t \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memtoupper () @@ -33,6 +35,7 @@ All lower case ASCII characters will be converted to upper case. The arrays may overlap, and there is an optimisation for the case where .IR dest==src . + .SH RETURN VALUE The .BR libsimple_memtoupper () @@ -43,12 +46,14 @@ The .BR libsimple_memptoupper () function returns .IR &dest[n] . + .SH ERRORS The .BR libsimple_memtoupper () and .BR libsimple_memptoupper () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -73,18 +78,25 @@ T{ .BR libsimple_memptoupper () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memtolower (3), .BR libsimple_memreplace (3), diff --git a/man3/libsimple_minimise_number_string.3 b/man3/libsimple_minimise_number_string.3 index 310b725..19533c6 100644 --- a/man3/libsimple_minimise_number_string.3 +++ b/man3/libsimple_minimise_number_string.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MINIMISE_NUMBER_STRING 3 2018-10-31 libsimple +.TH LIBSIMPLE_MINIMISE_NUMBER_STRING 3 libsimple .SH NAME libsimple_minimise_number_string \- ninimise a numerical string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_minimise_number_string(char *\fIs\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_minimise_number_string () @@ -21,15 +23,18 @@ function minimises a string representing a real value with the assumption that the string is on the format .B [+-]\e?[0-9]*\e(\e.[0-9]*\e)\e? (repeating decimals are not supported). + .SH RETURN VALUE The .BR libsimple_minimise_number_string () function returns the pointer .IR s . + .SH ERRORS The .BR libsimple_minimise_number_string () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -48,17 +53,24 @@ T{ .BR libsimple_minimise_number_string () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_timespectostr (3) diff --git a/man3/libsimple_multimespec.3 b/man3/libsimple_multimespec.3 index 34b352d..ad99b22 100644 --- a/man3/libsimple_multimespec.3 +++ b/man3/libsimple_multimespec.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_MULTIMESPEC 3 2018-10-29 libsimple +.TH LIBSIMPLE_MULTIMESPEC 3 libsimple .SH NAME libsimple_multimespec, libsimple_multimeval \- multiply a duration with an integer + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ int libsimple_multimeval(struct timeval *\fIprod\fP, const struct timeval *\fImu .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_multimespec () @@ -36,6 +38,7 @@ is in its valid range ([0, 1000000000) for .BR libsimple_multimespec () and [0, 1000000) for .BR libsimple_multimeval ()). + .SH RETURN VALUE The .BR libsimple_multimespec () @@ -45,6 +48,7 @@ functions return 0 on successful completion; otherwise, \-1 is returned and .I errno is set to indicate the error. + .SH ERRORS The .BR libsimple_multimespec () @@ -75,6 +79,7 @@ function and to for the .BR libsimple_multimeval () function. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -99,18 +104,25 @@ T{ .BR libsimple_multimeval () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_sumtimespec (3), .BR libsimple_difftimespec (3), diff --git a/man3/libsimple_posix_memalignz.3 b/man3/libsimple_posix_memalignz.3 index 3ea4655..a82605f 100644 --- a/man3/libsimple_posix_memalignz.3 +++ b/man3/libsimple_posix_memalignz.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_POSIX_MEMALIGNZ 3 2018-11-03 libsimple +.TH LIBSIMPLE_POSIX_MEMALIGNZ 3 libsimple .SH NAME libsimple_posix_memalignz \- allocate optionally initialised memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void libsimple_eposix_memalignz(void **\fImemptr\fP, int \fIclear\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_posix_memalignz (), @@ -73,6 +75,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_posix_memalignz () @@ -86,6 +89,7 @@ and .BR libsimple_eposix_memalignz () functions do not return a value, but terminated the process on failure. + .SH ERRORS The .BR libsimple_posix_memalignz () @@ -112,6 +116,7 @@ The and .BR libsimple_eposix_memalignz () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -142,18 +147,25 @@ T{ .BR libsimple_eposix_memalignz () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -162,7 +174,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_pvalloc.3 b/man3/libsimple_pvalloc.3 index b6cf4c6..9440712 100644 --- a/man3/libsimple_pvalloc.3 +++ b/man3/libsimple_pvalloc.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_PVALLOC 3 2018-11-03 libsimple +.TH LIBSIMPLE_PVALLOC 3 libsimple .SH NAME libsimple_pvalloc \- allocate memory with page size alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void *libsimple_epvalloc(size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_pvalloc (), @@ -60,6 +62,7 @@ function is used or if the .BR libsimple_epvalloc () function is used. + .SH RETURN VALUE The .BR libsimple_pvalloc (), @@ -78,6 +81,7 @@ it indicate the error, and the and .BR libsimple_epvalloc () functions terminated the process. + .SH ERRORS The .BR libsimple_pvalloc () @@ -95,6 +99,7 @@ The and .BR libsimple_epvalloc () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -125,14 +130,19 @@ T{ .BR libsimple_epvalloc () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES Portable applications shall assume that pointer returned by the @@ -146,8 +156,10 @@ is used explicitly. The GNU implementation of .BR pvalloc (3) is \(dqMT-Unsafe init\(dq. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -156,7 +168,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_pvallocz.3 b/man3/libsimple_pvallocz.3 index c758fcd..1fcc898 100644 --- a/man3/libsimple_pvallocz.3 +++ b/man3/libsimple_pvallocz.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_PVALLOCZ 3 2018-11-03 libsimple +.TH LIBSIMPLE_PVALLOCZ 3 libsimple .SH NAME libsimple_pvallocz \- allocate optionally initialised memory with page size alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void *libsimple_epvallocz(int \fIclear\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_pvallocz (), @@ -68,6 +70,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_pvallocz (), @@ -86,6 +89,7 @@ it indicate the error, and the and .BR libsimple_epvallocz () functions terminated the process. + .SH ERRORS The .BR libsimple_pvallocz () @@ -103,6 +107,7 @@ The and .BR libsimple_epvallocz () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -133,20 +138,27 @@ T{ .BR libsimple_epvallocz () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES The GNU implementation of .BR pvalloc (3) is \(dqMT-Unsafe init\(dq. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -155,7 +167,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_rawmemcasechr.3 b/man3/libsimple_rawmemcasechr.3 index 455a818..a6f3b31 100644 --- a/man3/libsimple_rawmemcasechr.3 +++ b/man3/libsimple_rawmemcasechr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMCASECHR 3 2018-10-21 libsimple +.TH LIBSIMPLE_RAWMEMCASECHR 3 libsimple .SH NAME libsimple_rawmemcasechr \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemcasechr(const void *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemcasechr () @@ -31,6 +33,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_rawmemcasechr () @@ -41,10 +44,12 @@ with a minimal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_rawmemcasechr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_rawmemcasechr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemcasechr_inv (3), .BR libsimple_memcasechr (3), diff --git a/man3/libsimple_rawmemcasechr_inv.3 b/man3/libsimple_rawmemcasechr_inv.3 index f5241a2..f282c7b 100644 --- a/man3/libsimple_rawmemcasechr_inv.3 +++ b/man3/libsimple_rawmemcasechr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMCASECHR_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_RAWMEMCASECHR_INV 3 libsimple .SH NAME libsimple_rawmemcasechr_inv \- find different byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemcasechr_inv(const void *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemcasechr_inv () @@ -32,6 +34,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_rawmemcasechr_inv () @@ -42,10 +45,12 @@ with a minimal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_rawmemcasechr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -64,18 +69,25 @@ T{ .BR libsimple_rawmemcasechr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemcasechr (3), .BR libsimple_memcasechr_inv (3), diff --git a/man3/libsimple_rawmemchr.3 b/man3/libsimple_rawmemchr.3 index 1df9b02..f2bf84c 100644 --- a/man3/libsimple_rawmemchr.3 +++ b/man3/libsimple_rawmemchr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMCHR 3 2018-10-21 libsimple +.TH LIBSIMPLE_RAWMEMCHR 3 libsimple .SH NAME libsimple_rawmemchr \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemchr(const void *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemchr () @@ -31,6 +33,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemchr () @@ -41,10 +44,12 @@ with a minimal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_rawmemchr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_rawmemchr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemchr_inv (3), .BR libsimple_rawmemcasechr (3), diff --git a/man3/libsimple_rawmemchr_inv.3 b/man3/libsimple_rawmemchr_inv.3 index 011e957..4fd5a48 100644 --- a/man3/libsimple_rawmemchr_inv.3 +++ b/man3/libsimple_rawmemchr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMCHR_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_RAWMEMCHR_INV 3 libsimple .SH NAME libsimple_rawmemchr_inv \- find different byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemchr_inv(const void *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemchr_inv () @@ -32,6 +34,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemchr_inv () @@ -42,10 +45,12 @@ with a minimal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_rawmemchr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -64,18 +69,25 @@ T{ .BR libsimple_rawmemchr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemchr (3), .BR libsimple_memchr_inv (3), diff --git a/man3/libsimple_rawmemcmove.3 b/man3/libsimple_rawmemcmove.3 index 51e9ef4..d4df247 100644 --- a/man3/libsimple_rawmemcmove.3 +++ b/man3/libsimple_rawmemcmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMCMOVE 3 2018-11-25 libsimple +.TH LIBSIMPLE_RAWMEMCMOVE 3 libsimple .SH NAME libsimple_rawmemcmove, libsimple_rawmemccpy \- copy or move bytes within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline void *libsimple_rawmemccpy(void *\fIdest\fP, const void *\fIsrc\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemcmove () @@ -40,6 +42,7 @@ function but not in the function. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemcmove () @@ -55,12 +58,14 @@ after it was copied. If the character does not exist in .IR src , the behaviour is undefined. + .SH ERRORS The .BR libsimple_rawmemcmove () and .BR libsimple_rawmemccpy () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -85,18 +90,25 @@ and .BR libsimple_rawmemccpy () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memcmove (3), .BR libsimple_mempmove (3), diff --git a/man3/libsimple_rawmemelem.3 b/man3/libsimple_rawmemelem.3 index 62c986c..348ce14 100644 --- a/man3/libsimple_rawmemelem.3 +++ b/man3/libsimple_rawmemelem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMELEM 3 2018-11-25 libsimple +.TH LIBSIMPLE_RAWMEMELEM 3 libsimple .SH NAME libsimple_rawmemelem \- find aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemelem(const void *\fIhaystack\fP, const void *\fIneedle\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemelem () @@ -33,6 +35,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemelem () @@ -46,10 +49,12 @@ is the returned pointer, and such that the offset is equivalent to zero modulo .IR width . If no such offset exists, the behaviour is undefined. + .SH ERRORS The .BR libsimple_rawmemelem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -68,18 +73,25 @@ T{ .BR libsimple_rawmemelem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemelem_inv (3), .BR libsimple_rawmemrelem (3), diff --git a/man3/libsimple_rawmemelem_inv.3 b/man3/libsimple_rawmemelem_inv.3 index 28e5bef..cd179c2 100644 --- a/man3/libsimple_rawmemelem_inv.3 +++ b/man3/libsimple_rawmemelem_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMELEM_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_RAWMEMELEM_INV 3 libsimple .SH NAME libsimple_rawmemelem_inv \- find different aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemelem_inv(const void *\fIhaystack\fP, const void *\fIneedle .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemelem_inv () @@ -34,6 +36,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemelem_inv () @@ -47,10 +50,12 @@ is the returned pointer, and such that the offset is equivalent to zero modulo .IR width . If no such offset exists, the behaviour is undefined. + .SH ERRORS The .BR libsimple_rawmemelem_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -69,18 +74,25 @@ T{ .BR libsimple_rawmemelem_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemelem (3), .BR libsimple_rawmemrelem_inv (3), diff --git a/man3/libsimple_rawmemelemmove.3 b/man3/libsimple_rawmemelemmove.3 index cafd956..da7b242 100644 --- a/man3/libsimple_rawmemelemmove.3 +++ b/man3/libsimple_rawmemelemmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMELEMMOVE 3 2018-11-25 libsimple +.TH LIBSIMPLE_RAWMEMELEMMOVE 3 libsimple .SH NAME libsimple_rawmemelemmove, libsimple_rawmemelemcpy \- copy or move elements within an array + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline void *libsimple_rawmemelemcpy(void *\fIdest\fP, const void *\fIsrc .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemelemmove () @@ -41,6 +43,7 @@ The arrays may overlap in the function but not in the .BR libsimple_rawmemelemcpy () function. + .SH RETURN VALUE The .BR libsimple_rawmemelemmove () @@ -56,12 +59,14 @@ after it was copied. If the element does not exist in .IR src , the behaviour is undefined. + .SH ERRORS The .BR libsimple_rawmemelemmove () and .BR libsimple_rawmemelemcpy () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -86,18 +91,25 @@ and .BR libsimple_rawmemelemcpy () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_memelemmove (3), .BR libsimple_mempmove (3), diff --git a/man3/libsimple_rawmemrcasechr.3 b/man3/libsimple_rawmemrcasechr.3 index 2959691..4ae1adb 100644 --- a/man3/libsimple_rawmemrcasechr.3 +++ b/man3/libsimple_rawmemrcasechr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMRCASECHR 3 2018-10-21 libsimple +.TH LIBSIMPLE_RAWMEMRCASECHR 3 libsimple .SH NAME libsimple_rawmemrcasechr \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemrcasechr(const void *s, int c, size_t n); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemrcasechr () @@ -33,6 +35,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_rawmemrcasechr () @@ -43,10 +46,12 @@ with a maximal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_rawmemrcasechr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -65,18 +70,25 @@ T{ .BR libsimple_rawmemrcasechr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemrcasechr_inv (3), .BR libsimple_rawmemrchr (3), diff --git a/man3/libsimple_rawmemrcasechr_inv.3 b/man3/libsimple_rawmemrcasechr_inv.3 index 060779d..7c82736 100644 --- a/man3/libsimple_rawmemrcasechr_inv.3 +++ b/man3/libsimple_rawmemrcasechr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMRCASECHR_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_RAWMEMRCASECHR_INV 3 libsimple .SH NAME libsimple_rawmemrcasechr_inv \- find different byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemrcasechr_inv(const void *s, int c, size_t n); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemrcasechr_inv () @@ -34,6 +36,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_rawmemrcasechr_inv () @@ -44,10 +47,12 @@ with a maximal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_rawmemrcasechr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_rawmemrcasechr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemrcasechr (3), .BR libsimple_rawmemrchr_inv (3), diff --git a/man3/libsimple_rawmemrchr.3 b/man3/libsimple_rawmemrchr.3 index 5bf0fd6..5bd898c 100644 --- a/man3/libsimple_rawmemrchr.3 +++ b/man3/libsimple_rawmemrchr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMRCHR 3 2018-10-21 libsimple +.TH LIBSIMPLE_RAWMEMRCHR 3 libsimple .SH NAME libsimple_rawmemrchr \- find byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemrchr(const void *s, int c, size_t n); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemrchr () @@ -33,6 +35,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemrchr () @@ -43,10 +46,12 @@ with a maximal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_rawmemrchr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -65,18 +70,25 @@ T{ .BR libsimple_rawmemrchr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemrchr_inv (3), .BR libsimple_rawmemrcasechr (3), diff --git a/man3/libsimple_rawmemrchr_inv.3 b/man3/libsimple_rawmemrchr_inv.3 index 28bd733..4603026 100644 --- a/man3/libsimple_rawmemrchr_inv.3 +++ b/man3/libsimple_rawmemrchr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMRCHR_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_RAWMEMRCHR_INV 3 libsimple .SH NAME libsimple_rawmemrchr_inv \- find different byte in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemrchr_inv(const void *s, int c, size_t n); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemrchr_inv () @@ -34,6 +36,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemrchr_inv () @@ -44,10 +47,12 @@ with a maximal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_rawmemrchr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_rawmemrchr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemrchr (3), .BR libsimple_rawmemrcasechr_inv (3), diff --git a/man3/libsimple_rawmemrelem.3 b/man3/libsimple_rawmemrelem.3 index 4ac85aa..1628f2f 100644 --- a/man3/libsimple_rawmemrelem.3 +++ b/man3/libsimple_rawmemrelem.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMRELEM 3 2018-11-25 libsimple +.TH LIBSIMPLE_RAWMEMRELEM 3 libsimple .SH NAME libsimple_rawmemrelem \- find aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemrelem(const void *\fIhaystack\fP, const void *\fIneedle\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemrelem () @@ -34,6 +36,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemrelem () @@ -47,10 +50,12 @@ is the returned pointer, and such that the offset is equivalent to zero modulo .IR width . If no such offset exists, the behaviour is undefined. + .SH ERRORS The .BR libsimple_rawmemrelem () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -69,18 +74,25 @@ T{ .BR libsimple_rawmemrelem () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemrelem_inv (3), .BR libsimple_memrelem (3), diff --git a/man3/libsimple_rawmemrelem_inv.3 b/man3/libsimple_rawmemrelem_inv.3 index ee16eb9..1bedba9 100644 --- a/man3/libsimple_rawmemrelem_inv.3 +++ b/man3/libsimple_rawmemrelem_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_RAWMEMRELEM_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_RAWMEMRELEM_INV 3 libsimple .SH NAME libsimple_rawmemrelem_inv \- find different aligned byte string in memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ void *libsimple_rawmemrelem_inv(const void *\fIhaystack\fP, const void *\fIneedl .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_rawmemrelem_inv () @@ -35,6 +37,7 @@ occurence, its behaviour is undefined if this is not the case. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_rawmemrelem_inv () @@ -48,10 +51,12 @@ is the returned pointer, and such that the offset is equivalent to zero modulo .IR width . If no such offset exists, the behaviour is undefined. + .SH ERRORS The .BR libsimple_rawmemrelem_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -70,18 +75,25 @@ T{ .BR libsimple_rawmemrelem_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_rawmemrelem (3), .BR libsimple_memrelem_inv (3), diff --git a/man3/libsimple_reallocarray.3 b/man3/libsimple_reallocarray.3 new file mode 100644 index 0000000..c6c6635 --- /dev/null +++ b/man3/libsimple_reallocarray.3 @@ -0,0 +1,203 @@ +.TH LIBSIMPLE_REALLOCARRAY 3 libsimple +.SH NAME +libsimple_reallocarray \- reallocate memory + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_reallocarray(void *\fIptr\fP, size_t \fIn\fP, size_t \fIm\fP); +static inline void *libsimple_enreallocarray(int \fIstatus\fP, void *\fIptr\fP, size_t \fIn\fP, size_t \fIm\fP); +static inline void *libsimple_ereallocarray(void *\fIptr\fP, size_t \fIn\fP, size_t \fIm\fP); + +#ifndef reallocarray +# define reallocarray libsimple_reallocarray +#endif +#ifndef enreallocarray +# define enreallocarray libsimple_enreallocarray +#endif +#ifndef ereallocarray +# define ereallocarray libsimple_ereallocarray +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_reallocarray (), +.BR libsimple_enreallocarray (), +and +.BR libsimple_ereallocarray () +functions are wrappers for the +.BR realloc (3) +function, they reallocate memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignof(max_align_t) +to the allocated memory of +.I n*m +bytes. The behaviour is unspecified if +.I n +or +.I m +is 0. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I n*m +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is not deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +The +.BR libsimple_enreallocarray () +and +.BR libsimple_ereallocarray () +functions will terminate the process if the memory +cannot be allocated, by calling the +.BR libsimple_enprintf () +and +.BR libsimple_eprintf () +functions, respectively. +On failure, the process's exit value will be +.I status +if the +.BR libsimple_enreallocarray () +function is used or +.IR libsimple_default_failure_exit (3) +if the +.BR libsimple_ereallocarray () +function is used. + +.SH RETURN VALUE +The +.BR libsimple_reallocarray (), +.BR libsimple_enreallocarray (), +and +.BR libsimple_ereallocarray () +functions return a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_reallocarray () +function returns +.B NULL +and set +.I errno +it indicate the error, and the +.BR libsimple_enreallocarray () +and +.BR libsimple_ereallocarray () +functions terminated the process. + +.SH ERRORS +The +.BR libsimple_reallocarray () +function will fail for the reasons specified for the +.BR realloc (3) +function. +.PP +The +.BR libsimple_enreallocarray () +and +.BR libsimple_ereallocarray () +functions will terminate the process on failure. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_reallocarray (), +.br +.BR libsimple_enreallocarray (), +.br +.BR libsimple_ereallocarray () +T} Thread safety MT-Safe +T{ +.BR libsimple_reallocarray (), +.br +.BR libsimple_enreallocarray (), +.br +.BR libsimple_ereallocarray () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_reallocarray (), +.br +.BR libsimple_enreallocarray (), +.br +.BR libsimple_ereallocarray () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_reallocarrayf.3 b/man3/libsimple_reallocarrayf.3 new file mode 100644 index 0000000..b3c2504 --- /dev/null +++ b/man3/libsimple_reallocarrayf.3 @@ -0,0 +1,155 @@ +.TH LIBSIMPLE_REALLOCARRAYF 3 libsimple +.SH NAME +libsimple_reallocarrayf \- reallocate memory + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_reallocarrayf(void *\fIptr\fP, size_t \fIn\fP, size_t \fIm\fP); + +#ifndef reallocarrayf +# define reallocarrayf libsimple_reallocarrayf +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_reallocarrayf () +function is a wrapper for the +.BR realloc(3) +function that reallocates memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignof(max_align_t) +to the allocated memory of +.I n*m +bytes. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I n*m +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +If +.I n +or +.I m +is 0, +.I ptr +is deallocaed and +.B NULL +is returned, however portable applications should, +unless the namespaced alias is used, assume the +behaviour is unspecifed in this case. + +.SH RETURN VALUE +The +.BR libsimple_reallocarrayf (), +function returns a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_reallocarrayf () +function returns +.B NULL +and set +.I errno +it indicate the error. + +.SH ERRORS +The +.BR libsimple_reallocarrayf () +function will fail for the reasons specified for the +.BR realloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_reallocarrayf () +T} Thread safety MT-Safe +T{ +.BR libsimple_reallocarrayf () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_reallocarrayf () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_reallocf.3 b/man3/libsimple_reallocf.3 new file mode 100644 index 0000000..b0c2d1b --- /dev/null +++ b/man3/libsimple_reallocf.3 @@ -0,0 +1,153 @@ +.TH LIBSIMPLE_REALLOCF 3 libsimple +.SH NAME +libsimple_reallocf \- reallocate memory + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_reallocf(void *\fIptr\fP, size_t \fIn\fP); + +#ifndef reallocf +# define reallocf libsimple_reallocf +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_reallocf () +function is a wrapper for the +.BR realloc(3) +function that reallocates memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignof(max_align_t) +to the allocated memory of +.I n +bytes. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I n +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +If +.I n +is 0, +.I ptr +is deallocaed and +.B NULL +is returned, however portable applications should, +unless the namespaced alias is used, assume the +behaviour is unspecifed in this case. + +.SH RETURN VALUE +The +.BR libsimple_reallocf (), +function returns a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_reallocf () +function returns +.B NULL +and set +.I errno +it indicate the error. + +.SH ERRORS +The +.BR libsimple_reallocf () +function will fail for the reasons specified for the +.BR realloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_reallocf () +T} Thread safety MT-Safe +T{ +.BR libsimple_reallocf () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_reallocf () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_reallocfn.3 b/man3/libsimple_reallocfn.3 new file mode 120000 index 0000000..d06b871 --- /dev/null +++ b/man3/libsimple_reallocfn.3 @@ -0,0 +1 @@ +libsimple_vreallocfn.3
\ No newline at end of file diff --git a/man3/libsimple_stpmove.3 b/man3/libsimple_stpmove.3 index 62282d6..d9e8db1 100644 --- a/man3/libsimple_stpmove.3 +++ b/man3/libsimple_stpmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STPMOVE 3 2018-11-16 libsimple +.TH LIBSIMPLE_STPMOVE 3 libsimple .SH NAME libsimple_stpmove \- move a string within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline void *libsimple_stpmove(void *\fIdest\fP, const void *\fIsrc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_stpmove () @@ -23,6 +25,7 @@ NUL byte that terminates it, into .IR dest . The arrays may overlap. + .SH RETURN VALUE The .BR libsimple_stpmove () @@ -32,10 +35,12 @@ with the offset of the length of string .I str (the address of the copied NUL byte in .IR dest ). + .SH ERRORS The .BR libsimple_stpmove () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -54,18 +59,25 @@ T{ .BR libsimple_stpmove () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strmove (3), .BR libsimple_stpnmove (3), diff --git a/man3/libsimple_stpnmove.3 b/man3/libsimple_stpnmove.3 index eed841a..f2fd267 100644 --- a/man3/libsimple_stpnmove.3 +++ b/man3/libsimple_stpnmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STPNMOVE 3 2018-11-16 libsimple +.TH LIBSIMPLE_STPNMOVE 3 libsimple .SH NAME libsimple_stpnmove \- move a string within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline void *libsimple_stpnmove(void *\fIdest\fP, const void *\fIsrc\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_stpnmove () @@ -25,6 +27,7 @@ NUL byte that terminates it (if any), into .IR dest . The arrays may overlap. + .SH RETURN VALUE The .BR libsimple_stpnmove () @@ -37,10 +40,12 @@ with the offset of the length of string or .I &dest[n] if no NUL byte was copied). + .SH ERRORS The .BR libsimple_stpnmove () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -59,18 +64,25 @@ T{ .BR libsimple_stpnmove () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strnmove (3), .BR libsimple_stpmove (3), diff --git a/man3/libsimple_strcasechr.3 b/man3/libsimple_strcasechr.3 index 0f1a7f3..7e6d897 100644 --- a/man3/libsimple_strcasechr.3 +++ b/man3/libsimple_strcasechr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASECHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCASECHR 3 libsimple .SH NAME libsimple_strcasechr \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strcasechr(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcasechr () @@ -27,6 +29,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcasechr () @@ -39,10 +42,12 @@ where is the returned pointer, if no such offset exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strcasechr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -61,18 +66,25 @@ T{ .BR libsimple_strcasechr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcasechr_inv (3), .BR libsimple_strcasechrnul (3), diff --git a/man3/libsimple_strcasechr_inv.3 b/man3/libsimple_strcasechr_inv.3 index baf5574..cfd2862 100644 --- a/man3/libsimple_strcasechr_inv.3 +++ b/man3/libsimple_strcasechr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASECHR_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRCASECHR_INV 3 libsimple .SH NAME libsimple_strcasechr_inv \- find a different character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strcasechr_inv(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcasechr_inv () @@ -28,6 +30,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcasechr_inv () @@ -40,10 +43,12 @@ where is the returned pointer, if no such offset exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strcasechr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strcasechr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcasechr (3), .BR libsimple_strchr_inv (3), diff --git a/man3/libsimple_strcasechrnul.3 b/man3/libsimple_strcasechrnul.3 index 08dbce4..550893a 100644 --- a/man3/libsimple_strcasechrnul.3 +++ b/man3/libsimple_strcasechrnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASECHRNUL 3 2018-10-21 libsimple +.TH LIBSIMPLE_STRCASECHRNUL 3 libsimple .SH NAME libsimple_strcasechrnul \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strcasechrnul(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcasechrnul () @@ -27,6 +29,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcasechrnul () @@ -37,10 +40,12 @@ with a minimal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_strcasechrnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -59,18 +64,25 @@ T{ .BR libsimple_strcasechrnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcasechrnul_inv (3), .BR libsimple_strcasechr (3), diff --git a/man3/libsimple_strcasechrnul_inv.3 b/man3/libsimple_strcasechrnul_inv.3 index 61c8179..01c085c 100644 --- a/man3/libsimple_strcasechrnul_inv.3 +++ b/man3/libsimple_strcasechrnul_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASECHRNUL_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_STRCASECHRNUL_INV 3 libsimple .SH NAME libsimple_strcasechrnul_inv \- skip a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strcasechrnul_inv(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcasechrnul_inv () @@ -28,6 +30,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcasechrnul_inv () @@ -38,10 +41,12 @@ with a minimal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_strcasechrnul_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -60,18 +65,25 @@ T{ .BR libsimple_strcasechrnul_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcasechrnul (3), .BR libsimple_strcasechr_inv (3), diff --git a/man3/libsimple_strcasecmpnul.3 b/man3/libsimple_strcasecmpnul.3 index 2b0afe6..1f4561e 100644 --- a/man3/libsimple_strcasecmpnul.3 +++ b/man3/libsimple_strcasecmpnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASECMPNUL 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCASECMPNUL 3 libsimple .SH NAME libsimple_strcasecmpnul \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strcasecmpnul(const char *\fIa\fP, const char *\fIb\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcasecmpnul () @@ -32,6 +34,7 @@ greater than the shorter string. The comparison is case-insensitive and made as if the strings were converted to lowercase and as .BR "unsigned char *" s. + .SH RETURN VALUE The .BR libsimple_strcasecmpnul () @@ -44,10 +47,12 @@ a positive value if is greater than .IR b , and 0 otherwise. + .SH ERRORS The .BR libsimple_strcasecmpnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_strcasecmpnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcmpnul (3), .BR libsimple_strcaseeqnul (3), diff --git a/man3/libsimple_strcaseends.3 b/man3/libsimple_strcaseends.3 index f658699..22e015f 100644 --- a/man3/libsimple_strcaseends.3 +++ b/man3/libsimple_strcaseends.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASEENDS 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCASEENDS 3 libsimple .SH NAME libsimple_strcaseends \- check the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_strcaseends(const char *\fIs\fP, const char *\fIt\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcaseends () @@ -23,6 +25,7 @@ ends with the string .IR t . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcaseends () @@ -31,10 +34,12 @@ function returns 1 if the string ends with the string .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_strcaseends () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -53,18 +58,25 @@ T{ .BR libsimple_strcaseends () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strends (3), .BR libsimple_strcasestarts (3), diff --git a/man3/libsimple_strcaseeq.3 b/man3/libsimple_strcaseeq.3 index b1a25bd..e0dbf7f 100644 --- a/man3/libsimple_strcaseeq.3 +++ b/man3/libsimple_strcaseeq.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASEEQ 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCASEEQ 3 libsimple .SH NAME libsimple_strcaseeq \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strcaseeq(const char *\fIa\fP, const char *\fIb\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcaseeq () @@ -25,16 +27,19 @@ neither of which may be .BR NULL . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcaseeq () function returns 1 if the strings are equals, with the possible exception of the case, otherwise it returns 0. + .SH ERRORS The .BR libsimple_strcaseeq () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -53,18 +58,25 @@ T{ .BR libsimple_strcaseeq () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcaseeqnul (3), .BR libsimple_streq (3), diff --git a/man3/libsimple_strcaseeqlen.3 b/man3/libsimple_strcaseeqlen.3 index 6adba9c..975300e 100644 --- a/man3/libsimple_strcaseeqlen.3 +++ b/man3/libsimple_strcaseeqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASEEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCASEEQLEN 3 libsimple .SH NAME libsimple_strcaseeqlen \- check initial commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ size_t libsimple_strcaseeqlen(const char *\fIa\fP, const char *\fIb\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcaseeqlen () @@ -24,6 +26,7 @@ have in common the string at their beginnings. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcaseeqlen () @@ -32,10 +35,12 @@ function returns the number of bytes and .I b have in common at their beginnings. + .SH ERRORS The .BR libsimple_strcaseeqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -54,18 +59,25 @@ T{ .BR libsimple_strcaseeqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcaseeq (3), .BR libsimple_streqlen (3), diff --git a/man3/libsimple_strcaseeqnul.3 b/man3/libsimple_strcaseeqnul.3 index fa26a17..27595b0 100644 --- a/man3/libsimple_strcaseeqnul.3 +++ b/man3/libsimple_strcaseeqnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASEEQNUL 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCASEEQNUL 3 libsimple .SH NAME libsimple_strcaseeqnul \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strcaseeqnul(const char *\fIa\fP, const char *\fIb\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcaseeqnul () @@ -25,16 +27,19 @@ both of which may be .BR NULL . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcaseeqnul () function returns 1 if the strings are equals, with the possible exception of the case, otherwise it returns 0. + .SH ERRORS The .BR libsimple_strcaseeqnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -53,18 +58,25 @@ T{ .BR libsimple_strcaseeqnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcaseeq (3), .BR libsimple_streqnul (3), diff --git a/man3/libsimple_strcasestarts.3 b/man3/libsimple_strcasestarts.3 index 0f9d689..bf6786c 100644 --- a/man3/libsimple_strcasestarts.3 +++ b/man3/libsimple_strcasestarts.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASESTARTS 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCASESTARTS 3 libsimple .SH NAME libsimple_strcasestarts \- check the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strcasestarts(const char *\fIs\fP, const char *\fIt\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcasestarts () @@ -23,6 +25,7 @@ starts with the string .IR t . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcasestarts () @@ -31,10 +34,12 @@ function returns 1 if the string begins with the string .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_strcasestarts () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -53,18 +58,25 @@ T{ .BR libsimple_strcasestarts () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strstarts (3), .BR libsimple_strcaseends (3), diff --git a/man3/libsimple_strcasestr.3 b/man3/libsimple_strcasestr.3 index 8ee2c45..47b396f 100644 --- a/man3/libsimple_strcasestr.3 +++ b/man3/libsimple_strcasestr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCASESTR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCASESTR 3 libsimple .SH NAME libsimple_strcasestr \- find a substring in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strcasestr(const char *\fIhaystack\fP, const char *\fIneedle\fP) .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcasestr () @@ -23,6 +25,7 @@ the first occurrence of the substring .IR needle . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strcasestr () @@ -38,10 +41,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strcasestr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -60,18 +65,25 @@ T{ .BR libsimple_strcasestr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrcasestr (3), .BR libsimple_strncasestr (3), diff --git a/man3/libsimple_strchr_inv.3 b/man3/libsimple_strchr_inv.3 index e1cdf53..df2fda5 100644 --- a/man3/libsimple_strchr_inv.3 +++ b/man3/libsimple_strchr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCHR_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRCHR_INV 3 libsimple .SH NAME libsimple_strchr_inv \- find a different character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strchr_inv(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strchr_inv () @@ -28,6 +30,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strchr_inv () @@ -40,10 +43,12 @@ where is the returned pointer, if no such offset exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strchr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strchr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcasechr_inv (3), .BR libsimple_strchrnul_inv (3), diff --git a/man3/libsimple_strchrnul.3 b/man3/libsimple_strchrnul.3 index ed54f0b..13c577b 100644 --- a/man3/libsimple_strchrnul.3 +++ b/man3/libsimple_strchrnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCHRNUL 3 2018-10-21 libsimple +.TH LIBSIMPLE_STRCHRNUL 3 libsimple .SH NAME libsimple_strchrnul \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strchrnul(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strchrnul () @@ -27,6 +29,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strchrnul () @@ -37,10 +40,12 @@ with a minimal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_strchrnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -59,18 +64,25 @@ T{ .BR libsimple_strchrnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_charstrnul_inv (3), .BR libsimple_strcasechrnul (3), diff --git a/man3/libsimple_strchrnul_inv.3 b/man3/libsimple_strchrnul_inv.3 index 4664d1a..1ce6e42 100644 --- a/man3/libsimple_strchrnul_inv.3 +++ b/man3/libsimple_strchrnul_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCHRNUL_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_STRCHRNUL_INV 3 libsimple .SH NAME libsimple_strchrnul_inv \- skip a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strchrnul_inv(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strchrnul_inv () @@ -28,6 +30,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strchrnul_inv () @@ -38,10 +41,12 @@ with a minimal offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_strchrnul_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -60,18 +65,25 @@ T{ .BR libsimple_strchrnul_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_charstrnul (3), .BR libsimple_strchr_inv (3), diff --git a/man3/libsimple_strcmove.3 b/man3/libsimple_strcmove.3 index 328e696..4888832 100644 --- a/man3/libsimple_strcmove.3 +++ b/man3/libsimple_strcmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCMOVE 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRCMOVE 3 libsimple .SH NAME libsimple_strcmove, libsimple_strccpy \- copy or move a string within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline char *libsimple_strccpy(char *restrict \fIdest\fP, const char *res .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcmove () @@ -41,6 +43,7 @@ function but not in the function. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strcmove () @@ -56,12 +59,14 @@ after it was copied, if the character was not copied .I NULL is returned. + .SH ERRORS The .BR libsimple_strcmove () and .BR libsimple_strccpy () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -86,18 +91,25 @@ T{ .BR libsimple_strccpy () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strmove (3), .BR libsimple_stpmove (3), diff --git a/man3/libsimple_strcmpnul.3 b/man3/libsimple_strcmpnul.3 index 9f6ec47..01a512c 100644 --- a/man3/libsimple_strcmpnul.3 +++ b/man3/libsimple_strcmpnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRCMPNUL 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRCMPNUL 3 libsimple .SH NAME libsimple_strcmpnul \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strcmpnul(const char *\fIa\fP, const char *\fIb\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strcmpnul () @@ -32,6 +34,7 @@ greater than the shorter string. The comparison is case-sensitive and made as if the strings were .IR "unsigned char *" s. + .SH RETURN VALUE The .BR libsimple_strcmpnul () @@ -44,10 +47,12 @@ a positive value if is greater than .IR b , and 0 otherwise. + .SH ERRORS The .BR libsimple_strcmpnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_strcmpnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcasecmpnul (3), .BR libsimple_streqnul (3), diff --git a/man3/libsimple_strend.3 b/man3/libsimple_strend.3 index adfdf6f..a3a1bfe 100644 --- a/man3/libsimple_strend.3 +++ b/man3/libsimple_strend.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STREND 3 2018-10-23 libsimple +.TH LIBSIMPLE_STREND 3 libsimple .SH NAME libsimple_strend \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,12 +15,14 @@ static inline char *libsimple_strend(const char *\fIs\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strend () function scans the string .I s for its end. + .SH RETURN VALUE The .BR libsimple_strend () @@ -30,10 +33,12 @@ with an offset such that where .I r is the returned pointer. + .SH ERRORS The .BR libsimple_strend () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -52,18 +57,25 @@ T{ .BR libsimple_strend () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strchrnul (3), .BR libsimple_strnend (3), diff --git a/man3/libsimple_strends.3 b/man3/libsimple_strends.3 index 9ab8b45..c7d55c5 100644 --- a/man3/libsimple_strends.3 +++ b/man3/libsimple_strends.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRENDS 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRENDS 3 libsimple .SH NAME libsimple_strends \- check the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_strends(const char *\fIs\fP, const char *\fIt\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strends () @@ -23,6 +25,7 @@ ends with the string .IR t . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strends () @@ -31,10 +34,12 @@ function returns 1 if the string ends with the string .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_strends () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -53,18 +58,25 @@ T{ .BR libsimple_strends () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcaseends (3), .BR libsimple_strstarts (3), diff --git a/man3/libsimple_streq.3 b/man3/libsimple_streq.3 index 76c1779..2a1fada 100644 --- a/man3/libsimple_streq.3 +++ b/man3/libsimple_streq.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STREQ 3 2018-10-23 libsimple +.TH LIBSIMPLE_STREQ 3 libsimple .SH NAME libsimple_streq \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_streq(const char *\fIa\fP, const char *\fIb\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_streq () @@ -25,15 +27,18 @@ neither of which may be .BR NULL . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_streq () function returns 1 if the strings are equals, otherwise it returns 0. + .SH ERRORS The .BR libsimple_streq () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -52,18 +57,25 @@ T{ .BR libsimple_streq () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_streqnul (3), .BR libsimple_strcaseeq (3), diff --git a/man3/libsimple_streqlen.3 b/man3/libsimple_streqlen.3 index cb92bc6..2ec78fe 100644 --- a/man3/libsimple_streqlen.3 +++ b/man3/libsimple_streqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STREQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_STREQLEN 3 libsimple .SH NAME libsimple_streqlen \- check initial commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ size_t libsimple_streqlen(const char *\fIa\fP, const char *\fIb\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_streqlen () @@ -24,6 +26,7 @@ have in common the string at their beginnings. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_streqlen () @@ -32,10 +35,12 @@ function returns the number of bytes and .I b have in common at their beginnings. + .SH ERRORS The .BR libsimple_streqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -54,18 +59,25 @@ T{ .BR libsimple_streqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_streq (3), .BR libsimple_strreqlen (3), diff --git a/man3/libsimple_streqnul.3 b/man3/libsimple_streqnul.3 index 84ccf88..f2d7d07 100644 --- a/man3/libsimple_streqnul.3 +++ b/man3/libsimple_streqnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STREQNUL 3 2018-10-23 libsimple +.TH LIBSIMPLE_STREQNUL 3 libsimple .SH NAME libsimple_streqnul \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_streqnul(const char *\fIa\fP, const char *\fIb\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_streqnul () @@ -25,15 +27,18 @@ both of which may be .BR NULL . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_streqnul () function returns 1 if the strings are equals, otherwise it returns 0. + .SH ERRORS The .BR libsimple_streqnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -52,18 +57,25 @@ T{ .BR libsimple_streqnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_streq (3), .BR libsimple_strcaseeqnul (3), diff --git a/man3/libsimple_strisutf8.3 b/man3/libsimple_strisutf8.3 index ff8f609..0a525f1 100644 --- a/man3/libsimple_strisutf8.3 +++ b/man3/libsimple_strisutf8.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRISUTF8 3 2018-11-16 libsimple +.TH LIBSIMPLE_STRISUTF8 3 libsimple .SH NAME libsimple_strisutf8, libsimple_strnisutf8, libsimple_memisutf8 \- check if a string is encoded in UTF-8 + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ int libsimple_memisutf8(const char *\fIstring\fP, size_t \fIn\fP, int \fIallow_m .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strisutf8 (), @@ -65,6 +67,7 @@ function is a .B const char * rather than a .BR "const void *" . + .SH RETURN VALUE The .BR libsimple_strisutf8 (), @@ -76,6 +79,7 @@ function returns 1 if the is in valid UTF-8 (Modified UTF-8 if .I allow_modified_nul is non-zero); otherwise 0 is returned. + .SH ERRORS The .BR libsimple_strisutf8 (), @@ -83,6 +87,7 @@ The and .BR libsimple_memisutf8 () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -113,17 +118,24 @@ T{ .BR libsimple_memisutf8 () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO, None. diff --git a/man3/libsimple_strmove.3 b/man3/libsimple_strmove.3 index 90d5dfc..1b03800 100644 --- a/man3/libsimple_strmove.3 +++ b/man3/libsimple_strmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRMOVE 3 2018-11-16 libsimple +.TH LIBSIMPLE_STRMOVE 3 libsimple .SH NAME libsimple_strmove \- move a string within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline char *libsimple_strmove(char *\fIdest\fP, const char *\fIsrc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strmove () @@ -23,15 +25,18 @@ NUL byte that terminates it, into .IR dest . The arrays may overlap. + .SH RETURN VALUE The .BR libsimple_strmove () function returns the pointer .IR dest . + .SH ERRORS The .BR libsimple_strmove () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -50,18 +55,25 @@ T{ .BR libsimple_strmove () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_stpmove (3), .BR libsimple_strnmove (3), diff --git a/man3/libsimple_strncasechr.3 b/man3/libsimple_strncasechr.3 index b0a1c96..064a588 100644 --- a/man3/libsimple_strncasechr.3 +++ b/man3/libsimple_strncasechr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASECHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCASECHR 3 libsimple .SH NAME libsimple_strncasechr \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strncasechr(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncasechr () @@ -30,6 +32,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncasechr () @@ -44,10 +47,12 @@ offset less than .I n exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strncasechr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_strncasechr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncasechr_inv (3), .BR libsimple_strncasechrnul (3), diff --git a/man3/libsimple_strncasechr_inv.3 b/man3/libsimple_strncasechr_inv.3 index c23fe84..11ba3f6 100644 --- a/man3/libsimple_strncasechr_inv.3 +++ b/man3/libsimple_strncasechr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASECHR_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRNCASECHR_INV 3 libsimple .SH NAME libsimple_strncasechr_inv \- find a different character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strncasechr_inv(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncasechr_inv () @@ -31,6 +33,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncasechr_inv () @@ -45,10 +48,12 @@ offset less than .I n exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strncasechr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_strncasechr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncasechr (3), .BR libsimple_strncasechrnul_inv (3), diff --git a/man3/libsimple_strncasechrnul.3 b/man3/libsimple_strncasechrnul.3 index d73f186..fd757a8 100644 --- a/man3/libsimple_strncasechrnul.3 +++ b/man3/libsimple_strncasechrnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASECHRNUL 3 2018-10-21 libsimple +.TH LIBSIMPLE_STRNCASECHRNUL 3 libsimple .SH NAME libsimple_strncasechrnul \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strncasechrnul(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP) .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncasechrnul () @@ -30,6 +32,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncasechrnul () @@ -45,10 +48,12 @@ offset less than exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strncasechrnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_strncasechrnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncasechrnul_inv (3), .BR libsimple_strncasechr (3), diff --git a/man3/libsimple_strncasechrnul_inv.3 b/man3/libsimple_strncasechrnul_inv.3 index 48cced8..ad409ab 100644 --- a/man3/libsimple_strncasechrnul_inv.3 +++ b/man3/libsimple_strncasechrnul_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASECHRNUL_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_STRNCASECHRNUL_INV 3 libsimple .SH NAME libsimple_strncasechrnul_inv \- skip a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strncasechrnul_inv(const char *\fIs\fP, int \fIc\fP, size_t \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncasechrnul_inv () @@ -31,6 +33,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncasechrnul_inv () @@ -46,10 +49,12 @@ offset less than exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strncasechrnul_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -68,18 +73,25 @@ T{ .BR libsimple_strncasechrnul_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncasechrnul (3), .BR libsimple_strncasechr_inv (3), diff --git a/man3/libsimple_strncasecmpnul.3 b/man3/libsimple_strncasecmpnul.3 index 959ea78..25b7239 100644 --- a/man3/libsimple_strncasecmpnul.3 +++ b/man3/libsimple_strncasecmpnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASECMPNUL 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCASECMPNUL 3 libsimple .SH NAME libsimple_strncasecmpnul \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strncasecmpnul(const char *\fIa\fP, const char *\fIb .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncasecmpnul () @@ -38,6 +40,7 @@ greater than the shorter string. The comparison is case-insensitive and made as if the strings were converted to lowercase and as .BR "unsigned char *" s. + .SH RETURN VALUE The .BR libsimple_strncasecmpnul () @@ -50,10 +53,12 @@ a positive value if is greater than .IR b , and 0 otherwise. + .SH ERRORS The .BR libsimple_strncasecmpnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -72,18 +77,25 @@ T{ .BR libsimple_strncasecmpnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncmpnul (3), .BR libsimple_strncaseeqnul (3), diff --git a/man3/libsimple_strncaseends.3 b/man3/libsimple_strncaseends.3 index 5bdc0d9..c9911ef 100644 --- a/man3/libsimple_strncaseends.3 +++ b/man3/libsimple_strncaseends.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASEENDS 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCASEENDS 3 libsimple .SH NAME libsimple_strncaseends \- check the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_strncaseends(const char *\fIs\fP, const char *\fIt\fP, size_t \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncaseends () @@ -26,6 +28,7 @@ ends with the string .IR t . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncaseends () @@ -34,10 +37,12 @@ function returns 1 if the string ends with the string .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_strncaseends () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -56,18 +61,25 @@ T{ .BR libsimple_strncaseends () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strnends (3), .BR libsimple_strncasestarts (3), diff --git a/man3/libsimple_strncaseeq.3 b/man3/libsimple_strncaseeq.3 index 55c2f79..5b7a6a9 100644 --- a/man3/libsimple_strncaseeq.3 +++ b/man3/libsimple_strncaseeq.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASEEQ 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCASEEQ 3 libsimple .SH NAME libsimple_strncaseeq \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strncaseeq(const char *\fIa\fP, const char *\fIb\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncaseeq () @@ -31,16 +33,19 @@ neither of which may be .BR NULL . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncaseeq () function returns 1 if the strings are equals, with the possible exception of the case, otherwise it returns 0. + .SH ERRORS The .BR libsimple_strncaseeq () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -59,18 +64,25 @@ T{ .BR libsimple_strncaseeq () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncaseeqnul (3), .BR libsimple_strneq (3), diff --git a/man3/libsimple_strncaseeqlen.3 b/man3/libsimple_strncaseeqlen.3 index 8fbc236..72cc85e 100644 --- a/man3/libsimple_strncaseeqlen.3 +++ b/man3/libsimple_strncaseeqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASEEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCASEEQLEN 3 libsimple .SH NAME libsimple_strncaseeqlen \- check initial commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ size_t libsimple_strncaseeqlen(const char *\fIa\fP, const char *\fIb\fP, size_t .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncaseeqlen () @@ -30,6 +32,7 @@ bytes unless it is shorter, at their beginnings. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncaseeqlen () @@ -40,10 +43,12 @@ and (both truncated to .I n bytes) have in common at their beginnings. + .SH ERRORS The .BR libsimple_strncaseeqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strncaseeqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcaseeq (3), .BR libsimple_streqlen (3), diff --git a/man3/libsimple_strncaseeqnul.3 b/man3/libsimple_strncaseeqnul.3 index 743d4be..b713996 100644 --- a/man3/libsimple_strncaseeqnul.3 +++ b/man3/libsimple_strncaseeqnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASEEQNUL 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCASEEQNUL 3 libsimple .SH NAME libsimple_strncaseeqnul \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strncaseeqnul(const char *\fIa\fP, const char *\fIb\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncaseeqnul () @@ -31,16 +33,19 @@ both of which may be .BR NULL . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncaseeqnul () function returns 1 if the strings are equals, with the possible exception of the case, otherwise it returns 0. + .SH ERRORS The .BR libsimple_strncaseeqnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -59,18 +64,25 @@ T{ .BR libsimple_strncaseeqnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncaseeq (3), .BR libsimple_strneqnul (3), diff --git a/man3/libsimple_strncasestarts.3 b/man3/libsimple_strncasestarts.3 index b1efd80..9cd63dd 100644 --- a/man3/libsimple_strncasestarts.3 +++ b/man3/libsimple_strncasestarts.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASESTARTS 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCASESTARTS 3 libsimple .SH NAME libsimple_strncasestarts \- check the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_strncasestarts(const char *\fIs\fP, const char *\fIt\fP, size_t \f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncasestarts () @@ -26,6 +28,7 @@ starts with the string .IR t . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncasestarts () @@ -34,10 +37,12 @@ function returns 1 if the string begins with the string .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_strncasestarts () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -56,18 +61,25 @@ T{ .BR libsimple_strncasestarts () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strnstarts (3), .BR libsimple_strncaseends (3), diff --git a/man3/libsimple_strncasestr.3 b/man3/libsimple_strncasestr.3 index 0235f7c..1a49c83 100644 --- a/man3/libsimple_strncasestr.3 +++ b/man3/libsimple_strncasestr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCASESTR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCASESTR 3 libsimple .SH NAME libsimple_strncasestr \- find a substring in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strncasestr(const char *\fIhaystack\fP, const char *\fIneedle\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncasestr () @@ -26,6 +28,7 @@ the first occurrence of the substring .IR needle . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strncasestr () @@ -41,10 +44,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strncasestr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_strncasestr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrncasestr (3), .BR libsimple_strnstr (3), diff --git a/man3/libsimple_strnchr.3 b/man3/libsimple_strnchr.3 index bdb2787..533c417 100644 --- a/man3/libsimple_strnchr.3 +++ b/man3/libsimple_strnchr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCHR 3 libsimple .SH NAME libsimple_strnchr \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strnchr(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnchr () @@ -30,6 +32,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strnchr () @@ -44,10 +47,12 @@ offset less than .I n exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strnchr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_strnchr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strnchr_inv (3), .BR libsimple_strnchrnul (3), diff --git a/man3/libsimple_strnchr_inv.3 b/man3/libsimple_strnchr_inv.3 index 594021f..8331f63 100644 --- a/man3/libsimple_strnchr_inv.3 +++ b/man3/libsimple_strnchr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCHR_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRNCHR_INV 3 libsimple .SH NAME libsimple_strnchr_inv \- find a different character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strnchr_inv(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnchr_inv () @@ -31,6 +33,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strnchr_inv () @@ -45,10 +48,12 @@ offset less than .I n exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strnchr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_strnchr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strnchr (3), .BR libsimple_strnchrnul_inv (3), diff --git a/man3/libsimple_strnchrnul.3 b/man3/libsimple_strnchrnul.3 index b0c328e..bc16d4b 100644 --- a/man3/libsimple_strnchrnul.3 +++ b/man3/libsimple_strnchrnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCHRNUL 3 2018-10-21 libsimple +.TH LIBSIMPLE_STRNCHRNUL 3 libsimple .SH NAME libsimple_strnchrnul \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strnchrnul(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnchrnul () @@ -30,6 +32,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strnchrnul () @@ -45,10 +48,12 @@ offset less than exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strnchrnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_strnchrnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. I promise! + .SH SEE ALSO .BR libsimple_strnchrnul_inv (3), .BR libsimple_strncasechrnul (3), diff --git a/man3/libsimple_strnchrnul_inv.3 b/man3/libsimple_strnchrnul_inv.3 index d11a7df..fb7083a 100644 --- a/man3/libsimple_strnchrnul_inv.3 +++ b/man3/libsimple_strnchrnul_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCHRNUL_INV 3 2018-11-24 libsimple +.TH LIBSIMPLE_STRNCHRNUL_INV 3 libsimple .SH NAME libsimple_strnchrnul_inv \- skip a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strnchrnul_inv(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP) .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnchrnul_inv () @@ -31,6 +33,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strnchrnul_inv () @@ -46,10 +49,12 @@ offset less than exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strnchrnul_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -68,18 +73,25 @@ T{ .BR libsimple_strnchrnul_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. I promise! + .SH SEE ALSO .BR libsimple_strnchrnul (3), .BR libsimple_strncasechrnul_inv (3), diff --git a/man3/libsimple_strncmove.3 b/man3/libsimple_strncmove.3 index c944372..0f33ad9 100644 --- a/man3/libsimple_strncmove.3 +++ b/man3/libsimple_strncmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCMOVE 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRNCMOVE 3 libsimple .SH NAME libsimple_strncmove, libsimple_strnccpy \- copy or move a string within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline char *libsimple_strnccpy(char *restrict \fIdest\fP, const char *re .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncmove () @@ -46,6 +48,7 @@ function but not in the function. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strncmove () @@ -61,12 +64,14 @@ after it was copied, if the character was not copied .I NULL is returned. + .SH ERRORS The .BR libsimple_strncmove () and .BR libsimple_strnccpy () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -91,18 +96,25 @@ T{ .BR libsimple_strnccpy () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strnmove (3), .BR libsimple_stpnmove (3), diff --git a/man3/libsimple_strncmpnul.3 b/man3/libsimple_strncmpnul.3 index f53dc8c..d6a6cbe 100644 --- a/man3/libsimple_strncmpnul.3 +++ b/man3/libsimple_strncmpnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNCMPNUL 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNCMPNUL 3 libsimple .SH NAME libsimple_strncmpnul \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strncmpnul(const char *\fIa\fP, const char *\fIb\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strncmpnul () @@ -38,6 +40,7 @@ greater than the shorter string. The comparison is case-sensitive and made as if the strings were .BR "unsigned char *" s. + .SH RETURN VALUE The .BR libsimple_strncmpnul () @@ -50,10 +53,12 @@ a positive value if is greater than .IR b , and 0 otherwise. + .SH ERRORS The .BR libsimple_strncmpnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -72,18 +77,25 @@ T{ .BR libsimple_strncmpnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncasecmpnul (3), .BR libsimple_strneqnul (3), diff --git a/man3/libsimple_strnend.3 b/man3/libsimple_strnend.3 index 26ed564..c3d918d 100644 --- a/man3/libsimple_strnend.3 +++ b/man3/libsimple_strnend.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNEND 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNEND 3 libsimple .SH NAME libsimple_strnend \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline char *libsimple_strnend(const char *\fIs\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnend () @@ -23,6 +25,7 @@ truncated to .I n bytes unless it is shorter, for its end. + .SH RETURN VALUE The .BR libsimple_strnend () @@ -38,10 +41,12 @@ if no such offset less than exists, .I &s[n] is returned. + .SH ERRORS The .BR libsimple_strnend () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -60,18 +65,25 @@ T{ .BR libsimple_strnend () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strnchrnul (3), .BR libsimple_strnchr (3), diff --git a/man3/libsimple_strnends.3 b/man3/libsimple_strnends.3 index a733b6b..e7ce864 100644 --- a/man3/libsimple_strnends.3 +++ b/man3/libsimple_strnends.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNENDS 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNENDS 3 libsimple .SH NAME libsimple_strnends \- check the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_strnends(const char *\fIs\fP, const char *\fIt\fP, size_t \fIn\fP) .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnends () @@ -26,6 +28,7 @@ ends with the string .IR t . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strnends () @@ -34,10 +37,12 @@ function returns 1 if the string ends with the string .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_strnends () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -56,18 +61,25 @@ T{ .BR libsimple_strnends () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncaseends (3), .BR libsimple_strnstarts (3), diff --git a/man3/libsimple_strneq.3 b/man3/libsimple_strneq.3 index a315870..43f2442 100644 --- a/man3/libsimple_strneq.3 +++ b/man3/libsimple_strneq.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNEQ 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNEQ 3 libsimple .SH NAME libsimple_strneq \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strneq(const char *\fIa\fP, const char *\fIb\fP, siz .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strneq () @@ -31,15 +33,18 @@ neither of which may be .BR NULL . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strneq () function returns 1 if the strings are equals, otherwise it returns 0. + .SH ERRORS The .BR libsimple_strneq () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -58,18 +63,25 @@ T{ .BR libsimple_strneq () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strneqnul (3), .BR libsimple_strncaseeq (3), diff --git a/man3/libsimple_strneqlen.3 b/man3/libsimple_strneqlen.3 index df01480..093d6fa 100644 --- a/man3/libsimple_strneqlen.3 +++ b/man3/libsimple_strneqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNEQLEN 3 libsimple .SH NAME libsimple_strneqlen \- check initial commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ size_t libsimple_strneqlen(const char *\fIa\fP, const char *\fIb\fP, size_t \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strneqlen () @@ -30,6 +32,7 @@ bytes unless it is shorter, at their beginnings. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strneqlen () @@ -40,10 +43,12 @@ and (both truncated to .I n bytes) have in common at their beginnings. + .SH ERRORS The .BR libsimple_strneqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strneqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_streq (3), .BR libsimple_strreqlen (3), diff --git a/man3/libsimple_strneqnul.3 b/man3/libsimple_strneqnul.3 index 610844b..b3de167 100644 --- a/man3/libsimple_strneqnul.3 +++ b/man3/libsimple_strneqnul.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNEQNUL 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNEQNUL 3 libsimple .SH NAME libsimple_strneqnul \- compare two strings + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline int libsimple_strneqnul(const char *\fIa\fP, const char *\fIb\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strneqnul () @@ -31,15 +33,18 @@ both of which may be .BR NULL . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strneqnul () function returns 1 if the strings are equals, otherwise it returns 0. + .SH ERRORS The .BR libsimple_strneqnul () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -58,18 +63,25 @@ T{ .BR libsimple_strneqnul () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strneq (3), .BR libsimple_strncaseeqnul (3), diff --git a/man3/libsimple_strnmove.3 b/man3/libsimple_strnmove.3 index 593a5cb..38c58f6 100644 --- a/man3/libsimple_strnmove.3 +++ b/man3/libsimple_strnmove.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNMOVE 3 2018-11-16 libsimple +.TH LIBSIMPLE_STRNMOVE 3 libsimple .SH NAME libsimple_strnmove \- move a string within an array of bytes + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline void *libsimple_strnmove(void *\fIdest\fP, const void *\fIsrc\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnmove () @@ -25,15 +27,18 @@ NUL byte that terminates it (if any), into .IR dest . The arrays may overlap. + .SH RETURN VALUE The .BR libsimple_strnmove () function returns the pointer .IR dest . + .SH ERRORS The .BR libsimple_strnmove () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -52,18 +57,25 @@ T{ .BR libsimple_strnmove () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_stpnmove (3), .BR libsimple_strmove (3), diff --git a/man3/libsimple_strnreplace.3 b/man3/libsimple_strnreplace.3 index ef2a4fe..fc8718c 100644 --- a/man3/libsimple_strnreplace.3 +++ b/man3/libsimple_strnreplace.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNREPLACE 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRNREPLACE 3 libsimple .SH NAME libsimple_strnreplace \- replace characters in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline char *libsimple_strnreplace(char *\fIs\fP, int \fIold\fP, int \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnreplace () @@ -32,6 +34,7 @@ character (up the last character is shorter). .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strnreplace () @@ -40,10 +43,12 @@ function returns the end of that is .I &s[strnlen(s,n)] (as evaluated before the function call). + .SH ERRORS The .BR libsimple_strnreplace () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strnreplace () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strntolower (3), .BR libsimple_strntoupper (3), diff --git a/man3/libsimple_strnset.3 b/man3/libsimple_strnset.3 index 3807917..1a9ce21 100644 --- a/man3/libsimple_strnset.3 +++ b/man3/libsimple_strnset.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNSET 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRNSET 3 libsimple .SH NAME libsimple_strnset, libsimple_stpnset \- fill a string with a character + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline char *libsimple_stpnset(char *\fIs\fP, int \fIc\fP, size_t \fIn\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnset () @@ -31,6 +33,7 @@ characters in the string .I s is shorter) with the character .IR c . + .SH RETURN VALUE The .BR libsimple_strnset () @@ -43,12 +46,14 @@ function returns the end of (that is .IR &s[strnlen(s,n)] , as evaluated before the function call. + .SH ERRORS The .BR libsimple_strnset () and .BR libsimple_stpnset () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -73,18 +78,25 @@ T{ .BR libsimple_stpnset () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strset (3), .BR libsimple_mempset (3), diff --git a/man3/libsimple_strnstarts.3 b/man3/libsimple_strnstarts.3 index 4f084ea..108afd1 100644 --- a/man3/libsimple_strnstarts.3 +++ b/man3/libsimple_strnstarts.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNSTARTS 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNSTARTS 3 libsimple .SH NAME libsimple_strnstarts \- check the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_strnstarts(const char *\fIs\fP, const char *\fIt\fP, size_t \fIn\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnstarts () @@ -26,6 +28,7 @@ starts with the string .IR t . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strnstarts () @@ -34,10 +37,12 @@ function returns 1 if the string begins with the string .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_strnstarts () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -56,18 +61,25 @@ T{ .BR libsimple_strnstarts () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strncasestarts (3), .BR libsimple_strnends (3), diff --git a/man3/libsimple_strnstr.3 b/man3/libsimple_strnstr.3 index dca50bb..d2c9825 100644 --- a/man3/libsimple_strnstr.3 +++ b/man3/libsimple_strnstr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNSTR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRNSTR 3 libsimple .SH NAME libsimple_strnstr \- find a substring in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strnstr(const char *\fIhaystack\fP, const char *\fIneedle\fP, si .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strnstr () @@ -26,6 +28,7 @@ the first occurrence of the substring .IR needle . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strnstr () @@ -41,10 +44,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strnstr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_strnstr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrnstr (3), .BR libsimple_strncasestr (3) diff --git a/man3/libsimple_strntolower.3 b/man3/libsimple_strntolower.3 index 805adf4..8c0f41c 100644 --- a/man3/libsimple_strntolower.3 +++ b/man3/libsimple_strntolower.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNTOLOWER 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRNTOLOWER 3 libsimple .SH NAME libsimple_strntolower, libsimple_stpntolower \- convert a string to lower case + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ char *libsimple_stpntolower(char *\fIdest\fP, const char *\fIsrc\fP, size_t \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strntolower () @@ -35,6 +37,7 @@ lower case; however no more than bytes will be copied or coverted. The arrays may overlap, and there is an optimisation for the case where .IR dest==src . + .SH RETURN VALUE The .BR libsimple_strntolower () @@ -48,12 +51,14 @@ end of the string copied into .IR dest , that is .IR &dest[strnlen(src,n)] . + .SH ERRORS The .BR libsimple_strntolower () and .BR libsimple_stpntolower () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -78,18 +83,25 @@ T{ .BR libsimple_stpntolower () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strntoupper (3), .BR libsimple_strnreplace (3), diff --git a/man3/libsimple_strntoupper.3 b/man3/libsimple_strntoupper.3 index f045291..abb3408 100644 --- a/man3/libsimple_strntoupper.3 +++ b/man3/libsimple_strntoupper.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRNTOUPPER 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRNTOUPPER 3 libsimple .SH NAME libsimple_strntoupper, libsimple_stpntoupper \- convert a string to upper case + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ char *libsimple_stpntoupper(char *\fIdest\fP, const char *\fIsrc\fP, size_t \fIn .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strntoupper () @@ -35,6 +37,7 @@ upper case; however no more than bytes will be copied or coverted. The arrays may overlap, and there is an optimisation for the case where .IR dest==src . + .SH RETURN VALUE The .BR libsimple_strntoupper () @@ -48,12 +51,14 @@ end of the string copied into .IR dest , that is .IR &dest[strnlen(src,n)] . + .SH ERRORS The .BR libsimple_strntoupper () and .BR libsimple_stpntoupper () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -78,18 +83,25 @@ T{ .BR libsimple_stpntoupper () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strntolower (3), .BR libsimple_strnreplace (3), diff --git a/man3/libsimple_strrcasechr.3 b/man3/libsimple_strrcasechr.3 index 62ff883..84e5f7e 100644 --- a/man3/libsimple_strrcasechr.3 +++ b/man3/libsimple_strrcasechr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRCASECHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRCASECHR 3 libsimple .SH NAME libsimple_strrcasechr \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrcasechr(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrcasechr () @@ -27,6 +29,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strrcasechr () @@ -39,10 +42,12 @@ where is the returned pointer, if no such offset exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strrcasechr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -61,18 +66,25 @@ T{ .BR libsimple_strrcasechr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrcasechr_inv (3), .BR libsimple_strcasechr (3), diff --git a/man3/libsimple_strrcasechr_inv.3 b/man3/libsimple_strrcasechr_inv.3 index 66f9df4..47581c7 100644 --- a/man3/libsimple_strrcasechr_inv.3 +++ b/man3/libsimple_strrcasechr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRCASECHR_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRRCASECHR_INV 3 libsimple .SH NAME libsimple_strrcasechr_inv \- find a different character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrcasechr_inv(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrcasechr_inv () @@ -28,6 +30,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strrcasechr_inv () @@ -40,10 +43,12 @@ where is the returned pointer, if no such offset exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strrcasechr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strrcasechr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrcasechr (3), .BR libsimple_strrchr_inv (3), diff --git a/man3/libsimple_strrcaseeqlen.3 b/man3/libsimple_strrcaseeqlen.3 index 551debe..714c65a 100644 --- a/man3/libsimple_strrcaseeqlen.3 +++ b/man3/libsimple_strrcaseeqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRCASEEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRCASEEQLEN 3 libsimple .SH NAME libsimple_strrcaseeqlen \- check terminal commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline size_t libsimple_strrcaseeqlen(const char *\fIa\fP, const char *\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrcaseeqlen () @@ -24,6 +26,7 @@ have in common the string at their ends. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strrcaseeqlen () @@ -32,10 +35,12 @@ function returns the number of bytes and .I b have in common at their ends. + .SH ERRORS The .BR libsimple_strrcaseeqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -54,18 +59,25 @@ T{ .BR libsimple_strrcaseeqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strreqlen (3), .BR libsimple_strcaseeqlen (3), diff --git a/man3/libsimple_strrcasestr.3 b/man3/libsimple_strrcasestr.3 index a2844b5..44585b1 100644 --- a/man3/libsimple_strrcasestr.3 +++ b/man3/libsimple_strrcasestr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRCASESTR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRCASESTR 3 libsimple .SH NAME libsimple_strrcasestr \- find a substring in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrcasestr(const char *\fIhaystack\fP, const char *\fIneedle\fP .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrcasestr () @@ -23,6 +25,7 @@ the last occurrence of the substring .IR needle . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strrcasestr () @@ -38,10 +41,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strrcasestr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -60,18 +65,25 @@ T{ .BR libsimple_strrcasestr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrstr (3), .BR libsimple_strcasestr (3), diff --git a/man3/libsimple_strrchr_inv.3 b/man3/libsimple_strrchr_inv.3 index 71059fa..8864e83 100644 --- a/man3/libsimple_strrchr_inv.3 +++ b/man3/libsimple_strrchr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRCHR_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRRCHR_INV 3 libsimple .SH NAME libsimple_strrchr_inv \- find a different character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrchr_inv(const char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrchr_inv () @@ -28,6 +30,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strrchr_inv () @@ -40,10 +43,12 @@ where is the returned pointer, if no such offset exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strrchr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strrchr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrchr (3), .BR libsimple_strrcasechr_inv (3), diff --git a/man3/libsimple_strreplace.3 b/man3/libsimple_strreplace.3 index 96d20e0..0cdedd8 100644 --- a/man3/libsimple_strreplace.3 +++ b/man3/libsimple_strreplace.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRREPLACE 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRREPLACE 3 libsimple .SH NAME libsimple_strreplace \- replace characters in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline char *libsimple_strreplace(char *\fIs\fP, int \fIold\fP, int \fIne .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strreplace () @@ -27,6 +29,7 @@ with the character .IR new . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strreplace () @@ -35,10 +38,12 @@ function returns the end of that is .I &s[strlen(s)] (as evaluated before the function call). + .SH ERRORS The .BR libsimple_strreplace () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -57,18 +62,25 @@ T{ .BR libsimple_strreplace () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strtolower (3), .BR libsimple_strtoupper (3), diff --git a/man3/libsimple_strreqlen.3 b/man3/libsimple_strreqlen.3 index 3fa4105..16c785e 100644 --- a/man3/libsimple_strreqlen.3 +++ b/man3/libsimple_strreqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRREQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRREQLEN 3 libsimple .SH NAME libsimple_strreqlen \- check terminal commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline size_t libsimple_strreqlen(const char *\fIa\fP, const char *\fIb\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strreqlen () @@ -24,6 +26,7 @@ have in common the string at their ends. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strreqlen () @@ -32,10 +35,12 @@ function returns the number of bytes and .I b have in common at their ends. + .SH ERRORS The .BR libsimple_strreqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -54,18 +59,25 @@ T{ .BR libsimple_strreqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strreqlen (3), .BR libsimple_streqlen (3), diff --git a/man3/libsimple_strrncasechr.3 b/man3/libsimple_strrncasechr.3 index 7e3ae4e..0a8450d 100644 --- a/man3/libsimple_strrncasechr.3 +++ b/man3/libsimple_strrncasechr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRNCASECHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRNCASECHR 3 libsimple .SH NAME libsimple_strrncasechr \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrncasechr(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrncasechr () @@ -30,6 +32,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strrncasechr () @@ -44,10 +47,12 @@ offset less than .I n exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strrncasechr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_strrncasechr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrncasechr_inv (3), .BR libsimple_strncasechr (3), diff --git a/man3/libsimple_strrncasechr_inv.3 b/man3/libsimple_strrncasechr_inv.3 index 40426d6..7666cb3 100644 --- a/man3/libsimple_strrncasechr_inv.3 +++ b/man3/libsimple_strrncasechr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRNCASECHR_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRRNCASECHR_INV 3 libsimple .SH NAME libsimple_strrncasechr_inv \- find a different character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrncasechr_inv(const char *\fIs\fP, int \fIc\fP, size_t \fIn\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrncasechr_inv () @@ -31,6 +33,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strrncasechr_inv () @@ -45,10 +48,12 @@ offset less than .I n exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strrncasechr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_strrncasechr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrncasechr (3), .BR libsimple_strncasechr_inv (3), diff --git a/man3/libsimple_strrncaseeqlen.3 b/man3/libsimple_strrncaseeqlen.3 index d938154..0d245f0 100644 --- a/man3/libsimple_strrncaseeqlen.3 +++ b/man3/libsimple_strrncaseeqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRNCASEEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRNCASEEQLEN 3 libsimple .SH NAME libsimple_strrncaseeqlen \- check terminal commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline size_t libsimple_strrncaseeqlen(const char *\fIa\fP, const char *\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrncaseeqlen () @@ -30,6 +32,7 @@ bytes unless it is shorter, at their ends. .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strrncaseeqlen () @@ -40,10 +43,12 @@ and (both truncated to .I n bytes) have in common at their ends. + .SH ERRORS The .BR libsimple_strrncaseeqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strrncaseeqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrneqlen (3), .BR libsimple_strncaseeqlen (3), diff --git a/man3/libsimple_strrncasestr.3 b/man3/libsimple_strrncasestr.3 index dcf48b5..f06cb20 100644 --- a/man3/libsimple_strrncasestr.3 +++ b/man3/libsimple_strrncasestr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRNCASESTR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRNCASESTR 3 libsimple .SH NAME libsimple_strrncasestr \- find a substring in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrncasestr(const char *\fIhaystack\fP, const char *\fIneedle\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrncasestr () @@ -26,6 +28,7 @@ the last occurrence of the substring .IR needle . .PP The comparison is case-insensitive. + .SH RETURN VALUE The .BR libsimple_strrncasestr () @@ -41,10 +44,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strrncasestr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_strrncasestr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrnstr (3), .BR libsimple_strncasestr (3), diff --git a/man3/libsimple_strrnchr.3 b/man3/libsimple_strrnchr.3 index a677bfe..fedb688 100644 --- a/man3/libsimple_strrnchr.3 +++ b/man3/libsimple_strrnchr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRNCHR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRNCHR 3 libsimple .SH NAME libsimple_strrnchr \- find a character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrnchr(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrnchr () @@ -30,6 +32,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strrnchr () @@ -44,10 +47,12 @@ offset less than .I n exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strrnchr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -66,18 +71,25 @@ T{ .BR libsimple_strrnchr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrnchr_inv (3), .BR libsimple_strrncasechr (3), diff --git a/man3/libsimple_strrnchr_inv.3 b/man3/libsimple_strrnchr_inv.3 index 3cfdac9..1f47baa 100644 --- a/man3/libsimple_strrnchr_inv.3 +++ b/man3/libsimple_strrnchr_inv.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRNCHR_INV 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRRNCHR_INV 3 libsimple .SH NAME libsimple_strrnchr_inv \- find a different character in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrnchr_inv(const char *\fIs\fP, int \fIc\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrnchr_inv () @@ -31,6 +33,7 @@ If no such character exist in the string, the string's end is returned. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strrnchr_inv () @@ -45,10 +48,12 @@ offset less than .I n exists, it returns .BR NULL . + .SH ERRORS The .BR libsimple_strrnchr_inv () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_strrnchr_inv () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrnchr (3), .BR libsimple_strrncasechr_inv (3), diff --git a/man3/libsimple_strrneqlen.3 b/man3/libsimple_strrneqlen.3 index 6828fa0..eced333 100644 --- a/man3/libsimple_strrneqlen.3 +++ b/man3/libsimple_strrneqlen.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRNEQLEN 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRNEQLEN 3 libsimple .SH NAME libsimple_strrneqlen \- check terminal commonality + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ static inline size_t libsimple_strrneqlen(const char *\fIa\fP, const char *\fIb\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrneqlen () @@ -30,6 +32,7 @@ bytes unless it is shorter, at their ends. .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strrneqlen () @@ -40,10 +43,12 @@ and (both truncated to .I n bytes) have in common at their ends. + .SH ERRORS The .BR libsimple_strrneqlen () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -62,18 +67,25 @@ T{ .BR libsimple_strrneqlen () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrneqlen (3), .BR libsimple_strneqlen (3), diff --git a/man3/libsimple_strrnstr.3 b/man3/libsimple_strrnstr.3 index 9e95196..6bd1ae8 100644 --- a/man3/libsimple_strrnstr.3 +++ b/man3/libsimple_strrnstr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRNSTR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRNSTR 3 libsimple .SH NAME libsimple_strrnstr \- find a substring in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrnstr(const char *\fIhaystack\fP, const char *\fIneedle\fP, s .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrnstr () @@ -26,6 +28,7 @@ the last occurrence of the substring .IR needle . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strrnstr () @@ -41,10 +44,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strrnstr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -63,18 +68,25 @@ T{ .BR libsimple_strrnstr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrncasestr (3), .BR libsimple_strnstr (3), diff --git a/man3/libsimple_strrstr.3 b/man3/libsimple_strrstr.3 index c3c16b7..19d5d98 100644 --- a/man3/libsimple_strrstr.3 +++ b/man3/libsimple_strrstr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRRSTR 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRRSTR 3 libsimple .SH NAME libsimple_strrstr \- find a substring in a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ char *libsimple_strrstr(const char *\fIhaystack\fP, const char *\fIneedle\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strrstr () @@ -23,6 +25,7 @@ the last occurrence of the substring .IR needle . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strrstr () @@ -38,10 +41,12 @@ is the returned pointer. If no such offset exists, .B NULL is returned. + .SH ERRORS The .BR libsimple_strrstr () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -60,18 +65,25 @@ T{ .BR libsimple_strrstr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strrcasestr (3), .BR libsimple_strrnstr (3), diff --git a/man3/libsimple_strset.3 b/man3/libsimple_strset.3 index d504edf..6ed9ff4 100644 --- a/man3/libsimple_strset.3 +++ b/man3/libsimple_strset.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRSET 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRSET 3 libsimple .SH NAME libsimple_strset, libsimple_stpset \- fill a string with a character + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline char *libsimple_stpset(char *\fIs\fP, int \fIc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strset () @@ -27,6 +29,7 @@ functions replace all characters in the string .I s with the character .IR c . + .SH RETURN VALUE The .BR libsimple_strset () @@ -39,12 +42,14 @@ function returns the end of (that is .IR &s[strlen(s)] , as evaluated before the function call. + .SH ERRORS The .BR libsimple_strset () and .BR libsimple_stpset () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -69,18 +74,25 @@ T{ .BR libsimple_stpset () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strnset (3), .BR libsimple_mempset (3), diff --git a/man3/libsimple_strstarts.3 b/man3/libsimple_strstarts.3 index fbd3412..0daf04e 100644 --- a/man3/libsimple_strstarts.3 +++ b/man3/libsimple_strstarts.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRSTARTS 3 2018-10-23 libsimple +.TH LIBSIMPLE_STRSTARTS 3 libsimple .SH NAME libsimple_strstarts \- check the beginning of a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -14,6 +15,7 @@ int libsimple_strstarts(const char *\fIs\fP, const char *\fIt\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strstarts () @@ -23,6 +25,7 @@ starts with the string .IR t . .PP The comparison is case-sensitive. + .SH RETURN VALUE The .BR libsimple_strstarts () @@ -31,10 +34,12 @@ function returns 1 if the string begins with the string .IR t , otherwise it returns 0. + .SH ERRORS The .BR libsimple_strstarts () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -53,18 +58,25 @@ T{ .BR libsimple_strstarts () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strcasestarts (3), .BR libsimple_strends (3), diff --git a/man3/libsimple_strtolower.3 b/man3/libsimple_strtolower.3 index 385de39..8075dde 100644 --- a/man3/libsimple_strtolower.3 +++ b/man3/libsimple_strtolower.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRTOLOWER 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRTOLOWER 3 libsimple .SH NAME libsimple_strtolower, libsimple_stptolower \- convert a string to lower case + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ char *libsimple_stptolower(char *\fIdest\fP, const char *\fIsrc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strtolower () @@ -33,6 +35,7 @@ with all upper case ASCII characters converted to lower case. The arrays may overlap, and there is an optimisation for the case where .IR dest==src . + .SH RETURN VALUE The .BR libsimple_strtolower () @@ -46,12 +49,14 @@ end of the string copied into .IR dest , that is .IR &dest[strlen(src)] . + .SH ERRORS The .BR libsimple_strtolower () and .BR libsimple_stptolower () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -76,18 +81,25 @@ T{ .BR libsimple_stptolower () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strtoupper (3), .BR libsimple_strreplace (3), diff --git a/man3/libsimple_strtotimespec.3 b/man3/libsimple_strtotimespec.3 index 85ff88b..b6d4a71 100644 --- a/man3/libsimple_strtotimespec.3 +++ b/man3/libsimple_strtotimespec.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRTOTIMESPEC 3 2018-10-31 libsimple +.TH LIBSIMPLE_STRTOTIMESPEC 3 libsimple .SH NAME libsimple_strtotimespec, libsimple_strtotimeval \- convert a string to a duration data structure + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ int libsimple_strtotimeval(struct timeval *restrict \fItv\fP, const char *\fIs\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strtotimespec () @@ -50,6 +52,7 @@ where the digits in .BR \e2 , if any, are repeating decimals and must contain atleast one digit if it is included. + .SH RETURN VALUE The .BR libsimple_strtotimespec () @@ -57,6 +60,7 @@ and .BR libsimple_strtotimeval () functions return 0 upon successful completion; otherwise \-1 is returned. + .SH ERRORS The .BR libsimple_strtotimespec () @@ -86,6 +90,7 @@ and (if the result is too small). .I *end will be set. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -110,18 +115,25 @@ T{ .BR libsimple_strtotimeval () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_sumtimespec (3), .BR libsimple_difftimespec (3), diff --git a/man3/libsimple_strtoupper.3 b/man3/libsimple_strtoupper.3 index cc1de4f..10333e5 100644 --- a/man3/libsimple_strtoupper.3 +++ b/man3/libsimple_strtoupper.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_STRTOUPPER 3 2018-11-25 libsimple +.TH LIBSIMPLE_STRTOUPPER 3 libsimple .SH NAME libsimple_strtoupper, libsimple_stptoupper \- convert a string to upper case + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ char *libsimple_stptoupper(char *\fIdest\fP, const char *\fIsrc\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_strtoupper () @@ -33,6 +35,7 @@ with all lower case ASCII characters converted to upper case. The arrays may overlap, and there is an optimisation for the case where .IR dest==src . + .SH RETURN VALUE The .BR libsimple_strtoupper () @@ -46,12 +49,14 @@ end of the string copied into .IR dest , that is .IR &dest[strlen(src)] . + .SH ERRORS The .BR libsimple_strtoupper () and .BR libsimple_stptoupper () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -76,18 +81,25 @@ T{ .BR libsimple_stptoupper () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_strtolower (3), .BR libsimple_strreplace (3), diff --git a/man3/libsimple_sumtimespec.3 b/man3/libsimple_sumtimespec.3 index 7d587e0..f5b9af3 100644 --- a/man3/libsimple_sumtimespec.3 +++ b/man3/libsimple_sumtimespec.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_SUMTIMESPEC 3 2018-10-29 libsimple +.TH LIBSIMPLE_SUMTIMESPEC 3 libsimple .SH NAME libsimple_sumtimespec, libsimple_sumtimeval \- calculate the sum of two durations + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ int libsimple_sumtimeval(struct timeval *\fIsum\fP, const struct timeval *\fIaug .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_sumtimespec () @@ -29,6 +31,7 @@ and .I addend and stores the result in .IR sum . + .SH RETURN VALUE The .BR libsimple_sumtimespec () @@ -47,6 +50,7 @@ are in thier valid range ([0, 1000000000) for .BR libsimple_sumtimespec () and [0, 1000000) for .BR libsimple_sumtimeval ()). + .SH ERRORS The .BR libsimple_sumtimespec () @@ -77,6 +81,7 @@ function and to for the .BR libsimple_sumtimeval () function. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -101,18 +106,25 @@ T{ .BR libsimple_sumtimeval () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_difftimespec (3), .BR libsimple_multimespec (3), diff --git a/man3/libsimple_timespectodouble.3 b/man3/libsimple_timespectodouble.3 index fddc899..4413f8f 100644 --- a/man3/libsimple_timespectodouble.3 +++ b/man3/libsimple_timespectodouble.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_TIMESPECTODOUBLE 3 2018-10-30 libsimple +.TH LIBSIMPLE_TIMESPECTODOUBLE 3 libsimple .SH NAME libsimple_timespectodouble, libsimple_timevaltodouble \- convert a duration data structure to a double + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ static inline double libsimple_timevaltodouble(const struct timeval *\fItv\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_timespectodouble () @@ -30,6 +32,7 @@ and respectively, to a .B double and return the result. + .SH RETURN VALUE The .BR libsimple_timespectodouble () @@ -37,12 +40,14 @@ and .BR libsimple_timevaltodouble () functions return the input argument as a .BR double . + .SH ERRORS The .BR libsimple_timespectodouble () and .BR libsimple_timevaltodouble () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -67,18 +72,25 @@ T{ .BR libsimple_timevaltodouble () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_sumtimespec (3), .BR libsimple_difftimespec (3), diff --git a/man3/libsimple_timespectostr.3 b/man3/libsimple_timespectostr.3 index d6e2b71..c1ce154 100644 --- a/man3/libsimple_timespectostr.3 +++ b/man3/libsimple_timespectostr.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_TIMESPECTOSTR 3 2018-10-30 libsimple +.TH LIBSIMPLE_TIMESPECTOSTR 3 libsimple .SH NAME libsimple_timespectostr, libsimple_timevaltostr \- convert a duration data structure to a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ char *libsimple_timevaltostr(char *restrict \fIbuf\fP, const struct timeval *res .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_timespectostr () @@ -59,6 +61,7 @@ and will always contain 9 (for the function) or 6 (for the .BR libsimple_timevaltostr () function) decimals. + .SH RETURN VALUE The .BR libsimple_timespectostr () @@ -77,6 +80,7 @@ pointer, otherwise the pointer is returned. On failure, .B NULL is returned. + .SH ERRORS The .BR libsimple_timespectostr () @@ -97,6 +101,7 @@ failed because it could not allocate enough memory. is negative or greater than 999\ 999\ 999, or .I tv->tv_usec is negative or greater than 999\ 999. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -121,18 +126,25 @@ T{ .BR libsimple_timevaltostr () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_minimise_number_string (3), .BR libsimple_sumtimespec (3), diff --git a/man3/libsimple_timeval2timespec.3 b/man3/libsimple_timeval2timespec.3 index d4381ce..f6dcf90 100644 --- a/man3/libsimple_timeval2timespec.3 +++ b/man3/libsimple_timeval2timespec.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_TIMEVAL2TIMESPEC 3 2018-10-30 libsimple +.TH LIBSIMPLE_TIMEVAL2TIMESPEC 3 libsimple .SH NAME libsimple_timeval2timespec, libsimple_timespec2timeval \- convert between timespec and timeval + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ int libsimple_timespec2timeval(struct timeval *restrict \fItv\fP, const struct t .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_timeval2timespec () @@ -37,6 +39,7 @@ to a rounding to nearest microsecond, and stores the result in .IR tv . + .SH RETURN VALUE The .BR libsimple_timespec2timeval () @@ -48,6 +51,7 @@ to indicate the error. The .BR libsimple_timeval2timespec () function does not return a value. + .SH ERRORS The .BR libsimple_timespec2timeval () @@ -65,6 +69,7 @@ will be stored in The .BR libsimple_timeval2timespec () function cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -89,18 +94,25 @@ T{ .BR libsimple_timespec2timeval () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_sumtimespec (3), .BR libsimple_difftimespec (3), diff --git a/man3/libsimple_unlist.3 b/man3/libsimple_unlist.3 index 5be3858..d3c2df1 100644 --- a/man3/libsimple_unlist.3 +++ b/man3/libsimple_unlist.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_UNLIST 3 2018-11-05 libsimple +.TH LIBSIMPLE_UNLIST 3 libsimple .SH NAME libsimple_unlist \- remove item for array and keep order + .SH SYNOPSIS .nf #include <libsimple.h> @@ -18,6 +19,7 @@ void LIBSIMPLE_UNLIST(\fItype\fP *\fIlist\fP, size_t \fIi\fP, size_t *\fInp\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_unlist () @@ -50,14 +52,17 @@ instead it is inferred from the type of as such, .I type must be a complete, non-void type. + .SH RETURN VALUE None. + .SH ERRORS The .BR libsimple_unlist () and .BR LIBSIMPLE_UNLIST () functions cannot fail. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -82,17 +87,24 @@ T{ .BR LIBSIMPLE_UNLIST () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR memmove (3) diff --git a/man3/libsimple_valigned_allocn.3 b/man3/libsimple_valigned_allocn.3 index 2600571..ab93f30 100644 --- a/man3/libsimple_valigned_allocn.3 +++ b/man3/libsimple_valigned_allocn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VALIGNED_ALLOCN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VALIGNED_ALLOCN 3 libsimple .SH NAME libsimple_valigned_allocn \- allocate memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_ealigned_allocn(size_t \fIalignment\fP, size_t \fI .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_aligned_allocn (), @@ -91,6 +93,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_valigned_allocn (), @@ -116,6 +119,7 @@ it indicate the error, and the and .BR libsimple_ealigned_allocn () functions terminated the process. + .SH ERRORS The .BR libsimple_valigned_allocn (), @@ -145,6 +149,7 @@ The and .BR libsimple_ealigned_allocn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -193,18 +198,25 @@ T{ .BR libsimple_ealigned_allocn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -213,7 +225,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_valigned_alloczn.3 b/man3/libsimple_valigned_alloczn.3 index 9f68adb..c40979e 100644 --- a/man3/libsimple_valigned_alloczn.3 +++ b/man3/libsimple_valigned_alloczn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VALIGNED_ALLOCZN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VALIGNED_ALLOCZN 3 libsimple .SH NAME libsimple_valigned_alloczn \- allocate optionally initialised memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_ealigned_alloczn(int \fIclear\fP, size_t \fIalignm .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_aligned_alloczn (), @@ -94,6 +96,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_valigned_alloczn (), @@ -119,6 +122,7 @@ it indicate the error, and the and .BR libsimple_ealigned_alloczn () functions terminated the process. + .SH ERRORS The .BR libsimple_valigned_alloczn (), @@ -148,6 +152,7 @@ The and .BR libsimple_ealigned_alloczn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -196,18 +201,25 @@ T{ .BR libsimple_ealigned_alloczn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -216,7 +228,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_valigned_reallocfn.3 b/man3/libsimple_valigned_reallocfn.3 new file mode 100644 index 0000000..0acf175 --- /dev/null +++ b/man3/libsimple_valigned_reallocfn.3 @@ -0,0 +1,189 @@ +.TH LIBSIMPLE_VALIGNED_REALLOCFN 3 libsimple +.SH NAME +libsimple_valigned_reallocfn \- reallocate memory and customise alignment + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_valigned_reallocfn(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, va_list \fIap\fP); +static inline void *libsimple_aligned_reallocfn(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, ..., /* (size_t)0 */); + +#ifndef valigned_reallocfn +# define valigned_reallocfn libsimple_valigned_reallocfn +#endif +#ifndef aligned_reallocfn +# define aligned_reallocfn libsimple_aligned_reallocfn +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_reallocfn () +function reallocates memory allocated on the +heap and return the older pointer or a new +pointer with the alignment of +.I alignment +to the allocated memory of +.I N +bytes, where +.I N +is the product of +.I n +and all following arguments (which should have the type +.BR size_t ) +up to the first 0; +.I n +must not be 0. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I N +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is also deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +The +.BR libsimple_valigned_reallocfn () +function is a version of the +.BR libsimple_aligned_reallocfn () +function that use +.B va_list +instead of variadic arguments. + +.SH RETURN VALUE +The +.BR libsimple_valigned_reallocfn () +and +.BR libsimple_aligned_reallocfn (), +functions return a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_valigned_reallocfn () +and +.BR libsimple_aligned_reallocfn () +functions return +.B NULL +and set +.I errno +it indicate the error. + +.SH ERRORS +The +.BR libsimple_vreallocn (), +.BR libsimple_reallocn () +function will fail for the reasons specified for the +.BR realloc (3) +function, and if: +.TP +.B EINVAL +.I n +is 0. +.TP +.B EINVAL +.I alignment +is an invalid alignment (usually it needs to be an power of 2). +.TP +.B ENOSYS +The function is not implemented. The function requires +non-standard libc functions, and is therefore not supported +for all libc implementations. + +The function is implemented if and only if the macro +.B LIBSIMPLE_HAVE_ALIGNED_REALLOC +is defined by the library. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_valigned_reallocfn (), +.br +.BR libsimple_aligned_reallocfn () +T} Thread safety MT-Safe +T{ +.BR libsimple_valigned_reallocfn (), +.br +.BR libsimple_aligned_reallocfn () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_valigned_reallocfn (), +.br +.BR libsimple_aligned_reallocfn () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_valigned_reallocn.3 b/man3/libsimple_valigned_reallocn.3 new file mode 100644 index 0000000..94baffb --- /dev/null +++ b/man3/libsimple_valigned_reallocn.3 @@ -0,0 +1,279 @@ +.TH LIBSIMPLE_VALIGNED_REALLOCN 3 libsimple +.SH NAME +libsimple_valigned_reallocn \- reallocate memory and customise alignment + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +void *libsimple_valigned_reallocn(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, va_list \fIap\fP); +void *libsimple_envaligned_reallocn(int \fIstatus\fP, void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, va_list \fIap\fP); +static inline void *libsimple_evaligned_reallocn(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, va_list \fIap\fP); +static inline void *libsimple_aligned_reallocn(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, ..., /* (size_t)0 */); +static inline void *libsimple_enaligned_reallocn(int \fIstatus\fP, void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, ..., /* (size_t)0 */); +static inline void *libsimple_ealigned_reallocn(void *\fIptr\fP, size_t \fIalignment\fP, size_t \fIn\fP, ..., /* (size_t)0 */); + +#ifndef valigned_reallocn +# define valigned_reallocn libsimple_valigned_reallocn +#endif +#ifndef envaligned_reallocn +# define envaligned_reallocn libsimple_envaligned_reallocn +#endif +#ifndef evaligned_reallocn +# define evaligned_reallocn libsimple_evaligned_reallocn +#endif +#ifndef aligned_reallocn +# define aligned_reallocn libsimple_aligned_reallocn +#endif +#ifndef enaligned_reallocn +# define enaligned_reallocn libsimple_enaligned_reallocn +#endif +#ifndef ealigned_reallocn +# define ealigned_reallocn libsimple_ealigned_reallocn +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_aligned_reallocn (), +.BR libsimple_enaligned_reallocn (), +and +.BR libsimple_ealigned_reallocn () +functions are wrappers for the +.BR realloc (3) +function, they reallocate memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignment +to the allocated memory of +.I N +bytes, where +.I N +is the product of +.I n +and all following arguments (which should have the type +.BR size_t ) +up to the first 0; +.I n +must not be 0. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I N +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is not deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +The +.BR libsimple_enaligned_reallocn () +and +.BR libsimple_ealigned_reallocn () +functions will terminate the process if the memory +cannot be allocated, by calling the +.BR libsimple_enprintf () +and +.BR libsimple_eprintf () +functions, respectively. +On failure, the process's exit value will be +.I status +if the +.BR libsimple_enaligned_reallocn () +function is used or +.IR libsimple_default_failure_exit (3) +if the +.BR libsimple_ealigned_reallocn () +function is used. +.PP +The +.BR libsimple_valigned_reallocn (), +.BR libsimple_envaligned_reallocn (), +and +.BR libsimple_evaligned_reallocn () +functions are versions of the +.BR libsimple_aligned_reallocn (), +.BR libsimple_enaligned_reallocn (), +and +.BR libsimple_ealigned_reallocn (), +respectively, that use +.B va_list +instead of variadic arguments. + +.SH RETURN VALUE +The +.BR libsimple_valigned_reallocn (), +.BR libsimple_envaligned_reallocn (), +.BR libsimple_evaligned_reallocn (), +.BR libsimple_aligned_reallocn (), +.BR libsimple_enaligned_reallocn (), +and +.BR libsimple_ealigned_reallocn () +functions return a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_valigned_reallocn () +and +.BR libsimple_aligned_reallocn () +functions return +.B NULL +and set +.I errno +it indicate the error, and the +.BR libsimple_envaligned_reallocn (), +.BR libsimple_evaligned_reallocn (), +.BR libsimple_enaligned_reallocn (), +and +.BR libsimple_ealigned_reallocn () +functions terminated the process. + +.SH ERRORS +The +.BR libsimple_valigned_reallocn () +and +.BR libsimple_aligned_reallocn () +functions will fail for the reasons specified for the +.BR realloc (3) +function, and if: +.TP +.B EINVAL +.I n +is 0. +.TP +.B EINVAL +.I alignment +is an invalid alignment (usually it needs to be an power of 2). +.TP +.B ENOSYS +The function is not implemented. The function requires +non-standard libc functions, and is therefore not supported +for all libc implementations. + +The function is implemented if and only if the macro +.B LIBSIMPLE_HAVE_ALIGNED_REALLOC +is defined by the library. +.PP +The +.BR libsimple_envaligned_reallocn (), +.BR libsimple_evaligned_reallocn (), +.BR libsimple_enaligned_reallocn (), +and +.BR libsimple_ealigned_reallocn () +functions will terminate the process on failure. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_valigned_reallocn (), +.br +.BR libsimple_envaligned_reallocn (), +.br +.BR libsimple_evaligned_reallocn (), +.br +.BR libsimple_aligned_reallocn (), +.br +.BR libsimple_enaligned_reallocn (), +.br +.BR libsimple_ealigned_reallocn () +T} Thread safety MT-Safe +T{ +.BR libsimple_valigned_reallocn (), +.br +.BR libsimple_envaligned_reallocn (), +.br +.BR libsimple_evaligned_reallocn (), +.br +.BR libsimple_aligned_reallocn (), +.br +.BR libsimple_enaligned_reallocn (), +.br +.BR libsimple_ealigned_reallocn () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_valigned_reallocn (), +.br +.BR libsimple_envaligned_reallocn (), +.br +.BR libsimple_evaligned_reallocn (), +.br +.BR libsimple_aligned_reallocn (), +.br +.BR libsimple_enaligned_reallocn (), +.br +.BR libsimple_ealigned_reallocn () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_valloc.3 b/man3/libsimple_valloc.3 index 84cce32..97e7b97 100644 --- a/man3/libsimple_valloc.3 +++ b/man3/libsimple_valloc.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VALLOC 3 2018-11-03 libsimple +.TH LIBSIMPLE_VALLOC 3 libsimple .SH NAME libsimple_valloc \- allocate memory with page size alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void *libsimple_evalloc(size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_valloc (), @@ -59,6 +61,7 @@ function is used or if the .BR libsimple_evalloc () function is used. + .SH RETURN VALUE The .BR libsimple_valloc (), @@ -77,6 +80,7 @@ it indicate the error, and the and .BR libsimple_evalloc () functions terminated the process. + .SH ERRORS The .BR libsimple_valloc () @@ -94,6 +98,7 @@ The and .BR libsimple_evalloc () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -124,14 +129,19 @@ T{ .BR libsimple_evalloc () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES Portable applications shall assume that pointer returned by the @@ -145,8 +155,10 @@ is used explicitly. The GNU implementation of .BR valloc (3) is \(dqMT-Unsafe init\(dq. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -155,7 +167,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vallocz.3 b/man3/libsimple_vallocz.3 index 3559a32..bc2f8b8 100644 --- a/man3/libsimple_vallocz.3 +++ b/man3/libsimple_vallocz.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VALLOCZ 3 2018-11-03 libsimple +.TH LIBSIMPLE_VALLOCZ 3 libsimple .SH NAME libsimple_vallocz \- allocate optionally initialised memory with page size alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -22,6 +23,7 @@ static inline void *libsimple_evallocz(int \fIclear\fP, size_t \fIn\fP); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_vallocz (), @@ -68,6 +70,7 @@ and functions behaviour is unspecified if .I n is 0. + .SH RETURN VALUE The .BR libsimple_vallocz (), @@ -86,6 +89,7 @@ it indicate the error, and the and .BR libsimple_evallocz () functions terminated the process. + .SH ERRORS The .BR libsimple_vallocz () @@ -103,6 +107,7 @@ The and .BR libsimple_evallocz () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -133,20 +138,27 @@ T{ .BR libsimple_evallocz () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES The GNU implementation of .BR valloc (3) is \(dqMT-Unsafe init\(dq. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -155,7 +167,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_varrayalloc.3 b/man3/libsimple_varrayalloc.3 index ceea9f1..d009b92 100644 --- a/man3/libsimple_varrayalloc.3 +++ b/man3/libsimple_varrayalloc.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VARRAYALLOC 3 2018-11-03 libsimple +.TH LIBSIMPLE_VARRAYALLOC 3 libsimple .SH NAME libsimple_varrayalloc \- allocate memory in a flexible manner + .SH SYNOPSIS .nf #include <libsimple.h> @@ -19,6 +20,7 @@ void *libsimple_earrayalloc(\fItype\fP, size_t \fIn\fP, ..., /* LIBSIMPLE_ARRAYA .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_varrayalloc (), @@ -74,6 +76,7 @@ will be used as the alignment for the returned pointer. * The specified allocatio size will be multiplied by .IR sizeof(type) . + .SH RETURN VALUE The .BR libsimple_varrayalloc (), @@ -99,6 +102,7 @@ to indicate the error, whereas the and .BR libsimple_earrayalloc () functions terminate the process. + .SH ERRORS The .BR libsimple_varrayalloc () @@ -123,6 +127,7 @@ The and .BR libsimple_earrayalloc () functions terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -171,18 +176,25 @@ T{ .BR libsimple_earrayalloc () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_vmemalloc (3), .BR libsimple_enmalloc (3), @@ -192,7 +204,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vasprintf.3 b/man3/libsimple_vasprintf.3 index e91c404..250e65f 100644 --- a/man3/libsimple_vasprintf.3 +++ b/man3/libsimple_vasprintf.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VASPRINTF 3 2018-11-04 libsimple +.TH LIBSIMPLE_VASPRINTF 3 libsimple .SH NAME libsimple_vasprintf \- allocate and format a string + .SH SYNOPSIS .nf #include <libsimple.h> @@ -26,6 +27,7 @@ char *libsimple_asprintfa(const char *\fIfmt\fP, ...); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_vasprintf () @@ -92,6 +94,7 @@ and .BR libsimple_asprintfa () functions are implemented as macros and are only available if compiling with GCC or Clang. + .SH RETURN VALUE The .BR libsimple_vasprintf () @@ -113,6 +116,7 @@ completion; otherwise is returned and .I errno set to indicate the error. + .SH ERRORS The .BR libsimple_vasprintf (), @@ -141,6 +145,7 @@ and functions, the kernel will kill the thread with a .B SIGSEGV signal. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -177,18 +182,25 @@ T{ .BR libsimple_asprintfa () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_vweprintf (3), .BR sprintf (3), diff --git a/man3/libsimple_vcallocn.3 b/man3/libsimple_vcallocn.3 index 0d1c71d..449cfd6 100644 --- a/man3/libsimple_vcallocn.3 +++ b/man3/libsimple_vcallocn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VCALLOCN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VCALLOCN 3 libsimple .SH NAME libsimple_vcallocn \- allocate memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_ecallocn(size_t \fIn\fP, ..., /* (size_t)0 */); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_callocn (), @@ -93,6 +95,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vcallocn (), @@ -118,6 +121,7 @@ it indicate the error, and the and .BR libsimple_ecallocn () functions terminated the process. + .SH ERRORS The .BR libsimple_vcallocn (), @@ -137,6 +141,7 @@ The and .BR libsimple_ecallocn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -185,18 +190,25 @@ T{ .BR libsimple_ecallocn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -204,7 +216,17 @@ None. .BR libsimple_vmalloczn (3), .BR libsimple_encalloc (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vmallocn.3 b/man3/libsimple_vmallocn.3 index 0aed464..9383069 100644 --- a/man3/libsimple_vmallocn.3 +++ b/man3/libsimple_vmallocn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VMALLOCN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VMALLOCN 3 libsimple .SH NAME libsimple_vmallocn \- allocate memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_emallocn(size_t \fIn\fP, ..., /* (size_t)0 */); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_mallocn (), @@ -93,6 +95,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vmallocn (), @@ -118,6 +121,7 @@ it indicate the error, and the and .BR libsimple_emallocn () functions terminated the process. + .SH ERRORS The .BR libsimple_vmallocn (), @@ -137,6 +141,7 @@ The and .BR libsimple_emallocn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -185,18 +190,25 @@ T{ .BR libsimple_emallocn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -204,7 +216,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vmalloczn.3 b/man3/libsimple_vmalloczn.3 index 8b12b4a..67354e6 100644 --- a/man3/libsimple_vmalloczn.3 +++ b/man3/libsimple_vmalloczn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VMALLOCZN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VMALLOCZN 3 libsimple .SH NAME libsimple_vmalloczn \- allocate optionally initialised memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_emalloczn(int \fIclear\fP, size_t \fIn\fP, ..., /* .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_malloczn (), @@ -98,6 +100,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vmalloczn (), @@ -123,6 +126,7 @@ it indicate the error, and the and .BR libsimple_emalloczn () functions terminated the process. + .SH ERRORS The .BR libsimple_vmalloczn (), @@ -144,6 +148,7 @@ The and .BR libsimple_emalloczn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -192,18 +197,25 @@ T{ .BR libsimple_emalloczn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -211,7 +223,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vmemalignn.3 b/man3/libsimple_vmemalignn.3 index 8a6c5c1..1f13cd7 100644 --- a/man3/libsimple_vmemalignn.3 +++ b/man3/libsimple_vmemalignn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VMEMALIGNN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VMEMALIGNN 3 libsimple .SH NAME libsimple_vmemalignn \- allocate memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_ememalignn(size_t \fIalignment\fP, size_t \fIn\fP, .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memalignn (), @@ -91,6 +93,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vmemalignn (), @@ -116,6 +119,7 @@ it indicate the error, and the and .BR libsimple_ememalignn () functions terminated the process. + .SH ERRORS The .BR libsimple_vmemalignn (), @@ -140,6 +144,7 @@ The and .BR libsimple_ememalignn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -188,18 +193,25 @@ T{ .BR libsimple_ememalignn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -208,7 +220,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignzn (3), diff --git a/man3/libsimple_vmemalignzn.3 b/man3/libsimple_vmemalignzn.3 index f59b3a0..d9b0434 100644 --- a/man3/libsimple_vmemalignzn.3 +++ b/man3/libsimple_vmemalignzn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VMEMALIGNZN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VMEMALIGNZN 3 libsimple .SH NAME libsimple_vmemalignzn \- allocate optionally initialised memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_ememalignzn(int \fIclear\fP, size_t \fIalignment\f .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_memalignzn (), @@ -94,6 +96,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vmemalignzn (), @@ -119,6 +122,7 @@ it indicate the error, and the and .BR libsimple_ememalignzn () functions terminated the process. + .SH ERRORS The .BR libsimple_vmemalignzn (), @@ -143,6 +147,7 @@ The and .BR libsimple_ememalignzn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -191,18 +196,25 @@ T{ .BR libsimple_ememalignzn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -211,7 +223,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vmemalloc.3 b/man3/libsimple_vmemalloc.3 index e088af2..ab0b4c3 100644 --- a/man3/libsimple_vmemalloc.3 +++ b/man3/libsimple_vmemalloc.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VMEMALLOC 3 2018-11-03 libsimple +.TH LIBSIMPLE_VMEMALLOC 3 libsimple .SH NAME libsimple_vmemalloc \- allocate memory in a flexible manner + .SH SYNOPSIS .nf #include <libsimple.h> @@ -19,6 +20,7 @@ static inline void *libsimple_ememalloc(size_t \fIn\fP, ..., /* LIBSIMPLE_MEMALL .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_vmemalloc () @@ -178,6 +180,7 @@ and functions, respectively, that use variadic arguments instead of .BR va_list . + .SH RETURN VALUE The .BR libsimple_vmemalloc (), @@ -203,6 +206,7 @@ to indicate the error, whereas the and .BR libsimple_ememalloc () functions terminate the process. + .SH ERRORS The .BR libsimple_vmemalloc () @@ -227,6 +231,7 @@ The and .BR libsimple_ememalloc () functions terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -275,18 +280,25 @@ T{ .BR libsimple_ememalloc () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_varrayalloc (3), .BR libsimple_enmalloc (3), @@ -296,7 +308,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vposix_memalignn.3 b/man3/libsimple_vposix_memalignn.3 index f05ab6b..b8da3e8 100644 --- a/man3/libsimple_vposix_memalignn.3 +++ b/man3/libsimple_vposix_memalignn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VPOSIX_MEMALIGNN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VPOSIX_MEMALIGNN 3 libsimple .SH NAME libsimple_vposix_memalignn \- allocate memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void libsimple_eposix_memalignn(void **\fImemptr\fP, size_t \fIali .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_posix_memalignn (), @@ -96,6 +98,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vposix_memalignn () @@ -113,6 +116,7 @@ and .BR libsimple_eposix_memalignn () functions to not return a value, but terminated the process on failure. + .SH ERRORS The .BR libsimple_vposix_memalignn (), @@ -142,6 +146,7 @@ The and .BR libsimple_eposix_memalignn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -190,18 +195,25 @@ T{ .BR libsimple_eposix_memalignn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -210,7 +222,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vposix_memalignzn.3 b/man3/libsimple_vposix_memalignzn.3 index 481a4b1..fd4c682 100644 --- a/man3/libsimple_vposix_memalignzn.3 +++ b/man3/libsimple_vposix_memalignzn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VPOSIX_MEMALIGNZN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VPOSIX_MEMALIGNZN 3 libsimple .SH NAME libsimple_vposix_memalignzn \- allocate optionally initialised memory with custom alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline int libsimple_eposix_memalignzn(void **\fImemptr\fP, int \fIclear\ .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_posix_memalignzn (), @@ -99,6 +101,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vposix_memalignzn () @@ -116,6 +119,7 @@ and .BR libsimple_eposix_memalignzn () functions do not return a value, but terminated the process on failure. + .SH ERRORS The .BR libsimple_vposix_memalignzn (), @@ -145,6 +149,7 @@ The and .BR libsimple_eposix_memalignzn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -193,18 +198,25 @@ T{ .BR libsimple_eposix_memalignzn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -213,7 +225,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vputenvf.3 b/man3/libsimple_vputenvf.3 index 33c5559..d772c81 100644 --- a/man3/libsimple_vputenvf.3 +++ b/man3/libsimple_vputenvf.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VPUTENVF 3 2018-10-20 libsimple +.TH LIBSIMPLE_VPUTENVF 3 libsimple .SH NAME libsimple_vputenvf \- change or add a string formatted value to the environment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void libsimple_eputenvf(const char *\fIfmt\fP, ...); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_vputenvf () @@ -88,6 +90,7 @@ for more information. Modifications made to the environment do not become visible to other process until the process image is changed. + .SH RETURN VALUE Upon successful completion, the .BR libsimple_vputenvf () @@ -96,6 +99,7 @@ and functions return 0; otherwise, they return \-1 and set .I errno to indicate the error. + .SH ERRORS The .BR libsimple_vputenvf () @@ -114,6 +118,7 @@ Insufficient memory was available. They may also fail for any reason specified for the .BR vsnprintf (3) function. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -162,14 +167,19 @@ T{ .BR libsimple_eputenvf () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES If the construct does not contain the .B '=' @@ -182,12 +192,14 @@ the behaviour is unspecified when countered by the and .BR unsetenv (3) functions. + .SH BUGS There is no mechanism for detecting which entries in the environment are statically allocated and which are dynamically allocated, this can lead to memory leaks with are detected by .BR valgrind (1). + .SH SEE ALSO .BR putenv (3), .BR setenv (3), diff --git a/man3/libsimple_vpvallocn.3 b/man3/libsimple_vpvallocn.3 index 4c05134..1d4bbbb 100644 --- a/man3/libsimple_vpvallocn.3 +++ b/man3/libsimple_vpvallocn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VPVALLOCN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VPVALLOCN 3 libsimple .SH NAME libsimple_vpvallocn \- allocate memory with page size alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_epvallocn(size_t \fIn\fP, ..., /* (size_t)0 */); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_pvallocn (), @@ -91,6 +93,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vpvallocn (), @@ -116,6 +119,7 @@ it indicate the error, and the and .BR libsimple_epvallocn () functions terminated the process. + .SH ERRORS The .BR libsimple_vpvallocn (), @@ -136,6 +140,7 @@ The and .BR libsimple_epvallocn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -184,20 +189,27 @@ T{ .BR libsimple_epvallocn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES The GNU implementation of .BR pvalloc (3) is \(dqMT-Unsafe init\(dq. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -206,7 +218,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vpvalloczn.3 b/man3/libsimple_vpvalloczn.3 index be9f1c5..e620758 100644 --- a/man3/libsimple_vpvalloczn.3 +++ b/man3/libsimple_vpvalloczn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VPVALLOCZN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VPVALLOCZN 3 libsimple .SH NAME libsimple_vpvalloczn \- allocate optionally initialised memory with page size alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_epvalloczn(int \fIclear\fP, size_t \fIn\fP, ..., / .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_pvalloczn (), @@ -93,6 +95,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vpvalloczn (), @@ -118,6 +121,7 @@ it indicate the error, and the and .BR libsimple_epvalloczn () functions terminated the process. + .SH ERRORS The .BR libsimple_vpvalloczn (), @@ -138,6 +142,7 @@ The and .BR libsimple_epvalloczn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -186,20 +191,27 @@ T{ .BR libsimple_epvalloczn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES The GNU implementation of .BR pvalloc (3) is \(dqMT-Unsafe init\(dq. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -208,7 +220,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vreallocfn.3 b/man3/libsimple_vreallocfn.3 new file mode 100644 index 0000000..5dd5390 --- /dev/null +++ b/man3/libsimple_vreallocfn.3 @@ -0,0 +1,178 @@ +.TH LIBSIMPLE_VREALLOCFN 3 libsimple +.SH NAME +libsimple_vreallocfn \- reallocate memory + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +static inline void *libsimple_vreallocfn(void *\fIptr\fP, size_t \fIn\fP, va_list \fIap\fP); +static inline void *libsimple_reallocfn(void *\fIptr\fP, size_t \fIn\fP, ..., /* (size_t)0 */); + +#ifndef vreallocfn +# define vreallocfn libsimple_vreallocfn +#endif +#ifndef reallocfn +# define reallocfn libsimple_reallocfn +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_reallocfn () +function is a wrapper for the +.BR realloc (3) +function, it reallocate memory allocated on +the heap and return the older pointer or a new +pointer with the alignment of +.I alignof(max_align_t) +to the allocated memory of +.I N +bytes, where +.I N +is the product of +.I n +and all following arguments (which should have the type +.BR size_t ) +up to the first 0; +.I n +must not be 0. The returned pointer will contain the +same content as +.IR ptr , +but truncated to +.I N +bytes if it is smaller or with the new bytes +unitialised if it is larger. If a new pointer +is returned, rather than +.IR ptr , +.I ptr +is deallocated; +.I ptr +is also deallocated on failure. The function +.BR free (3) +shall be called with the returned pointer as +input when the allocated memory is no longer needed. +.PP +The +.BR libsimple_vreallocfn () +function is a version of the +.BR libsimple_reallocfn () +function that use +.B va_list +instead of variadic arguments. + +.SH RETURN VALUE +The +.BR libsimple_vreallocfn () +and +.BR libsimple_reallocfn (), +functions return a pointer to the allocated memory +upon success completion; otherwise the +.BR libsimple_vreallocfn () +and +.BR libsimple_reallocfn () +functions return +.B NULL +and set +.I errno +it indicate the error. + +.SH ERRORS +The +.BR libsimple_vreallocn (), +.BR libsimple_reallocn () +function will fail for the reasons specified for the +.BR realloc (3) +function, and if: +.TP +.B EINVAL +.I n +is 0. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_vreallocfn (), +.br +.BR libsimple_reallocfn () +T} Thread safety MT-Safe +T{ +.BR libsimple_vreallocfn (), +.br +.BR libsimple_reallocfn () +T} Async-signal safety AS-Safe +T{ +.BR libsimple_vreallocfn (), +.br +.BR libsimple_reallocfn () +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_enmalloc (3), +.BR libsimple_mallocz (3), +.BR libsimple_vmallocn (3), +.BR libsimple_vmalloczn (3), +.BR libsimple_encalloc (3), +.BR libsimple_vcallocn (3), +.BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), +.BR libsimple_memalign (3), +.BR libsimple_memalignz (3), +.BR libsimple_vmemalignn (3), +.BR libsimple_vmemalignzn (3), +.BR libsimple_enposix_memalign (3), +.BR libsimple_posix_memalignz (3), +.BR libsimple_vposix_memalignn (3), +.BR libsimple_vposix_memalignzn (3), +.BR libsimple_enaligned_alloc (3), +.BR libsimple_aligned_allocz (3), +.BR libsimple_valigned_allocn (3), +.BR libsimple_valigned_alloczn (3), +.BR libsimple_pvalloc (3), +.BR libsimple_pvallocz (3), +.BR libsimple_vpvallocn (3), +.BR libsimple_vpvalloczn (3), +.BR libsimple_valloc (3), +.BR libsimple_vallocz (3), +.BR libsimple_vvallocn (3), +.BR libsimple_vvalloczn (3), +.BR libsimple_vmemalloc (3), +.BR libsimple_varrayalloc (3), +.BR malloc (3) diff --git a/man3/libsimple_vreallocn.3 b/man3/libsimple_vreallocn.3 index 2f61307..bddce8b 100644 --- a/man3/libsimple_vreallocn.3 +++ b/man3/libsimple_vreallocn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VREALLOCN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VREALLOCN 3 libsimple .SH NAME libsimple_vreallocn \- reallocate memory + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_ereallocn(void *\fIptr\fP, size_t \fIn\fP, ..., /* .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_reallocn (), @@ -43,7 +45,7 @@ and functions are wrappers for the .BR realloc (3) function, they reallocate memory allocated on -the heap and return the older pointer ot a new +the heap and return the older pointer or a new pointer with the alignment of .I alignof(max_align_t) to the allocated memory of @@ -106,6 +108,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vreallocn (), @@ -131,11 +134,13 @@ it indicate the error, and the and .BR libsimple_ereallocn () functions terminated the process. + .SH ERRORS The -.BR libsimple_vreallocn (), +.BR libsimple_vreallocn () +and .BR libsimple_reallocn () -function will fail for the reasons specified for the +functions will fail for the reasons specified for the .BR realloc (3) function, and if: .TP @@ -150,6 +155,7 @@ The and .BR libsimple_ereallocn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -198,18 +204,25 @@ T{ .BR libsimple_ereallocn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -218,6 +231,16 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vvallocn.3 b/man3/libsimple_vvallocn.3 index e21d37b..c378660 100644 --- a/man3/libsimple_vvallocn.3 +++ b/man3/libsimple_vvallocn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VVALLOCN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VVALLOCN 3 libsimple .SH NAME libsimple_vvallocn \- allocate memory with page size alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_evallocn(size_t \fIn\fP, ..., /* (size_t)0 */); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_vallocn (), @@ -90,6 +92,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vvallocn (), @@ -115,6 +118,7 @@ it indicate the error, and the and .BR libsimple_evallocn () functions terminated the process. + .SH ERRORS The .BR libsimple_vvallocn (), @@ -135,6 +139,7 @@ The and .BR libsimple_evallocn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -183,20 +188,27 @@ T{ .BR libsimple_evallocn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES The GNU implementation of .BR valloc (3) is \(dqMT-Unsafe init\(dq. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -205,7 +217,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vvalloczn.3 b/man3/libsimple_vvalloczn.3 index 1b7a8e0..9a2f9e4 100644 --- a/man3/libsimple_vvalloczn.3 +++ b/man3/libsimple_vvalloczn.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VVALLOCZN 3 2018-11-03 libsimple +.TH LIBSIMPLE_VVALLOCZN 3 libsimple .SH NAME libsimple_vvalloczn \- allocate optionally initialised memory with page size alignment + .SH SYNOPSIS .nf #include <libsimple.h> @@ -34,6 +35,7 @@ static inline void *libsimple_evalloczn(int \fIclear\fP, size_t \fIn\fP, ..., /* .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_valloczn (), @@ -93,6 +95,7 @@ and respectively, that use .B va_list instead of variadic arguments. + .SH RETURN VALUE The .BR libsimple_vvalloczn (), @@ -118,6 +121,7 @@ it indicate the error, and the and .BR libsimple_evalloczn () functions terminated the process. + .SH ERRORS The .BR libsimple_vvalloczn (), @@ -138,6 +142,7 @@ The and .BR libsimple_evalloczn () functions will terminate the process on failure. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -186,20 +191,27 @@ T{ .BR libsimple_evalloczn () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES The GNU implementation of .BR valloc (3) is \(dqMT-Unsafe init\(dq. + .SH BUGS None. + .SH SEE ALSO .BR libsimple_enmalloc (3), .BR libsimple_mallocz (3), @@ -208,7 +220,17 @@ None. .BR libsimple_encalloc (3), .BR libsimple_vcallocn (3), .BR libsimple_enrealloc (3), +.BR libsimple_reallocarray (3), .BR libsimple_vreallocn (3), +.BR libsimple_reallocf (3), +.BR libsimple_reallocarrayf (3), +.BR libsimple_vreallocfn (3), +.BR libsimple_aligned_realloc (3), +.BR libsimple_aligned_reallocarray (3), +.BR libsimple_aligned_vreallocn (3), +.BR libsimple_aligned_reallocf (3), +.BR libsimple_aligned_reallocarrayf (3), +.BR libsimple_aligned_vreallocfn (3), .BR libsimple_memalign (3), .BR libsimple_memalignz (3), .BR libsimple_vmemalignn (3), diff --git a/man3/libsimple_vweprintf.3 b/man3/libsimple_vweprintf.3 index 06d339d..8db6f0a 100644 --- a/man3/libsimple_vweprintf.3 +++ b/man3/libsimple_vweprintf.3 @@ -1,6 +1,7 @@ -.TH LIBSIMPLE_VWEPRINTF 3 2018-11-06 libsimple +.TH LIBSIMPLE_VWEPRINTF 3 libsimple .SH NAME libsimple_vweprintf \- print an error message + .SH SYNOPSIS .nf #include <libsimple.h> @@ -38,6 +39,7 @@ static inline void libsimple_eprintf(const char *\fIfmt\fP, ...); .PP Link with .IR \-lsimple . + .SH DESCRIPTION The .BR libsimple_vweprintf () @@ -151,10 +153,13 @@ function called when or .I libsimple_eprint_postprint is called. + .SH RETURN VALUE None. + .SH ERRORS None. + .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). @@ -203,18 +208,25 @@ T{ .BR libsimple_eprintf () T} Async-cancel safety AC-Safe .TE + .SH EXAMPLES None. + .SH APPLICATION USAGE None. + .SH RATIONALE None. + .SH FUTURE DIRECTIONS None. + .SH NOTES None. + .SH BUGS None. + .SH SEE ALSO .BR perror (3), .BR fprintf (3), diff --git a/man3/libsimple_wcsdupa.3 b/man3/libsimple_wcsdupa.3 new file mode 120000 index 0000000..85a85a6 --- /dev/null +++ b/man3/libsimple_wcsdupa.3 @@ -0,0 +1 @@ +libsimple_enwcsdup.3
\ No newline at end of file diff --git a/man3/libsimple_wcsndup.3 b/man3/libsimple_wcsndup.3 new file mode 100644 index 0000000..6821d25 --- /dev/null +++ b/man3/libsimple_wcsndup.3 @@ -0,0 +1,167 @@ +.TH LIBSIMPLE_WCSNDUP 3 libsimple +.SH NAME +libsimple_wcsndup \- duplicate a wide-character string + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +wchar_t *libsimple_wcsndupa(const wchar_t *\fIs\fP, size_t \fIn\fP); +wchar_t *libsimple_wcsndup(const wchar_t *\fIs\fP, size_t \fIn\fP); +wchar_t *libsimple_enwcsndup(int \fIstatus\fP, const wchar_t *\fIs\fP, size_t \fIn\fP); +static inline wchar_t *libsimple_ewcsndup(const wchar_t *\fIs\fP, size_t \fIn\fP); + +#ifndef wcsndupa +# define wcsndupa libsimple_wcsndupa +#endif +#ifndef wcsndup +# define wcsndup libsimple_wcsndup +#endif +#ifndef enwcsndup +# define enwcsndup libsimple_enwcsndup +#endif +#ifndef ewcsndup +# define ewcsndup libsimple_ewcsndup +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_wcsndup () +function allocates memory and copies the string +.I s +into the new allocation, however only up to the +.I n +first wide-characters; a NUL wide-character will +always be written to the end of the new +wide-character string. +.PP +The +.BR libsimple_enwcsndup () +and +.BR libsimple_ewcsndup () +functions are versions of the +.BR libsimple_wcsndup () +function that call the +.BR libsimple_enprintf (3) +function on failure, causing the process to print +an error message and exit. See +.BR libsimple_enprintf (3) +for more information. +.PP +The +.BR libsimple_wcsndupa () +function is implemented as a macro and is a version +of the +.BR libsimple_wcsndup () +function that uses allocates the memory on the stack +rather than on the heap, causing the return pointer +to become invalid when the calling function returns. +It is only available when compling with GCC or Clang. + +.SH RETURN VALUE +Upon successful completion, the +.BR libsimple_wcsndupa (), +.BR libsimple_wcsndup (), +.BR libsimple_enwcsndup (), +and +.BR libsimple_ewcsndup () +functions return a non-null pointer, on failure the +.BR libsimple_wcsndup () +function returns +.B NULL +and set +.I errno +to indicate the error, and the +.BR libsimple_enwcsndup (), +and +.BR libsimple_ewcsndup () +functions exit the process. The +.BR libsimple_wcsndupa () +function cannot fail, however the kernel +can kill the thread, and possibly the process, with a +.B SIGSEGV +signal if the memory cannot be allocated. +.PP +The returned pointer should be deallocated when it +is no longer needed, except for the pointer returned +by the +.BR libsimple_wcsndupa () +function, it is automatically deallocated when the +calling function returns. + +.SH ERRORS +The +.BR libsimple_wcsndup () +function may fail for any reason specified for the +.BR malloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_wcsndupa (), +.br +.BR libsimple_wcsndup (), +.br +.BR libsimple_enwcsndup (), +.br +.BR libsimple_ewcsndup (), +T} Thread safety MT-Safe +T{ +.BR libsimple_wcsndupa (), +.br +.BR libsimple_wcsndup (), +.br +.BR libsimple_enwcsndup (), +.br +.BR libsimple_ewcsndup (), +T} Async-signal safety AS-Safe +T{ +.BR libsimple_wcsndupa (), +.br +.BR libsimple_wcsndup (), +.br +.BR libsimple_enwcsndup (), +.br +.BR libsimple_ewcsndup (), +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_aligned_wcsndup (3), +.BR libsimple_enstrndup (3), +.BR libsimple_enstrdup (3), +.BR libsimple_memdup (3), +.BR libsimple_enwcsdup (3), +.BR libsimple_wmemdup (3), +.BR strndup (3), +.BR strdup (3), +.BR wcsdup (3) diff --git a/man3/libsimple_wcsndupa.3 b/man3/libsimple_wcsndupa.3 new file mode 120000 index 0000000..57c8250 --- /dev/null +++ b/man3/libsimple_wcsndupa.3 @@ -0,0 +1 @@ +libsimple_wcsndup.3
\ No newline at end of file diff --git a/man3/libsimple_wmemdup.3 b/man3/libsimple_wmemdup.3 new file mode 100644 index 0000000..1f9e9cd --- /dev/null +++ b/man3/libsimple_wmemdup.3 @@ -0,0 +1,167 @@ +.TH LIBSIMPLE_WMEMDUP 3 libsimple +.SH NAME +libsimple_wmemdup \- duplicate a wide-character array + +.SH SYNOPSIS +.nf +#include <libsimple.h> + +wchar_t *libsimple_wmemdupa(const wchar_t *\fIs\fP, size_t \fIn\fP); +wchar_t *libsimple_wmemdup(const wchar_t *\fIs\fP, size_t \fIn\fP); +wchar_t *libsimple_enwmemdup(int \fIstatus\fP, const wchar_t *\fIs\fP, size_t \fIn\fP); +static inline wchar_t *libsimple_ewmemdup(const wchar_t *\fIs\fP, size_t \fIn\fP); + +#ifndef wmemdupa +# define wmemdupa libsimple_wmemdupa +#endif +#ifndef wmemdup +# define wmemdup libsimple_wmemdup +#endif +#ifndef enwmemdup +# define enwmemdup libsimple_enwmemdup +#endif +#ifndef ewmemdup +# define ewmemdup libsimple_ewmemdup +#endif +.fi +.PP +Link with +.IR \-lsimple . + +.SH DESCRIPTION +The +.BR libsimple_wmemdup () +function allocates memory and copies +.I n +first wide-characters +.RB ( wchar_t ) +from +.I s +into the new allocation. +.PP +The +.BR libsimple_enwmemdup () +and +.BR libsimple_ewmemdup () +functions are versions of the +.BR libsimple_wmemdup () +function that call the +.BR libsimple_enprintf (3) +function on failure, causing the process to print +an error message and exit. See +.BR libsimple_enprintf (3) +for more information. +.PP +The +.BR libsimple_wmemdupa () +function is implemented as a macro and is a version +of the +.BR libsimple_wmemdup () +function that uses allocates the memory on the stack +rather than on the heap, causing the return pointer +to become invalid when the calling function returns. +It is only available when compling with GCC or Clang. + +.SH RETURN VALUE +Upon successful completion, the +.BR libsimple_wmemdupa (), +.BR libsimple_wmemdup (), +.BR libsimple_enwmemdup (), +and +.BR libsimple_ewmemdup () +functions return a non-null pointer, on failure the +.BR libsimple_wmemdup () +function returns +.B NULL +and set +.I errno +to indicate the error, and the +.BR libsimple_enwmemdup (), +and +.BR libsimple_ewmemdup () +functions exit the process. The +.BR libsimple_wmemdupa () +function cannot fail, however the kernel +can kill the thread, and possibly the process, with a +.B SIGSEGV +signal if the memory cannot be allocated. +.PP +The returned pointer should be deallocated when it +is no longer needed, except for the pointer returned +by the +.BR libsimple_wmemdupa () +function, it is automatically deallocated when the +calling function returns. + +.SH ERRORS +The +.BR libsimple_wmemdup () +function may fail for any reason specified for the +.BR malloc (3) +function. + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lb lb lb +l l l. +Interface Attribute Value +T{ +.BR libsimple_wmemdupa (), +.br +.BR libsimple_wmemdup (), +.br +.BR libsimple_enwmemdup (), +.br +.BR libsimple_ewmemdup (), +T} Thread safety MT-Safe +T{ +.BR libsimple_wmemdupa (), +.br +.BR libsimple_wmemdup (), +.br +.BR libsimple_enwmemdup (), +.br +.BR libsimple_ewmemdup (), +T} Async-signal safety AS-Safe +T{ +.BR libsimple_wmemdupa (), +.br +.BR libsimple_wmemdup (), +.br +.BR libsimple_enwmemdup (), +.br +.BR libsimple_ewmemdup (), +T} Async-cancel safety AC-Safe +.TE + +.SH EXAMPLES +None. + +.SH APPLICATION USAGE +None. + +.SH RATIONALE +None. + +.SH FUTURE DIRECTIONS +None. + +.SH NOTES +None. + +.SH BUGS +None. + +.SH SEE ALSO +.BR libsimple_aligned_wmemdup (3), +.BR libsimple_enstrndup (3), +.BR libsimple_enstrdup (3), +.BR libsimple_memdup (3), +.BR libsimple_enwcsdup (3), +.BR libsimple_wcsndup (3), +.BR strndup (3), +.BR strdup (3), +.BR wcsdup (3) diff --git a/man3/libsimple_wmemdupa.3 b/man3/libsimple_wmemdupa.3 new file mode 120000 index 0000000..93381ef --- /dev/null +++ b/man3/libsimple_wmemdupa.3 @@ -0,0 +1 @@ +libsimple_wmemdup.3
\ No newline at end of file diff --git a/man3/reallocarray.3libsimple b/man3/reallocarray.3libsimple new file mode 120000 index 0000000..9cb5fe4 --- /dev/null +++ b/man3/reallocarray.3libsimple @@ -0,0 +1 @@ +libsimple_reallocarray.3
\ No newline at end of file diff --git a/man3/reallocarrayf.3libsimple b/man3/reallocarrayf.3libsimple new file mode 120000 index 0000000..c0ad147 --- /dev/null +++ b/man3/reallocarrayf.3libsimple @@ -0,0 +1 @@ +libsimple_reallocarrayf.3
\ No newline at end of file diff --git a/man3/reallocf.3libsimple b/man3/reallocf.3libsimple new file mode 120000 index 0000000..e60bee6 --- /dev/null +++ b/man3/reallocf.3libsimple @@ -0,0 +1 @@ +libsimple_reallocf.3
\ No newline at end of file diff --git a/man3/reallocfn.3libsimple b/man3/reallocfn.3libsimple new file mode 120000 index 0000000..7db99ff --- /dev/null +++ b/man3/reallocfn.3libsimple @@ -0,0 +1 @@ +libsimple_reallocfn.3
\ No newline at end of file diff --git a/man3/valigned_reallocfn.3libsimple b/man3/valigned_reallocfn.3libsimple new file mode 120000 index 0000000..1ba44a5 --- /dev/null +++ b/man3/valigned_reallocfn.3libsimple @@ -0,0 +1 @@ +libsimple_valigned_reallocfn.3
\ No newline at end of file diff --git a/man3/valigned_reallocn.3libsimple b/man3/valigned_reallocn.3libsimple new file mode 120000 index 0000000..7c3a84f --- /dev/null +++ b/man3/valigned_reallocn.3libsimple @@ -0,0 +1 @@ +libsimple_valigned_reallocn.3
\ No newline at end of file diff --git a/man3/vreallocfn.3libsimple b/man3/vreallocfn.3libsimple new file mode 120000 index 0000000..d06b871 --- /dev/null +++ b/man3/vreallocfn.3libsimple @@ -0,0 +1 @@ +libsimple_vreallocfn.3
\ No newline at end of file diff --git a/man3/wcsdupa.3libsimple b/man3/wcsdupa.3libsimple new file mode 120000 index 0000000..4555af1 --- /dev/null +++ b/man3/wcsdupa.3libsimple @@ -0,0 +1 @@ +libsimple_wcsdupa.3
\ No newline at end of file diff --git a/man3/wcsndup.3libsimple b/man3/wcsndup.3libsimple new file mode 120000 index 0000000..57c8250 --- /dev/null +++ b/man3/wcsndup.3libsimple @@ -0,0 +1 @@ +libsimple_wcsndup.3
\ No newline at end of file diff --git a/man3/wcsndupa.3libsimple b/man3/wcsndupa.3libsimple new file mode 120000 index 0000000..ac844a1 --- /dev/null +++ b/man3/wcsndupa.3libsimple @@ -0,0 +1 @@ +libsimple_wcsndupa.3
\ No newline at end of file diff --git a/man3/wmemdup.3libsimple b/man3/wmemdup.3libsimple new file mode 120000 index 0000000..93381ef --- /dev/null +++ b/man3/wmemdup.3libsimple @@ -0,0 +1 @@ +libsimple_wmemdup.3
\ No newline at end of file diff --git a/man3/wmemdupa.3libsimple b/man3/wmemdupa.3libsimple new file mode 120000 index 0000000..919c84e --- /dev/null +++ b/man3/wmemdupa.3libsimple @@ -0,0 +1 @@ +libsimple_wmemdupa.3
\ No newline at end of file @@ -6,7 +6,7 @@ void * libsimple_memdup(const void *s, size_t n) { - void *ret = malloc(n ? n : (size_t)1); + void *ret = malloc(n + !n); if (!ret) return NULL; return memcpy(ret, s, n); @@ -229,11 +229,43 @@ strndup(const char *s, size_t n) } +#if 0 void * memdup(const void *s, size_t size) { return libsimple_memdup(s, size); } +#endif + + +wchar_t * +wcsdup(const wchar_t *s) +{ + wchar_t *r; + size_t n = wcslen(s) + 1; + if (n > SIZE_MAX / sizeof(wchar_t)) { + errno = ENOMEM; + return NULL; + } + r = malloc(n * sizeof(wchar_t)); + return r ? wcscpy(r, s) : r; +} + + +#if 0 +wchar_t * +wcsndup(const wchar_t *s, size_t n) +{ + return libsimple_wcsndup(s, n); +} + + +wchar_t * +wmemdup(const wchar_t *s, size_t n) +{ + return libsimple_wmemdup(s, n); +} +#endif void @@ -255,7 +287,7 @@ memset(void *s, int c, size_t n) { char *str = s; struct allocinfo *info; - if (just_alloced && s == just_alloced) { + if (s == just_alloced && just_alloced && !c) { info = get_allocinfo(s); info->zeroed = MAX(info->zeroed, n); } @@ -95,3 +95,42 @@ test_fprintf(FILE *restrict stream, const char *restrict format, ...) return test_vfprintf(stream, format, ap); va_end(ap); } + + + +static size_t +gcd(size_t u, size_t v) +{ + size_t t; + int shift = 0; + /* Not needed because u>0, v>0: if (!(u | v)) return u + v; */ + while (!((u | v) & 1)) u >>= 1, v >>= 1, shift++; + while (!(u & 1)) u >>= 1; + do { + while (!(v & 1)) v >>= 1; + if (u > v) t = u, u = v, v = t; + } while (v -= u); + return u << shift; +} + +static inline size_t +lcm(size_t u, size_t v) +{ + return u / gcd(u, v) * v; +} + +#define ASSERT_ALIGNMENT(INFO, ALIGN)\ + do {\ + assert((INFO)->alignment <= lcm(cacheline, ALIGN));\ + assert(!((INFO)->alignment % (ALIGN)));\ + if ((cacheline - (ALIGN) % cacheline) % cacheline + (INFO)->size % (ALIGN) > cacheline)\ + assert(!((INFO)->alignment % cacheline));\ + } while (0) + +#define DEFINE_PAGESIZE size_t pagesize = (size_t)sysconf(_SC_PAGESIZE) + +#ifdef _SC_LEVEL1_DCACHE_LINESIZ +#define DEFINE_CACHELINE size_t cacheline = (size_t)sysconf(_SC_LEVEL1_DCACHE_LINESIZE) +#else +#define DEFINE_CACHELINE size_t cacheline = 64 +#endif diff --git a/wcsndup.c b/wcsndup.c new file mode 100644 index 0000000..5621084 --- /dev/null +++ b/wcsndup.c @@ -0,0 +1,106 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_wcsndup(const wchar_t *s, size_t n) +{ + size_t size; + wchar_t *ret; + n = wcsnlen(s, n); + size = (n + 1) * sizeof(wchar_t); + ret = aligned_alloc(_Alignof(wchar_t), size); + if (!ret) + return NULL; + wmemcpy(ret, s, n); + ret[n] = 0; + return ret; +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + const wchar_t *s = L"test"; + wchar_t *p; + + p = libsimple_wcsndup(s, SIZE_MAX); + assert(p); + assert(p != s); + assert(!((uintptr_t)s % _Alignof(wchar_t))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(p))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + } + assert(!wmemcmp(p, s, 5)); + wmemset(p, 0, 5); + assert(!wmemcmp(s, L"test", 5)); + free(p); + + p = libsimple_wcsndup(s, 10); + assert(p); + assert(p != s); + assert(!((uintptr_t)s % _Alignof(wchar_t))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(p))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + } + assert(!wmemcmp(p, s, 5)); + wmemset(p, 0, 5); + assert(!wmemcmp(s, L"test", 5)); + free(p); + + p = libsimple_wcsndup(s, 5); + assert(p); + assert(p != s); + assert(!((uintptr_t)s % _Alignof(wchar_t))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(p))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + } + assert(!wmemcmp(p, s, 5)); + wmemset(p, 0, 5); + assert(!wmemcmp(s, L"test", 5)); + free(p); + + p = libsimple_wcsndup(s, 4); + assert(p); + assert(p != s); + assert(!((uintptr_t)s % _Alignof(wchar_t))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(p))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + } + assert(!wmemcmp(p, s, 5)); + wmemset(p, 0, 5); + assert(!wmemcmp(s, L"test", 5)); + free(p); + + p = libsimple_wcsndup(s, 2); + assert(p); + assert(p != s); + assert(!((uintptr_t)s % _Alignof(wchar_t))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(p))); + assert(info->size == 3 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + } + assert(!wmemcmp(p, s, 2)); + assert(!p[2]); + wmemset(p, 0, 3); + assert(!wmemcmp(s, L"test", 5)); + free(p); + + return 0; +} + +#endif diff --git a/wmemdup.c b/wmemdup.c new file mode 100644 index 0000000..2e9cc1c --- /dev/null +++ b/wmemdup.c @@ -0,0 +1,52 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" +#ifndef TEST + + +wchar_t * +libsimple_wmemdup(const wchar_t *s, size_t n) +{ + wchar_t *ret; + size_t size; + if (LIBSIMPLE_UMUL_OVERFLOW_NONZERO(n + !n, sizeof(wchar_t), &size, SIZE_MAX)) { + errno = ENOMEM; + return NULL; + } + ret = aligned_alloc(_Alignof(wchar_t), size); + if (!ret) + return NULL; + return wmemcpy(ret, s, n); +} + + +#else +#include "test.h" + +int +main(void) +{ + struct allocinfo *info; + const wchar_t *s = L"test"; + wchar_t *p; + + p = libsimple_wmemdup(s, 5); + assert(p); + assert(p != s); + assert(!((uintptr_t)s % _Alignof(wchar_t))); + if (have_custom_malloc()) { + assert((info = get_allocinfo(p))); + assert(info->size == 5 * sizeof(wchar_t)); + assert(info->alignment == _Alignof(wchar_t)); + } + assert(!wmemcmp(p, s, 5)); + wmemset(p, 0, 5); + assert(!wmemcmp(s, L"test", 5)); + free(p); + + errno = 0; + assert(!libsimple_wmemdup(NULL, SSIZE_MAX) && errno == ENOMEM); + + return 0; +} + +#endif |