18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_cistatic struct resword { 38c2ecf20Sopenharmony_ci const char *name; 48c2ecf20Sopenharmony_ci int token; 58c2ecf20Sopenharmony_ci} keywords[] = { 68c2ecf20Sopenharmony_ci { "__GENKSYMS_EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW }, 78c2ecf20Sopenharmony_ci { "__asm", ASM_KEYW }, 88c2ecf20Sopenharmony_ci { "__asm__", ASM_KEYW }, 98c2ecf20Sopenharmony_ci { "__attribute", ATTRIBUTE_KEYW }, 108c2ecf20Sopenharmony_ci { "__attribute__", ATTRIBUTE_KEYW }, 118c2ecf20Sopenharmony_ci { "__const", CONST_KEYW }, 128c2ecf20Sopenharmony_ci { "__const__", CONST_KEYW }, 138c2ecf20Sopenharmony_ci { "__extension__", EXTENSION_KEYW }, 148c2ecf20Sopenharmony_ci { "__inline", INLINE_KEYW }, 158c2ecf20Sopenharmony_ci { "__inline__", INLINE_KEYW }, 168c2ecf20Sopenharmony_ci { "__signed", SIGNED_KEYW }, 178c2ecf20Sopenharmony_ci { "__signed__", SIGNED_KEYW }, 188c2ecf20Sopenharmony_ci { "__typeof", TYPEOF_KEYW }, 198c2ecf20Sopenharmony_ci { "__typeof__", TYPEOF_KEYW }, 208c2ecf20Sopenharmony_ci { "__volatile", VOLATILE_KEYW }, 218c2ecf20Sopenharmony_ci { "__volatile__", VOLATILE_KEYW }, 228c2ecf20Sopenharmony_ci { "__builtin_va_list", VA_LIST_KEYW }, 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci { "__int128", BUILTIN_INT_KEYW }, 258c2ecf20Sopenharmony_ci { "__int128_t", BUILTIN_INT_KEYW }, 268c2ecf20Sopenharmony_ci { "__uint128_t", BUILTIN_INT_KEYW }, 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci // According to rth, c99 defines "_Bool", "__restrict", "__restrict__", "restrict". KAO 298c2ecf20Sopenharmony_ci { "_Bool", BOOL_KEYW }, 308c2ecf20Sopenharmony_ci { "__restrict", RESTRICT_KEYW }, 318c2ecf20Sopenharmony_ci { "__restrict__", RESTRICT_KEYW }, 328c2ecf20Sopenharmony_ci { "restrict", RESTRICT_KEYW }, 338c2ecf20Sopenharmony_ci { "asm", ASM_KEYW }, 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci // attribute commented out in modutils 2.4.2. People are using 'attribute' as a 368c2ecf20Sopenharmony_ci // field name which breaks the genksyms parser. It is not a gcc keyword anyway. 378c2ecf20Sopenharmony_ci // KAO. }, 388c2ecf20Sopenharmony_ci // { "attribute", ATTRIBUTE_KEYW }, 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci { "auto", AUTO_KEYW }, 418c2ecf20Sopenharmony_ci { "char", CHAR_KEYW }, 428c2ecf20Sopenharmony_ci { "const", CONST_KEYW }, 438c2ecf20Sopenharmony_ci { "double", DOUBLE_KEYW }, 448c2ecf20Sopenharmony_ci { "enum", ENUM_KEYW }, 458c2ecf20Sopenharmony_ci { "extern", EXTERN_KEYW }, 468c2ecf20Sopenharmony_ci { "float", FLOAT_KEYW }, 478c2ecf20Sopenharmony_ci { "inline", INLINE_KEYW }, 488c2ecf20Sopenharmony_ci { "int", INT_KEYW }, 498c2ecf20Sopenharmony_ci { "long", LONG_KEYW }, 508c2ecf20Sopenharmony_ci { "register", REGISTER_KEYW }, 518c2ecf20Sopenharmony_ci { "short", SHORT_KEYW }, 528c2ecf20Sopenharmony_ci { "signed", SIGNED_KEYW }, 538c2ecf20Sopenharmony_ci { "static", STATIC_KEYW }, 548c2ecf20Sopenharmony_ci { "struct", STRUCT_KEYW }, 558c2ecf20Sopenharmony_ci { "typedef", TYPEDEF_KEYW }, 568c2ecf20Sopenharmony_ci { "typeof", TYPEOF_KEYW }, 578c2ecf20Sopenharmony_ci { "union", UNION_KEYW }, 588c2ecf20Sopenharmony_ci { "unsigned", UNSIGNED_KEYW }, 598c2ecf20Sopenharmony_ci { "void", VOID_KEYW }, 608c2ecf20Sopenharmony_ci { "volatile", VOLATILE_KEYW }, 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define NR_KEYWORDS (sizeof(keywords)/sizeof(struct resword)) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic int is_reserved_word(register const char *str, register unsigned int len) 668c2ecf20Sopenharmony_ci{ 678c2ecf20Sopenharmony_ci int i; 688c2ecf20Sopenharmony_ci for (i = 0; i < NR_KEYWORDS; i++) { 698c2ecf20Sopenharmony_ci struct resword *r = keywords + i; 708c2ecf20Sopenharmony_ci int l = strlen(r->name); 718c2ecf20Sopenharmony_ci if (len == l && !memcmp(str, r->name, len)) 728c2ecf20Sopenharmony_ci return r->token; 738c2ecf20Sopenharmony_ci } 748c2ecf20Sopenharmony_ci return -1; 758c2ecf20Sopenharmony_ci} 76