Skip to content

Commit

Permalink
Some runtime fixes for VS2013
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Feb 18, 2016
1 parent 1adf486 commit 880ef3c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 70 deletions.
6 changes: 5 additions & 1 deletion Compiler/runtime/Dynload.cpp
Expand Up @@ -34,7 +34,11 @@ extern "C" {
#include <stdio.h>
#include <stdlib.h>
#include "openmodelica.h"
#include "modelica.h"
#include "util/read_write.h"
#include "util/real_array.h"
#include "util/string_array.h"
#include "util/boolean_array.h"
#include "util/integer_array.h"
#include "systemimpl.h"
#include "errorext.h"
#include "meta_modelica_builtin.h"
Expand Down
1 change: 0 additions & 1 deletion Compiler/runtime/Dynload_omc.cpp
Expand Up @@ -37,7 +37,6 @@ extern "C" {
#endif

#include "openmodelica.h"
#include "modelica.h"
#include "meta_modelica.h"
#define ADD_METARECORD_DEFINITIONS static
#include "OpenModelicaBootstrappingHeader.h"
Expand Down
3 changes: 1 addition & 2 deletions SimulationRuntime/c/math-support/pivot.c
Expand Up @@ -2,10 +2,9 @@
provides a simple function to do a full pivot search while doing an LU factorization
*/

#include "util/modelica.h"

#include <math.h>
#include <assert.h>
#include "openmodelica.h"

/* Matrixes using column major order (as in Fortran) */
#ifndef set_matrix_elt
Expand Down
10 changes: 5 additions & 5 deletions SimulationRuntime/c/meta/meta_modelica_segv.c
Expand Up @@ -30,6 +30,11 @@

/* Stack overflow handling */

#if defined(linux) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE 1
/* for pthread_getattr_np */
#endif

#include "meta_modelica.h"

void* mmc_getStacktraceMessages_threadData(threadData_t *threadData)
Expand All @@ -50,11 +55,6 @@ int mmc_hasStacktraceMessages(threadData_t *threadData)
return threadData->localRoots[LOCAL_ROOT_STACK_OVERFLOW] != 0;
}

#if defined(linux) && !defined(_GNU_SOURCE)
#define _GNU_SOURCE 1
/* for pthread_getattr_np */
#endif

pthread_key_t mmc_stack_overflow_jumper;

#if defined(linux) || defined(__APPLE_CC__)
Expand Down
12 changes: 5 additions & 7 deletions SimulationRuntime/c/openmodelica.h
Expand Up @@ -154,14 +154,12 @@ struct type_desc_s {
#define semiLinear(x,positiveSlope,negativeSlope) (x>=0?positiveSlope*x:negativeSlope*x)

/* sign function */
#define sign(v) (v>0?1:(v<0?-1:0))
static inline int sign(double v)
{
return v > 0 ? 1 : v < 0 ? -1 : 0;
}

#if defined(_MSC_VER)
#define fmax(x, y) ((x>y)?x:y)
#define fmin(x, y) ((x<y)?x:y)
#define snprintf sprintf_s
#define trunc(a) ((double)((int)(a)))
#endif
#include "util/omc_msvc.h"

/* initial and terminal function calls */
#define initial() data->simulationInfo->initial
Expand Down
52 changes: 1 addition & 51 deletions SimulationRuntime/c/util/modelica.h
Expand Up @@ -41,41 +41,7 @@
extern "C" {
#endif

/* adrpo: extreme windows crap! */
#if defined(__MINGW32__) || defined(_MSC_VER)
#define DLLImport __declspec( dllimport )
#define DLLExport __declspec( dllexport )
#else
#define DLLImport /* extern */
#define DLLExport /* nothing */
#endif

#if defined(IMPORT_INTO)
#define DLLDirection DLLImport
#else /* we export from the dll */
#define DLLDirection DLLExport
#endif

#if defined(__MINGW32__) || defined(_MSC_VER)
#define WIN32_LEAN_AND_MEAN
#if !defined(NOMINMAX)
#define NOMINMAX
#include <windows.h>
#endif
#endif

#include <stdlib.h>
#include <limits.h>

#if defined(__MINGW32__) || defined(_MSC_VER)
#define EXIT(code) exit(code)
#else
/* We need to patch exit() on Unix systems
* It does not change the exit code of simulations for some reason! */
#include <unistd.h>
#define EXIT(code) {fflush(NULL); _exit(code);}
#endif

#include "util/omc_msvc.h"
#include "omc_inline.h"

#include "util/modelica_string.h"
Expand All @@ -99,22 +65,6 @@ extern "C" {
#include "meta/meta_modelica_builtin.h"
#include "util/varinfo.h"


/* math functions (-lm)*/

/* Special Modelica builtin functions*/
#define smooth(P,EXP) (EXP)
#define semiLinear(x,positiveSlope,negativeSlope) (x>=0?positiveSlope*x:negativeSlope*x)

/* sign function */
#define sign(v) (v>0?1:(v<0?-1:0))

#if defined(_MSC_VER)
#define fmax(x, y) ((x>y)?x:y)
#define fmin(x, y) ((x<y)?x:y)
#define snprintf sprintf_s
#endif

#if defined(__cplusplus)
}
#endif
Expand Down
8 changes: 5 additions & 3 deletions SimulationRuntime/c/util/omc_msvc.h
Expand Up @@ -75,15 +75,17 @@ static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}};
#define WIN32
#endif

#define round(dbl) ((dbl) < 0.0 ? ceil((dbl) - 0.5) : floor((dbl) + 0.5))
#define geteuid(void) (-1)

#if defined(_WIN32) || defined(_WIN64)
#if _MSC_VER < 1800 /* VS 2013 */
#define round(dbl) ((dbl) < 0.0 ? ceil((dbl) - 0.5) : floor((dbl) + 0.5))
#define fmax(x, y) ((x>y)?x:y)
#define fmin(x, y) ((x<y)?x:y)
#define snprintf sprintf_s
#define trunc(a) ((double)((int)(a)))
#endif

#define snprintf sprintf_s

#define PATH_MAX _MAX_PATH
#include <stdarg.h>
char *realpath(const char *path, char *resolved_path);
Expand Down

0 comments on commit 880ef3c

Please sign in to comment.