Raymond Toy pushed to branch issue-468-core-math-signals at cmucl / cmucl

Commits:

6 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -147,7 +147,9 @@ linux:build:
    147 147
         - job: linux:install
    
    148 148
           artifacts: true
    
    149 149
       variables:
    
    150
    -    CONFIG: "x86_linux_clang"
    
    150
    +    # Fedora 41 must build with gcc because the clang build fails some
    
    151
    +    # ansi-tests.  See [#469].
    
    152
    +    CONFIG: "x86_linux"
    
    151 153
       # These rules is needed so that the static analyzer job can run on a
    
    152 154
       # schedule because this is a prerequisite of the analyzer build.  A
    
    153 155
       # regular push or merge request does the normal stuff.
    
    ... ... @@ -171,7 +173,7 @@ linux:cross-build:
    171 173
           - linux-4/lisp
    
    172 174
       variables:
    
    173 175
         # This must match the config used for the linux build!
    
    174
    -    CONFIG: "x86_linux_clang"
    
    176
    +    CONFIG: "x86_linux"
    
    175 177
     
    
    176 178
       needs:
    
    177 179
     
    
    ... ... @@ -346,7 +348,10 @@ ubuntu:build:
    346 348
         - job: ubuntu:install
    
    347 349
           artifacts: true
    
    348 350
       variables:
    
    349
    -    CONFIG: "x86_linux_clang"
    
    351
    +    # Build with gcc on Ubuntu 25.10.  It produces a lisp than passes
    
    352
    +    # the ansi-tests.  Clang seems to fail the ansi-tests WRITE.1,
    
    353
    +    # PRINT.1, and friends when cr_pow is used.
    
    354
    +    CONFIG: "x86_linux"
    
    350 355
     
    
    351 356
     ubuntu:test:
    
    352 357
       <<: *unit_test_configuration
    

  • bin/run-unit-tests.sh
    ... ... @@ -42,9 +42,9 @@ done
    42 42
     shift $((OPTIND - 1))
    
    43 43
     
    
    44 44
     # Create the test directory needed by the issue.45 test.
    
    45
    -rm -rf test-tmp
    
    46
    -mkdir test-tmp
    
    47
    -ln -s /bin/ls test-tmp/ls-link
    
    45
    +#rm -rf test-tmp
    
    46
    +#mkdir test-tmp
    
    47
    +#ln -s /bin/ls test-tmp/ls-link
    
    48 48
     
    
    49 49
     # Set the timestamps on 64-bit-timestamp-2038.txt and
    
    50 50
     # 64-bit-timestamp-2106.txt, but only for OSes where we know this
    
    ... ... @@ -56,8 +56,9 @@ ln -s /bin/ls test-tmp/ls-link
    56 56
     # tests/os.lisp.
    
    57 57
     case `uname -s` in
    
    58 58
         Linux)
    
    59
    -	touch -d "1 April 2038" tests/resources/64-bit-timestamp-2038.txt
    
    60
    -	touch -d "1 April 2106" tests/resources/64-bit-timestamp-2106.txt
    
    59
    +	# -t format is [[CC]YY]MMDDhhmm[.ss]
    
    60
    +	touch -t 203804010000 tests/resources/64-bit-timestamp-2038.txt
    
    61
    +	touch -t 210604010000 tests/resources/64-bit-timestamp-2106.txt
    
    61 62
     	;;
    
    62 63
     esac
    
    63 64
     
    

  • src/lisp/GNUmakefile
    ... ... @@ -55,7 +55,7 @@ version.o : version.c version
    55 55
     	mv ,version version
    
    56 56
     	$(CC) ${CFLAGS} $(CPPFLAGS) -DVERSION=`cat version` -c $<
    
    57 57
     
    
    58
    -lisp: ${OBJS} ${CORE64_OBJS} version.o
    
    58
    +lisp: ${OBJS} version.o
    
    59 59
     	$(CC) -g ${OS_LINK_FLAGS} -o ,lisp $^ ${OS_LIBS} -lm
    
    60 60
     	mv -f ,lisp lisp
    
    61 61
     
    
    ... ... @@ -75,7 +75,7 @@ internals.h internals.inc:
    75 75
     	@false
    
    76 76
     
    
    77 77
     clean:
    
    78
    -	$(RM) Depends *.o $(CORE64_OBJS) lisp lisp.nm core lisp.a
    
    78
    +	$(RM) Depends $(OBJS) lisp lisp.nm core lisp.a
    
    79 79
     	echo 'Map file for lisp version 0' > lisp.nm
    
    80 80
     
    
    81 81
     depend: Depends
    

  • src/lisp/irrat.c
    ... ... @@ -39,14 +39,21 @@ extern void cr_sincos(double, double *, double *);
    39 39
      * Wrappers for the special functions
    
    40 40
      */
    
    41 41
     
    
    42
    +#define MAYBE_SIGNAL_INVALID(test, val)		\
    
    43
    +    if ((test)) {				\ 
    
    44
    +        return fdlibm_setexception(val, FDLIBM_INVALID);	\
    
    45
    +    }
    
    46
    +
    
    47
    +#define MAYBE_SIGNAL_OVERFLOW(x)	\
    
    48
    +    if (isinf(x)) {	\
    
    49
    +	return fdlibm_setexception(x, FDLIBM_OVERFLOW); \
    
    50
    +    }
    
    51
    +
    
    42 52
     double
    
    43 53
     lisp_sin(double x)
    
    44 54
     {
    
    45 55
     #ifdef FEATURE_CORE_MATH
    
    46
    -    /* Signals invalid if x is infinite */
    
    47
    -    if (isinf(x)) {
    
    48
    -	return fdlibm_setexception(x, FDLIBM_INVALID);
    
    49
    -    }
    
    56
    +    MAYBE_SIGNAL_INVALID(isinf(x), x)
    
    50 57
     
    
    51 58
         return cr_sin(x);
    
    52 59
     #else    
    
    ... ... @@ -58,10 +65,7 @@ double
    58 65
     lisp_cos(double x)
    
    59 66
     {
    
    60 67
     #ifdef FEATURE_CORE_MATH
    
    61
    -    /* Signals invalid if x is infinite */
    
    62
    -    if (isinf(x)) {
    
    63
    -	return fdlibm_setexception(x, FDLIBM_INVALID);
    
    64
    -    }
    
    68
    +    MAYBE_SIGNAL_INVALID(isinf(x), x)
    
    65 69
     
    
    66 70
         return cr_cos(x);
    
    67 71
     #else    
    
    ... ... @@ -73,10 +77,7 @@ double
    73 77
     lisp_tan(double x)
    
    74 78
     {
    
    75 79
     #ifdef FEATURE_CORE_MATH
    
    76
    -    /* Signals invalid if x is infinite */
    
    77
    -    if (isinf(x)) {
    
    78
    -	return fdlibm_setexception(x, FDLIBM_INVALID);
    
    79
    -    }
    
    80
    +    MAYBE_SIGNAL_INVALID(isinf(x), x)
    
    80 81
     
    
    81 82
         return cr_tan(x);
    
    82 83
     #else    
    
    ... ... @@ -128,10 +129,7 @@ double
    128 129
     lisp_sinh(double x)
    
    129 130
     {
    
    130 131
     #ifdef FEATURE_CORE_MATH
    
    131
    -    /* Signal overflow if x is infinite */
    
    132
    -    if (isinf(x)) {
    
    133
    -	return fdlibm_setexception(x, FDLIBM_OVERFLOW);
    
    134
    -    }
    
    132
    +    MAYBE_SIGNAL_OVERFLOW(x)
    
    135 133
     	
    
    136 134
         return cr_sinh(x);
    
    137 135
     #else    
    
    ... ... @@ -163,10 +161,7 @@ double
    163 161
     lisp_asinh(double x)
    
    164 162
     {
    
    165 163
     #ifdef FEATURE_CORE_MATH
    
    166
    -    /* Signal overflow if x is infinite */
    
    167
    -    if (isinf(x)) {
    
    168
    -	return fdlibm_setexception(x, FDLIBM_OVERFLOW);
    
    169
    -    }
    
    164
    +    MAYBE_SIGNAL_OVERFLOW(x)
    
    170 165
     
    
    171 166
         return cr_asinh(x);
    
    172 167
     #else    
    
    ... ... @@ -178,14 +173,9 @@ double
    178 173
     lisp_acosh(double x)
    
    179 174
     {
    
    180 175
     #ifdef FEATURE_CORE_MATH
    
    181
    -    /* Signals invalid if x is not in the domain x >= 1 */
    
    182
    -    if (x < 1) {
    
    183
    -	return fdlibm_setexception(x, FDLIBM_INVALID);
    
    184
    -    }
    
    185
    -    /* Signal overflow if x is infinite */
    
    186
    -    if (isinf(x)) {
    
    187
    -	return fdlibm_setexception(x, FDLIBM_OVERFLOW);
    
    188
    -    }
    
    176
    +    MAYBE_SIGNAL_INVALID(x < 1, x)
    
    177
    +
    
    178
    +    MAYBE_SIGNAL_OVERFLOW(x)
    
    189 179
         
    
    190 180
         return cr_acosh(x);
    
    191 181
     #else    
    
    ... ... @@ -236,13 +226,17 @@ lisp_log10(double x)
    236 226
     double
    
    237 227
     lisp_pow(double x, double y)
    
    238 228
     {
    
    229
    +#ifdef FEATURE_CORE_MATH
    
    239 230
         /*
    
    240
    -     * cr_pow seems causes ansi-tests to fail in test WRITE.1 among
    
    241
    -     * others.  Somewhere an invalid operation is occurring.  Thus
    
    242
    -     * just use fdlibm for now until we can figure out what's causing
    
    243
    -     * the failure.
    
    231
    +     * cr_pow when compiled with older versions of gcc or clang can
    
    232
    +     * cause failures in the ansi-tests [#469].  Ubuntu 25.10 and Fedora 41
    
    233
    +     * (gcc only) are known to have compilers that work well enough
    
    234
    +     * that the ansi-tests pass.
    
    244 235
          */
    
    236
    +    return cr_pow(x, y);
    
    237
    +#else    
    
    245 238
         return __ieee754_pow(x, y);
    
    239
    +#endif
    
    246 240
     }
    
    247 241
     
    
    248 242
     double
    

  • tests/issues.lisp
    ... ... @@ -436,7 +436,7 @@
    436 436
     (define-test issue.45
    
    437 437
       (:tag :issues)
    
    438 438
       ;; This depends on run-tests to setup the test directory correctly!
    
    439
    -  (let* ((test-dir #p"test-tmp/")
    
    439
    +  (let* ((test-dir #p"tests/test-run-prog/")
    
    440 440
     	 (test-dir-name (namestring test-dir)))
    
    441 441
         (flet ((do-test (program)
    
    442 442
     	     (with-output-to-string (s)
    

  • tests/test-run-prog/ls-link
    1
    +#! /bin/sh
    
    2
    +exec /bin/ls "$@"