diff --git a/make_machdep/alignof_double.c b/make_machdep/alignof_double.c new file mode 100644 index 0000000000000000000000000000000000000000..638d4749eda51d26b49dda6fae317cbccf1619b0 --- /dev/null +++ b/make_machdep/alignof_double.c @@ -0,0 +1,10 @@ +#include "make_machdep_common.h" + +_Static_assert(ALIGNOF(double) != 1, "alignof_double is 1"); +_Static_assert(ALIGNOF(double) != 2, "alignof_double is 2"); +_Static_assert(ALIGNOF(double) != 3, "alignof_double is 3"); +_Static_assert(ALIGNOF(double) != 4, "alignof_double is 4"); +_Static_assert(ALIGNOF(double) != 5, "alignof_double is 5"); +_Static_assert(ALIGNOF(double) != 6, "alignof_double is 6"); +_Static_assert(ALIGNOF(double) != 7, "alignof_double is 7"); +_Static_assert(ALIGNOF(double) != 8, "alignof_double is 8"); diff --git a/make_machdep/alignof_float.c b/make_machdep/alignof_float.c new file mode 100644 index 0000000000000000000000000000000000000000..93a87cbec67a60947f65b2e6ded13d9f5fd7e70e --- /dev/null +++ b/make_machdep/alignof_float.c @@ -0,0 +1,10 @@ +#include "make_machdep_common.h" + +_Static_assert(ALIGNOF(float) != 1, "alignof_float is 1"); +_Static_assert(ALIGNOF(float) != 2, "alignof_float is 2"); +_Static_assert(ALIGNOF(float) != 3, "alignof_float is 3"); +_Static_assert(ALIGNOF(float) != 4, "alignof_float is 4"); +_Static_assert(ALIGNOF(float) != 5, "alignof_float is 5"); +_Static_assert(ALIGNOF(float) != 6, "alignof_float is 6"); +_Static_assert(ALIGNOF(float) != 7, "alignof_float is 7"); +_Static_assert(ALIGNOF(float) != 8, "alignof_float is 8"); diff --git a/make_machdep/alignof_fun.c b/make_machdep/alignof_fun.c index ee33251515fc681989f245971763b5d45011c331..6d3ba20a8a62a52bd73ad6cf9e997a2ce53f7c8c 100644 --- a/make_machdep/alignof_fun.c +++ b/make_machdep/alignof_fun.c @@ -1,5 +1,10 @@ #include "make_machdep_common.h" -int main(void); - -unsigned char alignof_fun = ALIGNOF(main); +_Static_assert(ALIGNOF(void ()) != 1, "alignof_fun is 1"); +_Static_assert(ALIGNOF(void ()) != 2, "alignof_fun is 2"); +_Static_assert(ALIGNOF(void ()) != 3, "alignof_fun is 3"); +_Static_assert(ALIGNOF(void ()) != 4, "alignof_fun is 4"); +_Static_assert(ALIGNOF(void ()) != 5, "alignof_fun is 5"); +_Static_assert(ALIGNOF(void ()) != 6, "alignof_fun is 6"); +_Static_assert(ALIGNOF(void ()) != 7, "alignof_fun is 7"); +_Static_assert(ALIGNOF(void ()) != 8, "alignof_fun is 8"); diff --git a/make_machdep/alignof_int.c b/make_machdep/alignof_int.c new file mode 100644 index 0000000000000000000000000000000000000000..db2098074713c5a423e49cd1b9e473a53fd54cdb --- /dev/null +++ b/make_machdep/alignof_int.c @@ -0,0 +1,9 @@ +#include "make_machdep_common.h" +_Static_assert(ALIGNOF(int) != 1, "alignof_int is 1"); +_Static_assert(ALIGNOF(int) != 2, "alignof_int is 2"); +_Static_assert(ALIGNOF(int) != 3, "alignof_int is 3"); +_Static_assert(ALIGNOF(int) != 4, "alignof_int is 4"); +_Static_assert(ALIGNOF(int) != 5, "alignof_int is 5"); +_Static_assert(ALIGNOF(int) != 6, "alignof_int is 6"); +_Static_assert(ALIGNOF(int) != 7, "alignof_int is 7"); +_Static_assert(ALIGNOF(int) != 8, "alignof_int is 8"); diff --git a/make_machdep/alignof_long.c b/make_machdep/alignof_long.c new file mode 100644 index 0000000000000000000000000000000000000000..2939718ac29b6e771c91f5c44ff59ff933c096b6 --- /dev/null +++ b/make_machdep/alignof_long.c @@ -0,0 +1,9 @@ +#include "make_machdep_common.h" +_Static_assert(ALIGNOF(long) != 1, "alignof_long is 1"); +_Static_assert(ALIGNOF(long) != 2, "alignof_long is 2"); +_Static_assert(ALIGNOF(long) != 3, "alignof_long is 3"); +_Static_assert(ALIGNOF(long) != 4, "alignof_long is 4"); +_Static_assert(ALIGNOF(long) != 5, "alignof_long is 5"); +_Static_assert(ALIGNOF(long) != 6, "alignof_long is 6"); +_Static_assert(ALIGNOF(long) != 7, "alignof_long is 7"); +_Static_assert(ALIGNOF(long) != 8, "alignof_long is 8"); diff --git a/make_machdep/alignof_longdouble.c b/make_machdep/alignof_longdouble.c index 77a0599315744e3de19df4f372d9116fbcbca118..3bec841257b133e15b5b161846207f240a262e12 100644 --- a/make_machdep/alignof_longdouble.c +++ b/make_machdep/alignof_longdouble.c @@ -1,3 +1,18 @@ #include "make_machdep_common.h" -unsigned char alignof_longdouble = ALIGNOF(long double); +_Static_assert(ALIGNOF(long double) != 1, "alignof_longdouble is 1"); +_Static_assert(ALIGNOF(long double) != 2, "alignof_longdouble is 2"); +_Static_assert(ALIGNOF(long double) != 3, "alignof_longdouble is 3"); +_Static_assert(ALIGNOF(long double) != 4, "alignof_longdouble is 4"); +_Static_assert(ALIGNOF(long double) != 5, "alignof_longdouble is 5"); +_Static_assert(ALIGNOF(long double) != 6, "alignof_longdouble is 6"); +_Static_assert(ALIGNOF(long double) != 7, "alignof_longdouble is 7"); +_Static_assert(ALIGNOF(long double) != 8, "alignof_longdouble is 8"); +_Static_assert(ALIGNOF(long double) != 9, "alignof_longdouble is 9"); +_Static_assert(ALIGNOF(long double) != 10, "alignof_longdouble is 10"); +_Static_assert(ALIGNOF(long double) != 11, "alignof_longdouble is 11"); +_Static_assert(ALIGNOF(long double) != 12, "alignof_longdouble is 12"); +_Static_assert(ALIGNOF(long double) != 13, "alignof_longdouble is 13"); +_Static_assert(ALIGNOF(long double) != 14, "alignof_longdouble is 14"); +_Static_assert(ALIGNOF(long double) != 15, "alignof_longdouble is 15"); +_Static_assert(ALIGNOF(long double) != 16, "alignof_longdouble is 16"); diff --git a/make_machdep/alignof_longlong.c b/make_machdep/alignof_longlong.c new file mode 100644 index 0000000000000000000000000000000000000000..cb808ff6e687694fea5c8c62f0687c6ebf3fc68f --- /dev/null +++ b/make_machdep/alignof_longlong.c @@ -0,0 +1,9 @@ +#include "make_machdep_common.h" +_Static_assert(ALIGNOF(long long) != 1, "alignof_longlong is 1"); +_Static_assert(ALIGNOF(long long) != 2, "alignof_longlong is 2"); +_Static_assert(ALIGNOF(long long) != 3, "alignof_longlong is 3"); +_Static_assert(ALIGNOF(long long) != 4, "alignof_longlong is 4"); +_Static_assert(ALIGNOF(long long) != 5, "alignof_longlong is 5"); +_Static_assert(ALIGNOF(long long) != 6, "alignof_longlong is 6"); +_Static_assert(ALIGNOF(long long) != 7, "alignof_longlong is 7"); +_Static_assert(ALIGNOF(long long) != 8, "alignof_longlong is 8"); diff --git a/make_machdep/alignof_ptr.c b/make_machdep/alignof_ptr.c new file mode 100644 index 0000000000000000000000000000000000000000..92b094544da4e0cd232cffa4b236739e008502bd --- /dev/null +++ b/make_machdep/alignof_ptr.c @@ -0,0 +1,10 @@ +#include "make_machdep_common.h" + +_Static_assert(ALIGNOF(void *) != 1, "alignof_ptr is 1"); +_Static_assert(ALIGNOF(void *) != 2, "alignof_ptr is 2"); +_Static_assert(ALIGNOF(void *) != 3, "alignof_ptr is 3"); +_Static_assert(ALIGNOF(void *) != 4, "alignof_ptr is 4"); +_Static_assert(ALIGNOF(void *) != 5, "alignof_ptr is 5"); +_Static_assert(ALIGNOF(void *) != 6, "alignof_ptr is 6"); +_Static_assert(ALIGNOF(void *) != 7, "alignof_ptr is 7"); +_Static_assert(ALIGNOF(void *) != 8, "alignof_ptr is 8"); diff --git a/make_machdep/alignof_short.c b/make_machdep/alignof_short.c new file mode 100644 index 0000000000000000000000000000000000000000..bbad8d49c13b14d7568dd39235fa916dd7b769bf --- /dev/null +++ b/make_machdep/alignof_short.c @@ -0,0 +1,9 @@ +#include "make_machdep_common.h" +_Static_assert(ALIGNOF(short) != 1, "alignof_short is 1"); +_Static_assert(ALIGNOF(short) != 2, "alignof_short is 2"); +_Static_assert(ALIGNOF(short) != 3, "alignof_short is 3"); +_Static_assert(ALIGNOF(short) != 4, "alignof_short is 4"); +_Static_assert(ALIGNOF(short) != 5, "alignof_short is 5"); +_Static_assert(ALIGNOF(short) != 6, "alignof_short is 6"); +_Static_assert(ALIGNOF(short) != 7, "alignof_short is 7"); +_Static_assert(ALIGNOF(short) != 8, "alignof_short is 8"); diff --git a/make_machdep/alignof_str.c b/make_machdep/alignof_str.c index 77c8ea19c76cd8476bf9d56a9c4cc62a934af220..86d50e598ca1c9658168598de844a9aa74bbb301 100644 --- a/make_machdep/alignof_str.c +++ b/make_machdep/alignof_str.c @@ -1,3 +1,10 @@ #include "make_machdep_common.h" -unsigned char alignof_str = ALIGNOF("literal string"); +_Static_assert(ALIGNOF("test string") != 1, "alignof_str is 1"); +_Static_assert(ALIGNOF("test string") != 2, "alignof_str is 2"); +_Static_assert(ALIGNOF("test string") != 3, "alignof_str is 3"); +_Static_assert(ALIGNOF("test string") != 4, "alignof_str is 4"); +_Static_assert(ALIGNOF("test string") != 5, "alignof_str is 5"); +_Static_assert(ALIGNOF("test string") != 6, "alignof_str is 6"); +_Static_assert(ALIGNOF("test string") != 7, "alignof_str is 7"); +_Static_assert(ALIGNOF("test string") != 8, "alignof_str is 8"); diff --git a/make_machdep/make_machdep.py b/make_machdep/make_machdep.py index bf68467450ae8e6d5b0084d321f18774b9a44d65..8b9d6519d0a0ef012433a907f883b31f6d676015 100755 --- a/make_machdep/make_machdep.py +++ b/make_machdep/make_machdep.py @@ -8,6 +8,7 @@ Prerequisites: - A C11-compatible (cross-)compiler (with support for _Generic), or a (cross-)compiler having __builtin_types_compatible_p +- A (cross-)compiler supporting _Static_assert - A (cross-)compiler supporting _Alignof or alignof - objdump @@ -29,98 +30,40 @@ cases and output warnings, but without preventing compilation of the rest. """ import argparse +import json from pathlib import Path import re import subprocess import sys - -re_symbol_name = re.compile("^[0-9a-fA-F]+ <([^>]+)>: *$") - -# Parsing objdump's format is not trivial: some versions print results as: -# <offset>: 01 02 03 04 <assembly> -# That is, bytes separated by single spaces, then several spaces, then assembly; -# while other versions (e.g. for mips) print several bytes together: -# <offset>: 01020304 <assembly> -# So we simply take all hexadecimal characters until the end of the line, -# and then split as soon as 2 consecutive spaces are found. -# Otherwise, we might end up considering instructions such as 'add' as part -# of the data. -# Unfortunately, objdump does not contain an option to display the data bytes -# themselves _without_ the disassembled data. -re_symbol_data = re.compile("^ *[0-9a-fA-F]+:[ \t]+([0-9a-fA-F ]+)") +import warnings parser = argparse.ArgumentParser(prog="make_machdep") parser.add_argument("-v", "--verbose", action="store_true") +parser.add_argument("-o", default=sys.stdout,type=argparse.Filetype('w'),dest="dest_file") parser.add_argument("--compiler") parser.add_argument("--compiler-version") parser.add_argument("--cpp-arch-flags", nargs="+", default=[], help="architecture-specific flags needed for preprocessing, e.g. '-m32'") parser.add_argument("--compiler-flags", nargs="+", default=["-c"], help="flags to be given to the compiler (other than those set by --cpp-arch-flags); by default, '-c'") -parser.add_argument("--objdump", action="store", help="objdump command to use", default="objdump") +parser.add_argument("--check", action="store_true") args, other_args = parser.parse_known_args() def print_machdep(machdep): - print("open Cil_types") - print("") - print("let machdep : mach = {") - for f, v in machdep.items(): - if isinstance(v, str): - print(f" {f} = \"{v}\";") - elif isinstance(v, bool): - print(f" {f} = {'true' if v else 'false'};") - elif isinstance(v, list): - l = ", ".join([f'"{e}"' for e in v]) - print(f" {f} = [{l}];") - else: - print(f" {f} = {v};") + json.dump(machdep,args.dest_file,indent=4,sort_keys=True) - print("}") +fc_share=subprocess.run("frama-c-config -print-share-path",capture_output=True).output + +def check_machdep(machdep): + try: + from jsonschema import validate, ValidationError + with open(fc_share+"/machdeps/machdep-schema.json", "r") as schema: + validate(machdep, json.load(schema)) + except ImportError: + warnings.warn("jsonschema is not available: no validation will be performed") + except OSError: + warnings.warn("error opening machdep-schema.json: no validation will be performed") + except ValidationError: + warnings.warn("machdep object is not conforming to machdep schema") -def decode_object_file(objfile, section=".data"): - command = [args.objdump, "-j" + section, "-d", str(objfile)] - if args.verbose: - print(f"[INFO] running command: {' '.join(command)}") - proc = subprocess.run(command, capture_output=True) - if proc.returncode != 0: - # Special case where objdump _may_ fail: section other than '.data' - if section != ".data": - return [], None - print(f"error: command returned non-zero ({proc.returncode}): {' '.join(command)}") - if args.verbose: - print(proc.stderr.decode("utf-8")) - sys.exit(1) - symbols = {} - cur_symbol = None - underscore_name = None - for line in proc.stdout.decode("utf-8").split("\n"): - m = re_symbol_name.match(line) - if m: - #print(f"found symbol: [{m.group(1)}]") - cur_symbol = m.group(1) - continue - m = re_symbol_data.match(line) - if m: - #print(f"found data: {m.group(1)}") - if not cur_symbol: - # This can happen when objdump decides to print more than one - # line from the starting offset - continue - #sys.exit(f"error: found data without symbol") - octet_string = m.group(1) - if " " in octet_string: - [octet_string, _rest] = octet_string.split(" ", maxsplit=1) - octet_string = octet_string.replace(" ", "") - octets = [] - for i in range(0, len(octet_string) // 2): - octets.append(int(octet_string[2*i:2*i+2], 16)) - # We assume all values fit in 1 byte (sizeof and alignof); - # for the literal string, the first byte is enough. - # We profit from having the symbol name to fill a special machdep field. - underscore_name = cur_symbol.startswith("_") - s = cur_symbol.strip("_") # Normalize symbol names - symbols[s] = octets[0] - cur_symbol = None - continue - return symbols, underscore_name # This must remain synchronized with cil_types.ml's 'mach' type machdep = { @@ -161,10 +104,24 @@ machdep = { compilation_command = other_args + args.compiler_flags source_files = [ + ("sizeof_short.i", "number"), + ("sizeof_int.i", "number"), + ("sizeof_long.i", "number"), + ("sizeof_longlong.i", "number"), + ("sizeof_ptr.i", "number"), + ("sizeof_float.i", "number"), + ("sizeof_double.i", "number"), + ("sizeof_longdouble.i", "number"), + ("sizeof_void.i", "number"), + ("sizeof_fun.i", "number"), ("sizeof_alignof_standard.c", "number"), - ("sizeof_void.c", "number"), - ("sizeof_fun.c", "number"), - ("sizeof_longdouble.c", "number"), + ("alignof_short.c", "number"), + ("alignof_int.c", "number"), + ("alignof_long.c", "number"), + ("alignof_longlong.c", "number"), + ("alignof_ptr.c", "number"), + ("alignof_float.c", "number"), + ("alignof_double.c", "number"), ("alignof_longdouble.c", "number"), ("alignof_fun.c", "number"), ("alignof_str.c", "number"), diff --git a/make_machdep/make_machdep_common.h b/make_machdep/make_machdep_common.h index aecf880bf9b009ff2faa3276578c48a3264b5de8..46e98a4d20c3b5b63310763b215b3932decc4761 100644 --- a/make_machdep/make_machdep_common.h +++ b/make_machdep/make_machdep_common.h @@ -8,17 +8,18 @@ #if __STDC_VERSION__ >= 201112L || defined(__COMPCERT__) // Assume _Generic() is supported # define COMPATIBLE(T1, T2) _Generic(((T1){0}), \ - T2: 0x15, \ - default: 0xf4 \ + T2: 1, \ + default: 0 \ ) #else // Expect that __builtin_types_compatible_p exists # define COMPATIBLE(T1, T2) (__builtin_types_compatible_p(T1, T2) ? 0x15 : 0xf4) #endif -#define TEST_TYPE_IS_HELPER1(test_type, type) test_type ## _IS_ ## type -#define TEST_TYPE_IS_HELPER2(test_type, type) TEST_TYPE_IS_HELPER1(test_type, type) -#define TEST_TYPE_IS(type) TEST_TYPE_IS_HELPER2(TEST_TYPE, type) +// needed to ensure the message is properly expanded for TEST_TYPE_IS +#define mkstr(s) #s -#define TEST_TYPE_MAYBE(type) unsigned char TEST_TYPE_IS(type) = COMPATIBLE(TEST_TYPE, type) -#define TEST_TYPE_MAYBE_(type, type_) unsigned char TEST_TYPE_IS(type_) = COMPATIBLE(TEST_TYPE, type) +#define TEST_TYPE_COMPATIBLE(T1,T2) \ + _Static_assert(!COMPATIBLE(T1,T2),"" mkstr(T2) " is " #T1); + +#define TEST_TYPE_IS(type) TEST_TYPE_COMPATIBLE(type, TEST_TYPE) diff --git a/make_machdep/ptrdiff_t.c b/make_machdep/ptrdiff_t.c index 13c895bdcf5b7819b549f7c5ca20847e5f761353..e19be36f09fdc4af927a36bb6928c36d4acecce5 100644 --- a/make_machdep/ptrdiff_t.c +++ b/make_machdep/ptrdiff_t.c @@ -2,5 +2,6 @@ #include <stddef.h> #define TEST_TYPE ptrdiff_t -TEST_TYPE_MAYBE(int); -TEST_TYPE_MAYBE(long); +TEST_TYPE_IS(int); +TEST_TYPE_IS(long); +TEST_TYPE_IS(long long); diff --git a/make_machdep/size_t.c b/make_machdep/size_t.c index 586f9b6ffaef54988e6eb1d7101f66028f1c6290..c853b2705090b1ecc8d7f4a709ed307dc99bbf79 100644 --- a/make_machdep/size_t.c +++ b/make_machdep/size_t.c @@ -1,6 +1,5 @@ -#include "make_machdep_common.h" #include <stddef.h> -#define TEST_TYPE size_t +#include "make_machdep_common.h" -TEST_TYPE_MAYBE_(unsigned int, unsigned_int); -TEST_TYPE_MAYBE_(unsigned long, unsigned_long); +_Static_assert(!COMPATIBLE(unsigned int, size_t), "size_t is unsigned int"); +_Static_assert(!COMPATIBLE(unsigned long, size_t), "size_t is unsigned long"); diff --git a/make_machdep/sizeof_double.i b/make_machdep/sizeof_double.i new file mode 100644 index 0000000000000000000000000000000000000000..e03d044bedc26e82dd2ec9729bbfe49e98a4971e --- /dev/null +++ b/make_machdep/sizeof_double.i @@ -0,0 +1,8 @@ +_Static_assert(sizeof(double) != 1, "sizeof_double is 1"); +_Static_assert(sizeof(double) != 2, "sizeof_double is 2"); +_Static_assert(sizeof(double) != 3, "sizeof_double is 3"); +_Static_assert(sizeof(double) != 4, "sizeof_double is 4"); +_Static_assert(sizeof(double) != 5, "sizeof_double is 5"); +_Static_assert(sizeof(double) != 6, "sizeof_double is 6"); +_Static_assert(sizeof(double) != 7, "sizeof_double is 7"); +_Static_assert(sizeof(double) != 8, "sizeof_double is 8"); diff --git a/make_machdep/sizeof_float.i b/make_machdep/sizeof_float.i new file mode 100644 index 0000000000000000000000000000000000000000..e3c22a3f78f4c9edc8f81154722947632bcd294a --- /dev/null +++ b/make_machdep/sizeof_float.i @@ -0,0 +1,8 @@ +_Static_assert(sizeof(float) != 1, "sizeof_float is 1"); +_Static_assert(sizeof(float) != 2, "sizeof_float is 2"); +_Static_assert(sizeof(float) != 3, "sizeof_float is 3"); +_Static_assert(sizeof(float) != 4, "sizeof_float is 4"); +_Static_assert(sizeof(float) != 5, "sizeof_float is 5"); +_Static_assert(sizeof(float) != 6, "sizeof_float is 6"); +_Static_assert(sizeof(float) != 7, "sizeof_float is 7"); +_Static_assert(sizeof(float) != 8, "sizeof_float is 8"); diff --git a/make_machdep/sizeof_fun.i b/make_machdep/sizeof_fun.i new file mode 100644 index 0000000000000000000000000000000000000000..9b893dbab6913ee5dbec41e5deeea526da7f194a --- /dev/null +++ b/make_machdep/sizeof_fun.i @@ -0,0 +1 @@ +_Static_assert(sizeof(void ()) != 1, "sizeof_fun is 1"); diff --git a/make_machdep/sizeof_int.i b/make_machdep/sizeof_int.i new file mode 100644 index 0000000000000000000000000000000000000000..758a8da7b26c4e92507ddddeec88c0fe17cdb0c6 --- /dev/null +++ b/make_machdep/sizeof_int.i @@ -0,0 +1,8 @@ +_Static_assert(sizeof(int) != 1, "sizeof_int is 1"); +_Static_assert(sizeof(int) != 2, "sizeof_int is 2"); +_Static_assert(sizeof(int) != 3, "sizeof_int is 3"); +_Static_assert(sizeof(int) != 4, "sizeof_int is 4"); +_Static_assert(sizeof(int) != 5, "sizeof_int is 5"); +_Static_assert(sizeof(int) != 6, "sizeof_int is 6"); +_Static_assert(sizeof(int) != 7, "sizeof_int is 7"); +_Static_assert(sizeof(int) != 8, "sizeof_int is 8"); diff --git a/make_machdep/sizeof_long.i b/make_machdep/sizeof_long.i new file mode 100644 index 0000000000000000000000000000000000000000..029c6a771b624580476002f478a7965ac0ae7502 --- /dev/null +++ b/make_machdep/sizeof_long.i @@ -0,0 +1,8 @@ +_Static_assert(sizeof(long) != 1, "sizeof_long is 1"); +_Static_assert(sizeof(long) != 2, "sizeof_long is 2"); +_Static_assert(sizeof(long) != 3, "sizeof_long is 3"); +_Static_assert(sizeof(long) != 4, "sizeof_long is 4"); +_Static_assert(sizeof(long) != 5, "sizeof_long is 5"); +_Static_assert(sizeof(long) != 6, "sizeof_long is 6"); +_Static_assert(sizeof(long) != 7, "sizeof_long is 7"); +_Static_assert(sizeof(long) != 8, "sizeof_long is 8"); diff --git a/make_machdep/sizeof_longdouble.i b/make_machdep/sizeof_longdouble.i new file mode 100644 index 0000000000000000000000000000000000000000..d76733dce3cc0a8c0b2ec0f1c68902b660c35545 --- /dev/null +++ b/make_machdep/sizeof_longdouble.i @@ -0,0 +1,16 @@ +_Static_assert(sizeof(long double) != 1, "sizeof_longdouble is 1"); +_Static_assert(sizeof(long double) != 2, "sizeof_longdouble is 2"); +_Static_assert(sizeof(long double) != 3, "sizeof_longdouble is 3"); +_Static_assert(sizeof(long double) != 4, "sizeof_longdouble is 4"); +_Static_assert(sizeof(long double) != 5, "sizeof_longdouble is 5"); +_Static_assert(sizeof(long double) != 6, "sizeof_longdouble is 6"); +_Static_assert(sizeof(long double) != 7, "sizeof_longdouble is 7"); +_Static_assert(sizeof(long double) != 8, "sizeof_longdouble is 8"); +_Static_assert(sizeof(long double) != 9, "sizeof_longdouble is 9"); +_Static_assert(sizeof(long double) != 10, "sizeof_longdouble is 10"); +_Static_assert(sizeof(long double) != 11, "sizeof_longdouble is 11"); +_Static_assert(sizeof(long double) != 12, "sizeof_longdouble is 12"); +_Static_assert(sizeof(long double) != 13, "sizeof_longdouble is 13"); +_Static_assert(sizeof(long double) != 14, "sizeof_longdouble is 14"); +_Static_assert(sizeof(long double) != 15, "sizeof_longdouble is 15"); +_Static_assert(sizeof(long double) != 16, "sizeof_longdouble is 16"); diff --git a/make_machdep/sizeof_longlong.i b/make_machdep/sizeof_longlong.i new file mode 100644 index 0000000000000000000000000000000000000000..ce3b1c7e738ee3c280473a9e4209d4c653b90e88 --- /dev/null +++ b/make_machdep/sizeof_longlong.i @@ -0,0 +1,8 @@ +_Static_assert(sizeof(long long) != 1, "sizeof_longlong is 1"); +_Static_assert(sizeof(long long) != 2, "sizeof_longlong is 2"); +_Static_assert(sizeof(long long) != 3, "sizeof_longlong is 3"); +_Static_assert(sizeof(long long) != 4, "sizeof_longlong is 4"); +_Static_assert(sizeof(long long) != 5, "sizeof_longlong is 5"); +_Static_assert(sizeof(long long) != 6, "sizeof_longlong is 6"); +_Static_assert(sizeof(long long) != 7, "sizeof_longlong is 7"); +_Static_assert(sizeof(long long) != 8, "sizeof_longlong is 8"); diff --git a/make_machdep/sizeof_ptr.i b/make_machdep/sizeof_ptr.i new file mode 100644 index 0000000000000000000000000000000000000000..359e2f962a9c1cb5dcc33e40c76bc4916a9d3a0d --- /dev/null +++ b/make_machdep/sizeof_ptr.i @@ -0,0 +1,8 @@ +_Static_assert(sizeof(void *) != 1, "sizeof_ptr is 1"); +_Static_assert(sizeof(void *) != 2, "sizeof_ptr is 2"); +_Static_assert(sizeof(void *) != 3, "sizeof_ptr is 3"); +_Static_assert(sizeof(void *) != 4, "sizeof_ptr is 4"); +_Static_assert(sizeof(void *) != 5, "sizeof_ptr is 5"); +_Static_assert(sizeof(void *) != 6, "sizeof_ptr is 6"); +_Static_assert(sizeof(void *) != 7, "sizeof_ptr is 7"); +_Static_assert(sizeof(void *) != 8, "sizeof_ptr is 8"); diff --git a/make_machdep/sizeof_short.i b/make_machdep/sizeof_short.i new file mode 100644 index 0000000000000000000000000000000000000000..299d215175573cf1efb0946ace6bb89b86419e83 --- /dev/null +++ b/make_machdep/sizeof_short.i @@ -0,0 +1,8 @@ +_Static_assert(sizeof(short) != 1, "sizeof_short is 1"); +_Static_assert(sizeof(short) != 2, "sizeof_short is 2"); +_Static_assert(sizeof(short) != 3, "sizeof_short is 3"); +_Static_assert(sizeof(short) != 4, "sizeof_short is 4"); +_Static_assert(sizeof(short) != 5, "sizeof_short is 5"); +_Static_assert(sizeof(short) != 6, "sizeof_short is 6"); +_Static_assert(sizeof(short) != 7, "sizeof_short is 7"); +_Static_assert(sizeof(short) != 8, "sizeof_short is 8"); diff --git a/make_machdep/sizeof_void.i b/make_machdep/sizeof_void.i new file mode 100644 index 0000000000000000000000000000000000000000..c5f0e53a77bdb82e8078ae31db54ee2f49553928 --- /dev/null +++ b/make_machdep/sizeof_void.i @@ -0,0 +1 @@ +_Static_assert(sizeof(void)!=1,"sizeof_void is 1"); diff --git a/make_machdep/wchar_t.c b/make_machdep/wchar_t.c index 40825fdf07a46c10034d9f4b21df74eb458b879c..564963d211e1b4d6e600205b003eda1f34c8705d 100644 --- a/make_machdep/wchar_t.c +++ b/make_machdep/wchar_t.c @@ -2,8 +2,9 @@ #include <stddef.h> #define TEST_TYPE wchar_t -TEST_TYPE_MAYBE_(unsigned short, unsigned_short); -TEST_TYPE_MAYBE(short); -TEST_TYPE_MAYBE_(unsigned int, unsigned_int); -TEST_TYPE_MAYBE(int); -TEST_TYPE_MAYBE(long); +TEST_TYPE_IS(unsigned short) +TEST_TYPE_IS(short) +TEST_TYPE_IS(unsigned int) +TEST_TYPE_IS(int) +TEST_TYPE_IS(unsigned long) +TEST_TYPE_IS(long)