Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions src/pyfmi/fmi_util.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/pyfmi/fmi_util_os.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef FMI_UTIL_OS_H
#define FMI_UTIL_OS_H

#include <stdio.h>

#if defined(_WIN32)
#define os_fseek _fseeki64
#define os_ftell _ftelli64
#else
#define os_fseek fseeko
#define os_ftell ftello
#endif

#endif
4 changes: 2 additions & 2 deletions src/pyfmi/master.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.")
Expand Down
Loading