File tree Expand file tree Collapse file tree 3 files changed +24
-15
lines changed Expand file tree Collapse file tree 3 files changed +24
-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
+ #if __has_builtin (__builtin_strlen )
28
+ #define X (name , lenstr , str ) \
29
+ _Static_assert(lenstr[0] == __builtin_strlen(str), "Macro length mismatch for " # name);
30
+ #include "defaultatoms.def"
31
+ #undef X
32
+ #endif
33
+
26
34
void defaultatoms_init (GlobalContext * glb )
27
35
{
28
36
29
- // About X macro: https://en.wikipedia.org/wiki/X_macro
30
37
#define X (name , lenstr , str ) \
31
38
lenstr str,
32
39
@@ -39,10 +46,6 @@ void defaultatoms_init(GlobalContext *glb)
39
46
#undef X
40
47
41
48
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
49
if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i )) {
47
50
AVM_ABORT ();
48
51
}
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
+ #if __has_builtin (__builtin_strlen )
28
+ #define X (name , lenstr , str ) \
29
+ _Static_assert(lenstr[0] == __builtin_strlen(str), "Macro length mismatch for " # name);
30
+ #include "platform_defaultatoms.def"
31
+ #undef X
32
+ #endif
33
+
26
34
void platform_defaultatoms_init (GlobalContext * glb )
27
35
{
28
- // About X macro: https://en.wikipedia.org/wiki/X_macro
29
36
#define X (name , lenstr , str ) \
30
37
lenstr str,
31
38
@@ -38,10 +45,6 @@ void platform_defaultatoms_init(GlobalContext *glb)
38
45
#undef X
39
46
40
47
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
48
if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i + PLATFORM_ATOMS_BASE_INDEX )) {
46
49
AVM_ABORT ();
47
50
}
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
+ #if __has_builtin (__builtin_strlen )
28
+ #define X (name , lenstr , str ) \
29
+ _Static_assert(lenstr[0] == __builtin_strlen(str), "Macro length mismatch for " # name);
30
+ #include "platform_defaultatoms.def"
31
+ #undef X
32
+ #endif
33
+
26
34
void platform_defaultatoms_init (GlobalContext * glb )
27
35
{
28
- // About X macro: https://en.wikipedia.org/wiki/X_macro
29
36
#define X (name , lenstr , str ) \
30
37
lenstr str,
31
38
@@ -38,10 +45,6 @@ void platform_defaultatoms_init(GlobalContext *glb)
38
45
#undef X
39
46
40
47
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
48
if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i + PLATFORM_ATOMS_BASE_INDEX )) {
46
49
AVM_ABORT ();
47
50
}
You can’t perform that action at this time.
0 commit comments