pike.git / src / sscanf.c

version» Context lines:

pike.git/src/sscanf.c:39:      #define CONSUME(X) do{if(*len>=X){INC_PCHARP(*str,X);*len-=X;}}while(0)   static p_wchar2 next_char( PCHARP *str, ptrdiff_t *len )   {    p_wchar2 res = *len ? EXTRACT_PCHARP(*str) : 0;    CONSUME(1);    return res;   }   #define READ() next_char(str,len)    + #ifdef HANDLES_UNALIGNED_MEMORY_ACCESS + #define NOINLINE_UNALIGNED + #else + /* Workaround for gcc 4.7.4 and others "optimizing" away calls to memcpy(), +  * and replacing them with direct (unaligned) memory accesses. +  * This generates broken code for eg %F on sparc. +  * cf https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50569 +  * Note that the patch for the above bug is in gcc 4.7.4, but isn't sufficient. +  */ + #define NOINLINE_UNALIGNED ATTRIBUTE((noinline)) DECLSPEC((noinline)) + #endif +    static void skip_comment( PCHARP *str, ptrdiff_t *len )   {    CONSUME(1); // Start '/'    switch(READ())    {    case '*':    while(*len)    {    while( READ() != '*' )    ;
pike.git/src/sscanf.c:613: Inside #if defined(NEED_CUSTOM_IEEE)
   }       r = (double)f;    if(extra_f)    r += ((double)extra_f)/4294967296.0;    return (FLOAT_TYPE)(s? -ldexp(r, e):ldexp(r, e));   }      #endif    - static FLOAT_TYPE extract_float_be(const char * x) { + static FLOAT_TYPE NOINLINE_UNALIGNED extract_float_be(const char * x) {   #ifdef FLOAT_IS_IEEE_BIG    float f;    memcpy(&f, x, sizeof(f));    return f;   #elif FLOAT_IS_IEEE_LITTLE    float f;    unsigned INT32 tmp = get_unaligned32(x);    tmp = bswap32(tmp);    memcpy(&f, &tmp, sizeof(f));    return f;   #else    return low_parse_IEEE_float(x, 4);   #endif   }    - static FLOAT_TYPE extract_double_be(const char * x) { + static FLOAT_TYPE NOINLINE_UNALIGNED extract_double_be(const char * x) {   #ifdef DOUBLE_IS_IEEE_BIG    double f;    memcpy(&f, x, sizeof(f));    return f;   #elif DOUBLE_IS_IEEE_LITTLE    double f;   #ifdef UINT64    UINT64 tmp = get_unaligned64(x);    tmp = bswap64(tmp);   #else
pike.git/src/sscanf.c:657:    tmp[1] = x[6];    tmp[0] = x[7];   #endif    memcpy(&f, &tmp, sizeof(f));    return f;   #else    return low_parse_IEEE_float(x, 8);   #endif   }    - static FLOAT_TYPE extract_float_le(const char * x) { + static FLOAT_TYPE NOINLINE_UNALIGNED extract_float_le(const char * x) {   #ifdef FLOAT_IS_IEEE_LITTLE    float f;    memcpy(&f, x, sizeof(f));    return f;   #elif FLOAT_IS_IEEE_BIG    float f;    unsigned INT32 tmp = get_unaligned32(x);    tmp = bswap32(tmp);    memcpy(&f, &tmp, sizeof(f));    return f;   #else    return low_parse_IEEE_float(x, -4);   #endif   }    - static FLOAT_TYPE extract_double_le(const char * x) { + static FLOAT_TYPE NOINLINE_UNALIGNED extract_double_le(const char * x) {   #ifdef DOUBLE_IS_IEEE_LITTLE    double f;    memcpy(&f, x, sizeof(f));    return f;   #elif DOUBLE_IS_IEEE_BIG    double f;   #ifdef UINT64    UINT64 tmp = get_unaligned64(x);    tmp = bswap64(tmp);   #else
pike.git/src/sscanf.c:727:    memcpy(x, input, sizeof(x)); \    } else { \    PCHARP tmp = MKPCHARP(input, shift); \    size_t i; \    for (i = 0; i < sizeof(x); INC_PCHARP(tmp, 1), i++) \    x[i] = EXTRACT_PCHARP(tmp); \    } \    (SVAL).u.float_number = fun(x); \   } while (0)    - static struct pike_string *get_string_slice( void *input, int shift, + static struct pike_string * NOINLINE_UNALIGNED +  get_string_slice( void *input, int shift,    ptrdiff_t offset, ptrdiff_t len,    struct pike_string *str )   {    if( !shift && str )    return string_slice( str, offset, len );    return make_shared_binary_pcharp(MKPCHARP(((char *)input)+(offset<<shift),shift),    len);   }      /* INT32 very_low_sscanf_{0,1,2}_{0,1,2}(p_wchar *input, ptrdiff_t input_len,