Back to index

glibc  2.9
Defines | Functions
loop.c File Reference
#include <assert.h>
#include <endian.h>
#include <gconv.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <sys/param.h>
#include <stddef.h>
#include "loop.c"

Go to the source code of this file.

Defines

#define __need_size_t
#define get16(addr)   *((__const uint16_t *) (addr))
#define get32(addr)   *((__const uint32_t *) (addr))
#define put16(addr, val)   *((uint16_t *) (addr)) = (val)
#define put32(addr, val)   *((uint32_t *) (addr)) = (val)
#define FCTNAME2(name)   name
#define FCTNAME(name)   FCTNAME2(name)
#define MAX_NEEDED_INPUT   MIN_NEEDED_INPUT
#define MAX_NEEDED_OUTPUT   MIN_NEEDED_OUTPUT
#define LOOPFCT   loop
#define EXTRA_LOOP_DECLS
#define UPDATE_PARAMS   do { } while (0)
#define REINIT_PARAMS   do { } while (0)
#define ignore_errors_p()   (irreversible != NULL && (flags & __GCONV_IGNORE_ERRORS))
#define STANDARD_FROM_LOOP_ERR_HANDLER(Incr)
#define STANDARD_TO_LOOP_ERR_HANDLER(Incr)
#define UNICODE_TAG_HANDLER(Character, Incr)
#define DEFINE_UNALIGNED

Functions

static int __attribute ((always_inline))

Define Documentation

#define __need_size_t

Definition at line 58 of file loop.c.

Definition at line 351 of file loop.c.

Definition at line 174 of file loop.c.

#define FCTNAME (   name)    FCTNAME2(name)

Definition at line 133 of file loop.c.

#define FCTNAME2 (   name)    name

Definition at line 76 of file loop.c.

#define get16 (   addr)    *((__const uint16_t *) (addr))

Definition at line 69 of file loop.c.

#define get32 (   addr)    *((__const uint32_t *) (addr))

Definition at line 70 of file loop.c.

#define ignore_errors_p ( )    (irreversible != NULL && (flags & __GCONV_IGNORE_ERRORS))

Definition at line 189 of file loop.c.

#define LOOPFCT   loop

Definition at line 162 of file loop.c.

Definition at line 145 of file loop.c.

Definition at line 157 of file loop.c.

#define put16 (   addr,
  val 
)    *((uint16_t *) (addr)) = (val)

Definition at line 73 of file loop.c.

#define put32 (   addr,
  val 
)    *((uint32_t *) (addr)) = (val)

Definition at line 74 of file loop.c.

#define REINIT_PARAMS   do { } while (0)

Definition at line 183 of file loop.c.

#define STANDARD_FROM_LOOP_ERR_HANDLER (   Incr)
Value:
{                                                                    \
    result = __GCONV_ILLEGAL_INPUT;                                         \
                                                                     \
    if (! ignore_errors_p ())                                               \
      break;                                                         \
                                                                     \
    /* We ignore the invalid input byte sequence.  */                       \
    inptr += (Incr);                                                 \
    ++*irreversible;                                                 \
    /* But we keep result == __GCONV_ILLEGAL_INPUT, because of the constraint \
       that "iconv -c" must give the same exitcode as "iconv".  */          \
    continue;                                                        \
  }

Definition at line 196 of file loop.c.

#define STANDARD_TO_LOOP_ERR_HANDLER (   Incr)

Definition at line 214 of file loop.c.

#define UNICODE_TAG_HANDLER (   Character,
  Incr 
)
Value:
{                                                                    \
    /* TAG characters are those in the range U+E0000..U+E007F.  */          \
    if (((Character) >> 7) == (0xe0000 >> 7))                               \
      {                                                                     \
       inptr += Incr;                                                       \
       continue;                                                     \
      }                                                                     \
  }

Definition at line 264 of file loop.c.

#define UPDATE_PARAMS   do { } while (0)

Definition at line 180 of file loop.c.


Function Documentation

static int __attribute ( (always_inline)  ) [inline, static]

Definition at line 277 of file loop.c.

{
#ifdef LOOP_NEED_STATE
  mbstate_t *state = step_data->__statep;
#endif
#ifdef LOOP_NEED_FLAGS
  int flags = step_data->__flags;
#endif
#ifdef LOOP_NEED_DATA
  void *data = step->__data;
#endif
  int result = __GCONV_EMPTY_INPUT;
  const unsigned char *inptr = *inptrp;
  unsigned char *outptr = *outptrp;

#ifdef INIT_PARAMS
  INIT_PARAMS;
#endif

  while (inptr != inend)
    {
      /* `if' cases for MIN_NEEDED_OUTPUT ==/!= 1 is made to help the
        compiler generating better code.  They will be optimized away
        since MIN_NEEDED_OUTPUT is always a constant.  */
      if (MIN_NEEDED_INPUT > 1
         && __builtin_expect (inptr + MIN_NEEDED_INPUT > inend, 0))
       {
         /* We don't have enough input for another complete input
            character.  */
         result = __GCONV_INCOMPLETE_INPUT;
         break;
       }
      if ((MIN_NEEDED_OUTPUT != 1
          && __builtin_expect (outptr + MIN_NEEDED_OUTPUT > outend, 0))
         || (MIN_NEEDED_OUTPUT == 1
             && __builtin_expect (outptr >= outend, 0)))
       {
         /* Overflow in the output buffer.  */
         result = __GCONV_FULL_OUTPUT;
         break;
       }

      /* Here comes the body the user provides.  It can stop with
        RESULT set to GCONV_INCOMPLETE_INPUT (if the size of the
        input characters vary in size), GCONV_ILLEGAL_INPUT, or
        GCONV_FULL_OUTPUT (if the output characters vary in size).  */
      BODY
    }

  /* Update the pointers pointed to by the parameters.  */
  *inptrp = inptr;
  *outptrp = outptr;