diff --git a/src/pyfmi/fmi_util.pxd b/src/pyfmi/fmi_util.pxd index cbb98c55..ea434fa4 100644 --- a/src/pyfmi/fmi_util.pxd +++ b/src/pyfmi/fmi_util.pxd @@ -29,26 +29,14 @@ cimport pyfmi.fmi3 as FMI3 This is because fseek/ftell is not sufficient as soon as the number of bytes in a result file exceed the maximum value for long int. """ -IF UNAME_SYSNAME == "Windows": - cdef extern from "stdio.h" nogil: - ctypedef struct FILE: - pass - long long _ftelli64(FILE *stream) - int _fseeki64(FILE *stream, long long offset, int whence) - cdef inline int os_specific_fseek(FILE *stream, long long offset, int whence): - return _fseeki64(stream, offset, whence) - cdef inline long long os_specific_ftell(FILE *stream): - return _ftelli64(stream) -ELSE: - cdef extern from "stdio.h" nogil: - ctypedef struct FILE: - pass - long long ftello(FILE *stream) - int fseeko(FILE *stream, long long offset, int whence) - cdef inline int os_specific_fseek(FILE *stream, long long offset, int whence): - return fseeko(stream, offset, whence) - cdef inline long long os_specific_ftell(FILE *stream): - return ftello(stream) +cdef extern from "fmi_util_os.h" nogil: + int os_fseek(FILE *stream, long long offset, int whence) + long long os_ftell(FILE *stream) + +cdef inline int os_specific_fseek(FILE *stream, long long offset, int whence) nogil: + return os_fseek(stream, offset, whence) +cdef inline long long os_specific_ftell(FILE *stream) nogil: + return os_ftell(stream) cdef class DumpDataFMI3: cdef np.ndarray time_tmp diff --git a/src/pyfmi/fmi_util_os.h b/src/pyfmi/fmi_util_os.h new file mode 100644 index 00000000..bddc698c --- /dev/null +++ b/src/pyfmi/fmi_util_os.h @@ -0,0 +1,14 @@ +#ifndef FMI_UTIL_OS_H +#define FMI_UTIL_OS_H + +#include + +#if defined(_WIN32) + #define os_fseek _fseeki64 + #define os_ftell _ftelli64 +#else + #define os_fseek fseeko + #define os_ftell ftello +#endif + +#endif diff --git a/src/pyfmi/master.pyx b/src/pyfmi/master.pyx index 531de547..5ffde493 100644 --- a/src/pyfmi/master.pyx +++ b/src/pyfmi/master.pyx @@ -44,7 +44,7 @@ from pyfmi.fmi2 import FMI2_CONTINUOUS, FMI2_INPUT, FMI2_OUTPUT from pyfmi.fmi_util import Graph from pyfmi.exceptions import FMUException, InvalidFMUException -IF WITH_OPENMP: +if WITH_OPENMP: cimport openmp DEF SERIAL = 0 @@ -1643,7 +1643,7 @@ cdef class Master: if options["num_threads"] and options["execution"] == "parallel": pass - IF WITH_OPENMP: + if WITH_OPENMP: openmp.omp_set_num_threads(options["num_threads"]) if options["step_size"] <= 0.0: raise FMUException("The step-size must be greater than zero.")