-/* $Id: assyntax.h,v 1.23 2003/10/21 08:33:10 dborca Exp $ */
#ifndef __ASSYNTAX_H__
#define __ASSYNTAX_H__
#endif
#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__))
-#define CONCAT(x, y) x ## y
+#define CONCAT(x, y) x ## y
+#define CONCAT3(x, y, z) x ## y ## z
#else
-#define CONCAT(x, y) x/**/y
+#define CONCAT(x, y) x/**/y
+#define CONCAT3(x, y, z) x/**/y/**/z
#endif
#ifdef ACK_ASSEMBLER
#define GLOBL CHOICE(.globl, .globl, .extern)
#define GLOBAL GLOBL
#define EXTERN GLOBL
-/*
-#define ALIGNTEXT32 CHOICE(.align 32, .align ARG2(5,0x90), .align 32)
-*/
+#ifndef __AOUT__
#define ALIGNTEXT32 CHOICE(.align 32, .balign 32, .align 32)
#define ALIGNTEXT16 CHOICE(.align 16, .balign 16, .align 16)
#define ALIGNTEXT8 CHOICE(.align 8, .balign 8, .align 8)
#define ALIGNDATA8 CHOICE(.align 8, .balign ARG2(8,0x0), .align 8)
#define ALIGNDATA4 CHOICE(.align 4, .balign ARG2(4,0x0), .align 4)
#define ALIGNDATA2 CHOICE(.align 2, .balign ARG2(2,0x0), .align 2)
+#else
+/* 'as -aout' on FreeBSD doesn't have .balign */
+#define ALIGNTEXT32 CHOICE(.align 32, .align ARG2(5,0x90), .align 32)
+#define ALIGNTEXT16 CHOICE(.align 16, .align ARG2(4,0x90), .align 16)
+#define ALIGNTEXT8 CHOICE(.align 8, .align ARG2(3,0x90), .align 8)
+#define ALIGNTEXT4 CHOICE(.align 4, .align ARG2(2,0x90), .align 4)
+#define ALIGNTEXT2 CHOICE(.align 2, .align ARG2(1,0x90), .align 2)
+/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is
+ * guaranteed to be filled with NOPs. Otherwise it does nothing.
+ */
+#define ALIGNTEXT32ifNOP CHOICE(.align 32, .align ARG2(5,0x90), /*can't do it*/)
+#define ALIGNTEXT16ifNOP CHOICE(.align 16, .align ARG2(4,0x90), /*can't do it*/)
+#define ALIGNTEXT8ifNOP CHOICE(.align 8, .align ARG2(3,0x90), /*can't do it*/)
+#define ALIGNTEXT4ifNOP CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/)
+#define ALIGNDATA32 CHOICE(.align 32, .align ARG2(5,0x0), .align 32)
+#define ALIGNDATA16 CHOICE(.align 16, .align ARG2(4,0x0), .align 16)
+#define ALIGNDATA8 CHOICE(.align 8, .align ARG2(3,0x0), .align 8)
+#define ALIGNDATA4 CHOICE(.align 4, .align ARG2(2,0x0), .align 4)
+#define ALIGNDATA2 CHOICE(.align 2, .align ARG2(1,0x0), .align 2)
+#endif /* __AOUT__ */
#define FILE(s) CHOICE(.file s, .file s, .file s)
#define STRING(s) CHOICE(.string s, .asciz s, .asciz s)
#define D_LONG CHOICE(.long, .long, .data4)
/* Addressing Modes */
/* Immediate Mode */
-#define ADDR(a) CHOICE(CONCAT($,a), CONCAT($,a), a)
-#define CONST(a) CHOICE(CONCAT($,a), CONCAT($,a), a)
+#define ADDR(a) CHOICE(CONCAT($,a), $a, a)
+#define CONST(a) CHOICE(CONCAT($,a), $a, a)
/* Indirect Mode */
#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */
#define P_XMM6 xmm6
#define P_XMM7 xmm7
-#define CONCAT(x, y) x ## y
+#define CONCAT(x, y) x ## y
+#define CONCAT3(x, y, z) x ## y ## z
#if defined(NASM_ASSEMBLER)
#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) \
|| (defined(__linux__) || defined(__OS2ELF__)) && defined(__ELF__) \
- || defined(__FreeBSD__) && __FreeBSD__ >= 3
+ || (defined(__FreeBSD__) && __FreeBSD__ >= 3) \
+ || (defined(__NetBSD__) && defined(__ELF__))
#define GLNAME(a) a
#else
#define GLNAME(a) CONCAT(_, a)
#define LEAVE leave
#define LGDT(a) lgdt a
#define LIDT(a) lidt a
-#define LDS(a, b) lds b, a
-#define LES(a, b) les b, a
-#define LFS(a, b) lfs b, a
-#define LGS(a, b) lgs b, a
-#define LSS(a, b) lss b, a
+#define LDS(a, b) lds b, P_(a)
+#define LES(a, b) les b, P_(a)
+#define LFS(a, b) lfs b, P_(a)
+#define LGS(a, b) lgs b, P_(a)
+#define LSS(a, b) lss b, P_(a)
#define LLDT(a) lldt a
#define LMSW(a) lmsw a
#define LOCK lock
#define REPZ REPE
#define RET ret
#define SAHF sahf
-#define SAL_L(a, b) sal L_(b), L_(a)
-#define SAL_W(a, b) sal W_(b), W_(a)
+#define SAL_L(a, b) sal L_(b), B_(a)
+#define SAL_W(a, b) sal W_(b), B_(a)
#define SAL_B(a, b) sal B_(b), B_(a)
-#define SAR_L(a, b) sar L_(b), L_(a)
-#define SAR_W(a, b) sar W_(b), W_(a)
+#define SAR_L(a, b) sar L_(b), B_(a)
+#define SAR_W(a, b) sar W_(b), B_(a)
#define SAR_B(a, b) sar B_(b), B_(a)
#define SBB_L(a, b) sbb L_(b), L_(a)
#define SBB_W(a, b) sbb W_(b), W_(a)
/* Added by BrianP for FreeBSD (per David Dawes) */
#if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER) && !defined(__bsdi__)
#define LLBL(a) CONCAT(.L,a)
+#define LLBL2(a,b) CONCAT3(.L,a,b)
#else
#define LLBL(a) a
+#define LLBL2(a,b) CONCAT(a,b)
#endif
/* Segment overrides */
#define TLBL(a) CONCAT(a,$)
#endif
+/* Hidden symbol visibility support.
+ * If we build with gcc's -fvisibility=hidden flag, we'll need to change
+ * the symbol visibility mode to 'default'.
+ */
+#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__)
+# define HIDDEN(x) .hidden x
+#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 && !defined(__DJGPP__) && !defined(__MINGW32__)
+# pragma GCC visibility push(default)
+# define HIDDEN(x) .hidden x
+#else
+# define HIDDEN(x)
+#endif
+
#endif /* __ASSYNTAX_H__ */