<bits/glibc-syscalls.h>: only regenerate when we have new uapi headers.
Test: update_all.py Change-Id: Iaa92dce263197f5a0e7d2dce5e00a31372dcb3e9
This commit is contained in:
parent
d1ff49c24a
commit
c4c2e24d5f
|
@ -1,6 +1,5 @@
|
||||||
/* Generated by gensyscalls.py. Do not edit. */
|
/* Generated file. Do not edit. */
|
||||||
#ifndef _BIONIC_BITS_GLIBC_SYSCALLS_H_
|
#pragma once
|
||||||
#define _BIONIC_BITS_GLIBC_SYSCALLS_H_
|
|
||||||
#if defined(__NR__llseek)
|
#if defined(__NR__llseek)
|
||||||
#define SYS__llseek __NR__llseek
|
#define SYS__llseek __NR__llseek
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,12 +60,6 @@
|
||||||
#if defined(__NR_brk)
|
#if defined(__NR_brk)
|
||||||
#define SYS_brk __NR_brk
|
#define SYS_brk __NR_brk
|
||||||
#endif
|
#endif
|
||||||
#if defined(__NR_cachectl)
|
|
||||||
#define SYS_cachectl __NR_cachectl
|
|
||||||
#endif
|
|
||||||
#if defined(__NR_cacheflush)
|
|
||||||
#define SYS_cacheflush __NR_cacheflush
|
|
||||||
#endif
|
|
||||||
#if defined(__NR_capget)
|
#if defined(__NR_capget)
|
||||||
#define SYS_capget __NR_capget
|
#define SYS_capget __NR_capget
|
||||||
#endif
|
#endif
|
||||||
|
@ -1123,9 +1116,6 @@
|
||||||
#if defined(__NR_syslog)
|
#if defined(__NR_syslog)
|
||||||
#define SYS_syslog __NR_syslog
|
#define SYS_syslog __NR_syslog
|
||||||
#endif
|
#endif
|
||||||
#if defined(__NR_sysmips)
|
|
||||||
#define SYS_sysmips __NR_sysmips
|
|
||||||
#endif
|
|
||||||
#if defined(__NR_tee)
|
#if defined(__NR_tee)
|
||||||
#define SYS_tee __NR_tee
|
#define SYS_tee __NR_tee
|
||||||
#endif
|
#endif
|
||||||
|
@ -1150,9 +1140,6 @@
|
||||||
#if defined(__NR_timer_settime)
|
#if defined(__NR_timer_settime)
|
||||||
#define SYS_timer_settime __NR_timer_settime
|
#define SYS_timer_settime __NR_timer_settime
|
||||||
#endif
|
#endif
|
||||||
#if defined(__NR_timerfd)
|
|
||||||
#define SYS_timerfd __NR_timerfd
|
|
||||||
#endif
|
|
||||||
#if defined(__NR_timerfd_create)
|
#if defined(__NR_timerfd_create)
|
||||||
#define SYS_timerfd_create __NR_timerfd_create
|
#define SYS_timerfd_create __NR_timerfd_create
|
||||||
#endif
|
#endif
|
||||||
|
@ -1255,4 +1242,3 @@
|
||||||
#if defined(__NR_writev)
|
#if defined(__NR_writev)
|
||||||
#define SYS_writev __NR_writev
|
#define SYS_writev __NR_writev
|
||||||
#endif
|
#endif
|
||||||
#endif /* _BIONIC_BITS_GLIBC_SYSCALLS_H_ */
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import sys, cpp, kernel, glob, os, re, getopt, clean_header, subprocess, shutil
|
||||||
from defaults import *
|
from defaults import *
|
||||||
from utils import *
|
from utils import *
|
||||||
|
|
||||||
def usage():
|
def Usage():
|
||||||
print """\
|
print """\
|
||||||
usage: %(progname)s [kernel-original-path] [kernel-modified-path]
|
usage: %(progname)s [kernel-original-path] [kernel-modified-path]
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ def usage():
|
||||||
""" % { "progname" : os.path.basename(sys.argv[0]) }
|
""" % { "progname" : os.path.basename(sys.argv[0]) }
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def processFiles(updater, original_dir, modified_dir, src_rel_dir, update_rel_dir):
|
def ProcessFiles(updater, original_dir, modified_dir, src_rel_dir, update_rel_dir):
|
||||||
# Delete the old headers before updating to the new headers.
|
# Delete the old headers before updating to the new headers.
|
||||||
update_dir = os.path.join(get_kernel_dir(), update_rel_dir)
|
update_dir = os.path.join(get_kernel_dir(), update_rel_dir)
|
||||||
shutil.rmtree(update_dir)
|
shutil.rmtree(update_dir)
|
||||||
|
@ -64,15 +64,64 @@ def processFiles(updater, original_dir, modified_dir, src_rel_dir, update_rel_di
|
||||||
update_path = os.path.join(update_rel_dir, rel_path)
|
update_path = os.path.join(update_rel_dir, rel_path)
|
||||||
print "cleaning %s -> %s (%s)" % (src_str, update_path, state)
|
print "cleaning %s -> %s (%s)" % (src_str, update_path, state)
|
||||||
|
|
||||||
|
|
||||||
|
# This lets us support regular system calls like __NR_write and also weird
|
||||||
|
# ones like __ARM_NR_cacheflush, where the NR doesn't come at the start.
|
||||||
|
def make__NR_name(name):
|
||||||
|
if name.startswith('__ARM_NR_'):
|
||||||
|
return name
|
||||||
|
else:
|
||||||
|
return '__NR_%s' % (name)
|
||||||
|
|
||||||
|
|
||||||
|
# Scan Linux kernel asm/unistd.h files containing __NR_* constants
|
||||||
|
# and write out equivalent SYS_* constants for glibc source compatibility.
|
||||||
|
def GenerateGlibcSyscallsHeader(updater):
|
||||||
|
libc_root = '%s/bionic/libc/' % os.environ['ANDROID_BUILD_TOP']
|
||||||
|
|
||||||
|
# Collect the set of all syscalls for all architectures.
|
||||||
|
syscalls = set()
|
||||||
|
pattern = re.compile(r'^\s*#\s*define\s*__NR_([a-z_]\S+)')
|
||||||
|
for unistd_h in ['kernel/uapi/asm-generic/unistd.h',
|
||||||
|
'kernel/uapi/asm-arm/asm/unistd.h',
|
||||||
|
'kernel/uapi/asm-arm/asm/unistd-common.h',
|
||||||
|
'kernel/uapi/asm-arm/asm/unistd-eabi.h',
|
||||||
|
'kernel/uapi/asm-arm/asm/unistd-oabi.h',
|
||||||
|
'kernel/uapi/asm-x86/asm/unistd_32.h',
|
||||||
|
'kernel/uapi/asm-x86/asm/unistd_64.h',
|
||||||
|
'kernel/uapi/asm-x86/asm/unistd_x32.h']:
|
||||||
|
for line in open(os.path.join(libc_root, unistd_h)):
|
||||||
|
m = re.search(pattern, line)
|
||||||
|
if m:
|
||||||
|
nr_name = m.group(1)
|
||||||
|
if 'reserved' not in nr_name and 'unused' not in nr_name:
|
||||||
|
syscalls.add(nr_name)
|
||||||
|
|
||||||
|
# Create a single file listing them all.
|
||||||
|
# Note that the input files include #if trickery, so even for a single
|
||||||
|
# architecture we don't know exactly which ones are available.
|
||||||
|
# https://b.corp.google.com/issues/37110151
|
||||||
|
content = '/* Generated file. Do not edit. */\n'
|
||||||
|
content += '#pragma once\n'
|
||||||
|
|
||||||
|
for syscall in sorted(syscalls):
|
||||||
|
nr_name = make__NR_name(syscall)
|
||||||
|
content += '#if defined(%s)\n' % nr_name
|
||||||
|
content += ' #define SYS_%s %s\n' % (syscall, nr_name)
|
||||||
|
content += '#endif\n'
|
||||||
|
|
||||||
|
updater.editFile('%s/include/bits/glibc-syscalls.h' % libc_root, content)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
optlist, args = getopt.getopt(sys.argv[1:], '')
|
optlist, args = getopt.getopt(sys.argv[1:], '')
|
||||||
except:
|
except:
|
||||||
# Unrecognized option
|
# Unrecognized option
|
||||||
sys.stderr.write("error: unrecognized option\n")
|
sys.stderr.write("error: unrecognized option\n")
|
||||||
usage()
|
Usage()
|
||||||
|
|
||||||
if len(optlist) > 0 or len(args) > 2:
|
if len(optlist) > 0 or len(args) > 2:
|
||||||
usage()
|
Usage()
|
||||||
|
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
original_dir = args[0]
|
original_dir = args[0]
|
||||||
|
@ -91,10 +140,16 @@ if not os.path.isdir(modified_dir):
|
||||||
panic("The kernel modified directory %s is not a directory\n" % modified_dir)
|
panic("The kernel modified directory %s is not a directory\n" % modified_dir)
|
||||||
|
|
||||||
updater = BatchFileUpdater()
|
updater = BatchFileUpdater()
|
||||||
|
|
||||||
# Process the original uapi headers first.
|
# Process the original uapi headers first.
|
||||||
processFiles(updater, original_dir, modified_dir, "uapi", "uapi"),
|
ProcessFiles(updater, original_dir, modified_dir, "uapi", "uapi"),
|
||||||
|
|
||||||
# Now process the special files.
|
# Now process the special files.
|
||||||
processFiles(updater, original_dir, modified_dir, "scsi", os.path.join("android", "scsi", "scsi"))
|
ProcessFiles(updater, original_dir, modified_dir, "scsi", os.path.join("android", "scsi", "scsi"))
|
||||||
|
|
||||||
updater.updateGitFiles()
|
updater.updateGitFiles()
|
||||||
|
|
||||||
|
# Now re-generate the <bits/glibc-syscalls.h> from the new uapi headers.
|
||||||
|
updater = BatchFileUpdater()
|
||||||
|
GenerateGlibcSyscallsHeader(updater)
|
||||||
|
updater.updateGitFiles()
|
||||||
|
|
|
@ -527,7 +527,6 @@ class State:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.old_stubs = []
|
self.old_stubs = []
|
||||||
self.new_stubs = []
|
self.new_stubs = []
|
||||||
self.other_files = []
|
|
||||||
self.syscalls = []
|
self.syscalls = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -565,56 +564,6 @@ class State:
|
||||||
syscall["asm-x86_64"] = add_footer(64, x86_64_genstub(syscall), syscall)
|
syscall["asm-x86_64"] = add_footer(64, x86_64_genstub(syscall), syscall)
|
||||||
|
|
||||||
|
|
||||||
# Scan Linux kernel asm/unistd.h files containing __NR_* constants
|
|
||||||
# and write out equivalent SYS_* constants for glibc source compatibility.
|
|
||||||
def gen_glibc_syscalls_h(self):
|
|
||||||
glibc_syscalls_h_path = "include/bits/glibc-syscalls.h"
|
|
||||||
logging.info("generating " + glibc_syscalls_h_path)
|
|
||||||
glibc_fp = create_file(glibc_syscalls_h_path)
|
|
||||||
glibc_fp.write("/* %s */\n" % warning)
|
|
||||||
glibc_fp.write("#ifndef _BIONIC_BITS_GLIBC_SYSCALLS_H_\n")
|
|
||||||
glibc_fp.write("#define _BIONIC_BITS_GLIBC_SYSCALLS_H_\n")
|
|
||||||
|
|
||||||
# Collect the set of all syscalls for all architectures.
|
|
||||||
syscalls = set()
|
|
||||||
pattern = re.compile(r'^\s*#\s*define\s*__NR_([a-z_]\S+)')
|
|
||||||
for unistd_h in ["kernel/uapi/asm-generic/unistd.h",
|
|
||||||
"kernel/uapi/asm-arm/asm/unistd.h",
|
|
||||||
"kernel/uapi/asm-arm/asm/unistd-common.h",
|
|
||||||
"kernel/uapi/asm-arm/asm/unistd-eabi.h",
|
|
||||||
"kernel/uapi/asm-arm/asm/unistd-oabi.h",
|
|
||||||
"kernel/uapi/asm-mips/asm/unistd.h",
|
|
||||||
"kernel/uapi/asm-mips/asm/unistd_n32.h",
|
|
||||||
"kernel/uapi/asm-mips/asm/unistd_n64.h",
|
|
||||||
"kernel/uapi/asm-mips/asm/unistd_nr_n32.h",
|
|
||||||
"kernel/uapi/asm-mips/asm/unistd_nr_n64.h",
|
|
||||||
"kernel/uapi/asm-mips/asm/unistd_nr_o32.h",
|
|
||||||
"kernel/uapi/asm-mips/asm/unistd_o32.h",
|
|
||||||
"kernel/uapi/asm-x86/asm/unistd_32.h",
|
|
||||||
"kernel/uapi/asm-x86/asm/unistd_64.h",
|
|
||||||
"kernel/uapi/asm-x86/asm/unistd_x32.h"]:
|
|
||||||
for line in open(os.path.join(bionic_libc_root, unistd_h)):
|
|
||||||
m = re.search(pattern, line)
|
|
||||||
if m:
|
|
||||||
nr_name = m.group(1)
|
|
||||||
if 'reserved' not in nr_name and 'unused' not in nr_name:
|
|
||||||
syscalls.add(nr_name)
|
|
||||||
|
|
||||||
# Write out a single file listing them all. Note that the input
|
|
||||||
# files include #if trickery, so even for a single architecture
|
|
||||||
# we don't know exactly which ones are available.
|
|
||||||
# https://code.google.com/p/android/issues/detail?id=215853
|
|
||||||
for syscall in sorted(syscalls):
|
|
||||||
nr_name = make__NR_name(syscall)
|
|
||||||
glibc_fp.write("#if defined(%s)\n" % nr_name)
|
|
||||||
glibc_fp.write(" #define SYS_%s %s\n" % (syscall, nr_name))
|
|
||||||
glibc_fp.write("#endif\n")
|
|
||||||
|
|
||||||
glibc_fp.write("#endif /* _BIONIC_BITS_GLIBC_SYSCALLS_H_ */\n")
|
|
||||||
glibc_fp.close()
|
|
||||||
self.other_files.append(glibc_syscalls_h_path)
|
|
||||||
|
|
||||||
|
|
||||||
# Write each syscall stub.
|
# Write each syscall stub.
|
||||||
def gen_syscall_stubs(self):
|
def gen_syscall_stubs(self):
|
||||||
for syscall in self.syscalls:
|
for syscall in self.syscalls:
|
||||||
|
@ -645,16 +594,15 @@ class State:
|
||||||
logging.info("creating %s..." % bionic_temp)
|
logging.info("creating %s..." % bionic_temp)
|
||||||
make_dir(bionic_temp)
|
make_dir(bionic_temp)
|
||||||
|
|
||||||
logging.info("re-generating stubs and support files...")
|
logging.info("re-generating stubs...")
|
||||||
|
|
||||||
self.gen_glibc_syscalls_h()
|
|
||||||
self.gen_syscall_stubs()
|
self.gen_syscall_stubs()
|
||||||
|
|
||||||
logging.info("comparing files...")
|
logging.info("comparing files...")
|
||||||
adds = []
|
adds = []
|
||||||
edits = []
|
edits = []
|
||||||
|
|
||||||
for stub in self.new_stubs + self.other_files:
|
for stub in self.new_stubs:
|
||||||
tmp_file = os.path.join(bionic_temp, stub)
|
tmp_file = os.path.join(bionic_temp, stub)
|
||||||
libc_file = os.path.join(bionic_libc_root, stub)
|
libc_file = os.path.join(bionic_libc_root, stub)
|
||||||
if not os.path.exists(libc_file):
|
if not os.path.exists(libc_file):
|
||||||
|
|
Loading…
Reference in New Issue