Double Precision Floating Math implementation
This commit is contained in:
10
cross.mk
10
cross.mk
@@ -18,14 +18,6 @@ TAGSFILE = tags
|
||||
MANROFF = nroff -man -h
|
||||
ELF2AOUT = cp
|
||||
|
||||
CFLAGS = -O -DCROSS
|
||||
CFLAGS = -O -DCROSS -I/usr/include -I$(TOPSRC)/include
|
||||
LDFLAGS =
|
||||
LIBS =
|
||||
|
||||
# Add system include path
|
||||
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
|
||||
CFLAGS += -I/usr/include
|
||||
else
|
||||
CFLAGS += -I/usr/include/i386-linux-gnu
|
||||
endif
|
||||
CFLAGS += -I$(TOPSRC)/include
|
||||
|
||||
@@ -12,8 +12,9 @@ extern double sinh(), cosh(), tanh();
|
||||
extern double gamma();
|
||||
extern double j0(), j1(), jn(), y0(), y1(), yn();
|
||||
|
||||
#define HUGE 1.701411733192644270e38
|
||||
#define LOGHUGE 39
|
||||
// ###PITO #define HUGE 1.701411733192644270e38
|
||||
#define HUGE 1.79769313486231570000e+308
|
||||
#define LOGHUGE 307
|
||||
|
||||
int isnanf(float x);
|
||||
int isnan(double x);
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#define va_copy(dest, src) __builtin_va_copy((dest), (src))
|
||||
|
||||
|
||||
#ifndef _VA_LIST_T
|
||||
#define _VA_LIST_T
|
||||
#ifndef _VA_LIST
|
||||
#define _VA_LIST
|
||||
#ifdef __GNUC__
|
||||
typedef __builtin_va_list va_list;
|
||||
#endif
|
||||
|
||||
10
lib/Makefile
10
lib/Makefile
@@ -5,15 +5,9 @@ PROG = ar as aout ld nm ranlib size strip
|
||||
# Build a list of the host include directories.
|
||||
CPP = $(shell gcc -print-prog-name=cc1)
|
||||
HOSTINC = $(addprefix -I,$(shell echo | $(CPP) -v 2>&1 | grep '^ /.*include'))
|
||||
HOSTINC += -I/usr/include/i386-linux-gnu
|
||||
|
||||
# Add system include path
|
||||
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
|
||||
HOSTINC += -I/usr/include
|
||||
else
|
||||
HOSTINC += -I/usr/include/i386-linux-gnu
|
||||
endif
|
||||
|
||||
CFLAGS += -nostdinc -fno-builtin -g -Werror -Wall -DCROSS -I. $(HOSTINC) \
|
||||
CFLAGS += -nostdinc -g -Werror -Wall -DCROSS -I. $(HOSTINC) \
|
||||
-I$(TOPSRC)/include -I$(TOPSRC)/src/cmd/ar \
|
||||
-I$(TOPSRC)/src/cmd/as
|
||||
LDFLAGS += -g
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS += ${DEFS} -Os
|
||||
CFLAGS += ${DEFS}
|
||||
|
||||
SRCS = creat.c ftime.c gethostid.c gtty.c memccpy.c memchr.c memcmp.c \
|
||||
memcpy.c memset.c nice.c pause.c rand.c sethostid.c \
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS += ${DEFS} -Os -Wall -Werror
|
||||
CFLAGS += ${DEFS}
|
||||
|
||||
SRCS = ${STDSRC}
|
||||
OBJS = ${STDOBJ}
|
||||
@@ -19,7 +19,7 @@ STDSRC = abort.c alarm.c atof.c atoi.c atol.c calloc.c closedir.c crypt.c \
|
||||
getpass.c getpwent.c getloadavg.c getmntinfo.c \
|
||||
getttyent.c getttynam.c getusershell.c getwd.c \
|
||||
initgroups.c isatty.c isinff.c isnanf.c ldexp.c malloc.c mktemp.c \
|
||||
modff.c ndbm.c nlist.c knlist.c opendir.c perror.c popen.c \
|
||||
modff.c modf.c ndbm.c nlist.c knlist.c opendir.c perror.c popen.c \
|
||||
psignal.c qsort.c random.c readdir.c regex.c scandir.c \
|
||||
seekdir.c setmode.c sethostname.c setenv.c siglist.c \
|
||||
signal.c siginterrupt.c sigsetops.c \
|
||||
@@ -36,7 +36,7 @@ STDOBJ = abort.o alarm.o atof.o atoi.o atol.o calloc.o closedir.o crypt.o \
|
||||
getpass.o getpwent.o getloadavg.o getmntinfo.o \
|
||||
getttyent.o getttynam.o getusershell.o getwd.o \
|
||||
initgroups.o isatty.o isinff.o isnanf.o ldexp.o malloc.o mktemp.o \
|
||||
modff.o ndbm.o nlist.o knlist.o opendir.o perror.o popen.o \
|
||||
modff.o modf.o ndbm.o nlist.o knlist.o opendir.o perror.o popen.o \
|
||||
psignal.o qsort.o random.o readdir.o regex.o scandir.o \
|
||||
seekdir.o setmode.o sethostname.o setenv.o siglist.o \
|
||||
signal.o siginterrupt.o sigsetops.o \
|
||||
|
||||
@@ -13,15 +13,9 @@
|
||||
*/
|
||||
int isinff (float x)
|
||||
{
|
||||
union {
|
||||
long s32;
|
||||
float f32;
|
||||
} u;
|
||||
long v;
|
||||
|
||||
u.f32 = x;
|
||||
v = (u.s32 & 0x7fffffff) ^ 0x7f800000;
|
||||
return ~((v | -v) >> 31) & (u.s32 >> 30);
|
||||
long lx = *(long*) &x;
|
||||
long v = (lx & 0x7fffffff) ^ 0x7f800000;
|
||||
return ~((v | -v) >> 31) & (lx >> 30);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -13,15 +13,10 @@
|
||||
*/
|
||||
int isnanf (float x)
|
||||
{
|
||||
union {
|
||||
long s32;
|
||||
float f32;
|
||||
} u;
|
||||
unsigned long ul;
|
||||
long lx = *(long*) &x;
|
||||
|
||||
u.f32 = x;
|
||||
ul = 0x7f800000 - (u.s32 & 0x7fffffff);
|
||||
return ul >> 31;
|
||||
lx = 0x7f800000 - (lx & 0x7fffffff);
|
||||
return (int) (((unsigned long) lx) >> 31);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
#include <math.h>
|
||||
#include <ieee.h>
|
||||
|
||||
static const double
|
||||
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
|
||||
twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
|
||||
huge = 1.0e+308,
|
||||
tiny = 1.0e-307;
|
||||
|
||||
static double
|
||||
_copysign(double x, double y)
|
||||
{
|
||||
unsigned long hx,hy;
|
||||
GET_HIGH_WORD(hx,x);
|
||||
GET_HIGH_WORD(hy,y);
|
||||
SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
|
||||
return x;
|
||||
}
|
||||
|
||||
double
|
||||
ldexp(fr, exp)
|
||||
double fr;
|
||||
int exp;
|
||||
ldexp(double x, int n)
|
||||
{
|
||||
double huge = 1.701411834604692293e38;
|
||||
int neg;
|
||||
int i;
|
||||
|
||||
neg = 0;
|
||||
if (fr < 0) {
|
||||
fr = -fr;
|
||||
neg = 1;
|
||||
unsigned long k,hx,lx;
|
||||
EXTRACT_WORDS(hx,lx,x);
|
||||
k = (hx&0x7ff00000)>>20; /* extract exponent */
|
||||
if (k==0) { /* 0 or subnormal x */
|
||||
if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
|
||||
x *= two54;
|
||||
GET_HIGH_WORD(hx,x);
|
||||
k = ((hx&0x7ff00000)>>20) - 54;
|
||||
if (n< -50000) return tiny*x; /*underflow*/
|
||||
}
|
||||
if (k==0x7ff) return x+x; /* NaN or Inf */
|
||||
k = k+n;
|
||||
if (k > 0x7fe) return huge*_copysign(huge,x); /* overflow */
|
||||
if (k > 0) /* normal result */
|
||||
{SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
|
||||
if (k <= -54) {
|
||||
if (n > 50000) /* in case integer overflow in n+k */
|
||||
return huge*_copysign(huge,x); /*overflow*/
|
||||
else return tiny*_copysign(tiny,x); /*underflow*/
|
||||
}
|
||||
fr = frexp(fr, &i);
|
||||
while (fr < 0.5) {
|
||||
fr = 2*fr;
|
||||
i = i-1;
|
||||
}
|
||||
exp = exp+i;
|
||||
if (exp > 127) {
|
||||
if (neg)
|
||||
return(-huge);
|
||||
else
|
||||
return(huge);
|
||||
}
|
||||
if (exp < -127)
|
||||
return(0);
|
||||
while (exp > 30) {
|
||||
fr = fr*(1L<<30);
|
||||
exp = exp-30;
|
||||
}
|
||||
while (exp < -30) {
|
||||
fr = fr/(1L<<30);
|
||||
exp = exp+30;
|
||||
}
|
||||
if (exp > 0)
|
||||
fr = fr*(1L<<exp);
|
||||
if (exp < 0)
|
||||
fr = fr/(1L<<-exp);
|
||||
if (neg)
|
||||
fr = -fr;
|
||||
return(fr);
|
||||
k += 54; /* subnormal result */
|
||||
SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
|
||||
return x*twom54;
|
||||
}
|
||||
|
||||
@@ -1,79 +1,95 @@
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
#include <math.h>
|
||||
// *** modified by Pito 11/2013 for RetroBSD ***
|
||||
|
||||
typedef union // LITTLE ENDIAN
|
||||
{
|
||||
double value;
|
||||
struct
|
||||
{
|
||||
unsigned long lsw;
|
||||
unsigned long msw;
|
||||
} parts;
|
||||
} ieee_double_shape_type;
|
||||
|
||||
/* Get two 32 bit ints from a double. */
|
||||
|
||||
#define EXTRACT_WORDS(high,low,d) \
|
||||
high = *(unsigned long long*) &d; \
|
||||
low = (*(unsigned long long*) &d) >> 32
|
||||
#define EXTRACT_WORDS(ix0,ix1,d) \
|
||||
do { \
|
||||
ieee_double_shape_type ew_u; \
|
||||
ew_u.value = (d); \
|
||||
(ix0) = ew_u.parts.msw; \
|
||||
(ix1) = ew_u.parts.lsw; \
|
||||
} while (0)
|
||||
|
||||
/* Get the more significant 32 bit int from a double. */
|
||||
|
||||
#define GET_HIGH_WORD(i,d) \
|
||||
do { \
|
||||
ieee_double_shape_type gh_u; \
|
||||
gh_u.value = (d); \
|
||||
(i) = gh_u.parts.msw; \
|
||||
} while (0)
|
||||
|
||||
/* Set a double from two 32 bit ints. */
|
||||
|
||||
#define INSERT_WORDS(d,high,low) \
|
||||
*(unsigned long long*) &(x) = (unsigned long long) (high) << 32 | (low)
|
||||
#define INSERT_WORDS(d,ix0,ix1) \
|
||||
do { \
|
||||
ieee_double_shape_type iw_u; \
|
||||
iw_u.parts.msw = (ix0); \
|
||||
iw_u.parts.lsw = (ix1); \
|
||||
(d) = iw_u.value; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* modf(double x, double *iptr)
|
||||
* return fraction part of x, and return x's integral part in *iptr.
|
||||
* Method:
|
||||
* Bit twiddling.
|
||||
*
|
||||
* Exception:
|
||||
* No exception.
|
||||
*/
|
||||
static const double one = 1.0;
|
||||
|
||||
double modf (double x, double *iptr)
|
||||
double modf(double x, double *iptr)
|
||||
{
|
||||
long i0, i1, j0;
|
||||
unsigned long i;
|
||||
|
||||
EXTRACT_WORDS (i0, i1, x);
|
||||
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; /* exponent of x */
|
||||
if (j0 < 20) { /* integer part in high x */
|
||||
if (j0 < 0) { /* |x|<1 */
|
||||
INSERT_WORDS (*iptr, i0 & 0x80000000, 0);
|
||||
/* *iptr = +-0 */
|
||||
return x;
|
||||
} else {
|
||||
i = (0x000fffff) >> j0;
|
||||
if (((i0 & i) | i1) == 0) { /* x is integral */
|
||||
*iptr = x;
|
||||
INSERT_WORDS (x, i0 & 0x80000000, 0);
|
||||
/* return +-0 */
|
||||
return x;
|
||||
} else {
|
||||
INSERT_WORDS (*iptr, i0 & (~i), 0);
|
||||
return x - *iptr;
|
||||
}
|
||||
}
|
||||
} else if (j0 > 51) { /* no fraction part */
|
||||
*iptr = x * one;
|
||||
/* We must handle NaNs separately. */
|
||||
if (j0 == 0x400 && ((i0 & 0xfffff) | i1))
|
||||
return x * one;
|
||||
|
||||
INSERT_WORDS (x, i0 & 0x80000000, 0);
|
||||
/* return +-0 */
|
||||
return x;
|
||||
} else { /* fraction part in low x */
|
||||
i = ((unsigned long) (0xffffffff)) >> (j0 - 20);
|
||||
if ((i1 & i) == 0) { /* x is integral */
|
||||
*iptr = x;
|
||||
INSERT_WORDS (x, i0 & 0x80000000, 0);
|
||||
/* return +-0 */
|
||||
return x;
|
||||
} else {
|
||||
INSERT_WORDS (*iptr, i0, i1 & (~i));
|
||||
return x - *iptr;
|
||||
}
|
||||
}
|
||||
long int i0,i1,j0;
|
||||
unsigned long i;
|
||||
double one = 1.0;
|
||||
EXTRACT_WORDS(i0,i1,x);
|
||||
j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */
|
||||
if(j0<20) { /* integer part in high x */
|
||||
if(j0<0) { /* |x|<1 */
|
||||
INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */
|
||||
return x;
|
||||
} else {
|
||||
i = (0x000fffff)>>j0;
|
||||
if(((i0&i)|i1)==0) { /* x is integral */
|
||||
unsigned long high;
|
||||
*iptr = x;
|
||||
GET_HIGH_WORD(high,x);
|
||||
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
|
||||
return x;
|
||||
} else {
|
||||
INSERT_WORDS(*iptr,i0&(~i),0);
|
||||
return x - *iptr;
|
||||
}
|
||||
}
|
||||
} else if (j0>51) { /* no fraction part */
|
||||
unsigned long high;
|
||||
*iptr = x*one;
|
||||
GET_HIGH_WORD(high,x);
|
||||
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
|
||||
return x;
|
||||
} else { /* fraction part in low x */
|
||||
i = ((unsigned long)(0xffffffff))>>(j0-20);
|
||||
if((i1&i)==0) { /* x is integral */
|
||||
unsigned long high;
|
||||
*iptr = x;
|
||||
GET_HIGH_WORD(high,x);
|
||||
INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */
|
||||
return x;
|
||||
} else {
|
||||
INSERT_WORDS(*iptr,i0,i1&(~i));
|
||||
return x - *iptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,43 +13,35 @@
|
||||
*/
|
||||
static const float one = 1.0;
|
||||
|
||||
float modff (float fx, float *iptr)
|
||||
float modff (float x, float *iptr)
|
||||
{
|
||||
union {
|
||||
unsigned u32;
|
||||
float f32;
|
||||
} x;
|
||||
unsigned hx, s;
|
||||
unsigned hx = *(unsigned*) &x & ~0x80000000;
|
||||
unsigned s;
|
||||
|
||||
x.f32 = fx;
|
||||
hx = x.u32 & ~0x80000000;
|
||||
if (hx >= 0x4b000000) { /* x is NaN, infinite, or integral */
|
||||
*iptr = x.f32;
|
||||
*iptr = x;
|
||||
if (hx <= 0x7f800000)
|
||||
x.u32 &= 0x80000000;
|
||||
return x.f32;
|
||||
*(unsigned*) &x &= 0x80000000;
|
||||
return x;
|
||||
}
|
||||
|
||||
if (hx < 0x3f800000) { /* |x| < 1 */
|
||||
float ret = x.f32;
|
||||
x.u32 &= 0x80000000;
|
||||
*iptr = x.f32;
|
||||
return ret;
|
||||
*iptr = x;
|
||||
*(unsigned*) iptr &= 0x80000000;
|
||||
return x;
|
||||
}
|
||||
|
||||
/* split x at the binary point */
|
||||
s = x.u32 & 0x80000000;
|
||||
fx = x.f32;
|
||||
x.u32 &= ~((1 << (0x96 - (hx >> 23))) - 1);
|
||||
*iptr = x.f32;
|
||||
x.f32 = fx - *iptr;
|
||||
s = *(unsigned*) &x & 0x80000000;
|
||||
*(unsigned*) iptr = *(unsigned*) &x & ~((1 << (0x96 - (hx >> 23))) - 1);
|
||||
x -= *iptr;
|
||||
|
||||
/* restore sign in case difference is 0 */
|
||||
x.u32 = (x.u32 & ~0x80000000) | s;
|
||||
return x.f32;
|
||||
*(unsigned*) &x = (*(unsigned*) &x & ~0x80000000) | s;
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
* For PIC32, double is the same as float.
|
||||
*/
|
||||
double modf (double x, double *iptr) __attribute__((alias ("modff")));
|
||||
//double modf (double x, double *iptr) __attribute__((alias ("modff")));
|
||||
|
||||
@@ -465,7 +465,7 @@ dbm_nextkey(db)
|
||||
db->dbm_flags |= _DBM_IOERR;
|
||||
#endif
|
||||
}
|
||||
if (db->dbm_pagbuf[0] != 0 && db->dbm_pagbuf[1] != 0) {
|
||||
if (((short *)db->dbm_pagbuf)[0] != 0) {
|
||||
item = makdatum(db->dbm_pagbuf, db->dbm_keyptr);
|
||||
if (item.dptr != NULL) {
|
||||
db->dbm_keyptr += 2;
|
||||
|
||||
@@ -2,7 +2,6 @@ TOPSRC = $(shell cd ../../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
ASFLAGS += ${DEFS}
|
||||
CFLAGS += -Os
|
||||
|
||||
# modules which can not use SYSCALL and must be assembled from sources. The
|
||||
# rest of the system calls are generated with printf(1) and do not have
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
CFLAGS += ${DEFS} -Os
|
||||
CFLAGS += ${DEFS}
|
||||
|
||||
SRCS = ${STDSRC} fgetc.c fgets.c fputc.c fputs.c gets.c puts.c \
|
||||
feof.c ferror.c fileno.c
|
||||
|
||||
@@ -42,7 +42,9 @@
|
||||
#include <math.h>
|
||||
|
||||
/* Max number conversion buffer length: a long in base 2, plus NUL byte. */
|
||||
#define MAXNBUF (sizeof(long) * 8 + 1)
|
||||
//#define MAXNBUF (sizeof(long) * 8 + 1)
|
||||
/* Max number conversion buffer length: MAXEXP(308) + MAXFRACTION(15) + 2 */
|
||||
#define MAXNBUF 308+15+2
|
||||
|
||||
static unsigned char *ksprintn (unsigned char *buf, unsigned long v, unsigned char base,
|
||||
int width, unsigned char *lp);
|
||||
@@ -361,7 +363,20 @@ number: if (sign && ((long) ul != 0L)) {
|
||||
case 'F':
|
||||
case 'g':
|
||||
case 'G': {
|
||||
double d = va_arg (ap, double);
|
||||
|
||||
double d;
|
||||
unsigned long *l = (unsigned long *) &d;
|
||||
|
||||
if (*(unsigned long*)&ap & 4) {
|
||||
l[0]= va_arg(ap, unsigned long);
|
||||
l[1]= va_arg(ap, unsigned long);
|
||||
}
|
||||
else {
|
||||
l[0]= va_arg(ap, unsigned long);
|
||||
l[0]= va_arg(ap, unsigned long);
|
||||
l[1]= va_arg(ap, unsigned long);
|
||||
}
|
||||
|
||||
/*
|
||||
* don't do unrealistic precision; just pad it with
|
||||
* zeroes later, so buffer size stays rational.
|
||||
@@ -583,10 +598,11 @@ cvt (double number, int prec, int sharpflag, unsigned char *negp, unsigned char
|
||||
* get integer portion of number; put into the end of the buffer; the
|
||||
* .01 is added for modf (356.0 / 10, &integer) returning .59999999...
|
||||
*/
|
||||
for (p = endp - 1; integer; ++expcnt) {
|
||||
tmp = modf (integer / 10, &integer);
|
||||
*p-- = (int) ((tmp + .01) * 10) + '0';
|
||||
}
|
||||
p = endp - 1;
|
||||
for (; integer && p >= startp; ++expcnt) {
|
||||
tmp = modf(integer * 0.1L , &integer);
|
||||
*p-- = (int)((tmp + .01L) * 10) + '0';
|
||||
}
|
||||
switch (fmtch) {
|
||||
case 'f':
|
||||
/* reverse integer into beginning of buffer */
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define HAVE_FLOAT 1
|
||||
|
||||
#define SPC 01
|
||||
#define STP 02
|
||||
|
||||
@@ -7,7 +7,7 @@ TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
DEFS =
|
||||
CFLAGS += ${DEFS} -Os
|
||||
CFLAGS += ${DEFS}
|
||||
|
||||
SRCS = getopt.c getsubopt.c strtol.c strtoul.c strtod.c
|
||||
OBJS = getopt.o getsubopt.o strtol.o strtoul.o strtod.o
|
||||
|
||||
@@ -7,7 +7,7 @@ TOPSRC = $(shell cd ../../..; pwd)
|
||||
include $(TOPSRC)/target.mk
|
||||
|
||||
DEFS =
|
||||
CFLAGS += ${DEFS} -Os
|
||||
CFLAGS += ${DEFS}
|
||||
|
||||
SRCS = strcspn.c strpbrk.c strerror.c strsep.c strspn.c strstr.c strtok.c strtok_r.c
|
||||
OBJS = strcspn.o strpbrk.o strerror.o strsep.o strspn.o strstr.o strtok.o strtok_r.o
|
||||
|
||||
@@ -39,15 +39,17 @@ asin(arg)
|
||||
|
||||
double
|
||||
acos(arg)
|
||||
double arg;
|
||||
double arg;
|
||||
{
|
||||
if(arg < 0)
|
||||
arg = -arg;
|
||||
double sign = 1.0;
|
||||
if(arg < 0.0){
|
||||
arg = -arg;
|
||||
sign = -1.0;
|
||||
}
|
||||
if(arg > 1.0){
|
||||
errno = EDOM;
|
||||
return(0.0);
|
||||
}
|
||||
|
||||
if(arg > 1.){
|
||||
errno = EDOM;
|
||||
return(0.);
|
||||
}
|
||||
|
||||
return(pio2 - asin(arg));
|
||||
return(pio2 - sign*asin(arg));
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
double static sq2p1 =2.414213562373095048802e0;
|
||||
static double sq2p1 =2.414213562373095048802e0;
|
||||
static double sq2m1 = .414213562373095048802e0;
|
||||
static double pio2 =1.570796326794896619231e0;
|
||||
static double pio4 = .785398163397448309615e0;
|
||||
|
||||
@@ -1,23 +1,47 @@
|
||||
/* Get two 32 bit ints from a double. */
|
||||
|
||||
#define EXTRACT_WORDS(high,low,d) \
|
||||
high = *(unsigned long long*) &d; \
|
||||
low = (*(unsigned long long*) &d) >> 32
|
||||
|
||||
|
||||
/* Set a double from two 32 bit ints. */
|
||||
|
||||
#define INSERT_WORDS(d,high,low) \
|
||||
*(unsigned long long*) &(x) = (unsigned long long) (high) << 32 | (low)
|
||||
|
||||
|
||||
typedef union
|
||||
typedef union // LITTLE ENDIAN
|
||||
{
|
||||
double value;
|
||||
struct
|
||||
{
|
||||
uint32_t lsw;
|
||||
uint32_t msw;
|
||||
unsigned long lsw;
|
||||
unsigned long msw;
|
||||
} parts;
|
||||
} ieee_double_shape_type;
|
||||
|
||||
/* Get two 32 bit ints from a double. */
|
||||
|
||||
#define EXTRACT_WORDS(ix0,ix1,d) \
|
||||
do { \
|
||||
ieee_double_shape_type ew_u; \
|
||||
ew_u.value = (d); \
|
||||
(ix0) = ew_u.parts.msw; \
|
||||
(ix1) = ew_u.parts.lsw; \
|
||||
} while (0)
|
||||
|
||||
/* Get the more significant 32 bit int from a double. */
|
||||
|
||||
#define GET_HIGH_WORD(i,d) \
|
||||
do { \
|
||||
ieee_double_shape_type gh_u; \
|
||||
gh_u.value = (d); \
|
||||
(i) = gh_u.parts.msw; \
|
||||
} while (0)
|
||||
|
||||
/* Set a double from two 32 bit ints. */
|
||||
|
||||
#define INSERT_WORDS(d,ix0,ix1) \
|
||||
do { \
|
||||
ieee_double_shape_type iw_u; \
|
||||
iw_u.parts.msw = (ix0); \
|
||||
iw_u.parts.lsw = (ix1); \
|
||||
(d) = iw_u.value; \
|
||||
} while (0)
|
||||
|
||||
#define SET_HIGH_WORD(d,v) \
|
||||
do { \
|
||||
ieee_double_shape_type sh_u; \
|
||||
sh_u.value = (d); \
|
||||
sh_u.parts.msw = (v); \
|
||||
(d) = sh_u.value; \
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -405,8 +405,12 @@ again:
|
||||
bdwrite (bp);
|
||||
}
|
||||
bp = 0;
|
||||
// ###PITO
|
||||
nc = (nc + NBPW-1) & ~(NBPW-1);
|
||||
getxfile (ip, &exdata.ex_exec, nc + (na+4)*NBPW, uid, gid);
|
||||
//nc = (nc + (NBPW*2)-1) & ~((NBPW*2)-1);
|
||||
//getxfile (ip, &exdata.ex_exec, nc + (na+4)*(NBPW*2), uid, gid);
|
||||
// ###PITO
|
||||
if (u.u_error) {
|
||||
//printf ("execve: getxfile error = %d\n", u.u_error);
|
||||
badarg:
|
||||
|
||||
@@ -5,8 +5,7 @@ SUBDIR = baremetal dip duinomite duinomite-uart duinomite-e \
|
||||
duinomite-e-uart explorer16 max32 max32-eth maximite \
|
||||
meb pinguino-micro starter-kit ubw32 ubw32-uart \
|
||||
ubw32-uart-sdram baremetal fubarino fubarino-uart \
|
||||
fubarino-uart-sramc mmb-mx7 maximite-color \
|
||||
32mxsdram-uart
|
||||
fubarino-uart-sramc mmb-mx7 maximite-color 32mxsdram-uart
|
||||
|
||||
default:
|
||||
|
||||
|
||||
@@ -24,19 +24,29 @@
|
||||
* The values are dependant upon the presence of the -fno-short-double
|
||||
* compiler option.
|
||||
*/
|
||||
#define DBL_EPSILON FLT_EPSILON
|
||||
#define DBL_MAX FLT_MAX
|
||||
#define DBL_MIN FLT_MIN
|
||||
#define DBL_DIG FLT_DIG
|
||||
#define DBL_MANT_DIG FLT_MANT_DIG
|
||||
#define DBL_MAX_10_EXP FLT_MAX_10_EXP
|
||||
#define DBL_MAX_EXP FLT_MAX_EXP
|
||||
#define DBL_MIN_10_EXP FLT_MIN_10_EXP
|
||||
#define DBL_MIN_EXP FLT_MIN_EXP
|
||||
//#define DBL_EPSILON FLT_EPSILON
|
||||
//#define DBL_MAX FLT_MAX
|
||||
//#define DBL_MIN FLT_MIN
|
||||
//#define DBL_DIG FLT_DIG
|
||||
//#define DBL_MANT_DIG FLT_MANT_DIG
|
||||
//#define DBL_MAX_10_EXP FLT_MAX_10_EXP
|
||||
//#define DBL_MAX_EXP FLT_MAX_EXP
|
||||
//#define DBL_MIN_10_EXP FLT_MIN_10_EXP
|
||||
//#define DBL_MIN_EXP FLT_MIN_EXP
|
||||
|
||||
/*
|
||||
* These values provide information pertaining to the long double type.
|
||||
*/
|
||||
#define DBL_EPSILON 2.2204460492503131E-16
|
||||
#define DBL_MAX 1.7976931348623157E+308
|
||||
#define DBL_MIN 2.2250738585072014E-308
|
||||
#define DBL_DIG 15
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MIN_10_EXP (-307)
|
||||
#define DBL_MIN_EXP (-1021)
|
||||
|
||||
#define LDBL_EPSILON 2.2204460492503131E-16
|
||||
#define LDBL_MAX 1.7976931348623157E+308
|
||||
#define LDBL_MIN 2.2250738585072014E-308
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
# chipKIT PIC32 compiler from UECIDE
|
||||
ifdef UECIDE
|
||||
ifndef GCCPREFIX
|
||||
GCCPREFIX = ${HOME}/.uecide/compilers/pic32-tools/bin/pic32-
|
||||
LDFLAGS = -Wl,--oformat=elf32-tradlittlemips
|
||||
endif
|
||||
endif
|
||||
|
||||
# chipKIT PIC32 compiler on Linux
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Download from https://github.com/jasonkajita/chipKIT-cxx/downloads
|
||||
|
||||
@@ -73,7 +73,7 @@ vers.o: $(BUILDPATH)/newvers.sh $(H)/*.h $(M)/*.[ch] $(S)/*.c
|
||||
$(CC) -c vers.c
|
||||
|
||||
reconfig:
|
||||
../../../tools/configsys/config $(CONFIG)
|
||||
$(CONFIGPATH)/config $(CONFIG)
|
||||
|
||||
.SUFFIXES: .i .srec .hex .dis .cpp .cxx .bin .elf
|
||||
|
||||
|
||||
13
target.mk
13
target.mk
@@ -1,15 +1,6 @@
|
||||
MACHINE = mips
|
||||
DESTDIR ?= $(TOPSRC)
|
||||
|
||||
# chipKIT PIC32 compiler from UECIDE
|
||||
ifdef UECIDE
|
||||
ifndef GCCPREFIX
|
||||
GCCPREFIX = ${HOME}/.uecide/compilers/pic32-tools/bin/pic32-
|
||||
LDFLAGS = -Wl,--oformat=elf32-tradlittlemips
|
||||
INCLUDES = -I${HOME}/.uecide/compilers/pic32-tools/lib/gcc/pic32mx/4.5.1/include
|
||||
endif
|
||||
endif
|
||||
|
||||
# chipKIT PIC32 compiler on Linux
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Download from https://github.com/jasonkajita/chipKIT-cxx/downloads
|
||||
@@ -34,8 +25,8 @@ ifndef GCCPREFIX
|
||||
INCLUDES =
|
||||
endif
|
||||
|
||||
CC = $(GCCPREFIX)gcc -mips32r2 -EL -msoft-float -nostdinc -fshort-double -I$(TOPSRC)/include $(INCLUDES)
|
||||
CXX = $(GCCPREFIX)g++ -mips32r2 -EL -msoft-float -nostdinc -fshort-double -I$(TOPSRC)/include $(INCLUDES)
|
||||
CC = $(GCCPREFIX)gcc -mips32r2 -EL -msoft-float -nostdinc -fno-short-double -I$(TOPSRC)/include $(INCLUDES)
|
||||
CXX = $(GCCPREFIX)g++ -mips32r2 -EL -msoft-float -nostdinc -fno-short-double -I$(TOPSRC)/include $(INCLUDES)
|
||||
LD = $(GCCPREFIX)ld
|
||||
AR = $(GCCPREFIX)ar
|
||||
RANLIB = $(GCCPREFIX)ranlib
|
||||
|
||||
Reference in New Issue
Block a user