File tree Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Expand file tree Collapse file tree 3 files changed +18
-15
lines changed Original file line number Diff line number Diff line change 23
23
#include <stdlib.h>
24
24
#include <string.h>
25
25
26
+ // About X macro: https://en.wikipedia.org/wiki/X_macro
27
+ #define X (name , lenstr , str ) \
28
+ _Static_assert(*lenstr == strlen(str), "Macro length mismatch for " # name);
29
+ #include "defaultatoms.def"
30
+ #undef X
31
+
26
32
void defaultatoms_init (GlobalContext * glb )
27
33
{
28
34
29
- // About X macro: https://en.wikipedia.org/wiki/X_macro
30
35
#define X (name , lenstr , str ) \
31
36
lenstr str,
32
37
@@ -39,10 +44,6 @@ void defaultatoms_init(GlobalContext *glb)
39
44
#undef X
40
45
41
46
for (int i = 0 ; i < PLATFORM_ATOMS_BASE_INDEX ; i ++ ) {
42
- if (UNLIKELY ((size_t ) atoms [i ][0 ] != strlen (atoms [i ] + 1 ))) {
43
- AVM_ABORT ();
44
- }
45
-
46
47
if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i )) {
47
48
AVM_ABORT ();
48
49
}
Original file line number Diff line number Diff line change 23
23
#include <stdlib.h>
24
24
#include <string.h>
25
25
26
+ // About X macro: https://en.wikipedia.org/wiki/X_macro
27
+ #define X (name , lenstr , str ) \
28
+ _Static_assert(*lenstr == strlen(str), "Macro length mismatch for " # name);
29
+ #include "platform_defaultatoms.def"
30
+ #undef X
31
+
26
32
void platform_defaultatoms_init (GlobalContext * glb )
27
33
{
28
- // About X macro: https://en.wikipedia.org/wiki/X_macro
29
34
#define X (name , lenstr , str ) \
30
35
lenstr str,
31
36
@@ -38,10 +43,6 @@ void platform_defaultatoms_init(GlobalContext *glb)
38
43
#undef X
39
44
40
45
for (int i = 0 ; i < ATOM_FIRST_AVAIL_INDEX - PLATFORM_ATOMS_BASE_INDEX ; i ++ ) {
41
- if (UNLIKELY ((size_t ) atoms [i ][0 ] != strlen (atoms [i ] + 1 ))) {
42
- AVM_ABORT ();
43
- }
44
-
45
46
if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i + PLATFORM_ATOMS_BASE_INDEX )) {
46
47
AVM_ABORT ();
47
48
}
Original file line number Diff line number Diff line change 23
23
#include <stdlib.h>
24
24
#include <string.h>
25
25
26
+ // About X macro: https://en.wikipedia.org/wiki/X_macro
27
+ #define X (name , lenstr , str ) \
28
+ _Static_assert(*lenstr == strlen(str), "Macro length mismatch for " # name);
29
+ #include "platform_defaultatoms.def"
30
+ #undef X
31
+
26
32
void platform_defaultatoms_init (GlobalContext * glb )
27
33
{
28
- // About X macro: https://en.wikipedia.org/wiki/X_macro
29
34
#define X (name , lenstr , str ) \
30
35
lenstr str,
31
36
@@ -38,10 +43,6 @@ void platform_defaultatoms_init(GlobalContext *glb)
38
43
#undef X
39
44
40
45
for (int i = 0 ; i < ATOM_FIRST_AVAIL_INDEX - PLATFORM_ATOMS_BASE_INDEX ; i ++ ) {
41
- if (UNLIKELY ((size_t ) atoms [i ][0 ] != strlen (atoms [i ] + 1 ))) {
42
- AVM_ABORT ();
43
- }
44
-
45
46
if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i + PLATFORM_ATOMS_BASE_INDEX )) {
46
47
AVM_ABORT ();
47
48
}
You can’t perform that action at this time.
0 commit comments