diff --git a/dmd/constfold.c b/dmd/constfold.c index 5e20f736..34b2c49a 100644 --- a/dmd/constfold.c +++ b/dmd/constfold.c @@ -487,6 +487,9 @@ Expression *Mod(Type *type, Expression *e1, Expression *e2) c = fmodl(e1->toReal(), r2) + fmodl(e1->toImaginary(), r2) * I; #elif defined(IN_GCC) c = complex_t(e1->toReal() % r2, e1->toImaginary() % r2); +#elif defined(__FreeBSD__) && __FreeBSD_version < 800000 + // freebsd is kinda messed up. the STABLE branch doesn't support C99's fmodl !?! + c = complex_t(fmod(e1->toReal(), r2), fmod(e1->toImaginary(), r2)); #else c = complex_t(fmodl(e1->toReal(), r2), fmodl(e1->toImaginary(), r2)); #endif @@ -498,6 +501,9 @@ Expression *Mod(Type *type, Expression *e1, Expression *e2) c = fmodl(e1->toReal(), i2) + fmodl(e1->toImaginary(), i2) * I; #elif defined(IN_GCC) c = complex_t(e1->toReal() % i2, e1->toImaginary() % i2); +#elif defined(__FreeBSD__) && __FreeBSD_version < 800000 + // freebsd is kinda messed up. the STABLE branch doesn't support C99's fmodl !?! + c = complex_t(fmod(e1->toReal(), i2), fmod(e1->toImaginary(), i2)); #else c = complex_t(fmodl(e1->toReal(), i2), fmodl(e1->toImaginary(), i2)); #endif diff --git a/dmd/mars.c b/dmd/mars.c index 84a43210..c4585b23 100644 --- a/dmd/mars.c +++ b/dmd/mars.c @@ -330,8 +330,10 @@ int main(int argc, char *argv[]) global.params.os = OSLinux; #elif __APPLE__ global.params.os = OSMacOSX; +#elif __FreeBSD__ + global.params.os = OSFreeBSD; #else -#error +#error Unsupported OS #endif /* linux */ assert(global.params.os != OSinvalid); @@ -843,6 +845,11 @@ int main(int argc, char *argv[]) global.params.tt_os = "-pc-darwin-gnu"; break; + case OSFreeBSD: + VersionCondition::addPredefinedGlobalIdent("freebsd"); + VersionCondition::addPredefinedGlobalIdent("Posix"); + break; + default: assert(false && "Target OS not supported"); } diff --git a/dmd/mars.h b/dmd/mars.h index 008a7c31..219c39c9 100644 --- a/dmd/mars.h +++ b/dmd/mars.h @@ -52,7 +52,8 @@ enum OS OSinvalid, OSLinux, OSWindows, - OSMacOSX + OSMacOSX, + OSFreeBSD }; // Put command line switches in here diff --git a/gen/linker.cpp b/gen/linker.cpp index abc045b1..5176080a 100644 --- a/gen/linker.cpp +++ b/gen/linker.cpp @@ -151,15 +151,18 @@ int linkExecutable(const char* argv0) } // default libs - if(global.params.os == OSLinux || global.params.os == OSMacOSX) - { - args.push_back("-lpthread"); + switch(global.params.os) { + case OSLinux: + case OSMacOSX: args.push_back("-ldl"); + case OSFreeBSD: + args.push_back("-lpthread"); args.push_back("-lm"); - } - else if (global.params.os == OSWindows) - { + break; + + case OSWindows: // FIXME: I'd assume kernel32 etc + break; } // object files diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index fb295428..95df537b 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -704,6 +704,12 @@ const LLStructType* DtoMutexType() return LLStructType::get(types); } + // FreeBSD + else if (global.params.os == OSFreeBSD) { + // Just a pointer + return LLStructType::get(DtoSize_t(), 0); + } + // pthread_fastlock std::vector types2; types2.push_back(DtoSize_t()); diff --git a/runtime/internal/critical.c b/runtime/internal/critical.c index 9bb41143..56231d61 100644 --- a/runtime/internal/critical.c +++ b/runtime/internal/critical.c @@ -75,7 +75,7 @@ void _STD_critical_term() /* ================================= linux ============================ */ -#if linux || __APPLE__ +#if linux || __APPLE__ || __FreeBSD__ #include #include diff --git a/tests/runtest b/tests/runtest index c6393789..b749558d 100755 --- a/tests/runtest +++ b/tests/runtest @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # check for command line arguments if [ -z "$1" ] ; then