Skip to content

Commit c64bf4d

Browse files
author
amaury.forgeotdarc
committed
Restore support for Microsoft VC6 compiler.
Some functions in the msvcrt module are skipped, and socket.ioctl is enabled only when using a more recent Platform SDK. (and yes, there are still companies that use a 10-years old compiler) git-svn-id: http://svn.python.org/projects/python/trunk@64214 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 5dff0d7 commit c64bf4d

8 files changed

Lines changed: 35 additions & 26 deletions

File tree

Include/pythonrun.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
153153
to a 8k margin. */
154154
#define PYOS_STACK_MARGIN 2048
155155

156-
#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER)
156+
#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300
157157
/* Enable stack checking under Microsoft C */
158158
#define USE_STACKCHECK
159159
#endif

Modules/errnomodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/* Windows socket errors (WSA*) */
77
#ifdef MS_WINDOWS
8-
#include <winsock.h>
8+
#include <windows.h>
99
#endif
1010

1111
/*

Modules/socketmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,7 +2805,7 @@ PyDoc_STRVAR(shutdown_doc,
28052805
Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\
28062806
of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).");
28072807

2808-
#ifdef MS_WINDOWS
2808+
#if defined(MS_WINDOWS) && defined(SIO_RCVALL)
28092809
static PyObject*
28102810
sock_ioctl(PySocketSockObject *s, PyObject *arg)
28112811
{
@@ -2858,7 +2858,7 @@ static PyMethodDef sock_methods[] = {
28582858
METH_NOARGS, getsockname_doc},
28592859
{"getsockopt", (PyCFunction)sock_getsockopt, METH_VARARGS,
28602860
getsockopt_doc},
2861-
#ifdef MS_WINDOWS
2861+
#if defined(MS_WINDOWS) && defined(SIO_RCVALL)
28622862
{"ioctl", (PyCFunction)sock_ioctl, METH_VARARGS,
28632863
sock_ioctl_doc},
28642864
#endif

Modules/socketmodule.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@
1313
# endif
1414

1515
#else /* MS_WINDOWS */
16-
#if _MSC_VER >= 1300
1716
# include <winsock2.h>
1817
# include <ws2tcpip.h>
19-
# include <MSTcpIP.h> /* for SIO_RCVALL */
20-
# define HAVE_ADDRINFO
21-
# define HAVE_SOCKADDR_STORAGE
22-
# define HAVE_GETADDRINFO
23-
# define HAVE_GETNAMEINFO
24-
# define ENABLE_IPV6
25-
#else
26-
# include <winsock.h>
27-
#endif
28-
#endif
18+
/* VC6 is shipped with old platform headers, and does not have MSTcpIP.h
19+
* Separate SDKs have all the functions we want, but older ones don't have
20+
* any version information. I use IPPROTO_IPV6 to detect a decent SDK.
21+
*/
22+
# ifdef IPPROTO_IPV6
23+
# include <MSTcpIP.h> /* for SIO_RCVALL */
24+
# define HAVE_ADDRINFO
25+
# define HAVE_SOCKADDR_STORAGE
26+
# define HAVE_GETADDRINFO
27+
# define HAVE_GETNAMEINFO
28+
# define ENABLE_IPV6
29+
# else
30+
typedef int socklen_t;
31+
# endif /* IPPROTO_IPV6 */
32+
#endif /* MS_WINDOWS */
2933

3034
#ifdef HAVE_SYS_UN_H
3135
# include <sys/un.h>

PC/VC6/_socket.dsp

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PC/VC6/pythoncore.dsp

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PC/msvcrtmodule.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ msvcrt_getch(PyObject *self, PyObject *args)
143143
return PyString_FromStringAndSize(s, 1);
144144
}
145145

146+
#ifdef _WCONIO_DEFINED
146147
static PyObject *
147148
msvcrt_getwch(PyObject *self, PyObject *args)
148149
{
@@ -158,6 +159,7 @@ msvcrt_getwch(PyObject *self, PyObject *args)
158159
u[0] = ch;
159160
return PyUnicode_FromUnicode(u, 1);
160161
}
162+
#endif
161163

162164
static PyObject *
163165
msvcrt_getche(PyObject *self, PyObject *args)
@@ -175,6 +177,7 @@ msvcrt_getche(PyObject *self, PyObject *args)
175177
return PyString_FromStringAndSize(s, 1);
176178
}
177179

180+
#ifdef _WCONIO_DEFINED
178181
static PyObject *
179182
msvcrt_getwche(PyObject *self, PyObject *args)
180183
{
@@ -190,6 +193,7 @@ msvcrt_getwche(PyObject *self, PyObject *args)
190193
s[0] = ch;
191194
return PyUnicode_FromUnicode(s, 1);
192195
}
196+
#endif
193197

194198
static PyObject *
195199
msvcrt_putch(PyObject *self, PyObject *args)
@@ -204,7 +208,7 @@ msvcrt_putch(PyObject *self, PyObject *args)
204208
return Py_None;
205209
}
206210

207-
211+
#ifdef _WCONIO_DEFINED
208212
static PyObject *
209213
msvcrt_putwch(PyObject *self, PyObject *args)
210214
{
@@ -223,6 +227,7 @@ msvcrt_putwch(PyObject *self, PyObject *args)
223227
Py_RETURN_NONE;
224228

225229
}
230+
#endif
226231

227232
static PyObject *
228233
msvcrt_ungetch(PyObject *self, PyObject *args)
@@ -238,6 +243,7 @@ msvcrt_ungetch(PyObject *self, PyObject *args)
238243
return Py_None;
239244
}
240245

246+
#ifdef _WCONIO_DEFINED
241247
static PyObject *
242248
msvcrt_ungetwch(PyObject *self, PyObject *args)
243249
{
@@ -251,6 +257,7 @@ msvcrt_ungetwch(PyObject *self, PyObject *args)
251257
Py_INCREF(Py_None);
252258
return Py_None;
253259
}
260+
#endif
254261

255262
static void
256263
insertint(PyObject *d, char *name, int value)
@@ -279,11 +286,12 @@ static struct PyMethodDef msvcrt_functions[] = {
279286
{"getche", msvcrt_getche, METH_VARARGS},
280287
{"putch", msvcrt_putch, METH_VARARGS},
281288
{"ungetch", msvcrt_ungetch, METH_VARARGS},
289+
#ifdef _WCONIO_DEFINED
282290
{"getwch", msvcrt_getwch, METH_VARARGS},
283291
{"getwche", msvcrt_getwche, METH_VARARGS},
284292
{"putwch", msvcrt_putwch, METH_VARARGS},
285293
{"ungetwch", msvcrt_ungetwch, METH_VARARGS},
286-
294+
#endif
287295
{NULL, NULL}
288296
};
289297

PC/pyconfig.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,13 +467,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
467467
/* Define to `unsigned' if <sys/types.h> doesn't define. */
468468
/* #undef size_t */
469469

470-
/* Define to `int' if <sys/types.h> doesn't define. */
471-
#if _MSC_VER + 0 >= 1300
472-
/* VC.NET typedefs socklen_t in ws2tcpip.h. */
473-
#else
474-
#define socklen_t int
475-
#endif
476-
477470
/* Define if you have the ANSI C header files. */
478471
#define STDC_HEADERS 1
479472

0 commit comments

Comments
 (0)