Small code cleanup.

- Wraps some LDC specific code in 'IN_LLVM' section
- Adds some MSVC specific code to 'IN_LLVM' section
- Removes an unused include file

Net result is much less errors with MSVC.
This commit is contained in:
kai
2012-03-15 07:11:54 +01:00
parent 947790248f
commit dee054fae0
6 changed files with 32 additions and 18 deletions

View File

@@ -22,6 +22,10 @@
#include "arraytypes.h"
#if IN_LLVM
#if defined(_MSC_VER)
#undef min
#undef max
#endif
#include "../ir/irdsymbol.h"
#endif

View File

@@ -2507,10 +2507,15 @@ done:
real_t::parse((char *)stringbuffer.data, real_t::Float);
#else
strtofres = strtof((char *)stringbuffer.data, NULL);
#ifdef IN_LLVM
#ifdef _MSC_VER
#define HUGE_VALF HUGE_VAL
#endif
// LDC change: don't error on gradual underflow
if (errno == ERANGE &&
strtofres != 0 && strtofres != HUGE_VALF && strtofres != -HUGE_VALF)
errno = 0;
#endif
#endif
result = TOKfloat32v;
p++;
@@ -2521,10 +2526,12 @@ done:
real_t::parse((char *)stringbuffer.data, real_t::Double);
#else
strtodres = strtod((char *)stringbuffer.data, NULL);
#if IN_LLVM
// LDC change: don't error on gradual underflow
if (errno == ERANGE &&
strtodres != 0 && strtodres != HUGE_VAL && strtodres != -HUGE_VAL)
errno = 0;
#endif
#endif
result = TOKfloat64v;
break;

View File

@@ -69,10 +69,6 @@ the target object file format:
#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1
#endif
#include <inttypes.h>
#include <stdarg.h>
#ifdef __DMC__

View File

@@ -22,6 +22,10 @@
#include "arraytypes.h"
#if IN_LLVM
#if defined(_MSC_VER)
#undef min
#undef max
#endif
#include "../ir/irdsymbol.h"
#endif

View File

@@ -2502,11 +2502,16 @@ done:
#ifdef IN_GCC
real_t::parse((char *)stringbuffer.data, real_t::Float);
#else
strtofres = strtof((char *)stringbuffer.data, NULL);
// LDC change: don't error on gradual underflow
if (errno == ERANGE &&
strtofres != 0 && strtofres != HUGE_VALF && strtofres != -HUGE_VALF)
errno = 0;
strtofres = strtof((char *)stringbuffer.data, NULL);
#ifdef IN_LLVM
#ifdef _MSC_VER
#define HUGE_VALF HUGE_VAL
#endif
// LDC change: don't error on gradual underflow
if (errno == ERANGE &&
strtofres != 0 && strtofres != HUGE_VALF && strtofres != -HUGE_VALF)
errno = 0;
#endif
#endif
result = TOKfloat32v;
p++;
@@ -2516,11 +2521,13 @@ done:
#ifdef IN_GCC
real_t::parse((char *)stringbuffer.data, real_t::Double);
#else
strtodres = strtod((char *)stringbuffer.data, NULL);
// LDC change: don't error on gradual underflow
if (errno == ERANGE &&
strtodres != 0 && strtodres != HUGE_VAL && strtodres != -HUGE_VAL)
errno = 0;
strtodres = strtod((char *)stringbuffer.data, NULL);
#ifdef IN_LLVM
// LDC change: don't error on gradual underflow
if (errno == ERANGE &&
strtodres != 0 && strtodres != HUGE_VAL && strtodres != -HUGE_VAL)
errno = 0;
#endif
#endif
result = TOKfloat64v;
break;

View File

@@ -69,10 +69,6 @@ the target object file format:
#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1
#endif
#include <inttypes.h>
#include <stdarg.h>
#ifdef __DMC__