#ifndef _AMD64_ASM_H_
#define _AMD64_ASM_H_
#ifdef __x86_64__
#ifdef __PIC__
#define PIC_PLT(x) x@PLT
#define PIC_GOT(x) x@GOTPCREL(%rip)
#else
#define PIC_PLT(x) x
#define PIC_GOT(x) x
#endif
#define _C_LABEL(x) x
#define _ASM_LABEL(x) x
#define CVAROFF(x,y) (_C_LABEL(x)+y)(%rip)
#ifdef __STDC__
# define __CONCAT(x,y) x ## y
# define __STRING(x) #x
#else
# define __CONCAT(x,y) xy
# define __STRING(x) "x"
#endif
#ifndef _ALIGN_TEXT
# ifdef _STANDALONE
# define _ALIGN_TEXT .align 4
# else
# define _ALIGN_TEXT .align 16
# endif
#endif
#define _ENTRY(x) \
.text; _ALIGN_TEXT; .globl x; .type x,@function; x:
#define _LABEL(x) \
.globl x; x:
#ifdef _KERNEL
#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 Xname; .type Xname,@function; Xname:
#define IDTVEC_END(name) \
.size Xname, . - Xname
#endif
#endif
#ifdef __STDC__
#define CPUVAR(off) %gs:CPU_INFO_ ## off
#else
#define CPUVAR(off) %gs:CPU_INFO_off
#endif
#ifdef GPROF
# define _PROF_PROLOGUE \
pushq %rbp; leaq (%rsp),%rbp; call PIC_PLT(__mcount); popq %rbp
#else
# define _PROF_PROLOGUE
#endif
#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
#define NENTRY(y) _ENTRY(_C_LABEL(y))
#define ALTENTRY(x) NENTRY(x)
#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
#define LABEL(y) _LABEL(_C_LABEL(y))
#define END(y) .size y, . - y
#define ASMSTR .asciz
#define _IDENTSTR(x) .pushsection ".ident","MS",@progbits,1; \
x; \
.popsection
#ifdef _NETBSD_REVISIONID
#define RCSID(_s) \
_IDENTSTR(.asciz _s); \
_IDENTSTR(.ascii "$"; .ascii "NetBSD: "; .ascii __FILE__; .ascii " "; \
.ascii _NETBSD_REVISIONID; .asciz " $")
#else
#define RCSID(_s) _IDENTSTR(.asciz _s)
#endif
#define WEAK_ALIAS(alias,sym) \
.weak alias; \
alias = sym
#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
#else
#include <i386/asm.h>
#endif
#endif