From 18770dac2e560c88daa3ca9944917be561c3548f Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 30 Jan 2011 00:58:45 +0000 Subject: Use __builtin_constant_p() to select the best byteswapping method: constant or target optimized. Same macro can then be used for constant values and inits as well as non-constant. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29171 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/aiff_enc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'apps/codecs/aiff_enc.c') diff --git a/apps/codecs/aiff_enc.c b/apps/codecs/aiff_enc.c index cfbc95196f..2d55dff755 100644 --- a/apps/codecs/aiff_enc.c +++ b/apps/codecs/aiff_enc.c @@ -56,15 +56,15 @@ struct aiff_header aiff_header = 0, /* form_size (*) */ { 'A', 'I', 'F', 'F' }, /* aiff_id */ { 'C', 'O', 'M', 'M' }, /* comm_id */ - H_TO_BE32(18), /* comm_size */ + htobe32(18), /* comm_size */ 0, /* num_channels (*) */ 0, /* num_sample_frames (*) */ - H_TO_BE16(PCM_DEPTH_BITS), /* sample_size */ + htobe16(PCM_DEPTH_BITS), /* sample_size */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* sample_rate (*) */ { 'S', 'S', 'N', 'D' }, /* ssnd_id */ 0, /* ssnd_size (*) */ - H_TO_BE32(0), /* offset */ - H_TO_BE32(0), /* block_size */ + htobe32(0), /* offset */ + htobe32(0), /* block_size */ }; /* (*) updated when finalizing file */ @@ -96,7 +96,10 @@ STATICIRAM void uint32_h_to_ieee754_extended_be(uint8_t f[10], uint32_t l) f[1] = (uint8_t)exp; /* mantissa is value left justified with most significant non-zero bit stored in bit 63 - bits 0-63 */ - *(uint32_t *)&f[2] = htobe32(l); + f[2] = (uint8_t)(l >> 24); + f[3] = (uint8_t)(l >> 16); + f[4] = (uint8_t)(l >> 8); + f[5] = (uint8_t)(l >> 0); } /* uint32_h_to_ieee754_extended_be */ /* called version often - inline */ -- cgit v1.2.3