Yzena
/
Yc
2
1
Fork 0
Browse Source

Make clang-format actually work

It's not ideal; there are cases where I have to use extra parens to
have the style I want (like with unary negative operators), and there
are a few things that are not exactly the style I want.

However, those little things are not nearly as important as having an
automatic formatter on the repo.

The style of Yc is now defined by whatever the latest version of
clang-format outputs. Obviously, the .clang-format file can be updated,
but other than that, and a few places where clang-format is explicitly
turned off, clang-format is the style.

Signed-off-by: Gavin Howard <gavin@yzena.com>
afl_persistent_mode
Gavin Howard 4 months ago
parent
commit
8a4e6faea7
Signed by: gavin
GPG Key ID: C08038BDF280D33E
  1. 2
      .clang-format
  2. 4
      benchmarks/arith.c
  3. 8
      benchmarks/listdir.c
  4. 17
      benchmarks/memcpy.c
  5. 17
      benchmarks/xxh3_v_spooky.c
  6. 112
      include/yc/arith.h
  7. 38
      include/yc/array.h
  8. 17
      include/yc/assert.h
  9. 53
      include/yc/gaml.h
  10. 1
      include/yc/imap.h
  11. 42
      include/yc/io.h
  12. 2
      include/yc/list.h
  13. 4
      include/yc/map.h
  14. 8
      include/yc/mappool.h
  15. 4
      include/yc/proc.h
  16. 5
      include/yc/setpool.h
  17. 34
      include/yc/simd.h
  18. 12
      include/yc/smap.h
  19. 8
      include/yc/str.h
  20. 2
      include/yc/string.h
  21. 4
      include/yc/strucon.h
  22. 2
      include/yc/svector.h
  23. 3
      include/yc/sys.h
  24. 2
      include/yc/time.h
  25. 241
      include/yc/types.h
  26. 2
      include/yc/vector.h
  27. 2
      include/yc/yao.h
  28. 22
      include/yc/yc.h
  29. 4
      samples/io/file_open.c
  30. 2
      samples/io/interactive.c
  31. 2
      samples/io/iterate.c
  32. 2
      samples/io/list_to_file.c
  33. 2
      samples/io/random_access.c
  34. 4
      src/alloc/alloc.h
  35. 4
      src/alloc/os/posix/alloc.c
  36. 2
      src/alloc/os/windows/alloc.c
  37. 6
      src/alloc/stack.c
  38. 36
      src/arith.c
  39. 2
      src/arith.h
  40. 2
      src/assert.c
  41. 8
      src/atomics/atomics.c
  42. 2
      src/atomics/os/posix/atomics.c
  43. 17
      src/atomics/os/windows/atomics.c
  44. 26
      src/gaml/gaml.c
  45. 6
      src/gaml/gaml.h
  46. 18
      src/gaml/lex.c
  47. 6
      src/gaml/parse.c
  48. 41
      src/hash/hash.c
  49. 18
      src/io/dir.c
  50. 6
      src/io/dirent.c
  51. 29
      src/io/file.c
  52. 3
      src/io/fs.c
  53. 8
      src/io/io.c
  54. 12
      src/io/os/posix/bareio.c
  55. 9
      src/io/os/posix/file.c
  56. 9
      src/io/os/posix/fs.c
  57. 18
      src/io/os/posix/io.c
  58. 8
      src/io/os/posix/posix.h
  59. 5
      src/io/os/windows/bareio.c
  60. 8
      src/io/os/windows/dir.c
  61. 2
      src/io/os/windows/file.c
  62. 19
      src/io/os/windows/fs.c
  63. 13
      src/io/os/windows/io.c
  64. 8
      src/io/os/windows/windows.h
  65. 19
      src/io/path.c
  66. 53
      src/list/list.c
  67. 8
      src/list/list.h
  68. 28
      src/map/imap.c
  69. 2
      src/map/imap.h
  70. 41
      src/map/map.c
  71. 4
      src/map/map.h
  72. 97
      src/map/smap.c
  73. 5
      src/map/smap.h
  74. 11
      src/mappool/mappool.c
  75. 2
      src/mappool/mappool.h
  76. 8
      src/multiplex/multiplex.c
  77. 2
      src/multiplex/multiplex.h
  78. 21
      src/multiplex/os/posix/multiplex.c
  79. 7
      src/multiplex/os/windows/multiplex.c
  80. 35
      src/opt/opt.c
  81. 14
      src/proc/os/posix/proc.c
  82. 4
      src/proc/os/windows/proc.c
  83. 19
      src/proc/proc.c
  84. 14
      src/proc/proc.h
  85. 12
      src/rig/main.c
  86. 7
      src/rig/rig.c
  87. 16
      src/rig/rig.h
  88. 19
      src/setpool/setpool.c
  89. 74
      src/stdio.c
  90. 4
      src/str/os/windows/str.c
  91. 9
      src/str/str.c
  92. 11
      src/string/string.c
  93. 5
      src/strucon/mutex.c
  94. 6
      src/strucon/os/posix/rwlock.c
  95. 23
      src/strucon/os/posix/semaphore.c
  96. 12
      src/strucon/os/posix/semaphore_darwin.c
  97. 3
      src/strucon/os/posix/strucon.c
  98. 2
      src/strucon/os/windows/rwlock.c
  99. 6
      src/strucon/os/windows/semaphore.c
  100. 3
      src/strucon/os/windows/strucon.c
  101. Some files were not shown because too many files have changed in this diff Show More

2
.clang-format

@ -126,6 +126,8 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
#RawStringFormats:
# This is used to get spaces around a bitwise and operator.
ReferenceAlignment: Middle
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true

4
benchmarks/arith.c

@ -31,10 +31,10 @@
* ******** END FILE DESCRIPTION ********
*/
#include <yc/yc.h>
#include <yc/arith.h>
#include <yc/timer.h>
#include <yc/io.h>
#include <yc/timer.h>
#include <yc/yc.h>
#include <stdint.h>

8
benchmarks/listdir.c

@ -32,10 +32,10 @@
* ******** END FILE DESCRIPTION ********
*/
#include <dirent.h>
#include <yc/io.h>
#include <dirent.h>
int
main(int argc, char* argv[])
{
@ -53,8 +53,8 @@ main(int argc, char* argv[])
size_t nentries = st.size / sizeof(struct dirent);
yprintf("nentries: %zu, size: %llu, sizeof dirent: %zu\n",
nentries, st.size, sizeof(struct dirent));
yprintf("nentries: %zu, size: %llu, sizeof dirent: %zu\n", nentries,
st.size, sizeof(struct dirent));
return 0;
}

17
benchmarks/memcpy.c

@ -31,20 +31,20 @@
* ******** END FILE DESCRIPTION ********
*/
#include <yc/yc.h>
#include <yc/io.h>
#include <yc/assert.h>
#include <yc/io.h>
#include <yc/timer.h>
#include <yc/yc.h>
#include <string.h>
#include <limits.h>
#include <string.h>
#define BUF_SIZE (((unsigned long) 1) << 16)
#define BUF_SIZE (((unsigned long) 1) << 16)
#define BUF_SIZEX (BUF_SIZE + 128)
#define I(i) ((i) & ((1 << CHAR_BIT) - 1))
#define I(i) ((i) & ((1 << CHAR_BIT) - 1))
#define NITERATIONS ((size_t) 10000)
#define MAX (32)
#define NITERATIONS ((size_t) 10000)
#define MAX (32)
#define TNITERATIONS (NITERATIONS * MAX * MAX)
typedef void* (*MemcpyF)(void*, const void*, size_t);
@ -53,7 +53,8 @@ typedef void* (*MemcpyF)(void*, const void*, size_t);
unsigned char a1[BUF_SIZEX];
unsigned char a2[BUF_SIZEX];
void bench(void)
void
bench(void)
{
size_t size;

17
benchmarks/xxh3_v_spooky.c

@ -33,15 +33,15 @@
#define XXH_STATIC_LINKING_ONLY
#define XXH_IMPLEMENTATION
#include <xxhash.h>
#include <yc/arith.h>
#include <yc/array.h>
#include <yc/timer.h>
#include <yc/io.h>
#include <yc/map.h>
#include <yc/str.h>
#include <yc/timer.h>
#include <yc/vector.h>
#include <yc/map.h>
#include <yc/io.h>
#include <xxhash.h>
#define MAX_CHARS (1025)
@ -56,7 +56,8 @@ xxh3_hasher(const void* str)
return XXH3_64bits(s->a, s->len);
}
void print_runs(const char* title, const YTimer arr[RUNS])
void
print_runs(const char* title, const YTimer arr[RUNS])
{
size_t l;
@ -116,8 +117,8 @@ main(int argc, char* argv[])
if (yerror(s != YSTATUS_SUCCESS)) return (int) s;
errors += yvec_pushString(words, (char*) line) ? 1 : 0;
} while (nread > 0);
}
while (nread > 0);
yfs_file_close(f);

112
include/yc/arith.h

