Revision 7a0e1f41 target-i386/helper.c

b/target-i386/helper.c
2541 2541

  
2542 2542
void helper_fbst_ST0_A0(void)
2543 2543
{
2544
    CPU86_LDouble tmp;
2545 2544
    int v;
2546 2545
    target_ulong mem_ref, mem_end;
2547 2546
    int64_t val;
2548 2547

  
2549
    tmp = rint(ST0);
2550
    val = (int64_t)tmp;
2548
    val = floatx_to_int64(ST0, &env->fp_status);
2551 2549
    mem_ref = A0;
2552 2550
    mem_end = mem_ref + 9;
2553 2551
    if (val < 0) {
......
2740 2738

  
2741 2739
void helper_frndint(void)
2742 2740
{
2743
    CPU86_LDouble a;
2744

  
2745
    a = ST0;
2746
#ifdef __arm__
2747
    switch(env->fpuc & RC_MASK) {
2748
    default:
2749
    case RC_NEAR:
2750
        asm("rndd %0, %1" : "=f" (a) : "f"(a));
2751
        break;
2752
    case RC_DOWN:
2753
        asm("rnddm %0, %1" : "=f" (a) : "f"(a));
2754
        break;
2755
    case RC_UP:
2756
        asm("rnddp %0, %1" : "=f" (a) : "f"(a));
2757
        break;
2758
    case RC_CHOP:
2759
        asm("rnddz %0, %1" : "=f" (a) : "f"(a));
2760
        break;
2761
    }
2762
#else
2763
    a = rint(a);
2764
#endif
2765
    ST0 = a;
2741
    ST0 = floatx_round_to_int(ST0, &env->fp_status);
2766 2742
}
2767 2743

  
2768 2744
void helper_fscale(void)
......
3263 3239
    return 1.0 / a;
3264 3240
}
3265 3241

  
3266
/* XXX: find a better solution */
3267
double helper_sqrt(double a)
3242
void update_fp_status(void)
3268 3243
{
3269
    return sqrt(a);
3270
}
3244
    int rnd_type;
3271 3245

  
3272
/* XXX: move that to another file */
3273
#if defined(__powerpc__)
3274
/* better to call an helper on ppc */
3275
float int32_to_float32(int32_t a)
3276
{
3277
    return (float)a;
3278
}
3279

  
3280
double int32_to_float64(int32_t a)
3281
{
3282
    return (double)a;
3283
}
3246
    /* set rounding mode */
3247
    switch(env->fpuc & RC_MASK) {
3248
    default:
3249
    case RC_NEAR:
3250
        rnd_type = float_round_nearest_even;
3251
        break;
3252
    case RC_DOWN:
3253
        rnd_type = float_round_down;
3254
        break;
3255
    case RC_UP:
3256
        rnd_type = float_round_up;
3257
        break;
3258
    case RC_CHOP:
3259
        rnd_type = float_round_to_zero;
3260
        break;
3261
    }
3262
    set_float_rounding_mode(rnd_type, &env->fp_status);
3263
#ifdef FLOATX80
3264
    switch((env->fpuc >> 8) & 3) {
3265
    case 0:
3266
        rnd_type = 32;
3267
        break;
3268
    case 2:
3269
        rnd_type = 64;
3270
        break;
3271
    case 3:
3272
    default:
3273
        rnd_type = 80;
3274
        break;
3275
    }
3276
    set_floatx80_rounding_precision(rnd_type, &env->fp_status);
3284 3277
#endif
3278
}
3285 3279

  
3286 3280
#if !defined(CONFIG_USER_ONLY) 
3287 3281

  

Also available in: Unified diff