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 2323#include <stdlib.h>
2424#include <string.h>
2525
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+
2634void defaultatoms_init (GlobalContext * glb )
2735{
2836
29- // About X macro: https://en.wikipedia.org/wiki/X_macro
3037#define X (name , lenstr , str ) \
3138 lenstr str,
3239
@@ -39,10 +46,6 @@ void defaultatoms_init(GlobalContext *glb)
3946#undef X
4047
4148 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-
4649 if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i )) {
4750 AVM_ABORT ();
4851 }
Original file line number Diff line number Diff line change 2323#include <stdlib.h>
2424#include <string.h>
2525
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+
2634void platform_defaultatoms_init (GlobalContext * glb )
2735{
28- // About X macro: https://en.wikipedia.org/wiki/X_macro
2936#define X (name , lenstr , str ) \
3037 lenstr str,
3138
@@ -38,10 +45,6 @@ void platform_defaultatoms_init(GlobalContext *glb)
3845#undef X
3946
4047 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-
4548 if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i + PLATFORM_ATOMS_BASE_INDEX )) {
4649 AVM_ABORT ();
4750 }
Original file line number Diff line number Diff line change 2323#include <stdlib.h>
2424#include <string.h>
2525
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+
2634void platform_defaultatoms_init (GlobalContext * glb )
2735{
28- // About X macro: https://en.wikipedia.org/wiki/X_macro
2936#define X (name , lenstr , str ) \
3037 lenstr str,
3138
@@ -38,10 +45,6 @@ void platform_defaultatoms_init(GlobalContext *glb)
3845#undef X
3946
4047 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-
4548 if (UNLIKELY (globalcontext_insert_atom (glb , atoms [i ]) != i + PLATFORM_ATOMS_BASE_INDEX )) {
4649 AVM_ABORT ();
4750 }
You can’t perform that action at this time.
0 commit comments