iconv/loop.c: Fix -Wundef warning with !_STRING_ARCH_unaligned
If code is required to handle the unaligned case then loop.c includes itself and relies on the #undefs at the end of the file to avoid outputting two copies of LOOPFCT and gconv_btowc. However MAX_NEEDED_INPUT is tested with #if so this causes a warning. Reorder the code so that the function definitions are in an #else block to make the behaviour clearer and fix the warning. Verified that code is unchanged on x86_64 and arm. ChangeLog: 2014-07-17 Will Newton <will.newton@linaro.org> * iconv/loop.c: Move definition of LOOPFCT and gconv_btowc into an #else block.
This commit is contained in:
parent
37fccd4192
commit
32bead5b6d
|
@ -1,3 +1,8 @@
|
||||||
|
2014-07-17 Will Newton <will.newton@linaro.org>
|
||||||
|
|
||||||
|
* iconv/loop.c: Move definition of LOOPFCT and gconv_btowc
|
||||||
|
into an #else block.
|
||||||
|
|
||||||
2014-07-16 Roland McGrath <roland@hack.frob.com>
|
2014-07-16 Roland McGrath <roland@hack.frob.com>
|
||||||
|
|
||||||
* sysdeps/arm/preconfigure.ac: Apply EABI sanity check to arm*, not
|
* sysdeps/arm/preconfigure.ac: Apply EABI sanity check to arm*, not
|
||||||
|
|
59
iconv/loop.c
59
iconv/loop.c
|
@ -354,12 +354,10 @@ FCTNAME (LOOPFCT) (struct __gconv_step *step,
|
||||||
# define DEFINE_UNALIGNED
|
# define DEFINE_UNALIGNED
|
||||||
# include "loop.c"
|
# include "loop.c"
|
||||||
# undef DEFINE_UNALIGNED
|
# undef DEFINE_UNALIGNED
|
||||||
#endif
|
#else
|
||||||
|
# if MAX_NEEDED_INPUT > 1
|
||||||
|
# define SINGLE(fct) SINGLE2 (fct)
|
||||||
#if MAX_NEEDED_INPUT > 1
|
# define SINGLE2(fct) fct##_single
|
||||||
# define SINGLE(fct) SINGLE2 (fct)
|
|
||||||
# define SINGLE2(fct) fct##_single
|
|
||||||
static inline int
|
static inline int
|
||||||
__attribute ((always_inline))
|
__attribute ((always_inline))
|
||||||
SINGLE(LOOPFCT) (struct __gconv_step *step,
|
SINGLE(LOOPFCT) (struct __gconv_step *step,
|
||||||
|
@ -369,37 +367,37 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
|
||||||
size_t *irreversible EXTRA_LOOP_DECLS)
|
size_t *irreversible EXTRA_LOOP_DECLS)
|
||||||
{
|
{
|
||||||
mbstate_t *state = step_data->__statep;
|
mbstate_t *state = step_data->__statep;
|
||||||
#ifdef LOOP_NEED_FLAGS
|
# ifdef LOOP_NEED_FLAGS
|
||||||
int flags = step_data->__flags;
|
int flags = step_data->__flags;
|
||||||
#endif
|
# endif
|
||||||
#ifdef LOOP_NEED_DATA
|
# ifdef LOOP_NEED_DATA
|
||||||
void *data = step->__data;
|
void *data = step->__data;
|
||||||
#endif
|
# endif
|
||||||
int result = __GCONV_OK;
|
int result = __GCONV_OK;
|
||||||
unsigned char bytebuf[MAX_NEEDED_INPUT];
|
unsigned char bytebuf[MAX_NEEDED_INPUT];
|
||||||
const unsigned char *inptr = *inptrp;
|
const unsigned char *inptr = *inptrp;
|
||||||
unsigned char *outptr = *outptrp;
|
unsigned char *outptr = *outptrp;
|
||||||
size_t inlen;
|
size_t inlen;
|
||||||
|
|
||||||
#ifdef INIT_PARAMS
|
# ifdef INIT_PARAMS
|
||||||
INIT_PARAMS;
|
INIT_PARAMS;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
#ifdef UNPACK_BYTES
|
# ifdef UNPACK_BYTES
|
||||||
UNPACK_BYTES
|
UNPACK_BYTES
|
||||||
#else
|
# else
|
||||||
/* Add the bytes from the state to the input buffer. */
|
/* Add the bytes from the state to the input buffer. */
|
||||||
assert ((state->__count & 7) <= sizeof (state->__value));
|
assert ((state->__count & 7) <= sizeof (state->__value));
|
||||||
for (inlen = 0; inlen < (size_t) (state->__count & 7); ++inlen)
|
for (inlen = 0; inlen < (size_t) (state->__count & 7); ++inlen)
|
||||||
bytebuf[inlen] = state->__value.__wchb[inlen];
|
bytebuf[inlen] = state->__value.__wchb[inlen];
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* Are there enough bytes in the input buffer? */
|
/* Are there enough bytes in the input buffer? */
|
||||||
if (MIN_NEEDED_INPUT > 1
|
if (MIN_NEEDED_INPUT > 1
|
||||||
&& __builtin_expect (inptr + (MIN_NEEDED_INPUT - inlen) > inend, 0))
|
&& __builtin_expect (inptr + (MIN_NEEDED_INPUT - inlen) > inend, 0))
|
||||||
{
|
{
|
||||||
*inptrp = inend;
|
*inptrp = inend;
|
||||||
#ifdef STORE_REST
|
# ifdef STORE_REST
|
||||||
while (inptr < inend)
|
while (inptr < inend)
|
||||||
bytebuf[inlen++] = *inptr++;
|
bytebuf[inlen++] = *inptr++;
|
||||||
|
|
||||||
|
@ -408,12 +406,12 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
|
||||||
inend = &bytebuf[inlen];
|
inend = &bytebuf[inlen];
|
||||||
|
|
||||||
STORE_REST
|
STORE_REST
|
||||||
#else
|
# else
|
||||||
/* We don't have enough input for another complete input
|
/* We don't have enough input for another complete input
|
||||||
character. */
|
character. */
|
||||||
while (inptr < inend)
|
while (inptr < inend)
|
||||||
state->__value.__wchb[inlen++] = *inptr++;
|
state->__value.__wchb[inlen++] = *inptr++;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
return __GCONV_INCOMPLETE_INPUT;
|
return __GCONV_INCOMPLETE_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -453,11 +451,11 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
|
||||||
result = __GCONV_OK;
|
result = __GCONV_OK;
|
||||||
|
|
||||||
/* Clear the state buffer. */
|
/* Clear the state buffer. */
|
||||||
#ifdef CLEAR_STATE
|
# ifdef CLEAR_STATE
|
||||||
CLEAR_STATE;
|
CLEAR_STATE;
|
||||||
#else
|
# else
|
||||||
state->__count &= ~7;
|
state->__count &= ~7;
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
else if (result == __GCONV_INCOMPLETE_INPUT)
|
else if (result == __GCONV_INCOMPLETE_INPUT)
|
||||||
{
|
{
|
||||||
|
@ -466,11 +464,11 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
|
||||||
assert (inend != &bytebuf[MAX_NEEDED_INPUT]);
|
assert (inend != &bytebuf[MAX_NEEDED_INPUT]);
|
||||||
|
|
||||||
*inptrp += inend - bytebuf - (state->__count & 7);
|
*inptrp += inend - bytebuf - (state->__count & 7);
|
||||||
#ifdef STORE_REST
|
# ifdef STORE_REST
|
||||||
inptrp = &inptr;
|
inptrp = &inptr;
|
||||||
|
|
||||||
STORE_REST
|
STORE_REST
|
||||||
#else
|
# else
|
||||||
/* We don't have enough input for another complete input
|
/* We don't have enough input for another complete input
|
||||||
character. */
|
character. */
|
||||||
assert (inend - inptr > (state->__count & ~7));
|
assert (inend - inptr > (state->__count & ~7));
|
||||||
|
@ -479,24 +477,25 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
|
||||||
inlen = 0;
|
inlen = 0;
|
||||||
while (inptr < inend)
|
while (inptr < inend)
|
||||||
state->__value.__wchb[inlen++] = *inptr++;
|
state->__value.__wchb[inlen++] = *inptr++;
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
# undef SINGLE
|
# undef SINGLE
|
||||||
# undef SINGLE2
|
# undef SINGLE2
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef ONEBYTE_BODY
|
# ifdef ONEBYTE_BODY
|
||||||
/* Define the shortcut function for btowc. */
|
/* Define the shortcut function for btowc. */
|
||||||
static wint_t
|
static wint_t
|
||||||
gconv_btowc (struct __gconv_step *step, unsigned char c)
|
gconv_btowc (struct __gconv_step *step, unsigned char c)
|
||||||
ONEBYTE_BODY
|
ONEBYTE_BODY
|
||||||
# define FROM_ONEBYTE gconv_btowc
|
# define FROM_ONEBYTE gconv_btowc
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We remove the macro definitions so that we can include this file again
|
/* We remove the macro definitions so that we can include this file again
|
||||||
for the definition of another function. */
|
for the definition of another function. */
|
||||||
|
|
Loading…
Reference in New Issue