A number of changes relating to syscall numbering:

- Introduced VG_SYSNUM_STRING and VG_SYSNUM_STRING_EXTRA which factor out
  differences in the way syscall numbers are printed on different platforms.
  This gets rid of seven "DDD" fixme-style comments.

- This also meant that Darwin syscall numbers are now printed in a
  non-ambiguous way -- previously Unix, machine-dependent and diagnostic
  syscalls were all printed the same way, even though their numbers overlap.
  Now each number is prefixed with "unix", "mdep", etc.  And Mach trap
  numbers aren't printed as negative numbers now that they have a "mach"
  prefix.

- Split each of pub_core_vkiscnums.h and pub_tool_vkiscnums.h into two
  parts, one suitable for inclusion in asm files, one suitable for inclusion
  in C files;  in both cases the latter includes the former.  This makes
  this module more like other modules that have asm-only components (eg.
  m_transtab);  it also allows the hacky VG_IN_ASSEMBLY_SOURCE macros and
  tests to be removed.

- Removed some of the VG_DARWIN_SYSNO_* macros that were no longer needed,
  and renamed some of the existing ones to make their meanings clearer.

- Added comments on the encoding of Darwin syscall numbers so it's
  possible for mortals to understand without reading the kernel code..



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10218 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c
index 06f6988..2e04ab5 100644
--- a/coregrind/m_debuglog.c
+++ b/coregrind/m_debuglog.c
@@ -400,10 +400,10 @@
 
 #elif defined(VGP_x86_darwin)
 
-/* Using _SYSNO_INDEX rather than _SYSNO_NUM assumes that these are
-   Unix-class syscalls (which they are).  Unfortunately _SYSNO_NUM
-   involves a C-style "cond ? :" expression which doesn't impress the
-   Darwin assembler very much. */
+/* We would use VG_DARWIN_SYSNO_TO_KERNEL instead of VG_DARWIN_SYSNO_INDEX
+   except that the former has a C ternary ?: operator which isn't valid in
+   asm code.  Both macros give the same results for Unix-class syscalls (which
+   these all are, as identified by the use of 'int 0x80'). */
 __attribute__((noinline))
 static UInt local_sys_write_stderr ( HChar* buf, Int n )
 {
@@ -454,7 +454,7 @@
       "movq  $2, %%rdi\n"    /* push stderr */
       "movq  %1, %%rsi\n"    /* push buf */
       "movl  %2, %%edx\n"    /* push n */
-      "movl  $"VG_STRINGIFY(VG_DARWIN_SYSNO_NUM(__NR_write_nocancel))
+      "movl  $"VG_STRINGIFY(VG_DARWIN_SYSNO_FOR_KERNEL(__NR_write_nocancel))
              ", %%eax\n"
       "syscall\n"            /* write(stderr, buf, n) */
       "jnc   1f\n"           /* jump if no error */
@@ -471,7 +471,7 @@
 {
    UInt __res;
    __asm__ volatile (
-      "movl $"VG_STRINGIFY(VG_DARWIN_SYSNO_NUM(__NR_getpid))", %%eax\n"
+      "movl $"VG_STRINGIFY(VG_DARWIN_SYSNO_FOR_KERNEL(__NR_getpid))", %%eax\n"
       "syscall\n"          /* getpid() */
       "movl %%eax, %0\n"   /* set __res = eax */
       : "=mr" (__res)