Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Side by Side Diff: PC/msvcrtmodule.c

Issue 3871: cross and native build of python for mingw32 with distutils
Patch Set: Created 7 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « PC/getpathp.c ('k') | PC/pyconfig.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /********************************************************* 1 /*********************************************************
2 2
3 msvcrtmodule.c 3 msvcrtmodule.c
4 4
5 A Python interface to the Microsoft Visual C Runtime 5 A Python interface to the Microsoft Visual C Runtime
6 Library, providing access to those non-portable, but 6 Library, providing access to those non-portable, but
7 still useful routines. 7 still useful routines.
8 8
9 Only ever compiled with an MS compiler, so no attempt 9 Only ever compiled with an MS compiler, so no attempt
10 has been made to avoid MS language extensions, etc... 10 has been made to avoid MS language extensions, etc...
11 11
12 This may only work on NT or 95... 12 This may only work on NT or 95...
13 13
14 Author: Mark Hammond and Guido van Rossum. 14 Author: Mark Hammond and Guido van Rossum.
15 Maintenance: Guido van Rossum. 15 Maintenance: Guido van Rossum.
16 16
17 ***********************************************************/ 17 ***********************************************************/
18 18
19 #include "Python.h" 19 #include "Python.h"
20 #include "malloc.h" 20 #include "malloc.h"
21 #include <io.h> 21 #include <io.h>
22 #include <conio.h> 22 #include <conio.h>
23 #include <sys/locking.h> 23 #include <sys/locking.h>
24 #ifdef _MSC_VER
25 # define HAVE_CRTDBG_H
26 #endif
27 #ifdef HAVE_CRTDBG_H
24 #include <crtdbg.h> 28 #include <crtdbg.h>
29 #endif
25 #include <windows.h> 30 #include <windows.h>
31
32 #if defined(__MINGW32__)
33 #if __MSVCRT_VERSION__ >= 0x0700
34 # define _WCONIO_DEFINED
35 /* NOTE: Up to version ?.?? mingw don't define functions
36 * listed below. Also this require module to be linked with
37 * ms-vcrt at least verion 7.
38 * To build with different runtimes see:
39 * http://www.mingw.org/wiki/HOWTO_Use_the_GCC_specs_file
40 *
41 * Also note that NT5.1(XP), shiped with msvcrt version 7.0,
42 * contain all those functions, but library name is msvcrt.dll.
43 * So if you like module to run on w2k as is you must define
44 * appropriate __MSVCRT_VERSION__ .
45 * If you like those functions even on w2k you must link
46 * with appropriate runtime and to pack it in distributions.
47 * This is what MSVC build do - it is build and packed
48 * with version 9.0 of Microsoft C-runtime.
49 */
50 _CRTIMP wint_t __cdecl __MINGW_NOTHROW _getwch (void);
51 _CRTIMP wint_t __cdecl __MINGW_NOTHROW _getwche (void);
52 _CRTIMP wint_t __cdecl __MINGW_NOTHROW _putwch (wchar_t);
53 _CRTIMP wint_t __cdecl __MINGW_NOTHROW _ungetwch(wint_t);
54 #endif /* __MSVCRT_VERSION__ >= 0x0700 */
55 #endif
26 56
27 #ifdef _MSC_VER 57 #ifdef _MSC_VER
28 #if _MSC_VER >= 1500 && _MSC_VER < 1600 58 #if _MSC_VER >= 1500 && _MSC_VER < 1600
29 #include <crtassem.h> 59 #include <crtassem.h>
30 #elif _MSC_VER >= 1600 60 #elif _MSC_VER >= 1600
31 #include <crtversion.h> 61 #include <crtversion.h>
32 #endif 62 #endif
33 #endif 63 #endif
34 64
35 // Force the malloc heap to clean itself up, and free unused blocks 65 // Force the malloc heap to clean itself up, and free unused blocks
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 #endif 342 #endif
313 343
314 static PyObject * 344 static PyObject *
315 msvcrt_ungetch(PyObject *self, PyObject *args) 345 msvcrt_ungetch(PyObject *self, PyObject *args)
316 { 346 {
317 char ch; 347 char ch;
318 348
319 if (!PyArg_ParseTuple(args, "c:ungetch", &ch)) 349 if (!PyArg_ParseTuple(args, "c:ungetch", &ch))
320 return NULL; 350 return NULL;
321 351
352 /* FIXME: why _ungetch is called instead _ungetwch */
322 if (_ungetch(ch) == EOF) 353 if (_ungetch(ch) == EOF)
323 return PyErr_SetFromErrno(PyExc_IOError); 354 return PyErr_SetFromErrno(PyExc_IOError);
324 Py_INCREF(Py_None); 355 Py_INCREF(Py_None);
325 return Py_None; 356 return Py_None;
326 } 357 }
327 358
328 PyDoc_STRVAR(ungetch_doc, 359 PyDoc_STRVAR(ungetch_doc,
329 "ungetch(char) -> None\n\ 360 "ungetch(char) -> None\n\
330 \n\ 361 \n\
331 Cause the byte string char to be \"pushed back\" into the\n\ 362 Cause the byte string char to be \"pushed back\" into the\n\
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 version = PyUnicode_FromFormat("%d.%d.%d.%d", _VC_CRT_MAJOR_VERSION, 549 version = PyUnicode_FromFormat("%d.%d.%d.%d", _VC_CRT_MAJOR_VERSION,
519 _VC_CRT_MINOR_VERSION, 550 _VC_CRT_MINOR_VERSION,
520 _VC_CRT_BUILD_VERSION, 551 _VC_CRT_BUILD_VERSION,
521 _VC_CRT_RBUILD_VERSION); 552 _VC_CRT_RBUILD_VERSION);
522 st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version); 553 st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version);
523 if (st < 0) return NULL; 554 if (st < 0) return NULL;
524 #endif 555 #endif
525 556
526 return m; 557 return m;
527 } 558 }
OLDNEW
« no previous file with comments | « PC/getpathp.c ('k') | PC/pyconfig.h » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+