(linenum→info "unix/slp.c:2238")

glibc/2.7/iconv/skeleton.c

    1: /* Skeleton for a conversion module.
    2:    Copyright (C) 1998-2002, 2005 Free Software Foundation, Inc.
    3:    This file is part of the GNU C Library.
    4:    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
    5: 
    6:    The GNU C Library is free software; you can redistribute it and/or
    7:    modify it under the terms of the GNU Lesser General Public
    8:    License as published by the Free Software Foundation; either
    9:    version 2.1 of the License, or (at your option) any later version.
   10: 
   11:    The GNU C Library is distributed in the hope that it will be useful,
   12:    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14:    Lesser General Public License for more details.
   15: 
   16:    You should have received a copy of the GNU Lesser General Public
   17:    License along with the GNU C Library; if not, write to the Free
   18:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   19:    02111-1307 USA.  */
   20: 
   21: /* This file can be included to provide definitions of several things
   22:    many modules have in common.  It can be customized using the following
   23:    macros:
   24: 
   25:      DEFINE_INIT        define the default initializer.  This requires the
   26:                         following symbol to be defined.
   27: 
   28:      CHARSET_NAME       string with official name of the coded character
   29:                         set (in all-caps)
   30: 
   31:      DEFINE_FINI        define the default destructor function.
   32: 
   33:      MIN_NEEDED_FROM    minimal number of bytes needed for the from-charset.
   34:      MIN_NEEDED_TO      likewise for the to-charset.
   35: 
   36:      MAX_NEEDED_FROM    maximal number of bytes needed for the from-charset.
   37:                         This macro is optional, it defaults to MIN_NEEDED_FROM.
   38:      MAX_NEEDED_TO      likewise for the to-charset.
   39: 
   40:      FROM_LOOP_MIN_NEEDED_FROM
   41:      FROM_LOOP_MAX_NEEDED_FROM
   42:                         minimal/maximal number of bytes needed on input
   43:                         of one round through the FROM_LOOP.  Defaults
   44:                         to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively.
   45:      FROM_LOOP_MIN_NEEDED_TO
   46:      FROM_LOOP_MAX_NEEDED_TO
   47:                         minimal/maximal number of bytes needed on output
   48:                         of one round through the FROM_LOOP.  Defaults
   49:                         to MIN_NEEDED_TO and MAX_NEEDED_TO, respectively.
   50:      TO_LOOP_MIN_NEEDED_FROM
   51:      TO_LOOP_MAX_NEEDED_FROM
   52:                         minimal/maximal number of bytes needed on input
   53:                         of one round through the TO_LOOP.  Defaults
   54:                         to MIN_NEEDED_TO and MAX_NEEDED_TO, respectively.
   55:      TO_LOOP_MIN_NEEDED_TO
   56:      TO_LOOP_MAX_NEEDED_TO
   57:                         minimal/maximal number of bytes needed on output
   58:                         of one round through the TO_LOOP.  Defaults
   59:                         to MIN_NEEDED_FROM and MAX_NEEDED_FROM, respectively.
   60: 
   61:      FROM_DIRECTION     this macro is supposed to return a value != 0
   62:                         if we convert from the current character set,
   63:                         otherwise it return 0.
   64: 
   65:      EMIT_SHIFT_TO_INIT this symbol is optional.  If it is defined it
   66:                         defines some code which writes out a sequence
   67:                         of bytes which bring the current state into
   68:                         the initial state.
   69: 
   70:      FROM_LOOP          name of the function implementing the conversion
   71:                         from the current character set.
   72:      TO_LOOP            likewise for the other direction
   73: 
   74:      ONE_DIRECTION      optional.  If defined to 1, only one conversion
   75:                         direction is defined instead of two.  In this
   76:                         case, FROM_DIRECTION should be defined to 1, and
   77:                         FROM_LOOP and TO_LOOP should have the same value.
   78: 
   79:      SAVE_RESET_STATE   in case of an error we must reset the state for
   80:                         the rerun so this macro must be defined for
   81:                         stateful encodings.  It takes an argument which
   82:                         is nonzero when saving.
   83: 
   84:      RESET_INPUT_BUFFER If the input character sets allow this the macro
   85:                         can be defined to reset the input buffer pointers
   86:                         to cover only those characters up to the error.
   87: 
   88:      FUNCTION_NAME      if not set the conversion function is named `gconv'.
   89: 
   90:      PREPARE_LOOP       optional code preparing the conversion loop.  Can
   91:                         contain variable definitions.
   92:      END_LOOP           also optional, may be used to store information
   93: 
   94:      EXTRA_LOOP_ARGS    optional macro specifying extra arguments passed
   95:                         to loop function.
   96: 
   97:      STORE_REST         optional, needed only when MAX_NEEDED_FROM > 4.
   98:                         This macro stores the seen but unconverted input bytes
   99:                         in the state.
  100: 
  101:      FROM_ONEBYTE       optional.  If defined, should be the name of a
  102:                         specialized conversion function for a single byte
  103:                         from the current character set to INTERNAL.  This
  104:                         function has prototype
  105:                            wint_t
  106:                            FROM_ONEBYTE (struct __gconv_step *, unsigned char);
  107:                         and does a special conversion:
  108:                         - The input is a single byte.
  109:                         - The output is a single uint32_t.
  110:                         - The state before the conversion is the initial state;
  111:                           the state after the conversion is irrelevant.
  112:                         - No transliteration.
  113:                         - __invocation_counter = 0.
  114:                         - __internal_use = 1.
  115:                         - do_flush = 0.
  116: 
  117:    Modules can use mbstate_t to store conversion state as follows:
  118: 
  119:    * Bits 2..0 of '__count' contain the number of lookahead input bytes
  120:      stored in __value.__wchb.  Always zero if the converter never
  121:      returns __GCONV_INCOMPLETE_INPUT.
  122: 
  123:    * Bits 31..3 of '__count' are module dependent shift state.
  124: 
  125:    * __value: When STORE_REST/UNPACK_BYTES aren't defined and when the
  126:      converter has returned __GCONV_INCOMPLETE_INPUT, this contains
  127:      at most 4 lookahead bytes. Converters with an mb_cur_max > 4
  128:      (currently only UTF-8) must find a way to store their state
  129:      in __value.__wch and define STORE_REST/UNPACK_BYTES appropriately.
  130: 
  131:    When __value contains lookahead, __count must not be zero, because
  132:    the converter is not in the initial state then, and mbsinit() --
  133:    defined as a (__count == 0) test -- must reflect this.
  134:  */
  135: 
  136: #include <assert.h>
  137: #include <gconv.h>
  138: #include <string.h>
  139: #define __need_size_t
  140: #define __need_NULL
  141: #include <stddef.h>
  142: 
  143: #ifndef STATIC_GCONV
  144: # include <dlfcn.h>
  145: #endif
  146: 
  147: #include <sysdep.h>
  148: 
  149: #ifndef DL_CALL_FCT
  150: # define DL_CALL_FCT(fct, args) fct args
  151: #endif
  152: 
  153: /* The direction objects.  */
  154: #if DEFINE_INIT
  155: # ifndef FROM_DIRECTION
  156: #  define FROM_DIRECTION_VAL NULL
  157: #  define TO_DIRECTION_VAL ((void *) ~((uintptr_t) 0))
  158: #  define FROM_DIRECTION (step->__data == FROM_DIRECTION_VAL)
  159: # endif
  160: #else
  161: # ifndef FROM_DIRECTION
  162: #  error "FROM_DIRECTION must be provided if non-default init is used"
  163: # endif
  164: #endif
  165: 
  166: 
  167: /* How many bytes are needed at most for the from-charset.  */
  168: #ifndef MAX_NEEDED_FROM
  169: # define MAX_NEEDED_FROM        MIN_NEEDED_FROM
  170: #endif
  171: 
  172: /* Same for the to-charset.  */
  173: #ifndef MAX_NEEDED_TO
  174: # define MAX_NEEDED_TO          MIN_NEEDED_TO
  175: #endif
  176: 
  177: /* Defaults for the per-direction min/max constants.  */
  178: #ifndef FROM_LOOP_MIN_NEEDED_FROM
  179: # define FROM_LOOP_MIN_NEEDED_FROM      MIN_NEEDED_FROM
  180: #endif
  181: #ifndef FROM_LOOP_MAX_NEEDED_FROM
  182: # define FROM_LOOP_MAX_NEEDED_FROM      MAX_NEEDED_FROM
  183: #endif
  184: #ifndef FROM_LOOP_MIN_NEEDED_TO
  185: # define FROM_LOOP_MIN_NEEDED_TO        MIN_NEEDED_TO
  186: #endif
  187: #ifndef FROM_LOOP_MAX_NEEDED_TO
  188: # define FROM_LOOP_MAX_NEEDED_TO        MAX_NEEDED_TO
  189: #endif
  190: #ifndef TO_LOOP_MIN_NEEDED_FROM
  191: # define TO_LOOP_MIN_NEEDED_FROM        MIN_NEEDED_TO
  192: #endif
  193: #ifndef TO_LOOP_MAX_NEEDED_FROM
  194: # define TO_LOOP_MAX_NEEDED_FROM        MAX_NEEDED_TO
  195: #endif
  196: #ifndef TO_LOOP_MIN_NEEDED_TO
  197: # define TO_LOOP_MIN_NEEDED_TO          MIN_NEEDED_FROM
  198: #endif
  199: #ifndef TO_LOOP_MAX_NEEDED_TO
  200: # define TO_LOOP_MAX_NEEDED_TO          MAX_NEEDED_FROM
  201: #endif
  202: 
  203: 
  204: /* Define macros which can access unaligned buffers.  These macros are
  205:    supposed to be used only in code outside the inner loops.  For the inner
  206:    loops we have other definitions which allow optimized access.  */
  207: #ifdef _STRING_ARCH_unaligned
  208: /* We can handle unaligned memory access.  */
  209: # define get16u(addr) *((__const uint16_t *) (addr))
  210: # define get32u(addr) *((__const uint32_t *) (addr))
  211: 
  212: /* We need no special support for writing values either.  */
  213: # define put16u(addr, val) *((uint16_t *) (addr)) = (val)
  214: # define put32u(addr, val) *((uint32_t *) (addr)) = (val)
  215: #else
  216: /* Distinguish between big endian and little endian.  */
  217: # if __BYTE_ORDER == __LITTLE_ENDIAN
  218: #  define get16u(addr) \
  219:      (((__const unsigned char *) (addr))[1] << 8                              \
  220:       | ((__const unsigned char *) (addr))[0])
  221: #  define get32u(addr) \
  222:      (((((__const unsigned char *) (addr))[3] << 8                            \
  223:         | ((__const unsigned char *) (addr))[2]) << 8                        \
  224:        | ((__const unsigned char *) (addr))[1]) << 8                          \
  225:       | ((__const unsigned char *) (addr))[0])
  226: 
  227: #  define put16u(addr, val) \
  228:      ({ uint16_t __val = (val);                                               \
  229:         ((unsigned char *) (addr))[0] = __val;                               \
  230:         ((unsigned char *) (addr))[1] = __val >> 8;                          \
  231:         (void) 0; })
  232: #  define put32u(addr, val) \
  233:      ({ uint32_t __val = (val);                                               \
  234:         ((unsigned char *) (addr))[0] = __val;                               \
  235:         __val >>= 8;                                                         \
  236:         ((unsigned char *) (addr))[1] = __val;                               \
  237:         __val >>= 8;                                                         \
  238:         ((unsigned char *) (addr))[2] = __val;                               \
  239:         __val >>= 8;                                                         \
  240:         ((unsigned char *) (addr))[3] = __val;                               \
  241:         (void) 0; })
  242: # else
  243: #  define get16u(addr) \
  244:      (((__const unsigned char *) (addr))[0] << 8                              \
  245:       | ((__const unsigned char *) (addr))[1])
  246: #  define get32u(addr) \
  247:      (((((__const unsigned char *) (addr))[0] << 8                            \
  248:         | ((__const unsigned char *) (addr))[1]) << 8                        \
  249:        | ((__const unsigned char *) (addr))[2]) << 8                          \
  250:       | ((__const unsigned char *) (addr))[3])
  251: 
  252: #  define put16u(addr, val) \
  253:      ({ uint16_t __val = (val);                                               \
  254:         ((unsigned char *) (addr))[1] = __val;                               \
  255:         ((unsigned char *) (addr))[0] = __val >> 8;                          \
  256:         (void) 0; })
  257: #  define put32u(addr, val) \
  258:      ({ uint32_t __val = (val);                                               \
  259:         ((unsigned char *) (addr))[3] = __val;                               \
  260:         __val >>= 8;                                                         \
  261:         ((unsigned char *) (addr))[2] = __val;                               \
  262:         __val >>= 8;                                                         \
  263:         ((unsigned char *) (addr))[1] = __val;                               \
  264:         __val >>= 8;                                                         \
  265:         ((unsigned char *) (addr))[0] = __val;                               \
  266:         (void) 0; })
  267: # endif
  268: #endif
  269: 
  270: 
  271: /* For conversions from a fixed width character set to another fixed width
  272:    character set we can define RESET_INPUT_BUFFER in a very fast way.  */
  273: #if !defined RESET_INPUT_BUFFER && !defined SAVE_RESET_STATE
  274: # if FROM_LOOP_MIN_NEEDED_FROM == FROM_LOOP_MAX_NEEDED_FROM \
  275:      && FROM_LOOP_MIN_NEEDED_TO == FROM_LOOP_MAX_NEEDED_TO \
  276:      && TO_LOOP_MIN_NEEDED_FROM == TO_LOOP_MAX_NEEDED_FROM \
  277:      && TO_LOOP_MIN_NEEDED_TO == TO_LOOP_MAX_NEEDED_TO
  278: /* We have to use these `if's here since the compiler cannot know that
  279:    (outbuf - outerr) is always divisible by FROM/TO_LOOP_MIN_NEEDED_TO.
  280:    The ?:1 avoids division by zero warnings that gcc 3.2 emits even for
  281:    obviously unreachable code.  */
  282: #  define RESET_INPUT_BUFFER \
  283:   if (FROM_DIRECTION)                                                         \
  284:     {                                                                         \
  285:       if (FROM_LOOP_MIN_NEEDED_FROM % FROM_LOOP_MIN_NEEDED_TO == 0)           \
  286:         *inptrp -= (outbuf - outerr)                                         \
  287:                    * (FROM_LOOP_MIN_NEEDED_FROM / FROM_LOOP_MIN_NEEDED_TO);   \
  288:       else if (FROM_LOOP_MIN_NEEDED_TO % FROM_LOOP_MIN_NEEDED_FROM == 0)      \
  289:         *inptrp -= (outbuf - outerr)                                         \
  290:                    / (FROM_LOOP_MIN_NEEDED_TO / FROM_LOOP_MIN_NEEDED_FROM     \
  291:                       ? : 1);                                               \
  292:       else                                                                    \
  293:         *inptrp -= ((outbuf - outerr) / FROM_LOOP_MIN_NEEDED_TO)             \
  294:                    * FROM_LOOP_MIN_NEEDED_FROM;                                     \
  295:     }                                                                         \
  296:   else                                                                        \
  297:     {                                                                         \
  298:       if (TO_LOOP_MIN_NEEDED_FROM % TO_LOOP_MIN_NEEDED_TO == 0)               \
  299:         *inptrp -= (outbuf - outerr)                                         \
  300:                    * (TO_LOOP_MIN_NEEDED_FROM / TO_LOOP_MIN_NEEDED_TO);             \
  301:       else if (TO_LOOP_MIN_NEEDED_TO % TO_LOOP_MIN_NEEDED_FROM == 0)          \
  302:         *inptrp -= (outbuf - outerr)                                         \
  303:                    / (TO_LOOP_MIN_NEEDED_TO / TO_LOOP_MIN_NEEDED_FROM ? : 1); \
  304:       else                                                                    \
  305:         *inptrp -= ((outbuf - outerr) / TO_LOOP_MIN_NEEDED_TO)               \
  306:                    * TO_LOOP_MIN_NEEDED_FROM;                               \
  307:     }
  308: # endif
  309: #endif
  310: 
  311: 
  312: /* The default init function.  It simply matches the name and initializes
  313:    the step data to point to one of the objects above.  */
  314: #if DEFINE_INIT
  315: # ifndef CHARSET_NAME
  316: #  error "CHARSET_NAME not defined"
  317: # endif
  318: 
  319: extern int gconv_init (struct __gconv_step *step);
  320: int
  321: gconv_init (struct __gconv_step *step)
  322: {
  323:   /* Determine which direction.  */
  324:   if (strcmp (step->__from_name, CHARSET_NAME) == 0)
  325:     {
  326:       step->__data = FROM_DIRECTION_VAL;
  327: 
  328:       step->__min_needed_from = FROM_LOOP_MIN_NEEDED_FROM;
  329:       step->__max_needed_from = FROM_LOOP_MAX_NEEDED_FROM;
  330:       step->__min_needed_to = FROM_LOOP_MIN_NEEDED_TO;
  331:       step->__max_needed_to = FROM_LOOP_MAX_NEEDED_TO;
  332: 
  333: #ifdef FROM_ONEBYTE
  334:       step->__btowc_fct = FROM_ONEBYTE;
  335: #endif
  336:     }
  337:   else if (__builtin_expect (strcmp (step->__to_name, CHARSET_NAME), 0) == 0)
  338:     {
  339:       step->__data = TO_DIRECTION_VAL;
  340: 
  341:       step->__min_needed_from = TO_LOOP_MIN_NEEDED_FROM;
  342:       step->__max_needed_from = TO_LOOP_MAX_NEEDED_FROM;
  343:       step->__min_needed_to = TO_LOOP_MIN_NEEDED_TO;
  344:       step->__max_needed_to = TO_LOOP_MAX_NEEDED_TO;
  345:     }
  346:   else
  347:     return __GCONV_NOCONV;
  348: 
  349: #ifdef SAVE_RESET_STATE
  350:   step->__stateful = 1;
  351: #else
  352:   step->__stateful = 0;
  353: #endif
  354: 
  355:   return __GCONV_OK;
  356: }
  357: #endif
  358: 
  359: 
  360: /* The default destructor function does nothing in the moment and so
  361:    we don't define it at all.  But we still provide the macro just in
  362:    case we need it some day.  */
  363: #if DEFINE_FINI
  364: #endif
  365: 
  366: 
  367: /* If no arguments have to passed to the loop function define the macro
  368:    as empty.  */
  369: #ifndef EXTRA_LOOP_ARGS
  370: # define EXTRA_LOOP_ARGS
  371: #endif
  372: 
  373: 
  374: /* This is the actual conversion function.  */
  375: #ifndef FUNCTION_NAME
  376: # define FUNCTION_NAME  gconv
  377: #endif
  378: 
  379: /* The macros are used to access the function to convert single characters.  */
  380: #define SINGLE(fct) SINGLE2 (fct)
  381: #define SINGLE2(fct) fct##_single
  382: 
  383: 
  384: extern int FUNCTION_NAME (struct __gconv_step *step,
  385:                           struct __gconv_step_data *data,
  386:                           const unsigned char **inptrp,
  387:                           const unsigned char *inend,
  388:                           unsigned char **outbufstart, size_t *irreversible,
  389:                           int do_flush, int consume_incomplete);
  390: int
  391: FUNCTION_NAME (struct __gconv_step *step, struct __gconv_step_data *data,
  392:                const unsigned char **inptrp, const unsigned char *inend,
  393:                unsigned char **outbufstart, size_t *irreversible, int do_flush,
  394:                int consume_incomplete)
  395: {
  396:   struct __gconv_step *next_step = step + 1;
  397:   struct __gconv_step_data *next_data = data + 1;
  398:   __gconv_fct fct = NULL;
  399:   int status;
  400: 
  401:   if ((data->__flags & __GCONV_IS_LAST) == 0)
  402:     {
  403:       fct = next_step->__fct;
  404: #ifdef PTR_DEMANGLE
  405:       if (next_step->__shlib_handle != NULL)
  406:         PTR_DEMANGLE (fct);
  407: #endif
  408:     }
  409: 
  410:   /* If the function is called with no input this means we have to reset
  411:      to the initial state.  The possibly partly converted input is
  412:      dropped.  */
  413:   if (__builtin_expect (do_flush, 0))
  414:     {
  415:       /* This should never happen during error handling.  */
  416:       assert (outbufstart == NULL);
  417: 
  418:       status = __GCONV_OK;
  419: 
  420: #ifdef EMIT_SHIFT_TO_INIT
  421:       if (do_flush == 1)
  422:         {
  423:           /* We preserve the initial values of the pointer variables.  */
  424:           unsigned char *outbuf = data->__outbuf;
  425:           unsigned char *outstart = outbuf;
  426:           unsigned char *outend = data->__outbufend;
  427: 
  428: # ifdef PREPARE_LOOP
  429:           PREPARE_LOOP
  430: # endif
  431: 
  432: # ifdef SAVE_RESET_STATE
  433:           SAVE_RESET_STATE (1);
  434: # endif
  435: 
  436:           /* Emit the escape sequence to reset the state.  */
  437:           EMIT_SHIFT_TO_INIT;
  438: 
  439:           /* Call the steps down the chain if there are any but only if we
  440:              successfully emitted the escape sequence.  This should only
  441:              fail if the output buffer is full.  If the input is invalid
  442:              it should be discarded since the user wants to start from a
  443:              clean state.  */
  444:           if (status == __GCONV_OK)
  445:             {
  446:               if (data->__flags & __GCONV_IS_LAST)
  447:                 /* Store information about how many bytes are available.  */
  448:                 data->__outbuf = outbuf;
  449:               else
  450:                 {
  451:                   /* Write out all output which was produced.  */
  452:                   if (outbuf > outstart)
  453:                     {
  454:                       const unsigned char *outerr = outstart;
  455:                       int result;
  456: 
  457:                       result = DL_CALL_FCT (fct, (next_step, next_data,
  458:                                                   &outerr, outbuf, NULL,
  459:                                                   irreversible, 0,
  460:                                                   consume_incomplete));
  461: 
  462:                       if (result != __GCONV_EMPTY_INPUT)
  463:                         {
  464:                           if (__builtin_expect (outerr != outbuf, 0))
  465:                             {
  466:                               /* We have a problem.  Undo the conversion.  */
  467:                               outbuf = outstart;
  468: 
  469:                               /* Restore the state.  */
  470: # ifdef SAVE_RESET_STATE
  471:                               SAVE_RESET_STATE (0);
  472: # endif
  473:                             }
  474: 
  475:                           /* Change the status.  */
  476:                           status = result;
  477:                         }
  478:                     }
  479: 
  480:                   if (status == __GCONV_OK)
  481:                     /* Now flush the remaining steps.  */
  482:                     status = DL_CALL_FCT (fct, (next_step, next_data, NULL,
  483:                                                 NULL, NULL, irreversible, 1,
  484:                                                 consume_incomplete));
  485:                 }
  486:             }
  487:         }
  488:       else
  489: #endif
  490:         {
  491:           /* Clear the state object.  There might be bytes in there from
  492:              previous calls with CONSUME_INCOMPLETE == 1.  But don't emit
  493:              escape sequences.  */
  494:           memset (data->__statep, '\0', sizeof (*data->__statep));
  495: 
  496:           if (! (data->__flags & __GCONV_IS_LAST))
  497:             /* Now flush the remaining steps.  */
  498:             status = DL_CALL_FCT (fct, (next_step, next_data, NULL, NULL,
  499:                                         NULL, irreversible, do_flush,
  500:                                         consume_incomplete));
  501:         }
  502:     }
  503:   else
  504:     {
  505:       /* We preserve the initial values of the pointer variables.  */
  506:       const unsigned char *inptr = *inptrp;
  507:       unsigned char *outbuf = (__builtin_expect (outbufstart == NULL, 1)
  508:                                ? data->__outbuf : *outbufstart);
  509:       unsigned char *outend = data->__outbufend;
  510:       unsigned char *outstart;
  511:       /* This variable is used to count the number of characters we
  512:          actually converted.  */
  513:       size_t lirreversible = 0;
  514:       size_t *lirreversiblep = irreversible ? &lirreversible : NULL;
  515: 
  516:       /* The following assumes that encodings, which have a variable length
  517:          what might unalign a buffer even though it is a aligned in the
  518:          beginning, either don't have the minimal number of bytes as a divisor
  519:          of the maximum length or have a minimum length of 1.  This is true
  520:          for all known and supported encodings.
  521:          We use && instead of || to combine the subexpression for the FROM
  522:          encoding and for the TO encoding, because usually one of them is
  523:          INTERNAL, for which the subexpression evaluates to 1, but INTERNAL
  524:          buffers are always aligned correctly.  */
  525: #define POSSIBLY_UNALIGNED \
  526:   (!defined _STRING_ARCH_unaligned                                            \
  527:    && (((FROM_LOOP_MIN_NEEDED_FROM != 1                                       \
  528:          && FROM_LOOP_MAX_NEEDED_FROM % FROM_LOOP_MIN_NEEDED_FROM == 0)              \
  529:         && (FROM_LOOP_MIN_NEEDED_TO != 1                                     \
  530:             && FROM_LOOP_MAX_NEEDED_TO % FROM_LOOP_MIN_NEEDED_TO == 0))              \
  531:        || ((TO_LOOP_MIN_NEEDED_FROM != 1                                      \
  532:             && TO_LOOP_MAX_NEEDED_FROM % TO_LOOP_MIN_NEEDED_FROM == 0)       \
  533:            && (TO_LOOP_MIN_NEEDED_TO != 1                                    \
  534:                && TO_LOOP_MAX_NEEDED_TO % TO_LOOP_MIN_NEEDED_TO == 0))))
  535: #if POSSIBLY_UNALIGNED
  536:       int unaligned;
  537: # define GEN_unaligned(name) GEN_unaligned2 (name)
  538: # define GEN_unaligned2(name) name##_unaligned
  539: #else
  540: # def