1 /**
2 Mirror _pyport.h
3 */4 moduledeimos.python.pyport;
5 6 /* D long is always 64 bits, but when the Python/C API mentions long, it is of
7 * course referring to the C type long, the size of which is 32 bits on both
8 * X86 and X86_64 under Windows, but 32 bits on X86 and 64 bits on X86_64 under
9 * most other operating systems. */10 11 /// _12 aliaslongC_longlong;
13 /// _14 aliasulongC_ulonglong;
15 16 version(Windows) {
17 /// _18 aliasintC_long;
19 /// _20 aliasuintC_ulong;
21 } else {
22 version (X86) {
23 /// _24 aliasintC_long;
25 /// _26 aliasuintC_ulong;
27 } else {
28 /// _29 aliaslongC_long;
30 /// _31 aliasulongC_ulong;
32 }
33 }
34 35 36 /*
37 * Py_ssize_t is defined as a signed type which is 8 bytes on X86_64 and 4
38 * bytes on X86.
39 */40 version(Python_2_5_Or_Later){
41 version (X86_64) {
42 /// _43 aliaslongPy_ssize_t;
44 } else {
45 /// _46 aliasintPy_ssize_t;
47 }
48 version(Python_3_2_Or_Later) {
49 /// Availability: >= 3.2 50 /// (Py_hash_t invariably replaces C_long, so we always define it for 51 /// convenience)52 aliasPy_ssize_tPy_hash_t;
53 /// Availability: >= 3.254 aliassize_tPy_uhash_t;
55 }else{
56 aliasC_longPy_hash_t;
57 }
58 }else {
59 /*
60 * Seems Py_ssize_t didn't exist in 2.4, and int was everywhere it is now.
61 */62 /// _63 aliasintPy_ssize_t;
64 /*
65 * Seems Py_hash_t didn't exist in 2.4, and C_long was everywhere it is now.
66 */67 /// _68 aliasC_longPy_hash_t;
69 }
70 71 version(linux) version(DigitalMars) version = dmd_linux;
72 version(OSX) version(DigitalMars) version = dmd_osx;
73 templatePyAPI_DATA(stringdecl) {
74 75 version(dmd_linux) {
76 // has to be special77 78 // todo: why does ldc/linux not work this way? 79 // --export-dynamic seems not to change anything80 // export causes dmd to prepend symbols with _imp__, so no use.81 // extern is not necessary for single-command builds82 // necessary for traditional per-file builds.83 enumPyAPI_DATA = (q{84 extern(C)
85 extern86 __gshared87 } ~ decl ~ ";");
88 } elseversion(dmd_osx) {
89 enumPyAPI_DATA = (q{90 extern(C)
91 extern92 __gshared93 } ~ decl ~ ";");
94 } else {
95 enumPyAPI_DATA = (q{96 extern(C)
97 extern98 export99 __gshared100 } ~ decl ~ ";");
101 }
102 }