File: callingconvention.srctree

package info (click to toggle)
cython 3.0.11%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,092 kB
  • sloc: python: 83,539; ansic: 18,831; cpp: 1,402; xml: 1,031; javascript: 511; makefile: 403; sh: 204; sed: 11
file content (95 lines) | stat: -rw-r--r-- 2,072 bytes parent folder | download | duplicates (5)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
PYTHON setup.py build_ext --inplace
PYTHON -c "import callingconvention"

######## setup.py ########

from distutils.core import setup
from Cython.Distutils import build_ext
from Cython.Distutils.extension import Extension

setup(
    ext_modules = [
        Extension("callingconvention", ["callingconvention.pyx", "external_callingconvention.c"]),
    ],
    cmdclass={'build_ext': build_ext},
)

######## callingconvention.pyx ########
# mode: compile

cdef extern from "callingconvention.h":
    pass

cdef extern int f1()
cdef extern int __cdecl f2()
cdef extern int __stdcall f3()
cdef extern int __fastcall f4()

cdef extern int (*p1)()
cdef extern int (__cdecl *p2)()
cdef extern int (__stdcall *p3)()
cdef extern int (__fastcall *p4)()

p1 = f1
p2 = f2
p3 = f3
p4 = f4


######## callingconvention.h ########

#define DLL_EXPORT
#include "external_callingconvention.h"


######## external_callingconvention.h ########

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#elif defined(DLL_EXPORT)
  #define DL_IMPORT(t) DL_EXPORT(t)
#endif

#ifdef __cplusplus
extern "C" {
#endif
extern DL_IMPORT(int) f1(void);
extern DL_IMPORT(int) __cdecl f2(void);
extern DL_IMPORT(int) __stdcall f3(void);
extern DL_IMPORT(int) __fastcall f4(void);
extern DL_IMPORT(int) (*p1)(void);
extern DL_IMPORT(int) (__cdecl *p2)(void);
extern DL_IMPORT(int) (__stdcall *p3)(void);
extern DL_IMPORT(int) (__fastcall *p4)(void);
#ifdef __cplusplus
}
#endif

######## external_callingconvention.c ########
#include <Python.h>

#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif


#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

DL_EXPORT(int) f1(void) {return 0;}
DL_EXPORT(int) __cdecl f2(void) {return 0;}
DL_EXPORT(int) __stdcall f3(void) {return 0;}
DL_EXPORT(int) __fastcall f4(void) {return 0;}
DL_EXPORT(int) (*p1)(void);
DL_EXPORT(int) (__cdecl *p2)(void);
DL_EXPORT(int) (__stdcall *p3)(void);
DL_EXPORT(int) (__fastcall *p4)(void);