diff --git a/ini/dragonflybsd/bin32/dmd.conf b/ini/dragonflybsd/bin32/dmd.conf new file mode 100644 index 000000000000..7f35963b9175 --- /dev/null +++ b/ini/dragonflybsd/bin32/dmd.conf @@ -0,0 +1,5 @@ +[Environment32] +DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L--export-dynamic + +[Environment64] +DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib64 -L--export-dynamic diff --git a/ini/dragonflybsd/bin64/dmd.conf b/ini/dragonflybsd/bin64/dmd.conf new file mode 100644 index 000000000000..7f35963b9175 --- /dev/null +++ b/ini/dragonflybsd/bin64/dmd.conf @@ -0,0 +1,5 @@ +[Environment32] +DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L--export-dynamic + +[Environment64] +DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib64 -L--export-dynamic diff --git a/src/dmd/astbase.d b/src/dmd/astbase.d index 09d94076b485..3586aea55137 100644 --- a/src/dmd/astbase.d +++ b/src/dmd/astbase.d @@ -6307,7 +6307,8 @@ struct ASTBase { return Type.tchar.pointerTo(); } - else if (global.params.isLinux || global.params.isFreeBSD || global.params.isOpenBSD || global.params.isSolaris || global.params.isOSX) + else if (global.params.isLinux || global.params.isFreeBSD || global.params.isOpenBSD || global.params.isDragonFlyBSD || + global.params.isSolaris || global.params.isOSX) { if (global.params.is64bit) { diff --git a/src/dmd/backend/backconfig.c b/src/dmd/backend/backconfig.c index a4c4157d03fc..29b82f13fd26 100644 --- a/src/dmd/backend/backconfig.c +++ b/src/dmd/backend/backconfig.c @@ -178,6 +178,25 @@ void out_config_init( config.objfmt = OBJ_ELF; config.ehmethod = betterC ? EH_NONE : EH_DM; #endif +#if TARGET_DRAGONFLYBSD + if (model == 64) + { config.exe = EX_DRAGONFLYBSD64; + config.ehmethod = betterC ? EH_NONE : EH_DWARF; + config.fpxmmregs = TRUE; + config.avx = avx; + } + else + { + assert(0); // Only 64-bit supported on DragonFlyBSD + } + config.flags |= CFGnoebp; + if (!exe) + { + config.flags3 |= CFG3pic; + config.flags |= CFGalwaysframe; // PIC needs a frame for TLS fixups + } + config.objfmt = OBJ_ELF; +#endif #if TARGET_SOLARIS if (model == 64) { config.exe = EX_SOLARIS64; @@ -336,7 +355,7 @@ void util_set32() _tysize[TYnullptr] = LONGSIZE; _tysize[TYnptr] = LONGSIZE; _tysize[TYnref] = LONGSIZE; -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS _tysize[TYldouble] = 12; _tysize[TYildouble] = 12; _tysize[TYcldouble] = 24; @@ -363,7 +382,7 @@ void util_set32() _tyalignsize[TYnullptr] = LONGSIZE; _tyalignsize[TYnref] = LONGSIZE; _tyalignsize[TYnptr] = LONGSIZE; -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS _tyalignsize[TYldouble] = 4; _tyalignsize[TYildouble] = 4; _tyalignsize[TYcldouble] = 4; @@ -401,7 +420,7 @@ void util_set64() _tysize[TYnullptr] = 8; _tysize[TYnptr] = 8; _tysize[TYnref] = 8; -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS || TARGET_OSX _tysize[TYldouble] = 16; _tysize[TYildouble] = 16; _tysize[TYcldouble] = 32; @@ -424,7 +443,7 @@ void util_set64() _tyalignsize[TYnullptr] = 8; _tyalignsize[TYnptr] = 8; _tyalignsize[TYnref] = 8; -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS _tyalignsize[TYldouble] = 16; _tyalignsize[TYildouble] = 16; _tyalignsize[TYcldouble] = 16; diff --git a/src/dmd/backend/cc.d b/src/dmd/backend/cc.d index 02b8ef07d5a7..c97e8ea01665 100644 --- a/src/dmd/backend/cc.d +++ b/src/dmd/backend/cc.d @@ -58,7 +58,7 @@ enum WM WM_ccast = 25, WM_obsolete = 26, - // if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS + // if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS WM_skip_attribute = 27, // skip GNUC attribute specification WM_warning_message = 28, // preprocessor warning message WM_bad_vastart = 29, // args for builtin va_start bad @@ -84,7 +84,7 @@ enum LANG //#include "msgs2.h" //#endif //#include "ty.h" -//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS //#include "../tk/mem.h" //#else //#include "mem.h" diff --git a/src/dmd/backend/cc.h b/src/dmd/backend/cc.h index a6a2948741fc..2b05aed4a8fc 100644 --- a/src/dmd/backend/cc.h +++ b/src/dmd/backend/cc.h @@ -77,7 +77,7 @@ enum WM WM_badnumber = 24, WM_ccast = 25, WM_obsolete = 26, -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS WM_skip_attribute = 27, // skip GNUC attribute specification WM_warning_message = 28, // preprocessor warning message WM_bad_vastart = 29, // args for builtin va_start bad @@ -106,7 +106,7 @@ enum LANG #include "msgs2.h" #endif #include "ty.h" -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS #include "../tk/mem.h" #else #include "mem.h" diff --git a/src/dmd/backend/cdef.d b/src/dmd/backend/cdef.d index 02b4a3b40dc3..af3a74d0eca9 100644 --- a/src/dmd/backend/cdef.d +++ b/src/dmd/backend/cdef.d @@ -85,7 +85,7 @@ enum bool HEADER_LIST = true; // Precompiled header variations //#define MEMORYHX (_WINDLL && _WIN32) // HX and SYM files are cached in memory -//#define MMFIO (_WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun) // if memory mapped files +//#define MMFIO (_WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun) // if memory mapped files //#define LINEARALLOC _WIN32 // if we can reserve address ranges // H_STYLE takes on one of these precompiled header methods @@ -272,7 +272,7 @@ enum { CHARSIZE = 1, SHORTSIZE = 2, - WCHARSIZE = 2, // 2 for WIN32, 4 for linux/OSX/FreeBSD/OpenBSD/Solaris + WCHARSIZE = 2, // 2 for WIN32, 4 for linux/OSX/FreeBSD/OpenBSD/DragonFlyBSD/Solaris LONGSIZE = 4, LLONGSIZE = 8, CENTSIZE = 16, @@ -288,7 +288,7 @@ enum //#define REGMASK 0xFFFF // 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 || MARS +//#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS || TARGET_OSX || MARS alias targ_ptrdiff_t = targ_llong; // ptrdiff_t for target machine alias targ_size_t = targ_ullong; // size_t for the target machine //#else @@ -311,14 +311,14 @@ alias targ_size_t = targ_ullong; // size_t for the target machine //#define OMFOBJ TARGET_WINDOS //#endif //#ifndef ELFOBJ -//#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS) +//#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS) //#endif //#ifndef MACHOBJ //#define MACHOBJ TARGET_OSX //#endif //#define SYMDEB_CODEVIEW TARGET_WINDOS -//#define SYMDEB_DWARF (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX) +//#define SYMDEB_DWARF (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS || TARGET_OSX) //#define TOOLKIT_H @@ -500,6 +500,7 @@ enum EX_SOLARIS64 = 0x200000, EX_OPENBSD = 0x400000, EX_OPENBSD64 = 0x800000, + EX_DRAGONFLYBSD64 = 0x1000000, } @@ -507,6 +508,7 @@ enum enum exefmt_t EX_flat = EX_OS2 | EX_WIN32 | EX_LINUX | EX_WIN64 | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | + EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64; // All DOS executable types diff --git a/src/dmd/backend/cdef.h b/src/dmd/backend/cdef.h index e2cd5c971b19..65dead55265a 100644 --- a/src/dmd/backend/cdef.h +++ b/src/dmd/backend/cdef.h @@ -26,6 +26,7 @@ __APPLE__ Mac OSX __FreeBSD__ FreeBSD __OpenBSD__ OpenBSD + __DragonFly__ DragonFlyBSD __sun Solaris, OpenSolaris, SunOS, OpenIndiana, etc __OS2__ IBM OS/2 DOS386 32 bit DOS extended executable @@ -118,7 +119,7 @@ One and only one of these macros must be set by the makefile: * The "__OpenBSD__" and "__GNUC__" macros control hosting issues * for operating system and compiler dependencies, respectively. * To target OpenBSD executables, use ELFOBJ for things specific to the - * ELF object file format, and TARGET_FREEBSD for things specific to + * ELF object file format, and TARGET_OPENBSD for things specific to * the OpenBSD memory model. * If this is all done right, one could generate a OpenBSD object file * even when compiling on win32, and vice versa. @@ -126,6 +127,23 @@ One and only one of these macros must be set by the makefile: * with these goals, and should be fixed. */ +/* DragonFlyBSD Version + * ------------- + * There are two main issues: hosting the compiler on DragonFlyBSD, + * and generating (targetting) DragonFlyBSD executables. + * The "__DragonFly__" and "__GNUC__" macros control hosting issues + * for operating system and compiler dependencies, respectively. + * To target DragonFlyBSD executables, use ELFOBJ for things specific to the + * ELF object file format, and TARGET_DRAGONFLYBSD for things specific to + * the DragonFlyBSD memory model. + * If this is all done right, one could generate a DragonFlyBSD object file + * even when compiling on linux/windows/osx etc, and vice versa. + * The compiler source code currently uses these macros very inconsistently + * with these goals, and should be fixed. + * + * DMD was Ported to DragonFlyBSD by Diederik de Groot + */ + /* Solaris Version * ------------- * There are two main issues: hosting the compiler on Solaris, @@ -186,6 +204,11 @@ One and only one of these macros must be set by the makefile: #define TARGET_OPENBSD 0 // target is an OpenBSD executable #endif +// Set to 1 using the makefile +#ifndef TARGET_DRAGONFLYBSD +#define TARGET_DRAGONFLYBSD 0 // target is a DragonFlyBSD executable +#endif + // Set to 1 using the makefile #ifndef TARGET_SOLARIS #define TARGET_SOLARIS 0 // target is a Solaris executable @@ -193,7 +216,7 @@ One and only one of these macros must be set by the makefile: // This is the default #ifndef TARGET_WINDOS -#define TARGET_WINDOS (!(TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)) +#define TARGET_WINDOS (!(TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS)) #endif #if __GNUC__ @@ -296,7 +319,7 @@ typedef long double longdouble; // Precompiled header variations #define MEMORYHX (_WINDLL && _WIN32) // HX and SYM files are cached in memory -#define MMFIO (_WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun) // if memory mapped files +#define MMFIO (_WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun) // if memory mapped files #define LINEARALLOC _WIN32 // if we can reserve address ranges // H_STYLE takes on one of these precompiled header methods @@ -503,7 +526,7 @@ enum { CHARSIZE = 1, SHORTSIZE = 2, - WCHARSIZE = 2, // 2 for WIN32, 4 for linux/OSX/FreeBSD/OpenBSD/Solaris + WCHARSIZE = 2, // 2 for WIN32, 4 for linux/OSX/FreeBSD/OpenBSD/DragonFlyBSD/Solaris LONGSIZE = 4, LLONGSIZE = 8, CENTSIZE = 16, @@ -519,7 +542,7 @@ enum #define REGMASK 0xFFFF // 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 || MARS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS || TARGET_OSX || MARS typedef targ_llong targ_ptrdiff_t; /* ptrdiff_t for target machine */ typedef targ_ullong targ_size_t; /* size_t for the target machine */ #else @@ -542,14 +565,14 @@ typedef targ_uns targ_size_t; /* size_t for the target machine */ #define OMFOBJ TARGET_WINDOS #endif #ifndef ELFOBJ -#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS) +#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS) #endif #ifndef MACHOBJ #define MACHOBJ TARGET_OSX #endif #define SYMDEB_CODEVIEW TARGET_WINDOS -#define SYMDEB_DWARF (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_OSX) +#define SYMDEB_DWARF (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS || TARGET_OSX) #define TOOLKIT_H @@ -737,6 +760,7 @@ enum EX_SOLARIS64 = 0x200000, EX_OPENBSD = 0x400000, EX_OPENBSD64 = 0x800000, + EX_DRAGONFLYBSD64 = 0x1000000, }; @@ -744,6 +768,7 @@ enum const exefmt_t EX_flat = EX_OS2 | EX_WIN32 | EX_LINUX | EX_WIN64 | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | + EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64; // All DOS executable types diff --git a/src/dmd/backend/cgcod.c b/src/dmd/backend/cgcod.c index 3c9386929df1..41bb1f0b7867 100644 --- a/src/dmd/backend/cgcod.c +++ b/src/dmd/backend/cgcod.c @@ -2544,7 +2544,7 @@ if (regcon.cse.mval & 1) elem_print(regcon.cse.value[0]); case OPrelconst: cdrelconst(cdb,e,pretregs); break; -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS case OPgot: cdgot(cdb,e,pretregs); break; diff --git a/src/dmd/backend/cgelem.c b/src/dmd/backend/cgelem.c index e3c5802b2c8e..d94613ada2ac 100644 --- a/src/dmd/backend/cgelem.c +++ b/src/dmd/backend/cgelem.c @@ -4968,7 +4968,7 @@ STATIC elem * elvalist(elem *e, goal_t goal) #endif -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS assert(I64); // va_start is not an intrinsic on 32-bit // (OPva_start &va) diff --git a/src/dmd/backend/cod1.c b/src/dmd/backend/cod1.c index 46121f5a4804..a7b28a266611 100644 --- a/src/dmd/backend/cod1.c +++ b/src/dmd/backend/cod1.c @@ -1285,7 +1285,7 @@ void getlvalue(CodeBuilder& cdb,code *pcs,elem *e,regm_t keepmsk) case FLextern: if (s->Sident[0] == '_' && memcmp(s->Sident + 1,"tls_array",10) == 0) { -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS // Rewrite as GS:[0000], or FS:[0000] for 64 bit if (I64) { @@ -1329,7 +1329,7 @@ void getlvalue(CodeBuilder& cdb,code *pcs,elem *e,regm_t keepmsk) case FLcsdata: case FLgot: case FLgotoff: -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS case FLtlsdata: #endif L3: @@ -1893,6 +1893,7 @@ void getClibInfo(unsigned clib, symbol **ps, ClibInfo **pinfo) EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | + EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64); ClibInfo *cinfo = &clibinfo[clib]; @@ -2572,7 +2573,7 @@ void callclib(CodeBuilder& cdb,elem *e,unsigned clib,regm_t *pretregs,regm_t kee } if (pushebx) { - if (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64)) + if (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64)) { cdb.gen1(0x50 + CX); // PUSH ECX cdb.gen1(0x50 + BX); // PUSH EBX @@ -3409,7 +3410,7 @@ static void funccall(CodeBuilder& cdb,elem *e,unsigned numpara,unsigned numalign fl = el_fl(e1); if (tym1 == TYifunc) cdbe.gen1(0x9C); // PUSHF -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS assert(!farfunc); if (s != tls_get_addr_sym) { @@ -3448,7 +3449,7 @@ static void funccall(CodeBuilder& cdb,elem *e,unsigned numpara,unsigned numalign tym_t e11ty = tybasic(e11->Ety); assert(!I16 || (e11ty == (farfunc ? TYfptr : TYnptr))); load_localgot(cdb); -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (config.flags3 & CFG3pic && I32) keepmsk |= mBX; #endif diff --git a/src/dmd/backend/cod2.c b/src/dmd/backend/cod2.c index 849e7a74870f..f544510bd738 100644 --- a/src/dmd/backend/cod2.c +++ b/src/dmd/backend/cod2.c @@ -909,7 +909,7 @@ void cdmul(CodeBuilder& cdb,elem *e,regm_t *pretregs) orthxmm(cdb,e,pretregs); return; } -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS orth87(cdb,e,pretregs); #else opdouble(cdb,e,pretregs,(oper == OPmul) ? CLIBdmul : CLIBddiv); @@ -4145,7 +4145,7 @@ void getoffset(CodeBuilder& cdb,elem *e,unsigned reg) goto L4; case FLtlsdata: -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS { L5: if (config.flags3 & CFG3pic) @@ -4271,7 +4271,7 @@ void getoffset(CodeBuilder& cdb,elem *e,unsigned reg) goto L4; case FLextern: -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (e->EV.sp.Vsym->ty() & mTYthread) goto L5; #endif diff --git a/src/dmd/backend/cod3.c b/src/dmd/backend/cod3.c index 1581ca3b8f13..0e3dba4e827e 100644 --- a/src/dmd/backend/cod3.c +++ b/src/dmd/backend/cod3.c @@ -631,7 +631,7 @@ regm_t regmask(tym_t tym, tym_t tyf) return mST0; case TYcfloat: -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (I32 && tybasic(tyf) == TYnfunc) return mDX | mAX; #endif @@ -1446,7 +1446,7 @@ void doswitch(CodeBuilder& cdb, block *b) regm_t retregs = IDXREGS; if (dword) retregs |= mMSW; -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (I32 && config.flags3 & CFG3pic) retregs &= ~mBX; // need EBX for GOT #endif @@ -1645,7 +1645,7 @@ void doswitch(CodeBuilder& cdb, block *b) genjmp(cdb,JNE,FLblock,b->nthSucc(0)); // JNE default } getregs(cdb,mCX|mDI); -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (config.flags3 & CFG3pic) { // Add in GOT getregs(cdb,mDX); @@ -1720,7 +1720,7 @@ void doswitch(CodeBuilder& cdb, block *b) const int mod = (disp > 127) ? 2 : 1; // 1 or 2 byte displacement if (csseg) cdb.gen1(SEGCS); // table is in code segment -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (config.flags3 & CFG3pic) { // ADD EDX,(ncases-1)*2[EDI] cdb.genc1(0x03,modregrm(mod,DX,7),FLconst,disp); @@ -1790,7 +1790,7 @@ void outjmptab(block *b) break; } } -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (I64) { if (config.flags3 & CFG3pic) @@ -2346,7 +2346,7 @@ void cdgot(CodeBuilder& cdb, elem *e, regm_t *pretregs) cdb.gen1(0x58 + reg); // L1: POP reg fixresult(cdb,e,retregs,pretregs); -#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS regm_t retregs = *pretregs & allregs; if (!retregs) retregs = allregs; @@ -2381,7 +2381,7 @@ void cdgot(CodeBuilder& cdb, elem *e, regm_t *pretregs) void load_localgot(CodeBuilder& cdb) { -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (config.flags3 & CFG3pic && I32) { if (localgot && !(localgot->Sflags & SFLdead)) @@ -2404,7 +2404,7 @@ void load_localgot(CodeBuilder& cdb) #endif } -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS /***************************** * Returns: * # of bytes stored @@ -3010,7 +3010,7 @@ void prolog_frame(CodeBuilder& cdb, unsigned farfunc, unsigned* xlocalsize, bool if (config.wflags & WFincbp && farfunc) cdb.gen1(0x40 + BP); // INC BP if (config.target_cpu < TARGET_80286 || - config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_WIN64) || + config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_WIN64) || !localsize || config.flags & CFGstack || (*xlocalsize >= 0x1000 && config.exe & EX_flat) || @@ -4297,7 +4297,7 @@ void cod3_thunk(Symbol *sthunk,Symbol *sfunc,unsigned p,tym_t thisty, sthunk->Soffset = thunkoffset; sthunk->Ssize = Offset(seg) - thunkoffset; // size of thunk sthunk->Sseg = seg; -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS objmod->pubdef(seg,sthunk,sthunk->Soffset); #endif #if TARGET_WINDOS @@ -6538,7 +6538,7 @@ static void do64bit(MiniCodeBuf *pbuf, enum FL fl,union evc *uev,int flags) // un-named external with is the start of .rodata or .data case FLextern: /* external data symbol */ case FLtlsdata: -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS case FLgot: case FLgotoff: #endif @@ -6648,7 +6648,7 @@ static void do32bit(MiniCodeBuf *pbuf, enum FL fl,union evc *uev,int flags, int // un-named external with is the start of .rodata or .data case FLextern: /* external data symbol */ case FLtlsdata: -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS case FLgot: case FLgotoff: #endif diff --git a/src/dmd/backend/cod4.c b/src/dmd/backend/cod4.c index 27c2326305ee..c3702792dcec 100644 --- a/src/dmd/backend/cod4.c +++ b/src/dmd/backend/cod4.c @@ -819,7 +819,7 @@ void cdaddass(CodeBuilder& cdb,elem *e,regm_t *pretregs) if (tyfloating(tyml)) { -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (op == OPnegass) cdnegass87(cdb,e,pretregs); else @@ -1332,7 +1332,7 @@ void cdmulass(CodeBuilder& cdb,elem *e,regm_t *pretregs) if (tyfloating(tyml)) { -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS opass87(cdb,e,pretregs); #else opassdbl(cdb,e,pretregs,op); @@ -2747,7 +2747,7 @@ void cdcnvt(CodeBuilder& cdb,elem *e, regm_t *pretregs) cdd_u32(cdb,e,pretregs); return; } -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS retregs = mST0; #else retregs = DOUBLEREGS; diff --git a/src/dmd/backend/code_stub.h b/src/dmd/backend/code_stub.h index f7f79bbc10af..9738f036523f 100644 --- a/src/dmd/backend/code_stub.h +++ b/src/dmd/backend/code_stub.h @@ -49,7 +49,7 @@ #define DOUBLEREGS_16 0 #define BYTEREGS_INIT 0 -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS extern regm_t ALLREGS; extern regm_t BYTEREGS; #define ALLREGS_INIT 0 diff --git a/src/dmd/backend/code_x86.h b/src/dmd/backend/code_x86.h index 1dc6ee398812..8731834e87a4 100644 --- a/src/dmd/backend/code_x86.h +++ b/src/dmd/backend/code_x86.h @@ -124,7 +124,7 @@ enum extern regm_t ALLREGS; extern regm_t BYTEREGS; -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS // To support positional independent code, // must be able to remove BX from available registers #define ALLREGS_INIT (mAX|mBX|mCX|mDX|mSI|mDI) diff --git a/src/dmd/backend/debug.c b/src/dmd/backend/debug.c index 0c6b100002b7..e23048233881 100644 --- a/src/dmd/backend/debug.c +++ b/src/dmd/backend/debug.c @@ -87,7 +87,7 @@ void WRTYxx(tym_t t) printf("mTYconst|"); if (t & mTYvolatile) printf("mTYvolatile|"); -#if !MARS && (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun) +#if !MARS && (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun) if (t & mTYtransu) printf("mTYtransu|"); #endif diff --git a/src/dmd/backend/dwarf.c b/src/dmd/backend/dwarf.c index 28f3cddd820c..b58affb6c0a7 100644 --- a/src/dmd/backend/dwarf.c +++ b/src/dmd/backend/dwarf.c @@ -24,7 +24,7 @@ #include #endif -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun #include #include #include @@ -95,7 +95,7 @@ bool doUnwindEhFrame() { if (funcsym_p->Sfunc->Fflags3 & Feh_none) { - return (config.exe & (EX_FREEBSD | EX_FREEBSD64)) != 0; + return (config.exe & (EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64)) != 0; } /* FreeBSD fails when having some frames as having unwinding info and some not. @@ -104,7 +104,7 @@ bool doUnwindEhFrame() */ assert(!(usednteh & ~(EHtry | EHcleanup))); return (usednteh & (EHtry | EHcleanup)) || - (config.exe & (EX_FREEBSD | EX_FREEBSD64)) && !config.betterC; + (config.exe & (EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64)) && !config.betterC; } #if ELFOBJ diff --git a/src/dmd/backend/el.c b/src/dmd/backend/el.c index d12c9cc6b1f1..6d5ea0b7d446 100644 --- a/src/dmd/backend/el.c +++ b/src/dmd/backend/el.c @@ -1165,7 +1165,7 @@ int el_depends(elem *ea,elem *eb) symbol *el_alloc_localgot() { -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS /* Since localgot is a local variable to each function, * localgot must be set back to NULL * at the start of code gen for each function. @@ -1337,7 +1337,7 @@ elem *el_picvar(symbol *s) return e; } #endif -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS elem *el_picvar(symbol *s) { elem *e; @@ -1532,13 +1532,13 @@ elem * el_var(symbol *s) //printf("el_var(s = '%s')\n", s->Sident); //printf("%x\n", s->Stype->Tty); -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (config.flags3 & CFG3pic && !tyfunc(s->ty())) // Position Independent Code return el_picvar(s); #endif -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (config.flags3 & CFG3pic && tyfunc(s->ty())) { switch (s->Sclass) @@ -1564,7 +1564,7 @@ elem * el_var(symbol *s) //printf("thread local %s\n", s->Sident); #if TARGET_OSX ; -#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS /* For 32 bit: * Generate for var locals: * MOV reg,GS:[00000000] // add GS: override in back end @@ -1683,7 +1683,7 @@ elem * el_var(symbol *s) { elem *e; //printf("el_var(s = '%s')\n", s->Sident); -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (config.flags3 & CFG3pic && !tyfunc(s->ty())) return el_picvar(s); #endif @@ -1774,7 +1774,7 @@ elem * el_ptr(symbol *s) return e; } #endif -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (config.flags3 & CFG3pic && tyfunc(s->ty())) e = el_picvar(s); diff --git a/src/dmd/backend/elfobj.c b/src/dmd/backend/elfobj.c index db4207cc1262..3ca1138b10a1 100644 --- a/src/dmd/backend/elfobj.c +++ b/src/dmd/backend/elfobj.c @@ -54,6 +54,8 @@ # define ELFOSABI ELFOSABI_SYSV # elif TARGET_OPENBSD # define ELFOSABI ELFOSABI_OPENBSD +# elif TARGET_DRAGONFLYBSD +# define ELFOSABI ELFOSABI_SYSV # else # error "No ELF OS ABI defined. Please fix" # endif @@ -82,7 +84,7 @@ void addSegmentToComdat(segidx_t seg, segidx_t comdatseg); * If set the compiler requires full druntime support of the new * section registration. */ -#define REQUIRE_DSO_REGISTRY (DMDV2 && (TARGET_LINUX || TARGET_FREEBSD)) +#define REQUIRE_DSO_REGISTRY (DMDV2 && (TARGET_LINUX || TARGET_FREEBSD || TARGET_DRAGONFLYBSD)) /****** * FreeBSD uses ELF, but the linker crashes with Elf comdats with the following message: @@ -2238,7 +2240,7 @@ char *obj_mangle2(Symbol *s,char *dest, size_t *destlen) } break; case mTYman_std: -#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (tyfunc(s->ty()) && !variadic(s->Stype)) #else if (!(config.flags4 & CFG4oldstdmangle) && diff --git a/src/dmd/backend/evalu8.c b/src/dmd/backend/evalu8.c index c9a40faad616..8606d4b92086 100644 --- a/src/dmd/backend/evalu8.c +++ b/src/dmd/backend/evalu8.c @@ -39,7 +39,7 @@ #include #endif -#if __FreeBSD__ || __OpenBSD__ +#if __FreeBSD__ || __OpenBSD__ || __DragonFly__ #define fmodl fmod #endif diff --git a/src/dmd/backend/global.d b/src/dmd/backend/global.d index 04ed7c15b985..c9e1a26e571f 100644 --- a/src/dmd/backend/global.d +++ b/src/dmd/backend/global.d @@ -498,7 +498,7 @@ void dwarf_CFA_set_reg_offset(int reg, int offset); void dwarf_CFA_offset(int reg, int offset); void dwarf_CFA_args_size(size_t sz); -// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS elem *exp_isconst(); elem *lnx_builtin_next_arg(elem *efunc,list_t arglist); char *lnx_redirect_funcname(const(char)*); diff --git a/src/dmd/backend/global.h b/src/dmd/backend/global.h index 4bda74073585..cb70dab2abb2 100644 --- a/src/dmd/backend/global.h +++ b/src/dmd/backend/global.h @@ -439,7 +439,7 @@ void postoptelem(elem *); unsigned swaprel(unsigned); int elemisone(elem *); -/* msc.c */ +/* dmsc.d */ targ_size_t size(tym_t); extern "C" { Symbol *symboldata(targ_size_t offset,tym_t ty); } bool dom(block *A , block *B); @@ -491,7 +491,7 @@ void dwarf_CFA_set_reg_offset(int reg, int offset); void dwarf_CFA_offset(int reg, int offset); void dwarf_CFA_args_size(size_t sz); -// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS elem *exp_isconst(); elem *lnx_builtin_next_arg(elem *efunc,list_t arglist); char *lnx_redirect_funcname(const char *); diff --git a/src/dmd/backend/machobj.c b/src/dmd/backend/machobj.c index 3de8c9c8a9f0..c842725e4208 100644 --- a/src/dmd/backend/machobj.c +++ b/src/dmd/backend/machobj.c @@ -22,7 +22,7 @@ #include #endif -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun #include #include #endif @@ -2092,7 +2092,7 @@ char *obj_mangle2(Symbol *s,char *dest) *p = toupper(*p); break; case mTYman_std: -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS if (tyfunc(s->ty()) && !variadic(s->Stype)) #else if (!(config.flags4 & CFG4oldstdmangle) && diff --git a/src/dmd/backend/nteh.c b/src/dmd/backend/nteh.c index 35a119313079..f0dfb8e3d10e 100644 --- a/src/dmd/backend/nteh.c +++ b/src/dmd/backend/nteh.c @@ -313,7 +313,7 @@ void nteh_prolog(CodeBuilder& cdb) /* An sindex value of -2 is a magic value that tells the * stack unwinder to skip this frame. */ - assert(config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_OPENBSD | EX_OPENBSD64)); + assert(config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64)); cs.Iop = 0x68; cs.Iflags = 0; cs.Irex = 0; diff --git a/src/dmd/backend/obj.h b/src/dmd/backend/obj.h index 6bd576971a74..2fe132ec0567 100644 --- a/src/dmd/backend/obj.h +++ b/src/dmd/backend/obj.h @@ -24,7 +24,7 @@ struct seg_data; #if TARGET_WINDOS #define OMF 1 -#elif (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS) +#elif (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS) #define ELF 1 #elif TARGET_OSX #define MACH 1 @@ -107,7 +107,7 @@ struct seg_data; static void gotref(symbol *s); -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS static unsigned addstr(Outbuffer *strtab, const char *); static symbol *getGOTsym(); static void refGOTsym(); @@ -193,7 +193,7 @@ class Obj static void gotref(symbol *s); -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS static unsigned addstr(Outbuffer *strtab, const char *); static symbol *getGOTsym(); static void refGOTsym(); diff --git a/src/dmd/backend/optabgen.c b/src/dmd/backend/optabgen.c index 11bf83e6579f..890c20b4699f 100644 --- a/src/dmd/backend/optabgen.c +++ b/src/dmd/backend/optabgen.c @@ -1035,7 +1035,7 @@ void dotytab() case TYcldouble: #if TARGET_OSX sz = 16; -#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS sz = 4; #elif TARGET_WINDOS sz = 2; diff --git a/src/dmd/backend/os.c b/src/dmd/backend/os.c index 3dff7817f10a..8c0a0f41369e 100644 --- a/src/dmd/backend/os.c +++ b/src/dmd/backend/os.c @@ -20,7 +20,7 @@ #include #include -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun #include #include #include @@ -628,7 +628,7 @@ int os_file_exists(const char *name) else result = 1; return result; -#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#elif __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun struct stat buf; return stat(name,&buf) == 0; /* file exists if stat succeeded */ @@ -705,7 +705,7 @@ char *file_8dot3name(const char *filename) int file_write(char *name, void *buffer, unsigned len) { -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun int fd; ssize_t numwritten; @@ -778,7 +778,7 @@ int file_write(char *name, void *buffer, unsigned len) int file_createdirs(char *name) { -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun return 1; #endif #if _WIN32 @@ -872,6 +872,18 @@ int os_critsecsize64() } #endif +#if __DragonFlyBSD__ +int os_critsecsize32() +{ + return 4; // sizeof(pthread_mutex_t) on 32 bit +} + +int os_critsecsize64() +{ + return 8; // sizeof(pthread_mutex_t) on 64 bit +} +#endif + #if __APPLE__ int os_critsecsize32() { diff --git a/src/dmd/backend/out.c b/src/dmd/backend/out.c index 82dc6d7f9ecf..c5ba3d8bdf0b 100644 --- a/src/dmd/backend/out.c +++ b/src/dmd/backend/out.c @@ -375,7 +375,7 @@ void dt_writeToObj(Obj& objmod, dt_t *dt, int seg, targ_size_t& offset) if (tybasic(dt->Dty) == TYcptr) objmod.reftocodeseg(seg,offset,dt->DTabytes); else -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS objmod.reftodatseg(seg,offset,dt->DTabytes,dt->DTseg,flags); #else /*else*/ if (dt->DTseg == DATA) diff --git a/src/dmd/backend/strtold.c b/src/dmd/backend/strtold.c index b58f9c9c136e..9bd7081492fc 100644 --- a/src/dmd/backend/strtold.c +++ b/src/dmd/backend/strtold.c @@ -19,7 +19,7 @@ #include #include #endif -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun #include #endif @@ -31,7 +31,7 @@ extern char * __cdecl __locale_decpoint; void __pascal __set_errno (int an_errno); #endif -#if _WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if _WIN32 || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun #if 0 /* This is for compilers that don't support hex float literals, @@ -46,7 +46,7 @@ static longdouble postab[] = {1e+4096L,1e+2048L,1e+1024L,1e+512L, 1e+256L,1e+128L,1e+64L,1e+32L,1e+16L,1e+8L,1e+4L,1e+2L,1e+1L}; -#elif (defined(__GNUC__) && __FreeBSD__ && __i386__) || _MSC_VER +#elif (defined(__GNUC__) && (__FreeBSD__ || __DragonFly__) && __i386__) || _MSC_VER // GCC on FreeBSD/i386 incorrectly rounds long double constants to double precision. Workaround: diff --git a/src/dmd/backend/token.h b/src/dmd/backend/token.h index f25cad764cc4..0a017029e89c 100644 --- a/src/dmd/backend/token.h +++ b/src/dmd/backend/token.h @@ -171,7 +171,7 @@ enum TK { TK_stdcall, TK_syscall, TK_try, -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS TK_attribute, TK_extension, TK_format, @@ -203,7 +203,7 @@ enum TK { TKandand,TKshl,TKshr,TKrcur,TKeq,TKaddass,TKminass,TKmulass,TKdivass, TKmodass,TKshrass,TKshlass,TKandass,TKxorass,TKorass,TKsemi, TKadd,TKellipsis, -#if !TX86 || TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if !TX86 || TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS TKdollar, #endif diff --git a/src/dmd/backend/ty.d b/src/dmd/backend/ty.d index a43d428ab132..e59e0542e867 100644 --- a/src/dmd/backend/ty.d +++ b/src/dmd/backend/ty.d @@ -182,7 +182,7 @@ enum mTYnothrow = 0x00200000, // nothrow function // Used only by C/C++ compiler -//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS mTYnoret = 0x01000000, // function has no return mTYtransu = 0x01000000, // transparent union //#else @@ -196,7 +196,7 @@ enum mTYsyscall = 0x40000000, mTYjava = 0x80000000, -//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS // mTYTFF = 0xFE000000, //#else mTYTFF = 0xFF000000, @@ -326,7 +326,7 @@ static if (__VERSION__ <= 2066) /* Array to give the 'relaxed' type for relaxed type checking */ extern __gshared ubyte[TYMAX] _tyrelax; //#define type_relax (config.flags3 & CFG3relax) // !=0 if relaxed type checking -//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS //#define type_semirelax (config.flags3 & CFG3semirelax) // !=0 if semi-relaxed type checking //#else //#define type_semirelax type_relax diff --git a/src/dmd/backend/ty.h b/src/dmd/backend/ty.h index 27fba7be4092..80f04bbcc820 100644 --- a/src/dmd/backend/ty.h +++ b/src/dmd/backend/ty.h @@ -180,7 +180,7 @@ enum mTYnothrow = 0x00200000, // nothrow function // Used only by C/C++ compiler -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS mTYnoret = 0x01000000, // function has no return mTYtransu = 0x01000000, // transparent union #else @@ -194,7 +194,7 @@ enum mTYsyscall = 0x40000000, mTYjava = 0x80000000, -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS mTYTFF = 0xFE000000, #else mTYTFF = 0xFF000000, @@ -319,7 +319,7 @@ inline unsigned tysimd(tym_t ty) { return tytab[ty & 0xFF] & TYFLsimd; } /* Array to give the 'relaxed' type for relaxed type checking */ extern unsigned char _tyrelax[]; #define type_relax (config.flags3 & CFG3relax) // !=0 if relaxed type checking -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS #define type_semirelax (config.flags3 & CFG3semirelax) // !=0 if semi-relaxed type checking #else #define type_semirelax type_relax diff --git a/src/dmd/backend/util2.c b/src/dmd/backend/util2.c index 545b24ed19e3..05c1c1b30963 100644 --- a/src/dmd/backend/util2.c +++ b/src/dmd/backend/util2.c @@ -141,7 +141,7 @@ void util_progress(int linnum) #endif -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || _MSC_VER +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun || _MSC_VER void util_progress() { } diff --git a/src/dmd/backend/var.c b/src/dmd/backend/var.c index 58617e4a682c..ed4b859831b8 100644 --- a/src/dmd/backend/var.c +++ b/src/dmd/backend/var.c @@ -57,7 +57,7 @@ int linkage_spec = 0; /* using the default */ #if MEMMODELS == 1 tym_t functypetab[LINK_MAXDIM] = { -#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS TYnfunc, TYnpfunc, TYnpfunc, diff --git a/src/dmd/cli.d b/src/dmd/cli.d index 6682bd604599..7cb4da968d20 100644 --- a/src/dmd/cli.d +++ b/src/dmd/cli.d @@ -25,6 +25,7 @@ enum TargetOS macOS = 4, freeBSD = 8, solaris = 16, + dragonFlyBSD = 32, } // Detect the current TargetOS @@ -44,13 +45,17 @@ else version(FreeBSD) { private enum targetOS = TargetOS.freeBSD; } +else version(DragonFlyBSD) +{ + private enum targetOS = TargetOS.dragonFlyBSD; +} else version(Solaris) { private enum targetOS = TargetOS.solaris; } else { - private enum targetOS = TarggetOS.all; + private enum targetOS = TargetOS.all; } /** @@ -212,7 +217,8 @@ struct Usage "generate library rather than object files" ), Option("m32", - "generate 32 bit code" + "generate 32 bit code", + (TargetOS.all & ~TargetOS.dragonFlyBSD) // available on all OS'es except DragonFly, which does not support 32-bit binaries ), Option("m32mscoff", "generate 32 bit code and write MS-COFF object files", diff --git a/src/dmd/dmsc.d b/src/dmd/dmsc.d index 6bf3cc4027a3..4c9f6bf53385 100644 --- a/src/dmd/dmsc.d +++ b/src/dmd/dmsc.d @@ -101,6 +101,7 @@ void backend_init() global.params.isOSX || global.params.isFreeBSD || global.params.isOpenBSD || + global.params.isDragonFlyBSD || global.params.isSolaris) { exe = params.pic == 0; diff --git a/src/dmd/e2ir.d b/src/dmd/e2ir.d index 5c8d047f5aed..c34945169f48 100644 --- a/src/dmd/e2ir.d +++ b/src/dmd/e2ir.d @@ -288,6 +288,7 @@ private elem *callfunc(Loc loc, if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || + global.params.isDragonFlyBSD || global.params.isSolaris) && tf.linkage != LINK.d) { // ehidden goes last on Linux/OSX C++ @@ -1982,7 +1983,7 @@ elem *toElem(Expression e, IRState *irs) { ts = symbol_genauto(Type_toCtype(t1)); int rtl; - if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris || + if (global.params.isLinux || global.params.isFreeBSD || global.params.isDragonFlyBSD || global.params.isSolaris || global.params.is64bit && global.params.isWindows) rtl = RTLSYM__DINVARIANT; else diff --git a/src/dmd/globals.d b/src/dmd/globals.d index 1e0136f9834d..14fcc8514c6d 100644 --- a/src/dmd/globals.d +++ b/src/dmd/globals.d @@ -25,16 +25,17 @@ template xversion(string s) enum xversion = mixin(`{ version (` ~ s ~ `) return true; else return false; }`)(); } -enum IN_GCC = xversion!`IN_GCC`; +enum IN_GCC = xversion!`IN_GCC`; enum TARGET : bool { - Linux = xversion!`linux`, - OSX = xversion!`OSX`, - FreeBSD = xversion!`FreeBSD`, - OpenBSD = xversion!`OpenBSD`, - Solaris = xversion!`Solaris`, - Windows = xversion!`Windows`, + Linux = xversion!`linux`, + OSX = xversion!`OSX`, + FreeBSD = xversion!`FreeBSD`, + OpenBSD = xversion!`OpenBSD`, + Solaris = xversion!`Solaris`, + Windows = xversion!`Windows`, + DragonFlyBSD = xversion!`DragonFlyBSD`, } enum CHECKENABLE : ubyte @@ -100,6 +101,7 @@ struct Param bool isWindows; // generate code for Windows bool isFreeBSD; // generate code for FreeBSD bool isOpenBSD; // generate code for OpenBSD + bool isDragonFlyBSD; // generate code for DragonFlyBSD bool isSolaris; // generate code for Solaris bool hasObjectiveC; // target supports Objective-C bool mscoff = false; // for Win32: write MsCoff object files instead of OMF @@ -297,7 +299,7 @@ struct Global { obj_ext = "obj"; } - else static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + else static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { obj_ext = "o"; } @@ -309,7 +311,7 @@ struct Global { lib_ext = "lib"; } - else static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + else static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { lib_ext = "a"; } @@ -321,7 +323,7 @@ struct Global { dll_ext = "dll"; } - else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { dll_ext = "so"; } @@ -337,7 +339,7 @@ struct Global { run_noext = false; } - else static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + else static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { // Allow 'script' D source files to have no extension. run_noext = true; diff --git a/src/dmd/globals.h b/src/dmd/globals.h index 260de8b24429..8fc5d7169bd6 100644 --- a/src/dmd/globals.h +++ b/src/dmd/globals.h @@ -89,6 +89,7 @@ struct Param bool isWindows; // generate code for Windows bool isFreeBSD; // generate code for FreeBSD bool isOpenBSD; // generate code for OpenBSD + bool isDragonFlyBSD;// generate code for DragonFlyBSD bool isSolaris; // generate code for Solaris bool hasObjectiveC; // target supports Objective-C bool mscoff; // for Win32: write COFF object files instead of OMF diff --git a/src/dmd/glue.d b/src/dmd/glue.d index 8c6674626c34..c389d3d75353 100644 --- a/src/dmd/glue.d +++ b/src/dmd/glue.d @@ -891,7 +891,7 @@ void FuncDeclaration_toObjFile(FuncDeclaration fd, bool multiobj) if (fd.isMain() && onlyOneMain(fd.loc)) { if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || - global.params.isOpenBSD || global.params.isSolaris) + global.params.isOpenBSD || global.params.isDragonFlyBSD || global.params.isSolaris) { objmod.external_def("_main"); } @@ -910,7 +910,7 @@ void FuncDeclaration_toObjFile(FuncDeclaration fd, bool multiobj) else if (fd.isRtInit()) { if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || - global.params.isOpenBSD || global.params.isSolaris || + global.params.isOpenBSD || global.params.isDragonFlyBSD || global.params.isSolaris || global.params.mscoff) { objmod.ehsections(); // initialize exception handling sections @@ -1095,7 +1095,7 @@ void FuncDeclaration_toObjFile(FuncDeclaration fd, bool multiobj) pi++; } - if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) && + if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isDragonFlyBSD || global.params.isSolaris) && fd.linkage != LINK.d && shidden && sthis) { /* swap shidden and sthis @@ -1330,7 +1330,7 @@ void FuncDeclaration_toObjFile(FuncDeclaration fd, bool multiobj) } } - if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) + if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isDragonFlyBSD || global.params.isSolaris) { // A hack to get a pointer to this function put in the .dtors segment if (fd.ident && memcmp(fd.ident.toChars(), "_STD".ptr, 4) == 0) diff --git a/src/dmd/lib.d b/src/dmd/lib.d index 261118809e45..d19e0e7456a0 100644 --- a/src/dmd/lib.d +++ b/src/dmd/lib.d @@ -28,7 +28,7 @@ static if (TARGET.Windows) import dmd.libomf; import dmd.libmscoff; } -else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) +else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { import dmd.libelf; } @@ -51,7 +51,7 @@ class Library { return (global.params.mscoff || global.params.is64bit) ? LibMSCoff_factory() : LibOMF_factory(); } - else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { return LibElf_factory(); } diff --git a/src/dmd/mars.d b/src/dmd/mars.d index b3448db073f0..1a5ff3b219ae 100644 --- a/src/dmd/mars.d +++ b/src/dmd/mars.d @@ -315,10 +315,17 @@ private int tryMain(size_t argc, const(char)** argv) { browse("http://dlang.org/dmd-freebsd.html"); } + /*NOTE: No regular builds for openbsd/dragonflybsd (yet) */ + /* version (OpenBSD) { browse("http://dlang.org/dmd-openbsd.html"); } + version (DragonFlyBSD) + { + browse("http://dlang.org/dmd-dragonflybsd.html"); + } + */ return EXIT_SUCCESS; } @@ -360,7 +367,7 @@ private int tryMain(size_t argc, const(char)** argv) { global.params.pic = 1; } - static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { if (global.params.lib && global.params.dll) error(Loc(), "cannot mix -lib and -shared"); @@ -539,7 +546,7 @@ private int tryMain(size_t argc, const(char)** argv) libmodules.push(files[i]); continue; } - static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { if (FileName.equals(ext, global.dll_ext)) { @@ -1194,7 +1201,7 @@ private void setDefaultLibrary() else global.params.defaultlibname = "phobos"; } - else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + else static if (TARGET.Linux || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { global.params.defaultlibname = "libphobos2.a"; } @@ -1258,6 +1265,13 @@ private void addDefaultVersionIdentifiers() VersionCondition.addPredefinedGlobalIdent("ELFv1"); global.params.isOpenBSD = true; } + else static if (TARGET.DragonFlyBSD) + { + VersionCondition.addPredefinedGlobalIdent("Posix"); + VersionCondition.addPredefinedGlobalIdent("DragonFlyBSD"); + VersionCondition.addPredefinedGlobalIdent("ELFv1"); + global.params.isDragonFlyBSD = true; + } else static if (TARGET.Solaris) { VersionCondition.addPredefinedGlobalIdent("Posix"); @@ -1541,7 +1555,7 @@ private bool parseCommandLine(const ref Strings arguments, const size_t argc, re } else if (arg == "-fPIC") { - static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) { params.pic = 1; } @@ -1579,8 +1593,12 @@ private bool parseCommandLine(const ref Strings arguments, const size_t argc, re } else if (arg == "-m32") // https://dlang.org/dmd.html#switch-m32 { - params.is64bit = false; - params.mscoff = false; + static if (TARGET.DragonFlyBSD) { + error("-m32 is not supported on DragonFlyBSD, it is 64-bit only"); + } else { + params.is64bit = false; + params.mscoff = false; + } } else if (arg == "-m64") // https://dlang.org/dmd.html#switch-m64 { diff --git a/src/dmd/mars.h b/src/dmd/mars.h index d830a222e997..e360a1f33046 100644 --- a/src/dmd/mars.h +++ b/src/dmd/mars.h @@ -26,31 +26,33 @@ dmd are: Macros defined by the compiler, not the code: Compiler: - __DMC__ Digital Mars compiler - _MSC_VER Microsoft compiler - __GNUC__ Gnu compiler - __clang__ Clang compiler + __DMC__ Digital Mars compiler + _MSC_VER Microsoft compiler + __GNUC__ Gnu compiler + __clang__ Clang compiler Host operating system: - _WIN32 Microsoft NT, Windows 95, Windows 98, Win32s, - Windows 2000, Win XP, Vista - _WIN64 Windows for AMD64 - __linux__ Linux - __APPLE__ Mac OSX - __FreeBSD__ FreeBSD - __OpenBSD__ OpenBSD - __sun Solaris, OpenSolaris, SunOS, OpenIndiana, etc + _WIN32 Microsoft NT, Windows 95, Windows 98, Win32s, + Windows 2000, Win XP, Vista + _WIN64 Windows for AMD64 + __linux__ Linux + __APPLE__ Mac OSX + __FreeBSD__ FreeBSD + __OpenBSD__ OpenBSD + __DragonFly__ DragonFlyBSD + __sun Solaris, OpenSolaris, SunOS, OpenIndiana, etc For the target systems, there are the target operating system and the target object file format: Target operating system: - TARGET_WINDOS Covers 32 bit windows and 64 bit windows - TARGET_LINUX Covers 32 and 64 bit linux - TARGET_OSX Covers 32 and 64 bit Mac OSX - TARGET_FREEBSD Covers 32 and 64 bit FreeBSD - TARGET_OPENBSD Covers 32 and 64 bit OpenBSD - TARGET_SOLARIS Covers 32 and 64 bit Solaris + TARGET_WINDOS Covers 32 bit windows and 64 bit windows + TARGET_LINUX Covers 32 and 64 bit linux + TARGET_OSX Covers 32 and 64 bit Mac OSX + TARGET_FREEBSD Covers 32 and 64 bit FreeBSD + TARGET_OPENBSD Covers 32 and 64 bit OpenBSD + TARGET_DRAGONFLYBSD Covers 64 bit DragonFlyBSD + TARGET_SOLARIS Covers 32 and 64 bit Solaris It is expected that the compiler for each platform will be able to generate 32 and 64 bit code from the same compiler binary. diff --git a/src/dmd/root/object.h b/src/dmd/root/object.h index 3970cc912de1..f20433cca5f0 100644 --- a/src/dmd/root/object.h +++ b/src/dmd/root/object.h @@ -10,7 +10,7 @@ #ifndef OBJECT_H #define OBJECT_H -#define POSIX (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun) +#define POSIX (__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun) #if __DMC__ #pragma once diff --git a/src/dmd/scanelf.d b/src/dmd/scanelf.d index 152c33b204aa..9c636899299b 100644 --- a/src/dmd/scanelf.d +++ b/src/dmd/scanelf.d @@ -20,6 +20,8 @@ version (linux) import core.sys.linux.elf; else version (FreeBSD) import core.sys.freebsd.sys.elf; +else version (DragonFlyBSD) + import core.sys.dragonflybsd.sys.elf; else version (Solaris) import core.sys.solaris.elf; diff --git a/src/dmd/target.d b/src/dmd/target.d index 6b3e291da231..c304bec515f2 100644 --- a/src/dmd/target.d +++ b/src/dmd/target.d @@ -90,7 +90,7 @@ struct Target ptrsize = 8; classinfosize = 0x98; // 152 } - if (global.params.isLinux || global.params.isFreeBSD || global.params.isOpenBSD || global.params.isSolaris) + if (global.params.isLinux || global.params.isFreeBSD || global.params.isOpenBSD || global.params.isDragonFlyBSD || global.params.isSolaris) { realsize = 12; realpad = 2; @@ -123,7 +123,7 @@ struct Target assert(0); if (global.params.is64bit) { - if (global.params.isLinux || global.params.isFreeBSD || global.params.isSolaris) + if (global.params.isLinux || global.params.isFreeBSD || global.params.isDragonFlyBSD || global.params.isSolaris) { realsize = 16; realpad = 6; @@ -140,7 +140,7 @@ struct Target c_long_doublesize = 8; cppExceptions = global.params.isLinux || global.params.isFreeBSD || - global.params.isOSX; + global.params.isDragonFlyBSD || global.params.isOSX; int64Mangle = global.params.isOSX ? 'x' : 'l'; uint64Mangle = global.params.isOSX ? 'y' : 'm'; @@ -159,7 +159,8 @@ struct Target case Tcomplex80: return Target.realalignsize; case Tcomplex32: - if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isOpenBSD || global.params.isSolaris) + if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isOpenBSD || + global.params.isDragonFlyBSD || global.params.isSolaris) return 4; break; case Tint64: @@ -167,7 +168,8 @@ struct Target case Tfloat64: case Timaginary64: case Tcomplex64: - if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isOpenBSD || global.params.isSolaris) + if (global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isOpenBSD || + global.params.isDragonFlyBSD || global.params.isSolaris) return global.params.is64bit ? 8 : 4; break; default: @@ -220,6 +222,11 @@ struct Target // sizeof(pthread_mutex_t) for OpenBSD. return global.params.isLP64 ? 8 : 4; } + else if (global.params.isDragonFlyBSD) + { + // sizeof(pthread_mutex_t) for DragonFlyBSD. + return global.params.isLP64 ? 8 : 4; + } else if (global.params.isOSX) { // sizeof(pthread_mutex_t) for OSX. @@ -244,7 +251,8 @@ struct Target { return Type.tchar.pointerTo(); } - else if (global.params.isLinux || global.params.isFreeBSD || global.params.isOpenBSD || global.params.isSolaris || global.params.isOSX) + else if (global.params.isLinux || global.params.isFreeBSD || global.params.isOpenBSD || global.params.isDragonFlyBSD || + global.params.isSolaris || global.params.isOSX) { if (global.params.is64bit) { @@ -452,7 +460,7 @@ struct Target extern (C++) static const(char)* toCppMangle(Dsymbol s) { - static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.DragonFlyBSD || TARGET.Solaris) return toCppMangleItanium(s); else static if (TARGET.Windows) return toCppMangleMSVC(s); @@ -462,7 +470,7 @@ struct Target extern (C++) static const(char)* cppTypeInfoMangle(ClassDeclaration cd) { - static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris) + static if (TARGET.Linux || TARGET.OSX || TARGET.FreeBSD || TARGET.OpenBSD || TARGET.Solaris || TARGET.DragonFlyBSD) return cppTypeInfoMangleItanium(cd); else static if (TARGET.Windows) return cppTypeInfoMangleMSVC(cd); diff --git a/src/dmd/tk/filespec.c b/src/dmd/tk/filespec.c index de94a3fd9df4..12a6c142206f 100644 --- a/src/dmd/tk/filespec.c +++ b/src/dmd/tk/filespec.c @@ -25,7 +25,7 @@ #include #endif -#if M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun #include #include #endif @@ -87,7 +87,7 @@ char * filespecaddpath(const char *path,const char *filename) /**********************/ char * filespecrootpath(char *filespec) { -#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun #define DIRCHAR '/' #endif #if MSDOS || __OS2__ || __NT__ || _WIN32 @@ -112,7 +112,7 @@ char * filespecrootpath(char *filespec) #endif /* get current working directory path */ -#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun cwd_t = (char *)getcwd(NULL, 256); #endif #if MSDOS || __OS2__ || __NT__ || _WIN32 @@ -134,7 +134,7 @@ char * filespecrootpath(char *filespec) if (cwd[strlen(cwd) - 1] == DIRCHAR) cwd[strlen(cwd) - 1] = '\0'; #endif -#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun free(cwd_t); #endif p = filespec; @@ -151,7 +151,7 @@ char * filespecrootpath(char *filespec) { cwd_t = cwd; cwd = (char *)mem_calloc(strlen(cwd_t) + 1 + strlen(p) + 1); -#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun sprintf(cwd, "%s/%s", cwd_t, p); /* add relative directory */ #endif #if MSDOS || __OS2__ || __NT__ || _WIN32 @@ -172,7 +172,7 @@ char * filespecrootpath(char *filespec) { /* ... save remaining string */ cwd_t = cwd; cwd = (char *)mem_calloc(strlen(cwd_t) + 1 + strlen(p) + 1); -#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if SUN || M_UNIX || M_XENIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun sprintf(cwd, "%s/%s", cwd_t, p); /* add relative directory */ #endif #if MSDOS || __OS2__ || __NT__ || _WIN32 @@ -403,7 +403,7 @@ char * filespecbackup(const char *filespec) #if MSDOS || __OS2__ || __NT__ || _WIN32 return filespecforceext(filespec,"BAK"); #endif -#if BSDUNIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if BSDUNIX || __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun char *p,*f; /* Prepend .B to file name, if it isn't already there */ diff --git a/src/dmd/tk/mem.c b/src/dmd/tk/mem.c index c62bafc3a382..3b29bcec74a9 100644 --- a/src/dmd/tk/mem.c +++ b/src/dmd/tk/mem.c @@ -326,7 +326,7 @@ static struct mem_debug 11111, 0, BEFOREVAL, -#if !(__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun) +#if !(__linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun) AFTERVAL #endif }; @@ -842,7 +842,7 @@ void mem_init() mem_numalloc = 0; mem_maxalloc = 0; mem_alloclist.Mnext = NULL; -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun *(long *) &(mem_alloclist.data[0]) = AFTERVAL; #endif #endif diff --git a/src/dmd/toir.d b/src/dmd/toir.d index a95b53f54971..52160104cebe 100644 --- a/src/dmd/toir.d +++ b/src/dmd/toir.d @@ -1087,7 +1087,7 @@ L2: //printf(" 3 RET.stack\n"); return RET.stack; } - else if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isSolaris) && + else if ((global.params.isLinux || global.params.isOSX || global.params.isFreeBSD || global.params.isDragonFlyBSD || global.params.isSolaris) && tf.linkage == LINK.c && tns.iscomplex()) { diff --git a/src/osmodel.mak b/src/osmodel.mak index c0aa7cfb8e50..dfbcdc3a3b94 100644 --- a/src/osmodel.mak +++ b/src/osmodel.mak @@ -28,6 +28,9 @@ ifeq (,$(OS)) ifeq (NetBSD,$(uname_S)) OS:=netbsd endif + ifeq (DragonFly,$(uname_S)) + OS:=dragonflybsd + endif ifeq (Solaris,$(uname_S)) OS:=solaris endif diff --git a/test/Makefile b/test/Makefile index 5f1a157258a9..aff802ad1cd9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -105,6 +105,8 @@ ifeq (freebsd,$(OS)) SHELL=/usr/local/bin/bash else ifeq (netbsd,$(OS)) SHELL=/usr/pkg/bin/bash +else ifeq (dragonflybsd,$(OS)) + SHELL=/usr/local/bin/bash else SHELL=/bin/bash endif diff --git a/test/d_do_test.d b/test/d_do_test.d index d09321cbdfb6..3e2799170952 100755 --- a/test/d_do_test.d +++ b/test/d_do_test.d @@ -32,7 +32,7 @@ void usage() ~ " REQUIRED_ARGS: arguments always passed to the compiler\n" ~ " DMD: compiler to use, ex: ../src/dmd (required)\n" ~ " CC: C++ compiler to use, ex: dmc, g++\n" - ~ " OS: win32, win64, linux, freebsd, osx, netbsd\n" + ~ " OS: win32, win64, linux, freebsd, osx, netbsd, dragonflybsd\n" ~ " RESULTS_DIR: base directory for test results\n" ~ " MODEL: 32 or 64 (required)\n" ~ " windows vs non-windows portability env vars:\n" @@ -582,6 +582,16 @@ int tryMain(string[] args) (!testArgs.requiredArgs.empty ? " " : ""), testArgs.permuteArgs); + version (DragonFlyBSD) + { + // DragonFlyBSD is x86_64 only, instead of adding DISABLED to a lot of tests, just exclude them from running + if (testArgs.requiredArgs.canFind("-m32")) + { + testArgs.disabled = true; + writefln("!!! [Skipping -m32 on %s]", envData.os); + } + } + if (testArgs.disabledPlatforms.canFind(envData.os, envData.os ~ envData.model)) { testArgs.disabled = true; diff --git a/test/do_test.sh b/test/do_test.sh index be8c9e8dd86b..9f6d63cb15bf 100755 --- a/test/do_test.sh +++ b/test/do_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # enable debugging # set -x diff --git a/test/fail_compilation/fail3753.d b/test/fail_compilation/fail3753.d index 485599586534..72fa7af7cfdf 100644 --- a/test/fail_compilation/fail3753.d +++ b/test/fail_compilation/fail3753.d @@ -37,6 +37,10 @@ void main() { static assert(0); } + version (DragonFlyBSD) + { + static assert(0); + } version (OSX) { static assert(0); diff --git a/test/runnable/dhry.d b/test/runnable/dhry.d index 40f9ccff0935..812d7d279508 100644 --- a/test/runnable/dhry.d +++ b/test/runnable/dhry.d @@ -1,6 +1,6 @@ // PERMUTE_ARGS: // REQUIRED_ARGS: -release -O -g -inline -// DISABLED: freebsd +// DISABLED: freebsd dragonflybsd /* ************************************************************************* diff --git a/test/runnable/extra-files/cppb.cpp b/test/runnable/extra-files/cppb.cpp index 3a16c24b53c7..7110b1e9a900 100644 --- a/test/runnable/extra-files/cppb.cpp +++ b/test/runnable/extra-files/cppb.cpp @@ -348,7 +348,7 @@ size_t getoffset13161a() /****************************************************/ -#if __linux__ || __APPLE__ || __FreeBSD__ +#if __linux__ || __APPLE__ || __FreeBSD__ || __DragonFly__ #include #include #include @@ -405,7 +405,7 @@ wchar_t f13289_cpp_wchar_t(wchar_t ch) } } -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ || __DragonFly__ unsigned short f13289_d_wchar(unsigned short ch); wchar_t f13289_d_dchar(wchar_t ch); #elif _WIN32 @@ -415,7 +415,7 @@ unsigned int f13289_d_dchar(unsigned int ch); bool f13289_cpp_test() { -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ || __DragonFly__ if (!(f13289_d_wchar((unsigned short)'c') == (unsigned short)'C')) return false; if (!(f13289_d_wchar((unsigned short)'D') == (unsigned short)'D')) return false; if (!(f13289_d_dchar(L'e') == L'E')) return false; @@ -581,7 +581,7 @@ void fuzz2_cppvararg(uint64_t arg10, uint64_t arg11, bool arg12) fuzz2_checkValues(arg10, arg11, arg12); } -#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ +#if __linux__ || __APPLE__ || __FreeBSD__ || __OpenBSD__ || __sun || __NetBSD__ || __DragonFly__ #define wchar unsigned short #elif _WIN32 #define wchar wchar_t diff --git a/test/runnable/test17559.d b/test/runnable/test17559.d index 4b6f5461febf..a759f1564c6c 100644 --- a/test/runnable/test17559.d +++ b/test/runnable/test17559.d @@ -1,5 +1,5 @@ // REQUIRED_ARGS: -g -// REQUIRED_ARGS(linux freebsd): -L-export-dynamic +// REQUIRED_ARGS(linux freebsd dragonflybsd): -L-export-dynamic // PERMUTE_ARGS: // DISABLED: osx