diff --git a/share/compliance/c11_functions.json b/share/compliance/c11_functions.json index 2f7d18b10365d5a192c1aad54c37acd9433ca51b..6f69e6149ee7e3f749df48337f4f5502a146dc47 100644 --- a/share/compliance/c11_functions.json +++ b/share/compliance/c11_functions.json @@ -1,14 +1,16 @@ { - "description": "C11 reserved function identifiers", + "description": "C11 reserved function and macro identifiers", "notes": { "description": "The 'notes' field is a list of characteristics related to CWEs or that may affect the 'difficulty' of analyzing such functions with Frama-C. Each note is succintly described below.", "variadic":"Variadic function, OR having an argument of type va_list.", - "safer-alts":"A list of recommended alternatives for functions considered unsafe (CWE-242, CWE-477, CWE-676)." + "safer-alts":"A list of recommended alternatives for functions considered unsafe (CWE-242, CWE-477, CWE-676).", + "not-in-posix":"This identifier is absent from POSIX-1.2008.", + "macro":"C11 specifies this identifier as a macro, not a function." }, "source":"ISO/IEC 9899:2011", "data":{ "abort":{"header":"stdlib.h"}, - "abort_handler_s": {"header":"stdlib.h"}, + "abort_handler_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "abs": {"header":"stdlib.h"}, "acos": {"header":"math.h"}, "acosf": {"header":"math.h"}, @@ -16,16 +18,16 @@ "acoshf": {"header":"math.h"}, "acoshl": {"header":"math.h"}, "acosl": {"header":"math.h"}, - "aligned_alloc": {"header":"stdlib.h"}, + "aligned_alloc": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "asctime": {"header":"time.h", "notes":{"safer-alts":["asctime_s"]}}, - "asctime_s": {"header":"time.h"}, + "asctime_s": {"header":"time.h", "notes":{"not-in-posix":true}}, "asin": {"header":"math.h"}, "asinf": {"header":"math.h"}, "asinh": {"header":"math.h"}, "asinhf": {"header":"math.h"}, "asinhl": {"header":"math.h"}, "asinl": {"header":"math.h"}, - "at_quick_exit": {"header":"stdlib.h"}, + "at_quick_exit": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "atan": {"header":"math.h"}, "atan2": {"header":"math.h"}, "atan2f": {"header":"math.h"}, @@ -39,31 +41,31 @@ "atoi": {"header":"stdlib.h"}, "atol": {"header":"stdlib.h"}, "atoll": {"header":"stdlib.h"}, - "atomic_compare_exchange_strong": {"header":"stdatomic.h"}, - "atomic_compare_exchange_strong_explicit": {"header":"stdatomic.h"}, - "atomic_compare_exchange_weak": {"header":"stdatomic.h"}, - "atomic_compare_exchange_weak_explicit": {"header":"stdatomic.h"}, - "atomic_exchange": {"header":"stdatomic.h"}, - "atomic_exchange_explicit": {"header":"stdatomic.h"}, - "atomic_fetch_key": {"header":"stdatomic.h"}, - "atomic_fetch_key_explicit": {"header":"stdatomic.h"}, - "atomic_flag_clear": {"header":"stdatomic.h"}, - "atomic_flag_clear_explicit": {"header":"stdatomic.h"}, - "atomic_flag_test_and_set": {"header":"stdatomic.h"}, - "atomic_flag_test_and_set_explicit": {"header":"stdatomic.h"}, - "atomic_init": {"header":"stdatomic.h"}, - "atomic_is_lock_free": {"header":"stdatomic.h"}, - "atomic_load": {"header":"stdatomic.h"}, - "atomic_load_explicit": {"header":"stdatomic.h"}, - "atomic_signal_fence": {"header":"stdatomic.h"}, - "atomic_store": {"header":"stdatomic.h"}, - "atomic_store_explicit": {"header":"stdatomic.h"}, - "atomic_thread_fence": {"header":"stdatomic.h"}, + "atomic_compare_exchange_strong": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_compare_exchange_strong_explicit": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_compare_exchange_weak": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_compare_exchange_weak_explicit": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_exchange": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_exchange_explicit": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_fetch_key": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_fetch_key_explicit": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_flag_clear": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_flag_clear_explicit": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_flag_test_and_set": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_flag_test_and_set_explicit": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_init": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_is_lock_free": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_load": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_load_explicit": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_signal_fence": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_store": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_store_explicit": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, + "atomic_thread_fence": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, "bsearch": {"header":"stdlib.h", "notes":{"safer-alts":["bsearch_s"]}}, - "bsearch_s": {"header":"stdlib.h"}, + "bsearch_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "btowc": {"header":"wchar.h"}, - "c16rtomb": {"header":"uchar.h"}, - "c32rtomb": {"header":"uchar.h"}, + "c16rtomb": {"header":"uchar.h", "notes":{"not-in-posix":true}}, + "c32rtomb": {"header":"uchar.h", "notes":{"not-in-posix":true}}, "cabs": {"header":"complex.h"}, "cabsf": {"header":"complex.h"}, "cabsl": {"header":"complex.h"}, @@ -73,7 +75,7 @@ "cacoshf": {"header":"complex.h"}, "cacoshl": {"header":"complex.h"}, "cacosl": {"header":"complex.h"}, - "call_once": {"header":"threads.h"}, + "call_once": {"header":"threads.h", "notes":{"not-in-posix":true}}, "calloc": {"header":"stdlib.h"}, "carg": {"header":"complex.h"}, "cargf": {"header":"complex.h"}, @@ -156,7 +158,7 @@ "ctanhl": {"header":"complex.h"}, "ctanl": {"header":"complex.h"}, "ctime": {"header":"time.h"}, - "ctime_s": {"header":"time.h"}, + "ctime_s": {"header":"time.h", "notes":{"not-in-posix":true}}, "difftime": {"header":"time.h"}, "div": {"header":"stdlib.h"}, "erf": {"header":"math.h"}, @@ -217,10 +219,10 @@ "fmodf": {"header":"math.h"}, "fmodl": {"header":"math.h"}, "fopen": {"header":"stdio.h", "notes":{"safer-alts":["fopen_s"]}}, - "fopen_s": {"header":"stdio.h"}, - "fpclassify": {"header":"math.h"}, + "fopen_s": {"header":"stdio.h", "notes":{"not-in-posix":true}}, + "fpclassify": {"header":"math.h", "notes":{"macro":true}}, "fprintf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["fprintf_s"]}}, - "fprintf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "fprintf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "fputc": {"header":"stdio.h"}, "fputs": {"header":"stdio.h"}, "fputwc": {"header":"wchar.h"}, @@ -228,34 +230,34 @@ "fread": {"header":"stdio.h"}, "free": {"header":"stdlib.h"}, "freopen": {"header":"stdio.h", "notes":{"safer-alts":["freopen_s"]}}, - "freopen_s": {"header":"stdio.h"}, + "freopen_s": {"header":"stdio.h", "notes":{"not-in-posix":true}}, "frexp": {"header":"math.h"}, "frexpf": {"header":"math.h"}, "frexpl": {"header":"math.h"}, "fscanf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["fscanf_s"]}}, - "fscanf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "fscanf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "fseek": {"header":"stdio.h"}, "fsetpos": {"header":"stdio.h"}, "ftell": {"header":"stdio.h"}, "fwide": {"header":"wchar.h"}, "fwprintf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["fwprintf_s"]}}, - "fwprintf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "fwprintf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix": true}}, "fwrite": {"header":"stdio.h"}, "fwscanf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["fwscanf_s"]}}, - "fwscanf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "fwscanf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "getc": {"header":"stdio.h"}, "getchar": {"header":"stdio.h"}, "getenv": {"header":"stdlib.h", "notes":{"safer-alts":["getenv_s"]}}, - "getenv_s": {"header":"stdlib.h"}, - "gets_s": {"header":"stdio.h"}, + "getenv_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, + "gets_s": {"header":"stdio.h", "notes":{"not-in-posix":true}}, "getwc": {"header":"wchar.h"}, "getwchar": {"header":"wchar.h"}, "gmtime": {"header":"time.h", "notes":{"safer-alts":["gmtime_s"]}}, - "gmtime_s": {"header":"time.h"}, + "gmtime_s": {"header":"time.h", "notes":{"not-in-posix":true}}, "hypot": {"header":"math.h"}, "hypotf": {"header":"math.h"}, "hypotl": {"header":"math.h"}, - "ignore_handler_s": {"header":"stdlib.h"}, + "ignore_handler_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "ilogb": {"header":"math.h"}, "ilogbf": {"header":"math.h"}, "ilogbl": {"header":"math.h"}, @@ -266,21 +268,21 @@ "isblank": {"header":"ctype.h"}, "iscntrl": {"header":"ctype.h"}, "isdigit": {"header":"ctype.h"}, - "isfinite": {"header":"math.h"}, + "isfinite": {"header":"math.h", "notes":{"macro":true}}, "isgraph": {"header":"ctype.h"}, - "isgreater": {"header":"math.h"}, - "isgreaterequal": {"header":"math.h"}, - "isinf": {"header":"math.h"}, - "isless": {"header":"math.h"}, - "islessequal": {"header":"math.h"}, - "islessgreater": {"header":"math.h"}, + "isgreater": {"header":"math.h", "notes":{"macro":true}}, + "isgreaterequal": {"header":"math.h", "notes":{"macro":true}}, + "isinf": {"header":"math.h", "notes":{"macro":true}}, + "isless": {"header":"math.h", "notes":{"macro":true}}, + "islessequal": {"header":"math.h", "notes":{"macro":true}}, + "islessgreater": {"header":"math.h", "notes":{"macro":true}}, "islower": {"header":"ctype.h"}, - "isnan": {"header":"math.h"}, - "isnormal": {"header":"math.h"}, + "isnan": {"header":"math.h", "notes":{"macro":true}}, + "isnormal": {"header":"math.h", "notes":{"macro":true}}, "isprint": {"header":"ctype.h"}, "ispunct": {"header":"ctype.h"}, "isspace": {"header":"ctype.h"}, - "isunordered": {"header":"math.h"}, + "isunordered": {"header":"math.h", "notes":{"macro":true}}, "isupper": {"header":"ctype.h"}, "iswalnum": {"header":"wctype.h"}, "iswalpha": {"header":"wctype.h"}, @@ -296,7 +298,7 @@ "iswupper": {"header":"wctype.h"}, "iswxdigit": {"header":"wctype.h"}, "isxdigit": {"header":"ctype.h"}, - "kill_dependency": {"header":"stdatomic.h"}, + "kill_dependency": {"header":"stdatomic.h", "notes":{"not-in-posix":true}}, "labs": {"header":"stdlib.h"}, "ldexp": {"header":"math.h"}, "ldexpf": {"header":"math.h"}, @@ -315,7 +317,7 @@ "llroundl": {"header":"math.h"}, "localeconv": {"header":"locale.h"}, "localtime": {"header":"time.h", "notes":{"safer-alts":["localtime_s"]}}, - "localtime_s": {"header":"time.h"}, + "localtime_s": {"header":"time.h", "notes":{"not-in-posix":true}}, "log": {"header":"math.h"}, "log10": {"header":"math.h"}, "log10f": {"header":"math.h"}, @@ -346,28 +348,28 @@ "mbrtowc": {"header":"wchar.h"}, "mbsinit": {"header":"wchar.h"}, "mbsrtowcs": {"header":"wchar.h", "notes":{"safer-alts":["mbsrtowcs_s"]}}, - "mbsrtowcs_s": {"header":"wchar.h"}, + "mbsrtowcs_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "mbstowcs": {"header":"stdlib.h", "notes":{"safer-alts":["mbstowcs_s"]}}, - "mbstowcs_s": {"header":"stdlib.h"}, + "mbstowcs_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "mbtowc": {"header":"stdlib.h"}, "memchr": {"header":"string.h"}, "memcmp": {"header":"string.h"}, "memcpy": {"header":"string.h", "notes":{"safer-alts":["memcpy_s"]}}, - "memcpy_s": {"header":"string.h"}, + "memcpy_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "memmove": {"header":"string.h", "notes":{"safer-alts":["memmove_s"]}}, - "memmove_s": {"header":"string.h"}, + "memmove_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "memset": {"header":"string.h", "notes":{"safer-alts":["memset_s"]}}, - "memset_s": {"header":"string.h"}, + "memset_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "mktime": {"header":"time.h"}, "modf": {"header":"math.h"}, "modff": {"header":"math.h"}, "modfl": {"header":"math.h"}, - "mtx_destroy": {"header":"threads.h"}, - "mtx_init": {"header":"threads.h"}, - "mtx_lock": {"header":"threads.h"}, - "mtx_timedlock": {"header":"threads.h"}, - "mtx_trylock": {"header":"threads.h"}, - "mtx_unlock": {"header":"threads.h"}, + "mtx_destroy": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "mtx_init": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "mtx_lock": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "mtx_timedlock": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "mtx_trylock": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "mtx_unlock": {"header":"threads.h", "notes":{"not-in-posix":true}}, "nan": {"header":"math.h"}, "nanf": {"header":"math.h"}, "nanl": {"header":"math.h"}, @@ -385,15 +387,15 @@ "powf": {"header":"math.h"}, "powl": {"header":"math.h"}, "printf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["printf_s"]}}, - "printf_s": {"header":"stdio.h"}, + "printf_s": {"header":"stdio.h", "notes":{"not-in-posix":true}}, "putc": {"header":"stdio.h"}, "putchar": {"header":"stdio.h"}, "puts": {"header":"stdio.h"}, "putwc": {"header":"wchar.h"}, "putwchar": {"header":"wchar.h"}, "qsort": {"header":"stdlib.h"}, - "qsort_s": {"header":"stdlib.h"}, - "quick_exit": {"header":"stdlib.h"}, + "qsort_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, + "quick_exit": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "raise": {"header":"signal.h"}, "rand": {"header":"stdlib.h"}, "realloc": {"header":"stdlib.h"}, @@ -419,14 +421,14 @@ "scalbnf": {"header":"math.h"}, "scalbnl": {"header":"math.h"}, "scanf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["scanf_s"]}}, - "scanf_s": {"header":"stdio.h", "notes":{"variadic":true}}, - "set_constraint_handler_s": {"header":"stdlib.h"}, + "scanf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, + "set_constraint_handler_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "setbuf": {"header":"stdio.h"}, "setjmp": {"header":"setjmp.h"}, "setlocale": {"header":"locale.h"}, "setvbuf": {"header":"stdio.h"}, "signal": {"header":"signal.h"}, - "signbit": {"header":"math.h"}, + "signbit": {"header":"math.h", "notes":{"macro":true}}, "sin": {"header":"math.h"}, "sinf": {"header":"math.h"}, "sinh": {"header":"math.h"}, @@ -434,35 +436,35 @@ "sinhl": {"header":"math.h"}, "sinl": {"header":"math.h"}, "snprintf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["snprintf_s", "sprintf_s"]}}, - "snprintf_s": {"header":"stdio.h", "notes":{"variadic":true}}, - "snwprintf_s": {"header":"wchar.h"}, + "snprintf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, + "snwprintf_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "sprintf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["sprintf_s", "snprintf_s"]}}, - "sprintf_s": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["snprintf_s"]}}, + "sprintf_s": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["snprintf_s"], "not-in-posix":true}}, "sqrt": {"header":"math.h"}, "sqrtf": {"header":"math.h"}, "sqrtl": {"header":"math.h"}, "srand": {"header":"stdlib.h"}, "sscanf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["sscanf_s"]}}, - "sscanf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "sscanf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "strcat": {"header":"string.h", "notes":{"safer-alts":["strcat_s", "strncat_s", "strlcat", "strncat"]}}, - "strcat_s": {"header":"string.h"}, + "strcat_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "strchr": {"header":"string.h"}, "strcmp": {"header":"string.h"}, "strcoll": {"header":"string.h"}, "strcpy": {"header":"string.h", "notes":{"safer-alts":["strcpy_s", "strncpy_s", "strlcpy", "strncpy"]}}, - "strcpy_s": {"header":"string.h"}, + "strcpy_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "strcspn": {"header":"string.h"}, "strerror": {"header":"string.h"}, - "strerror_s": {"header":"string.h"}, - "strerrorlen_s": {"header":"string.h"}, + "strerror_s": {"header":"string.h", "notes":{"not-in-posix":true}}, + "strerrorlen_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "strftime": {"header":"time.h"}, "strlen": {"header":"string.h", "notes":{"safer-alts":["strnlen_s"]}}, "strncat": {"header":"string.h", "notes":{"safer-alts":["strncat_s", "strlcat"]}}, - "strncat_s": {"header":"string.h"}, + "strncat_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "strncmp": {"header":"string.h"}, "strncpy": {"header":"string.h", "notes":{"safer-alts":["strncpy_s", "strlcpy"]}}, - "strncpy_s": {"header":"string.h"}, - "strnlen_s": {"header":"string.h"}, + "strncpy_s": {"header":"string.h", "notes":{"not-in-posix":true}}, + "strnlen_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "strpbrk": {"header":"string.h"}, "strrchr": {"header":"string.h"}, "strspn": {"header":"string.h"}, @@ -471,7 +473,7 @@ "strtof": {"header":"stdlib.h"}, "strtoimax": {"header":"inttypes.h"}, "strtok": {"header":"string.h", "notes":{"safer-alts":["strtok_s"]}}, - "strtok_s": {"header":"string.h"}, + "strtok_s": {"header":"string.h", "notes":{"not-in-posix":true}}, "strtol": {"header":"stdlib.h"}, "strtold": {"header":"stdlib.h"}, "strtoll": {"header":"stdlib.h"}, @@ -480,9 +482,9 @@ "strtoumax": {"header":"inttypes.h"}, "strxfrm": {"header":"string.h"}, "swprintf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["swprintf_s", "sprintf_s"]}}, - "swprintf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "swprintf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "swscanf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["swscanf_s", "sscanf_s"]}}, - "swscanf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "swscanf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "system": {"header":"stdlib.h"}, "tan": {"header":"math.h"}, "tanf": {"header":"math.h"}, @@ -493,20 +495,20 @@ "tgamma": {"header":"math.h"}, "tgammaf": {"header":"math.h"}, "tgammal": {"header":"math.h"}, - "thrd_create": {"header":"threads.h"}, - "thrd_current": {"header":"threads.h"}, - "thrd_detach": {"header":"threads.h"}, - "thrd_equal": {"header":"threads.h"}, - "thrd_exit": {"header":"threads.h"}, - "thrd_join": {"header":"threads.h"}, - "thrd_sleep": {"header":"threads.h"}, - "thrd_yield": {"header":"threads.h"}, + "thrd_create": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "thrd_current": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "thrd_detach": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "thrd_equal": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "thrd_exit": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "thrd_join": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "thrd_sleep": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "thrd_yield": {"header":"threads.h", "notes":{"not-in-posix":true}}, "time": {"header":"time.h"}, - "timespec_get": {"header":"time.h"}, + "timespec_get": {"header":"time.h", "notes":{"not-in-posix":true}}, "tmpfile": {"header":"stdio.h", "notes":{"safer-alts":["tmpfile_s"]}}, - "tmpfile_s": {"header":"stdio.h"}, + "tmpfile_s": {"header":"stdio.h", "notes":{"not-in-posix":true}}, "tmpnam": {"header":"stdio.h", "notes":{"safer-alts":["tmpnam_s"]}}, - "tmpnam_s": {"header":"stdio.h"}, + "tmpnam_s": {"header":"stdio.h", "notes":{"not-in-posix":true}}, "tolower": {"header":"ctype.h"}, "toupper": {"header":"ctype.h"}, "towctrans": {"header":"wctype.h"}, @@ -515,96 +517,96 @@ "trunc": {"header":"math.h"}, "truncf": {"header":"math.h"}, "truncl": {"header":"math.h"}, - "tss_create": {"header":"threads.h"}, - "tss_delete": {"header":"threads.h"}, - "tss_get": {"header":"threads.h"}, - "tss_set": {"header":"threads.h"}, + "tss_create": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "tss_delete": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "tss_get": {"header":"threads.h", "notes":{"not-in-posix":true}}, + "tss_set": {"header":"threads.h", "notes":{"not-in-posix":true}}, "ungetc": {"header":"stdio.h"}, "ungetwc": {"header":"wchar.h"}, - "va_arg": {"header":"stdarg.h"}, - "va_copy": {"header":"stdarg.h"}, - "va_end": {"header":"stdarg.h"}, - "va_start": {"header":"stdarg.h"}, + "va_arg": {"header":"stdarg.h", "notes":{"macro":true}}, + "va_copy": {"header":"stdarg.h", "notes":{"macro":true}}, + "va_end": {"header":"stdarg.h", "notes":{"macro":true}}, + "va_start": {"header":"stdarg.h", "notes":{"macro":true}}, "vfprintf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["vfprintf_s"]}}, - "vfprintf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "vfprintf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "vfscanf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["vfscanf_s"]}}, - "vfscanf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "vfscanf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "vfwprintf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["vfwprintf_s"]}}, - "vfwprintf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "vfwprintf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "vfwscanf": {"header":"wchar.h", "notes":{"variadic":true}, "notes":{"safer-alts":["vfwscanf_s"]}}, - "vfwscanf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "vfwscanf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "vprintf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["vprintf_s"]}}, - "vprintf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "vprintf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "vscanf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["vscanf_s"]}}, - "vscanf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "vscanf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "vsnprintf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["vsnprintf_s"]}}, - "vsnprintf_s": {"header":"stdio.h", "notes":{"variadic":true}}, - "vsnwprintf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "vsnprintf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, + "vsnwprintf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "vsprintf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["vsprintf_s", "sprintf_s"]}}, - "vsprintf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "vsprintf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "vsscanf": {"header":"stdio.h", "notes":{"variadic":true, "safer-alts":["vsscanf_s"]}}, - "vsscanf_s": {"header":"stdio.h", "notes":{"variadic":true}}, + "vsscanf_s": {"header":"stdio.h", "notes":{"variadic":true, "not-in-posix":true}}, "vswprintf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["vswprintf_s", "sprintf_s"]}}, - "vswprintf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "vswprintf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "vswscanf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["vswscanf_s"]}}, - "vswscanf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "vswscanf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "vwprintf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["vwprintf_s"]}}, - "vwprintf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "vwprintf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "vwscanf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["vwscanf_s"]}}, - "vwscanf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "vwscanf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "wcrtomb": {"header":"wchar.h", "notes":{"safer-alts":["wcrtomb_s"]}}, - "wcrtomb_s": {"header":"wchar.h"}, + "wcrtomb_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wcscat": {"header":"wchar.h", "notes":{"safer-alts":["wcscat_s", "strcat_s"]}}, - "wcscat_s": {"header":"wchar.h"}, + "wcscat_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wcschr": {"header":"wchar.h"}, "wcscmp": {"header":"wchar.h"}, "wcscoll": {"header":"wchar.h"}, "wcscpy": {"header":"wchar.h", "notes":{"safer-alts":["wcscpy_s", "strcpy_s"]}}, - "wcscpy_s": {"header":"wchar.h"}, + "wcscpy_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wcscspn": {"header":"wchar.h"}, "wcsftime": {"header":"wchar.h"}, "wcslen": {"header":"wchar.h", "notes":{"safer-alts":["wcsnlen_s"]}}, "wcsncat": {"header":"wchar.h", "notes":{"safer-alts":["wcsncat_s", "strncat_s", "strlcat"]}}, - "wcsncat_s": {"header":"wchar.h"}, + "wcsncat_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wcsncmp": {"header":"wchar.h"}, "wcsncpy": {"header":"wchar.h", "notes":{"safer-alts":["wcsncpy_s", "strncpy_s", "strlcpy"]}}, - "wcsncpy_s": {"header":"wchar.h"}, - "wcsnlen_s": {"header":"wchar.h"}, + "wcsncpy_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, + "wcsnlen_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wcspbrk": {"header":"wchar.h"}, "wcsrchr": {"header":"wchar.h"}, "wcsrtombs": {"header":"wchar.h", "notes":{"safer-alts":["wcsrtombs_s"]}}, - "wcsrtombs_s": {"header":"wchar.h"}, + "wcsrtombs_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wcsspn": {"header":"wchar.h"}, "wcsstr": {"header":"wchar.h"}, "wcstod": {"header":"wchar.h"}, "wcstof": {"header":"wchar.h"}, "wcstoimax": {"header":"inttypes.h"}, "wcstok": {"header":"wchar.h", "notes":{"safer-alts":["wcstok_s"]}}, - "wcstok_s": {"header":"wchar.h"}, + "wcstok_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wcstol": {"header":"wchar.h"}, "wcstold": {"header":"wchar.h"}, "wcstoll": {"header":"wchar.h"}, "wcstombs": {"header":"stdlib.h", "notes":{"safer-alts":["wcstombs_s"]}}, - "wcstombs_s": {"header":"stdlib.h"}, + "wcstombs_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "wcstoul": {"header":"wchar.h"}, "wcstoull": {"header":"wchar.h"}, "wcstoumax": {"header":"inttypes.h"}, "wcsxfrm": {"header":"wchar.h"}, "wctob": {"header":"wchar.h"}, "wctomb": {"header":"stdlib.h", "notes":{"safer-alts":["wctomb_s"]}}, - "wctomb_s": {"header":"stdlib.h"}, + "wctomb_s": {"header":"stdlib.h", "notes":{"not-in-posix":true}}, "wctrans": {"header":"wctype.h"}, "wctype": {"header":"wctype.h"}, "wmemchr": {"header":"wchar.h"}, "wmemcmp": {"header":"wchar.h"}, "wmemcpy": {"header":"wchar.h", "notes":{"safer-alts":["wmemcpy_s"]}}, - "wmemcpy_s": {"header":"wchar.h"}, + "wmemcpy_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wmemmove": {"header":"wchar.h", "notes":{"safer-alts":["wmemmove_s"]}}, - "wmemmove_s": {"header":"wchar.h"}, + "wmemmove_s": {"header":"wchar.h", "notes":{"not-in-posix":true}}, "wmemset": {"header":"wchar.h"}, "wprintf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["wprintf_s"]}}, - "wprintf_s": {"header":"wchar.h", "notes":{"variadic":true}}, + "wprintf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}}, "wscanf": {"header":"wchar.h", "notes":{"variadic":true, "safer-alts":["wscanf_s", "sscanf_s"]}}, - "wscanf_s": {"header":"wchar.h", "notes":{"variadic":true}} + "wscanf_s": {"header":"wchar.h", "notes":{"variadic":true, "not-in-posix":true}} } } diff --git a/share/compliance/posix_identifiers.json b/share/compliance/posix_identifiers.json index 5a6d63ae92f1f57f8142d7720399f80cb5be9da1..b4badf4cb0004a8ee1a6cfd547a27f9981c0aac8 100644 --- a/share/compliance/posix_identifiers.json +++ b/share/compliance/posix_identifiers.json @@ -13,6 +13,7 @@ {"type":"macroOrIdentifier", "description":"declaration or definition; unspecified whether it is a macro or an identifier declared with external linkage"}, {"type":"macro", "description":"macro"}, {"type":"pragma", "description":"preprocessing pragma directive"}, + {"type":"reserved_name", "description":"name reserved by POSIX"}, {"type":"type", "description":"type or structure"}, {"type":"variable", "description":"external variable"} ], @@ -102,7 +103,11 @@ }, "extension_names":{ "ADV":"Advisory Information", + "BE":"Batch Environment Services and Utilities", + "CD":"C-Language Development Utilities", "CX":"Extension to the ISO C standard", + "FD":"FORTRAN Development Utilities", + "FR":"FORTRAN Runtime Utilities", "FSC":"File Synchronization", "FUT":"Reserved for future usage", "IP6":"IPV6", @@ -110,12 +115,18 @@ "ML":"Process Memory Locking", "MLR":"Range Memory Locking", "MON":"Monotonic Clock", + "MSG":"Message Passing", "OB":"Obsolescent", + "PIO":"Prioritized Input and Output", "PS":"Process Scheduling", "REM":"Removed from POSIX.1-2008 (but present in a previous version)", + "RPI":"Robust Mutex Priority Inheritance", "RPP":"Robust Mutex Priority Protection", + "RS":"Raw Sockets", + "SD":"Software Development Utilities", "SHM":"Shared Memory Objects", "SIO":"Synchronized Input and Output", + "SPN":"Spawn", "SS":"Process Sporadic Server", "TCT":"Thread CPU-Time Clocks", "TEF":"Trace Event Filter", @@ -130,6 +141,8 @@ "TSP":"Thread Sporadic Server", "TSS":"Thread Stack Size Attribute", "TYM":"Typed Memory Objects", + "UP":"User Portability Utilities", + "UU":"UUCP Utilities", "XSI":"X/Open System Interfaces", "XSR":"XSI STREAMS" }, @@ -1115,7 +1128,7 @@ "fdiml": {"id_type":"function", "header":"math.h", "extensions":[]}, "fdopen": {"id_type":"function", "header":"stdio.h", "extensions":[]}, "fdopendir": {"id_type":"function", "header":"dirent.h", "extensions":[]}, - "fds_bits": {"id_type":"IDTY", "header":"sys/select.h", "extensions":["REM"]}, + "fds_bits": {"id_type":"field", "header":"sys/select.h", "extensions":["REM"]}, "FE_ALL_EXCEPT": {"id_type":"macro", "header":"fenv.h", "extensions":[]}, "FE_DFL_ENV": {"id_type":"macro", "header":"fenv.h", "extensions":[]}, "FE_DIVBYZERO": {"id_type":"macro", "header":"fenv.h", "extensions":[]}, @@ -3426,7 +3439,7 @@ "utimes": {"id_type":"function", "header":"sys/time.h", "extensions":[]}, "utmpx": {"id_type":"type", "header":"utmpx.h", "extensions":[]}, "utsname": {"id_type":"type", "header":"sys/utsname.h", "extensions":[]}, - "va_arg": {"id_type":"type", "header":"stdarg.h", "extensions":[]}, + "va_arg": {"id_type":"macro", "header":"stdarg.h", "extensions":[]}, "va_copy": {"id_type":"macro", "header":"stdarg.h", "extensions":[]}, "va_end": {"id_type":"macro", "header":"stdarg.h", "extensions":[]}, "va_list": {"id_type":"type", "header":"stdarg.h", "extensions":[]}, diff --git a/tests/compliance/check-json.i b/tests/compliance/check-json.i index b4c5e6c33fc7f804398a3320873a02c67a4440cc..99a889344abf1496eaf7701a4e17589f3d3611cf 100644 --- a/tests/compliance/check-json.i +++ b/tests/compliance/check-json.i @@ -5,4 +5,5 @@ EXECNOW: LOG json_@PTEST_NAME@_2.txt python3 -m json.tool < @SHARE@/glibc_functions.json | head -n 2 > @PTEST_RESULT@/json_@PTEST_NAME@_2.txt 2> @DEV_NULL@ EXECNOW: LOG json_@PTEST_NAME@_3.txt python3 -m json.tool < @SHARE@/nonstandard_identifiers.json | head -n 2 > @PTEST_RESULT@/json_@PTEST_NAME@_3.txt 2> @DEV_NULL@ EXECNOW: LOG json_@PTEST_NAME@_4.txt python3 -m json.tool < @SHARE@/posix_identifiers.json | head -n 2 > @PTEST_RESULT@/json_@PTEST_NAME@_4.txt 2> @DEV_NULL@ + EXECNOW: LOG json_@PTEST_NAME@_5.txt python3 @PTEST_DIR@/sanity-checks.py @SHARE@ > @PTEST_RESULT@/json_@PTEST_NAME@_5.txt 2> @DEV_NULL@ */ diff --git a/tests/compliance/oracle/json_check-json_1.txt b/tests/compliance/oracle/json_check-json_1.txt index 1c7fc7039ae9a32a7e24b026fa194ade1cc32984..1b5870264ab3d7511f6c0ec3cce36b2ddf76554c 100644 --- a/tests/compliance/oracle/json_check-json_1.txt +++ b/tests/compliance/oracle/json_check-json_1.txt @@ -1,2 +1,2 @@ { - "description": "C11 reserved function identifiers", + "description": "C11 reserved function and macro identifiers", diff --git a/tests/compliance/oracle/json_check-json_5.txt b/tests/compliance/oracle/json_check-json_5.txt new file mode 100644 index 0000000000000000000000000000000000000000..7a7ac78c07c94eab5f3e5cbdd027727aa0dd3148 --- /dev/null +++ b/tests/compliance/oracle/json_check-json_5.txt @@ -0,0 +1,2 @@ +../../../share/compliance/posix_identifiers.json checked. +../../../share/compliance/c11_functions.json checked. diff --git a/tests/compliance/sanity-checks.py b/tests/compliance/sanity-checks.py new file mode 100755 index 0000000000000000000000000000000000000000..3a7418b6414ecad96ed170dd867841fd0c6ac54f --- /dev/null +++ b/tests/compliance/sanity-checks.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 +#-*- coding: utf-8 -*- + +# Perform some sanity checks related to the compliance JSON files + +import json +import sys +from pathlib import Path + +if len(sys.argv) < 2: + sys.exit(f"usage: {sys.argv[0]} dir (where dir is FRAMAC_SHARE/compliance)") + +compliance_dir = sys.argv[1] + +posix_ids_path = Path(compliance_dir) / "posix_identifiers.json" +posix_headers = set() +posix_dict = {} +with open(posix_ids_path) as data: + js = json.load(data) + posix_dict = js["data"] + id_types = set(e["type"] for e in js["id_types"]) + posix_headers = set(js["headers"].keys()) + extension_names = set(js["extension_names"].keys()) + unique_ids = set() + for (i, v) in posix_dict.items(): + if i in unique_ids: + sys.exit("duplicate id {i}") + unique_ids.add(i) + id_type = v["id_type"] + if id_type not in id_types: + sys.exit(f"error: unknown id_type '{id_type}' for id {i}") + header = v["header"] + if header not in posix_headers: + sys.exit(f"error: unknown header {header} for id {i}") + exts = set(v["extensions"]) + unknown_exts = exts - extension_names + if unknown_exts: + sys.exit(f"error: unknown extension(s) {unknown_exts} for id {i}") +print(f"{posix_ids_path} checked.") + +c11_headers_path = Path(compliance_dir) / "c11_headers.json" +c11_headers = [] +with open(c11_headers_path) as data: + js = json.load(data) + c11_headers = js["data"] + +c11_funs_path = Path(compliance_dir) / "c11_functions.json" +c11_funs = [] +with open(c11_funs_path) as data: + js = json.load(data) + c11_funs = js["data"] + +for (i, v) in c11_funs.items(): + header = v["header"] + if header not in c11_headers: + sys.exit(f"error: unknown header {header} for id {i}") + if i not in posix_dict: + if "notes" in v: + if "not-in-posix" not in v["notes"]: + print(f"warning: C11 identifier unexpectedly not in POSIX: {i}") + else: + if "notes" in v and "not-in-posix" in v["notes"]: + print(f"warning: C11 identifier unexpectedly found in POSIX: {i}") + id_type = posix_dict[i]["id_type"] + if id_type != "function": + if "notes" in v and "macro" in v["notes"]: + if id_type != "macro": + print(f"warning: C11 macro {i} is not a macro in POSIX, but a {id_type}") + else: + print(f"warning: C11 function {i} is not a function in POSIX, but a {id_type}") + posix_header = posix_dict[i]["header"] + if header != posix_header: + sys.exit(f"error: C11 function {i} mapped to header {header}, but in POSIX it is mapped to header {posix_header}") +print(f"{c11_funs_path} checked.")