Sort the syscalls.mk files, give all generated files the same header.

No non-comment changes to the .S files.

Change-Id: Iafcfd004c3ea92b64268f80ab16df615b97cefac
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index d31af9d..2334e35 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -4,7 +4,14 @@
 # the header files listing all available system calls, and the
 # makefiles used to build all the stubs.
 
-import sys, os.path, glob, re, commands, filecmp, shutil
+import commands
+import filecmp
+import glob
+import os.path
+import re
+import shutil
+import stat
+import sys
 
 from bionic_utils import *
 
@@ -13,6 +20,8 @@
 # temp directory where we store all intermediate files
 bionic_temp = "/tmp/bionic_gensyscalls/"
 
+warning = "Generated by gensyscalls.py. Do not edit."
+
 DRY_RUN = False
 
 def make_dir(path):
@@ -30,7 +39,8 @@
     return open(bionic_temp + relpath, "w")
 
 
-syscall_stub_header = """/* autogenerated by gensyscalls.py */
+syscall_stub_header = "/* " + warning + " */\n" + \
+"""
 #include <asm/unistd.h>
 #include <linux/err.h>
 #include <machine/asm.h>
@@ -81,7 +91,8 @@
 # MIPS assembler templates for each syscall stub
 #
 
-mips_call = """/* autogenerated by gensyscalls.py */
+mips_call = "/* " + warning + " */\n" + \
+"""
 #include <asm/unistd.h>
     .text
     .globl %(func)s
@@ -359,7 +370,7 @@
         glibc_syscalls_h_path = "include/sys/glibc-syscalls.h"
         D("generating " + glibc_syscalls_h_path)
         glibc_fp = create_file(glibc_syscalls_h_path)
-        glibc_fp.write("/* Auto-generated by gensyscalls.py; do not edit. */\n")
+        glibc_fp.write("/* %s */\n" % warning)
         glibc_fp.write("#ifndef _BIONIC_GLIBC_SYSCALLS_H_\n")
         glibc_fp.write("#define _BIONIC_GLIBC_SYSCALLS_H_\n")
 
@@ -383,9 +394,9 @@
         path = "arch-%s/syscalls.mk" % arch
         D("generating " + path)
         fp = create_file(path)
-        fp.write("# Auto-generated by gensyscalls.py. Do not edit.\n")
+        fp.write("# %s\n" % warning)
         fp.write("syscall_src :=\n")
-        for syscall in self.syscalls:
+        for syscall in sorted(self.syscalls, key=lambda syscall: syscall["func"]):
             if syscall.has_key("asm-%s" % arch):
                 fp.write("syscall_src += arch-%s/syscalls/%s.S\n" % (arch, syscall["func"]))
         fp.close()