Skip to content

Commit 95878e9

Browse files
authored
Fix cython3 warnings (#410)
1 parent 67d63ff commit 95878e9

3 files changed

Lines changed: 24 additions & 22 deletions

File tree

src/pyfmi/fmi_util.pxd

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,14 @@ cimport pyfmi.fmi3 as FMI3
2929
This is because fseek/ftell is not sufficient as soon as the number of bytes in a result file
3030
exceed the maximum value for long int.
3131
"""
32-
IF UNAME_SYSNAME == "Windows":
33-
cdef extern from "stdio.h" nogil:
34-
ctypedef struct FILE:
35-
pass
36-
long long _ftelli64(FILE *stream)
37-
int _fseeki64(FILE *stream, long long offset, int whence)
38-
cdef inline int os_specific_fseek(FILE *stream, long long offset, int whence):
39-
return _fseeki64(stream, offset, whence)
40-
cdef inline long long os_specific_ftell(FILE *stream):
41-
return _ftelli64(stream)
42-
ELSE:
43-
cdef extern from "stdio.h" nogil:
44-
ctypedef struct FILE:
45-
pass
46-
long long ftello(FILE *stream)
47-
int fseeko(FILE *stream, long long offset, int whence)
48-
cdef inline int os_specific_fseek(FILE *stream, long long offset, int whence):
49-
return fseeko(stream, offset, whence)
50-
cdef inline long long os_specific_ftell(FILE *stream):
51-
return ftello(stream)
32+
cdef extern from "fmi_util_os.h" nogil:
33+
int os_fseek(FILE *stream, long long offset, int whence)
34+
long long os_ftell(FILE *stream)
35+
36+
cdef inline int os_specific_fseek(FILE *stream, long long offset, int whence) nogil:
37+
return os_fseek(stream, offset, whence)
38+
cdef inline long long os_specific_ftell(FILE *stream) nogil:
39+
return os_ftell(stream)
5240

5341
cdef class DumpDataFMI3:
5442
cdef np.ndarray time_tmp

src/pyfmi/fmi_util_os.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef FMI_UTIL_OS_H
2+
#define FMI_UTIL_OS_H
3+
4+
#include <stdio.h>
5+
6+
#if defined(_WIN32)
7+
#define os_fseek _fseeki64
8+
#define os_ftell _ftelli64
9+
#else
10+
#define os_fseek fseeko
11+
#define os_ftell ftello
12+
#endif
13+
14+
#endif

src/pyfmi/master.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ from pyfmi.fmi2 import FMI2_CONTINUOUS, FMI2_INPUT, FMI2_OUTPUT
4444
from pyfmi.fmi_util import Graph
4545
from pyfmi.exceptions import FMUException, InvalidFMUException
4646

47-
IF WITH_OPENMP:
47+
if WITH_OPENMP:
4848
cimport openmp
4949

5050
DEF SERIAL = 0
@@ -1643,7 +1643,7 @@ cdef class Master:
16431643

16441644
if options["num_threads"] and options["execution"] == "parallel":
16451645
pass
1646-
IF WITH_OPENMP:
1646+
if WITH_OPENMP:
16471647
openmp.omp_set_num_threads(options["num_threads"])
16481648
if options["step_size"] <= 0.0:
16491649
raise FMUException("The step-size must be greater than zero.")

0 commit comments

Comments
 (0)