diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-02-10 14:09:10 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2023-02-17 15:56:54 -0300 |
commit | 5729e0e9af590807df66a3db688008f9547bce9f (patch) | |
tree | b4f50ff2f122c75e0833ec18c7256afa2c4c1ab7 /iconv/loop.c | |
parent | 62d4c768a4df59e4381464385b3a7246e6df6661 (diff) | |
download | glibc-5729e0e9af590807df66a3db688008f9547bce9f.tar.gz glibc-5729e0e9af590807df66a3db688008f9547bce9f.tar.xz glibc-5729e0e9af590807df66a3db688008f9547bce9f.zip |
iconv: Remove _STRING_ARCH_unaligned usage for get/set macros
And use a packed structure instead. The compiler generates optimized unaligned code if the architecture supports it. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Diffstat (limited to 'iconv/loop.c')
-rw-r--r-- | iconv/loop.c | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/iconv/loop.c b/iconv/loop.c index 963c59ca9a..9d8a7cceb3 100644 --- a/iconv/loop.c +++ b/iconv/loop.c @@ -57,75 +57,10 @@ #include <stddef.h> #include <libc-diag.h> -/* We have to provide support for machines which are not able to handled - unaligned memory accesses. Some of the character encodings have - representations with a fixed width of 2 or 4 bytes. But if we cannot - access unaligned memory we still have to read byte-wise. */ #undef FCTNAME2 #if _STRING_ARCH_unaligned || !defined DEFINE_UNALIGNED -/* We can handle unaligned memory access. */ -# define get16(addr) *((const uint16_t *) (addr)) -# define get32(addr) *((const uint32_t *) (addr)) - -/* We need no special support for writing values either. */ -# define put16(addr, val) *((uint16_t *) (addr)) = (val) -# define put32(addr, val) *((uint32_t *) (addr)) = (val) - # define FCTNAME2(name) name #else -/* Distinguish between big endian and little endian. */ -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define get16(addr) \ - (((const unsigned char *) (addr))[1] << 8 \ - | ((const unsigned char *) (addr))[0]) -# define get32(addr) \ - (((((const unsigned char *) (addr))[3] << 8 \ - | ((const unsigned char *) (addr))[2]) << 8 \ - | ((const unsigned char *) (addr))[1]) << 8 \ - | ((const unsigned char *) (addr))[0]) - -# define put16(addr, val) \ - ({ uint16_t __val = (val); \ - ((unsigned char *) (addr))[0] = __val; \ - ((unsigned char *) (addr))[1] = __val >> 8; \ - (void) 0; }) -# define put32(addr, val) \ - ({ uint32_t __val = (val); \ - ((unsigned char *) (addr))[0] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[1] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[2] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[3] = __val; \ - (void) 0; }) -# else -# define get16(addr) \ - (((const unsigned char *) (addr))[0] << 8 \ - | ((const unsigned char *) (addr))[1]) -# define get32(addr) \ - (((((const unsigned char *) (addr))[0] << 8 \ - | ((const unsigned char *) (addr))[1]) << 8 \ - | ((const unsigned char *) (addr))[2]) << 8 \ - | ((const unsigned char *) (addr))[3]) - -# define put16(addr, val) \ - ({ uint16_t __val = (val); \ - ((unsigned char *) (addr))[1] = __val; \ - ((unsigned char *) (addr))[0] = __val >> 8; \ - (void) 0; }) -# define put32(addr, val) \ - ({ uint32_t __val = (val); \ - ((unsigned char *) (addr))[3] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[2] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[1] = __val; \ - __val >>= 8; \ - ((unsigned char *) (addr))[0] = __val; \ - (void) 0; }) -# endif - # define FCTNAME2(name) name##_unaligned #endif #define FCTNAME(name) FCTNAME2(name) @@ -349,10 +284,6 @@ FCTNAME (LOOPFCT) (struct __gconv_step *step, #if !defined DEFINE_UNALIGNED && !_STRING_ARCH_unaligned \ && MIN_NEEDED_INPUT != 1 && MAX_NEEDED_INPUT % MIN_NEEDED_INPUT == 0 \ && MIN_NEEDED_OUTPUT != 1 && MAX_NEEDED_OUTPUT % MIN_NEEDED_OUTPUT == 0 -# undef get16 -# undef get32 -# undef put16 -# undef put32 # undef unaligned # define DEFINE_UNALIGNED @@ -540,8 +471,4 @@ gconv_btowc (struct __gconv_step *step, unsigned char c) #undef LOOP_NEED_STATE #undef LOOP_NEED_FLAGS #undef LOOP_NEED_DATA -#undef get16 -#undef get32 -#undef put16 -#undef put32 #undef unaligned |