shithub: femtolisp

ref: 91da922a22ed83f60bbc33d48e31de47349ac467
dir: /llt/lltinit.c/

View raw version
#ifdef PLAN9
#include <u.h>
#include <libc.h>
#else
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <locale.h>
#endif
#include "dtypes.h"
#include "timefuncs.h"
#include "ios.h"
#include "random.h"
#include "utf8.h"

double D_PNAN;
double D_NNAN;
double D_PINF;
double D_NINF;
float  F_PNAN;
float  F_NNAN;
float  F_PINF;
float  F_NINF;

void llt_init(void)
{
    randomize();

    ios_init_stdstreams();

    D_PNAN = strtod("+NaN",NULL);
    D_NNAN = strtod("-NaN",NULL);
    D_PINF = strtod("+Inf",NULL);
    D_NINF = strtod("-Inf",NULL);
#ifdef PLAN9
    u32int x;
    x = 0x7fc00000; memcpy(&F_PNAN, &x, 4);
    x = 0xffc00000; memcpy(&F_NNAN, &x, 4);
    x = 0x7f800000; memcpy(&F_PINF, &x, 4);
    x = 0xff800000; memcpy(&F_NINF, &x, 4);
#else
    F_PNAN = strtof("+NaN",NULL);
    F_NNAN = -strtof("+NaN",NULL);
    F_PINF = strtof("+Inf",NULL);
    F_NINF = strtof("-Inf",NULL);
#endif
}