Win32: Drop support for older than MSVC 8.0/_MSC_VER 1400

Visual C++ 2005 (8.0):
- _MSC_VER: 1400
- MSVCRT_VERSION: 80
This commit is contained in:
Nobuyoshi Nakada 2024-12-09 14:56:58 +09:00 committed by Nobuyoshi Nakada
parent 1979f8c07d
commit cdb9893c55
Notes: git 2025-11-19 02:04:20 +00:00
16 changed files with 50 additions and 315 deletions

View File

@ -526,6 +526,7 @@ AS_CASE(["$target_os"],
RT_VER=`echo "$rb_cv_msvcrt" | tr -cd [0-9]`
test "$RT_VER" = "" && RT_VER=60
test "$rb_cv_msvcrt" = "ucrt" && RT_VER=140
AS_IF([test $RT_VER -lt 80], AC_MSG_ERROR(Runtime library $RT_VER is not supported))
AC_DEFINE_UNQUOTED(RUBY_MSVCRT_VERSION, $RT_VER)
sysconfdir=
])

View File

@ -168,9 +168,7 @@ ruby_debug_breakpoint(void)
}
#if defined _WIN32
# if RUBY_MSVCRT_VERSION >= 80
extern int ruby_w32_rtc_error;
# endif
#endif
#if defined _WIN32 || defined __CYGWIN__
#include <windows.h>
@ -233,9 +231,7 @@ ruby_env_debug_option(const char *str, int len, void *arg)
SET_WHEN("ci", ruby_on_ci, 1);
SET_WHEN_UINT("rgengc", &ruby_rgengc_debug, 1, ruby_rgengc_debug = 1);
#if defined _WIN32
# if RUBY_MSVCRT_VERSION >= 80
SET_WHEN("rtc_error", ruby_w32_rtc_error, 1);
# endif
#endif
#if defined _WIN32 || defined __CYGWIN__
SET_WHEN_UINT("codepage", ruby_w32_codepage, numberof(ruby_w32_codepage),

View File

@ -1076,7 +1076,7 @@ NORETURN(static void die(void));
static void
die(void)
{
#if defined(_WIN32) && defined(RUBY_MSVCRT_VERSION) && RUBY_MSVCRT_VERSION >= 80
#if defined(_WIN32)
_set_abort_behavior( 0, _CALL_REPORTFAULT);
#endif

View File

@ -62,9 +62,6 @@
#endif
#include <unistd.h>
#else
#if defined(_MSC_VER) && _MSC_VER <= 1200
#include <windows.h>
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <io.h>

View File

@ -55,9 +55,6 @@
#endif
#endif
#ifdef _WIN32
#if defined(_MSC_VER) && _MSC_VER <= 1200
#include <windows.h>
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#define snprintf _snprintf

View File

@ -38,19 +38,8 @@
# define RBIMPL_COMPILER_VERSION_MINOR (_MSC_FULL_VER % 10000000 / 100000)
# define RBIMPL_COMPILER_VERSION_PATCH (_MSC_FULL_VER % 100000)
#elif defined(_MSC_FULL_VER)
# define RBIMPL_COMPILER_IS_MSVC 1
# /* _MSC_FULL_VER = XXYYZZZZ */
# define RBIMPL_COMPILER_VERSION_MAJOR (_MSC_FULL_VER / 1000000)
# define RBIMPL_COMPILER_VERSION_MINOR (_MSC_FULL_VER % 1000000 / 10000)
# define RBIMPL_COMPILER_VERSION_PATCH (_MSC_FULL_VER % 10000)
#else
# define RBIMPL_COMPILER_IS_MSVC 1
# /* _MSC_VER = XXYY */
# define RBIMPL_COMPILER_VERSION_MAJOR (_MSC_VER / 100)
# define RBIMPL_COMPILER_VERSION_MINOR (_MSC_VER % 100)
# define RBIMPL_COMPILER_VERSION_PATCH 0
# error Unsupported MSVC version
#endif
#endif /* RBIMPL_COMPILER_IS_MSVC_H */

View File

@ -30,15 +30,10 @@ extern "C++" { /* template without extern "C++" */
#if !defined(_WIN64) && !defined(WIN32)
#define WIN32
#endif
#if defined(_MSC_VER) && _MSC_VER <= 1200
#include <windows.h>
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <mswsock.h>
#if !defined(_MSC_VER) || _MSC_VER >= 1400
#include <iphlpapi.h>
#endif
#if defined(__cplusplus) && defined(_MSC_VER)
}
#endif
@ -59,13 +54,7 @@ extern "C++" { /* template without extern "C++" */
#include <direct.h>
#include <process.h>
#include <time.h>
#if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
extern "C++" { /* template without extern "C++" */
#endif
#include <math.h>
#if defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER == 1200
}
#endif
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -436,7 +425,7 @@ extern int rb_w32_utruncate(const char *path, rb_off_t length);
#define HAVE_TRUNCATE 1
#define truncate rb_w32_utruncate
#if defined(_MSC_VER) && _MSC_VER >= 1400 && _MSC_VER < 1800
#if defined(_MSC_VER) && _MSC_VER < 1800
#define strtoll _strtoi64
#define strtoull _strtoui64
#endif

View File

@ -30,13 +30,13 @@
#include <stdint.h> /* for uintptr_t */
#include "internal/compilers.h" /* for MSC_VERSION_SINCE */
#if MSC_VERSION_SINCE(1310)
#ifdef _MSC_VER
# include <stdlib.h> /* for _byteswap_uint64 */
#endif
#if defined(HAVE_X86INTRIN_H)
# include <x86intrin.h> /* for _lzcnt_u64 */
#elif MSC_VERSION_SINCE(1310)
#elif defined(_MSC_VER)
# include <intrin.h> /* for the following intrinsics */
#endif
@ -50,16 +50,13 @@
# pragma intrinsic(__lzcnt64)
#endif
#if MSC_VERSION_SINCE(1310)
#if defined(_MSC_VER)
# pragma intrinsic(_rotl)
# pragma intrinsic(_rotr)
# ifdef _WIN64
# pragma intrinsic(_rotl64)
# pragma intrinsic(_rotr64)
# endif
#endif
#if MSC_VERSION_SINCE(1400)
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanReverse)
# ifdef _WIN64
@ -266,7 +263,7 @@ ruby_swap16(uint16_t x)
#if __has_builtin(__builtin_bswap16)
return __builtin_bswap16(x);
#elif MSC_VERSION_SINCE(1310)
#elif defined(_MSC_VER)
return _byteswap_ushort(x);
#else
@ -281,7 +278,7 @@ ruby_swap32(uint32_t x)
#if __has_builtin(__builtin_bswap32)
return __builtin_bswap32(x);
#elif MSC_VERSION_SINCE(1310)
#elif defined(_MSC_VER)
return _byteswap_ulong(x);
#else
@ -298,7 +295,7 @@ ruby_swap64(uint64_t x)
#if __has_builtin(__builtin_bswap64)
return __builtin_bswap64(x);
#elif MSC_VERSION_SINCE(1310)
#elif defined(_MSC_VER)
return _byteswap_uint64(x);
#else
@ -323,7 +320,7 @@ nlz_int32(uint32_t x)
#elif defined(__x86_64__) && defined(__LZCNT__)
return (unsigned int)_lzcnt_u32(x);
#elif MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
#elif defined(_MSC_VER) /* &&! defined(__AVX2__) */
unsigned long r;
return _BitScanReverse(&r, x) ? (31 - (int)r) : 32;
@ -352,7 +349,7 @@ nlz_int64(uint64_t x)
#elif defined(__x86_64__) && defined(__LZCNT__)
return (unsigned int)_lzcnt_u64(x);
#elif defined(_WIN64) && MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
#elif defined(_WIN64) && defined(_MSC_VER) /* &&! defined(__AVX2__) */
unsigned long r;
return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64;
@ -538,7 +535,7 @@ ntz_int32(uint32_t x)
#if defined(__x86_64__) && defined(__BMI__)
return (unsigned)_tzcnt_u32(x);
#elif MSC_VERSION_SINCE(1400)
#elif defined(_MSC_VER)
/* :FIXME: Is there any way to issue TZCNT instead of BSF, apart from using
* assembly? Because issuing LZCNT seems possible (see nlz.h). */
unsigned long r;
@ -559,8 +556,8 @@ ntz_int64(uint64_t x)
{
#if defined(__x86_64__) && defined(__BMI__)
return (unsigned)_tzcnt_u64(x);
#elif defined(_WIN64) && MSC_VERSION_SINCE(1400)
`
#elif defined(_WIN64) && defined(_MSC_VER)
unsigned long r;
return _BitScanForward64(&r, x) ? (int)r : 64;
@ -608,10 +605,10 @@ RUBY_BIT_ROTL(VALUE v, int n)
#elif __has_builtin(__builtin_rotateleft64) && (SIZEOF_VALUE * CHAR_BIT == 64)
return __builtin_rotateleft64(v, n);
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 32)
#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 32)
return _rotl(v, n);
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 64)
#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 64)
return _rotl64(v, n);
#elif defined(_lrotl) && (SIZEOF_VALUE == SIZEOF_LONG)
@ -632,10 +629,10 @@ RUBY_BIT_ROTR(VALUE v, int n)
#elif __has_builtin(__builtin_rotateright64) && (SIZEOF_VALUE * CHAR_BIT == 64)
return __builtin_rotateright64(v, n);
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 32)
#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 32)
return _rotr(v, n);
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 64)
#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 64)
return _rotr64(v, n);
#elif defined(_lrotr) && (SIZEOF_VALUE == SIZEOF_LONG)

View File

@ -1591,17 +1591,11 @@ rb_float_equal(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
if (isnan(b)) return Qfalse;
#endif
}
else {
return num_equal(x, y);
}
a = RFLOAT_VALUE(x);
#if MSC_VERSION_BEFORE(1300)
if (isnan(a)) return Qfalse;
#endif
return RBOOL(a == b);
}
@ -1734,16 +1728,10 @@ rb_float_gt(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
if (isnan(b)) return Qfalse;
#endif
}
else {
return rb_num_coerce_relop(x, y, '>');
}
#if MSC_VERSION_BEFORE(1300)
if (isnan(a)) return Qfalse;
#endif
return RBOOL(a > b);
}
@ -1777,16 +1765,10 @@ flo_ge(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
if (isnan(b)) return Qfalse;
#endif
}
else {
return rb_num_coerce_relop(x, y, idGE);
}
#if MSC_VERSION_BEFORE(1300)
if (isnan(a)) return Qfalse;
#endif
return RBOOL(a >= b);
}
@ -1819,16 +1801,10 @@ flo_lt(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
if (isnan(b)) return Qfalse;
#endif
}
else {
return rb_num_coerce_relop(x, y, '<');
}
#if MSC_VERSION_BEFORE(1300)
if (isnan(a)) return Qfalse;
#endif
return RBOOL(a < b);
}
@ -1862,16 +1838,10 @@ flo_le(VALUE x, VALUE y)
}
else if (RB_FLOAT_TYPE_P(y)) {
b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
if (isnan(b)) return Qfalse;
#endif
}
else {
return rb_num_coerce_relop(x, y, idLE);
}
#if MSC_VERSION_BEFORE(1300)
if (isnan(a)) return Qfalse;
#endif
return RBOOL(a <= b);
}
@ -1899,10 +1869,7 @@ rb_float_eql(VALUE x, VALUE y)
if (RB_FLOAT_TYPE_P(y)) {
double a = RFLOAT_VALUE(x);
double b = RFLOAT_VALUE(y);
#if MSC_VERSION_BEFORE(1300)
if (isnan(a) || isnan(b)) return Qfalse;
#endif
return RBOOL(a == b);
return RBOOL(a == b);
}
return Qfalse;
}

View File

@ -30,13 +30,13 @@
#include <stdint.h> /* for uintptr_t */
#include "internal/compilers.h" /* for MSC_VERSION_SINCE */
#if MSC_VERSION_SINCE(1310)
#if defined(_MSC_VER)
# include <stdlib.h> /* for _byteswap_uint64 */
#endif
#if defined(HAVE_X86INTRIN_H)
# include <x86intrin.h> /* for _lzcnt_u64 */
#elif MSC_VERSION_SINCE(1310)
#elif defined(_MSC_VER)
# include <intrin.h> /* for the following intrinsics */
#endif
@ -50,7 +50,7 @@
# pragma intrinsic(__lzcnt64)
#endif
#if MSC_VERSION_SINCE(1310)
#if defined(_MSC_VER)
# pragma intrinsic(_rotl)
# pragma intrinsic(_rotr)
# ifdef _WIN64
@ -59,7 +59,7 @@
# endif
#endif
#if MSC_VERSION_SINCE(1400)
#if defined(_MSC_VER)
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanReverse)
# ifdef _WIN64
@ -180,7 +180,7 @@ ruby_swap16(uint16_t x)
#if __has_builtin(__builtin_bswap16)
return __builtin_bswap16(x);
#elif MSC_VERSION_SINCE(1310)
#elif defined(_MSC_VER)
return _byteswap_ushort(x);
#else
@ -195,7 +195,7 @@ ruby_swap32(uint32_t x)
#if __has_builtin(__builtin_bswap32)
return __builtin_bswap32(x);
#elif MSC_VERSION_SINCE(1310)
#elif defined(_MSC_VER)
return _byteswap_ulong(x);
#else
@ -212,7 +212,7 @@ ruby_swap64(uint64_t x)
#if __has_builtin(__builtin_bswap64)
return __builtin_bswap64(x);
#elif MSC_VERSION_SINCE(1310)
#elif defined(_MSC_VER)
return _byteswap_uint64(x);
#else
@ -237,7 +237,7 @@ nlz_int32(uint32_t x)
#elif defined(__x86_64__) && defined(__LZCNT__)
return (unsigned int)_lzcnt_u32(x);
#elif MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
#elif defined(_MSC_VER) /* &&! defined(__AVX2__) */
unsigned long r;
return _BitScanReverse(&r, x) ? (31 - (int)r) : 32;
@ -266,7 +266,7 @@ nlz_int64(uint64_t x)
#elif defined(__x86_64__) && defined(__LZCNT__)
return (unsigned int)_lzcnt_u64(x);
#elif defined(_WIN64) && MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
#elif defined(_WIN64) && defined(_MSC_VER) /* &&! defined(__AVX2__) */
unsigned long r;
return _BitScanReverse64(&r, x) ? (63u - (unsigned int)r) : 64;
@ -452,7 +452,7 @@ ntz_int32(uint32_t x)
#if defined(__x86_64__) && defined(__BMI__)
return (unsigned)_tzcnt_u32(x);
#elif MSC_VERSION_SINCE(1400)
#elif defined(_MSC_VER)
/* :FIXME: Is there any way to issue TZCNT instead of BSF, apart from using
* assembly? Because issuing LZCNT seems possible (see nlz.h). */
unsigned long r;
@ -474,7 +474,7 @@ ntz_int64(uint64_t x)
#if defined(__x86_64__) && defined(__BMI__)
return (unsigned)_tzcnt_u64(x);
#elif defined(_WIN64) && MSC_VERSION_SINCE(1400)
#elif defined(_WIN64) && defined(_MSC_VER)
unsigned long r;
return _BitScanForward64(&r, x) ? (int)r : 64;
@ -522,10 +522,10 @@ RUBY_BIT_ROTL(VALUE v, int n)
#elif __has_builtin(__builtin_rotateleft64) && (SIZEOF_VALUE * CHAR_BIT == 64)
return __builtin_rotateleft64(v, n);
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 32)
#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 32)
return _rotl(v, n);
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 64)
#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 64)
return _rotl64(v, n);
#elif defined(_lrotl) && (SIZEOF_VALUE == SIZEOF_LONG)
@ -546,10 +546,10 @@ RUBY_BIT_ROTR(VALUE v, int n)
#elif __has_builtin(__builtin_rotateright64) && (SIZEOF_VALUE * CHAR_BIT == 64)
return __builtin_rotateright64(v, n);
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 32)
#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 32)
return _rotr(v, n);
#elif MSC_VERSION_SINCE(1310) && (SIZEOF_VALUE * CHAR_BIT == 64)
#elif defined(_MSC_VER) && (SIZEOF_VALUE * CHAR_BIT == 64)
return _rotr64(v, n);
#elif defined(_lrotr) && (SIZEOF_VALUE == SIZEOF_LONG)

View File

@ -230,7 +230,7 @@ int_pair_to_real_inclusive(uint32_t a, uint32_t b)
const uint128_t m = ((uint128_t)1 << dig) | 1;
uint128_t x = ((uint128_t)a << 32) | b;
r = (double)(uint64_t)((x * m) >> 64);
#elif defined HAVE_UINT64_T && !MSC_VERSION_BEFORE(1300)
#elif defined HAVE_UINT64_T
uint64_t x = ((uint64_t)a << dig_u) +
(((uint64_t)b + (a >> dig_u)) >> dig_r64);
r = (double)x;

View File

@ -266,19 +266,6 @@
# include <stdio.h>
#endif
#ifdef _WIN32
# if defined(_MSC_VER) && (_MSC_VER < 1300)
# ifndef _INTPTR_T_DEFINED
# define _INTPTR_T_DEFINED
typedef int intptr_t;
# endif
# ifndef _UINTPTR_T_DEFINED
# define _UINTPTR_T_DEFINED
typedef unsigned int uintptr_t;
# endif
# endif
#endif /* _WIN32 */
#ifndef PRIdPTR
# ifdef _WIN64
# define PRIdPTR "I64d"

View File

@ -2518,15 +2518,6 @@ opt_equality_specialized(VALUE recv, VALUE obj)
double a = RFLOAT_VALUE(recv);
double b = RFLOAT_VALUE(obj);
#if MSC_VERSION_BEFORE(1300)
if (isnan(a)) {
return Qfalse;
}
else if (isnan(b)) {
return Qfalse;
}
else
#endif
return RBOOL(a == b);
}
else if (RBASIC_CLASS(recv) == rb_cString && EQ_UNREDEFINED_P(STRING)) {
@ -2624,37 +2615,27 @@ check_match(rb_execution_context_t *ec, VALUE pattern, VALUE target, enum vm_che
}
#if MSC_VERSION_BEFORE(1300)
#define CHECK_CMP_NAN(a, b) if (isnan(a) || isnan(b)) return Qfalse;
#else
#define CHECK_CMP_NAN(a, b) /* do nothing */
#endif
static inline VALUE
double_cmp_lt(double a, double b)
{
CHECK_CMP_NAN(a, b);
return RBOOL(a < b);
}
static inline VALUE
double_cmp_le(double a, double b)
{
CHECK_CMP_NAN(a, b);
return RBOOL(a <= b);
}
static inline VALUE
double_cmp_gt(double a, double b)
{
CHECK_CMP_NAN(a, b);
return RBOOL(a > b);
}
static inline VALUE
double_cmp_ge(double a, double b)
{
CHECK_CMP_NAN(a, b);
return RBOOL(a >= b);
}
@ -6878,7 +6859,6 @@ vm_opt_lt(VALUE recv, VALUE obj)
else if (RBASIC_CLASS(recv) == rb_cFloat &&
RBASIC_CLASS(obj) == rb_cFloat &&
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
CHECK_CMP_NAN(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
return RBOOL(RFLOAT_VALUE(recv) < RFLOAT_VALUE(obj));
}
else {
@ -6903,7 +6883,6 @@ vm_opt_le(VALUE recv, VALUE obj)
else if (RBASIC_CLASS(recv) == rb_cFloat &&
RBASIC_CLASS(obj) == rb_cFloat &&
BASIC_OP_UNREDEFINED_P(BOP_LE, FLOAT_REDEFINED_OP_FLAG)) {
CHECK_CMP_NAN(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
return RBOOL(RFLOAT_VALUE(recv) <= RFLOAT_VALUE(obj));
}
else {
@ -6928,7 +6907,6 @@ vm_opt_gt(VALUE recv, VALUE obj)
else if (RBASIC_CLASS(recv) == rb_cFloat &&
RBASIC_CLASS(obj) == rb_cFloat &&
BASIC_OP_UNREDEFINED_P(BOP_GT, FLOAT_REDEFINED_OP_FLAG)) {
CHECK_CMP_NAN(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
return RBOOL(RFLOAT_VALUE(recv) > RFLOAT_VALUE(obj));
}
else {
@ -6953,7 +6931,6 @@ vm_opt_ge(VALUE recv, VALUE obj)
else if (RBASIC_CLASS(recv) == rb_cFloat &&
RBASIC_CLASS(obj) == rb_cFloat &&
BASIC_OP_UNREDEFINED_P(BOP_GE, FLOAT_REDEFINED_OP_FLAG)) {
CHECK_CMP_NAN(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
return RBOOL(RFLOAT_VALUE(recv) >= RFLOAT_VALUE(obj));
}
else {

View File

@ -130,6 +130,11 @@ TEST_RUNNABLE = yes
CAT_DEPEND = type
!if !defined(MSC_VER)
! error MSC_VER not defined. Retry from configure pass.
!else if $(MSC_VER) < 1400
! error MSVC $(MSC_VER) is not supported
!endif
!if !defined(MACHINE)
MACHINE = x86
!endif
@ -140,9 +145,6 @@ PROCESSOR_LEVEL = 5
!if 6 < $(PROCESSOR_LEVEL)
PROCESSOR_LEVEL = 6
!endif
!if $(MSC_VER) < 1400
PROCESSOR_FLAG = -G$(PROCESSOR_LEVEL)
!endif
CPU = i$(PROCESSOR_LEVEL)86
ARCH = i386
!else
@ -159,12 +161,8 @@ XCFLAGS = $(XCFLAGS) -DRUBY_DEVEL=1
XCFLAGS = $(XCFLAGS) -Dmodular_gc_dir="$(modular_gc_dir)"
!endif
!if !defined(OPTFLAGS)
!if $(MSC_VER) < 1400
OPTFLAGS = -O2b2xg-
!else
OPTFLAGS = -O2sy-
!endif
!endif
!if $(MSC_VER) >= 1900
OPTFLAGS = $(OPTFLAGS) -Zc:inline
!endif
@ -176,6 +174,8 @@ PLATFORM = mswin32
!endif
!if !defined(RT)
!error RT not defined. Retry from configure pass.
!else if $(RT_VER) < 80
! error Runtime library $(RT_VER) is not supported
!endif
!ifndef NTVER
NTVER = _WIN32_WINNT_WIN8
@ -278,13 +278,9 @@ RUNTIMEFLAG = -MD
COMPILERFLAG = -Zm600
!endif
!if !defined(WARNFLAGS)
!if $(MSC_VER) >= 1400
WARNFLAGS = -W2 -wd4100 -wd4127 -wd4210 -wd4214 -wd4255 -wd4574 \
-wd4668 -wd4710 -wd4711 -wd4820 -wd4996 \
-we4028 -we4142 -we4047 -we4013
!else
WARNFLAGS = -W2
!endif
!if $(MSC_VER) >= 1944
# https://developercommunity.visualstudio.com/t/warning-C5287:-operands-are-different-e/10877942
WARNFLAGS = $(WARNFLAGS) -wd5287
@ -318,9 +314,7 @@ EXTSOLIBS =
!endif
!if !defined(LIBS)
LIBS = user32.lib advapi32.lib shell32.lib ws2_32.lib
!if $(MSC_VER) >= 1400
LIBS = $(LIBS) iphlpapi.lib
!endif
!if defined(USE_GMP)
LIBS = $(LIBS) gmp.lib
!endif
@ -697,11 +691,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
!if $(MSC_VER) >= 1920
#define HAVE_AFUNIX_H 1
!endif
!if $(MSC_VER) >= 1400
#define HAVE_LONG_LONG 1
!else
#define ULL_TO_DOUBLE(n) ((double)(unsigned long)((n)>>32) * (1I64 << 32) + (unsigned long)(n))
!endif
#define HAVE_OFF_T 1
#define rb_off_t __int64
#define SIGNEDNESS_OF_OFF_T -1
@ -710,11 +700,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
#define SIZEOF_INT 4
#define SIZEOF_SHORT 2
#define SIZEOF_LONG 4
!if $(MSC_VER) >= 1400
#define SIZEOF_LONG_LONG 8
!else
#define SIZEOF_LONG_LONG 0
!endif
#define SIZEOF___INT64 8
#ifndef _INTEGRAL_MAX_BITS
#define _INTEGRAL_MAX_BITS 64
@ -729,15 +715,9 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
#define SIZEOF_DOUBLE 8
#define SIGNEDNESS_OF_TIME_T -1
#define NEGATIVE_TIME_T 1
!if $(RT_VER) >= 80
#define SIZEOF_TIME_T 8
#define TIMET2NUM(v) LL2NUM(v)
#define NUM2TIMET(v) NUM2LL(v)
!else
#define SIZEOF_TIME_T 4
#define TIMET2NUM(v) LONG2NUM(v)
#define NUM2TIMET(v) NUM2LONG(v)
!endif
#define CLOCKID2NUM(v) INT2NUM(v)
#define NUM2CLOCKID(v) NUM2INT(v)
#define SIZEOF_CLOCK_T 4
@ -753,22 +733,15 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
#define SIZEOF_INTPTR_T 4
#define SIZEOF_UINTPTR_T 4
!endif
!if $(MSC_VER) < 1400
#define SIZE_MAX UINT_MAX
!endif
!if $(MSC_VER) >= 1800
#define HAVE_VA_COPY 1
!else
#define HAVE_VA_COPY_VIA_STRUCT_ASSIGNMENT 1
!endif
!if $(MSC_VER) > 1100
#define NORETURN(x) __declspec(noreturn) x
!endif
!if $(MSC_VER) >= 1300
#define DEPRECATED(x) __declspec(deprecated) x
#define RUBY_CXX_DEPRECATED(mesg) __declspec(deprecated(mesg))
#define NOINLINE(x) __declspec(noinline) x
!endif
#define ALWAYS_INLINE(x) __forceinline x
#define WARN_UNUSED_RESULT(x) x
#define MAYBE_UNUSED(x) x
@ -1119,7 +1092,7 @@ s,@LIBPATHFLAG@,-libpath:%s,;t t
s,@RPATHFLAG@,,;t t
s,@LIBARG@,%s.lib,;t t
s,@LINK_SO@,$$(LDSHARED) -Fe$$(@) $$(OBJS) $$(LIBS) $$(LOCAL_LIBS) -link $$(DLDFLAGS) -implib:$$(*F:.so=)-$$(arch).lib -pdb:$$(*F:.so=)-$$(arch).pdb -def:$$(DEFFILE),;t t
!if $(MSC_VER) >= 1400 && $(MSC_VER) < 1800
!if $(MSC_VER) < 1800
s,@LINK_SO@,@if exist $$(@).manifest $$(RUBY) -run -e wait_writable -- -n 10 $$(@),;t t
s,@LINK_SO@,@if exist $$(@).manifest $(MANIFESTTOOL) -manifest $$(@).manifest -outputresource:$$(@);2,;t t
s,@LINK_SO@,@if exist $$(@).manifest $$(RM) $$(@:/=\).manifest,;t t

View File

@ -629,14 +629,10 @@ rb_freopen(VALUE fname, const char *mode, FILE *file)
len = MultiByteToWideChar(CP_UTF8, 0, name, n, wname, len);
wname[len] = L'\0';
RB_GC_GUARD(fname);
#if RUBY_MSVCRT_VERSION < 80 && !defined(HAVE__WFREOPEN_S)
e = _wfreopen(wname, wmode, file) ? 0 : errno;
#else
{
FILE *newfp = 0;
e = _wfreopen_s(&newfp, wname, wmode, file);
}
#endif
ALLOCV_END(wtmp);
return e;
}

View File

@ -21,6 +21,10 @@
#undef __STRICT_ANSI__
/* Visual C++ 2005 (8.0):
* - _MSC_VER: 1400
* - MSVCRT_VERSION: 80
*/
#include "ruby/ruby.h"
#include "ruby/encoding.h"
#include "ruby/io.h"
@ -42,7 +46,7 @@
#include <shlobj.h>
#include <mbstring.h>
#include <shlwapi.h>
#if defined _MSC_VER && _MSC_VER >= 1400
#if defined _MSC_VER
#include <crtdbg.h>
#include <rtcapi.h>
#endif
@ -65,10 +69,6 @@
#include "encindex.h"
#define isdirsep(x) ((x) == '/' || (x) == '\\')
#if defined _MSC_VER && _MSC_VER <= 1200
# define CharNextExA(cp, p, flags) CharNextExA((WORD)(cp), (p), (flags))
#endif
static int w32_wopen(const WCHAR *file, int oflag, int perm);
static int w32_stati128(const char *path, struct stati128 *st, UINT cp, BOOL lstat);
static char *w32_getenv(const char *name, UINT cp);
@ -503,11 +503,6 @@ rb_w32_special_folder(int type)
return rb_w32_conv_from_wchar(path, rb_filesystem_encoding());
}
#if defined _MSC_VER && _MSC_VER <= 1200
/* License: Ruby's */
#define GetSystemWindowsDirectoryW GetWindowsDirectoryW
#endif
/* License: Ruby's */
UINT
rb_w32_system_tmpdir(WCHAR *path, UINT len)
@ -629,7 +624,6 @@ init_env(void)
static void init_stdhandle(void);
#if RUBY_MSVCRT_VERSION >= 80
/* License: Ruby's */
static void
invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file, unsigned int line, uintptr_t dummy)
@ -639,7 +633,7 @@ invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file,
int ruby_w32_rtc_error;
# ifndef __MINGW32__
#ifndef __MINGW32__
/* License: Ruby's */
RBIMPL_ATTR_NONNULL((5))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 5, 6)
@ -658,7 +652,6 @@ rtc_error_handler(int e, const char *src, int line, const char *exe, const char
rb_write_error2(RSTRING_PTR(str), RSTRING_LEN(str));
return 0;
}
# endif
#endif
static CRITICAL_SECTION select_mutex;
@ -852,13 +845,11 @@ socklist_delete(SOCKET *sockp, int *flagp)
return ret;
}
#if RUBY_MSVCRT_VERSION >= 80
# ifdef __MINGW32__
# define _CrtSetReportMode(type,mode) ((void)0)
# define _RTC_SetErrorFunc(func) ((void)0)
# endif
static void set_pioinfo_extra(void);
#endif
static int w32_cmdvector(const WCHAR *, char ***, UINT, rb_encoding *);
//
// Initialization stuff
@ -867,13 +858,10 @@ static int w32_cmdvector(const WCHAR *, char ***, UINT, rb_encoding *);
void
rb_w32_sysinit(int *argc, char ***argv)
{
#if RUBY_MSVCRT_VERSION >= 80
_CrtSetReportMode(_CRT_ASSERT, 0);
_set_invalid_parameter_handler(invalid_parameter);
_RTC_SetErrorFunc(rtc_error_handler);
set_pioinfo_extra();
#endif
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX);
get_version();
@ -2464,10 +2452,8 @@ typedef struct {
char pipech; /* one char buffer for handles opened on pipes */
int lockinitflag;
CRITICAL_SECTION lock;
#if RUBY_MSVCRT_VERSION >= 80
char textmode;
char pipech2[2];
#endif
} ioinfo;
#endif
@ -2492,7 +2478,6 @@ static inline ioinfo* _pioinfo(int);
#define rb_acrt_lowio_lock_fh(i) EnterCriticalSection(&_pioinfo(i)->lock)
#define rb_acrt_lowio_unlock_fh(i) LeaveCriticalSection(&_pioinfo(i)->lock)
#if RUBY_MSVCRT_VERSION >= 80
static size_t pioinfo_extra = 0; /* workaround for VC++8 SP1 */
/* License: Ruby's */
@ -2656,9 +2641,6 @@ set_pioinfo_extra(void)
pioinfo_extra = 0;
}
}
#else
#define pioinfo_extra 0
#endif
static inline ioinfo*
_pioinfo(int fd)
@ -4235,7 +4217,6 @@ socketpair(int af, int type, int protocol, int *sv)
return 0;
}
#if !defined(_MSC_VER) || _MSC_VER >= 1400
/* License: Ruby's */
static void
str2guid(const char *str, GUID *guid)
@ -4361,7 +4342,6 @@ freeifaddrs(struct ifaddrs *ifp)
ifp = next;
}
}
#endif
#if 0 // Have never been used
//
@ -7592,20 +7572,6 @@ rb_w32_write_console(uintptr_t strarg, int fd)
return (long)reslen;
}
#if RUBY_MSVCRT_VERSION < 80 && !defined(HAVE__GMTIME64_S)
/* License: Ruby's */
static int
unixtime_to_filetime(time_t time, FILETIME *ft)
{
ULARGE_INTEGER tmp;
tmp.QuadPart = unix_to_filetime((ULONGLONG)time);
ft->dwLowDateTime = tmp.LowPart;
ft->dwHighDateTime = tmp.HighPart;
return 0;
}
#endif
/* License: Ruby's */
static int
timespec_to_filetime(const struct timespec *ts, FILETIME *ft)
@ -7982,23 +7948,6 @@ rb_w32_isatty(int fd)
return 1;
}
#if defined(_MSC_VER) && RUBY_MSVCRT_VERSION <= 60
extern long _ftol(double);
/* License: Ruby's */
long
_ftol2(double d)
{
return _ftol(d);
}
/* License: Ruby's */
long
_ftol2_sse(double d)
{
return _ftol(d);
}
#endif
#ifndef signbit
/* License: Ruby's */
int
@ -8030,68 +7979,6 @@ rb_w32_fd_is_text(int fd)
return _osfile(fd) & FTEXT;
}
#if RUBY_MSVCRT_VERSION < 80 && !defined(HAVE__GMTIME64_S)
/* License: Ruby's */
static int
unixtime_to_systemtime(const time_t t, SYSTEMTIME *st)
{
FILETIME ft;
if (unixtime_to_filetime(t, &ft)) return -1;
if (!FileTimeToSystemTime(&ft, st)) return -1;
return 0;
}
/* License: Ruby's */
static void
systemtime_to_tm(const SYSTEMTIME *st, struct tm *t)
{
int y = st->wYear, m = st->wMonth, d = st->wDay;
t->tm_sec = st->wSecond;
t->tm_min = st->wMinute;
t->tm_hour = st->wHour;
t->tm_mday = st->wDay;
t->tm_mon = st->wMonth - 1;
t->tm_year = y - 1900;
t->tm_wday = st->wDayOfWeek;
switch (m) {
case 1:
break;
case 2:
d += 31;
break;
default:
d += 31 + 28 + (!(y % 4) && ((y % 100) || !(y % 400)));
d += ((m - 3) * 153 + 2) / 5;
break;
}
t->tm_yday = d - 1;
}
/* License: Ruby's */
static int
systemtime_to_localtime(TIME_ZONE_INFORMATION *tz, SYSTEMTIME *gst, SYSTEMTIME *lst)
{
TIME_ZONE_INFORMATION stdtz;
SYSTEMTIME sst;
if (!SystemTimeToTzSpecificLocalTime(tz, gst, lst)) return -1;
if (!tz) {
GetTimeZoneInformation(&stdtz);
tz = &stdtz;
}
if (tz->StandardBias == tz->DaylightBias) return 0;
if (!tz->StandardDate.wMonth) return 0;
if (!tz->DaylightDate.wMonth) return 0;
if (tz != &stdtz) stdtz = *tz;
stdtz.StandardDate.wMonth = stdtz.DaylightDate.wMonth = 0;
if (!SystemTimeToTzSpecificLocalTime(&stdtz, gst, &sst)) return 0;
if (lst->wMinute == sst.wMinute && lst->wHour == sst.wHour)
return 0;
return 1;
}
#endif
#ifdef HAVE__GMTIME64_S
# ifndef HAVE__LOCALTIME64_S
/* assume same as _gmtime64_s() */
@ -8115,17 +8002,8 @@ gmtime_r(const time_t *tp, struct tm *rp)
errno = e;
return NULL;
}
#if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__GMTIME64_S)
e = gmtime_s(rp, tp);
if (e != 0) goto error;
#else
{
SYSTEMTIME st;
if (unixtime_to_systemtime(*tp, &st)) goto error;
rp->tm_isdst = 0;
systemtime_to_tm(&st, rp);
}
#endif
return rp;
}
@ -8139,17 +8017,8 @@ localtime_r(const time_t *tp, struct tm *rp)
errno = e;
return NULL;
}
#if RUBY_MSVCRT_VERSION >= 80 || defined(HAVE__LOCALTIME64_S)
e = localtime_s(rp, tp);
if (e) goto error;
#else
{
SYSTEMTIME gst, lst;
if (unixtime_to_systemtime(*tp, &gst)) goto error;
rp->tm_isdst = systemtime_to_localtime(NULL, &gst, &lst);
systemtime_to_tm(&lst, rp);
}
#endif
return rp;
}