Skip to content

Commit

Permalink
Merge pull request #516 from rainers/vcbuild
Browse files Browse the repository at this point in the history
build dmd with Microsoft compiler
  • Loading branch information
WalterBright committed Feb 25, 2012
2 parents 6011636 + aec6a94 commit 3389350
Show file tree
Hide file tree
Showing 72 changed files with 4,125 additions and 350 deletions.
30 changes: 15 additions & 15 deletions src/backend/bcomplex.c
Expand Up @@ -9,8 +9,8 @@
Complex_ld Complex_ld::div(Complex_ld &x, Complex_ld &y)
{
Complex_ld q;
long double r;
long double den;
longdouble r;
longdouble den;

if (fabs(y.re) < fabs(y.im))
{
Expand Down Expand Up @@ -38,9 +38,9 @@ Complex_ld Complex_ld::mul(Complex_ld &x, Complex_ld &y)
return p;
}

long double Complex_ld::abs(Complex_ld &z)
longdouble Complex_ld::abs(Complex_ld &z)
{
long double x,y,ans,temp;
longdouble x,y,ans,temp;

x = fabs(z.re);
y = fabs(z.im);
Expand All @@ -64,7 +64,7 @@ long double Complex_ld::abs(Complex_ld &z)
Complex_ld Complex_ld::sqrtc(Complex_ld &z)
{
Complex_ld c;
long double x,y,w,r;
longdouble x,y,w,r;

if (z.re == 0 && z.im == 0)
{
Expand Down Expand Up @@ -104,8 +104,8 @@ Complex_ld Complex_ld::sqrtc(Complex_ld &z)
Complex_d Complex_d::div(Complex_d &x, Complex_d &y)
{
Complex_d q;
long double r;
long double den;
longdouble r;
longdouble den;

if (fabs(y.re) < fabs(y.im))
{
Expand Down Expand Up @@ -133,9 +133,9 @@ Complex_d Complex_d::mul(Complex_d &x, Complex_d &y)
return p;
}

long double Complex_d::abs(Complex_d &z)
longdouble Complex_d::abs(Complex_d &z)
{
long double x,y,ans,temp;
longdouble x,y,ans,temp;

x = fabs(z.re);
y = fabs(z.im);
Expand All @@ -159,7 +159,7 @@ long double Complex_d::abs(Complex_d &z)
Complex_d Complex_d::sqrtc(Complex_d &z)
{
Complex_d c;
long double x,y,w,r;
longdouble x,y,w,r;

if (z.re == 0 && z.im == 0)
{
Expand Down Expand Up @@ -199,8 +199,8 @@ Complex_d Complex_d::sqrtc(Complex_d &z)
Complex_f Complex_f::div(Complex_f &x, Complex_f &y)
{
Complex_f q;
long double r;
long double den;
longdouble r;
longdouble den;

if (fabs(y.re) < fabs(y.im))
{
Expand Down Expand Up @@ -228,9 +228,9 @@ Complex_f Complex_f::mul(Complex_f &x, Complex_f &y)
return p;
}

long double Complex_f::abs(Complex_f &z)
longdouble Complex_f::abs(Complex_f &z)
{
long double x,y,ans,temp;
longdouble x,y,ans,temp;

x = fabs(z.re);
y = fabs(z.im);
Expand All @@ -254,7 +254,7 @@ long double Complex_f::abs(Complex_f &z)
Complex_f Complex_f::sqrtc(Complex_f &z)
{
Complex_f c;
long double x,y,w,r;
longdouble x,y,w,r;

if (z.re == 0 && z.im == 0)
{
Expand Down
10 changes: 6 additions & 4 deletions src/backend/bcomplex.h
Expand Up @@ -3,6 +3,8 @@
#ifndef BCOMPLEX_H
#define BCOMPLEX_H 1

#include "longdouble.h"

// Avoid interfering with system <complex.h> and other
// such; roll our own for reliable bootstrapping

Expand All @@ -11,7 +13,7 @@ struct Complex_f

static Complex_f div(Complex_f &x, Complex_f &y);
static Complex_f mul(Complex_f &x, Complex_f &y);
static long double abs(Complex_f &z);
static longdouble abs(Complex_f &z);
static Complex_f sqrtc(Complex_f &z);
};

Expand All @@ -20,16 +22,16 @@ struct Complex_d

static Complex_d div(Complex_d &x, Complex_d &y);
static Complex_d mul(Complex_d &x, Complex_d &y);
static long double abs(Complex_d &z);
static longdouble abs(Complex_d &z);
static Complex_d sqrtc(Complex_d &z);
};

struct Complex_ld
{ long double re, im;
{ longdouble re, im;

static Complex_ld div(Complex_ld &x, Complex_ld &y);
static Complex_ld mul(Complex_ld &x, Complex_ld &y);
static long double abs(Complex_ld &z);
static longdouble abs(Complex_ld &z);
static Complex_ld sqrtc(Complex_ld &z);
};

Expand Down
9 changes: 8 additions & 1 deletion src/backend/cc.h
Expand Up @@ -1332,7 +1332,14 @@ struct Aliassym : Symbol { };
/* Format the identifier for presentation to the user */
char *cpp_prettyident (Symbol *s);

inline char *prettyident(Symbol *s) { return CPP ? cpp_prettyident(s) : s->Sident; }
inline char *prettyident(Symbol *s)
{
#if CPP
return cpp_prettyident(s);
#else
return s->Sident;
#endif
}

/**********************************
* Function parameters:
Expand Down
9 changes: 6 additions & 3 deletions src/backend/cdef.h
Expand Up @@ -240,7 +240,7 @@ One and only one of these macros must be set by the makefile:

#if __GNUC__
#define LONGLONG 1
#elif __SC__ < 0x700 || _MSC_VER
#elif __SC__ > 0 && __SC__ < 0x700
#define LONGLONG 0
#else
#define LONGLONG 1 // add in code to support 64 bit integral types
Expand All @@ -252,6 +252,8 @@ One and only one of these macros must be set by the makefile:
#define LDOUBLE (config.exe == EX_NT) // support true long doubles
#endif

#include "longdouble.h"

// Precompiled header variations
#define MEMORYHX (_WINDLL && _WIN32) // HX and SYM files are cached in memory
#define MMFIO (_WIN32 || linux || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun&&__SVR4) // if memory mapped files
Expand Down Expand Up @@ -444,7 +446,7 @@ typedef unsigned long long targ_ullong;
#endif
typedef float targ_float;
typedef double targ_double;
typedef long double targ_ldouble;
typedef longdouble targ_ldouble;

// Extract most significant register from constant
#define MSREG(p) ((REGSIZE == 2) ? (p) >> 16 : ((sizeof(targ_llong) == 8) ? (p) >> 32 : 0))
Expand Down Expand Up @@ -483,7 +485,8 @@ typedef unsigned targ_uns;
#define FPTRSIZE tysize[TYfptr]
#define REGMASK 0xFFFF

#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX
// targ_llong is also used to store host pointers, so it should have at least their size
#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX || _WIN64
typedef targ_llong targ_ptrdiff_t; /* ptrdiff_t for target machine */
typedef targ_ullong targ_size_t; /* size_t for the target machine */
#else
Expand Down
6 changes: 4 additions & 2 deletions src/backend/cg87.c
Expand Up @@ -663,7 +663,7 @@ __body
{0.0,1.0,PI,LOG2T,LOG2E,LOG2,LN2};
static double dval[7] =
{0.0,1.0,PI,LOG2T,LOG2E,LOG2,LN2};
static long double ldval[7] =
static longdouble ldval[7] =
#if __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun&&__SVR4
#define M_PIl 0x1.921fb54442d1846ap+1L // 3.14159 fldpi
#define M_LOG2T_L 0x1.a934f0979a3715fcp+1L // 3.32193 fldl2t
Expand All @@ -676,6 +676,8 @@ __body
#define M_LOG2T_L LOG2T
#define M_LOG2_L LOG2
{0.0,1.0,M_PIl,M_LOG2T_L,M_LOG2El,M_LOG2_L,M_LN2l};
#elif _MSC_VER
{ ld_zero, ld_one, ld_pi, ld_log2t, ld_log2e, ld_log2, ld_ln2 };
#else
{0.0,1.0,M_PI_L,M_LOG2T_L,M_LOG2E_L,M_LOG2_L,M_LN2_L};
#endif
Expand All @@ -689,7 +691,7 @@ __body
int sz;
int zero;
void *p;
static char zeros[sizeof(long double)];
static char zeros[sizeof(longdouble)];

if (im == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cgcod.c
Expand Up @@ -17,7 +17,7 @@
#include <stdlib.h>
#include <time.h>

#if __sun&&__SVR4
#if __sun&&__SVR4 || _MSC_VER
#include <alloca.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/backend/cgcv.c
Expand Up @@ -519,7 +519,7 @@ void cv_init()
* Return number of bytes required to store a numeric leaf.
*/

inline unsigned cv4_numericbytes(targ_size_t value)
unsigned cv4_numericbytes(targ_size_t value)
{ unsigned u;

if (value < 0x8000)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cgcv.h
Expand Up @@ -58,7 +58,7 @@ extern Cgcv cgcv;

debtyp_t * debtyp_alloc(unsigned length);
int cv_stringbytes(const char *name);
inline unsigned cv4_numericbytes(targ_size_t value);
unsigned cv4_numericbytes(targ_size_t value);
void cv4_storenumeric(unsigned char *p,targ_size_t value);
idx_t cv_debtyp ( debtyp_t *d );
int cv_namestring ( unsigned char *p , const char *name );
Expand Down
12 changes: 6 additions & 6 deletions src/backend/cgobj.c
Expand Up @@ -1129,7 +1129,7 @@ void obj_user(const char *p)
STATIC void obj_defaultlib()
{
char library[4]; // default library
static const char model[MEMMODELS] = "SMCLV";
static const char model[MEMMODELS+1] = "SMCLV";

#if MARS
memcpy(library,"SM?",4);
Expand Down Expand Up @@ -1264,7 +1264,7 @@ void obj_theadr(const char *modname)

void obj_compiler()
{
static const char compiler[] = "\0\xDBDigital Mars C/C++"
static const char compiler[] = "\0\xDB" "Digital Mars C/C++"
VERSION
; // compiled by ...

Expand Down Expand Up @@ -1292,7 +1292,7 @@ STATIC void objheader(char *csegname)
int texti = 8; // index of _TEXT

static char comment[] = {0,0x9D,'0','?','O'}; // memory model
static char model[MEMMODELS] = "smclv";
static char model[MEMMODELS+1] = "smclv";
static char exten[] = {0,0xA1,1,'C','V'}; // extended format
static char pmdeb[] = {0x80,0xA1,1,'H','L','L',0}; // IBM PM debug format

Expand Down Expand Up @@ -1606,7 +1606,7 @@ void obj_funcptr(Symbol *s)
{
// We need to always put out the segments in triples, so that the
// linker will put them in the correct order.
static char lnames[4][5+4+5] =
static char lnames[4][5+4+5+1] =
{ "\03XIB\02XI\03XIE", // near constructor
"\03XCB\02XC\03XCE", // near destructor
"\04XIFB\03XIF\04XIFE", // far constructor
Expand Down Expand Up @@ -2137,7 +2137,7 @@ size_t obj_mangle(Symbol *s,char *dest)

// Use as max length the max length lib.exe can handle
// Use 5 as length of _ + @nnn
#define LIBIDMAX ((512 - 0x25 - 3 - 4) - 5)
// #define LIBIDMAX ((512 - 0x25 - 3 - 4) - 5)
#define LIBIDMAX 128
if (len > LIBIDMAX)
//if (len > IDMAX)
Expand Down Expand Up @@ -2954,7 +2954,7 @@ unsigned obj_bytes(int seg,targ_size_t offset,unsigned nbytes, void *p)
while (nbytes)
{ obj_byte(seg,offset,*(char *)p);
offset++;
((char *)p)++;
p = ((char *)p) + 1;
nbytes--;
lr = SegData[seg]->ledata;
if (lr->i + nbytes <= LEDATAMAX)
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cod1.c
Expand Up @@ -17,7 +17,7 @@
#include <stdlib.h>
#include <time.h>

#if __sun&&__SVR4
#if __sun&&__SVR4 || _MSC_VER
#include <alloca.h>
#endif

Expand Down
12 changes: 6 additions & 6 deletions src/backend/cod3.c
Expand Up @@ -631,7 +631,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
code_orrex(cs, REX_W);
}
}
cs = genc(cs,0xE8,0,0,0,FLblock,(long)list_block(bf->Bsucc));
cs = genc(cs,0xE8,0,0,0,FLblock,(targ_size_t)list_block(bf->Bsucc));
if (nalign)
{ cs = genc2(cs,0x81,modregrm(3,0,SP),nalign); // ADD ESP,nalign
if (I64)
Expand Down Expand Up @@ -694,7 +694,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
code_orrex(c, REX_W);
}
// CALL bl->Bsucc
c = genc(c,0xE8,0,0,0,FLblock,(long)list_block(bl->Bsucc));
c = genc(c,0xE8,0,0,0,FLblock,(targ_size_t)list_block(bl->Bsucc));
if (nalign)
{ c = genc2(c,0x81,modregrm(3,0,SP),nalign); // ADD ESP,nalign
if (I64)
Expand All @@ -711,7 +711,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
// corresponding BC_ret
//assert(list_block(list_next(bl->Bsucc))->BC == BC_ret);
// PUSH &succ
c = genc(c,0x68,0,0,0,FLblock,(long)list_block(list_next(bl->Bsucc)));
c = genc(c,0x68,0,0,0,FLblock,(targ_size_t)list_block(list_next(bl->Bsucc)));
nextb = list_block(bl->Bsucc);
goto L2;
}
Expand Down Expand Up @@ -811,7 +811,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym

c = cat(c,nteh_gensindex(-1));
gensaverestore(retregs,&cs,&cr);
cs = genc(cs,0xE8,0,0,0,FLblock,(long)list_block(bf->Bsucc));
cs = genc(cs,0xE8,0,0,0,FLblock,(targ_size_t)list_block(bf->Bsucc));
bl->Bcode = cat3(c,cs,cr);
}
else
Expand All @@ -836,7 +836,7 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
}
}
// CALL bf->Bsucc
cs = genc(cs,0xE8,0,0,0,FLblock,(long)list_block(bf->Bsucc));
cs = genc(cs,0xE8,0,0,0,FLblock,(targ_size_t)list_block(bf->Bsucc));
if (nalign)
{ cs = genc2(cs,0x81,modregrm(3,0,SP),nalign); // ADD ESP,nalign
if (I64)
Expand Down Expand Up @@ -5179,7 +5179,7 @@ static char *pgen;

#define GEN(c) (*pgen++ = (c))
#define GENP(n,p) (memcpy(pgen,(p),(n)), pgen += (n))
#if ELFOBJ || MACHOBJ
#if ELFOBJ || MACHOBJ || _MSC_VER
#define FLUSH() if (pgen-bytes) cod3_flush()
#else
#define FLUSH() ((pgen - bytes) && cod3_flush())
Expand Down
19 changes: 11 additions & 8 deletions src/backend/code.h
Expand Up @@ -32,14 +32,17 @@ struct Declaration;
#define SI 6
#define DI 7

#define R8 8
#define R9 9
#define R10 10
#define R11 11
#define R12 12
#define R13 13
#define R14 14
#define R15 15
enum // #defining R12-R15 interfere with setjmps' _JUMP_BUFFER members
{
R8 = 8,
R9 = 9,
R10 = 10,
R11 = 11,
R12 = 12,
R13 = 13,
R14 = 14,
R15 = 15,
};

#define XMM0 16
#define XMM1 17
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cppman.c
Expand Up @@ -624,7 +624,7 @@ char *template_mangle(symbol *s,param_t *arglist)
}
p = (char *)&d;
// ni = tysize[TYdouble];
ni = sizeof(long double); // just until new unmangler is in
ni = sizeof(longdouble); // just until new unmangler is in
L1:
a[1] = 0;
n = cpp_catname(n,a);
Expand Down

0 comments on commit 3389350

Please sign in to comment.