File: ffi_kdumpfile.py

package info (click to toggle)
pykdumpfile 0.5.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 300 kB
  • sloc: python: 2,607; ansic: 447; makefile: 17
file content (33 lines) | stat: -rw-r--r-- 582 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from os import path
from cffi import FFI

ffi = FFI()

for header in ('addrxlat.h', 'kdumpfile.h'):
    header_file = path.join(path.dirname(__file__), header)
    with open(header_file) as f:
        ffi.cdef(f.read())

ffi.cdef("""
/* Blob data must be allocated by libc allocators.
 * Expose them here.
 */
void *malloc(size_t size);
void free(void *ptr);

extern "Python" {
}
""")
ffi.set_source(
    '_kdumpfile',
    '''
#include <libkdumpfile/kdumpfile.h>
#include <stdlib.h>
''',
    libraries = [
        'kdumpfile',
    ],
)

if __name__ == '__main__':
    ffi.compile()