From 14b9b110982fd7f00392b898230c4015bd2bdaaa Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 25 Jun 2013 00:37:25 +0200 Subject: [PATCH] If MS_WIN64 is defined, MS_WINDOWS is also defined: #ifdef can be simplified. --- Include/pyport.h | 2 +- Modules/_io/_iomodule.h | 2 +- Modules/_io/fileio.c | 14 +++++++------- Modules/posixmodule.c | 8 ++++---- Modules/socketmodule.c | 8 ++++---- Objects/fileobject.c | 2 +- Python/fileutils.c | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Include/pyport.h b/Include/pyport.h index f16cce9c496..acb6d5da710 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -263,7 +263,7 @@ typedef size_t Py_uhash_t; */ #ifdef HAVE_LONG_LONG # ifndef PY_FORMAT_LONG_LONG -# if defined(MS_WIN64) || defined(MS_WINDOWS) +# ifdef MS_WINDOWS # define PY_FORMAT_LONG_LONG "I64" # else # error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG" diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h index 0fe90a3b3b2..ad1faa8c46e 100644 --- a/Modules/_io/_iomodule.h +++ b/Modules/_io/_iomodule.h @@ -77,7 +77,7 @@ extern int _PyIO_trap_eintr(void); long with "%lld" even when both long and long long have the same precision. */ -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS /* Windows uses long long for offsets */ typedef PY_LONG_LONG Py_off_t; diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 34a58014a60..efcc594140b 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -533,7 +533,7 @@ fileio_readinto(fileio *self, PyObject *args) len = pbuf.len; Py_BEGIN_ALLOW_THREADS errno = 0; -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS if (len > INT_MAX) len = INT_MAX; n = read(self->fd, pbuf.buf, (int)len); @@ -602,7 +602,7 @@ fileio_readall(fileio *self) if (!_PyVerify_fd(self->fd)) return PyErr_SetFromErrno(PyExc_IOError); -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS pos = _lseeki64(self->fd, 0L, SEEK_CUR); #else pos = lseek(self->fd, 0L, SEEK_CUR); @@ -645,7 +645,7 @@ fileio_readall(fileio *self) Py_BEGIN_ALLOW_THREADS errno = 0; n = bufsize - bytes_read; -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS if (n > INT_MAX) n = INT_MAX; n = read(self->fd, PyBytes_AS_STRING(result) + bytes_read, (int)n); @@ -706,7 +706,7 @@ fileio_read(fileio *self, PyObject *args) return fileio_readall(self); } -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS if (size > INT_MAX) size = INT_MAX; #endif @@ -718,7 +718,7 @@ fileio_read(fileio *self, PyObject *args) if (_PyVerify_fd(self->fd)) { Py_BEGIN_ALLOW_THREADS errno = 0; -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS n = read(self->fd, ptr, (int)size); #else n = read(self->fd, ptr, size); @@ -766,7 +766,7 @@ fileio_write(fileio *self, PyObject *args) Py_BEGIN_ALLOW_THREADS errno = 0; len = pbuf.len; -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS if (len > 32767 && isatty(self->fd)) { /* Issue #11395: the Windows console returns an error (12: not enough space error) on writing into stdout if stdout mode is @@ -839,7 +839,7 @@ portable_lseek(int fd, PyObject *posobj, int whence) if (_PyVerify_fd(fd)) { Py_BEGIN_ALLOW_THREADS -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS res = _lseeki64(fd, pos, whence); #else res = lseek(fd, pos, whence); diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index baad29918b8..fd4628c7637 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -361,7 +361,7 @@ static int win32_can_symlink = 0; #undef STAT #undef FSTAT #undef STRUCT_STAT -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS # define STAT win32_stat # define LSTAT win32_lstat # define FSTAT win32_fstat @@ -7425,7 +7425,7 @@ static PyObject * posix_lseek(PyObject *self, PyObject *args) { int fd, how; -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS PY_LONG_LONG pos, res; #else off_t pos, res; @@ -7453,7 +7453,7 @@ posix_lseek(PyObject *self, PyObject *args) if (!_PyVerify_fd(fd)) return posix_error(); Py_BEGIN_ALLOW_THREADS -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS res = _lseeki64(fd, pos, how); #else res = lseek(fd, pos, how); @@ -7659,7 +7659,7 @@ posix_write(PyObject *self, PyObject *args) } len = pbuf.len; Py_BEGIN_ALLOW_THREADS -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS if (len > INT_MAX) len = INT_MAX; size = write(fd, pbuf.buf, (int)len); diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index bd0a20a2428..0fd14abe059 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -2553,7 +2553,7 @@ sock_recv_guts(PySocketSockObject *s, char* cbuf, Py_ssize_t len, int flags) Py_BEGIN_ALLOW_THREADS timeout = internal_select_ex(s, 0, interval); if (!timeout) { -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS if (len > INT_MAX) len = INT_MAX; outlen = recv(s->sock_fd, cbuf, (int)len, flags); @@ -3251,7 +3251,7 @@ sock_send(PySocketSockObject *s, PyObject *args) if (!timeout) { #ifdef __VMS n = sendsegmented(s->sock_fd, buf, len, flags); -#elif defined(MS_WIN64) || defined(MS_WINDOWS) +#elif defined(MS_WINDOWS) if (len > INT_MAX) len = INT_MAX; n = send(s->sock_fd, buf, (int)len, flags); @@ -3308,7 +3308,7 @@ sock_sendall(PySocketSockObject *s, PyObject *args) if (!timeout) { #ifdef __VMS n = sendsegmented(s->sock_fd, buf, len, flags); -#elif defined(MS_WIN64) || defined(MS_WINDOWS) +#elif defined(MS_WINDOWS) if (len > INT_MAX) len = INT_MAX; n = send(s->sock_fd, buf, (int)len, flags); @@ -3407,7 +3407,7 @@ sock_sendto(PySocketSockObject *s, PyObject *args) Py_BEGIN_ALLOW_THREADS timeout = internal_select_ex(s, 1, interval); if (!timeout) { -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS if (len > INT_MAX) len = INT_MAX; n = sendto(s->sock_fd, buf, (int)len, flags, diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 3a31314086f..e0c5bfef55f 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -390,7 +390,7 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args) Py_BEGIN_ALLOW_THREADS errno = 0; -#if defined(MS_WIN64) || defined(MS_WINDOWS) +#ifdef MS_WINDOWS if (n > INT_MAX) n = INT_MAX; n = write(self->fd, c, (int)n); diff --git a/Python/fileutils.c b/Python/fileutils.c index 293cb77f559..e75985655d7 100644 --- a/Python/fileutils.c +++ b/Python/fileutils.c @@ -16,13 +16,13 @@ extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size); PyObject * _Py_device_encoding(int fd) { -#if defined(MS_WINDOWS) || defined(MS_WIN64) +#if defined(MS_WINDOWS) UINT cp; #endif if (!_PyVerify_fd(fd) || !isatty(fd)) { Py_RETURN_NONE; } -#if defined(MS_WINDOWS) || defined(MS_WIN64) +#if defined(MS_WINDOWS) if (fd == 0) cp = GetConsoleCP(); else if (fd == 1 || fd == 2)