From 3e04919a3bb7f97890e0208e2c3e596837a1cd29 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Thu, 21 May 2026 07:58:51 +0200 Subject: [PATCH 1/2] Fix cython3 warnings --- src/pyfmi/fmi_util.pxd | 4 ++-- src/pyfmi/master.pyx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pyfmi/fmi_util.pxd b/src/pyfmi/fmi_util.pxd index cbb98c55..0523dbe9 100644 --- a/src/pyfmi/fmi_util.pxd +++ b/src/pyfmi/fmi_util.pxd @@ -29,7 +29,7 @@ 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": +if UNAME_SYSNAME == "Windows": cdef extern from "stdio.h" nogil: ctypedef struct FILE: pass @@ -39,7 +39,7 @@ IF UNAME_SYSNAME == "Windows": return _fseeki64(stream, offset, whence) cdef inline long long os_specific_ftell(FILE *stream): return _ftelli64(stream) -ELSE: +else: cdef extern from "stdio.h" nogil: ctypedef struct FILE: pass 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.") From 511f98a2eb189ebe7c682c118fe019cfe2df0893 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Thu, 21 May 2026 08:18:38 +0200 Subject: [PATCH 2/2] more --- src/pyfmi/fmi_util.pxd | 28 ++++++++-------------------- src/pyfmi/fmi_util_os.h | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 src/pyfmi/fmi_util_os.h diff --git a/src/pyfmi/fmi_util.pxd b/src/pyfmi/fmi_util.pxd index 0523dbe9..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