Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^6: Module for 128-bit integer math?

by syphilis (Archbishop)
on Feb 09, 2011 at 08:45 UTC ( [id://887153]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Module for 128-bit integer math?
in thread Module for 128-bit integer math?

I have just uploaded Math::Int128 to CPAN

Just tried building it using the mingw64 compiler, and it failed spectacularly. I speculate that this is a shortcoming of the compiler ... though it does have the 16 byte __int128 data type. However, the __int128 data type appears to be a signed value only.
The "unsigned __int128" is, afaict, an unknown type and, I suspect, the cause of the errors reproduced below.

Trying to determine sizeof(unsigned __int128) in a C program produces the compile-time error:
expected ')' before '__int128'

Salva, let me know if there's any point in following this further with that compiler, and I'll certainly try to work through it. Here's what I get when running dmake (x64 build of perl-5.12.0):
C:\sis\Math-Int128-0.01>dmake test cp lib/Math/Int128.pm blib\lib\Math\Int128.pm C:\_64\perl512_M\bin\perl.exe C:\_64\perl512_M\lib\ExtUtils\xsubpp -t +ypemap C:\ _64\perl512_M\lib\ExtUtils\typemap Int128.xs > Int128.xsc && C:\_64\p +erl512_M\b in\perl.exe -MExtUtils::Command -e "mv" -- Int128.xsc Int128.c x86_64-w64-mingw32-gcc -c -I. -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DWIN +64 -DCONSE RVATIVE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasi +ng -mms-bi tfields -DPERL_MSVCRT_READFIX -g -O0 -DVERSION=\"0.01\" -DXS_V +ERSION=\"0 .01\" "-IC:\_64\perl512_M\lib\CORE" Int128.c Int128.xs:15:27: error: expected '=', ',', ';', 'asm' or '__attribute_ +_' before 'uint128_t' Int128.xs:63:17: error: expected declaration specifiers or '...' befor +e 'uint128 _t' Int128.xs: In function 'newSVu128': Int128.xs:66:22: error: 'u128' undeclared (first use in this function) Int128.xs:66:22: note: each undeclared identifier is reported only onc +e for each function it appears in Int128.xs: At top level: Int128.xs:99:1: error: expected '=', ',', ';', 'asm' or '__attribute__ +' before ' atoa128' Int128.xs:169:1: error: expected '=', ',', ';', 'asm' or '__attribute_ +_' before 'SvU128' Int128.xs: In function 'su128_to_number': Int128.xs:210:5: error: 'uint128_t' undeclared (first use in this func +tion) Int128.xs:210:15: error: expected ';' before 'u128' Int128.xs:212:10: error: 'u128' undeclared (first use in this function +) Int128.xs: At top level: Int128.xs:221:26: error: expected ')' before 'u128' Int128.xs:247:23: error: expected ')' before 'i128' Int128.xs: In function 'XS_Math__Int128_uint128': Int128.xs:274:5: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__Int128_net_to_uint128': Int128.xs:333:55: error: 'uint128_t' undeclared (first use in this fun +ction) Int128.xs:333:65: error: expected ')' before 'pv' Int128.xs:334:65: error: expected ')' before 'pv' Int128.xs:335:63: error: expected ')' before 'pv' Int128.xs:336:61: error: expected ')' before 'pv' Int128.xs:337:59: error: expected ')' before 'pv' Int128.xs:338:57: error: expected ')' before 'pv' Int128.xs:339:55: error: expected ')' before 'pv' Int128.xs:340:53: error: expected ')' before 'pv' Int128.xs:341:51: error: expected ')' before 'pv' Int128.xs:342:49: error: expected ')' before 'pv' Int128.xs:343:47: error: expected ')' before 'pv' Int128.xs:344:45: error: expected ')' before 'pv' Int128.xs:345:43: error: expected ')' before 'pv' Int128.xs:346:41: error: expected ')' before 'pv' Int128.xs:347:39: error: expected ')' before 'pv' Int128.xs:348:37: error: expected ')' before 'pv' Int128.xs:348:37: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__Int128_uint128_to_net': Int128.xs:375:5: error: 'uint128_t' undeclared (first use in this func +tion) Int128.xs:375:15: error: expected ';' before 'u128' Int128.xs:383:36: error: 'u128' undeclared (first use in this function +) Int128.xs: In function 'XS_Math__Int128_native_to_uint128': Int128.xs:411:5: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__Int128_uint128_to_native': Int128.xs:437:5: error: 'uint128_t' undeclared (first use in this func +tion) Int128.xs:437:15: error: expected ';' before 'u128' Int128.xs:443:5: error: 'u128' undeclared (first use in this function) Int128.xs: In function 'XS_Math__Int128_uint128_to_hex': Int128.xs:453:5: error: 'uint128_t' undeclared (first use in this func +tion) Int128.xs:453:15: error: expected ';' before 'u128' Int128.xs:459:17: error: 'u128' undeclared (first use in this function +) Int128.xs: In function 'XS_Math__Int128__left': Int128.xs:623:9: error: 'uint128_t' undeclared (first use in this func +tion) Int128.xs:623:19: error: expected ';' before 'b' Int128.xs:626:13: error: 'b' undeclared (first use in this function) Int128.xs:635:19: error: expected ';' before 'b' Int128.xs: In function 'XS_Math__Int128__right': Int128.xs:652:9: error: 'uint128_t' undeclared (first use in this func +tion) Int128.xs:652:19: error: expected ';' before 'b' Int128.xs:655:13: error: 'b' undeclared (first use in this function) Int128.xs:664:19: error: expected ';' before 'b' Int128.xs: In function 'XS_Math__UInt128__add': Int128.xs:938:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__sub': Int128.xs:957:27: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__mul': Int128.xs:973:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__div': Int128.xs:988:5: error: 'uint128_t' undeclared (first use in this func +tion) Int128.xs:988:15: error: expected ';' before 'up' Int128.xs:989:15: error: expected ';' before 'down' Int128.xs:993:13: error: 'up' undeclared (first use in this function) Int128.xs:994:13: error: 'down' undeclared (first use in this function +) Int128.xs:1002:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__remainder': Int128.xs:1021:5: error: 'uint128_t' undeclared (first use in this fun +ction) Int128.xs:1021:15: error: expected ';' before 'up' Int128.xs:1022:15: error: expected ';' before 'down' Int128.xs:1026:13: error: 'up' undeclared (first use in this function) Int128.xs:1027:13: error: 'down' undeclared (first use in this functio +n) Int128.xs:1035:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__left': Int128.xs:1054:9: error: 'uint128_t' undeclared (first use in this fun +ction) Int128.xs:1054:19: error: expected ';' before 'a' Int128.xs:1056:13: error: 'a' undeclared (first use in this function) Int128.xs:1057:13: error: 'b' undeclared (first use in this function) Int128.xs:1063:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__right': Int128.xs:1082:9: error: 'uint128_t' undeclared (first use in this fun +ction) Int128.xs:1082:19: error: expected ';' before 'a' Int128.xs:1084:13: error: 'a' undeclared (first use in this function) Int128.xs:1085:13: error: 'b' undeclared (first use in this function) Int128.xs:1091:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs:1094:19: error: expected ';' before 'b' Int128.xs: In function 'XS_Math__UInt128__spaceship': Int128.xs:1111:5: error: 'uint128_t' undeclared (first use in this fun +ction) Int128.xs:1111:15: error: expected ';' before 'left' Int128.xs:1112:15: error: expected ';' before 'right' Int128.xs:1115:9: error: 'left' undeclared (first use in this function +) Int128.xs:1116:9: error: 'right' undeclared (first use in this functio +n) Int128.xs: In function 'XS_Math__UInt128__and': Int128.xs:1209:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__or': Int128.xs:1225:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__xor': Int128.xs:1241:9: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__bnot': Int128.xs:1266:5: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__neg': Int128.xs:1276:5: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here Int128.xs: In function 'XS_Math__UInt128__clone': Int128.xs:1306:5: error: too many arguments to function 'newSVu128' Int128.xs:63:1: note: declared here dmake: Error code 129, while making 'Int128.o'
Cheers,
Rob

Replies are listed 'Best First'.
Re^7: Module for 128-bit integer math?
by salva (Canon) on Feb 09, 2011 at 09:33 UTC
    Probably the version of GCC you are using is not recent enough.

    What do you get when you run...?

    x86_64-w64-mingw32-gcc --version
      I get:
      C:\>x86_64-w64-mingw32-gcc --version x86_64-w64-mingw32-gcc (GCC) 4.6.0 20100414 (experimental) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There i +s NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR +POSE. C:\>
      Update: But, in addition to the version number, there's also the consideration of what features have been ported to MinGW.

      Cheers,
      Rob
        Your compiler is almost one year old. Support for unsigned __int128 types was probably not yet implemented.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://887153]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found