scripts: gen_syscalls: Add compiler check to pragma.
This commit addresses the following portability issues: 1. gen_syscalls incorrectly assumes that the compiler is always GCC. 2. pragma GCC diagnostic push and pop are not supported in GCC < 4.6. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
parent
ce46e0df4d
commit
2a1c6258fa
1 changed files with 13 additions and 0 deletions
|
@ -80,8 +80,13 @@ syscall_template = """
|
|||
#include <syscall_list.h>
|
||||
#include <syscall_macros.h>
|
||||
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#pragma GCC diagnostic push
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -93,7 +98,9 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* include guard */
|
||||
|
@ -411,12 +418,18 @@ def main():
|
|||
|
||||
with open(mrsh_fn, "w") as fp:
|
||||
fp.write("/* auto-generated by gen_syscalls.py, don't edit */\n")
|
||||
fp.write("#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)\n")
|
||||
fp.write("#pragma GCC diagnostic push\n")
|
||||
fp.write("#endif\n")
|
||||
fp.write("#ifdef __GNUC__\n")
|
||||
fp.write("#pragma GCC diagnostic ignored \"-Wstrict-aliasing\"\n")
|
||||
fp.write("#endif\n")
|
||||
fp.write(mrsh_includes[fn] + "\n")
|
||||
fp.write("\n")
|
||||
fp.write(mrsh_defs[fn] + "\n")
|
||||
fp.write("#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)\n")
|
||||
fp.write("#pragma GCC diagnostic pop\n")
|
||||
fp.write("#endif\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue