New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional ICC-only support for using long doubles on Win32 #16264
Comments
From @steve-m-hayCreated by @steve-m-hayThe attached patch by bulk88 taken from See the following entries on that ticket for further details: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=123113#txn-1316983 Perl Info
|
From @steve-m-hay0001-icc-longdouble-wip.patchFrom 6d149aa0e5feff84216d4da035c7f1b2278e81bc Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Thu, 9 Jan 2014 03:10:40 -0500
Subject: [PATCH] icc longdouble wip
---
generate_uudmap.c | 2 ++
perl.h | 12 ++++++++++++
uconfig.h | 8 ++++----
util.c | 9 +++++++--
win32/Makefile | 10 +++++-----
win32/config.vc | 18 +++++++++---------
win32/config_H.vc | 30 +++++++++++++++---------------
7 files changed, 54 insertions(+), 35 deletions(-)
diff --git a/generate_uudmap.c b/generate_uudmap.c
index b6307c0..b72f374 100644
--- a/generate_uudmap.c
+++ b/generate_uudmap.c
@@ -108,6 +108,8 @@ int main(int argc, char **argv) {
int bits;
struct mg_data_raw_t *p = mg_data_raw;
+ fprintf(stderr, "sizeof ld %d\n", sizeof(long double));
+
if (argc < 4 || argv[1][0] == '\0' || argv[2][0] == '\0'
|| argv[3][0] == '\0') {
fprintf(stderr, "Usage: %s uudemap.h bitcount.h mg_data.h\n", argv[0]);
diff --git a/perl.h b/perl.h
index b6e0c3e..6c7d5bd 100644
--- a/perl.h
+++ b/perl.h
@@ -1671,6 +1671,7 @@ typedef UVTYPE UV;
# endif
# if !(defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE))
# undef USE_LONG_DOUBLE /* Ouch! */
+ #error undefed ULD
# endif
#endif
@@ -1763,10 +1764,15 @@ typedef NVTYPE NV;
# include <ieeefp.h>
#endif
+#ifndef USE_LONG_DOUBLE
+#error no LD
+#endif
+
#ifdef USE_LONG_DOUBLE
# ifdef I_SUNMATH
# include <sunmath.h>
# endif
+# include <mathimf.h>
# define NV_DIG LDBL_DIG
# ifdef LDBL_MANT_DIG
# define NV_MANT_DIG LDBL_MANT_DIG
@@ -1798,6 +1804,7 @@ typedef NVTYPE NV;
# endif
# endif
# endif
+
# ifdef HAS_SQRTL
# define Perl_cos cosl
# define Perl_sin sinl
@@ -1843,6 +1850,7 @@ EXTERN_C long double modfl(long double, long double *);
# endif
# endif
#else
+#error die
# define NV_DIG DBL_DIG
# ifdef DBL_MANT_DIG
# define NV_MANT_DIG DBL_MANT_DIG
@@ -5833,6 +5841,10 @@ extern void moncontrol(int);
*/
+#ifndef HAS_SQRTL
+#error no long
+#endif
+
#endif /* Include guard */
/*
diff --git a/uconfig.h b/uconfig.h
index 8e728ab..e29fabd 100644
--- a/uconfig.h
+++ b/uconfig.h
@@ -4361,10 +4361,10 @@
* This symbol, if defined, contains the string used by stdio to
* format long doubles (format 'f') for input.
*/
-/*#define PERL_PRIfldbl "llf" / **/
-/*#define PERL_PRIgldbl "llg" / **/
-/*#define PERL_PRIeldbl "lle" / **/
-/*#define PERL_SCNfldbl "llf" / **/
+#define PERL_PRIfldbl "llf" / **/
+#define PERL_PRIgldbl "llg" / **/
+#define PERL_PRIeldbl "lle" / **/
+#define PERL_SCNfldbl "llf" / **/
/* PERL_MAD:
* This symbol, if defined, indicates that the Misc Attribution
diff --git a/util.c b/util.c
index f308e93..455b7bb 100644
--- a/util.c
+++ b/util.c
@@ -4769,10 +4769,12 @@ Perl_my_snprintf(char *buffer, const Size_t len, const char *format, ...)
{
int retval;
va_list ap;
+ restart:
PERL_ARGS_ASSERT_MY_SNPRINTF;
va_start(ap, format);
+ memset(buffer, 0, len);
#ifdef HAS_VSNPRINTF
- retval = vsnprintf(buffer, len, format, ap);
+ retval = ___mingw_vsnprintf(buffer, len, format, ap);
#else
retval = vsprintf(buffer, format, ap);
#endif
@@ -4784,8 +4786,11 @@ Perl_my_snprintf(char *buffer, const Size_t len, const char *format, ...)
||
(len > 0 && (Size_t)retval >= len)
#endif
- )
+ ) {
+ DebugBreak();
+ goto restart;
Perl_croak_nocontext("panic: my_snprintf buffer overflow");
+ }
return retval;
}
diff --git a/win32/Makefile b/win32/Makefile
index 885f8ce..2c90bef 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -134,14 +134,14 @@ CCTYPE = MSVC90
#
# If you are using Intel C++ Compiler uncomment this
#
-#__ICC = define
+__ICC = define
#
# uncomment next line if you want debug version of perl (big,slow)
# If not enabled, we automatically try to use maximum optimization
# with all compilers that are known to have a working optimizer.
#
-#CFG = Debug
+CFG = Debug
#
# uncomment to enable linking with setargv.obj under the Visual C
@@ -443,10 +443,10 @@ LOCDEFS = -DPERLDLL -DPERL_CORE
SUBSYS = console
CXX_FLAG = -TP -EHsc
-LIBC = msvcrt.lib
+LIBC = msvcrtd.lib
!IF "$(CFG)" == "Debug"
-OPTIMIZE = -Od -MD -Zi -DDEBUGGING
+OPTIMIZE = -Od -MDd -Zi -DDEBUGGING
LINK_DBG = -debug
!ELSE
# -O1 yields smaller code, which turns out to be faster than -O2 on x86 and x64
@@ -517,7 +517,7 @@ LIBBASEFILES = $(LIBBASEFILES) bufferoverflowU.lib
LIBFILES = $(LIBBASEFILES) $(LIBC)
#EXTRACFLAGS = -nologo -GF -W4 -wd4127 -wd4706
-EXTRACFLAGS = -nologo -GF -W3
+EXTRACFLAGS = -nologo -GF -W3 /Qlong-double /Qpc80 -DUSE_LONG_DOUBLE -DHAS_LONG_DOUBLE
CFLAGS = $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) \
$(PCHFLAGS) $(OPTIMIZE)
LINK_FLAGS = -nologo -nodefaultlib $(LINK_DBG) \
diff --git a/win32/config.vc b/win32/config.vc
index a15b926..bc90fd8 100644
--- a/win32/config.vc
+++ b/win32/config.vc
@@ -449,7 +449,7 @@ d_socklen_t='undef'
d_sockpair='undef'
d_socks5_init='undef'
d_sprintf_returns_strlen='define'
-d_sqrtl='undef'
+d_sqrtl='define'
d_srand48_r='undef'
d_srandom_r='undef'
d_sresgproto='undef'
@@ -828,16 +828,16 @@ nm_opt=''
nm_so_opt=''
nonxs_ext='Errno'
nroff=''
-nvEUformat='"E"'
-nvFUformat='"F"'
-nvGUformat='"G"'
+nvEUformat='"LE"'
+nvFUformat='"LF"'
+nvGUformat='"LG"'
nv_overflows_integers_at='256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0'
nv_preserves_uv_bits='32'
-nveformat='"e"'
-nvfformat='"f"'
-nvgformat='"g"'
-nvsize='8'
-nvtype='double'
+nveformat='"Le"'
+nvfformat='"Lf"'
+nvgformat='"Lg"'
+nvsize='12'
+nvtype='long double'
o_nonblock='O_NONBLOCK'
obj_ext='.obj'
old_pthread_create_joinable=''
diff --git a/win32/config_H.vc b/win32/config_H.vc
index f55a6d2..7f612f3 100644
--- a/win32/config_H.vc
+++ b/win32/config_H.vc
@@ -1930,9 +1930,9 @@
* C preprocessor can make decisions based on it. It is only
* defined if the system supports long doubles.
*/
-#define HAS_LONG_DOUBLE /**/
+/*#define HAS_LONG_DOUBLE /**/
#ifdef HAS_LONG_DOUBLE
-#define LONG_DOUBLESIZE 8 /**/
+#define LONG_DOUBLESIZE 16 /**/
#endif
/* HAS_LONG_LONG:
@@ -3558,7 +3558,7 @@
* available to break a long double floating-point number into
* a normalized fraction and an integral power of 2.
*/
-/*#define HAS_FREXPL / **/
+#define HAS_FREXPL
/* HAS_STRUCT_FS_DATA:
* This symbol, if defined, indicates that the struct fs_data
@@ -3780,8 +3780,8 @@
* and 1.150000. The bug has been seen in certain versions of glibc,
* release 2.2.2 is known to be okay.
*/
-/*#define HAS_MODFL / **/
-/*#define HAS_MODFL_PROTO / **/
+#define HAS_MODFL
+#define HAS_MODFL_PROTO
/*#define HAS_MODFL_POW32_BUG / **/
/* HAS_MPROTECT:
@@ -3954,7 +3954,7 @@
* This symbol, if defined, indicates that the sqrtl routine is
* available to do long double square roots.
*/
-/*#define HAS_SQRTL / **/
+#define HAS_SQRTL / **/
/* HAS_SETRESGID_PROTO:
* This symbol, if defined, indicates that the system provides
@@ -4361,10 +4361,10 @@
* This symbol, if defined, contains the string used by stdio to
* format long doubles (format 'f') for input.
*/
-/*#define PERL_PRIfldbl "f" / **/
-/*#define PERL_PRIgldbl "g" / **/
-/*#define PERL_PRIeldbl "e" / **/
-/*#define PERL_SCNfldbl "f" / **/
+#define PERL_PRIfldbl "f"
+#define PERL_PRIgldbl "g"
+#define PERL_PRIeldbl "e"
+#define PERL_SCNfldbl "f"
/* PERL_MAD:
* This symbol, if defined, indicates that the Misc Attribution
@@ -4479,7 +4479,7 @@
#define I64TYPE __int64 /**/
#define U64TYPE unsigned __int64 /**/
#endif
-#define NVTYPE double /**/
+#define NVTYPE long double /**/
#define IVSIZE 4 /**/
#define UVSIZE 4 /**/
#define I8SIZE 1 /**/
@@ -4492,7 +4492,7 @@
#define I64SIZE 8 /**/
#define U64SIZE 8 /**/
#endif
-#define NVSIZE 8 /**/
+#define NVSIZE 12 /**/
#define NV_PRESERVES_UV
#define NV_PRESERVES_UV_BITS 32
#define NV_OVERFLOWS_INTEGERS_AT 256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0
@@ -4548,9 +4548,9 @@
#define UVof "lo" /**/
#define UVxf "lx" /**/
#define UVXf "lX" /**/
-#define NVef "e" /**/
-#define NVff "f" /**/
-#define NVgf "g" /**/
+#define NVef "Le" /**/
+#define NVff "Lf" /**/
+#define NVgf "Lg" /**/
/* SELECT_MIN_BITS:
* This symbol holds the minimum number of bits operated by select.
--
1.8.0.msysgit.0
|
Migrated from rt.perl.org#132478 (status was 'new')
Searchable as RT132478$
The text was updated successfully, but these errors were encountered: