Raymond Toy pushed to branch issue-435-add-core-math-lisp-support at cmucl / cmucl

Commits:

13 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -9,6 +9,18 @@ variables:
    9 9
       tar_ext: "xz"
    
    10 10
       bootstrap: ""
    
    11 11
     
    
    12
    +workflow:
    
    13
    +  rules:
    
    14
    +    # Always run on schedules (for analyze and markdown-link-check stages)
    
    15
    +    - if: $CI_PIPELINE_SOURCE == "schedule"
    
    16
    +    # Run on merge requests
    
    17
    +    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    
    18
    +    # Don't create a branch pipeline when an MR pipeline already exists
    
    19
    +    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
    
    20
    +      when: never
    
    21
    +    - if: $CI_COMMIT_BRANCH
    
    22
    +    - if: $CI_COMMIT_TAG
    
    23
    +
    
    12 24
     # Default install configuration to download the cmucl tarballs to use
    
    13 25
     # for building.
    
    14 26
     .install_template: &install_configuration
    
    ... ... @@ -159,18 +171,12 @@ linux:cross-build:
    159 171
         CONFIG: "x86_linux"
    
    160 172
     
    
    161 173
       needs:
    
    162
    -
    
    163
    -    # Normally need the linux:install stage to get the compiler to
    
    164
    -    # use.  But for #337, we need the normal build from linux:build to
    
    165
    -    # do the cross-compile.  Once the snapshot is made, we can use
    
    166
    -    # linux:install instead.
    
    167
    -    - job: linux:build
    
    168
    -    #- job: linux:install
    
    174
    +    - job: linux:install
    
    169 175
           artifacts: true
    
    170 176
       script:
    
    171 177
         - bin/create-target.sh xtarget $CONFIG
    
    172 178
         - bin/create-target.sh xcross $CONFIG
    
    173
    -    - bin/cross-build-world.sh -crl xtarget xcross src/tools/cross-scripts/cross-x86-x86.lisp dist/bin/lisp
    
    179
    +    - bin/cross-build-world.sh -crl xtarget xcross src/tools/cross-scripts/cross-x86-x86.lisp snapshot/bin/lisp
    
    174 180
         - bin/build.sh -b xlinux $bootstrap -R -C $CONFIG -o "xtarget/lisp/lisp -lib xtarget/lisp"
    
    175 181
         - bin/make-dist.sh -I xdist xlinux-4
    
    176 182
     
    
    ... ... @@ -294,7 +300,11 @@ linux:static-analyzer:
    294 300
       needs:
    
    295 301
         - job: linux:build
    
    296 302
           artifacts: true
    
    297
    -  when: manual
    
    303
    +  rules:
    
    304
    +    - if: $CI_PIPELINE_SOURCE == "schedule"
    
    305
    +    - if: $RUN_CHECKS
    
    306
    +    - when: manual
    
    307
    +      allow_failure: true
    
    298 308
       script:
    
    299 309
         # Analysis can generate huge amounts of output.  For now just save
    
    300 310
         # the results to the log file instead of also having it go to the
    
    ... ... @@ -354,10 +364,16 @@ markdown-link-check:
    354 364
       # Only the linux runner has markdown-link-check installed
    
    355 365
       tags:
    
    356 366
         - linux
    
    357
    -  when: manual
    
    358 367
       # It's ok if this fails; we don't want to declare the entire
    
    359 368
       # pipeline as having failed.
    
    360 369
       allow_failure: true
    
    370
    +  # This job doesn't depend on any others.
    
    371
    +  needs: []
    
    372
    +  rules:
    
    373
    +    - if: $CI_PIPELINE_SOURCE == "schedule"
    
    374
    +    - if: $RUN_CHECKS
    
    375
    +    - when: manual
    
    376
    +      allow_failure: true
    
    361 377
       script:
    
    362 378
         # Check links in the main repo
    
    363 379
         - find . -name \*.md -print0 | xargs -0 -n1 markdown-link-check
    
    ... ... @@ -366,3 +382,4 @@ markdown-link-check:
    366 382
         # https://gitlab.com/gitlab-org/gitlab/-/issues/17845.
    
    367 383
         - git clone https://gitlab.common-lisp.net/cmucl/cmucl.wiki.git
    
    368 384
         - find cmucl.wiki -name \*.md -print0 | xargs -0 -n1 markdown-link-check
    
    385
    +

  • src/code/irrat.lisp
    ... ... @@ -56,10 +56,9 @@
    56 56
     	       (push (list (intern (format nil "ARG-~D" i))
    
    57 57
     			   'double-float)
    
    58 58
     		     results))))
    
    59
    -       ;; We assume the single-float version has the same C name as
    
    60
    -       ;; the double-float version except an "f" is appended.  The
    
    61
    -       ;; lisp name is the same as the double-float name except "F" is
    
    62
    -       ;; appended.
    
    59
    +       ;; The C99 convention is for the float version to have the same
    
    60
    +       ;; name as the double version but with an "f" appended.  We do
    
    61
    +       ;; the same here and append an "F" to the lisp name too.
    
    63 62
            (alien:def-alien-routine (,(concatenate 'string c-name "f")
    
    64 63
     				 ,(symbolicate lisp-name "F"))
    
    65 64
     	 single-float
    

  • src/lisp/irrat.c
    ... ... @@ -58,6 +58,31 @@ extern void cr_sincosf(float, float *, float *);
    58 58
     extern float cr_log2f(float);
    
    59 59
     #else
    
    60 60
     #include "openlibm_math.h"
    
    61
    +/*
    
    62
    + * Declare the openlibm functions we use.  This is needed because we
    
    63
    + * changed the names of the openlibm functions.
    
    64
    + */
    
    65
    +extern float openlibm_asinhf(float);
    
    66
    +extern float openlibm_atanf(float);
    
    67
    +extern float openlibm_cosf(float);
    
    68
    +extern float openlibm_expm1f(float);
    
    69
    +extern float openlibm_log1pf(float);
    
    70
    +extern float openlibm_sinf(float);
    
    71
    +extern float openlibm_tanf(float);
    
    72
    +extern float openlibm_tanhf(float);
    
    73
    +extern void openlibm_sincosf(float, float*, float*);
    
    74
    +extern float __ieee754_acosf(float);
    
    75
    +extern float __ieee754_acoshf(float);
    
    76
    +extern float __ieee754_logf(float);
    
    77
    +extern float __ieee754_atanhf(float);
    
    78
    +extern float __ieee754_asinf(float);
    
    79
    +extern float __ieee754_atan2f(float, float);
    
    80
    +extern float __ieee754_expf(float);
    
    81
    +extern float __ieee754_coshf(float);
    
    82
    +extern float __ieee754_log10f(float);
    
    83
    +extern float __ieee754_sinhf(float);
    
    84
    +extern float __ieee754_hypotf(float, float);
    
    85
    +
    
    61 86
     #endif
    
    62 87
     
    
    63 88
     
    
    ... ... @@ -80,17 +105,6 @@ extern float cr_log2f(float);
    80 105
             }						    \
    
    81 106
         } while (0)
    
    82 107
         
    
    83
    -
    
    84
    -#ifdef DARWIN
    
    85
    -#define DARWIN_SINGLE_FLOAT_OVERFLOW(y) \
    
    86
    -    do {				\
    
    87
    -        if (fabs(y) >= 0x1.0p128) {				\
    
    88
    -	    return fdlibm_setexception(y, FDLIBM_OVERFLOW);	\
    
    89
    -	}							\
    
    90
    -    } while (0)
    
    91
    -    
    
    92
    -#endif
    
    93
    -    
    
    94 108
     double
    
    95 109
     lisp_sin(double x)
    
    96 110
     {
    
    ... ... @@ -372,7 +386,7 @@ lisp_sinf(float x)
    372 386
     #ifdef FEATURE_CORE_MATH
    
    373 387
         return cr_sinf(x);
    
    374 388
     #else    
    
    375
    -    return sinf(x);
    
    389
    +    return openlibm_sinf(x);
    
    376 390
     #endif    
    
    377 391
     }
    
    378 392
     
    
    ... ... @@ -382,7 +396,7 @@ lisp_cosf(float x)
    382 396
     #ifdef FEATURE_CORE_MATH
    
    383 397
         return cr_cosf(x);
    
    384 398
     #else    
    
    385
    -    return cosf(x);
    
    399
    +    return openlibm_cosf(x);
    
    386 400
     #endif
    
    387 401
     }
    
    388 402
     
    
    ... ... @@ -392,7 +406,7 @@ lisp_tanf(float x)
    392 406
     #ifdef FEATURE_CORE_MATH
    
    393 407
         return cr_tanf(x);
    
    394 408
     #else    
    
    395
    -    return tanf(x);
    
    409
    +    return openlibm_tanf(x);
    
    396 410
     #endif
    
    397 411
     }
    
    398 412
     
    
    ... ... @@ -402,7 +416,7 @@ lisp_atanf(float x)
    402 416
     #ifdef FEATURE_CORE_MATH
    
    403 417
         return cr_atanf(x);
    
    404 418
     #else    
    
    405
    -    return atanf(x);
    
    419
    +    return openlibm_atanf(x);
    
    406 420
     #endif
    
    407 421
     }
    
    408 422
     
    
    ... ... @@ -412,7 +426,7 @@ lisp_atan2f(float y, float x)
    412 426
     #ifdef FEATURE_CORE_MATH
    
    413 427
         return cr_atan2f(y, x);
    
    414 428
     #else    
    
    415
    -    return atan2f(y, x);
    
    429
    +    return __ieee754_atan2f(y, x);
    
    416 430
     #endif
    
    417 431
     }
    
    418 432
     
    
    ... ... @@ -422,7 +436,7 @@ lisp_asinf(float x)
    422 436
     #ifdef FEATURE_CORE_MATH
    
    423 437
         return cr_asinf(x);
    
    424 438
     #else    
    
    425
    -    return asinf(x);
    
    439
    +    return __ieee754_asinf(x);
    
    426 440
     #endif
    
    427 441
     }
    
    428 442
     
    
    ... ... @@ -432,7 +446,7 @@ lisp_acosf(float x)
    432 446
     #ifdef FEATURE_CORE_MATH
    
    433 447
         return cr_acosf(x);
    
    434 448
     #else    
    
    435
    -    return acosf(x);
    
    449
    +    return __ieee754_acosf(x);
    
    436 450
     #endif
    
    437 451
     }
    
    438 452
     
    
    ... ... @@ -442,7 +456,7 @@ lisp_sinhf(float x)
    442 456
     #ifdef FEATURE_CORE_MATH
    
    443 457
         return cr_sinhf(x);
    
    444 458
     #else    
    
    445
    -    return sinhf(x);
    
    459
    +    return __ieee754_sinhf(x);
    
    446 460
     #endif
    
    447 461
     }
    
    448 462
     
    
    ... ... @@ -452,7 +466,7 @@ lisp_coshf(float x)
    452 466
     #ifdef FEATURE_CORE_MATH
    
    453 467
         return cr_coshf(x);
    
    454 468
     #else    
    
    455
    -    return coshf(x);
    
    469
    +    return __ieee754_coshf(x);
    
    456 470
     #endif
    
    457 471
     }
    
    458 472
     
    
    ... ... @@ -462,7 +476,7 @@ lisp_tanhf(float x)
    462 476
     #ifdef FEATURE_CORE_MATH
    
    463 477
         return cr_tanhf(x);
    
    464 478
     #else    
    
    465
    -    return tanhf(x);
    
    479
    +    return openlibm_tanhf(x);
    
    466 480
     #endif
    
    467 481
     }
    
    468 482
     
    
    ... ... @@ -472,7 +486,7 @@ lisp_asinhf(float x)
    472 486
     #ifdef FEATURE_CORE_MATH
    
    473 487
         return cr_asinhf(x);
    
    474 488
     #else    
    
    475
    -    return asinhf((double) x);
    
    489
    +    return openlibm_asinhf((double) x);
    
    476 490
     #endif
    
    477 491
     }
    
    478 492
     
    
    ... ... @@ -482,7 +496,7 @@ lisp_acoshf(float x)
    482 496
     #ifdef FEATURE_CORE_MATH
    
    483 497
         return cr_acoshf(x);
    
    484 498
     #else    
    
    485
    -    return acoshf(x);
    
    499
    +    return __ieee754_acoshf(x);
    
    486 500
     #endif
    
    487 501
     }
    
    488 502
     
    
    ... ... @@ -492,7 +506,7 @@ lisp_atanhf(float x)
    492 506
     #ifdef FEATURE_CORE_MATH
    
    493 507
         return cr_atanhf(x);
    
    494 508
     #else    
    
    495
    -    return atanhf(x);
    
    509
    +    return __ieee754_atanhf(x);
    
    496 510
     #endif
    
    497 511
     }
    
    498 512
     
    
    ... ... @@ -502,7 +516,7 @@ lisp_expf(float x)
    502 516
     #ifdef FEATURE_CORE_MATH
    
    503 517
         return cr_expf(x);
    
    504 518
     #else    
    
    505
    -    return expf(x);
    
    519
    +    return __ieee754_expf(x);
    
    506 520
     #endif
    
    507 521
     }
    
    508 522
     
    
    ... ... @@ -512,7 +526,7 @@ lisp_logf(float x)
    512 526
     #ifdef FEATURE_CORE_MATH
    
    513 527
         return cr_logf(x);
    
    514 528
     #else    
    
    515
    -    return log(x);
    
    529
    +    return __ieee754_log(x);
    
    516 530
     #endif
    
    517 531
     }
    
    518 532
     
    
    ... ... @@ -522,7 +536,7 @@ lisp_log10f(float x)
    522 536
     #ifdef FEATURE_CORE_MATH
    
    523 537
         return cr_log10f(x);
    
    524 538
     #else    
    
    525
    -    return log10f(x);
    
    539
    +    return __ieee754_log10f(x);
    
    526 540
     #endif
    
    527 541
     }
    
    528 542
     
    
    ... ... @@ -554,7 +568,7 @@ lisp_hypotf(float x, float y)
    554 568
     #ifdef FEATURE_CORE_MATH
    
    555 569
         return cr_hypotf(x, y);
    
    556 570
     #else    
    
    557
    -    return hypotf(x, y);
    
    571
    +    return __ieee754_hypotf(x, y);
    
    558 572
     #endif
    
    559 573
     }
    
    560 574
     
    
    ... ... @@ -564,7 +578,7 @@ lisp_log1pf(float x)
    564 578
     #ifdef FEATURE_CORE_MATH
    
    565 579
         return cr_log1pf(x);
    
    566 580
     #else    
    
    567
    -    return log1pf(x);
    
    581
    +    return openlibm_log1pf(x);
    
    568 582
     #endif
    
    569 583
     }
    
    570 584
     
    
    ... ... @@ -574,7 +588,7 @@ lisp_expm1f(float x)
    574 588
     #ifdef FEATURE_CORE_MATH
    
    575 589
         return cr_expm1f(x);
    
    576 590
     #else    
    
    577
    -    return expm1f(x);
    
    591
    +    return openlibm_expm1f(x);
    
    578 592
     #endif
    
    579 593
     }
    
    580 594
     
    
    ... ... @@ -584,9 +598,9 @@ lisp_sincosf(float x, float *s, float *c)
    584 598
     #ifdef FEATURE_CORE_MATH
    
    585 599
         cr_sincosf(x, s, c);
    
    586 600
     #else    
    
    587
    -    extern void sincosf(float x, float *s, float *c);
    
    601
    +    extern void openlibm_sincosf(float x, float *s, float *c);
    
    588 602
     
    
    589
    -    sincosf(x, s, c);
    
    603
    +    openlibm_sincosf(x, s, c);
    
    590 604
     #endif
    
    591 605
     }
    
    592 606
     
    

  • src/lisp/openlibm/math_private.h
    ... ... @@ -309,6 +309,7 @@ irint(double x)
    309 309
     #define	__ieee754_yn	yn
    
    310 310
     #define	__ieee754_remainder remainder
    
    311 311
     #define	__ieee754_sqrtf	sqrtf
    
    312
    +#if 0
    
    312 313
     #define	__ieee754_acosf	acosf
    
    313 314
     #define	__ieee754_acoshf acoshf
    
    314 315
     #define	__ieee754_logf	logf
    
    ... ... @@ -317,14 +318,31 @@ irint(double x)
    317 318
     #define	__ieee754_atan2f atan2f
    
    318 319
     #define	__ieee754_expf	expf
    
    319 320
     #define	__ieee754_coshf	coshf
    
    321
    +#else
    
    322
    +extern float __ieee754_acosf(float);
    
    323
    +extern float __ieee754_acoshf(float);
    
    324
    +extern float __ieee754_logf(float);
    
    325
    +extern float __ieee754_atanhf(float);
    
    326
    +extern float __ieee754_asinf(float);
    
    327
    +extern float __ieee754_atan2f(float, float);
    
    328
    +extern float __ieee754_expf(float);
    
    329
    +extern float __ieee754_coshf(float);
    
    330
    +#endif
    
    320 331
     #define	__ieee754_fmodf	fmodf
    
    321 332
     #define	__ieee754_powf	powf
    
    322 333
     #define	__ieee754_lgammaf lgammaf
    
    323 334
     #define	__ieee754_lgammaf_r lgammaf_r
    
    335
    +#if 0
    
    324 336
     #define	__ieee754_log10f log10f
    
    325 337
     #define	__ieee754_log2f log2f
    
    326 338
     #define	__ieee754_sinhf	sinhf
    
    327 339
     #define	__ieee754_hypotf hypotf
    
    340
    +#else
    
    341
    +extern float __ieee754_log10f(float);
    
    342
    +extern float __ieee754_log2f(float);
    
    343
    +extern float __ieee754_sinhf(float);
    
    344
    +extern float __ieee754_hypotf(float, float);
    
    345
    +#endif
    
    328 346
     #define	__ieee754_j0f	j0f
    
    329 347
     #define	__ieee754_j1f	j1f
    
    330 348
     #define	__ieee754_y0f	y0f
    

  • src/lisp/openlibm/s_asinhf.c
    ... ... @@ -26,7 +26,7 @@ ln2 = 6.9314718246e-01, /* 0x3f317218 */
    26 26
     huge=  1.0000000000e+30;
    
    27 27
     
    
    28 28
     OLM_DLLEXPORT float
    
    29
    -asinhf(float x)
    
    29
    +openlibm_asinhf(float x)
    
    30 30
     {
    
    31 31
     	float t,w;
    
    32 32
     	int32_t hx,ix;
    

  • src/lisp/openlibm/s_atanf.c
    ... ... @@ -47,7 +47,7 @@ one = 1.0,
    47 47
     huge   = 1.0e30;
    
    48 48
     
    
    49 49
     OLM_DLLEXPORT float
    
    50
    -atanf(float x)
    
    50
    +openlibm_atanf(float x)
    
    51 51
     {
    
    52 52
     	float w,s1,s2,z;
    
    53 53
     	int32_t ix,hx,id;
    

  • src/lisp/openlibm/s_cosf.c
    ... ... @@ -36,7 +36,7 @@ c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
    36 36
     c4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
    
    37 37
     
    
    38 38
     OLM_DLLEXPORT float
    
    39
    -cosf(float x)
    
    39
    +openlibm_cosf(float x)
    
    40 40
     {
    
    41 41
     	double y;
    
    42 42
     	int32_t n, hx, ix;
    

  • src/lisp/openlibm/s_expm1f.c
    ... ... @@ -38,7 +38,7 @@ Q1 = -3.3333212137e-2, /* -0x888868.0p-28 */
    38 38
     Q2 =  1.5807170421e-3;		/*  0xcf3010.0p-33 */
    
    39 39
     
    
    40 40
     OLM_DLLEXPORT float
    
    41
    -expm1f(float x)
    
    41
    +openlibm_expm1f(float x)
    
    42 42
     {
    
    43 43
     	float y,hi,lo,c,t,e,hxs,hfx,r1,twopk;
    
    44 44
     	int32_t k,xsb;
    

  • src/lisp/openlibm/s_log1pf.c
    ... ... @@ -36,7 +36,7 @@ Lp7 = 1.4798198640e-01; /* 3E178897 */
    36 36
     static const float zero = 0.0;
    
    37 37
     
    
    38 38
     OLM_DLLEXPORT float
    
    39
    -log1pf(float x)
    
    39
    +openlibm_log1pf(float x)
    
    40 40
     {
    
    41 41
     	float hfsq,f,c,s,z,R,u;
    
    42 42
     	int32_t k,hx,hu,ax;
    

  • src/lisp/openlibm/s_sincosf.c
    ... ... @@ -73,7 +73,7 @@ __kernel_sincosdf( double x, float * s, float * c )
    73 73
     }
    
    74 74
     
    
    75 75
     OLM_DLLEXPORT void
    
    76
    -sincosf(float x, float * s, float * c) {
    
    76
    +openlibm_sincosf(float x, float * s, float * c) {
    
    77 77
     	// Worst approximation of sin and cos NA
    
    78 78
     	*s = x;
    
    79 79
     	*c = x;
    

  • src/lisp/openlibm/s_sinf.c
    ... ... @@ -36,7 +36,7 @@ s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
    36 36
     s4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
    
    37 37
     
    
    38 38
     OLM_DLLEXPORT float
    
    39
    -sinf(float x)
    
    39
    +openlibm_sinf(float x)
    
    40 40
     {
    
    41 41
     	double y;
    
    42 42
     	int32_t n, hx, ix;
    

  • src/lisp/openlibm/s_tanf.c
    ... ... @@ -34,7 +34,7 @@ t3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
    34 34
     t4pio2 = 4*M_PI_2;			/* 0x401921FB, 0x54442D18 */
    
    35 35
     
    
    36 36
     OLM_DLLEXPORT float
    
    37
    -tanf(float x)
    
    37
    +openlibm_tanf(float x)
    
    38 38
     {
    
    39 39
     	double y;
    
    40 40
     	int32_t n, hx, ix;
    

  • src/lisp/openlibm/s_tanhf.c
    ... ... @@ -22,7 +22,7 @@
    22 22
     
    
    23 23
     static const float one=1.0, two=2.0, tiny = 1.0e-30, huge = 1.0e30;
    
    24 24
     OLM_DLLEXPORT float
    
    25
    -tanhf(float x)
    
    25
    +openlibm_tanhf(float x)
    
    26 26
     {
    
    27 27
     	float t,z;
    
    28 28
     	int32_t jx,ix;