blob: 2334e35596af0f0b02f115faccbce6f964b6a1dc [file] [log] [blame]
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -07001#!/usr/bin/python
Pavel Chupinf12a18b2012-12-12 13:11:48 +04002
3# This tool is used to generate the assembler system call stubs,
4# the header files listing all available system calls, and the
5# makefiles used to build all the stubs.
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -07006
Elliott Hughes103ccde2013-10-16 14:27:59 -07007import commands
8import filecmp
9import glob
10import os.path
11import re
12import shutil
13import stat
14import sys
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070015
16from bionic_utils import *
17
Elliott Hughes18bc9752013-06-17 10:26:10 -070018bionic_libc_root = os.environ["ANDROID_BUILD_TOP"] + "/bionic/libc/"
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070019
20# temp directory where we store all intermediate files
21bionic_temp = "/tmp/bionic_gensyscalls/"
22
Elliott Hughes103ccde2013-10-16 14:27:59 -070023warning = "Generated by gensyscalls.py. Do not edit."
24
Pavel Chupinf12a18b2012-12-12 13:11:48 +040025DRY_RUN = False
26
27def make_dir(path):
Raghu Gandham1fa0d842012-01-27 17:51:42 -080028 path = os.path.abspath(path)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070029 if not os.path.exists(path):
30 parent = os.path.dirname(path)
31 if parent:
32 make_dir(parent)
33 os.mkdir(path)
34
Elliott Hughes0437f3f2013-10-07 23:53:13 -070035
Pavel Chupinf12a18b2012-12-12 13:11:48 +040036def create_file(relpath):
37 dir = os.path.dirname(bionic_temp + relpath)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070038 make_dir(dir)
Pavel Chupinf12a18b2012-12-12 13:11:48 +040039 return open(bionic_temp + relpath, "w")
40
41
Elliott Hughes103ccde2013-10-16 14:27:59 -070042syscall_stub_header = "/* " + warning + " */\n" + \
43"""
Pavel Chupinf12a18b2012-12-12 13:11:48 +040044#include <asm/unistd.h>
45#include <linux/err.h>
46#include <machine/asm.h>
47
Elliott Hughes0437f3f2013-10-07 23:53:13 -070048ENTRY(%(func)s)
Pavel Chupinf12a18b2012-12-12 13:11:48 +040049"""
50
Elliott Hughes0437f3f2013-10-07 23:53:13 -070051
H.J. Lu6fe4e872013-10-04 10:03:17 -070052function_alias = """
53 .globl _C_LABEL(%(alias)s)
Elliott Hughes0437f3f2013-10-07 23:53:13 -070054 .equ _C_LABEL(%(alias)s), _C_LABEL(%(func)s)
H.J. Lu6fe4e872013-10-04 10:03:17 -070055"""
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -070056
Elliott Hughes0437f3f2013-10-07 23:53:13 -070057
58#
59# ARM assembler templates for each syscall stub
60#
61
62arm_eabi_call_default = syscall_stub_header + """\
63 mov ip, r7
64 ldr r7, =%(__NR_name)s
65 swi #0
66 mov r7, ip
67 cmn r0, #(MAX_ERRNO + 1)
68 bxls lr
69 neg r0, r0
70 b __set_errno
71END(%(func)s)
72"""
73
74arm_eabi_call_long = syscall_stub_header + """\
75 mov ip, sp
76 .save {r4, r5, r6, r7}
77 stmfd sp!, {r4, r5, r6, r7}
78 ldmfd ip, {r4, r5, r6}
79 ldr r7, =%(__NR_name)s
80 swi #0
81 ldmfd sp!, {r4, r5, r6, r7}
82 cmn r0, #(MAX_ERRNO + 1)
83 bxls lr
84 neg r0, r0
85 b __set_errno
86END(%(func)s)
87"""
88
89
90#
91# MIPS assembler templates for each syscall stub
92#
93
Elliott Hughes103ccde2013-10-16 14:27:59 -070094mips_call = "/* " + warning + " */\n" + \
95"""
Elliott Hughes0437f3f2013-10-07 23:53:13 -070096#include <asm/unistd.h>
97 .text
98 .globl %(func)s
99 .align 4
100 .ent %(func)s
101
102%(func)s:
103 .set noreorder
104 .cpload $t9
105 li $v0, %(__NR_name)s
106 syscall
107 bnez $a3, 1f
108 move $a0, $v0
109 j $ra
110 nop
1111:
112 la $t9,__set_errno
113 j $t9
114 nop
115 .set reorder
116 .end %(func)s
117"""
118
119
Elliott Hughescd6780b2013-02-07 14:07:00 -0800120#
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700121# x86 assembler templates for each syscall stub
122#
123
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700124x86_registers = [ "%ebx", "%ecx", "%edx", "%esi", "%edi", "%ebp" ]
125
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700126x86_call = """\
127 movl $%(__NR_name)s, %%eax
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700128 int $0x80
Elliott Hughes9aceab52013-03-12 14:57:30 -0700129 cmpl $-MAX_ERRNO, %%eax
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700130 jb 1f
131 negl %%eax
132 pushl %%eax
133 call __set_errno
134 addl $4, %%esp
135 orl $-1, %%eax
1361:
137"""
138
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700139x86_return = """\
140 ret
141END(%(func)s)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700142"""
143
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700144
Elliott Hughescd6780b2013-02-07 14:07:00 -0800145#
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400146# x86_64 assembler templates for each syscall stub
147#
148
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700149x86_64_call = """\
150 movl $%(__NR_name)s, %%eax
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400151 syscall
152 cmpq $-MAX_ERRNO, %%rax
153 jb 1f
154 negl %%eax
155 movl %%eax, %%edi
156 call __set_errno
157 orq $-1, %%rax
1581:
159 ret
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700160END(%(func)s)
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400161"""
162
Raghu Gandham1fa0d842012-01-27 17:51:42 -0800163
David 'Digit' Turner95d751f2010-12-16 16:47:14 +0100164def param_uses_64bits(param):
165 """Returns True iff a syscall parameter description corresponds
166 to a 64-bit type."""
167 param = param.strip()
168 # First, check that the param type begins with one of the known
169 # 64-bit types.
170 if not ( \
171 param.startswith("int64_t") or param.startswith("uint64_t") or \
172 param.startswith("loff_t") or param.startswith("off64_t") or \
173 param.startswith("long long") or param.startswith("unsigned long long") or
174 param.startswith("signed long long") ):
175 return False
176
177 # Second, check that there is no pointer type here
178 if param.find("*") >= 0:
179 return False
180
181 # Ok
182 return True
183
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700184
David 'Digit' Turner95d751f2010-12-16 16:47:14 +0100185def count_arm_param_registers(params):
186 """This function is used to count the number of register used
Elliott Hughescd6780b2013-02-07 14:07:00 -0800187 to pass parameters when invoking an ARM system call.
David 'Digit' Turner95d751f2010-12-16 16:47:14 +0100188 This is because the ARM EABI mandates that 64-bit quantities
189 must be passed in an even+odd register pair. So, for example,
190 something like:
191
192 foo(int fd, off64_t pos)
193
194 would actually need 4 registers:
195 r0 -> int
196 r1 -> unused
197 r2-r3 -> pos
198 """
199 count = 0
200 for param in params:
201 if param_uses_64bits(param):
202 if (count & 1) != 0:
203 count += 1
204 count += 2
205 else:
206 count += 1
207 return count
208
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700209
David 'Digit' Turner95d751f2010-12-16 16:47:14 +0100210def count_generic_param_registers(params):
211 count = 0
212 for param in params:
213 if param_uses_64bits(param):
214 count += 2
215 else:
216 count += 1
217 return count
218
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700219
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400220def count_generic_param_registers64(params):
221 count = 0
222 for param in params:
223 count += 1
224 return count
225
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700226
Elliott Hughescda62092013-03-22 13:50:44 -0700227# This lets us support regular system calls like __NR_write and also weird
228# ones like __ARM_NR_cacheflush, where the NR doesn't come at the start.
229def make__NR_name(name):
230 if name.startswith("__"):
231 return name
232 else:
233 return "__NR_%s" % (name)
234
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700235
236def add_aliases(stub, syscall):
237 aliases = syscall["aliases"]
238 for alias in aliases:
239 stub += function_alias % { "func" : syscall["func"], "alias" : alias }
240 return stub
241
242
243def arm_eabi_genstub(syscall):
244 num_regs = count_arm_param_registers(syscall["params"])
245 if num_regs > 4:
246 return arm_eabi_call_long % syscall
247 return arm_eabi_call_default % syscall
248
249
250def mips_genstub(syscall):
251 return mips_call % syscall
252
253
254def x86_genstub(syscall):
255 result = syscall_stub_header % syscall
256 stack_bias = 4
257
258 numparams = count_generic_param_registers(syscall["params"])
259 for r in range(numparams):
260 result += " pushl " + x86_registers[r] + "\n"
261 stack_bias += 4
262
263 for r in range(numparams):
264 result += " mov %d(%%esp), %s" % (stack_bias+r*4, x86_registers[r]) + "\n"
265
266 result += x86_call % syscall
267
268 for r in range(numparams):
269 result += " popl " + x86_registers[numparams-r-1] + "\n"
270
271 result += x86_return % syscall
272 return result
273
274def x86_genstub_socketcall(syscall):
275 # %ebx <--- Argument 1 - The call id of the needed vectored
276 # syscall (socket, bind, recv, etc)
277 # %ecx <--- Argument 2 - Pointer to the rest of the arguments
278 # from the original function called (socket())
279
280 result = syscall_stub_header % syscall
281 stack_bias = 4
282
283 # save the regs we need
284 result += " pushl %ebx" + "\n"
285 stack_bias += 4
286 result += " pushl %ecx" + "\n"
287 stack_bias += 4
288
289 # set the call id (%ebx)
290 result += " mov $%d, %%ebx" % syscall["socketcall_id"] + "\n"
291
292 # set the pointer to the rest of the args into %ecx
293 result += " mov %esp, %ecx" + "\n"
294 result += " addl $%d, %%ecx" % (stack_bias) + "\n"
295
296 # now do the syscall code itself
297 result += x86_call % syscall
298
299 # now restore the saved regs
300 result += " popl %ecx" + "\n"
301 result += " popl %ebx" + "\n"
302
303 # epilog
304 result += x86_return % syscall
305 return result
306
307
308def x86_64_genstub(syscall):
309 result = syscall_stub_header % syscall
310 num_regs = count_generic_param_registers64(syscall["params"])
311 if (num_regs > 3):
312 # rcx is used as 4th argument. Kernel wants it at r10.
313 result += " movq %rcx, %r10\n"
314
315 result += x86_64_call % syscall
316 return result
317
318
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700319class State:
320 def __init__(self):
321 self.old_stubs = []
322 self.new_stubs = []
323 self.other_files = []
324 self.syscalls = []
325
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400326
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700327 def process_file(self, input):
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700328 parser = SysCallsTxtParser()
329 parser.parse_file(input)
330 self.syscalls = parser.syscalls
331 parser = None
332
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700333 for syscall in self.syscalls:
334 syscall["__NR_name"] = make__NR_name(syscall["name"])
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700335
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700336 if syscall.has_key("arm"):
337 syscall["asm-arm"] = add_aliases(arm_eabi_genstub(syscall), syscall)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700338
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700339 if syscall.has_key("x86"):
340 if syscall["socketcall_id"] >= 0:
341 syscall["asm-x86"] = add_aliases(x86_genstub_socketcall(syscall), syscall)
The Android Open Source Project4e468ed2008-12-17 18:03:48 -0800342 else:
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700343 syscall["asm-x86"] = add_aliases(x86_genstub(syscall), syscall)
344 elif syscall["socketcall_id"] >= 0:
Elliott Hughesd6121652013-09-25 22:43:36 -0700345 E("socketcall_id for dispatch syscalls is only supported for x86 in '%s'" % t)
The Android Open Source Project4e468ed2008-12-17 18:03:48 -0800346 return
Elliott Hughescd6780b2013-02-07 14:07:00 -0800347
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700348 if syscall.has_key("mips"):
349 syscall["asm-mips"] = add_aliases(mips_genstub(syscall), syscall)
The Android Open Source Project4e468ed2008-12-17 18:03:48 -0800350
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700351 if syscall.has_key("x86_64"):
352 syscall["asm-x86_64"] = add_aliases(x86_64_genstub(syscall), syscall)
353
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700354
Elliott Hughes1b91c6c2013-03-22 18:56:24 -0700355 # Scan a Linux kernel asm/unistd.h file containing __NR_* constants
356 # and write out equivalent SYS_* constants for glibc source compatibility.
Elliott Hughes5c2772f2013-03-21 22:15:06 -0700357 def scan_linux_unistd_h(self, fp, path):
358 pattern = re.compile(r'^#define __NR_([a-z]\S+) .*')
359 syscalls = set() # MIPS defines everything three times; work around that.
360 for line in open(path):
361 m = re.search(pattern, line)
362 if m:
363 syscalls.add(m.group(1))
364 for syscall in sorted(syscalls):
Elliott Hughescda62092013-03-22 13:50:44 -0700365 fp.write("#define SYS_%s %s\n" % (syscall, make__NR_name(syscall)))
Elliott Hughes8ecf2252013-03-21 18:06:55 -0700366
367
Elliott Hughes1b91c6c2013-03-22 18:56:24 -0700368 def gen_glibc_syscalls_h(self):
Elliott Hughescda62092013-03-22 13:50:44 -0700369 # TODO: generate a separate file for each architecture, like glibc's bits/syscall.h.
Elliott Hughes9724ce32013-03-21 19:43:54 -0700370 glibc_syscalls_h_path = "include/sys/glibc-syscalls.h"
Elliott Hughes1b91c6c2013-03-22 18:56:24 -0700371 D("generating " + glibc_syscalls_h_path)
Elliott Hughes9724ce32013-03-21 19:43:54 -0700372 glibc_fp = create_file(glibc_syscalls_h_path)
Elliott Hughes103ccde2013-10-16 14:27:59 -0700373 glibc_fp.write("/* %s */\n" % warning)
Elliott Hughes9724ce32013-03-21 19:43:54 -0700374 glibc_fp.write("#ifndef _BIONIC_GLIBC_SYSCALLS_H_\n")
375 glibc_fp.write("#define _BIONIC_GLIBC_SYSCALLS_H_\n")
376
Elliott Hughes5c2772f2013-03-21 22:15:06 -0700377 glibc_fp.write("#if defined(__arm__)\n")
Elliott Hughes18bc9752013-06-17 10:26:10 -0700378 self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-arm/asm/unistd.h")
Elliott Hughes5c2772f2013-03-21 22:15:06 -0700379 glibc_fp.write("#elif defined(__mips__)\n")
Elliott Hughes18bc9752013-06-17 10:26:10 -0700380 self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-mips/asm/unistd.h")
Elliott Hughes5c2772f2013-03-21 22:15:06 -0700381 glibc_fp.write("#elif defined(__i386__)\n")
Elliott Hughes18bc9752013-06-17 10:26:10 -0700382 self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-x86/asm/unistd_32.h")
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400383 glibc_fp.write("#elif defined(__x86_64__)\n")
384 self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-x86/asm/unistd_64.h")
Elliott Hughes5c2772f2013-03-21 22:15:06 -0700385 glibc_fp.write("#endif\n")
386
387 glibc_fp.write("#endif /* _BIONIC_GLIBC_SYSCALLS_H_ */\n")
388 glibc_fp.close()
389 self.other_files.append(glibc_syscalls_h_path)
390
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700391
Elliott Hughesd6121652013-09-25 22:43:36 -0700392 # Write the contents of syscalls.mk.
The Android Open Source Project4e468ed2008-12-17 18:03:48 -0800393 def gen_arch_syscalls_mk(self, arch):
394 path = "arch-%s/syscalls.mk" % arch
Elliott Hughesd6121652013-09-25 22:43:36 -0700395 D("generating " + path)
396 fp = create_file(path)
Elliott Hughes103ccde2013-10-16 14:27:59 -0700397 fp.write("# %s\n" % warning)
Elliott Hughesd6121652013-09-25 22:43:36 -0700398 fp.write("syscall_src :=\n")
Elliott Hughes103ccde2013-10-16 14:27:59 -0700399 for syscall in sorted(self.syscalls, key=lambda syscall: syscall["func"]):
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700400 if syscall.has_key("asm-%s" % arch):
401 fp.write("syscall_src += arch-%s/syscalls/%s.S\n" % (arch, syscall["func"]))
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700402 fp.close()
Elliott Hughesd6121652013-09-25 22:43:36 -0700403 self.other_files.append(path)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700404
Raghu Gandham1fa0d842012-01-27 17:51:42 -0800405
Elliott Hughesd6121652013-09-25 22:43:36 -0700406 # Write each syscall stub.
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700407 def gen_syscall_stubs(self):
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700408 for syscall in self.syscalls:
Elliott Hughesd6121652013-09-25 22:43:36 -0700409 for arch in all_arches:
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700410 if syscall.has_key("asm-%s" % arch):
411 filename = "arch-%s/syscalls/%s.S" % (arch, syscall["func"])
Elliott Hughesd6121652013-09-25 22:43:36 -0700412 D2(">>> generating " + filename)
413 fp = create_file(filename)
Elliott Hughes0437f3f2013-10-07 23:53:13 -0700414 fp.write(syscall["asm-%s" % arch])
Elliott Hughesd6121652013-09-25 22:43:36 -0700415 fp.close()
416 self.new_stubs.append(filename)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700417
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700418
Elliott Hughesd6121652013-09-25 22:43:36 -0700419 def regenerate(self):
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400420 D("scanning for existing architecture-specific stub files...")
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700421
Elliott Hughes18bc9752013-06-17 10:26:10 -0700422 bionic_libc_root_len = len(bionic_libc_root)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700423
Elliott Hughesd6121652013-09-25 22:43:36 -0700424 for arch in all_arches:
Elliott Hughes18bc9752013-06-17 10:26:10 -0700425 arch_path = bionic_libc_root + "arch-" + arch
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400426 D("scanning " + arch_path)
427 files = glob.glob(arch_path + "/syscalls/*.S")
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700428 for f in files:
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400429 self.old_stubs.append(f[bionic_libc_root_len:])
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700430
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400431 D("found %d stub files" % len(self.old_stubs))
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700432
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400433 if not os.path.exists(bionic_temp):
434 D("creating %s..." % bionic_temp)
435 make_dir(bionic_temp)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700436
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400437 D("re-generating stubs and support files...")
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700438
Elliott Hughes1b91c6c2013-03-22 18:56:24 -0700439 self.gen_glibc_syscalls_h()
Elliott Hughesd6121652013-09-25 22:43:36 -0700440 for arch in all_arches:
The Android Open Source Project4e468ed2008-12-17 18:03:48 -0800441 self.gen_arch_syscalls_mk(arch)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700442 self.gen_syscall_stubs()
443
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400444 D("comparing files...")
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700445 adds = []
446 edits = []
447
448 for stub in self.new_stubs + self.other_files:
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400449 if not os.path.exists(bionic_libc_root + stub):
David 'Digit' Turnerfc269312010-10-11 22:11:06 +0200450 # new file, git add it
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400451 D("new file: " + stub)
452 adds.append(bionic_libc_root + stub)
453 shutil.copyfile(bionic_temp + stub, bionic_libc_root + stub)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700454
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400455 elif not filecmp.cmp(bionic_temp + stub, bionic_libc_root + stub):
456 D("changed file: " + stub)
457 edits.append(stub)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700458
459 deletes = []
460 for stub in self.old_stubs:
461 if not stub in self.new_stubs:
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400462 D("deleted file: " + stub)
463 deletes.append(bionic_libc_root + stub)
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700464
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400465 if not DRY_RUN:
466 if adds:
467 commands.getoutput("git add " + " ".join(adds))
468 if deletes:
469 commands.getoutput("git rm " + " ".join(deletes))
470 if edits:
471 for file in edits:
472 shutil.copyfile(bionic_temp + file, bionic_libc_root + file)
473 commands.getoutput("git add " + " ".join((bionic_libc_root + file) for file in edits))
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700474
Pavel Chupinf12a18b2012-12-12 13:11:48 +0400475 commands.getoutput("git add %s%s" % (bionic_libc_root,"SYSCALLS.TXT"))
David 'Digit' Turnerfc269312010-10-11 22:11:06 +0200476
477 if (not adds) and (not deletes) and (not edits):
478 D("no changes detected!")
479 else:
480 D("ready to go!!")
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700481
482D_setlevel(1)
483
484state = State()
Elliott Hughes18bc9752013-06-17 10:26:10 -0700485state.process_file(bionic_libc_root+"SYSCALLS.TXT")
The Android Open Source Projecta27d2ba2008-10-21 07:00:00 -0700486state.regenerate()