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

[PATCH] d521697 add missing LLONG limits.h constants to POSIX #13406

Open
p5pRT opened this issue Nov 9, 2013 · 10 comments
Open

[PATCH] d521697 add missing LLONG limits.h constants to POSIX #13406

p5pRT opened this issue Nov 9, 2013 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 9, 2013

Migrated from rt.perl.org#120496 (status was 'open')

Searchable as RT120496$

@p5pRT
Copy link
Author

p5pRT commented Nov 9, 2013

From calid1984@gmail.com

This is a bug report for perl from calid1984@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.18.1.


Flags​:
  category=library
  severity=low
  module=POSIX


Site configuration information for perl 5.18.1​:

Configured by nobody at Tue Aug 13 13​:22​:58 CEST 2013.

Summary of my perl5 (revision 5 version 18 subversion 1) configuration​:

  Platform​:
  osname=linux, osvers=3.10.5-1-arch, archname=x86_64-linux-thread-multi
  uname='linux mnt-chroots-arch-extra-x86_64-flo-64 3.10.5-1-arch #1 smp
preempt mon aug 5 08​:04​:22 cest 2013 x86_64 gnulinux '
  config_args='-des -Dusethreads -Duseshrplib -Doptimize=-march=x86-64
-mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4
-Dprefix=/usr -Dvendorprefix=/usr -Dprivlib=/usr/share/perl5/core_perl
-Darchlib=/usr/lib/perl5/core_perl -Dsitelib=/usr/share/perl5/site_perl
-Dsitearch=/usr/lib/perl5/site_perl
-Dvendorlib=/usr/share/perl5/vendor_perl
-Dvendorarch=/usr/lib/perl5/vendor_perl -Dscriptdir=/usr/bin/core_perl
-Dsitescript=/usr/bin/site_perl -Dvendorscript=/usr/bin/vendor_perl
-Dinc_version_list=none -Dman1ext=1perl -Dman3ext=3perl
-Dcccdlflags='-fPIC' -Dlddlflags=-shared
-Wl,-O1,--sort-common,--as-needed,-z,relro
-Dldflags=-Wl,-O1,--sort-common,--as-needed,-z,relro'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=define, usemultiplicity=define
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
  optimize='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector
--param=ssp-buffer-size=4',
  cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include'
  ccversion='', gccversion='4.8.1 20130725 (prerelease)', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags ='-Wl,-O1,--sort-common,--as-needed,-z,relro
-fstack-protector -L/usr/local/lib'
  libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib /lib64
/usr/lib64
  libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
-lgdbm_compat
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
  libc=/lib/libc-2.17.so, so=so, useshrplib=true, libperl=libperl.so
  gnulibc_version='2.17'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-rpath,/usr/lib/perl5/core_perl/CORE'
  cccdlflags='-fPIC', lddlflags='-shared
-Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib
-fstack-protector'

Locally applied patches​:


@​INC for perl 5.18.1​:
  /usr/lib/perl5/site_perl
  /usr/share/perl5/site_perl
  /usr/lib/perl5/vendor_perl
  /usr/share/perl5/vendor_perl
  /usr/lib/perl5/core_perl
  /usr/share/perl5/core_perl
  .


Environment for perl 5.18.1​:
  HOME=/home/calid
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)

PATH=/home/calid/perl5/bin​:/home/calid/python2/bin​:/home/calid/python3/bin​:/usr/local/sbin​:/usr/local/bin​:/usr/bin​:/usr/bin/vendor_perl​:/usr/bin/core_perl
  PERL_BADLANG (unset)
  PERL_LOCAL_LIB_ROOT=​:/home/calid/perl5
  PERL_MB_OPT=--install_base /home/calid/perl5
  PERL_MM_OPT=INSTALL_BASE=/home/calid/perl5
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 9, 2013

From calid1984@gmail.com

0001-add-missing-LLONG-limits.h-constants-to-POSIX.patch
From d5216972b096dcc697d9ef3d8ef763babc065370 Mon Sep 17 00:00:00 2001
From: Dylan Cali <calid1984@gmail.com>
Date: Sat, 9 Nov 2013 05:48:36 -0600
Subject: [PATCH] add missing LLONG limits.h constants to POSIX
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------1.8.4"

This is a multi-part message in MIME format.
--------------1.8.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


sort both the expected and actual exports in POSIX export.t
---
 ext/POSIX/Makefile.PL   | 1 +
 ext/POSIX/lib/POSIX.pm  | 1 +
 ext/POSIX/lib/POSIX.pod | 2 +-
 ext/POSIX/t/export.t    | 5 +++--
 4 files changed, 6 insertions(+), 3 deletions(-)


--------------1.8.4
Content-Type: text/x-patch; name="0001-add-missing-LLONG-limits.h-constants-to-POSIX.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-add-missing-LLONG-limits.h-constants-to-POSIX.patch"

diff --git a/ext/POSIX/Makefile.PL b/ext/POSIX/Makefile.PL
index e6e621c..0824322 100644
--- a/ext/POSIX/Makefile.PL
+++ b/ext/POSIX/Makefile.PL
@@ -55,6 +55,7 @@ my @names =
       TCIOFLUSH TCION TCOFLUSH TCOOFF TCOON TCSADRAIN TCSAFLUSH TCSANOW
       TMP_MAX TOSTOP TZNAME_MAX VEOF VEOL VERASE VINTR VKILL VMIN VQUIT
       VSTART VSTOP VSUSP VTIME WNOHANG WUNTRACED W_OK X_OK
+      ULLONG_MAX LLONG_MAX LLONG_MIN
       _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON _PC_MAX_INPUT
       _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX _PC_PIPE_BUF _PC_VDISABLE
       _SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL _SC_NGROUPS_MAX
diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm
index d5f344a..a9dcd05 100644
--- a/ext/POSIX/lib/POSIX.pm
+++ b/ext/POSIX/lib/POSIX.pm
@@ -283,6 +283,7 @@ our %EXPORT_TAGS = (
 
     limits_h =>	[qw( ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX
 		INT_MAX INT_MIN LINK_MAX LONG_MAX LONG_MIN MAX_CANON
+		ULLONG_MAX LLONG_MAX LLONG_MIN
 		MAX_INPUT MB_LEN_MAX NAME_MAX NGROUPS_MAX OPEN_MAX
 		PATH_MAX PIPE_BUF SCHAR_MAX SCHAR_MIN SHRT_MAX SHRT_MIN
 		SSIZE_MAX STREAM_MAX TZNAME_MAX UCHAR_MAX UINT_MAX
diff --git a/ext/POSIX/lib/POSIX.pod b/ext/POSIX/lib/POSIX.pod
index 8f4362a..5833c48 100644
--- a/ext/POSIX/lib/POSIX.pod
+++ b/ext/POSIX/lib/POSIX.pod
@@ -2110,7 +2110,7 @@ LDBL_MAX_EXP LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP
 ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX INT_MAX INT_MIN LINK_MAX LONG_MAX
 LONG_MIN MAX_CANON MAX_INPUT MB_LEN_MAX NAME_MAX NGROUPS_MAX OPEN_MAX PATH_MAX
 PIPE_BUF SCHAR_MAX SCHAR_MIN SHRT_MAX SHRT_MIN SSIZE_MAX STREAM_MAX TZNAME_MAX
-UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX
+UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX ULLONG_MAX LLONG_MAX LLONG_MIN
 
 =back
 
diff --git a/ext/POSIX/t/export.t b/ext/POSIX/t/export.t
index f76c60c..2341cde 100644
--- a/ext/POSIX/t/export.t
+++ b/ext/POSIX/t/export.t
@@ -65,7 +65,8 @@ my %expect = (
 		  TZNAME_MAX UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX VEOF VEOL
 		  VERASE VINTR VKILL VMIN VQUIT VSTART VSTOP VSUSP VTIME
 		  WEXITSTATUS WIFEXITED WIFSIGNALED WIFSTOPPED WNOHANG WSTOPSIG
-		  WTERMSIG WUNTRACED W_OK X_OK _PC_CHOWN_RESTRICTED
+		  WTERMSIG WUNTRACED W_OK X_OK
+		  ULLONG_MAX LLONG_MAX LLONG_MIN _PC_CHOWN_RESTRICTED
 		  _PC_LINK_MAX _PC_MAX_CANON _PC_MAX_INPUT _PC_NAME_MAX
 		  _PC_NO_TRUNC _PC_PATH_MAX _PC_PIPE_BUF _PC_VDISABLE
 		  _POSIX_ARG_MAX _POSIX_CHILD_MAX _POSIX_CHOWN_RESTRICTED
@@ -115,5 +116,5 @@ while (my ($var, $expect) = each %expect) {
     my $have = *{$POSIX::{$var}}{ARRAY};
     cmp_ok(@$have, '==', @$expect,
 	   "Correct number of entries for \@POSIX::$var");
-    is_deeply([sort @$have], $expect, "Correct entries for \@POSIX::$var");
+    is_deeply([sort @$have], [sort @$expect], "Correct entries for \@POSIX::$var");
 }

--------------1.8.4--


@p5pRT
Copy link
Author

p5pRT commented Nov 11, 2013

From @tonycoz

On Sat Nov 09 05​:21​:34 2013, calid1984@​gmail.com wrote​:

This is a bug report for perl from calid1984@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.18.1.

Build on a 32-bit system without -Duse64bitint​:

[tony@​localhost perl]$ ./perl -Ilib -MPOSIX=​:limits_h -E 'say ULLONG_MAX'
-1
[tony@​localhost perl]$ ./perl -Ilib -MPOSIX=​:limits_h -E 'say LLONG_MAX'
-1
[tony@​localhost perl]$ ./perl -Ilib -MPOSIX=​:limits_h -E 'say LLONG_MIN'
0
[tony@​localhost perl]$ ./perl -Ilib -V​:longlongsize -V​:ivsize
longlongsize='8';
ivsize='4';

The constants should probably be returned as NVs when IV is too small.

Tony

@p5pRT
Copy link
Author

p5pRT commented Nov 11, 2013

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

@p5pRT
Copy link
Author

p5pRT commented Nov 11, 2013

From @bulk88

On Sun Nov 10 21​:04​:33 2013, tonyc wrote​:

Build on a 32-bit system without -Duse64bitint​:

[tony@​localhost perl]$ ./perl -Ilib -MPOSIX=​:limits_h -E 'say ULLONG_MAX'
-1
[tony@​localhost perl]$ ./perl -Ilib -MPOSIX=​:limits_h -E 'say LLONG_MAX'
-1
[tony@​localhost perl]$ ./perl -Ilib -MPOSIX=​:limits_h -E 'say LLONG_MIN'
0
[tony@​localhost perl]$ ./perl -Ilib -V​:longlongsize -V​:ivsize
longlongsize='8';
ivsize='4';

The constants should probably be returned as NVs when IV is too small.

Tony

Wouldnt PVs be more accurate than 2^53 NVs? If they are PVs, you can pass them to an extended precision overload library like Math​::Int64 without any precision loss.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Nov 11, 2013

From zefram@fysh.org

Tony Cook via RT wrote​:

The constants should probably be returned as NVs when IV is too small.

That won't work. The most common NV (especially with 32-bit IV) is
64-bit IEEE double, which can't exactly represent 2**63-1 (LLONG_MAX)
or 2**64-1 (ULLONG_MAX).

The constants could be represented as decimal strings, leaving it for
the user to arrange conversion to an appropriate type for arithmetic (or
Math​::Decimal can operate on the strings directly), though that would
catch many people out with implicit conversion to NV. Such confusion
could be avoided by returning the constants as bignums (Math​::BigInt),
but that would be a new dependency and would bring in surprising semantics
of its own. Or the constants could just be omitted.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Nov 13, 2013

From @tonycoz

On Mon Nov 11 04​:06​:11 2013, zefram@​fysh.org wrote​:

Tony Cook via RT wrote​:

The constants should probably be returned as NVs when IV is too small.

That won't work. The most common NV (especially with 32-bit IV) is
64-bit IEEE double, which can't exactly represent 2**63-1 (LLONG_MAX)
or 2**64-1 (ULLONG_MAX).

The constants could be represented as decimal strings, leaving it for
the user to arrange conversion to an appropriate type for arithmetic (or
Math​::Decimal can operate on the strings directly), though that would
catch many people out with implicit conversion to NV. Such confusion
could be avoided by returning the constants as bignums (Math​::BigInt),
but that would be a new dependency and would bring in surprising semantics
of its own. Or the constants could just be omitted.

Yes, you're right.

Also, ULLONG_MAX should be a UV not an IV, when UV/IV are large enough.

Tony

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2013

From calid1984@gmail.com

are one of you already working on this? would it be a duplication of
effort if I looked into how to do this?

On Tue, Nov 12, 2013 at 6​:29 PM, Tony Cook via RT <perlbug-followup@​perl.org

wrote​:

On Mon Nov 11 04​:06​:11 2013, zefram@​fysh.org wrote​:

Tony Cook via RT wrote​:

The constants should probably be returned as NVs when IV is too small.

That won't work. The most common NV (especially with 32-bit IV) is
64-bit IEEE double, which can't exactly represent 2**63-1 (LLONG_MAX)
or 2**64-1 (ULLONG_MAX).

The constants could be represented as decimal strings, leaving it for
the user to arrange conversion to an appropriate type for arithmetic (or
Math​::Decimal can operate on the strings directly), though that would
catch many people out with implicit conversion to NV. Such confusion
could be avoided by returning the constants as bignums (Math​::BigInt),
but that would be a new dependency and would bring in surprising
semantics
of its own. Or the constants could just be omitted.

Yes, you're right.

Also, ULLONG_MAX should be a UV not an IV, when UV/IV are large enough.

Tony

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2013

From @tonycoz

On Sat Nov 23 17​:18​:47 2013, calid1984@​gmail.com wrote​:

are one of you already working on this? would it be a duplication of
effort if I looked into how to do this?

I haven't spent any time on it, it's all yours.

Tony

@khwilliamson
Copy link
Contributor

Any progress on this? It appears to be stalled.

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

No branches or pull requests

3 participants