lib9: make a p9frexp function wrapping system frexp

Under certain conditions it looks like frexp gets #defined
to something else on macOS during system headers,
which then breaks the declaration in libc.h.
This commit is contained in:
Russ Cox 2020-01-08 22:28:44 -05:00
parent fafa622a5b
commit e0c4896ed4
3 changed files with 13 additions and 1 deletions

View file

@ -383,7 +383,7 @@ extern int encodefmt(Fmt*);
extern int dirmodefmt(Fmt*);
extern int exitcode(char*);
extern void exits(char*);
extern double frexp(double, int*);
extern double p9frexp(double, int*);
extern ulong getcallerpc(void*);
#if defined(__GNUC__) || defined(__clang__)
#define getcallerpc(x) ((ulong)__builtin_return_address(0))
@ -436,6 +436,8 @@ extern void (*_unpin)(void);
#define atoll p9atoll
#define encrypt p9encrypt
#define decrypt p9decrypt
#undef frexp
#define frexp p9frexp
#define getenv p9getenv
#define getwd p9getwd
#define longjmp p9longjmp

9
src/lib9/frexp.c Normal file
View file

@ -0,0 +1,9 @@
#include <u.h>
#define NOPLAN9DEFINES
#include <libc.h>
double
p9frexp(double d, int *i)
{
return frexp(d, i);
}

View file

@ -22,6 +22,7 @@ FMTOFILES=\
fmtstr.$O\
fmtvprint.$O\
fprint.$O\
frexp.$O\
nan64.$O\
print.$O\
runefmtstr.$O\