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

Delta Between Two Patch Sets: Include/pyport.h

Issue 3871: cross and native build of python for mingw32 with distutils
Left Patch Set: Created 9 years, 6 months ago
Right 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:
Right: Side by side diff | Download
« no previous file with change/comment | « Include/pymath.h ('k') | Include/pythonrun.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 #ifndef Py_PYPORT_H 1 #ifndef Py_PYPORT_H
2 #define Py_PYPORT_H 2 #define Py_PYPORT_H
3 3
4 #include "pyconfig.h" /* include for defines */ 4 #include "pyconfig.h" /* include for defines */
5 5
6 /* Some versions of HP-UX & Solaris need inttypes.h for int32_t, 6 /* Some versions of HP-UX & Solaris need inttypes.h for int32_t,
7 INT32_MAX, etc. */ 7 INT32_MAX, etc. */
8 #ifdef HAVE_INTTYPES_H 8 #ifdef HAVE_INTTYPES_H
9 #include <inttypes.h> 9 #include <inttypes.h>
10 #endif 10 #endif
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 #if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) 670 #if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H)
671 /* BSDI does not supply a prototype for the 'openpty' and 'forkpty' 671 /* BSDI does not supply a prototype for the 'openpty' and 'forkpty'
672 functions, even though they are included in libutil. */ 672 functions, even though they are included in libutil. */
673 #include <termios.h> 673 #include <termios.h>
674 extern int openpty(int *, int *, char *, struct termios *, struct winsize *); 674 extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
675 extern pid_t forkpty(int *, char *, struct termios *, struct winsize *); 675 extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
676 #endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */ 676 #endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */
677 #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ 677 #endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
678 678
679 679
680 #ifdef __MINGW32__
681 /* FIXME: some of next definitions specific to gcc(mingw build) can be
682 generalized on definitions of _WIN32 or WIN32 and to be common for
683 all windows build instead explicitly to define only for non-autotools
684 based builds (see PC/pyconfig.h for details). */
685 #if defined(_WIN64)
686 # define MS_WIN64
687 #endif
688 #if !defined(MS_WIN32) && defined(_WIN32)
689 # define MS_WIN32
690 #endif
691 #if !defined(MS_WIN32) && defined(_WIN32)
692 # define MS_WIN32
693 #endif
694 #if !defined(MS_WINDOWS) && defined(MS_WIN32)
695 # define MS_WINDOWS
696 #endif
697
698 #ifndef PYTHONPATH
699 # define PYTHONPATH L".\\DLLs;.\\lib"
700 #endif
701
702 /* python 2.6+ requires Windows 2000 or greater. */
703 #define Py_WINVER 0x0500
704
705 #if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE)
706 /* FIXME if NTDDI_xxx is in use by mingw (see PC/pyconfig.h) */
707 #ifndef WINVER
708 # define WINVER Py_WINVER
709 #endif
710 #ifndef _WIN32_WINNT
711 # define _WIN32_WINNT Py_WINVER
712 #endif
713 #endif
714
715 #ifdef PLATFORM
716 /*NOTE: if compile getplatform.c PLATFORM is set to MACHDEP that is
717 "win" for mingw build (see respective comment in configure.in). */
718 # undef PLATFORM
719 #endif
720 /* always set to "win32" - see PC/pyconfig.h */
721 #define PLATFORM "win32"
722
723 #if defined(MS_WIN64)
724 # define SIZEOF_HKEY 8
725 #elif defined(MS_WIN32)
726 # define SIZEOF_HKEY 4
727 #endif
728
729 /*NOTE: mingw has isinf as macro defined in math.h.
730 Since PC/pyconfig.h define Py_IS_INFINITY(X) that cover HAVE_DECL_ISFINITE
731 here for Py_IS_INFINITY we define same as for MSVC build.
732 This makes HAVE_DECL_ISFINITE needless.
733 Also see commants in configure.in and pymath.h. */
734 #define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
735
736 #ifndef HAVE_LARGEFILE_SUPPORT
737 /*
738 FIXME: on windows platforms:
739 - Python use PY_LONG_LONG(!) for Py_off_t (_fileio.c);
740 - HAVE_LARGEFILE_SUPPORT is defined in PC/pyconfig.h;
741 - PC/pyconfig.h define 4 for SIZEOF_OFF_T and 8 for SIZEOF_FPOS_T;
742 - If HAVE_LARGEFILE_SUPPORT isn't defined python will use off_t(!)
743 for Py_off_t (see fileobjects.c and bz2module.c).
744 Since for mingw configure detect 4 for size of "off_t" and 8 - for
745 "fpos_t" we has to define HAVE_LARGEFILE_SUPPORT too.
746 TODO: to test with AC_SYS_LARGEFILE and appropriate updates in
747 python code.
748 */
749 # define HAVE_LARGEFILE_SUPPORT
750 #endif
751
752 #if defined(Py_ENABLE_SHARED)
753 # define MS_COREDLL 1 /* deprecated old symbol, but still in use for windows co de */
754 #else
755 # define MS_NO_COREDLL 1
756 #endif
757
758 #if Py_UNICODE_SIZE == 2
759 /* For mingw is 2 but FIXME: What about to raise error in configure if
760 unicode size isn't two ? Did python windows code support ucs4 ? */
761 # define Py_WIN_WIDE_FILENAMES
762 #endif
763
764 /* NOTE: Don't define HAVE_STDDEF_H.
765 * It is defined by PC/pyconfig.h and used by Include/Python.h
766 * (with comment For size_t?) but isn't required for mingw */
767
768 #if 0
769 /* Obsolete:
770 * Author: Charles-Fran├žois Natali <neologix@free.fr>
771 * Date: Sun Aug 28 17:51:43 2011 +0200
772 * NOTE: still defined in PC/pyconfig.h ;)
773 */
774 #define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
775 #endif
776
777 /* All other defines from PC/pyconfig.h are in autoconf generated
778 pyconfig.h */
779 #if 0
780 /*FIXME:
781 MSDN:
782 "The getaddrinfo function was added to the ws2_32.dll on Windows XP
783 and later."
784 mingw:
785 getaddrinfo and getnameinfo is defined for WINVER >= 0x0501.
786 PC/pyconfig.h:
787 "Python 2.6+ requires Windows 2000 or greater"
788 So far so good but socketmodule.h define HAVE_GETADDRINFO and
789 HAVE_GETNAMEINFO under very specific condition :
790 # ifdef SIO_GET_MULTICAST_FILTER
791 # include <MSTcpIP.h>
792 So the question is "Separate SDKs" required for w2k in MSVC build ?
793 TODO: resolve later, may by configure :-/. For now python code will
794 use fake implementation and if user define appropriate value for
795 WINVER - the functionas from C runtime.
796 For details see socketmodule.c .
797 */
798 #ifndef HAVE_GETADDRINFO
799 # define HAVE_GETADDRINFO
800 #endif
801 #ifndef HAVE_GETNAMEINFO
802 # define HAVE_GETNAMEINFO
803 #endif
804 #endif
805
806 /* Refer to <Modules/_math.h> .
807 For mingw host configure detect functions described as HAVE_XXX
808 in _math.h but as MSVC don't define them we will undefine HAVE_XXX
809 too to use _Py_* replacements same as MSVC build .
810 */
811 #undef HAVE_ACOSH
812 #undef HAVE_ASINH
813 #undef HAVE_ATANH
814 #undef HAVE_EXPM1
815 #undef HAVE_LOG1P
816
817 /* Refer to <PC/pyconfig.h> .
818 Side by Side assemblies are not supported by default in MSVC CRT 10 .
819 */
820 #if __MSVCRT_VERSION__ >= 0x0800 && __MSVCRT_VERSION__ < 0x1000
821 #define HAVE_SXS 1
822 #endif
823
824 #endif /*def __MINGW32__*/
825
680 /* On 4.4BSD-descendants, ctype functions serves the whole range of 826 /* On 4.4BSD-descendants, ctype functions serves the whole range of
681 * wchar_t character set rather than single byte code points only. 827 * wchar_t character set rather than single byte code points only.
682 * This characteristic can break some operations of string object 828 * This characteristic can break some operations of string object
683 * including str.upper() and str.split() on UTF-8 locales. This 829 * including str.upper() and str.split() on UTF-8 locales. This
684 * workaround was provided by Tim Robbins of FreeBSD project. 830 * workaround was provided by Tim Robbins of FreeBSD project.
685 */ 831 */
686 832
687 #ifdef __FreeBSD__ 833 #ifdef __FreeBSD__
688 #include <osreldate.h> 834 #include <osreldate.h>
689 #if __FreeBSD_version > 500039 835 #if __FreeBSD_version > 500039
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 PyMODINIT_FUNC: A Python module init function. If these functions are 869 PyMODINIT_FUNC: A Python module init function. If these functions are
724 inside the Python core, they are private to the core. 870 inside the Python core, they are private to the core.
725 If in an extension module, it may be declared with 871 If in an extension module, it may be declared with
726 external linkage depending on the platform. 872 external linkage depending on the platform.
727 873
728 As a number of platforms support/require "__declspec(dllimport/dllexport)", 874 As a number of platforms support/require "__declspec(dllimport/dllexport)",
729 we support a HAVE_DECLSPEC_DLL macro to save duplication. 875 we support a HAVE_DECLSPEC_DLL macro to save duplication.
730 */ 876 */
731 877
732 /* 878 /*
733 All windows ports, except cygwin, are handled in PC/pyconfig.h. 879 MSVC windows port is handled in PC/pyconfig.h.
734 880
735 Cygwin is the only other autoconf platform requiring special 881 Cygwin and Mingw are autoconf platforms requiring special
736 linkage handling and it uses __declspec(). 882 linkage handling and it uses __declspec().
737 */ 883 */
738 #if defined(__CYGWIN__) 884 #if defined(__CYGWIN__) || defined(__MINGW32__)
739 # define HAVE_DECLSPEC_DLL 885 # define HAVE_DECLSPEC_DLL
740 #endif 886 #endif
741 887
742 /* only get special linkage if built as shared or platform is Cygwin */ 888 /* only get special linkage if built as shared or platform is Cygwin */
743 #if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) 889 #if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
744 # if defined(HAVE_DECLSPEC_DLL) 890 # if defined(HAVE_DECLSPEC_DLL)
745 # ifdef Py_BUILD_CORE 891 # ifdef Py_BUILD_CORE
746 # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE 892 # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
747 # define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RT YPE 893 # define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RT YPE
748 /* module init functions inside the core need no external linkage */ 894 /* module init functions inside the core need no external linkage */
749 /* except for Cygwin to handle embedding */ 895 /* except for Cygwin to handle embedding */
750 # if defined(__CYGWIN__) 896 # if defined(__CYGWIN__)
751 # define PyMODINIT_FUNC __declspec(dllexport) PyOb ject* 897 # define PyMODINIT_FUNC __declspec(dllexport) PyOb ject*
752 # else /* __CYGWIN__ */ 898 # else /* __CYGWIN__ */
753 # define PyMODINIT_FUNC PyObject* 899 # define PyMODINIT_FUNC PyObject*
754 # endif /* __CYGWIN__ */ 900 # endif /* __CYGWIN__ */
755 # else /* Py_BUILD_CORE */ 901 # else /* Py_BUILD_CORE */
756 /* Building an extension module, or an embedded situation */ 902 /* Building an extension module, or an embedded situation */
757 /* public Python functions and data are imported */ 903 /* public Python functions and data are imported */
758 /* Under Cygwin, auto-import functions to prevent compilation */ 904 /* Under Cygwin, auto-import functions to prevent compilation */
759 /* failures similar to those described at the bottom of 4.1: */ 905 /* failures similar to those described at the bottom of 4.1: */
760 /* http://docs.python.org/extending/windows.html#a-cookbook-approach */ 906 /* http://docs.python.org/extending/windows.html#a-cookbook-approach */
761 # if !defined(__CYGWIN__) 907 # if !defined(__CYGWIN__) && !defined(__MINGW32__)
762 # define PyAPI_FUNC(RTYPE) __declspec(dllimport) R TYPE 908 # define PyAPI_FUNC(RTYPE) __declspec(dllimport) R TYPE
763 # endif /* !__CYGWIN__ */ 909 # else
910 # define PyAPI_FUNC(RTYPE) RTYPE
911 # endif /* !__CYGWIN__ !__MINGW32__ */
912 /* NOTE: The issue3945 "compile error in _fileio.c (cygwin)"
913 * was resolved with modification of code.
914 * This issue was resolved for gcc(mingw) with enabling auto
915 * import feature. Since _fileio.c problem now disappear there
916 * is no more reasons to avoid dllimport for gcc(mingw).
917 */
764 # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RT YPE 918 # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RT YPE
765 /* module init functions outside the core must be exported */ 919 /* module init functions outside the core must be exported */
766 # if defined(__cplusplus) 920 # if defined(__cplusplus)
767 # define PyMODINIT_FUNC extern "C" __declspec(dlle xport) PyObject* 921 # define PyMODINIT_FUNC extern "C" __declspec(dlle xport) PyObject*
768 # else /* __cplusplus */ 922 # else /* __cplusplus */
769 # define PyMODINIT_FUNC __declspec(dllexport) PyOb ject* 923 # define PyMODINIT_FUNC __declspec(dllexport) PyOb ject*
770 # endif /* __cplusplus */ 924 # endif /* __cplusplus */
771 # endif /* Py_BUILD_CORE */ 925 # endif /* Py_BUILD_CORE */
772 # endif /* HAVE_DECLSPEC */ 926 # endif /* HAVE_DECLSPEC */
773 #endif /* Py_ENABLE_SHARED */ 927 #endif /* Py_ENABLE_SHARED */
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 #define Py_VA_COPY(x, y) Py_MEMCPY((x), (y), sizeof(va_list)) 1029 #define Py_VA_COPY(x, y) Py_MEMCPY((x), (y), sizeof(va_list))
876 #else 1030 #else
877 #ifdef __va_copy 1031 #ifdef __va_copy
878 #define Py_VA_COPY __va_copy 1032 #define Py_VA_COPY __va_copy
879 #else 1033 #else
880 #define Py_VA_COPY(x, y) (x) = (y) 1034 #define Py_VA_COPY(x, y) (x) = (y)
881 #endif 1035 #endif
882 #endif 1036 #endif
883 1037
884 #endif /* Py_PYPORT_H */ 1038 #endif /* Py_PYPORT_H */
LEFTRIGHT

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