| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-skip-if "incompatible options" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */ |
| 3 |
/* { dg-options "-mthumb -O2" } */ |
| 4 |
|
| 5 |
typedef unsigned int size_t; |
| 6 |
typedef unsigned int wchar_t; |
| 7 |
typedef int ptrdiff_t; |
| 8 |
typedef signed char __int8_t ; |
| 9 |
typedef unsigned char __uint8_t ; |
| 10 |
typedef signed short __int16_t; |
| 11 |
typedef unsigned short __uint16_t; |
| 12 |
typedef __int16_t __int_least16_t; |
| 13 |
typedef __uint16_t __uint_least16_t; |
| 14 |
typedef signed int __int32_t; |
| 15 |
typedef unsigned int __uint32_t; |
| 16 |
typedef __int32_t __int_least32_t; |
| 17 |
typedef __uint32_t __uint_least32_t; |
| 18 |
typedef signed long long __int64_t; |
| 19 |
typedef unsigned long long __uint64_t; |
| 20 |
typedef int _LOCK_T; |
| 21 |
typedef int _LOCK_RECURSIVE_T; |
| 22 |
typedef long _off_t; |
| 23 |
typedef short __dev_t; |
| 24 |
typedef unsigned short __uid_t; |
| 25 |
typedef unsigned short __gid_t; |
| 26 |
__extension__ typedef long long _off64_t; |
| 27 |
typedef long _fpos_t; |
| 28 |
typedef signed int _ssize_t; |
| 29 |
typedef unsigned int wint_t; |
| 30 |
typedef struct |
| 31 |
{ |
| 32 |
int __count; |
| 33 |
union |
| 34 |
{ |
| 35 |
wint_t __wch; |
| 36 |
unsigned char __wchb[4]; |
| 37 |
} __value; |
| 38 |
} _mbstate_t; |
| 39 |
typedef _LOCK_RECURSIVE_T _flock_t; |
| 40 |
typedef void *_iconv_t; |
| 41 |
typedef unsigned long __ULong; |
| 42 |
struct _reent; |
| 43 |
struct _Bigint |
| 44 |
{ |
| 45 |
struct _Bigint *_next; |
| 46 |
int _k, _maxwds, _sign, _wds; |
| 47 |
__ULong _x[1]; |
| 48 |
}; |
| 49 |
struct __tm |
| 50 |
{ |
| 51 |
int __tm_sec; |
| 52 |
int __tm_min; |
| 53 |
int __tm_hour; |
| 54 |
int __tm_mday; |
| 55 |
int __tm_mon; |
| 56 |
int __tm_year; |
| 57 |
int __tm_wday; |
| 58 |
int __tm_yday; |
| 59 |
int __tm_isdst; |
| 60 |
}; |
| 61 |
struct _on_exit_args { |
| 62 |
void * _fnargs[32]; |
| 63 |
void * _dso_handle[32]; |
| 64 |
__ULong _fntypes; |
| 65 |
__ULong _is_cxa; |
| 66 |
}; |
| 67 |
struct _atexit { |
| 68 |
struct _atexit *_next; |
| 69 |
int _ind; |
| 70 |
void (*_fns[32])(void); |
| 71 |
struct _on_exit_args _on_exit_args; |
| 72 |
}; |
| 73 |
struct __sbuf { |
| 74 |
unsigned char *_base; |
| 75 |
int _size; |
| 76 |
}; |
| 77 |
struct __sFILE { |
| 78 |
unsigned char *_p; |
| 79 |
int _r; |
| 80 |
int _w; |
| 81 |
short _flags; |
| 82 |
short _file; |
| 83 |
struct __sbuf _bf; |
| 84 |
int _lbfsize; |
| 85 |
void * _cookie; |
| 86 |
int (* _read) (struct _reent *, void *, char *, int) |
| 87 |
; |
| 88 |
int (* _write) (struct _reent *, void *, const char *, int) |
| 89 |
; |
| 90 |
_fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); |
| 91 |
int (* _close) (struct _reent *, void *); |
| 92 |
struct __sbuf _ub; |
| 93 |
unsigned char *_up; |
| 94 |
int _ur; |
| 95 |
unsigned char _ubuf[3]; |
| 96 |
unsigned char _nbuf[1]; |
| 97 |
struct __sbuf _lb; |
| 98 |
int _blksize; |
| 99 |
_off_t _offset; |
| 100 |
struct _reent *_data; |
| 101 |
_flock_t _lock; |
| 102 |
_mbstate_t _mbstate; |
| 103 |
int _flags2; |
| 104 |
}; |
| 105 |
typedef struct __sFILE __FILE; |
| 106 |
struct _glue |
| 107 |
{ |
| 108 |
struct _glue *_next; |
| 109 |
int _niobs; |
| 110 |
__FILE *_iobs; |
| 111 |
}; |
| 112 |
struct _rand48 { |
| 113 |
unsigned short _seed[3]; |
| 114 |
unsigned short _mult[3]; |
| 115 |
unsigned short _add; |
| 116 |
}; |
| 117 |
struct _reent |
| 118 |
{ |
| 119 |
int _errno; |
| 120 |
__FILE *_stdin, *_stdout, *_stderr; |
| 121 |
int _inc; |
| 122 |
char _emergency[25]; |
| 123 |
int _current_category; |
| 124 |
const char *_current_locale; |
| 125 |
int __sdidinit; |
| 126 |
void (* __cleanup) (struct _reent *); |
| 127 |
struct _Bigint *_result; |
| 128 |
int _result_k; |
| 129 |
struct _Bigint *_p5s; |
| 130 |
struct _Bigint **_freelist; |
| 131 |
int _cvtlen; |
| 132 |
char *_cvtbuf; |
| 133 |
union |
| 134 |
{ |
| 135 |
struct |
| 136 |
{ |
| 137 |
unsigned int _unused_rand; |
| 138 |
char * _strtok_last; |
| 139 |
char _asctime_buf[26]; |
| 140 |
struct __tm _localtime_buf; |
| 141 |
int _gamma_signgam; |
| 142 |
__extension__ unsigned long long _rand_next; |
| 143 |
struct _rand48 _r48; |
| 144 |
_mbstate_t _mblen_state; |
| 145 |
_mbstate_t _mbtowc_state; |
| 146 |
_mbstate_t _wctomb_state; |
| 147 |
char _l64a_buf[8]; |
| 148 |
char _signal_buf[24]; |
| 149 |
int _getdate_err; |
| 150 |
_mbstate_t _mbrlen_state; |
| 151 |
_mbstate_t _mbrtowc_state; |
| 152 |
_mbstate_t _mbsrtowcs_state; |
| 153 |
_mbstate_t _wcrtomb_state; |
| 154 |
_mbstate_t _wcsrtombs_state; |
| 155 |
int _h_errno; |
| 156 |
} _reent; |
| 157 |
struct |
| 158 |
{ |
| 159 |
unsigned char * _nextf[30]; |
| 160 |
unsigned int _nmalloc[30]; |
| 161 |
} _unused; |
| 162 |
} _new; |
| 163 |
struct _atexit *_atexit; |
| 164 |
struct _atexit _atexit0; |
| 165 |
void (**(_sig_func))(int); |
| 166 |
struct _glue __sglue; |
| 167 |
__FILE __sf[3]; |
| 168 |
}; |
| 169 |
extern struct _reent *_impure_ptr ; |
| 170 |
extern struct _reent *const _global_impure_ptr ; |
| 171 |
void _reclaim_reent (struct _reent *); |
| 172 |
typedef struct |
| 173 |
{ |
| 174 |
int quot; |
| 175 |
int rem; |
| 176 |
} div_t; |
| 177 |
typedef struct |
| 178 |
{ |
| 179 |
long quot; |
| 180 |
long rem; |
| 181 |
} ldiv_t; |
| 182 |
typedef struct |
| 183 |
{ |
| 184 |
long long int quot; |
| 185 |
long long int rem; |
| 186 |
} lldiv_t; |
| 187 |
typedef int (*__compar_fn_t) (const void *, const void *); |
| 188 |
int __locale_mb_cur_max (void); |
| 189 |
void abort (void) __attribute__ ((noreturn)); |
| 190 |
int abs (int); |
| 191 |
int atexit (void (*__func)(void)); |
| 192 |
double atof (const char *__nptr); |
| 193 |
float atoff (const char *__nptr); |
| 194 |
int atoi (const char *__nptr); |
| 195 |
int _atoi_r (struct _reent *, const char *__nptr); |
| 196 |
long atol (const char *__nptr); |
| 197 |
long _atol_r (struct _reent *, const char *__nptr); |
| 198 |
void * bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar) |
| 199 |
; |
| 200 |
void * calloc (size_t __nmemb, size_t __size) ; |
| 201 |
div_t div (int __numer, int __denom); |
| 202 |
void exit (int __status) __attribute__ ((noreturn)); |
| 203 |
void free (void *) ; |
| 204 |
char * getenv (const char *__string); |
| 205 |
char * _getenv_r (struct _reent *, const char *__string); |
| 206 |
char * _findenv (const char *, int *); |
| 207 |
char * _findenv_r (struct _reent *, const char *, int *); |
| 208 |
extern char *suboptarg; |
| 209 |
int getsubopt (char **, char * const *, char **); |
| 210 |
long labs (long); |
| 211 |
ldiv_t ldiv (long __numer, long __denom); |
| 212 |
void * malloc (size_t __size) ; |
| 213 |
int mblen (const char *, size_t); |
| 214 |
int _mblen_r (struct _reent *, const char *, size_t, _mbstate_t *); |
| 215 |
int mbtowc (wchar_t *, const char *, size_t); |
| 216 |
int _mbtowc_r (struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *); |
| 217 |
int wctomb (char *, wchar_t); |
| 218 |
int _wctomb_r (struct _reent *, char *, wchar_t, _mbstate_t *); |
| 219 |
size_t mbstowcs (wchar_t *, const char *, size_t); |
| 220 |
size_t _mbstowcs_r (struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *); |
| 221 |
size_t wcstombs (char *, const wchar_t *, size_t); |
| 222 |
size_t _wcstombs_r (struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *); |
| 223 |
char * mkdtemp (char *); |
| 224 |
int mkostemp (char *, int); |
| 225 |
int mkostemps (char *, int, int); |
| 226 |
int mkstemp (char *); |
| 227 |
int mkstemps (char *, int); |
| 228 |
char * mktemp (char *) __attribute__ ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead"))); |
| 229 |
char * _mkdtemp_r (struct _reent *, char *); |
| 230 |
int _mkostemp_r (struct _reent *, char *, int); |
| 231 |
int _mkostemps_r (struct _reent *, char *, int, int); |
| 232 |
int _mkstemp_r (struct _reent *, char *); |
| 233 |
int _mkstemps_r (struct _reent *, char *, int); |
| 234 |
char * _mktemp_r (struct _reent *, char *) __attribute__ ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead"))); |
| 235 |
void qsort (void * __base, size_t __nmemb, size_t __size, __compar_fn_t _compar); |
| 236 |
int rand (void); |
| 237 |
void * realloc (void * __r, size_t __size) ; |
| 238 |
void * reallocf (void * __r, size_t __size); |
| 239 |
void srand (unsigned __seed); |
| 240 |
double strtod (const char *__n, char **__end_PTR); |
| 241 |
double _strtod_r (struct _reent *,const char *__n, char **__end_PTR); |
| 242 |
float strtof (const char *__n, char **__end_PTR); |
| 243 |
long strtol (const char *__n, char **__end_PTR, int __base); |
| 244 |
long _strtol_r (struct _reent *,const char *__n, char **__end_PTR, int __base); |
| 245 |
unsigned long strtoul (const char *__n, char **__end_PTR, int __base); |
| 246 |
unsigned long _strtoul_r (struct _reent *,const char *__n, char **__end_PTR, int __base); |
| 247 |
int system (const char *__string); |
| 248 |
long a64l (const char *__input); |
| 249 |
char * l64a (long __input); |
| 250 |
char * _l64a_r (struct _reent *,long __input); |
| 251 |
int on_exit (void (*__func)(int, void *),void * __arg); |
| 252 |
void _Exit (int __status) __attribute__ ((noreturn)); |
| 253 |
int putenv (char *__string); |
| 254 |
int _putenv_r (struct _reent *, char *__string); |
| 255 |
void * _reallocf_r (struct _reent *, void *, size_t); |
| 256 |
int setenv (const char *__string, const char *__value, int __overwrite); |
| 257 |
int _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite); |
| 258 |
char * gcvt (double,int,char *); |
| 259 |
char * gcvtf (float,int,char *); |
| 260 |
char * fcvt (double,int,int *,int *); |
| 261 |
char * fcvtf (float,int,int *,int *); |
| 262 |
char * ecvt (double,int,int *,int *); |
| 263 |
char * ecvtbuf (double, int, int*, int*, char *); |
| 264 |
char * fcvtbuf (double, int, int*, int*, char *); |
| 265 |
char * ecvtf (float,int,int *,int *); |
| 266 |
char * dtoa (double, int, int, int *, int*, char**); |
| 267 |
int rand_r (unsigned *__seed); |
| 268 |
double drand48 (void); |
| 269 |
double _drand48_r (struct _reent *); |
| 270 |
double erand48 (unsigned short [3]); |
| 271 |
double _erand48_r (struct _reent *, unsigned short [3]); |
| 272 |
long jrand48 (unsigned short [3]); |
| 273 |
long _jrand48_r (struct _reent *, unsigned short [3]); |
| 274 |
void lcong48 (unsigned short [7]); |
| 275 |
void _lcong48_r (struct _reent *, unsigned short [7]); |
| 276 |
long lrand48 (void); |
| 277 |
long _lrand48_r (struct _reent *); |
| 278 |
long mrand48 (void); |
| 279 |
long _mrand48_r (struct _reent *); |
| 280 |
long nrand48 (unsigned short [3]); |
| 281 |
long _nrand48_r (struct _reent *, unsigned short [3]); |
| 282 |
unsigned short * |
| 283 |
seed48 (unsigned short [3]); |
| 284 |
unsigned short * |
| 285 |
_seed48_r (struct _reent *, unsigned short [3]); |
| 286 |
void srand48 (long); |
| 287 |
void _srand48_r (struct _reent *, long); |
| 288 |
long long atoll (const char *__nptr); |
| 289 |
long long _atoll_r (struct _reent *, const char *__nptr); |
| 290 |
long long llabs (long long); |
| 291 |
lldiv_t lldiv (long long __numer, long long __denom); |
| 292 |
long long strtoll (const char *__n, char **__end_PTR, int __base); |
| 293 |
long long _strtoll_r (struct _reent *, const char *__n, char **__end_PTR, int __base); |
| 294 |
unsigned long long strtoull (const char *__n, char **__end_PTR, int __base); |
| 295 |
unsigned long long _strtoull_r (struct _reent *, const char *__n, char **__end_PTR, int __base); |
| 296 |
void cfree (void *); |
| 297 |
int unsetenv (const char *__string); |
| 298 |
int _unsetenv_r (struct _reent *, const char *__string); |
| 299 |
char * _dtoa_r (struct _reent *, double, int, int, int *, int*, char**); |
| 300 |
void * _malloc_r (struct _reent *, size_t) ; |
| 301 |
void * _calloc_r (struct _reent *, size_t, size_t) ; |
| 302 |
void _free_r (struct _reent *, void *) ; |
| 303 |
void * _realloc_r (struct _reent *, void *, size_t) ; |
| 304 |
void _mstats_r (struct _reent *, char *); |
| 305 |
int _system_r (struct _reent *, const char *); |
| 306 |
void __eprintf (const char *, const char *, unsigned int, const char *); |
| 307 |
extern long double strtold (const char *, char **); |
| 308 |
extern long double wcstold (const wchar_t *, wchar_t **); |
| 309 |
typedef long int __off_t; |
| 310 |
typedef int __pid_t; |
| 311 |
__extension__ typedef long long int __loff_t; |
| 312 |
struct stat; |
| 313 |
struct tms; |
| 314 |
struct timeval; |
| 315 |
struct timezone; |
| 316 |
extern int _close_r (struct _reent *, int); |
| 317 |
extern int _execve_r (struct _reent *, const char *, char *const *, char *const *); |
| 318 |
extern int _fcntl_r (struct _reent *, int, int, int); |
| 319 |
extern int _fork_r (struct _reent *); |
| 320 |
extern int _fstat_r (struct _reent *, int, struct stat *); |
| 321 |
extern int _getpid_r (struct _reent *); |
| 322 |
extern int _isatty_r (struct _reent *, int); |
| 323 |
extern int _kill_r (struct _reent *, int, int); |
| 324 |
extern int _link_r (struct _reent *, const char *, const char *); |
| 325 |
extern _off_t _lseek_r (struct _reent *, int, _off_t, int); |
| 326 |
extern int _mkdir_r (struct _reent *, const char *, int); |
| 327 |
extern int _open_r (struct _reent *, const char *, int, int); |
| 328 |
extern _ssize_t _read_r (struct _reent *, int, void *, size_t); |
| 329 |
extern int _rename_r (struct _reent *, const char *, const char *); |
| 330 |
extern void *_sbrk_r (struct _reent *, ptrdiff_t); |
| 331 |
extern int _stat_r (struct _reent *, const char *, struct stat *); |
| 332 |
extern unsigned long _times_r (struct _reent *, struct tms *); |
| 333 |
extern int _unlink_r (struct _reent *, const char *); |
| 334 |
extern int _wait_r (struct _reent *, int *); |
| 335 |
extern _ssize_t _write_r (struct _reent *, int, const void *, size_t); |
| 336 |
extern int _gettimeofday_r (struct _reent *, struct timeval *__tp, void *__tzp); |
| 337 |
typedef signed char int8_t ; |
| 338 |
typedef unsigned char uint8_t ; |
| 339 |
typedef signed char int_least8_t; |
| 340 |
typedef unsigned char uint_least8_t; |
| 341 |
typedef signed short int16_t; |
| 342 |
typedef unsigned short uint16_t; |
| 343 |
typedef int16_t int_least16_t; |
| 344 |
typedef uint16_t uint_least16_t; |
| 345 |
typedef signed long int32_t; |
| 346 |
typedef unsigned long uint32_t; |
| 347 |
typedef int32_t int_least32_t; |
| 348 |
typedef uint32_t uint_least32_t; |
| 349 |
typedef signed long long int64_t; |
| 350 |
typedef unsigned long long uint64_t; |
| 351 |
typedef int64_t int_least64_t; |
| 352 |
typedef uint64_t uint_least64_t; |
| 353 |
typedef signed int int_fast8_t; |
| 354 |
typedef unsigned int uint_fast8_t; |
| 355 |
typedef signed int int_fast16_t; |
| 356 |
typedef unsigned int uint_fast16_t; |
| 357 |
typedef signed int int_fast32_t; |
| 358 |
typedef unsigned int uint_fast32_t; |
| 359 |
typedef int_least64_t int_fast64_t; |
| 360 |
typedef uint_least64_t uint_fast64_t; |
| 361 |
typedef long long int intmax_t; |
| 362 |
typedef long long unsigned int uintmax_t; |
| 363 |
typedef signed int intptr_t; |
| 364 |
typedef unsigned int uintptr_t; |
| 365 |
void * memchr (const void *, int, size_t); |
| 366 |
int memcmp (const void *, const void *, size_t); |
| 367 |
void * memcpy (void * , const void * , size_t); |
| 368 |
void * memmove (void *, const void *, size_t); |
| 369 |
void * memset (void *, int, size_t); |
| 370 |
char *strcat (char *, const char *); |
| 371 |
char *strchr (const char *, int); |
| 372 |
int strcmp (const char *, const char *); |
| 373 |
int strcoll (const char *, const char *); |
| 374 |
char *strcpy (char *, const char *); |
| 375 |
size_t strcspn (const char *, const char *); |
| 376 |
char *strerror (int); |
| 377 |
size_t strlen (const char *); |
| 378 |
char *strncat (char *, const char *, size_t); |
| 379 |
int strncmp (const char *, const char *, size_t); |
| 380 |
char *strncpy (char *, const char *, size_t); |
| 381 |
char *strpbrk (const char *, const char *); |
| 382 |
char *strrchr (const char *, int); |
| 383 |
size_t strspn (const char *, const char *); |
| 384 |
char *strstr (const char *, const char *); |
| 385 |
char *strtok (char *, const char *); |
| 386 |
size_t strxfrm (char *, const char *, size_t); |
| 387 |
char *strtok_r (char *, const char *, char **); |
| 388 |
int bcmp (const void *, const void *, size_t); |
| 389 |
void bcopy (const void *, void *, size_t); |
| 390 |
void bzero (void *, size_t); |
| 391 |
int ffs (int); |
| 392 |
char *index (const char *, int); |
| 393 |
void * memccpy (void * , const void * , int, size_t); |
| 394 |
void * mempcpy (void *, const void *, size_t); |
| 395 |
void * memmem (const void *, size_t, const void *, size_t); |
| 396 |
void * memrchr (const void *, int, size_t); |
| 397 |
void * rawmemchr (const void *, int); |
| 398 |
char *rindex (const char *, int); |
| 399 |
char *stpcpy (char *, const char *); |
| 400 |
char *stpncpy (char *, const char *, size_t); |
| 401 |
int strcasecmp (const char *, const char *); |
| 402 |
char *strcasestr (const char *, const char *); |
| 403 |
char *strchrnul (const char *, int); |
| 404 |
char *strdup (const char *); |
| 405 |
char *_strdup_r (struct _reent *, const char *); |
| 406 |
char *strndup (const char *, size_t); |
| 407 |
char *_strndup_r (struct _reent *, const char *, size_t); |
| 408 |
int strerror_r (int, char *, size_t) __asm__ ("" "__xpg_strerror_r"); |
| 409 |
size_t strlcat (char *, const char *, size_t); |
| 410 |
size_t strlcpy (char *, const char *, size_t); |
| 411 |
int strncasecmp (const char *, const char *, size_t); |
| 412 |
size_t strnlen (const char *, size_t); |
| 413 |
char *strsep (char **, const char *); |
| 414 |
char *strlwr (char *); |
| 415 |
char *strupr (char *); |
| 416 |
char *strsignal (int __signo); |
| 417 |
char * _strerror_r (struct _reent *, int, int, int *); |
| 418 |
typedef union |
| 419 |
{ |
| 420 |
double value; |
| 421 |
struct |
| 422 |
{ |
| 423 |
unsigned int fraction1:32; |
| 424 |
unsigned int fraction0:20; |
| 425 |
unsigned int exponent :11; |
| 426 |
unsigned int sign : 1; |
| 427 |
} number; |
| 428 |
struct |
| 429 |
{ |
| 430 |
unsigned int function1:32; |
| 431 |
unsigned int function0:19; |
| 432 |
unsigned int quiet:1; |
| 433 |
unsigned int exponent: 11; |
| 434 |
unsigned int sign : 1; |
| 435 |
} nan; |
| 436 |
struct |
| 437 |
{ |
| 438 |
unsigned long lsw; |
| 439 |
unsigned long msw; |
| 440 |
} parts; |
| 441 |
long aslong[2]; |
| 442 |
} __ieee_double_shape_type; |
| 443 |
typedef union |
| 444 |
{ |
| 445 |
float value; |
| 446 |
struct |
| 447 |
{ |
| 448 |
unsigned int fraction0: 7; |
| 449 |
unsigned int fraction1: 16; |
| 450 |
unsigned int exponent: 8; |
| 451 |
unsigned int sign : 1; |
| 452 |
} number; |
| 453 |
struct |
| 454 |
{ |
| 455 |
unsigned int function1:16; |
| 456 |
unsigned int function0:6; |
| 457 |
unsigned int quiet:1; |
| 458 |
unsigned int exponent:8; |
| 459 |
unsigned int sign:1; |
| 460 |
} nan; |
| 461 |
long p1; |
| 462 |
} __ieee_float_shape_type; |
| 463 |
typedef int fp_rnd; |
| 464 |
fp_rnd fpgetround (void); |
| 465 |
fp_rnd fpsetround (fp_rnd); |
| 466 |
typedef int fp_except; |
| 467 |
fp_except fpgetmask (void); |
| 468 |
fp_except fpsetmask (fp_except); |
| 469 |
fp_except fpgetsticky (void); |
| 470 |
fp_except fpsetsticky (fp_except); |
| 471 |
typedef int fp_rdi; |
| 472 |
fp_rdi fpgetroundtoi (void); |
| 473 |
fp_rdi fpsetroundtoi (fp_rdi); |
| 474 |
int isnan (double); |
| 475 |
int isinf (double); |
| 476 |
int finite (double); |
| 477 |
int isnanf (float); |
| 478 |
int isinff (float); |
| 479 |
int finitef (float); |
| 480 |
union __dmath |
| 481 |
{ |
| 482 |
double d; |
| 483 |
__ULong i[2]; |
| 484 |
}; |
| 485 |
union __fmath |
| 486 |
{ |
| 487 |
float f; |
| 488 |
__ULong i[1]; |
| 489 |
}; |
| 490 |
union __ldmath |
| 491 |
{ |
| 492 |
long double ld; |
| 493 |
__ULong i[4]; |
| 494 |
}; |
| 495 |
extern double atan (double); |
| 496 |
extern double cos (double); |
| 497 |
extern double sin (double); |
| 498 |
extern double tan (double); |
| 499 |
extern double tanh (double); |
| 500 |
extern double frexp (double, int *); |
| 501 |
extern double modf (double, double *); |
| 502 |
extern double ceil (double); |
| 503 |
extern double fabs (double); |
| 504 |
extern double floor (double); |
| 505 |
extern double acos (double); |
| 506 |
extern double asin (double); |
| 507 |
extern double atan2 (double, double); |
| 508 |
extern double cosh (double); |
| 509 |
extern double sinh (double); |
| 510 |
extern double exp (double); |
| 511 |
extern double ldexp (double, int); |
| 512 |
extern double log (double); |
| 513 |
extern double log10 (double); |
| 514 |
extern double pow (double, double); |
| 515 |
extern double sqrt (double); |
| 516 |
extern double fmod (double, double); |
| 517 |
typedef float float_t; |
| 518 |
typedef double double_t; |
| 519 |
extern int __isinff (float x); |
| 520 |
extern int __isinfd (double x); |
| 521 |
extern int __isnanf (float x); |
| 522 |
extern int __isnand (double x); |
| 523 |
extern int __fpclassifyf (float x); |
| 524 |
extern int __fpclassifyd (double x); |
| 525 |
extern int __signbitf (float x); |
| 526 |
extern int __signbitd (double x); |
| 527 |
extern double infinity (void); |
| 528 |
extern double nan (const char *); |
| 529 |
extern int finite (double); |
| 530 |
extern double copysign (double, double); |
| 531 |
extern double logb (double); |
| 532 |
extern int ilogb (double); |
| 533 |
extern double asinh (double); |
| 534 |
extern double cbrt (double); |
| 535 |
extern double nextafter (double, double); |
| 536 |
extern double rint (double); |
| 537 |
extern double scalbn (double, int); |
| 538 |
extern double exp2 (double); |
| 539 |
extern double scalbln (double, long int); |
| 540 |
extern double tgamma (double); |
| 541 |
extern double nearbyint (double); |
| 542 |
extern long int lrint (double); |
| 543 |
extern long long int llrint (double); |
| 544 |
extern double round (double); |
| 545 |
extern long int lround (double); |
| 546 |
extern long long int llround (double); |
| 547 |
extern double trunc (double); |
| 548 |
extern double remquo (double, double, int *); |
| 549 |
extern double fdim (double, double); |
| 550 |
extern double fmax (double, double); |
| 551 |
extern double fmin (double, double); |
| 552 |
extern double fma (double, double, double); |
| 553 |
extern double log1p (double); |
| 554 |
extern double expm1 (double); |
| 555 |
extern double acosh (double); |
| 556 |
extern double atanh (double); |
| 557 |
extern double remainder (double, double); |
| 558 |
extern double gamma (double); |
| 559 |
extern double lgamma (double); |
| 560 |
extern double erf (double); |
| 561 |
extern double erfc (double); |
| 562 |
extern double log2 (double); |
| 563 |
extern double hypot (double, double); |
| 564 |
extern float atanf (float); |
| 565 |
extern float cosf (float); |
| 566 |
extern float sinf (float); |
| 567 |
extern float tanf (float); |
| 568 |
extern float tanhf (float); |
| 569 |
extern float frexpf (float, int *); |
| 570 |
extern float modff (float, float *); |
| 571 |
extern float ceilf (float); |
| 572 |
extern float fabsf (float); |
| 573 |
extern float floorf (float); |
| 574 |
extern float acosf (float); |
| 575 |
extern float asinf (float); |
| 576 |
extern float atan2f (float, float); |
| 577 |
extern float coshf (float); |
| 578 |
extern float sinhf (float); |
| 579 |
extern float expf (float); |
| 580 |
extern float ldexpf (float, int); |
| 581 |
extern float logf (float); |
| 582 |
extern float log10f (float); |
| 583 |
extern float powf (float, float); |
| 584 |
extern float sqrtf (float); |
| 585 |
extern float fmodf (float, float); |
| 586 |
extern float exp2f (float); |
| 587 |
extern float scalblnf (float, long int); |
| 588 |
extern float tgammaf (float); |
| 589 |
extern float nearbyintf (float); |
| 590 |
extern long int lrintf (float); |
| 591 |
extern long long llrintf (float); |
| 592 |
extern float roundf (float); |
| 593 |
extern long int lroundf (float); |
| 594 |
extern long long int llroundf (float); |
| 595 |
extern float truncf (float); |
| 596 |
extern float remquof (float, float, int *); |
| 597 |
extern float fdimf (float, float); |
| 598 |
extern float fmaxf (float, float); |
| 599 |
extern float fminf (float, float); |
| 600 |
extern float fmaf (float, float, float); |
| 601 |
extern float infinityf (void); |
| 602 |
extern float nanf (const char *); |
| 603 |
extern int finitef (float); |
| 604 |
extern float copysignf (float, float); |
| 605 |
extern float logbf (float); |
| 606 |
extern int ilogbf (float); |
| 607 |
extern float asinhf (float); |
| 608 |
extern float cbrtf (float); |
| 609 |
extern float nextafterf (float, float); |
| 610 |
extern float rintf (float); |
| 611 |
extern float scalbnf (float, int); |
| 612 |
extern float log1pf (float); |
| 613 |
extern float expm1f (float); |
| 614 |
extern float acoshf (float); |
| 615 |
extern float atanhf (float); |
| 616 |
extern float remainderf (float, float); |
| 617 |
extern float gammaf (float); |
| 618 |
extern float lgammaf (float); |
| 619 |
extern float erff (float); |
| 620 |
extern float erfcf (float); |
| 621 |
extern float log2f (float); |
| 622 |
extern float hypotf (float, float); |
| 623 |
extern long double atanl (long double); |
| 624 |
extern long double cosl (long double); |
| 625 |
extern long double sinl (long double); |
| 626 |
extern long double tanl (long double); |
| 627 |
extern long double tanhl (long double); |
| 628 |
extern long double frexpl (long double value, int *); |
| 629 |
extern long double modfl (long double, long double *); |
| 630 |
extern long double ceill (long double); |
| 631 |
extern long double fabsl (long double); |
| 632 |
extern long double floorl (long double); |
| 633 |
extern long double log1pl (long double); |
| 634 |
extern long double expm1l (long double); |
| 635 |
extern long double acosl (long double); |
| 636 |
extern long double asinl (long double); |
| 637 |
extern long double atan2l (long double, long double); |
| 638 |
extern long double coshl (long double); |
| 639 |
extern long double sinhl (long double); |
| 640 |
extern long double expl (long double); |
| 641 |
extern long double ldexpl (long double, int); |
| 642 |
extern long double logl (long double); |
| 643 |
extern long double log10l (long double); |
| 644 |
extern long double powl (long double, long double); |
| 645 |
extern long double sqrtl (long double); |
| 646 |
extern long double fmodl (long double, long double); |
| 647 |
extern long double hypotl (long double, long double); |
| 648 |
extern long double copysignl (long double, long double); |
| 649 |
extern long double nanl (const char *); |
| 650 |
extern int ilogbl (long double); |
| 651 |
extern long double asinhl (long double); |
| 652 |
extern long double cbrtl (long double); |
| 653 |
extern long double nextafterl (long double, long double); |
| 654 |
extern long double rintl (long double); |
| 655 |
extern long double scalbnl (long double, int); |
| 656 |
extern long double exp2l (long double); |
| 657 |
extern long double scalblnl (long double, long); |
| 658 |
extern long double tgammal (long double); |
| 659 |
extern long double nearbyintl (long double); |
| 660 |
extern long int lrintl (long double); |
| 661 |
extern long long int llrintl (long double); |
| 662 |
extern long double roundl (long double); |
| 663 |
extern long lroundl (long double); |
| 664 |
extern long long int llroundl (long double); |
| 665 |
extern long double truncl (long double); |
| 666 |
extern long double remquol (long double, long double, int *); |
| 667 |
extern long double fdiml (long double, long double); |
| 668 |
extern long double fmaxl (long double, long double); |
| 669 |
extern long double fminl (long double, long double); |
| 670 |
extern long double fmal (long double, long double, long double); |
| 671 |
extern long double acoshl (long double); |
| 672 |
extern long double atanhl (long double); |
| 673 |
extern long double remainderl (long double, long double); |
| 674 |
extern long double lgammal (long double); |
| 675 |
extern long double erfl (long double); |
| 676 |
extern long double erfcl (long double); |
| 677 |
extern double drem (double, double); |
| 678 |
extern void sincos (double, double *, double *); |
| 679 |
extern double gamma_r (double, int *); |
| 680 |
extern double lgamma_r (double, int *); |
| 681 |
extern double y0 (double); |
| 682 |
extern double y1 (double); |
| 683 |
extern double yn (int, double); |
| 684 |
extern double j0 (double); |
| 685 |
extern double j1 (double); |
| 686 |
extern double jn (int, double); |
| 687 |
extern float dremf (float, float); |
| 688 |
extern void sincosf (float, float *, float *); |
| 689 |
extern float gammaf_r (float, int *); |
| 690 |
extern float lgammaf_r (float, int *); |
| 691 |
extern float y0f (float); |
| 692 |
extern float y1f (float); |
| 693 |
extern float ynf (int, float); |
| 694 |
extern float j0f (float); |
| 695 |
extern float j1f (float); |
| 696 |
extern float jnf (int, float); |
| 697 |
extern double exp10 (double); |
| 698 |
extern double pow10 (double); |
| 699 |
extern float exp10f (float); |
| 700 |
extern float pow10f (float); |
| 701 |
extern int *__signgam (void); |
| 702 |
struct exception |
| 703 |
{ |
| 704 |
int type; |
| 705 |
char *name; |
| 706 |
double arg1; |
| 707 |
double arg2; |
| 708 |
double retval; |
| 709 |
int err; |
| 710 |
}; |
| 711 |
extern int matherr (struct exception *e); |
| 712 |
enum __fdlibm_version |
| 713 |
{ |
| 714 |
__fdlibm_ieee = -1, |
| 715 |
__fdlibm_svid, |
| 716 |
__fdlibm_xopen, |
| 717 |
__fdlibm_posix |
| 718 |
}; |
| 719 |
extern enum __fdlibm_version __fdlib_version; |
| 720 |
typedef int error_t; |
| 721 |
extern int *__errno (void); |
| 722 |
extern const char * const _sys_errlist[]; |
| 723 |
extern int _sys_nerr; |
| 724 |
typedef unsigned char u_char; |
| 725 |
typedef unsigned short u_short; |
| 726 |
typedef unsigned int u_int; |
| 727 |
typedef unsigned long u_long; |
| 728 |
typedef unsigned short ushort; |
| 729 |
typedef unsigned int uint; |
| 730 |
typedef unsigned long ulong; |
| 731 |
typedef unsigned long clock_t; |
| 732 |
typedef long time_t; |
| 733 |
struct timespec { |
| 734 |
time_t tv_sec; |
| 735 |
long tv_nsec; |
| 736 |
}; |
| 737 |
struct itimerspec { |
| 738 |
struct timespec it_interval; |
| 739 |
struct timespec it_value; |
| 740 |
}; |
| 741 |
typedef long daddr_t; |
| 742 |
typedef char * caddr_t; |
| 743 |
typedef unsigned short ino_t; |
| 744 |
typedef _off_t off_t; |
| 745 |
typedef __dev_t dev_t; |
| 746 |
typedef __uid_t uid_t; |
| 747 |
typedef __gid_t gid_t; |
| 748 |
typedef int pid_t; |
| 749 |
typedef long key_t; |
| 750 |
typedef _ssize_t ssize_t; |
| 751 |
typedef unsigned int mode_t __attribute__ ((__mode__ (__SI__))); |
| 752 |
typedef unsigned short nlink_t; |
| 753 |
typedef long fd_mask; |
| 754 |
typedef struct _types_fd_set { |
| 755 |
fd_mask fds_bits[(((64)+(((sizeof (fd_mask) * 8))-1))/((sizeof (fd_mask) * 8)))]; |
| 756 |
} _types_fd_set; |
| 757 |
typedef unsigned long clockid_t; |
| 758 |
typedef unsigned long timer_t; |
| 759 |
typedef unsigned long useconds_t; |
| 760 |
typedef long suseconds_t; |
| 761 |
union double_union |
| 762 |
{ |
| 763 |
double d; |
| 764 |
__uint32_t i[2]; |
| 765 |
}; |
| 766 |
typedef __int32_t Long; |
| 767 |
typedef union { double d; __ULong i[2]; } U; |
| 768 |
typedef struct _Bigint _Bigint; |
| 769 |
struct _reent ; |
| 770 |
struct FPI; |
| 771 |
double __ulp (double x); |
| 772 |
double __b2d (_Bigint *a , int *e); |
| 773 |
_Bigint * _Balloc (struct _reent *p, int k); |
| 774 |
void _Bfree (struct _reent *p, _Bigint *v); |
| 775 |
_Bigint * __multadd (struct _reent *p, _Bigint *, int, int); |
| 776 |
_Bigint * __s2b (struct _reent *, const char*, int, int, __ULong); |
| 777 |
_Bigint * __i2b (struct _reent *,int); |
| 778 |
_Bigint * __multiply (struct _reent *, _Bigint *, _Bigint *); |
| 779 |
_Bigint * __pow5mult (struct _reent *, _Bigint *, int k); |
| 780 |
int __hi0bits (__ULong); |
| 781 |
int __lo0bits (__ULong *); |
| 782 |
_Bigint * __d2b (struct _reent *p, double d, int *e, int *bits); |
| 783 |
_Bigint * __lshift (struct _reent *p, _Bigint *b, int k); |
| 784 |
_Bigint * __mdiff (struct _reent *p, _Bigint *a, _Bigint *b); |
| 785 |
int __mcmp (_Bigint *a, _Bigint *b); |
| 786 |
int __gethex (struct _reent *p, const char **sp, const struct FPI *fpi, Long *exp, _Bigint **bp, int sign); |
| 787 |
double __ratio (_Bigint *a, _Bigint *b); |
| 788 |
__ULong __any_on (_Bigint *b, int k); |
| 789 |
void __copybits (__ULong *c, int n, _Bigint *b); |
| 790 |
int __hexnan (const char **sp, const struct FPI *fpi, __ULong *x0); |
| 791 |
extern const double __mprec_tinytens[]; |
| 792 |
extern const double __mprec_bigtens[]; |
| 793 |
extern const double __mprec_tens[]; |
| 794 |
extern const unsigned char __hexdig[]; |
| 795 |
double _mprec_log10 (int); |
| 796 |
static int |
| 797 |
quorem(_Bigint * b , _Bigint * S) |
| 798 |
{ |
| 799 |
int n; |
| 800 |
long borrow, y; |
| 801 |
__ULong carry, q, ys; |
| 802 |
__ULong *bx, *bxe, *sx, *sxe; |
| 803 |
long z; |
| 804 |
__ULong si, zs; |
| 805 |
n = S->_wds; |
| 806 |
if (b->_wds < n) |
| 807 |
return 0; |
| 808 |
sx = S->_x; |
| 809 |
sxe = sx + --n; |
| 810 |
bx = b->_x; |
| 811 |
bxe = bx + n; |
| 812 |
q = *bxe / (*sxe + 1); |
| 813 |
if (q) |
| 814 |
{ |
| 815 |
borrow = 0; |
| 816 |
carry = 0; |
| 817 |
do |
| 818 |
{ |
| 819 |
si = *sx++; |
| 820 |
ys = (si & 0xffff) * q + carry; |
| 821 |
zs = (si >> 16) * q + (ys >> 16); |
| 822 |
carry = zs >> 16; |
| 823 |
y = (*bx & 0xffff) - (ys & 0xffff) + borrow; |
| 824 |
borrow = y >> 16; |
| 825 |
; |
| 826 |
z = (*bx >> 16) - (zs & 0xffff) + borrow; |
| 827 |
borrow = z >> 16; |
| 828 |
; |
| 829 |
(*(bx)++ = ((z) << 16) | ((y) & 0xffff)); |
| 830 |
} |
| 831 |
while (sx <= sxe); |
| 832 |
if (!*bxe) |
| 833 |
{ |
| 834 |
bx = b->_x; |
| 835 |
while (--bxe > bx && !*bxe) |
| 836 |
--n; |
| 837 |
b->_wds = n; |
| 838 |
} |
| 839 |
} |
| 840 |
if (__mcmp (b, S) >= 0) |
| 841 |
{ |
| 842 |
q++; |
| 843 |
borrow = 0; |
| 844 |
carry = 0; |
| 845 |
bx = b->_x; |
| 846 |
sx = S->_x; |
| 847 |
do |
| 848 |
{ |
| 849 |
si = *sx++; |
| 850 |
ys = (si & 0xffff) + carry; |
| 851 |
zs = (si >> 16) + (ys >> 16); |
| 852 |
carry = zs >> 16; |
| 853 |
y = (*bx & 0xffff) - (ys & 0xffff) + borrow; |
| 854 |
borrow = y >> 16; |
| 855 |
; |
| 856 |
z = (*bx >> 16) - (zs & 0xffff) + borrow; |
| 857 |
borrow = z >> 16; |
| 858 |
; |
| 859 |
(*(bx)++ = ((z) << 16) | ((y) & 0xffff)); |
| 860 |
} |
| 861 |
while (sx <= sxe); |
| 862 |
bx = b->_x; |
| 863 |
bxe = bx + n; |
| 864 |
if (!*bxe) |
| 865 |
{ |
| 866 |
while (--bxe > bx && !*bxe) |
| 867 |
--n; |
| 868 |
b->_wds = n; |
| 869 |
} |
| 870 |
} |
| 871 |
return q; |
| 872 |
} |
| 873 |
char * |
| 874 |
_dtoa_r(struct _reent *ptr , double _d , int mode , int ndigits , int *decpt , int *sign , char **rve) |
| 875 |
{ |
| 876 |
int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0, |
| 877 |
k_check, leftright, m2, m5, s2, s5, spec_case, try_quick; |
| 878 |
union double_union d, d2, eps; |
| 879 |
long L; |
| 880 |
int denorm; |
| 881 |
__ULong x; |
| 882 |
_Bigint *b, *b1, *delta, *mlo = ((void *)0), *mhi, *S; |
| 883 |
double ds; |
| 884 |
char *s, *s0; |
| 885 |
d.d = _d; |
| 886 |
; |
| 887 |
if (((ptr)->_result)) |
| 888 |
{ |
| 889 |
((ptr)->_result)->_k = ((ptr)->_result_k); |
| 890 |
((ptr)->_result)->_maxwds = 1 << ((ptr)->_result_k); |
| 891 |
_Bfree (ptr, ((ptr)->_result)); |
| 892 |
((ptr)->_result) = 0; |
| 893 |
} |
| 894 |
if ((d.i[1]) & ((__uint32_t)0x80000000L)) |
| 895 |
{ |
| 896 |
*sign = 1; |
| 897 |
(d.i[1]) &= ~((__uint32_t)0x80000000L); |
| 898 |
} |
| 899 |
else |
| 900 |
*sign = 0; |
| 901 |
if (((d.i[1]) & ((__uint32_t)0x7ff00000L)) == ((__uint32_t)0x7ff00000L)) |
| 902 |
{ |
| 903 |
*decpt = 9999; |
| 904 |
s = |
| 905 |
!(d.i[0]) && !((d.i[1]) & 0xfffff) ? "Infinity" : |
| 906 |
"NaN"; |
| 907 |
if (rve) |
| 908 |
*rve = |
| 909 |
s[3] ? s + 8 : |
| 910 |
s + 3; |
| 911 |
return s; |
| 912 |
} |
| 913 |
if (!d.d) |
| 914 |
{ |
| 915 |
*decpt = 1; |
| 916 |
s = "0"; |
| 917 |
if (rve) |
| 918 |
*rve = s + 1; |
| 919 |
return s; |
| 920 |
} |
| 921 |
b = __d2b (ptr, d.d, &be, &bbits); |
| 922 |
if ((i = (int) ((d.i[1]) >> 20 & (((__uint32_t)0x7ff00000L) >> 20))) != 0) |
| 923 |
{ |
| 924 |
d2.d = d.d; |
| 925 |
(d2.i[1]) &= ((__uint32_t)0xfffffL); |
| 926 |
(d2.i[1]) |= ((__uint32_t)0x3ff00000L); |
| 927 |
i -= 1023; |
| 928 |
denorm = 0; |
| 929 |
} |
| 930 |
else |
| 931 |
{ |
| 932 |
i = bbits + be + (1023 + (53 - 1) - 1); |
| 933 |
x = (i > 32) ? ((d.i[1]) << (64 - i)) | ((d.i[0]) >> (i - 32)) |
| 934 |
: ((d.i[0]) << (32 - i)); |
| 935 |
d2.d = x; |
| 936 |
(d2.i[1]) -= 31 * ((__uint32_t)0x100000L); |
| 937 |
i -= (1023 + (53 - 1) - 1) + 1; |
| 938 |
denorm = 1; |
| 939 |
} |
| 940 |
ds = (d2.d - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981; |
| 941 |
k = (int) ds; |
| 942 |
if (ds < 0. && ds != k) |
| 943 |
k--; |
| 944 |
k_check = 1; |
| 945 |
if (k >= 0 && k <= 22) |
| 946 |
{ |
| 947 |
if (d.d < __mprec_tens[k]) |
| 948 |
k--; |
| 949 |
k_check = 0; |
| 950 |
} |
| 951 |
j = bbits - i - 1; |
| 952 |
if (j >= 0) |
| 953 |
{ |
| 954 |
b2 = 0; |
| 955 |
s2 = j; |
| 956 |
} |
| 957 |
else |
| 958 |
{ |
| 959 |
b2 = -j; |
| 960 |
s2 = 0; |
| 961 |
} |
| 962 |
if (k >= 0) |
| 963 |
{ |
| 964 |
b5 = 0; |
| 965 |
s5 = k; |
| 966 |
s2 += k; |
| 967 |
} |
| 968 |
else |
| 969 |
{ |
| 970 |
b2 -= k; |
| 971 |
b5 = -k; |
| 972 |
s5 = 0; |
| 973 |
} |
| 974 |
if (mode < 0 || mode > 9) |
| 975 |
mode = 0; |
| 976 |
try_quick = 1; |
| 977 |
if (mode > 5) |
| 978 |
{ |
| 979 |
mode -= 4; |
| 980 |
try_quick = 0; |
| 981 |
} |
| 982 |
leftright = 1; |
| 983 |
ilim = ilim1 = -1; |
| 984 |
switch (mode) |
| 985 |
{ |
| 986 |
case 0: |
| 987 |
case 1: |
| 988 |
i = 18; |
| 989 |
ndigits = 0; |
| 990 |
break; |
| 991 |
case 2: |
| 992 |
leftright = 0; |
| 993 |
case 4: |
| 994 |
if (ndigits <= 0) |
| 995 |
ndigits = 1; |
| 996 |
ilim = ilim1 = i = ndigits; |
| 997 |
break; |
| 998 |
case 3: |
| 999 |
leftright = 0; |
| 1000 |
case 5: |
| 1001 |
i = ndigits + k + 1; |
| 1002 |
ilim = i; |
| 1003 |
ilim1 = i - 1; |
| 1004 |
if (i <= 0) |
| 1005 |
i = 1; |
| 1006 |
} |
| 1007 |
j = sizeof (__ULong); |
| 1008 |
for (((ptr)->_result_k) = 0; sizeof (_Bigint) - sizeof (__ULong) + j <= i; |
| 1009 |
j <<= 1) |
| 1010 |
((ptr)->_result_k)++; |
| 1011 |
((ptr)->_result) = _Balloc (ptr, ((ptr)->_result_k)); |
| 1012 |
s = s0 = (char *) ((ptr)->_result); |
| 1013 |
if (ilim >= 0 && ilim <= 14 && try_quick) |
| 1014 |
{ |
| 1015 |
i = 0; |
| 1016 |
d2.d = d.d; |
| 1017 |
k0 = k; |
| 1018 |
ilim0 = ilim; |
| 1019 |
ieps = 2; |
| 1020 |
if (k > 0) |
| 1021 |
{ |
| 1022 |
ds = __mprec_tens[k & 0xf]; |
| 1023 |
j = k >> 4; |
| 1024 |
if (j & 0x10) |
| 1025 |
{ |
| 1026 |
j &= 0x10 - 1; |
| 1027 |
d.d /= __mprec_bigtens[5 - 1]; |
| 1028 |
ieps++; |
| 1029 |
} |
| 1030 |
for (; j; j >>= 1, i++) |
| 1031 |
if (j & 1) |
| 1032 |
{ |
| 1033 |
ieps++; |
| 1034 |
ds *= __mprec_bigtens[i]; |
| 1035 |
} |
| 1036 |
d.d /= ds; |
| 1037 |
} |
| 1038 |
else if ((j1 = -k) != 0) |
| 1039 |
{ |
| 1040 |
d.d *= __mprec_tens[j1 & 0xf]; |
| 1041 |
for (j = j1 >> 4; j; j >>= 1, i++) |
| 1042 |
if (j & 1) |
| 1043 |
{ |
| 1044 |
ieps++; |
| 1045 |
d.d *= __mprec_bigtens[i]; |
| 1046 |
} |
| 1047 |
} |
| 1048 |
if (k_check && d.d < 1. && ilim > 0) |
| 1049 |
{ |
| 1050 |
if (ilim1 <= 0) |
| 1051 |
goto fast_failed; |
| 1052 |
ilim = ilim1; |
| 1053 |
k--; |
| 1054 |
d.d *= 10.; |
| 1055 |
ieps++; |
| 1056 |
} |
| 1057 |
eps.d = ieps * d.d + 7.; |
| 1058 |
(eps.i[1]) -= (53 - 1) * ((__uint32_t)0x100000L); |
| 1059 |
if (ilim == 0) |
| 1060 |
{ |
| 1061 |
S = mhi = 0; |
| 1062 |
d.d -= 5.; |
| 1063 |
if (d.d > eps.d) |
| 1064 |
goto one_digit; |
| 1065 |
if (d.d < -eps.d) |
| 1066 |
goto no_digits; |
| 1067 |
goto fast_failed; |
| 1068 |
} |
| 1069 |
if (leftright) |
| 1070 |
{ |
| 1071 |
eps.d = 0.5 / __mprec_tens[ilim - 1] - eps.d; |
| 1072 |
for (i = 0;;) |
| 1073 |
{ |
| 1074 |
L = d.d; |
| 1075 |
d.d -= L; |
| 1076 |
*s++ = '0' + (int) L; |
| 1077 |
if (d.d < eps.d) |
| 1078 |
goto ret1; |
| 1079 |
if (1. - d.d < eps.d) |
| 1080 |
goto bump_up; |
| 1081 |
if (++i >= ilim) |
| 1082 |
break; |
| 1083 |
eps.d *= 10.; |
| 1084 |
d.d *= 10.; |
| 1085 |
} |
| 1086 |
} |
| 1087 |
else |
| 1088 |
{ |
| 1089 |
eps.d *= __mprec_tens[ilim - 1]; |
| 1090 |
for (i = 1;; i++, d.d *= 10.) |
| 1091 |
{ |
| 1092 |
L = d.d; |
| 1093 |
d.d -= L; |
| 1094 |
*s++ = '0' + (int) L; |
| 1095 |
if (i == ilim) |
| 1096 |
{ |
| 1097 |
if (d.d > 0.5 + eps.d) |
| 1098 |
goto bump_up; |
| 1099 |
else if (d.d < 0.5 - eps.d) |
| 1100 |
{ |
| 1101 |
while (*--s == '0'); |
| 1102 |
s++; |
| 1103 |
goto ret1; |
| 1104 |
} |
| 1105 |
break; |
| 1106 |
} |
| 1107 |
} |
| 1108 |
} |
| 1109 |
fast_failed: |
| 1110 |
s = s0; |
| 1111 |
d.d = d2.d; |
| 1112 |
k = k0; |
| 1113 |
ilim = ilim0; |
| 1114 |
} |
| 1115 |
if (be >= 0 && k <= 14) |
| 1116 |
{ |
| 1117 |
ds = __mprec_tens[k]; |
| 1118 |
if (ndigits < 0 && ilim <= 0) |
| 1119 |
{ |
| 1120 |
S = mhi = 0; |
| 1121 |
if (ilim < 0 || d.d <= 5 * ds) |
| 1122 |
goto no_digits; |
| 1123 |
goto one_digit; |
| 1124 |
} |
| 1125 |
for (i = 1;; i++) |
| 1126 |
{ |
| 1127 |
L = d.d / ds; |
| 1128 |
d.d -= L * ds; |
| 1129 |
*s++ = '0' + (int) L; |
| 1130 |
if (i == ilim) |
| 1131 |
{ |
| 1132 |
d.d += d.d; |
| 1133 |
if ((d.d > ds) || ((d.d == ds) && (L & 1))) |
| 1134 |
{ |
| 1135 |
bump_up: |
| 1136 |
while (*--s == '9') |
| 1137 |
if (s == s0) |
| 1138 |
{ |
| 1139 |
k++; |
| 1140 |
*s = '0'; |
| 1141 |
break; |
| 1142 |
} |
| 1143 |
++*s++; |
| 1144 |
} |
| 1145 |
break; |
| 1146 |
} |
| 1147 |
if (!(d.d *= 10.)) |
| 1148 |
break; |
| 1149 |
} |
| 1150 |
goto ret1; |
| 1151 |
} |
| 1152 |
m2 = b2; |
| 1153 |
m5 = b5; |
| 1154 |
mhi = mlo = 0; |
| 1155 |
if (leftright) |
| 1156 |
{ |
| 1157 |
if (mode < 2) |
| 1158 |
{ |
| 1159 |
i = |
| 1160 |
denorm ? be + (1023 + (53 - 1) - 1 + 1) : |
| 1161 |
1 + 53 - bbits; |
| 1162 |
} |
| 1163 |
else |
| 1164 |
{ |
| 1165 |
j = ilim - 1; |
| 1166 |
if (m5 >= j) |
| 1167 |
m5 -= j; |
| 1168 |
else |
| 1169 |
{ |
| 1170 |
s5 += j -= m5; |
| 1171 |
b5 += j; |
| 1172 |
m5 = 0; |
| 1173 |
} |
| 1174 |
if ((i = ilim) < 0) |
| 1175 |
{ |
| 1176 |
m2 -= i; |
| 1177 |
i = 0; |
| 1178 |
} |
| 1179 |
} |
| 1180 |
b2 += i; |
| 1181 |
s2 += i; |
| 1182 |
mhi = __i2b (ptr, 1); |
| 1183 |
} |
| 1184 |
if (m2 > 0 && s2 > 0) |
| 1185 |
{ |
| 1186 |
i = m2 < s2 ? m2 : s2; |
| 1187 |
b2 -= i; |
| 1188 |
m2 -= i; |
| 1189 |
s2 -= i; |
| 1190 |
} |
| 1191 |
if (b5 > 0) |
| 1192 |
{ |
| 1193 |
if (leftright) |
| 1194 |
{ |
| 1195 |
if (m5 > 0) |
| 1196 |
{ |
| 1197 |
mhi = __pow5mult (ptr, mhi, m5); |
| 1198 |
b1 = __multiply (ptr, mhi, b); |
| 1199 |
_Bfree (ptr, b); |
| 1200 |
b = b1; |
| 1201 |
} |
| 1202 |
if ((j = b5 - m5) != 0) |
| 1203 |
b = __pow5mult (ptr, b, j); |
| 1204 |
} |
| 1205 |
else |
| 1206 |
b = __pow5mult (ptr, b, b5); |
| 1207 |
} |
| 1208 |
S = __i2b (ptr, 1); |
| 1209 |
if (s5 > 0) |
| 1210 |
S = __pow5mult (ptr, S, s5); |
| 1211 |
spec_case = 0; |
| 1212 |
if (mode < 2) |
| 1213 |
{ |
| 1214 |
if (!(d.i[0]) && !((d.i[1]) & ((__uint32_t)0xfffffL)) |
| 1215 |
&& (d.i[1]) & ((__uint32_t)0x7ff00000L) |
| 1216 |
) |
| 1217 |
{ |
| 1218 |
b2 += 1; |
| 1219 |
s2 += 1; |
| 1220 |
spec_case = 1; |
| 1221 |
} |
| 1222 |
} |
| 1223 |
if ((i = ((s5 ? 32 - __hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0x1f) != 0) |
| 1224 |
i = 32 - i; |
| 1225 |
if (i > 4) |
| 1226 |
{ |
| 1227 |
i -= 4; |
| 1228 |
b2 += i; |
| 1229 |
m2 += i; |
| 1230 |
s2 += i; |
| 1231 |
} |
| 1232 |
else if (i < 4) |
| 1233 |
{ |
| 1234 |
i += 28; |
| 1235 |
b2 += i; |
| 1236 |
m2 += i; |
| 1237 |
s2 += i; |
| 1238 |
} |
| 1239 |
if (b2 > 0) |
| 1240 |
b = __lshift (ptr, b, b2); |
| 1241 |
if (s2 > 0) |
| 1242 |
S = __lshift (ptr, S, s2); |
| 1243 |
if (k_check) |
| 1244 |
{ |
| 1245 |
if (__mcmp (b, S) < 0) |
| 1246 |
{ |
| 1247 |
k--; |
| 1248 |
b = __multadd (ptr, b, 10, 0); |
| 1249 |
if (leftright) |
| 1250 |
mhi = __multadd (ptr, mhi, 10, 0); |
| 1251 |
ilim = ilim1; |
| 1252 |
} |
| 1253 |
} |
| 1254 |
if (ilim <= 0 && mode > 2) |
| 1255 |
{ |
| 1256 |
if (ilim < 0 || __mcmp (b, S = __multadd (ptr, S, 5, 0)) <= 0) |
| 1257 |
{ |
| 1258 |
no_digits: |
| 1259 |
k = -1 - ndigits; |
| 1260 |
goto ret; |
| 1261 |
} |
| 1262 |
one_digit: |
| 1263 |
*s++ = '1'; |
| 1264 |
k++; |
| 1265 |
goto ret; |
| 1266 |
} |
| 1267 |
if (leftright) |
| 1268 |
{ |
| 1269 |
if (m2 > 0) |
| 1270 |
mhi = __lshift (ptr, mhi, m2); |
| 1271 |
mlo = mhi; |
| 1272 |
if (spec_case) |
| 1273 |
{ |
| 1274 |
mhi = _Balloc (ptr, mhi->_k); |
| 1275 |
memcpy((char *)&mhi->_sign, (char *)&mlo->_sign, mlo->_wds*sizeof(long) + 2*sizeof(int)); |
| 1276 |
mhi = __lshift (ptr, mhi, 1); |
| 1277 |
} |
| 1278 |
for (i = 1;; i++) |
| 1279 |
{ |
| 1280 |
dig = quorem (b, S) + '0'; |
| 1281 |
j = __mcmp (b, mlo); |
| 1282 |
delta = __mdiff (ptr, S, mhi); |
| 1283 |
j1 = delta->_sign ? 1 : __mcmp (b, delta); |
| 1284 |
_Bfree (ptr, delta); |
| 1285 |
if (j1 == 0 && !mode && !((d.i[0]) & 1)) |
| 1286 |
{ |
| 1287 |
if (dig == '9') |
| 1288 |
goto round_9_up; |
| 1289 |
if (j > 0) |
| 1290 |
dig++; |
| 1291 |
*s++ = dig; |
| 1292 |
goto ret; |
| 1293 |
} |
| 1294 |
if ((j < 0) || ((j == 0) && !mode |
| 1295 |
&& !((d.i[0]) & 1) |
| 1296 |
)) |
| 1297 |
{ |
| 1298 |
if (j1 > 0) |
| 1299 |
{ |
| 1300 |
b = __lshift (ptr, b, 1); |
| 1301 |
j1 = __mcmp (b, S); |
| 1302 |
if (((j1 > 0) || ((j1 == 0) && (dig & 1))) |
| 1303 |
&& dig++ == '9') |
| 1304 |
goto round_9_up; |
| 1305 |
} |
| 1306 |
*s++ = dig; |
| 1307 |
goto ret; |
| 1308 |
} |
| 1309 |
if (j1 > 0) |
| 1310 |
{ |
| 1311 |
if (dig == '9') |
| 1312 |
{ |
| 1313 |
round_9_up: |
| 1314 |
*s++ = '9'; |
| 1315 |
goto roundoff; |
| 1316 |
} |
| 1317 |
*s++ = dig + 1; |
| 1318 |
goto ret; |
| 1319 |
} |
| 1320 |
*s++ = dig; |
| 1321 |
if (i == ilim) |
| 1322 |
break; |
| 1323 |
b = __multadd (ptr, b, 10, 0); |
| 1324 |
if (mlo == mhi) |
| 1325 |
mlo = mhi = __multadd (ptr, mhi, 10, 0); |
| 1326 |
else |
| 1327 |
{ |
| 1328 |
mlo = __multadd (ptr, mlo, 10, 0); |
| 1329 |
mhi = __multadd (ptr, mhi, 10, 0); |
| 1330 |
} |
| 1331 |
} |
| 1332 |
} |
| 1333 |
else |
| 1334 |
for (i = 1;; i++) |
| 1335 |
{ |
| 1336 |
*s++ = dig = quorem (b, S) + '0'; |
| 1337 |
if (i >= ilim) |
| 1338 |
break; |
| 1339 |
b = __multadd (ptr, b, 10, 0); |
| 1340 |
} |
| 1341 |
b = __lshift (ptr, b, 1); |
| 1342 |
j = __mcmp (b, S); |
| 1343 |
if ((j > 0) || ((j == 0) && (dig & 1))) |
| 1344 |
{ |
| 1345 |
roundoff: |
| 1346 |
while (*--s == '9') |
| 1347 |
if (s == s0) |
| 1348 |
{ |
| 1349 |
k++; |
| 1350 |
*s++ = '1'; |
| 1351 |
goto ret; |
| 1352 |
} |
| 1353 |
++*s++; |
| 1354 |
} |
| 1355 |
else |
| 1356 |
{ |
| 1357 |
while (*--s == '0'); |
| 1358 |
s++; |
| 1359 |
} |
| 1360 |
ret: |
| 1361 |
_Bfree (ptr, S); |
| 1362 |
if (mhi) |
| 1363 |
{ |
| 1364 |
if (mlo && mlo != mhi) |
| 1365 |
_Bfree (ptr, mlo); |
| 1366 |
_Bfree (ptr, mhi); |
| 1367 |
} |
| 1368 |
ret1: |
| 1369 |
_Bfree (ptr, b); |
| 1370 |
*s = 0; |
| 1371 |
*decpt = k + 1; |
| 1372 |
if (rve) |
| 1373 |
*rve = s; |
| 1374 |
return s0; |
| 1375 |
} |