Generate assembler system call stubs via genrule.
There's no need to check in generated code.
Test: builds & boots
Change-Id: Ife368bca4349d4adeb0666db590356196b4fbd63
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 9b6dc81..b307486 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -8,7 +8,6 @@
import commands
import filecmp
import glob
-import logging
import os.path
import re
import shutil
@@ -478,8 +477,6 @@
self.syscalls.append(t)
- logging.debug(t)
-
def parse_open_file(self, fp):
for line in fp:
self.lineno += 1
@@ -489,64 +486,47 @@
self.parse_line(line)
def parse_file(self, file_path):
- logging.debug("parse_file: %s" % file_path)
with open(file_path) as fp:
self.parse_open_file(fp)
-class State:
- def __init__(self):
- self.syscalls = []
+def main(arch):
+ parser = SysCallsTxtParser()
+ parser.parse_file(os.path.join(bionic_libc, "SYSCALLS.TXT"))
+ for syscall in parser.syscalls:
+ syscall["__NR_name"] = make__NR_name(syscall["name"])
- def process_file(self, input):
- parser = SysCallsTxtParser()
- parser.parse_file(input)
- self.syscalls = parser.syscalls
- parser = None
+ if syscall.has_key("arm"):
+ syscall["asm-arm"] = add_footer(32, arm_eabi_genstub(syscall), syscall)
- for syscall in self.syscalls:
- syscall["__NR_name"] = make__NR_name(syscall["name"])
+ if syscall.has_key("arm64"):
+ syscall["asm-arm64"] = add_footer(64, arm64_genstub(syscall), syscall)
- if syscall.has_key("arm"):
- syscall["asm-arm"] = add_footer(32, arm_eabi_genstub(syscall), syscall)
+ if syscall.has_key("x86"):
+ if syscall["socketcall_id"] >= 0:
+ syscall["asm-x86"] = add_footer(32, x86_genstub_socketcall(syscall), syscall)
+ else:
+ syscall["asm-x86"] = add_footer(32, x86_genstub(syscall), syscall)
+ elif syscall["socketcall_id"] >= 0:
+ E("socketcall_id for dispatch syscalls is only supported for x86 in '%s'" % t)
+ return
- if syscall.has_key("arm64"):
- syscall["asm-arm64"] = add_footer(64, arm64_genstub(syscall), syscall)
+ if syscall.has_key("mips"):
+ syscall["asm-mips"] = add_footer(32, mips_genstub(syscall), syscall)
- if syscall.has_key("x86"):
- if syscall["socketcall_id"] >= 0:
- syscall["asm-x86"] = add_footer(32, x86_genstub_socketcall(syscall), syscall)
- else:
- syscall["asm-x86"] = add_footer(32, x86_genstub(syscall), syscall)
- elif syscall["socketcall_id"] >= 0:
- E("socketcall_id for dispatch syscalls is only supported for x86 in '%s'" % t)
- return
+ if syscall.has_key("mips64"):
+ syscall["asm-mips64"] = add_footer(64, mips64_genstub(syscall), syscall)
- if syscall.has_key("mips"):
- syscall["asm-mips"] = add_footer(32, mips_genstub(syscall), syscall)
+ if syscall.has_key("x86_64"):
+ syscall["asm-x86_64"] = add_footer(64, x86_64_genstub(syscall), syscall)
- if syscall.has_key("mips64"):
- syscall["asm-mips64"] = add_footer(64, mips64_genstub(syscall), syscall)
+ print("/* Generated by gensyscalls.py. Do not edit. */\n")
+ print("#include <private/bionic_asm.h>\n")
+ for syscall in parser.syscalls:
+ if syscall.has_key("asm-%s" % arch):
+ print(syscall["asm-%s" % arch])
- if syscall.has_key("x86_64"):
- syscall["asm-x86_64"] = add_footer(64, x86_64_genstub(syscall), syscall)
-
-
- def regenerate(self):
- for arch in all_arches:
- filename = '%s/arch-%s/syscalls.S' % (bionic_libc, arch)
- fp = open(filename, 'w')
- fp.write("/* Generated by gensyscalls.py. Do not edit. */\n")
- fp.write("#include <private/bionic_asm.h>\n")
- for syscall in self.syscalls:
- if syscall.has_key("asm-%s" % arch):
- fp.write(syscall["asm-%s" % arch])
- fp.close()
-
-logging.basicConfig(level=logging.INFO)
if __name__ == "__main__":
- state = State()
- state.process_file(os.path.join(bionic_libc, "SYSCALLS.TXT"))
- state.regenerate()
+ main(sys.argv[1])