# New Ticket Created by Jarkko Hietaniemi # Please include the string: [perl #30995] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=30995 >
Anyone who thinks sizeof(int) == sizeof(long) == sizeof(*) should now as a penance run ten times around the building, backwards. Anyone who thinks one can dereference unaligned pointers must do twenty. Anyone who thinks that C char is always signed should do five. The unmanagedstruct tried to dereference unaligned pointers. (a) in unmanagedstruct.pmc fixed ret_int to align properly (the main thing was to separate INTVAL and int cases, but I added some other types while I was at it) (b) config.h.in: added SHORT_SIZE and INT_SIZE to support (a) (c) nci.t: the test assumed that (char)(3*64) would be -64 and therefore explicitly abs()ed the result - that the result would be 192 was not expected at all. (d) pdd16_native_call.pod: added a note about signedness of the C char. Not that anyone ever reads documentation. -- Jarkko Hietaniemi <[EMAIL PROTECTED]> http://www.iki.fi/jhi/ "There is this special biologist word we use for 'stable'. It is 'dead'." -- Jack Cohen
--- config/gen/config_h/config_h.in 2004-04-13 17:18:20.000000000 +0300 +++ ../parrot-nci/config/gen/config_h/config_h.in 2004-08-08 19:06:23.000000000 +0300 @@ -65,6 +65,8 @@ #define NUMVAL_SIZE ${nvsize} #define OPCODE_T_SIZE ${opcode_t_size} #define PTR_SIZE ${ptrsize} +#define SHORT_SIZE ${shortsize} +#define INT_SIZE ${intsize} #define LONG_SIZE ${longsize} #define HUGEINTVAL_SIZE ${hugeintvalsize} --- t/pmc/nci.t 2004-07-20 09:28:32.000000000 +0300 +++ ../parrot-nci/t/pmc/nci.t 2004-08-08 15:02:34.000000000 +0300 @@ -12,8 +12,8 @@ =head1 DESCRIPTION -Tests the NCI PMC. These are all skipped unless JIT CPU architecture is -i386 and the F<libnci.so> library is found. +Tests the NCI PMC. These are all skipped unless the F<libnci.so> +library is found. =cut @@ -174,11 +174,10 @@ dlfunc P0, P1, "nci_csc", "csc" print "dlfunced\n" set I0, 1 # prototype used - unchecked - set I5, 64 - set I6, 3 + set I5, 6 + set I6, 7 invoke - abs I5 # 3 * 64 as char may be signed/unsigned - ne I5, 64, nok_1 + ne I5, 42, nok_1 print "ok 1\n" ne I0, 0, nok_2 # test return value convention ne I1, 1, nok_2 @@ -192,6 +191,16 @@ print "\n" end nok_2: print "nok 2\n" + print I0 + print "\n" + print I1 + print "\n" + print I2 + print "\n" + print I3 + print "\n" + print I4 + print "\n" end CODE loaded --- docs/pdds/pdd16_native_call.pod 2004-07-20 09:26:49.000000000 +0300 +++ ../parrot-nci/docs/pdds/pdd16_native_call.pod 2004-08-08 15:20:59.000000000 +0300 @@ -62,18 +62,23 @@ =item c Char. This is an integer type, taken from (or put into) an I register. +NOTE: it might be signed or unsigned because that is how an unadorned +C 'char' works. =item s -short. An integer type, taken from or put into an I register +short. An integer type, taken from or put into an I register. +It is always signed, not unsigned. =item i int. An integer type. +It is always signed, not unsigned. =item l long. An integer type. You know the drill. +It is always signed, not unsigned. =item f --- classes/unmanagedstruct.pmc 2004-07-29 22:02:05.000000000 +0300 +++ ../parrot-nci/classes/unmanagedstruct.pmc 2004-08-08 19:24:42.000000000 +0300 @@ -214,10 +214,33 @@ { switch (type) { case enum_type_INTVAL: - case enum_type_int: return *(INTVAL*) p; +#if INT_SIZE == 4 + case enum_type_int32: + case enum_type_uint32: +#endif +#if INT_SIZE == 8 + case enum_type_int64: + case enum_type_uint64: +#endif + case enum_type_int: + return *(int*) p; +#if LONG_SIZE == 4 + case enum_type_int32: + case enum_type_uint32: +#endif +#if LONG_SIZE == 8 + case enum_type_int64: + case enum_type_uint64: +#endif + case enum_type_long: + case enum_type_ulong: + return *(long*) p; +#if SHORT_SIZE == 2 case enum_type_int16: case enum_type_uint16: +#endif + /* If SHORT_SIZE != 2 getting int16s requires extra tricks. */ case enum_type_short: return *(short*) p; case enum_type_uint8: