diff options
author | Elliott Hughes <enh@google.com> | 2013-03-21 18:06:55 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-03-21 18:06:55 -0700 |
commit | 8ecf2258274b6ef2630a503a314573d80517465a (patch) | |
tree | 8b81caa5797370eb13345976ce20f41d197ec7ea /libc/tools | |
parent | 6eb978c9bf02d2bcdece2826577cc65900030690 (diff) | |
download | bionic-8ecf2258274b6ef2630a503a314573d80517465a.zip bionic-8ecf2258274b6ef2630a503a314573d80517465a.tar.gz bionic-8ecf2258274b6ef2630a503a314573d80517465a.tar.bz2 |
Provide glibc-compatible SYS_* aliases for the __NR_* constants.
This helps us remove another external/strace bionic hack.
Change-Id: I3e82c0d2fd27e479be98f096e05b666fd16f8eb3
Diffstat (limited to 'libc/tools')
-rwxr-xr-x | libc/tools/gensyscalls.py | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py index 91e7a57..389177e 100755 --- a/libc/tools/gensyscalls.py +++ b/libc/tools/gensyscalls.py @@ -303,15 +303,31 @@ class State: t["asm-mips"] = self.mips_genstub(syscall_func,"__NR_"+syscall_name) - def gen_NR_syscall(self,fp,name,id): - fp.write( "#define __NR_%-25s (__NR_SYSCALL_BASE + %d)\n" % (name,id) ) + def gen_NR_syscall(self, fp, name, id): + fp.write("#define __NR_%-25s (__NR_SYSCALL_BASE + %d)\n" % (name,id)) + + + def gen_glibc_syscalls_h(self): + glibc_syscalls_h_path = "include/sys/glibc-syscalls.h" + all_syscall_names = set() + for sc in self.syscalls: + all_syscall_names.add(sc["name"]) + fp = create_file(glibc_syscalls_h_path) + fp.write("/* Auto-generated by gensyscalls.py; do not edit. */\n") + fp.write("#ifndef _BIONIC_GLIBC_SYSCALLS_H_\n") + fp.write("#define _BIONIC_GLIBC_SYSCALLS_H_\n") + for syscall_name in sorted(all_syscall_names): + fp.write("#define SYS_%-25s __NR_%s\n" % (syscall_name, syscall_name)) + fp.write("#endif\n") + fp.close() + self.other_files.append(glibc_syscalls_h_path) + - # now dump the content of linux-syscalls.h def gen_linux_syscalls_h(self): - path = "include/sys/linux-syscalls.h" - D( "generating "+path ) - fp = create_file( path ) - fp.write( "/* auto-generated by gensyscalls.py, do not touch */\n" ) + linux_syscalls_h_path = "include/sys/linux-syscalls.h" + D("generating " + linux_syscalls_h_path) + fp = create_file(linux_syscalls_h_path) + fp.write( "/* Auto-generated by gensyscalls.py; do not edit. */\n" ) fp.write( "#ifndef _BIONIC_LINUX_SYSCALLS_H_\n" ) fp.write( "#define _BIONIC_LINUX_SYSCALLS_H_\n\n" ) fp.write( "#if !defined __ASM_ARM_UNISTD_H && !defined __ASM_I386_UNISTD_H && !defined __ASM_MIPS_UNISTD_H\n" ) @@ -328,7 +344,7 @@ class State: sc_id = sc["common"] sc_name = sc["name"] if sc_id >= 0: - self.gen_NR_syscall( fp, sc_name, sc_id ) + self.gen_NR_syscall(fp, sc_name, sc_id) # now, all arm-specific syscalls fp.write( "\n#ifdef __arm__\n" ); @@ -336,7 +352,7 @@ class State: sc_id = sc["armid"] sc_name = sc["name"] if sc_id >= 0: - self.gen_NR_syscall( fp, sc_name, sc_id ) + self.gen_NR_syscall(fp, sc_name, sc_id) fp.write( "#endif\n" ); gen_syscalls = {} @@ -346,7 +362,7 @@ class State: sc_id = sc["x86id"] sc_name = sc["name"] if sc_id >= 0 and sc_name not in gen_syscalls: - self.gen_NR_syscall( fp, sc_name, sc_id ) + self.gen_NR_syscall(fp, sc_name, sc_id) gen_syscalls[sc_name] = True fp.write( "#endif\n" ); @@ -355,13 +371,13 @@ class State: for sc in sorted(self.syscalls,key=lambda x:x["mipsid"]): sc_id = sc["mipsid"] if sc_id >= 0: - self.gen_NR_syscall( fp, sc["name"], sc_id ) + self.gen_NR_syscall(fp, sc["name"], sc_id) fp.write( "#endif\n" ); fp.write( "\n#endif\n" ) fp.write( "\n#endif /* _BIONIC_LINUX_SYSCALLS_H_ */\n" ); fp.close() - self.other_files.append( path ) + self.other_files.append(linux_syscalls_h_path) # now dump the contents of syscalls.mk @@ -432,6 +448,7 @@ class State: D( "re-generating stubs and support files" ) + self.gen_glibc_syscalls_h() self.gen_linux_syscalls_h() for arch in all_archs: self.gen_arch_syscalls_mk(arch) |