Skip to content
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

[Win32] UV_MAX is wrong on "use 64bit int" builds #15533

Closed
p5pRT opened this issue Aug 20, 2016 · 6 comments
Closed

[Win32] UV_MAX is wrong on "use 64bit int" builds #15533

p5pRT opened this issue Aug 20, 2016 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 20, 2016

Migrated from rt.perl.org#129009 (status was 'rejected')

Searchable as RT129009$

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2016

From @sisyphus

Hi,

I'm assuming that UV_MAX (defined in perl.h) should be set to the maximum
value that a UV can hold - ie to the value of ~0.

However, on all "use 64bit int" builds that I've tested (from perl-5.12.0 to
perl-5.25.3) I'm finding that UV_MAX is set to 4294967295, whereas the
maximum value a UV can hold is 18446744073709551615.

Here is the demo​:

###############################

C​:\_32\>type try.pl
use warnings;
use strict;

use Inline C => <<'EOC';

void foo() {
#ifdef HAS_QUAD
  printf("has quad defined\n");
#endif

#ifdef USE_64_BIT_INT
  printf("use 64bit int defined\n");
#endif

#ifndef INT64_MAX
  printf("int64_max NOT defined\n");
#endif

  printf("%u %u %u %u\n", UV_MAX, QUADKIND, QUAD_IS_INT64_T,
PERL_UQUAD_MAX);
}

EOC

foo();

C​:\_32>perl try.pl
has quad defined
use 64bit int defined
int64_max NOT defined
4294967295 3 4 4294967295

C​:\_32\>perl -le "print ~0;"
18446744073709551615

###############################

What is the best portable way to obtain the maximum UV value from within XS
?

Here is the 'perl -V' output for the perl (5.25.3)that produced the above
results​:

Summary of my perl5 (revision 5 version 25 subversion 3) configuration​:

  Platform​:
  osname=MSWin32
  osvers=6.1
  archname=MSWin32-x64-multi-thread
  uname=''
  config_args='undef'
  hint=recommended
  useposix=true
  d_sigaction=undef
  useithreads=define
  usemultiplicity=define
  use64bitint=define
  use64bitall=undef
  uselongdouble=undef
  usemymalloc=n
  bincompat5005=undef
  Compiler​:
  cc='gcc'
  ccflags
' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'
  optimize='-s -O2'
  cppflags='-DWIN32'
  ccversion=''
  gccversion='5.3.0'
  gccosandvers=''
  intsize=4
  longsize=4
  ptrsize=8
  doublesize=8
  byteorder=12345678
  doublekind=3
  d_longlong=define
  longlongsize=8
  d_longdbl=define
  longdblsize=16
  longdblkind=3
  ivtype='long long'
  ivsize=8
  nvtype='double'
  nvsize=8
  Off_t='long long'
  lseeksize=8
  alignbytes=8
  prototype=define
  Linker and Libraries​:
  ld='g++'
  ldflags
='-s -L"c​:\_64\blead-5.25.3\lib\CORE" -L"C​:\_64\gcc-mingw-530\mingw64\lib"'
  libpth=C​:\_64\gcc-mingw-530\mingw64\lib
C​:\_64\gcc-mingw-530\mingw64\x86_64-w64-mingw32\lib
C​:\_64\msys_530\1.0\local\lib
C​:\_64\gcc-mingw-530\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0
  libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion
-lodbc32 -lodbccp32 -lcomctl32
  perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion
-lodbc32 -lodbccp32 -lcomctl32
  libc=
  so=dll
  useshrplib=true
  libperl=libperl525.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_win32.xs
  dlext=dll
  d_dlsymun=undef
  ccdlflags=' '
  cccdlflags=' '
  lddlflags='-mdll -s -L"c​:\_64\blead-5.25.3\lib\CORE" -L"C​:\_64\gcc-mingw-530\mingw64\lib"'

Characteristics of this binary (from libperl)​:
  Compile-time options​:
  HAS_TIMES
  HAVE_INTERP_INTERN
  MULTIPLICITY
  PERLIO_LAYERS
  PERL_COPY_ON_WRITE
  PERL_DONT_CREATE_GVSV
  PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
  PERL_IMPLICIT_CONTEXT
  PERL_IMPLICIT_SYS
  PERL_MALLOC_WRAP
  PERL_OP_PARENT
  PERL_PRESERVE_IVUV
  USE_64_BIT_INT
  USE_ITHREADS
  USE_LARGE_FILES
  USE_LOCALE
  USE_LOCALE_COLLATE
  USE_LOCALE_CTYPE
  USE_LOCALE_NUMERIC
  USE_LOCALE_TIME
  USE_PERLIO
  USE_PERL_ATOF
  Built under MSWin32
  Compiled at Jul 21 2016 11​:10​:53
  @​INC​:
  C​:/_64/blead-5.25.3/site/lib
  C​:/_64/blead-5.25.3/lib
  .

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2016

From zefram@fysh.org

Sisyphus wrote​:

printf("%u %u %u %u\n", UV_MAX, QUADKIND, QUAD_IS_INT64_T,
PERL_UQUAD_MAX);

%u takes an int argument, so of course the output is limited to the
int range. Try printf("%"UVuf"\n", (UV)UV_MAX). I don't know what
format you'd need for PERL_UQUAD_MAX.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2016

From @sisyphus

Duh ... of course.
Sorry.

-----Original Message-----
From​: Zefram
Sent​: Saturday, August 20, 2016 6​:13 PM
To​: perl5-porters@​perl.org
Subject​: Re​: [perl #129009] [Win32] UV_MAX is wrong on "use 64bit int"
builds

Sisyphus wrote​:

printf("%u %u %u %u\n", UV_MAX, QUADKIND, QUAD_IS_INT64_T,
PERL_UQUAD_MAX);

%u takes an int argument, so of course the output is limited to the
int range. Try printf("%"UVuf"\n", (UV)UV_MAX). I don't know what
format you'd need for PERL_UQUAD_MAX.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2016

From @khwilliamson

rejected
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented Aug 20, 2016

@khwilliamson - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant