Use get16, get32, put16, and put32 instead of direct casting pointer
authordrepper <drepper>
Tue, 28 Mar 2000 17:27:37 +0000 (17:27 +0000)
committerdrepper <drepper>
Tue, 28 Mar 2000 17:27:37 +0000 (17:27 +0000)
to potentially handle unaligned memory accesses.

21 files changed:
iconvdata/8bit-gap.c
iconvdata/8bit-generic.c
iconvdata/ansi_x3.110.c
iconvdata/big5.c
iconvdata/euc-cn.c
iconvdata/euc-jp.c
iconvdata/euc-kr.c
iconvdata/euc-tw.c
iconvdata/gbk.c
iconvdata/iso-2022-cn.c
iconvdata/iso-2022-jp.c
iconvdata/iso-2022-kr.c
iconvdata/iso646.c
iconvdata/iso_6937-2.c
iconvdata/iso_6937.c
iconvdata/johab.c
iconvdata/sjis.c
iconvdata/t.61.c
iconvdata/uhc.c
iconvdata/unicode.c
iconvdata/utf-16.c

index 5ab2975..b633c47 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic conversion to and from 8bit charsets,
    converting from UCS using gaps.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -55,7 +55,8 @@ struct gap
        break;                                                                \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
     ++inptr;                                                                 \
   }
 #include <iconv/loop.c>
@@ -68,7 +69,7 @@ struct gap
 #define BODY \
   {                                                                          \
     const struct gap *rp = from_idx;                                         \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     unsigned char res;                                                       \
                                                                              \
     if (ch >= 0xffff)                                                        \
index bd9da7a..3543bdf 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic conversion to and from 8bit charsets.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -41,7 +41,8 @@
        break;                                                                \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
     ++inptr;                                                                 \
   }
 #include <iconv/loop.c>
@@ -53,7 +54,7 @@
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
                                                                              \
     if (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0])                     \
        || (ch != 0 && from_ucs4[ch] == '\0'))                                \
index 35658b5..1dd214b 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic conversion to and from ANSI_X3.110-1983.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -441,7 +441,8 @@ static const char from_ucs4[][2] =
       }                                                                              \
                                                                              \
     inptr += incr;                                                           \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -454,7 +455,7 @@ static const char from_ucs4[][2] =
 #define BODY \
   {                                                                          \
     char tmp[2];                                                             \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     const char *cp;                                                          \
                                                                              \
     if (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]))                    \
index 5551bba..42d59c3 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for Big5 handling.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -8475,7 +8475,8 @@ static const char from_ucs4_tab13[][2] =
     else                                                                     \
       ++inptr;                                                               \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    putr32 (outptr, ch);                                                     \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -8487,7 +8488,7 @@ static const char from_ucs4_tab13[][2] =
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     char buf[2];                                                             \
     const char *cp;                                                          \
                                                                              \
index da10cdc..61601e7 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for EUC-CN handling.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -88,7 +88,8 @@
          inptr += 2;                                                         \
        }                                                                     \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
                                                                              \
     if (ch <= L'\x7f')                                                       \
       /* It's plain ASCII.  */                                               \
index 3d97c01..2c25d7a 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for EUC-JP handling.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
          }                                                                   \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
                                                                              \
     if (ch <= 0x7f)                                                          \
       /* It's plain ASCII.  */                                               \
index f74d774..19516b6 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for EUC-KR handling.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jungshik Shin <jshin@pantheon.yale.edu>
    and Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -104,7 +104,8 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
          }                                                                   \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -116,7 +117,7 @@ euckr_from_ucs4 (uint32_t ch, unsigned char *cp)
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     unsigned char cp[2];                                                     \
                                                                              \
     /* Decomposing Hangul syllables not available in KS C 5601 into          \
index 036baae..a508c84 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for EUC-TW handling.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
          }                                                                   \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
                                                                              \
     if (ch <= 0x7f)                                                          \
       /* It's plain ASCII.  */                                               \
index 45bfcbc..9956ea3 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for GBK handling.
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Sean Chen <sean.chen@turbolinux.com>, 1999.
 
@@ -13167,7 +13167,8 @@ static const char __gbk_from_ucs4_tab12[][2] =
          inptr += 2;                                                         \
        }                                                                     \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -13179,7 +13180,7 @@ static const char __gbk_from_ucs4_tab12[][2] =
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     unsigned char buf[2];                                                    \
     const unsigned char *cp = buf;                                           \
                                                                              \
index 563d173..1b0eefb 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion module for ISO-2022-CN.
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -221,7 +221,8 @@ enum
          }                                                                   \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #define EXTRA_LOOP_DECLS       , int *setp
 #define INIT_PARAMS            int set = *setp & CURRENT_MASK; \
@@ -240,7 +241,7 @@ enum
     uint32_t ch;                                                             \
     size_t written = 0;                                                              \
                                                                              \
-    ch = *((uint32_t *) inptr);                                                      \
+    ch = get32 (inptr);                                                              \
                                                                              \
     /* First see whether we can write the character using the currently              \
        selected character set.  */                                           \
index a3c9f7d..decb6c1 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion module for ISO-2022-JP.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -436,7 +436,8 @@ gconv_end (struct __gconv_step *data)
          }                                                                   \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #define EXTRA_LOOP_DECLS       , enum variant var, int *setp
 #define INIT_PARAMS            int set = *setp % 0x100, set2 = *setp / 0x100
@@ -454,7 +455,7 @@ gconv_end (struct __gconv_step *data)
     uint32_t ch;                                                             \
     size_t written = 0;                                                              \
                                                                              \
-    ch = *((uint32_t *) inptr);                                                      \
+    ch = get32 (inptr);                                                              \
                                                                              \
     /* First see whether we can write the character using the currently              \
        selected character set.  */                                           \
index 8ed5d21..ea03353 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion module for ISO-2022-KR.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -189,7 +189,8 @@ enum
          }                                                                   \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #define EXTRA_LOOP_DECLS       , int *setp
 #define INIT_PARAMS            int set = *setp
@@ -207,7 +208,7 @@ enum
     uint32_t ch;                                                             \
     size_t written = 0;                                                              \
                                                                              \
-    ch = *((uint32_t *) inptr);                                                      \
+    ch = get32 (inptr);                                                              \
                                                                              \
     /* First see whether we can write the character using the currently              \
        selected character set.  */                                           \
index 5b2ba72..c8d0a02 100644 (file)
@@ -1,5 +1,5 @@
 /* Conversion to and from the various ISO 646 CCS.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -410,7 +410,8 @@ gconv_end (struct __gconv_step *data)
        result = failure;                                                     \
        break;                                                                \
       }                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
     ++inptr;                                                                 \
   }
 #define EXTRA_LOOP_DECLS       , enum variant var
@@ -426,7 +427,7 @@ gconv_end (struct __gconv_step *data)
     unsigned char ch;                                                        \
     int failure = __GCONV_OK;                                                \
                                                                              \
-    ch = *((uint32_t *) inptr);                                                      \
+    ch = get32 (inptr);                                                              \
     switch (*((uint32_t *) inptr))                                           \
       {                                                                              \
       case 0x23:                                                             \
index 1ec0976..a688b7c 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic conversion to and from ISO 6937-2.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -446,7 +446,8 @@ static const char from_ucs4[][2] =
        ++inptr;                                                              \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -459,7 +460,7 @@ static const char from_ucs4[][2] =
 #define BODY \
   {                                                                          \
     char tmp[2];                                                             \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     const char *cp;                                                          \
                                                                              \
     if (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]))                    \
index ca4ab0f..81e5d0c 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic conversion to and from ISO 6937.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -438,7 +438,8 @@ static const char from_ucs4[][2] =
        ++inptr;                                                              \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -451,7 +452,7 @@ static const char from_ucs4[][2] =
 #define BODY \
   {                                                                          \
     char tmp[2];                                                             \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     const char *cp;                                                          \
                                                                              \
     if (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]))                    \
index 4cff932..1822b0d 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for JOHAB handling.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jungshik Shin <jshin@pantheon.yale.edu>
    and Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -274,7 +274,8 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
        inptr += 2;                                                           \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -286,7 +287,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     /*                                                                       \
        if (ch >= (sizeof (from_ucs4_lat1) / sizeof (from_ucs4_lat1[0])))      \
         {                                                                    \
index d18ab9b..4ca7ce9 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for SJIS handling.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -4410,7 +4410,8 @@ static const char from_ucs4_extra[0x100][2] =
          }                                                                   \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -4422,7 +4423,7 @@ static const char from_ucs4_extra[0x100][2] =
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     const char *cp;                                                          \
                                                                              \
     if (ch >= (sizeof (from_ucs4_lat1) / sizeof (from_ucs4_lat1[0])))        \
index 2b8d896..10a52a1 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic conversion to and from T.61.
-   Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -422,7 +422,8 @@ static const char from_ucs4[][2] =
        break;                                                                \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -435,7 +436,7 @@ static const char from_ucs4[][2] =
 #define BODY \
   {                                                                          \
     char tmp[2];                                                             \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
     const char *cp;                                                          \
                                                                              \
     if (ch >= sizeof (from_ucs4) / sizeof (from_ucs4[0]))                    \
index ac4be8a..e42cb2e 100644 (file)
@@ -1,5 +1,5 @@
 /* Mapping tables for UHC handling.
-   Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jungshik Shin <jshin@pantheon.yale.edu>, 1998.
 
@@ -3140,7 +3140,8 @@ static const char uhc_hangul_from_ucs[11172][2] =
          }                                                                   \
       }                                                                              \
                                                                              \
-    *((uint32_t *) outptr)++ = ch;                                           \
+    put32 (outptr, ch);                                                              \
+    outptr += 4;                                                             \
   }
 #include <iconv/loop.c>
 
@@ -3152,7 +3153,7 @@ static const char uhc_hangul_from_ucs[11172][2] =
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t ch = *((uint32_t *) inptr);                                     \
+    uint32_t ch = get32 (inptr);                                             \
                                                                              \
     if (ch < 0x7f)                                                           \
       /* XXX Think about 0x5c ; '\'.  */                                     \
index b29976b..0db7a01 100644 (file)
          if (inptr + 2 > inbufend)                                           \
            return __GCONV_EMPTY_INPUT;                                       \
                                                                              \
-         if (*(uint16_t *) inptr == BOM)                                     \
+         if (get16u (inptr) == BOM)                                          \
            /* Simply ignore the BOM character.  */                           \
            inptr += 2;                                                       \
-         else if (*(uint16_t *) inptr == BOM_OE)                             \
+         else if (get16u (inptr) == BOM_OE)                                  \
            {                                                                 \
              ((struct unicode_data *) step->__data)->swap = 1;               \
              inptr += 2;                                                     \
@@ -66,7 +66,7 @@
       if (outbuf + 2 > outend)                                               \
        return __GCONV_FULL_OUTPUT;                                           \
                                                                              \
-      *(uint16_t *) outbuf = BOM;                                            \
+      put16u (outbuf, BOM);                                                  \
       outbuf += 2;                                                           \
     }                                                                        \
   swap = ((struct unicode_data *) step->__data)->swap;
@@ -147,7 +147,7 @@ gconv_end (struct __gconv_step *data)
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t c = *((uint32_t *) inptr);                                              \
+    uint32_t c = get32 (inptr);                                                      \
                                                                              \
     if (c >= 0x10000)                                                        \
       {                                                                              \
@@ -155,7 +155,7 @@ gconv_end (struct __gconv_step *data)
        break;                                                                \
       }                                                                              \
                                                                              \
-    *((uint16_t *) outptr) = c;                                                      \
+    put16 (outptr, c);                                                       \
                                                                              \
     outptr += 2;                                                             \
     inptr += 4;                                                                      \
@@ -171,12 +171,12 @@ gconv_end (struct __gconv_step *data)
 #define LOOPFCT                        FROM_LOOP
 #define BODY \
   {                                                                          \
-    uint16_t u1 = *(uint16_t *) inptr;                                       \
+    uint16_t u1 = get16 (inptr);                                             \
                                                                              \
     if (swap)                                                                \
       u1 = bswap_16 (u1);                                                    \
                                                                              \
-    *((uint32_t *) outptr) = u1;                                             \
+    put32 (outptr, u1);                                                              \
                                                                              \
     inptr += 2;                                                                      \
     outptr += 4;                                                             \
index c7e677e..b0b9c47 100644 (file)
          if (inptr + 2 > inbufend)                                           \
            return __GCONV_EMPTY_INPUT;                                       \
                                                                              \
-         if (*(uint16_t *) inptr == BOM)                                     \
+         if (get16u (inptr) == BOM)                                          \
            /* Simply ignore the BOM character.  */                           \
            inptr += 2;                                                       \
-         else if (*(uint16_t *) inptr == BOM_OE)                             \
+         else if (get16u (inptr) == BOM_OE)                                  \
            {                                                                 \
              ((struct utf16_data *) step->__data)->swap = 1;                 \
              inptr += 2;                                                     \
@@ -69,7 +69,7 @@
       if (outbuf + 2 > outend)                                               \
        return __GCONV_FULL_OUTPUT;                                           \
                                                                              \
-      *(uint16_t *) outbuf = BOM;                                            \
+      put16u (outbuf, BOM);                                                  \
       outbuf += 2;                                                           \
     }
 #define EXTRA_LOOP_ARGS                , var, data, swap
@@ -193,7 +193,7 @@ gconv_end (struct __gconv_step *data)
 #define LOOPFCT                        TO_LOOP
 #define BODY \
   {                                                                          \
-    uint32_t c = *((uint32_t *) inptr);                                              \
+    uint32_t c = get32 (inptr);                                                      \
                                                                              \
     if (swap)                                                                \
       {                                                                              \
@@ -213,12 +213,12 @@ gconv_end (struct __gconv_step *data)
                break;                                                        \
              }                                                               \
                                                                              \
-           *((uint16_t *) outptr) = bswap_16 (0xd7c0 + (c >> 10));           \
+           put16 (outptr, bswap_16 (0xd7c0 + (c >> 10)));                    \
            outptr += 2;                                                      \
-           *((uint16_t *) outptr) = bswap_16 (0xdc00 + (c & 0x3ff));         \
+           put16 (outptr, bswap_16 (0xdc00 + (c & 0x3ff)));                  \
          }                                                                   \
        else                                                                  \
-         *((uint16_t *) outptr) = bswap_16 (c);                              \
+         put16 (outptr, bswap_16 (c));                                       \
       }                                                                              \
     else                                                                     \
       {                                                                              \
@@ -238,12 +238,12 @@ gconv_end (struct __gconv_step *data)
                break;                                                        \
              }                                                               \
                                                                              \
-           *((uint16_t *) outptr) = 0xd7c0 + (c >> 10);                      \
+           put16 (outptr, 0xd7c0 + (c >> 10));                               \
            outptr += 2;                                                      \
-           *((uint16_t *) outptr) = 0xdc00 + (c & 0x3ff);                    \
+           put16 (outptr, 0xdc00 + (c & 0x3ff));                             \
          }                                                                   \
        else                                                                  \
-         *((uint16_t *) outptr) = c;                                         \
+         put16 (outptr, c);                                                  \
       }                                                                              \
     outptr += 2;                                                             \
     inptr += 4;                                                                      \
@@ -260,7 +260,7 @@ gconv_end (struct __gconv_step *data)
 #define LOOPFCT                        FROM_LOOP
 #define BODY \
   {                                                                          \
-    uint16_t u1 = *(uint16_t *) inptr;                                       \
+    uint16_t u1 = get16 (inptr);                                             \
                                                                              \
     if (swap)                                                                \
       {                                                                              \
@@ -269,7 +269,7 @@ gconv_end (struct __gconv_step *data)
        if (u1 < 0xd800 || u1 > 0xdfff)                                       \
          {                                                                   \
            /* No surrogate.  */                                              \
-           *((uint32_t *) outptr) = u1;                                      \
+           put32 (outptr, u1);                               \
            inptr += 2;                                                       \
          }                                                                   \
        else                                                                  \
@@ -286,16 +286,18 @@ gconv_end (struct __gconv_step *data)
                break;                                                        \
              }                                                               \
                                                                              \
-           u2 = bswap_16 (((uint16_t *) inptr)[1]);                          \
+           inptr += 2;                                                       \
+           u2 = bswap_16 (get16 (inptr));                                    \
            if (u2 < 0xdc00 || u2 >= 0xdfff)                                  \
              {                                                               \
                /* This is no valid second word for a surrogate.  */          \
                result = __GCONV_ILLEGAL_INPUT;                               \
+               inptr -= 2;                                                   \
                break;                                                        \
              }                                                               \
                                                                              \
-           *((uint32_t *) outptr) = ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00);   \
-           inptr += 4;                                                       \
+           put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00));            \
+           inptr += 2;                                                       \
          }                                                                   \
       }                                                                              \
     else                                                                     \
@@ -303,7 +305,7 @@ gconv_end (struct __gconv_step *data)
        if (u1 < 0xd800 || u1 > 0xdfff)                                       \
          {                                                                   \
            /* No surrogate.  */                                              \
-           *((uint32_t *) outptr) = u1;                                      \
+           put32 (outptr, u1);                                               \
            inptr += 2;                                                       \
          }                                                                   \
        else                                                                  \
@@ -320,16 +322,18 @@ gconv_end (struct __gconv_step *data)
                break;                                                        \
              }                                                               \
                                                                              \
-           u2 = ((uint16_t *) inptr)[1];                                     \
+           inptr += 2;                                                       \
+           u2 = get16 (inptr);                                               \
            if (u2 < 0xdc00 || u2 >= 0xdfff)                                  \
              {                                                               \
                /* This is no valid second word for a surrogate.  */          \
                result = __GCONV_ILLEGAL_INPUT;                               \
+               inptr -= 2;                                                   \
                break;                                                        \
              }                                                               \
                                                                              \
-           *((uint32_t *) outptr) = ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00);   \
-           inptr += 4;                                                       \
+           put32 (outptr, ((u1 - 0xd7c0) << 10) + (u2 - 0xdc00));            \
+           inptr += 2;                                                       \
          }                                                                   \
       }                                                                              \
     outptr += 4;                                                             \