1 // SPDX-License-Identifier: GPL-2.0-only 2 static struct resword { 3 const char *name; 4 int token; 5 } keywords[] = { 6 { "__GENKSYMS_EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW }, 7 { "__asm", ASM_KEYW }, 8 { "__asm__", ASM_KEYW }, 9 { "__attribute", ATTRIBUTE_KEYW }, 10 { "__attribute__", ATTRIBUTE_KEYW }, 11 { "__const", CONST_KEYW }, 12 { "__const__", CONST_KEYW }, 13 { "__extension__", EXTENSION_KEYW }, 14 { "__inline", INLINE_KEYW }, 15 { "__inline__", INLINE_KEYW }, 16 { "__signed", SIGNED_KEYW }, 17 { "__signed__", SIGNED_KEYW }, 18 { "__typeof", TYPEOF_KEYW }, 19 { "__typeof__", TYPEOF_KEYW }, 20 { "__typeof_unqual", TYPEOF_KEYW }, 21 { "__typeof_unqual__", TYPEOF_KEYW }, 22 { "__volatile", VOLATILE_KEYW }, 23 { "__volatile__", VOLATILE_KEYW }, 24 { "__builtin_va_list", VA_LIST_KEYW }, 25 26 { "__int128", BUILTIN_INT_KEYW }, 27 { "__int128_t", BUILTIN_INT_KEYW }, 28 { "__uint128_t", BUILTIN_INT_KEYW }, 29 30 // According to rth, c99 defines "_Bool", "__restrict", "__restrict__", "restrict". KAO 31 { "_Bool", BOOL_KEYW }, 32 { "__restrict", RESTRICT_KEYW }, 33 { "__restrict__", RESTRICT_KEYW }, 34 { "restrict", RESTRICT_KEYW }, 35 { "asm", ASM_KEYW }, 36 37 // c11 keywords that can be used at module scope 38 { "_Static_assert", STATIC_ASSERT_KEYW }, 39 40 // attribute commented out in modutils 2.4.2. People are using 'attribute' as a 41 // field name which breaks the genksyms parser. It is not a gcc keyword anyway. 42 // KAO. }, 43 // { "attribute", ATTRIBUTE_KEYW }, 44 45 // X86 named address space qualifiers 46 { "__seg_gs", X86_SEG_KEYW }, 47 { "__seg_fs", X86_SEG_KEYW }, 48 49 { "auto", AUTO_KEYW }, 50 { "char", CHAR_KEYW }, 51 { "const", CONST_KEYW }, 52 { "double", DOUBLE_KEYW }, 53 { "enum", ENUM_KEYW }, 54 { "extern", EXTERN_KEYW }, 55 { "float", FLOAT_KEYW }, 56 { "inline", INLINE_KEYW }, 57 { "int", INT_KEYW }, 58 { "long", LONG_KEYW }, 59 { "register", REGISTER_KEYW }, 60 { "short", SHORT_KEYW }, 61 { "signed", SIGNED_KEYW }, 62 { "static", STATIC_KEYW }, 63 { "struct", STRUCT_KEYW }, 64 { "typedef", TYPEDEF_KEYW }, 65 { "typeof", TYPEOF_KEYW }, 66 { "typeof_unqual", TYPEOF_KEYW }, 67 { "union", UNION_KEYW }, 68 { "unsigned", UNSIGNED_KEYW }, 69 { "void", VOID_KEYW }, 70 { "volatile", VOLATILE_KEYW }, 71 }; 72 73 #define NR_KEYWORDS (sizeof(keywords)/sizeof(struct resword)) 74 75 static int is_reserved_word(register const char *str, register unsigned int len) 76 { 77 int i; 78 for (i = 0; i < NR_KEYWORDS; i++) { 79 struct resword *r = keywords + i; 80 int l = strlen(r->name); 81 if (len == l && !memcmp(str, r->name, len)) 82 return r->token; 83 } 84 return -1; 85 } 86