@ -50,17 +50,17 @@ extern "C" {
*/
//! @cond Doxygen suppress.
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
//! @endcond
#include <yc/yc.h>
#include <yc/assert.h>
#include <yc/yc.h>
//! @cond Doxygen suppress.
@ -108,9 +108,9 @@ extern "C" {
#ifdef YC_INT128_STRUCT
#define YC_BOTTOM32 (((uint_fast64_t) 0xffffffffULL))
#define YC_TRUNC32(n) ((n) & YC_BOTTOM32)
#define YC_CHOP32(n) ((n) >> 32)
#define YC_BOTTOM32 (((uint_fast64_t) 0xffffffffULL))
#define YC_TRUNC32(n) ((n) &YC_BOTTOM32)
#define YC_CHOP32(n) ((n) >> 32)
/**
* @typedef uint128_t
@ -130,64 +130,49 @@ extern ys128 ys128_max;
extern ys128 ys128_min;
extern yu128 yu128_max;
yinline static inline
uint128_t
yinline static inline uint128_t
yc_a128(const uint64_t a, const uint64_t b);
yinline static inline
uint128_t
yinline static inline uint128_t
yc_s128(const uint64_t a, const uint64_t b);
yinline static inline
uint128_t
yinline static inline uint128_t
yc_m128(const uint64_t a, const uint64_t b);
yinline static inline
uint128_t
yinline static inline uint128_t
yc_n128(const uint128_t a);
yinline static inline
uint128_t
yinline static inline uint128_t
yc_sn128(const uint128_t a);
yinline static inline
bool
yinline static inline bool
yc_eq128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_ne128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_ult128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_ule128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_ugt128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_uge128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_slt128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_sle128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_sgt128(const uint128_t a, const uint128_t b);
yinline static inline
bool
yinline static inline bool
yc_sge128(const uint128_t a, const uint128_t b);
#else // YC_INT128_STRUCT
@ -209,6 +194,8 @@ typedef __uint128_t uint128_t;
*/
typedef long long llong;
// clang-format off
//! @cond Doxygen suppress.
#define YC_MAX_8 (255ULL)
#define YC_MAX_16 (65535ULL)
@ -1459,8 +1446,7 @@ yc_2y(intptr_t, ysptr)
#ifdef YC_INT128_STRUCT
yinline static inline
uint128_t
yinline static inline uint128_t
yc_a128(const uint64_t a, const uint64_t b)
{
uint128_t r;
@ -1471,8 +1457,7 @@ yc_a128(const uint64_t a, const uint64_t b)
return r;
}
yinline static inline
uint128_t
yinline static inline uint128_t
yc_s128(const uint64_t a, const uint64_t b)
{
const uint64_t c = (~(b)) + 1;
@ -1480,8 +1465,7 @@ yc_s128(const uint64_t a, const uint64_t b)
return yc_a128(a, c);
}
yinline static inline
uint128_t
yinline static inline uint128_t
yc_m128(const uint64_t a, const uint64_t b)
{
uint128_t r;
@ -1504,8 +1488,7 @@ yc_m128(const uint64_t a, const uint64_t b)
return r;
}
yinline static inline
uint128_t
yinline static inline uint128_t
yc_n128(const uint128_t a)
{
const uint128_t r = { .l = ~(a.l), .h = ~(a.h) };
@ -1513,8 +1496,7 @@ yc_n128(const uint128_t a)
return r;
}
yinline static inline
uint128_t
yinline static inline uint128_t
yc_sn128(const uint128_t a)
{
uint128_t r;
@ -1527,50 +1509,43 @@ yc_sn128(const uint128_t a)
return r;
}
yinline static inline
bool
yinline static inline bool
yc_eq128(const uint128_t a, const uint128_t b)
{
return (a.l == b.l && a.h == b.h);
}
yinline static inline
bool
yinline static inline bool
yc_ne128(const uint128_t a, const uint128_t b)
{
return (a.l != b.l || a.h != b.h);
}
yinline static inline
bool
yinline static inline bool
yc_ult128(const uint128_t a, const uint128_t b)
{
return (a.h < b.h || (a.h == b.h && a.l < b.l));
}
yinline static inline
bool
yinline static inline bool
yc_ule128(const uint128_t a, const uint128_t b)
{
return (a.h < b.h || (a.h == b.h && a.l <= b.l));
}
yinline static inline
bool
yinline static inline bool
yc_ugt128(const uint128_t a, const uint128_t b)
{
return (a.h > b.h || (a.h == b.h && a.l > b.l));
}
yinline static inline
bool
yinline static inline bool
yc_uge128(const uint128_t a, const uint128_t b)
{
return (a.h > b.h || (a.h == b.h && a.l >= b.l));
}
yinline static inline
bool
yinline static inline bool
yc_slt128(const uint128_t a, const uint128_t b)
{
if (a.h >= ys64_min)
@ -1583,8 +1558,7 @@ yc_slt128(const uint128_t a, const uint128_t b)
}
}
yinline static inline
bool
yinline static inline bool
yc_sle128(const uint128_t a, const uint128_t b)
{
if (a.h >= ys64_min)
@ -1597,8 +1571,7 @@ yc_sle128(const uint128_t a, const uint128_t b)
}
}
yinline static inline
bool
yinline static inline bool
yc_sgt128(const uint128_t a, const uint128_t b)
{
if (a.h >= ys64_min)
@ -1611,8 +1584,7 @@ yc_sgt128(const uint128_t a, const uint128_t b)
}
}
yinline static inline
bool
yinline static inline bool
yc_sge128(const uint128_t a, const uint128_t b)
{
if (a.h >= ys64_min)
@ -1627,6 +1599,8 @@ yc_sge128(const uint128_t a, const uint128_t b)
#endif // YC_INT128_STRUCT
// clang-format on
/**
* @}
*/

38
include/yc/array.h

@ -39,8 +39,8 @@
extern "C" {
#endif
#include <yc/assert.h>
#include <yc/arith.h>
#include <yc/assert.h>
//! @cond Doxygen suppress.
#include <stddef.h>
@ -94,9 +94,10 @@ extern "C" {
*/
#ifdef YDEBUG
#define YARRAY_INIT(arr, p, l) \
do { \
do \
{ \
void* _yarray_temp_p_ = (p); \
yusize _yarray_temp_l_ = (yusize)(l); \
yusize _yarray_temp_l_ = (yusize) (l); \
yassert(_yarray_temp_p_ != NULL, "pointer is NULL"); \
yassert(yssizesn((yssize) _yarray_temp_l_), \
"length is less than or equal to 0"); \
@ -106,11 +107,12 @@ extern "C" {
} \
while (0)
#else // YDEBUG
#define YARRAY_INIT(arr, p, l) \
do { \
arr.len = (size_t)(l); \
arr.a = (p); \
} \
#define YARRAY_INIT(arr, p, l) \
do \
{ \
arr.len = (size_t) (l); \
arr.a = (p); \
} \
while (0)
#endif // YDEBUG
@ -129,9 +131,10 @@ extern "C" {
*/
#ifdef YDEBUG
#define YARRAY_INITP(arr, p, l) \
do { \
do \
{ \
void* _yarray_temp_p_ = (p); \
size_t _yarray_temp_l_ = (size_t)(l); \
size_t _yarray_temp_l_ = (size_t) (l); \
yassert(_yarray_temp_p_ != NULL, "pointer is NULL"); \
yassert(yssizesn((yssize) _yarray_temp_l_), \
"length is less than or equal to 0"); \
@ -141,14 +144,17 @@ extern "C" {
} \
while (0)
#else // YDEBUG
#define YARRAY_INITP(arr, p, l) \
do { \
arr->len = (yusize)(l); \
arr->a = (p); \
} \
#define YARRAY_INITP(arr, p, l) \
do \
{ \
arr->len = (yusize) (l); \
arr->a = (p); \
} \
while (0)
#endif // YDEBUG
// clang-format off
/**
* @def yi
* A define that will index an array type made by @a YARRAY_TYPE and do bounds
@ -206,6 +212,8 @@ extern "C" {
"length of the array (%zu)", i, (p)->len), \
(p)->a[0]))
// clang-format on
//! @cond Doxygen suppress.
/**
* An array of plain bytes.

17
include/yc/assert.h

@ -73,7 +73,6 @@ extern "C" {
#define ypanicv(msg, ...) \
(ypanic_impl(__FILE__, __LINE__, __func__, (char*) (msg).a), __VA_ARGS__)
/**
* @def ypanica(msg)
* A macro that will abort with a message, assumed to by a ystr.
@ -111,7 +110,7 @@ ypanic_impl(const char* const file, int line, const char* const func,
*/
yinline ynoreturn void
yassert_fail(const char* const expr, const char* const file, int line,
const char* const func, const char* const msg, ...);
const char* const func, const char* const msg, ...);
/**
* @def yassert(Expr, Msg)
@ -144,13 +143,17 @@ yassert_fail(const char* const expr, const char* const file, int line,
((void) ((Expr) || \
(yassert_fail(#Expr, __FILE__, __LINE__, __func__, (Msg)), 0)))
#define yassertv(Expr, Msg, ...) \
((void) ((Expr) || \
(yassert_fail(#Expr, __FILE__, __LINE__, __func__, \
(Msg), __VA_ARGS__), 0)))
// clang-format off
#define yassertv(Expr, Msg, ...) \
((void) ((Expr) || (yassert_fail(#Expr, __FILE__, __LINE__, __func__, \
(Msg), __VA_ARGS__), 0)))
// clang-format on
#else
#define yassert(Expr, Msg) ((void) 0)
#define yassert(Expr, Msg) ((void) 0)
#define yassertv(Expr, Msg, ...) ((void) 0)
#endif

53
include/yc/gaml.h

@ -46,9 +46,9 @@ extern "C" {
#include <stdlib.h>
//! @endcond
#include <yc/yc.h>
#include <yc/str.h>
#include <yc/io.h>
#include <yc/str.h>
#include <yc/yc.h>
/**
* @file yc/gaml.h
@ -332,8 +332,8 @@ ygaml_addItem_nil(YGaml g, const char* key, YGaml* res) yparamsnonnull(1, 2);
* @pre @a key must not exist in @a g.
*/
YStatus
ygaml_addItem_bool(YGaml g, const char* key, bool val,
YGaml* res) yparamsnonnull(1, 2);
ygaml_addItem_bool(YGaml g, const char* key, bool val, YGaml* res)
yparamsnonnull(1, 2);
/**
* Adds an integer item to the GAML item at the specified key. This panics if
@ -351,8 +351,8 @@ ygaml_addItem_bool(YGaml g, const char* key, bool val,
* @pre @a key must not exist in @a g.
*/
YStatus
ygaml_addItem_int(YGaml g, const char* key, yullong val, bool neg,
YGaml* res) yparamsnonnull(1, 2);
ygaml_addItem_int(YGaml g, const char* key, yullong val, bool neg, YGaml* res)
yparamsnonnull(1, 2);
/**
* Adds a float item to the GAML item at the specified key. This panics if the
@ -369,8 +369,8 @@ ygaml_addItem_int(YGaml g, const char* key, yullong val, bool neg,
* @pre @a key must not exist in @a g.
*/
YStatus
ygaml_addItem_float(YGaml g, const char* key, double val,
YGaml* res) yparamsnonnull(1, 2);
ygaml_addItem_float(YGaml g, const char* key, double val, YGaml* res)
yparamsnonnull(1, 2);
/**
* Adds a string item to the GAML item at the specified key. This panics if the
@ -388,8 +388,8 @@ ygaml_addItem_float(YGaml g, const char* key, double val,
* @pre @a key must not exist in @a g.
*/
YStatus
ygaml_addItem_str(YGaml g, const char* key, ystr val,
YGaml* res) yparamsnonnull(1, 2);
ygaml_addItem_str(YGaml g, const char* key, ystr val, YGaml* res)
yparamsnonnull(1, 2);
/**
* Adds a string item, as a C string, to the GAML item at the specified key.
@ -408,8 +408,8 @@ ygaml_addItem_str(YGaml g, const char* key, ystr val,
* @pre @a key must not exist in @a g.
*/
YStatus
ygaml_addItem_cstr(YGaml g, const char* key, const yuchar* val,
YGaml* res) yparamsnonnull(1, 2);
ygaml_addItem_cstr(YGaml g, const char* key, const yuchar* val, YGaml* res)
yparamsnonnull(1, 2);
/**
* Adds a symbol item to the GAML item at the specified key. This panics if the
@ -428,8 +428,8 @@ ygaml_addItem_cstr(YGaml g, const char* key, const yuchar* val,
* @pre @a val must begin with #.
*/
YStatus
ygaml_addItem_symbol(YGaml g, const char* key, ystr val,
YGaml* res) yparamsnonnull(1, 2);
ygaml_addItem_symbol(YGaml g, const char* key, ystr val, YGaml* res)
yparamsnonnull(1, 2);
/**
* Adds a symbol item, as a C string, to the GAML item at the specified key.
@ -449,8 +449,8 @@ ygaml_addItem_symbol(YGaml g, const char* key, ystr val,
* @pre @a val must begin with #.
*/
YStatus
ygaml_addItem_csymbol(YGaml g, const char* key, const yuchar* val,
YGaml* res) yparamsnonnull(1, 2);
ygaml_addItem_csymbol(YGaml g, const char* key, const yuchar* val, YGaml* res)
yparamsnonnull(1, 2);
/**
* Adds an object item to the GAML item at the specified index, pushing all
@ -528,8 +528,8 @@ ygaml_addElem_bool(YGaml g, size_t idx, bool val, YGaml* res) yparamsnonnull(1);
* @pre @a idx must be within range. It can be equal to the length.
*/
YStatus
ygaml_addElem_int(YGaml g, size_t idx, yullong val, bool neg,
YGaml* res) yparamsnonnull(1);
ygaml_addElem_int(YGaml g, size_t idx, yullong val, bool neg, YGaml* res)
yparamsnonnull(1);
/**
* Adds a float item to the GAML item at the specified index, pushing all
@ -545,8 +545,8 @@ ygaml_addElem_int(YGaml g, size_t idx, yullong val, bool neg,
* @pre @a idx must be within range. It can be equal to the length.
*/
YStatus
ygaml_addElem_float(YGaml g, size_t idx, double val,
YGaml* res) yparamsnonnull(1);
ygaml_addElem_float(YGaml g, size_t idx, double val, YGaml* res)
yparamsnonnull(1);
/**
* Adds a string item to the GAML item at the specified index, pushing all
@ -581,8 +581,8 @@ ygaml_addElem_str(YGaml g, size_t idx, ystr val, YGaml* res) yparamsnonnull(1);
* @pre @a idx must be within range. It can be equal to the length.
*/
YStatus
ygaml_addElem_cstr(YGaml g, size_t idx, const yuchar* val,
YGaml* res) yparamsnonnull(1);
ygaml_addElem_cstr(YGaml g, size_t idx, const yuchar* val, YGaml* res)
yparamsnonnull(1);
/**
* Adds a symbol item to the GAML item at the specified index, pushing all
@ -600,8 +600,8 @@ ygaml_addElem_cstr(YGaml g, size_t idx, const yuchar* val,
* @pre @a val must begin with #.
*/
YStatus
ygaml_addElem_symbol(YGaml g, size_t idx, ystr val,
YGaml* res) yparamsnonnull(1);
ygaml_addElem_symbol(YGaml g, size_t idx, ystr val, YGaml* res)
yparamsnonnull(1);
/**
* Adds a symbol item, as a C string, to the GAML item at the specified index,
@ -620,9 +620,8 @@ ygaml_addElem_symbol(YGaml g, size_t idx, ystr val,
* @pre @a val must begin with #.
*/
YStatus
ygaml_addElem_csymbol(YGaml g, size_t idx, const yuchar* val,
YGaml* res) yparamsnonnull(1);
ygaml_addElem_csymbol(YGaml g, size_t idx, const yuchar* val, YGaml* res)
yparamsnonnull(1);
/**
* Changes the value of the integer item. This panics if the item is not an

1
include/yc/imap.h

@ -46,6 +46,7 @@ extern "C" {
#include <stdlib.h>
//! @endcond
#include <yc/map.h>
#include <yc/yc.h>
/**

42
include/yc/io.h

@ -39,17 +39,17 @@
extern "C" {
#endif
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <yc/yc.h>
#include <yc/alloc.h>
#include <yc/arith.h>
#include <yc/array.h>
#include <yc/alloc.h>
#include <yc/str.h>
#include <yc/string.h>
#include <yc/yc.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
@ -236,26 +236,26 @@ typedef struct ydir* YDir;
* @def YSTAT_LINK
* A bit marking a link.
*/
#define YSTAT_LINK (1U<<3)
#define YSTAT_LINK (1U << 3)
/**
* @def YSTAT_READ
* A bit marking read permission.
*/
#define YSTAT_READ (1U<<2)
#define YSTAT_READ (1U << 2)
/**
* @def YSTAT_WRITE
* A bit marking write permission.
*/
#define YSTAT_WRITE (1U<<1)
#define YSTAT_WRITE (1U << 1)
/**
* @def YSTAT_EXEC
* A bit marking execute permission. For directories, this means whether it can
* be searched or not.
*/
#define YSTAT_EXEC (1U<<0)
#define YSTAT_EXEC (1U << 0)
/**
* An enum of possible file types.
@ -920,44 +920,44 @@ yfs_dir_close(YDir dir) yallnonnull;
* @def YFILE_CREATE_FLAG
* A flag for if the file was opened in create mode.
*/
#define YFILE_CREATE_FLAG (1UL<<0)
#define YFILE_CREATE_FLAG (1UL << 0)
/**
* @def YFILE_BINARY_FLAG
* A flag for if the file was opened in binary mode.
*/
#define YFILE_BINARY_FLAG (1UL<<1)
#define YFILE_BINARY_FLAG (1UL << 1)
/**
* @def YFILE_READ_FLAG
* A flag for if the file was opened in read mode.
*/
#define YFILE_READ_FLAG (1UL<<2)
#define YFILE_READ_FLAG (1UL << 2)
/**
* @def YFILE_WRITE_FLAG
* A flag for if the file was opened in write mode.
*/
#define YFILE_WRITE_FLAG (1UL<<3)
#define YFILE_WRITE_FLAG (1UL << 3)
/**
* @def YFILE_APPEND_FLAG
* A flag for if the file was opened in append mode.
*/
#define YFILE_APPEND_FLAG (1UL<<4)
#define YFILE_APPEND_FLAG (1UL << 4)
/**
* @def YFILE_TRUNC_FLAG
* A flag for if the file was opened in truncate mode.
*/
#define YFILE_TRUNC_FLAG (1UL<<5)
#define YFILE_TRUNC_FLAG (1UL << 5)
/**
* @def YFILE_EXCLUSIVE_FLAG
* A flag for if the file was opened in truncate mode. This cannot be used
* without @a YFILE_CREATE_FLAG.
*/
#define YFILE_EXCLUSIVE_FLAG (1UL<<6)
#define YFILE_EXCLUSIVE_FLAG (1UL << 6)
/**
* @typedef yoffset
@ -1296,8 +1296,8 @@ yread(yuchar* buf, size_t n, size_t* nread) yparamsnonnull(1) yinline;
* @pre @a buf must have at least @a n bytes of space.
*/
YStatus
yfread(YFile f, yuchar* buf, size_t n,
size_t* nread) yinline yparamsnonnull(1, 2);
yfread(YFile f, yuchar* buf, size_t n, size_t* nread) yinline
yparamsnonnull(1, 2);
/**
* Writes at most @a n characters from @a buf to stdout. The number of
@ -1326,8 +1326,8 @@ ywrite(const char* buf, size_t n, size_t* nwritten) yparamsnonnull(1) yinline;
* @pre @a buf must have at least @a n bytes of space.
*/
YStatus
yfwrite(YFile f, const char* buf, size_t n,
size_t* nwritten) yparamsnonnull(1, 2);
yfwrite(YFile f, const char* buf, size_t n, size_t* nwritten)
yparamsnonnull(1, 2);
/**
* Flushes stdout.

2
include/yc/list.h

@ -40,9 +40,9 @@ extern "C" {
#endif
//! @cond Doxygen suppress.
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
//! @endcond
#include <yc/yc.h>

4
include/yc/map.h

@ -46,9 +46,9 @@ extern "C" {
#include <stdlib.h>
//! @endcond
#include <yc/yc.h>
#include <yc/types.h>
#include <yc/str.h>
#include <yc/types.h>
#include <yc/yc.h>
/**
* @file yc/map.h

8
include/yc/mappool.h

@ -219,8 +219,8 @@ ymappool_getStringKey(const YMapPool p,
* @a ymappool_createStringKey().
*/
void*
ymappool_malloc(YMapPool p, const void* key, size_t size,
YDtor dtor) yinline yparamsnonnull(1, 2);
ymappool_malloc(YMapPool p, const void* key, size_t size, YDtor dtor) yinline
yparamsnonnull(1, 2);
/**
* Allocates space in the pool for the key and returns a pointer to the space,
@ -267,8 +267,8 @@ ymappool_mallocStringKey(YMapPool p, const char* key, size_t size,
* @a ymappool_createStringKey().
*/
void*
ymappool_calloc(YMapPool p, const void* key, size_t size,
YDtor dtor) yinline yparamsnonnull(1, 2);
ymappool_calloc(YMapPool p, const void* key, size_t size, YDtor dtor) yinline
yparamsnonnull(1, 2);
/**
* Allocates space in @a p for @a key and returns a pointer to the space, or

4
include/yc/proc.h

@ -40,8 +40,8 @@ extern "C" {
#endif
#include <yc/array.h>
#include <yc/str.h>
#include <yc/io.h>
#include <yc/str.h>
#include <yc/svector.h>
#include <stdarg.h>
@ -259,7 +259,7 @@ yproc_exec(YProcPipelineResult* result, yproccmd* cmd, YPath wd,
* @pre @a cmd must not be NULL.
*/
YStatus
yproc_exec_env(YProcPipelineResult* result, yproccmd *cmd, YPath wd, ystrv env,
yproc_exec_env(YProcPipelineResult* result, yproccmd* cmd, YPath wd, ystrv env,
bool capture) yallnonnull;
/**

5
include/yc/setpool.h

@ -46,8 +46,8 @@ extern "C" {
#include <stdlib.h>
//! @endcond
#include <yc/yc.h>
#include <yc/alloc.h>
#include <yc/yc.h>
/**
* @file yc/alloc.h
@ -79,7 +79,8 @@ typedef struct ysetpool* YSetPool;
* @pre @a dtor must be a valid destructor index.
*/
void*
ysetpool_alloc(YSetPool p, const void* data, size_t size, YDtor dtor) yallnonnull;
ysetpool_alloc(YSetPool p, const void* data, size_t size,
YDtor dtor) yallnonnull;
/**
* Returns the number of allocations in the setpool.

34
include/yc/simd.h

@ -54,17 +54,15 @@ extern "C" {
#if defined(_MSC_VER)
/* Microsoft C/C++-compatible compiler */
#include <intrin.h>
#include <immintrin.h>
#include <intrin.h>
#elif (defined(__clang__) || defined(__GNUC__)) && \
(defined(__x86_64__) || defined(__i386__)) && \
(defined(__GLIBC__))
(defined(__x86_64__) || defined(__i386__)) && (defined(__GLIBC__))
/* GCC-compatible compiler, targeting x86/x86-64 */
#include <x86intrin.h>
#include <immintrin.h>
#include <x86intrin.h>
#ifdef __SSE2__
@ -72,15 +70,13 @@ extern "C" {
typedef __m128i ysimd128;
yinline static inline
ysimd128
yinline static inline ysimd128
ysimd128l(const ysimd128* addr)
{
return _mm_load_si128(addr);
}
yinline static inline
void
yinline static inline void
ysimd128s(ysimd128* addr, const ysimd128 d)
{
_mm_store_si128(addr, d);
@ -95,15 +91,13 @@ ysimd128s(ysimd128* addr, const ysimd128 d)
typedef __m256i ysimd256;
yinline static inline
ysimd256
yinline static inline ysimd256
ysimd256l(const ysimd256* addr)
{
return _mm_load_si256(addr);
}
yinline static inline
void
yinline static inline void
ysimd256s(ysimd256* addr, const ysimd256 d)
{
_mm_store_si256(addr, d);
@ -123,7 +117,7 @@ ysimd256s(ysimd256* addr, const ysimd256 d)
#include <mmintrin.h>
#elif (defined(__clang__) || defined(__GNUC__) || defined(__xlC__)) && \
(defined(__VEC__) || defined(__ALTIVEC__))
(defined(__VEC__) || defined(__ALTIVEC__))
/* XLC or GCC-compatible compiler, targeting PowerPC with VMX/VSX */
#include <altivec.h>
@ -146,8 +140,7 @@ typedef struct ysimd128
uint32_t d[4];
} ysimd128;
yinline static inline
ysimd128
yinline static inline ysimd128
ysimd128l(const ysimd128* addr)
{
size_t i;
@ -161,8 +154,7 @@ ysimd128l(const ysimd128* addr)
return r;
}
yinline static inline
void
yinline static inline void
ysimd128s(ysimd128* addr, const ysimd128 d)
{
size_t i;
@ -182,8 +174,7 @@ typedef struct ysimd256
uint64_t d[4];
} ysimd256;
yinline static inline
ysimd256
yinline static inline ysimd256
ysimd256l(const ysimd256* addr)
{
size_t i = 0;
@ -200,8 +191,7 @@ ysimd256l(const ysimd256* addr)
return r;
}
yinline static inline
void
yinline static inline void
ysimd256s(ysimd256* addr, const ysimd256 d)
{
size_t i;

12
include/yc/smap.h

@ -46,9 +46,9 @@ extern "C" {
#include <stdlib.h>
//! @endcond
#include <yc/yc.h>
#include <yc/types.h>
#include <yc/map.h>
#include <yc/types.h>
#include <yc/yc.h>
/**
* @file yc/smap.h
@ -344,8 +344,8 @@ ysmap_load(const YSMap m) yallnonnull yinline ypure;
* element size of @a m.
*/
YStatus
ysmap_insert(YSMap m, const void* key, const void* val,
size_t* idx) yparamsnonnull(1, 2);
ysmap_insert(YSMap m, const void* key, const void* val, size_t* idx)
yparamsnonnull(1, 2);
/**
* Inserts a value using the string as the key. If the YSMap was
@ -364,8 +364,8 @@ ysmap_insert(YSMap m, const void* key, const void* val,
* element size of @a m.
*/
YStatus
ysmap_insertStringKey(YSMap m, const char* key, const void* val,
size_t* idx) yparamsnonnull(1, 2);
ysmap_insertStringKey(YSMap m, const char* key, const void* val, size_t* idx)
yparamsnonnull(1, 2);
/**
* Removes all items from the map.

8
include/yc/str.h

@ -46,8 +46,8 @@ extern "C" {
#include <stdlib.h>
//! @endcond
#include <yc/yc.h>
#include <yc/array.h>
#include <yc/yc.h>
/**
* @file yc/str.h
@ -83,7 +83,8 @@ extern "C" {
* @pre @a p must be constant at compile time.
*/
#define YSTR_INIT(s, p) \
do { \
do \
{ \
char* _ystr_temp_s = (p); \
size_t _ystr_temp_l = strlen(_ystr_temp_s) + 1; \
YARRAY_INIT(s, _ystr_temp_s, _ystr_temp_l); \
@ -101,7 +102,8 @@ extern "C" {
* @pre @a p must be constant at compile time.
*/
#define YSTR_INITP(s, p) \
do { \
do \
{ \
char* _ystr_temp_s = (p); \
size_t _ystr_temp_l = strlen(_ystr_temp_s) + 1; \
YARRAY_INITP(s, _ystr_temp_s, _ystr_temp_l); \

2
include/yc/string.h

@ -41,9 +41,9 @@ extern "C" {
#include <yc/arith.h>
#include <yc/array.h>
#include <yc/str.h>
#include <yc/vector.h>
#include <yc/yc.h>
#include <yc/str.h>
/**
* @file yc/string.h

4
include/yc/strucon.h

@ -40,17 +40,17 @@ extern "C" {
#endif
//! @cond Doxygen suppress.
#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <signal.h>
//! @endcond
#include <yc/yc.h>
#include <yc/alloc.h>
#include <yc/arith.h>
#include <yc/atomics.h>
#include <yc/yc.h>
/**
* @file yc/strucon.h

2
include/yc/svector.h

@ -39,8 +39,8 @@
extern "C" {
#endif
#include <yc/yc.h>
#include <yc/vector.h>
#include <yc/yc.h>
/**
* @file yc/svector.h

3
include/yc/sys.h

@ -46,8 +46,8 @@ extern "C" {
#include <stdlib.h>
//! @endcond
#include <yc/yc.h>
#include <yc/str.h>
#include <yc/yc.h>
/**
* @file yc/sys.h
@ -82,4 +82,3 @@ ysys_pagesize(void) yinline;
#endif
#endif // YC_SYS_H

2
include/yc/time.h

@ -43,8 +43,8 @@
extern "C" {
#endif
#include <yc/yc.h>
#include <yc/io.h>
#include <yc/yc.h>
/**
* @file yc/time.h

241
include/yc/types.h

@ -196,7 +196,10 @@ typedef struct
* @param i The name of the enum item to generate.
* @return Material to be used in the @a YTYPE_GEN_ENUM varargs.
*/
#define YTYPE_GEN_ENUM_ITEM(i) { .name = YTYPE_GEN_TYPE_STR(i) }
#define YTYPE_GEN_ENUM_ITEM(i) \
{ \
.name = YTYPE_GEN_TYPE_STR(i) \
}
/**
* @def YTYPE_GEN_STRUCT_MEMBER
@ -207,12 +210,11 @@ typedef struct
* @param s The parent struct of the member.
* @return Material to be used in the @a YTYPE_GEN_STRUCT varargs.
*/
#define YTYPE_GEN_STRUCT_MEMBER(n, t, s) \
{ \
.name = YTYPE_GEN_TYPE_STR(n), \
.type = &_y_type_ ## t, \
.offset = offsetof(s, n) \
}
#define YTYPE_GEN_STRUCT_MEMBER(n, t, s) \