Commit 96027115 authored by (no author)'s avatar (no author) Committed by Jens Gustedt
Browse files

documentation and whitespace


Signed-off-by: default avatarJens Gustedt <Jens.Gustedt@loria.fr>
parent 32ae64d4
......@@ -116,6 +116,13 @@
<anchor>ga33164ea696ce26d414df2fd3dca057fc</anchor>
<arglist>(OBJP, EXPECTED, DESIRED)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>atomic_exchange</name>
<anchorfile>group__atomic_gab1452731a25566508807d6fe92e55cf9.html</anchorfile>
<anchor>gab1452731a25566508807d6fe92e55cf9</anchor>
<arglist>(OBJP, DESIRED)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>atomic_fetch_add</name>
......@@ -137,13 +144,6 @@
<anchor>gadc3fefa52ac8a2e588df25ebc79afd80</anchor>
<arglist>(OBJP, OPERAND)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>atomic_fetch_and_store</name>
<anchorfile>group__atomic_gadc4844e27863d4b2d146e41f1c70ea03.html</anchorfile>
<anchor>gadc4844e27863d4b2d146e41f1c70ea03</anchor>
<arglist>(OBJP, DESIRED)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>atomic_fetch_max</name>
......@@ -868,30 +868,30 @@
<member kind="function">
<type>uint8_t</type>
<name>P99_PASTE</name>
<anchorfile>p99__atomic__gcc_8h_a86cc72848bb704e7cc882ff4f0a35bb2.html</anchorfile>
<anchor>a86cc72848bb704e7cc882ff4f0a35bb2</anchor>
<arglist>(p00_atomic_fetch_and_store_, 1)(uint8_t volatile *p00_p</arglist>
<anchorfile>p99__atomic__gcc_8h_a3bf1466f647dd4e426adc475bc633682.html</anchorfile>
<anchor>a3bf1466f647dd4e426adc475bc633682</anchor>
<arglist>(p00_atomic_exchange_, 1)(uint8_t volatile *p00_p</arglist>
</member>
<member kind="function">
<type>uint16_t</type>
<name>P99_PASTE</name>
<anchorfile>p99__atomic__gcc_8h_ab9e23f97d5f0940fc780bed243f2284b.html</anchorfile>
<anchor>ab9e23f97d5f0940fc780bed243f2284b</anchor>
<arglist>(p00_atomic_fetch_and_store_, 2)(uint16_t volatile *p00_p</arglist>
<anchorfile>p99__atomic__gcc_8h_a564ae6fe9e595f353aad357877970532.html</anchorfile>
<anchor>a564ae6fe9e595f353aad357877970532</anchor>
<arglist>(p00_atomic_exchange_, 2)(uint16_t volatile *p00_p</arglist>
</member>
<member kind="function">
<type>uint32_t</type>
<name>P99_PASTE</name>
<anchorfile>p99__atomic__gcc_8h_aac0766ef7687fa8f4ff1d92549b97fbe.html</anchorfile>
<anchor>aac0766ef7687fa8f4ff1d92549b97fbe</anchor>
<arglist>(p00_atomic_fetch_and_store_, 4)(uint32_t volatile *p00_p</arglist>
<anchorfile>p99__atomic__gcc_8h_a2222a1dba5df6fc6e42339d9e5309cb3.html</anchorfile>
<anchor>a2222a1dba5df6fc6e42339d9e5309cb3</anchor>
<arglist>(p00_atomic_exchange_, 4)(uint32_t volatile *p00_p</arglist>
</member>
<member kind="function">
<type>uint64_t</type>
<name>P99_PASTE</name>
<anchorfile>p99__atomic__gcc_8h_a6810eb798805d5b933801501c1115a2b.html</anchorfile>
<anchor>a6810eb798805d5b933801501c1115a2b</anchor>
<arglist>(p00_atomic_fetch_and_store_, 8)(uint64_t volatile *p00_p</arglist>
<anchorfile>p99__atomic__gcc_8h_a80d7bca8730953560b82eca7faa6d93c.html</anchorfile>
<anchor>a80d7bca8730953560b82eca7faa6d93c</anchor>
<arglist>(p00_atomic_exchange_, 8)(uint64_t volatile *p00_p</arglist>
</member>
</compound>
<compound kind="file">
......@@ -7070,6 +7070,40 @@
<arglist>(...)</arglist>
</member>
</compound>
<compound kind="file">
<name>p99_qsort.h</name>
<path>/home/gustedt/build/orwl/p99-source/p99/</path>
<filename>p99__qsort_8h</filename>
<includes id="p99__rand_8h" name="p99_rand.h" local="yes" imported="no">p99_rand.h</includes>
<member kind="define">
<type>#define</type>
<name>qsort_s</name>
<anchorfile>group__sorting_ga7dffa4b52032f181ca7360c7de4e48cb.html</anchorfile>
<anchor>ga7dffa4b52032f181ca7360c7de4e48cb</anchor>
<arglist>(B, N, S, CMP, CTX)</arglist>
</member>
<member kind="function">
<type>signed</type>
<name>p99_ilog2</name>
<anchorfile>group__sorting_ga05807be33b5e68937bb6458333d4c339.html</anchorfile>
<anchor>ga05807be33b5e68937bb6458333d4c339</anchor>
<arglist>(uintmax_t p00_i)</arglist>
</member>
<member kind="function">
<type>bool</type>
<name>p99_is_sorted</name>
<anchorfile>group__sorting_ga9ecb9298d2c8cb8cba981000710d7b8d.html</anchorfile>
<anchor>ga9ecb9298d2c8cb8cba981000710d7b8d</anchor>
<arglist>(void *p00_base, rsize_t p00_n, rsize_t p00_s, int(*p00_comp)(const void *, const void *, void *), void *p00_ctx)</arglist>
</member>
<member kind="function">
<type>rsize_t</type>
<name>p99_mismatch</name>
<anchorfile>group__sorting_ga1ca07f2aaf851bd6e99f2bdec6fdefec.html</anchorfile>
<anchor>ga1ca07f2aaf851bd6e99f2bdec6fdefec</anchor>
<arglist>(void *p00_base, rsize_t p00_n, rsize_t p00_s, int(*p00_comp)(const void *, const void *, void *), void *p00_ctx)</arglist>
</member>
</compound>
<compound kind="file">
<name>p99_rand.h</name>
<path>/home/gustedt/build/orwl/p99-source/p99/</path>
......@@ -7250,16 +7284,16 @@
<member kind="define">
<type>#define</type>
<name>P99_ASORT</name>
<anchorfile>p99__swap_8h_aae4c45f828a3fc295ba09738065ef620.html</anchorfile>
<anchor>aae4c45f828a3fc295ba09738065ef620</anchor>
<arglist>(TAB, COMP)</arglist>
<anchorfile>p99__swap_8h_a8b54df939370c509ff7a9b26a8101aae.html</anchorfile>
<anchor>a8b54df939370c509ff7a9b26a8101aae</anchor>
<arglist>(TAB,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>P99_QSORT</name>
<anchorfile>p99__swap_8h_a7a022c4bd7cfbbf6e0e8c255caf4e1b0.html</anchorfile>
<anchor>a7a022c4bd7cfbbf6e0e8c255caf4e1b0</anchor>
<arglist>(TAB, NB, COMP)</arglist>
<anchorfile>p99__swap_8h_ac1f0c291dff5d6db6e15b7b6828f85b5.html</anchorfile>
<anchor>ac1f0c291dff5d6db6e15b7b6828f85b5</anchor>
<arglist>(TAB, NB,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
......@@ -7508,6 +7542,13 @@
<anchor>ga7b75882abf4279114a1e5e072f1d63fd</anchor>
<arglist>(F, E,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>P99_THROW_CALL_NEGATE</name>
<anchorfile>group__try_gaff676c5efd7542cd3eff90b9098b94fb.html</anchorfile>
<anchor>gaff676c5efd7542cd3eff90b9098b94fb</anchor>
<arglist>(F, E,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>P99_THROW_CALL_RANGE</name>
......@@ -10901,6 +10942,13 @@
<anchor>ga33164ea696ce26d414df2fd3dca057fc</anchor>
<arglist>(OBJP, EXPECTED, DESIRED)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>atomic_exchange</name>
<anchorfile>group__atomic_gab1452731a25566508807d6fe92e55cf9.html</anchorfile>
<anchor>gab1452731a25566508807d6fe92e55cf9</anchor>
<arglist>(OBJP, DESIRED)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>atomic_fetch_add</name>
......@@ -10922,13 +10970,6 @@
<anchor>gadc3fefa52ac8a2e588df25ebc79afd80</anchor>
<arglist>(OBJP, OPERAND)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>atomic_fetch_and_store</name>
<anchorfile>group__atomic_gadc4844e27863d4b2d146e41f1c70ea03.html</anchorfile>
<anchor>gadc4844e27863d4b2d146e41f1c70ea03</anchor>
<arglist>(OBJP, DESIRED)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>atomic_fetch_max</name>
......@@ -13761,9 +13802,9 @@
</member>
<member kind="function">
<type>unsigned</type>
<name>p99_futex_fetch_and_store</name>
<anchorfile>group__futex_gae9992e6155e6444297674daf34127bb4.html</anchorfile>
<anchor>gae9992e6155e6444297674daf34127bb4</anchor>
<name>p99_futex_exchange</name>
<anchorfile>group__futex_ga5f3a21217d8b30a26562eaf0a9fa742a.html</anchorfile>
<anchor>ga5f3a21217d8b30a26562eaf0a9fa742a</anchor>
<arglist>(p99_futex volatile *p00_fut, unsigned p00_desired, unsigned p00_cstart, unsigned p00_clen, unsigned p00_wmin, unsigned p00_wmax)</arglist>
</member>
<member kind="function">
......@@ -15488,6 +15529,13 @@
<anchor>ga7b75882abf4279114a1e5e072f1d63fd</anchor>
<arglist>(F, E,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>P99_THROW_CALL_NEGATE</name>
<anchorfile>group__try_gaff676c5efd7542cd3eff90b9098b94fb.html</anchorfile>
<anchor>gaff676c5efd7542cd3eff90b9098b94fb</anchor>
<arglist>(F, E,...)</arglist>
</member>
<member kind="define">
<type>#define</type>
<name>P99_THROW_CALL_RANGE</name>
......@@ -19101,6 +19149,39 @@
<arglist>(T, F, N)</arglist>
</member>
</compound>
<compound kind="group">
<name>sorting</name>
<title>Sorting</title>
<filename>group__sorting.html</filename>
<member kind="define">
<type>#define</type>
<name>qsort_s</name>
<anchorfile>group__sorting_ga7dffa4b52032f181ca7360c7de4e48cb.html</anchorfile>
<anchor>ga7dffa4b52032f181ca7360c7de4e48cb</anchor>
<arglist>(B, N, S, CMP, CTX)</arglist>
</member>
<member kind="function">
<type>signed</type>
<name>p99_ilog2</name>
<anchorfile>group__sorting_ga05807be33b5e68937bb6458333d4c339.html</anchorfile>
<anchor>ga05807be33b5e68937bb6458333d4c339</anchor>
<arglist>(uintmax_t p00_i)</arglist>
</member>
<member kind="function">
<type>bool</type>
<name>p99_is_sorted</name>
<anchorfile>group__sorting_ga9ecb9298d2c8cb8cba981000710d7b8d.html</anchorfile>
<anchor>ga9ecb9298d2c8cb8cba981000710d7b8d</anchor>
<arglist>(void *p00_base, rsize_t p00_n, rsize_t p00_s, int(*p00_comp)(const void *, const void *, void *), void *p00_ctx)</arglist>
</member>
<member kind="function">
<type>rsize_t</type>
<name>p99_mismatch</name>
<anchorfile>group__sorting_ga1ca07f2aaf851bd6e99f2bdec6fdefec.html</anchorfile>
<anchor>ga1ca07f2aaf851bd6e99f2bdec6fdefec</anchor>
<arglist>(void *p00_base, rsize_t p00_n, rsize_t p00_s, int(*p00_comp)(const void *, const void *, void *), void *p00_ctx)</arglist>
</member>
</compound>
<compound kind="group">
<name>random</name>
<title>Pseudo Random Generator</title>
......@@ -19572,9 +19653,9 @@
</member>
<member kind="function">
<type>unsigned</type>
<name>p99_futex_fetch_and_store</name>
<anchorfile>group__futex_gae9992e6155e6444297674daf34127bb4.html</anchorfile>
<anchor>gae9992e6155e6444297674daf34127bb4</anchor>
<name>p99_futex_exchange</name>
<anchorfile>group__futex_ga5f3a21217d8b30a26562eaf0a9fa742a.html</anchorfile>
<anchor>ga5f3a21217d8b30a26562eaf0a9fa742a</anchor>
<arglist>(p99_futex volatile *p00_fut, unsigned p00_desired, unsigned p00_cstart, unsigned p00_clen, unsigned p00_wmin, unsigned p00_wmax)</arglist>
</member>
<member kind="function">
......@@ -19874,6 +19955,7 @@
<file>p99_notifier.h</file>
<file>p99_paste.h</file>
<file>p99_posix_default.h</file>
<file>p99_qsort.h</file>
<file>p99_rand.h</file>
<file>p99_special.c</file>
<file>p99_str.h</file>
......
......@@ -42,16 +42,16 @@ do { \
} \
} while (false)
#define P00_QSWAP_VCPY_(A, B) \
for (size_t p00Mi = 0; p00Mi < p00_vsize; ++p00Mi) \
#define P00_QSWAP_VCPY_(A, B) \
for (size_t p00Mi = 0; p00Mi < p00_vsize; ++p00Mi) \
(A)[p00Mi] = (B)[p00Mi]
#define P00_QSWAP_VCPY(P, A, B) \
do { \
P00_QSWAP_VCPY_(p00_tmp, (P)[A]); \
P00_QSWAP_VCPY_((P)[A], (P)[B]); \
P00_QSWAP_VCPY_((P)[B], p00_tmp); \
#define P00_QSWAP_VCPY(P, A, B) \
do { \
P00_QSWAP_VCPY_(p00_tmp, (P)[A]); \
P00_QSWAP_VCPY_((P)[A], (P)[B]); \
P00_QSWAP_VCPY_((P)[B], p00_tmp); \
} while (false)
#define P00_QSWAP_ASSIGN(P, A, B) \
......@@ -85,6 +85,9 @@ do { \
} \
}
/**
** @brief compute the integer logarithm base @c 2 of @a p00_i
**/
p99_inline
signed p99_ilog2(uintmax_t p00_i) {
if (!p00_i) return -1;
......@@ -189,11 +192,11 @@ do { \
p99_inline
errno_t p00_qsort_generic16(void *p00_base,
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
size_t const p00_vsize = p00_s / sizeof(uint16_t);
typedef uint16_t p00_el[p00_vsize];
register p00_el *const p00_B = p00_base;
......@@ -204,11 +207,11 @@ errno_t p00_qsort_generic16(void *p00_base,
p99_inline
errno_t p00_qsort_generic32(void *p00_base,
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
size_t const p00_vsize = p00_s / sizeof(uint32_t);
typedef uint32_t p00_el[p00_vsize];
register p00_el *const p00_B = p00_base;
......@@ -219,11 +222,11 @@ errno_t p00_qsort_generic32(void *p00_base,
p99_inline
errno_t p00_qsort_generic64(void *p00_base,
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
size_t const p00_vsize = p00_s / sizeof(uint64_t);
typedef uint64_t p00_el[p00_vsize];
register p00_el *const p00_B = p00_base;
......@@ -235,11 +238,11 @@ errno_t p00_qsort_generic64(void *p00_base,
#ifdef UINT128_MAX
p99_inline
errno_t p00_qsort_generic128(void *p00_base,
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
size_t const p00_vsize = p00_s / sizeof(uint128_t);
typedef uint128_t p00_el[p00_vsize];
register p00_el *const p00_B = p00_base;
......@@ -250,11 +253,11 @@ errno_t p00_qsort_generic128(void *p00_base,
# ifdef P99X_UINT128_MAX
p99_inline
errno_t p00_qsort_generic128(void *p00_base,
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
int (*p00_comp)(const void *, const void *, void *),
void *p00_ctx) {
size_t const p00_vsize = p00_s / sizeof(p99x_uint128);
typedef p99x_uint128 p00_el[p00_vsize];
register p00_el *const p00_B = p00_base;
......@@ -265,8 +268,8 @@ errno_t p00_qsort_generic128(void *p00_base,
#endif
P99_WEAK(p99_qsort_generic)
errno_t p99_qsort_generic(void *p00_base,
P99_WEAK(p00_qsort_generic)
errno_t p00_qsort_generic(void *p00_base,
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
......@@ -281,7 +284,7 @@ errno_t p99_qsort_generic(void *p00_base,
#define P00_QSORT_DECLARE(T) \
p99_inline \
errno_t P99_PASTE2(p99_qsort_, T)(void *p00_base, \
errno_t P99_PASTE2(p00_qsort_, T)(void *p00_base, \
rsize_t p00_n, \
rsize_t p00_a, \
rsize_t p00_s, \
......@@ -291,7 +294,7 @@ errno_t P99_PASTE2(p99_qsort_, T)(void *p00_base, \
_Alignas(sizeof(max_align_t)) T p00_tmp; \
P00_QSORT_BODY(P00_QSWAP_ASSIGN); \
} \
P99_MACRO_END(p99_qsort_, T)
P99_MACRO_END(p00_qsort_, T)
P00_QSORT_DECLARE(_Bool);
P00_QSORT_DECLARE(schar);
......@@ -348,7 +351,7 @@ P00_QSORT_DECLARE(p99x_int128);
#endif
p99_inline
errno_t p99_qsort_s(void *p00_base,
errno_t p00_qsort_s(void *p00_base,
rsize_t p00_n,
rsize_t p00_a,
rsize_t p00_s,
......@@ -377,73 +380,109 @@ errno_t p99_qsort_s(void *p00_base,
# endif
#endif
}
return p99_qsort_generic(p00_base, p00_n, p00_a, p00_s, p00_comp, p00_ctx);
return p00_qsort_generic(p00_base, p00_n, p00_a, p00_s, p00_comp, p00_ctx);
}
/**
** @brief A generic sorting routine.
**
** This an implementation of the @c qsort variant as it is specified
** in Annex K of the C11 standard. Its particularity is that it
** additionally takes a "context" argument, which allows to program
** comparison functions more widely, without refering to global
** variables. Its prototype if it were not implemented as
** a type generic macro, would be:
**
** @code
** errno_t qsort_s(void *base,
** rsize_t nmemb,
** rsize_t size,
** int (*compar)(const void *x, const void *y, void *context),
** void *context);
** @endcode
**
** Because this is a type generic macro, the implementation can take
** care of the "real" base type of @c base, in particular about
** alignment. If it really only would receive a @c void* it would
** have to make the worst assumptions about that and always use
** @c memcpy to copy elements around. If it has more type information it
** can use more efficient means for that. So casting the first
** argument to @c void* wouldn't be a good idea.
**/
#ifdef __STDC_NO_COMPLEX__
#define qsort_s(B, N, S, CMP, CTX) \
P99_CONSTRAINT_TRIGGER( \
P99_GENERIC(&((B)[0]), \
p99_qsort_s, \
(void_ptr*, p99_qsort_void_ptr), \
p00_qsort_s, \
(void_ptr*, p00_qsort_void_ptr), \
/* */ \
(float*, p99_qsort_float), \
(double*, p99_qsort_double), \
(double*, p99_qsort_cdouble), \
(float*, p00_qsort_float), \
(double*, p00_qsort_double), \
(double*, p00_qsort_cdouble), \
/* */ \
(_Bool*, p99_qsort__Bool), \
(char*, p99_qsort_char), \
(uchar*, p99_qsort_uchar), \
(schar*, p99_qsort_schar), \
(_Bool*, p00_qsort__Bool), \
(char*, p00_qsort_char), \
(uchar*, p00_qsort_uchar), \
(schar*, p00_qsort_schar), \
/* */ \
(ushort*, p99_qsort_ushort), \
(short*, p99_qsort_short), \
(ushort*, p00_qsort_ushort), \
(short*, p00_qsort_short), \
/* */ \
(unsigned*, p99_qsort_unsigned), \
(signed*, p99_qsort_signed), \
(unsigned*, p00_qsort_unsigned), \
(signed*, p00_qsort_signed), \
/* */ \
(long*, p99_qsort_long), \
(ulong*, p99_qsort_ulong), \
(long*, p00_qsort_long), \
(ulong*, p00_qsort_ulong), \
/* */ \
(llong*, p99_qsort_llong), \
(ullong*, p99_qsort_ullong) \
(llong*, p00_qsort_llong), \
(ullong*, p00_qsort_ullong) \
)((B), (N), alignof(*(B)), (S), (CMP), (CTX)), \
"qsort_s runtime constraint violation")
#else
#define qsort_s(B, N, S, CMP, CTX) \
P99_CONSTRAINT_TRIGGER( \
P99_GENERIC(&((B)[0]), \
p99_qsort_s, \
(void_ptr*, p99_qsort_void_ptr), \
p00_qsort_s, \
(void_ptr*, p00_qsort_void_ptr), \
/* */ \
(float*, p99_qsort_float), \
(double*, p99_qsort_double), \
(ldouble*, p99_qsort_ldouble), \
(float*, p00_qsort_float), \
(double*, p00_qsort_double), \
(ldouble*, p00_qsort_ldouble), \
/* */ \
(cfloat*, p99_qsort_cfloat), \
(cdouble*, p99_qsort_cdouble), \
(cldouble*, p99_qsort_cldouble), \
(cfloat*, p00_qsort_cfloat), \
(cdouble*, p00_qsort_cdouble), \
(cldouble*, p00_qsort_cldouble), \
/* */ \
(_Bool*, p99_qsort__Bool), \
(char*, p99_qsort_char), \
(uchar*, p99_qsort_uchar), \
(schar*, p99_qsort_schar), \
(_Bool*, p00_qsort__Bool), \
(char*, p00_qsort_char), \
(uchar*, p00_qsort_uchar), \
(schar*, p00_qsort_schar), \
/* */ \
(ushort*, p99_qsort_ushort), \
(short*, p99_qsort_short), \
(ushort*, p00_qsort_ushort), \
(short*, p00_qsort_short), \
/* */ \
(unsigned*, p99_qsort_unsigned), \
(signed*, p99_qsort_signed), \
(unsigned*, p00_qsort_unsigned), \
(signed*, p00_qsort_signed), \
/* */ \
(long*, p99_qsort_long), \
(ulong*, p99_qsort_ulong), \
(long*, p00_qsort_long), \
(ulong*, p00_qsort_ulong), \
/* */ \
(llong*, p99_qsort_llong), \
(ullong*, p99_qsort_ullong) \
(llong*, p00_qsort_llong), \
(ullong*, p00_qsort_ullong) \
)((B), (N), alignof(*(B)), (S), (CMP), (CTX)), \
"qsort_s runtime constraint violation")
#endif
/**
** @brief Check if the array passed in as @a p00_base is sorted and
** return the first mismatch if it is not.
**
** A mismatch here is defined as the first position at which we
** detect that the array is not sorted. If the array is in fact
** sorted the return value is @a p00_n.
**/
p99_inline
rsize_t p99_mismatch(void *p00_base,
rsize_t p00_n,
......@@ -459,6 +498,9 @@ rsize_t p99_mismatch(void *p00_base,
return p00_n;
}
/**
** @brief Check if the array passed in as @a p00_base is sorted
**/
p99_inline
bool p99_is_sorted(void *p00_base,
rsize_t p00_n,
......
......@@ -107,7 +107,7 @@
** @see P99_ANAME(NAME, DIM, VAR) for argument <code>NAME</code>, <code>VAR</code>.
** @see P99_ARE_EQ(FIRST, ...) for argument <code>FIRST</code>.
** @see P99_ARE_ORDERED(OP, ...) for arguments <code>OP</code>, <code>__VA_ARG__[0]</code>, <code>__VA_ARG__[1]</code>.
** @see P99_ASORT(TAB, COMP) for argument <code>TAB</code>.
** @see P99_ASORT(TAB, ...) for argument <code>TAB</code>.
** @see P99_ASUB(X, T, N, L) for argument <code>T</code>.
** @see P99_ATOMIC_INHERIT(T) for argument <code>T</code>.
** @see P99_AVALUE(X, ...) for arguments <code>X</code>, <code>__VA_ARG__[0]</code>, <code>__VA_ARG__[1]</code>, <code>__VA_ARG__[2]</code>.
......@@ -206,7 +206,7 @@
** @see P99_PRINTF(FORMAT, ...) for arguments <code>__VA_ARG__[0]</code>, <code>__VA_ARG__[1]</code>, <code>__VA_ARG__[2]</code>.
** @see P99_PROTOTYPE(...) for argument <code>__VA_ARG__[0]</code>, <code>__VA_ARG__[2]</code>.
** @see P99_PZERO(X, N) for argument <code>X</code>.
** @see P99_QSORT(TAB, NB, COMP) for argument <code>TAB</code>.
** @see P99_QSORT(TAB, NB, ...) for argument <code>TAB</code>.
** @see P99_QVALUE(X) for argument <code>X</code>.
** @see P99_REP(...) for arguments <code>__VA_ARG__[0]</code>, <code>__VA_ARG__[1]</code>, <code>__VA_ARG__[2]</code>.
** @see P99_REPEAT(MACRO, N) for argument <code>MACRO</code>, <code>N</code>.
......
......@@ -3,6 +3,7 @@
/* Except for parts copied from previous work and as explicitly stated below, */
/* the authors and copyright holders for this work are as follows: */
/* (C) copyright 2012 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 Simon Peeters */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......@@ -368,16 +369,16 @@ p00_throw_call_neg(F(__VA_ARGS__), E, p00_unwind_top, P99_STRINGIFY(__LINE__), _
p99_inline
int p00_throw_call_negate(int p00_neg,
errno_t p00_def,
p00_jmp_buf0 * p00_top,
char const* p00_file,
char const* p00_context,
char const* p00_info) {
errno_t p00_def,
p00_jmp_buf0 * p00_top,
char const* p00_file,
char const* p00_context,
char const* p00_info) {
if (P99_UNLIKELY(p00_neg < 0)) p00_jmp_throw(-p00_neg, p00_top, p00_file, p00_context, p00_info);
return p00_neg;
}
#define P00_THROW_CALL_NEGATE(F, E, ...) \
#define P00_THROW_CALL_NEGATE(F, E, ...) \
p00_throw_call_negate(F(__VA_ARGS__), E, p00_unwind_top, P99_STRINGIFY(__LINE__), __func__, #F ", neg return")
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment