Unify our assembler macros.

Our <machine/asm.h> files were modified from upstream, to the extent
that no architecture was actually using the upstream ENTRY or END macros,
assuming that architecture even had such a macro upstream. This patch moves
everyone to the same macros, with just a few tweaks remaining in the
<machine/asm.h> files, which no one should now use directly.

I've removed most of the unused cruft from the <machine/asm.h> files, though
there's still rather a lot in the mips/mips64 ones.

Bug: 12229603
Change-Id: I2fff287dc571ac1087abe9070362fb9420d85d6d
diff --git a/libc/arch-x86/bionic/__bionic_clone.S b/libc/arch-x86/bionic/__bionic_clone.S
index 3823ecc..e6ddaaa 100644
--- a/libc/arch-x86/bionic/__bionic_clone.S
+++ b/libc/arch-x86/bionic/__bionic_clone.S
@@ -1,5 +1,4 @@
-#include <asm/unistd.h>
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 // pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
 ENTRY(__bionic_clone)
diff --git a/libc/arch-x86/bionic/__get_sp.S b/libc/arch-x86/bionic/__get_sp.S
index 0739d79..31ec6bc 100644
--- a/libc/arch-x86/bionic/__get_sp.S
+++ b/libc/arch-x86/bionic/__get_sp.S
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 ENTRY(__get_sp)
   mov  %esp, %eax
diff --git a/libc/arch-x86/bionic/_setjmp.S b/libc/arch-x86/bionic/_setjmp.S
index 9221138..0b256a2 100644
--- a/libc/arch-x86/bionic/_setjmp.S
+++ b/libc/arch-x86/bionic/_setjmp.S
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 /*
  * C library -- _setjmp, _longjmp
diff --git a/libc/arch-x86/bionic/setjmp.S b/libc/arch-x86/bionic/setjmp.S
index e149d42..5b94311 100644
--- a/libc/arch-x86/bionic/setjmp.S
+++ b/libc/arch-x86/bionic/setjmp.S
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 /*
  * C library -- setjmp, longjmp
diff --git a/libc/arch-x86/bionic/sigsetjmp.S b/libc/arch-x86/bionic/sigsetjmp.S
index 69494b4..7ef732e 100644
--- a/libc/arch-x86/bionic/sigsetjmp.S
+++ b/libc/arch-x86/bionic/sigsetjmp.S
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 ENTRY(sigsetjmp)
 	movl	4(%esp),%ecx
diff --git a/libc/arch-x86/include/machine/asm.h b/libc/arch-x86/include/machine/asm.h
index 5ccf78f..913e6c8 100644
--- a/libc/arch-x86/include/machine/asm.h
+++ b/libc/arch-x86/include/machine/asm.h
@@ -37,10 +37,6 @@
 #ifndef _I386_ASM_H_
 #define _I386_ASM_H_
 
-#ifdef _KERNEL_OPT
-#include "opt_multiprocessor.h"
-#endif
-
 #ifdef PIC
 #define PIC_PROLOGUE	\
 	pushl	%ebx;	\
@@ -61,27 +57,6 @@
 #define PIC_GOTOFF(x)	x
 #endif
 
-#ifdef __ELF__
-# define _C_LABEL(x)	x
-#else
-# ifdef __STDC__
-#  define _C_LABEL(x)	_ ## x
-# else
-#  define _C_LABEL(x)	_/**/x
-# endif
-#endif
-#define	_ASM_LABEL(x)	x
-
-#define CVAROFF(x, y)		_C_LABEL(x) + y
-
-#ifdef __STDC__
-# define __CONCAT(x,y)	x ## y
-# define __STRING(x)	#x
-#else
-# define __CONCAT(x,y)	x/**/y
-# define __STRING(x)	"x"
-#endif
-
 /* let kernels and others override entrypoint alignment */
 #if !defined(_ALIGN_TEXT) && !defined(_KERNEL)
 # ifdef _STANDALONE
@@ -93,126 +68,4 @@
 # endif
 #endif
 
-#define _ENTRY(x) \
-	.text; _ALIGN_TEXT; .globl x; .type x,@function; x: .cfi_startproc;
-#define _LABEL(x) \
-	.globl x; x:
-
-#ifdef _KERNEL
-
-#define CPUVAR(off) %fs:__CONCAT(CPU_INFO_,off)
-
-/* XXX Can't use __CONCAT() here, as it would be evaluated incorrectly. */
-#ifdef __ELF__
-#ifdef __STDC__
-#define	IDTVEC(name) \
-	ALIGN_TEXT; .globl X ## name; .type X ## name,@function; X ## name:
-#define	IDTVEC_END(name) \
-	.size X ## name, . - X ## name
-#else 
-#define	IDTVEC(name) \
-	ALIGN_TEXT; .globl X/**/name; .type X/**/name,@function; X/**/name:
-#define	IDTVEC_END(name) \
-	.size X/**/name, . - X/**/name
-#endif /* __STDC__ */ 
-#else 
-#ifdef __STDC__
-#define	IDTVEC(name) \
-	ALIGN_TEXT; .globl _X ## name; .type _X ## name,@function; _X ## name: 
-#define	IDTVEC_END(name) \
-	.size _X ## name, . - _X ## name
-#else
-#define	IDTVEC(name) \
-	ALIGN_TEXT; .globl _X/**/name; .type _X/**/name,@function; _X/**/name:
-#define	IDTVEC_END(name) \
-	.size _X/**/name, . - _X/**/name
-#endif /* __STDC__ */
-#endif /* __ELF__ */
-
-#ifdef _STANDALONE
-#define ALIGN_DATA	.align	4
-#define ALIGN_TEXT	.align	4	/* 4-byte boundaries */
-#define SUPERALIGN_TEXT	.align	16	/* 15-byte boundaries */
-#elif defined __ELF__
-#define ALIGN_DATA	.align	4
-#define ALIGN_TEXT	.align	16	/* 16-byte boundaries */
-#define SUPERALIGN_TEXT	.align	16	/* 16-byte boundaries */
-#else
-#define ALIGN_DATA	.align	2
-#define ALIGN_TEXT	.align	4	/* 16-byte boundaries */
-#define SUPERALIGN_TEXT	.align	4	/* 16-byte boundaries */
-#endif /* __ELF__ */
-
-#define _ALIGN_TEXT ALIGN_TEXT
-
-#ifdef GPROF
-#ifdef __ELF__
-#define	MCOUNT_ASM	call	_C_LABEL(__mcount)
-#else /* __ELF__ */
-#define	MCOUNT_ASM	call	_C_LABEL(mcount)
-#endif /* __ELF__ */
-#else /* GPROF */
-#define	MCOUNT_ASM	/* nothing */
-#endif /* GPROF */
-
-#endif /* _KERNEL */
-
-
-
-#ifdef GPROF
-# ifdef __ELF__
-#  define _PROF_PROLOGUE	\
-	pushl %ebp; movl %esp,%ebp; call PIC_PLT(__mcount); popl %ebp
-# else 
-#  define _PROF_PROLOGUE	\
-	pushl %ebp; movl %esp,%ebp; call PIC_PLT(mcount); popl %ebp
-# endif
-#else
-# define _PROF_PROLOGUE
-#endif
-
-#define	ENTRY(y)	_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
-#define	NENTRY(y)	_ENTRY(_C_LABEL(y))
-#define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
-#define	LABEL(y)	_LABEL(_C_LABEL(y))
-#define	END(y)		.cfi_endproc; .size y, . - y
-
-#define	ASMSTR		.asciz
-
-#ifdef __ELF__
-#define RCSID(x)	.pushsection ".ident"; .asciz x; .popsection
-#else
-#define RCSID(x)	.text; .asciz x
-#endif
-
-#ifdef NO_KERNEL_RCSIDS
-#define	__KERNEL_RCSID(_n, _s)	/* nothing */
-#else
-#define	__KERNEL_RCSID(_n, _s)	RCSID(_s)
-#endif
-
-#ifdef __ELF__
-#define	WEAK_ALIAS(alias,sym)						\
-	.weak alias;							\
-	alias = sym
-#endif
-/*
- * STRONG_ALIAS: create a strong alias.
- */
-#define STRONG_ALIAS(alias,sym)						\
-	.globl alias;							\
-	alias = sym
-
-#ifdef __STDC__
-#define	WARN_REFERENCES(sym,msg)					\
-	.pushsection .gnu.warning. ## sym;				\
-	.ascii msg;							\
-	.popsection
-#else
-#define	WARN_REFERENCES(sym,msg)					\
-	.pushsection .gnu.warning./**/sym;				\
-	.ascii msg;							\
-	.popsection
-#endif /* __STDC__ */
-
 #endif /* !_I386_ASM_H_ */
diff --git a/libc/arch-x86/string/bcopy.S b/libc/arch-x86/string/bcopy.S
index 40df1d0..f425c58 100644
--- a/libc/arch-x86/string/bcopy.S
+++ b/libc/arch-x86/string/bcopy.S
@@ -31,7 +31,7 @@
  * SUCH DAMAGE.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 	/*
 	 * (ov)bcopy (src,dst,cnt)
diff --git a/libc/arch-x86/string/memcmp.S b/libc/arch-x86/string/memcmp.S
index 3b50530..ef36b4f 100644
--- a/libc/arch-x86/string/memcmp.S
+++ b/libc/arch-x86/string/memcmp.S
@@ -4,7 +4,7 @@
  * Public domain.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 ENTRY(memcmp)
 	pushl	%edi
diff --git a/libc/arch-x86/string/strcat.S b/libc/arch-x86/string/strcat.S
index c75f38a..49e8eee 100644
--- a/libc/arch-x86/string/strcat.S
+++ b/libc/arch-x86/string/strcat.S
@@ -4,7 +4,7 @@
  * Public domain.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 #if defined(APIWARN)
 #APP
diff --git a/libc/arch-x86/string/strcmp.S b/libc/arch-x86/string/strcmp.S
index 5d3f4fc..580f4d5 100644
--- a/libc/arch-x86/string/strcmp.S
+++ b/libc/arch-x86/string/strcmp.S
@@ -4,7 +4,7 @@
  * Public domain.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 /*
  * NOTE: I've unrolled the loop eight times: large enough to make a
diff --git a/libc/arch-x86/string/strncmp.S b/libc/arch-x86/string/strncmp.S
index 6649473..9ba83a1 100644
--- a/libc/arch-x86/string/strncmp.S
+++ b/libc/arch-x86/string/strncmp.S
@@ -4,7 +4,7 @@
  * Public domain.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 /*
  * NOTE: I've unrolled the loop eight times: large enough to make a
diff --git a/libc/arch-x86/string/swab.S b/libc/arch-x86/string/swab.S
index 2f6cfb2..b44d134 100644
--- a/libc/arch-x86/string/swab.S
+++ b/libc/arch-x86/string/swab.S
@@ -4,7 +4,7 @@
  * Public domain.
  */
 
-#include <machine/asm.h>
+#include <private/bionic_asm.h>
 
 /*
  * On the i486, this code is negligibly faster than the code generated