Skip to content

Commit 3309033

Browse files
committed
Fixes "incomplete type" complaints
cython always complaint about "incomplete type" for pthread_mutex_t and sockaddr_storage. They must be atleast defined with a "pass", which makes the complaint go away. Also reformat the imports a bit.
1 parent 2617092 commit 3309033

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

UPGRADE_C_API.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,8 @@ Then, simply generate the header definitions like in this example:
5151
scripts/pyslurm_bindgen.py -D /directoy/with/slurm/headers > pyslurm/slurm/header.pxi
5252
5353
The script outputs everything to `stdout`. Simply redirect the output to the file: :code:`pyslurm/slurm/header.pxi`.
54+
The headers should now be fully translated.
5455

55-
Now, 99% of the work is done for generating the headers. For the 1% left, you now need to open the generated file, search for the two follwowing statements and comment them out:
56-
57-
- `slurm_addr_t control_addr`
58-
- `phtread_mutex_t lock`
59-
60-
The compiler will otherwise complain that these are incomplete type definitions.
6156

6257
Compiling, Updating, Testing
6358
----------------------------

pyslurm/slurm/__init__.pxd

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
from libcpp cimport bool
2-
from posix.unistd cimport uid_t, pid_t, gid_t
3-
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t
4-
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t
52
from cpython.version cimport PY_MAJOR_VERSION
6-
from libc.string cimport strlen, memcpy
73

8-
cdef extern from "<netinet/in.h>" nogil:
9-
ctypedef struct sockaddr_in
10-
ctypedef struct sockaddr_storage
4+
from posix.unistd cimport (
5+
uid_t,
6+
pid_t,
7+
gid_t,
8+
)
9+
10+
from libc.stdint cimport (
11+
int8_t,
12+
int16_t,
13+
int32_t,
14+
int64_t,
15+
uint8_t,
16+
uint16_t,
17+
uint32_t,
18+
uint64_t,
19+
)
20+
21+
from libc.string cimport (
22+
strlen,
23+
memcpy,
24+
)
25+
26+
cdef extern from '<netinet/in.h>' nogil:
27+
ctypedef struct sockaddr_storage:
28+
pass
1129

1230
cdef extern from '<stdio.h>' nogil:
1331
ctypedef struct FILE
1432
cdef FILE *stdout
1533

16-
cdef extern from 'time.h' nogil:
34+
cdef extern from '<time.h>' nogil:
1735
ctypedef long time_t
1836
double difftime(time_t time1, time_t time2)
1937
time_t time(time_t *t)
@@ -24,8 +42,15 @@ cdef extern from '<Python.h>' nogil:
2442
cdef int __LINE__
2543
char *__FUNCTION__
2644

27-
cdef extern from "<pthread.h>" nogil:
28-
ctypedef union pthread_mutex_t
45+
cdef extern from '<pthread.h>' nogil:
46+
ctypedef struct pthread_mutex_t:
47+
pass
48+
49+
ctypedef struct pthread_cond_t:
50+
pass
51+
52+
ctypedef struct pthread_t:
53+
pass
2954

3055
cdef extern from *:
3156
ctypedef struct slurm_job_credential

0 commit comments

Comments
 (0)