Raymond Toy pushed to branch master at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • src/lisp/Config.x86_common
    ... ... @@ -65,6 +65,34 @@ CORE64_SRCS=\
    65 65
     	$(CORE_MATH_64)/log1p/log1p.c \
    
    66 66
     	$(CORE_MATH_64)/expm1/expm1.c \
    
    67 67
     	$(CORE_MATH_64)/sincos/sincos.c
    
    68
    +
    
    69
    +CORE_MATH_32=core-math/src/binary32
    
    70
    +CORE32_SRCS=\
    
    71
    +	$(CORE_MATH_32)/sin/sinf.c \
    
    72
    +	$(CORE_MATH_32)/cos/cosf.c \
    
    73
    +	$(CORE_MATH_32)/tan/tanf.c \
    
    74
    +	$(CORE_MATH_32)/atan2/atan2f.c \
    
    75
    +	$(CORE_MATH_32)/asin/asinf.c \
    
    76
    +	$(CORE_MATH_32)/acos/acosf.c \
    
    77
    +	$(CORE_MATH_32)/atan/atanf.c \
    
    78
    +	$(CORE_MATH_32)/sinh/sinhf.c \
    
    79
    +	$(CORE_MATH_32)/cosh/coshf.c \
    
    80
    +	$(CORE_MATH_32)/tanh/tanhf.c \
    
    81
    +	$(CORE_MATH_32)/asinh/asinhf.c \
    
    82
    +	$(CORE_MATH_32)/acosh/acoshf.c \
    
    83
    +	$(CORE_MATH_32)/atanh/atanhf.c \
    
    84
    +	$(CORE_MATH_32)/exp/expf.c \
    
    85
    +	$(CORE_MATH_32)/log/logf.c \
    
    86
    +	$(CORE_MATH_32)/log10/log10f.c \
    
    87
    +	$(CORE_MATH_32)/log2/log2f.c \
    
    88
    +	$(CORE_MATH_32)/pow/powf.c \
    
    89
    +	$(CORE_MATH_32)/hypot/hypotf.c \
    
    90
    +	$(CORE_MATH_32)/log1p/log1pf.c \
    
    91
    +	$(CORE_MATH_32)/expm1/expm1f.c \
    
    92
    +	$(CORE_MATH_32)/sincos/sincosf.c
    
    93
    +
    
    94
    +CORE_MATH_SRCS = $(CORE64_SRCS) $(CORE32_SRCS)
    
    95
    +
    
    68 96
     endif
    
    69 97
     
    
    70 98
     ifeq ($(filter 2% 3%, $(shell $(CC) -dumpversion)),)
    

  • src/lisp/GNUmakefile
    ... ... @@ -36,7 +36,7 @@ SRCS = lisp.c coreparse.c alloc.c monitor.c print.c interr.c \
    36 36
     	dynbind.c breakpoint.c regnames.c backtrace.c save.c purify.c \
    
    37 37
     	runprog.c time.c case-mapping.c exec-init.c \
    
    38 38
     	irrat.c \
    
    39
    -	${CORE64_SRCS} \
    
    39
    +	${CORE_MATH_SRCS} \
    
    40 40
     	${FDLIBM} ${ARCH_SRC} ${ASSEM_SRC} ${OS_SRC} ${GC_SRC}
    
    41 41
     
    
    42 42
     
    

  • src/lisp/irrat.c
    ... ... @@ -32,6 +32,28 @@ extern double cr_hypot(double, double);
    32 32
     extern double cr_log1p(double);
    
    33 33
     extern double cr_expm1(double);
    
    34 34
     extern void cr_sincos(double, double *, double *);
    
    35
    +
    
    36
    +extern float cr_sinf(float);
    
    37
    +extern float cr_cosf(float);
    
    38
    +extern float cr_tanf(float);
    
    39
    +extern float cr_atanf(float);
    
    40
    +extern float cr_atan2f(float, float);
    
    41
    +extern float cr_asinf(float);
    
    42
    +extern float cr_acosf(float);
    
    43
    +extern float cr_sinhf(float);
    
    44
    +extern float cr_coshf(float);
    
    45
    +extern float cr_tanhf(float);
    
    46
    +extern float cr_asinhf(float);
    
    47
    +extern float cr_acoshf(float);
    
    48
    +extern float cr_atanhf(float);
    
    49
    +extern float cr_expf(float);
    
    50
    +extern float cr_logf(float);
    
    51
    +extern float cr_log10f(float);
    
    52
    +extern float cr_powf(float, float);
    
    53
    +extern float cr_hypotf(float, float);
    
    54
    +extern float cr_log1pf(float);
    
    55
    +extern float cr_expm1f(float);
    
    56
    +extern void cr_sincosf(float, float *, float *);
    
    35 57
     #endif
    
    36 58
     
    
    37 59
     
    
    ... ... @@ -297,7 +319,7 @@ lisp_scalbn(double x, int n)
    297 319
     }
    
    298 320
     
    
    299 321
     void
    
    300
    -lisp_sincos (double x, double *s, double *c)
    
    322
    +lisp_sincos(double x, double *s, double *c)
    
    301 323
     {
    
    302 324
     #ifdef FEATURE_CORE_MATH
    
    303 325
         cr_sincos(x, s, c);
    
    ... ... @@ -307,3 +329,236 @@ lisp_sincos (double x, double *s, double *c)
    307 329
         cmucl_sincos(x, s, c);
    
    308 330
     #endif
    
    309 331
     }
    
    332
    +
    
    333
    +/*
    
    334
    + * The single-float versions of the special functions.  When core-math
    
    335
    + * is set, we use the single-float core-math functions.  Otherwise, we
    
    336
    + * use the double-float versions from fdlibm, with appropriate
    
    337
    + * coercions.
    
    338
    + */
    
    339
    +float
    
    340
    +lisp_sinf(float x)
    
    341
    +{
    
    342
    +#ifdef FEATURE_CORE_MATH
    
    343
    +    return cr_sinf(x);
    
    344
    +#else    
    
    345
    +    return (float) fdlibm_sin((double) x);
    
    346
    +#endif    
    
    347
    +}
    
    348
    +
    
    349
    +float
    
    350
    +lisp_cosf(float x)
    
    351
    +{
    
    352
    +#ifdef FEATURE_CORE_MATH
    
    353
    +    return cr_cosf(x);
    
    354
    +#else    
    
    355
    +    return (float) fdlibm_cos((double) x);
    
    356
    +#endif
    
    357
    +}
    
    358
    +
    
    359
    +float
    
    360
    +lisp_tanf(float x)
    
    361
    +{
    
    362
    +#ifdef FEATURE_CORE_MATH
    
    363
    +    return cr_tanf(x);
    
    364
    +#else    
    
    365
    +    return (float) fdlibm_tan((double) x);
    
    366
    +#endif
    
    367
    +}
    
    368
    +
    
    369
    +float
    
    370
    +lisp_atanf(float x)
    
    371
    +{
    
    372
    +#ifdef FEATURE_CORE_MATH
    
    373
    +    return cr_atanf(x);
    
    374
    +#else    
    
    375
    +    return (float) fdlibm_atan((double) x);
    
    376
    +#endif
    
    377
    +}
    
    378
    +
    
    379
    +float
    
    380
    +lisp_atan2f(float y, float x)
    
    381
    +{
    
    382
    +#ifdef FEATURE_CORE_MATH
    
    383
    +    return cr_atan2f(y, x);
    
    384
    +#else    
    
    385
    +    return (float) __ieee754_atan2((double) y, (double) x);
    
    386
    +#endif
    
    387
    +}
    
    388
    +
    
    389
    +float
    
    390
    +lisp_asinf(float x)
    
    391
    +{
    
    392
    +#ifdef FEATURE_CORE_MATH
    
    393
    +    return cr_asinf(x);
    
    394
    +#else    
    
    395
    +    return (float) __ieee754_asin((double) x);
    
    396
    +#endif
    
    397
    +}
    
    398
    +
    
    399
    +float
    
    400
    +lisp_acosf(float x)
    
    401
    +{
    
    402
    +#ifdef FEATURE_CORE_MATH
    
    403
    +    return cr_acosf(x);
    
    404
    +#else    
    
    405
    +    return (float) __ieee754_acos((double) x);
    
    406
    +#endif
    
    407
    +}
    
    408
    +
    
    409
    +float
    
    410
    +lisp_sinhf(float x)
    
    411
    +{
    
    412
    +#ifdef FEATURE_CORE_MATH
    
    413
    +    return cr_sinhf(x);
    
    414
    +#else    
    
    415
    +    return (float) __ieee754_sinh((double) x);
    
    416
    +#endif
    
    417
    +}
    
    418
    +
    
    419
    +float
    
    420
    +lisp_coshf(float x)
    
    421
    +{
    
    422
    +#ifdef FEATURE_CORE_MATH
    
    423
    +    return cr_coshf(x);
    
    424
    +#else    
    
    425
    +    return (float) __ieee754_cosh((double) x);
    
    426
    +#endif
    
    427
    +}
    
    428
    +
    
    429
    +float
    
    430
    +lisp_tanhf(float x)
    
    431
    +{
    
    432
    +#ifdef FEATURE_CORE_MATH
    
    433
    +    return cr_tanhf(x);
    
    434
    +#else    
    
    435
    +    return (float) fdlibm_tanh((double) x);
    
    436
    +#endif
    
    437
    +}
    
    438
    +
    
    439
    +float
    
    440
    +lisp_asinhf(float x)
    
    441
    +{
    
    442
    +#ifdef FEATURE_CORE_MATH
    
    443
    +    return cr_asinhf(x);
    
    444
    +#else    
    
    445
    +    return (float) fdlibm_asinh((double) x);
    
    446
    +#endif
    
    447
    +}
    
    448
    +
    
    449
    +float
    
    450
    +lisp_acoshf(float x)
    
    451
    +{
    
    452
    +#ifdef FEATURE_CORE_MATH
    
    453
    +    return cr_acoshf(x);
    
    454
    +#else    
    
    455
    +    return (float) __ieee754_acosh((double) x);
    
    456
    +#endif
    
    457
    +}
    
    458
    +
    
    459
    +float
    
    460
    +lisp_atanhf(float x)
    
    461
    +{
    
    462
    +#ifdef FEATURE_CORE_MATH
    
    463
    +    return cr_atanhf(x);
    
    464
    +#else    
    
    465
    +    return (float) __ieee754_atanh((double) x);
    
    466
    +#endif
    
    467
    +}
    
    468
    +
    
    469
    +float
    
    470
    +lisp_expf(float x)
    
    471
    +{
    
    472
    +#ifdef FEATURE_CORE_MATH
    
    473
    +    return cr_expf(x);
    
    474
    +#else    
    
    475
    +    return (float) __ieee754_exp((double) x);
    
    476
    +#endif
    
    477
    +}
    
    478
    +
    
    479
    +float
    
    480
    +lisp_logf(float x)
    
    481
    +{
    
    482
    +#ifdef FEATURE_CORE_MATH
    
    483
    +    return cr_logf(x);
    
    484
    +#else    
    
    485
    +    return (float) __ieee754_log((double) x);
    
    486
    +#endif
    
    487
    +}
    
    488
    +
    
    489
    +float
    
    490
    +lisp_log10f(float x)
    
    491
    +{
    
    492
    +#ifdef FEATURE_CORE_MATH
    
    493
    +    return cr_log10f(x);
    
    494
    +#else    
    
    495
    +    return (float) __ieee754_log10((double) x);
    
    496
    +#endif
    
    497
    +}
    
    498
    +
    
    499
    +float
    
    500
    +lisp_powf(float x, float y)
    
    501
    +{
    
    502
    +#ifdef FEATURE_CORE_MATH
    
    503
    +    /*
    
    504
    +     * cr_pow when compiled with older versions of gcc or clang can
    
    505
    +     * cause failures in the ansi-tests [#469].  Ubuntu 25.10 and Fedora 41
    
    506
    +     * (gcc only) are known to have compilers that work well enough
    
    507
    +     * that the ansi-tests pass.
    
    508
    +     */
    
    509
    +    return cr_powf(x, y);
    
    510
    +#else    
    
    511
    +    /*
    
    512
    +     * cr_pow seems causes ansi-tests to fail in test WRITE.1 among
    
    513
    +     * others.  Somewhere an invalid operation is occurring.  Thus
    
    514
    +     * just use fdlibm for now until we can figure out what's causing
    
    515
    +     * the failure.
    
    516
    +     */
    
    517
    +    return (float) __ieee754_pow((double) x, (double) y);
    
    518
    +#endif
    
    519
    +}
    
    520
    +
    
    521
    +float
    
    522
    +lisp_hypotf(float x, float y)
    
    523
    +{
    
    524
    +#ifdef FEATURE_CORE_MATH
    
    525
    +    return cr_hypotf(x, y);
    
    526
    +#else    
    
    527
    +    return (float) __ieee754_hypot((double) x, (double) y);
    
    528
    +#endif
    
    529
    +}
    
    530
    +
    
    531
    +float
    
    532
    +lisp_log1pf(float x)
    
    533
    +{
    
    534
    +#ifdef FEATURE_CORE_MATH
    
    535
    +    return cr_log1pf(x);
    
    536
    +#else    
    
    537
    +    return (float) fdlibm_log1p((double) x);
    
    538
    +#endif
    
    539
    +}
    
    540
    +
    
    541
    +float
    
    542
    +lisp_expm1f(float x)
    
    543
    +{
    
    544
    +#ifdef FEATURE_CORE_MATH
    
    545
    +    return cr_expm1f(x);
    
    546
    +#else    
    
    547
    +    return (float) fdlibm_expm1((double) x);
    
    548
    +#endif
    
    549
    +}
    
    550
    +
    
    551
    +void
    
    552
    +lisp_sincosf(float x, float *s, float *c)
    
    553
    +{
    
    554
    +#ifdef FEATURE_CORE_MATH
    
    555
    +    cr_sincosf(x, s, c);
    
    556
    +#else    
    
    557
    +    extern void cmucl_sincos(double, double*, double*);
    
    558
    +    double ds, dc;
    
    559
    +    
    
    560
    +    cmucl_sincos((double) x, &ds, &dc);
    
    561
    +    *s = (float) ds;
    
    562
    +    *c = (float) dc;
    
    563
    +#endif
    
    564
    +}