diff options
author | bde <bde@FreeBSD.org> | 1997-02-16 18:26:31 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1997-02-16 18:26:31 +0000 |
commit | 9e8f1bd4ec847780eb9aaf168c43f1271f0e37f5 (patch) | |
tree | ceebd776f63210707bd1eec59b604a7213f9a2ac /sys/amd64/include/asmacros.h | |
parent | 85bd6daaf1022d92875e9125182a7b3db3f3b183 (diff) | |
download | FreeBSD-src-9e8f1bd4ec847780eb9aaf168c43f1271f0e37f5.zip FreeBSD-src-9e8f1bd4ec847780eb9aaf168c43f1271f0e37f5.tar.gz |
Select between the generic math functions and the i387-specific ones
at runtime.
etc/make.conf:
Nuked HAVE_FPU option.
lib/msun/Makefile:
Always build the i387 objects. Copy the i387 source files at build
time so that the i387 objects have different names. This is simpler
than renaming the files in the cvs repository or repeating half of
bsd.lib.mk to add explicit rules.
lib/msun/src/*.c:
Renamed all functions that have an i387-specific version by adding
`__generic_' to their names.
lib/msun/src/get_hw_float.c:
New file for getting machdep.hw_float from the kernel.
sys/i386/include/asmacros.h:
Abuse the ENTRY() macro to generate jump vectors and associated code.
This works much like PIC PLT dynamic initialization. The PIC case is
messy. The old i387 entry points are renamed. Renaming is easier
here because the names are given by macro expansions.
Diffstat (limited to 'sys/amd64/include/asmacros.h')
-rw-r--r-- | sys/amd64/include/asmacros.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/sys/amd64/include/asmacros.h b/sys/amd64/include/asmacros.h index d918853..3cfedeb 100644 --- a/sys/amd64/include/asmacros.h +++ b/sys/amd64/include/asmacros.h @@ -127,6 +127,83 @@ #include "/usr/src/lib/libc/i386/DEFS.h" /* XXX blech */ +/* + * In the !KERNEL case, this header is only (ab)used in lib/msun/i387. + * Use it to generate code to select between the generic math functions + * and the i387 ones. + */ +#undef ENTRY +#define ANAME(x) CNAME(__CONCAT(__i387_,x)) +#define ASELNAME(x) CNAME(__CONCAT(__arch_select_,x)) +#define AVECNAME(x) CNAME(__CONCAT(__arch_,x)) +#define GNAME(x) CNAME(__CONCAT(__generic_,x)) + +/* Don't bother profiling this. */ +#ifdef PIC +#define ARCH_DISPATCH(x) \ + START_ENTRY; \ + .globl CNAME(x); .type CNAME(x),@function; CNAME(x): ; \ + PIC_PROLOGUE; \ + movl PIC_GOT(AVECNAME(x)),%eax; \ + PIC_EPILOGUE; \ + jmpl *(%eax) + +#define ARCH_SELECT(x) START_ENTRY; \ + .type ASELNAME(x),@function; \ + ASELNAME(x): \ + PIC_PROLOGUE; \ + call PIC_PLT(CNAME(__get_hw_float)); \ + testl %eax,%eax; \ + movl PIC_GOT(ANAME(x)),%eax; \ + jne 8f; \ + movl PIC_GOT(GNAME(x)),%eax; \ + 8: \ + movl PIC_GOT(AVECNAME(x)),%edx; \ + movl %eax,(%edx); \ + PIC_EPILOGUE; \ + jmpl *%eax +#else /* !PIC */ +#define ARCH_DISPATCH(x) \ + START_ENTRY; \ + .globl CNAME(x); .type CNAME(x),@function; CNAME(x): ; \ + jmpl *AVECNAME(x) + +#define ARCH_SELECT(x) START_ENTRY; \ + .type ASELNAME(x),@function; \ + ASELNAME(x): \ + call CNAME(__get_hw_float); \ + testl %eax,%eax; \ + movl $ANAME(x),%eax; \ + jne 8f; \ + movl $GNAME(x),%eax; \ + 8: \ + movl %eax,AVECNAME(x); \ + jmpl *%eax +#endif /* PIC */ + +#define ARCH_VECTOR(x) .data; .align 2; \ + .globl AVECNAME(x); \ + .type AVECNAME(x),@object; \ + .size AVECNAME(x),4; \ + AVECNAME(x): .long ASELNAME(x) + +#ifdef PROF + +#define ALTENTRY(x) ENTRY(x); jmp 9f +#define ENTRY(x) ARCH_VECTOR(x); ARCH_SELECT(x); ARCH_DISPATCH(x); \ + START_ENTRY; \ + .globl ANAME(x); .type ANAME(x),@function; ANAME(x):; \ + call HIDENAME(mcount); 9: + +#else /* !PROF */ + +#define ALTENTRY(x) ENTRY(x) +#define ENTRY(x) ARCH_VECTOR(x); ARCH_SELECT(x); ARCH_DISPATCH(x); \ + START_ENTRY; \ + .globl ANAME(x); .type ANAME(x),@function; ANAME(x): + +#endif /* PROF */ + #ifndef RCSID #define RCSID(a) #endif |