This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In pp_pack.c, refactor DO_BO_(UN)?PACK to use my_letohn etc
authorNicholas Clark <nick@ccl4.org>
Mon, 6 May 2013 14:54:12 +0000 (16:54 +0200)
committerNicholas Clark <nick@ccl4.org>
Mon, 20 May 2013 19:19:43 +0000 (21:19 +0200)
Previously they were using a my_letoh* function for the appropriate size.

This commit probably breaks fixed 16 and 32 bit templates on big endian
Crays where sizeof(short) and sizeof(int) are 8. A future commit will
restore support. (Although it's not clear whether such Crays can still
build blead cleanly, as we've not had any feedback since Boeing
decommissioned their Cray.)

pp_pack.c

index 2967598..8e08c0c 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -242,14 +242,14 @@ S_mul128(pTHX_ SV *sv, U8 m)
 # define DO_BO_UNPACK(var, type)                                              \
         STMT_START {                                                          \
           if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) {          \
-            var = my_letoh ## type (var);                                     \
+            my_letohn(&var, sizeof(var));                                     \
           }                                                                   \
         } STMT_END
 
 # define DO_BO_PACK(var, type)                                                \
         STMT_START {                                                          \
           if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_LITTLE_ENDIAN) {          \
-            var = my_htole ## type (var);                                     \
+            my_htolen(&var, sizeof(var));                                     \
           }                                                                   \
         } STMT_END
 
@@ -286,14 +286,14 @@ S_mul128(pTHX_ SV *sv, U8 m)
 # define DO_BO_UNPACK(var, type)                                              \
         STMT_START {                                                          \
           if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) {             \
-            var = my_betoh ## type (var);                                     \
+            my_betohn(&var, sizeof(var));                                     \
           }                                                                   \
         } STMT_END
 
 # define DO_BO_PACK(var, type)                                                \
         STMT_START {                                                          \
           if (TYPE_ENDIANNESS(datumtype) == TYPE_IS_BIG_ENDIAN) {             \
-            var = my_htobe ## type (var);                                     \
+            my_htoben(&var, sizeof(var));                                     \
           }                                                                   \
         } STMT_END