Skip to content

Commit edb229f

Browse files
committed
Forgotten comments for coconut_pub.h.
1 parent 4d0913f commit edb229f

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

src/coconut_pub.h

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,90 @@
1111

1212
#include <stdbool.h>
1313

14-
void c_output(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
15-
16-
14+
/**
15+
* Blocks calling thread until event is published.
16+
*/
1717
void c_wait_event(const char *event);
1818

19+
/**
20+
* Unblocks all threads waiting for event.
21+
*/
1922
void c_publish_event(const char *event);
2023

24+
/**
25+
* Returns true if event was published.
26+
*/
2127
bool c_is_event_published(const char *event);
2228

23-
29+
/**
30+
* Sets desired interleaving of blocks. Sequence that may run concurrently
31+
* should be delimited with ' ', sequences for sequential execution with ';'.
32+
*/
2433
void c_set_blocks_interleaving(const char *interleaving);
2534

35+
/**
36+
* Marks beginning of block.
37+
*/
2638
void c_begin_block(const char *block);
2739

40+
/**
41+
* Marks end of block.
42+
*/
2843
void c_end_block();
2944

45+
/**
46+
* Convenience function equivalent to c_begin_block(id); c_end_block(). That
47+
* allows for similar behaviour as event API.
48+
*/
3049
void c_one_line_block(const char *block);
3150

51+
/**
52+
* Checks if block has not been started yet.
53+
*/
3254
bool c_is_before_block(const char *block);
3355

56+
/**
57+
* Checks if block has been started and has not finished yet.
58+
*/
3459
bool c_is_during_block(const char *block);
3560

61+
/**
62+
* Check if block has finished.
63+
*/
3664
bool c_is_after_block(const char *block);
3765

66+
/**
67+
* Function for safe outputting to stderr.
68+
*/
69+
void c_output(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
70+
71+
/**
72+
* Asserts that COND is true. Prints passed message otherwise.
73+
*/
3874
#define c_assert_true(COND, FMT, ...) do { if (!(COND)) { c_output("[%s:%s:%d]: Assert failed: " FMT "\n", __FILE__, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); } } while (0)
75+
/**
76+
* Asserts that COND is false. Prints passed message otherwise.
77+
*/
3978
#define c_assert_false(COND, FMT, ...) c_assert_true(!(COND), FMT, ##__VA_ARGS__)
79+
/**
80+
* Asserts that EVENT has not been published yet. Prints passed message otherwise.
81+
*/
4082
#define c_assert_before_event(EVENT, FMT, ...) do { if (c_is_event_published(EVENT)) c_assert_true(0, FMT, ##__VA_ARGS__); } while (0)
83+
/**
84+
* Asserts that EVENT has been published. Prints passed message otherwise.
85+
*/
4186
#define c_assert_after_event(EVENT, FMT, ...) do { if (!c_is_event_published(EVENT)) c_assert_true(0, FMT, ##__VA_ARGS__); } while (0)
87+
/**
88+
* Asserts that BLOCK has not been started yet. Prints passed message otherwise.
89+
*/
4290
#define c_assert_before_block(BLOCK, FMT, ...) do { if (!c_is_before_block(BLOCK)) c_assert_true(0, FMT, ##__VA_ARGS__); } while (0)
91+
/**
92+
* Asserts that BLOCK has been started but has not finished yet. Prints passed message otherwise.
93+
*/
4394
#define c_assert_during_block(BLOCK, FMT, ...) do { if (!c_is_during_block(BLOCK)) c_assert_true(0, FMT, ##__VA_ARGS__); } while (0)
95+
/**
96+
* Asserts that BLOCK has finished. Prints passed message otherwise.
97+
*/
4498
#define c_assert_after_block(BLOCK, FMT, ...) do { if (!c_is_after_block(BLOCK)) c_assert_true(0, FMT, ##__VA_ARGS__); } while (0)
4599

46100
#else

0 commit comments

Comments
 (0)