-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
73 lines (51 loc) · 1.29 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
General Information
===================
CMX is C preprocessor (macro) library designed to simplify
C programs
Installation
============
See file 'INSTALL'
How to report bug and/or participate
====================================
Visit project on github:
https://github.com/happy-barney/c-cmx
Parts
=====
* cmx-struct-refs
Helps to implement struct ref counting
Example:
CMX_STRUCT_REFS_UNREF (ptr) {
/* executed when ref count drops to 0 */
}
* cmx-struct-shareable
Macros to implement uniform way how to treat struct's flow mutex
if enabled
Example:
foo (struct Foo *ptr) {
CMX_STRUCT_SHAREABLE_SYNCHRONIZE (ptr) {
}
}
* cmx-synchronize
Providing CMX_SYNCHRONIZE and CMX_RUN_ONCE allows you to simplify
(ie, hides) mutex operations into one keyword-look-like macro
Example:
foo_init (void) {
CMX_RUN_ONCE {
foo = ...;
bar = ...;
}
}
* cmx-local
Stores variable value, executes block and restore its value.
Macros can be serialized.
Example:
foo () {
int i = 1;
int j = 1;
CMX_LOCAL (i)
printf ("%d %d\n", ++i, ++j); /* 2 2 */
printf ("%d %d\n", ++i, ++j); /* 2 3 */
CMX_LOCAL (i) CMX_LOCAL (j)
printf ("%d %d\n", ++i, ++j); /* 3 4 */
printf ("%d %d\n", ++i, ++j); /* 3 4 */
}