Commit d51dabf0 authored by Raymond Toy's avatar Raymond Toy
Browse files

Fix #86: Make cmucl work with gcc 8.1.1 and later

In alloc(), save the fpu state on entry to the function and restore it
just before returning.  

While we're at it, use the __attribute__ option to get a 16-byte
aligned area where we can save the fpu state.

And also set optimization to -O2 for linux.
parent 38372fd9
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ include Config.x86_common

# gcc 8.1.1 and 8.3.1 (and probably anything after 8.1.1?) won't
# produce a working lisp with -O2.  Just use -O1.
COPT = -O1
COPT = -O2
CFLAGS += $(COPT)
CPPFLAGS += -m32 -D__NO_CTYPE -D_GNU_SOURCE
CFLAGS += -rdynamic  -march=pentium4 -mfpmath=sse -mtune=generic
+38 −16
Original line number Diff line number Diff line
@@ -8412,9 +8412,24 @@ gencgc_pickup_dynamic(void)

void do_pending_interrupt(void);

//#pragma GCC optimize ("-O1")
char *
alloc(int nbytes)
{
#if 0 && (defined(i386) || defined(__x86_64))
    /*
     * Need to save and restore the FPU registers on x86, but only for
     * sse2.  See Ticket #61.
     *
     * Not needed by sparc or ppc because we never call alloc from
     * Lisp directly to do allocation.
     */
    FPU_STATE(fpu_state);

    if (fpu_mode == SSE2) {
        save_fpu_state(fpu_state);
    }
#endif
    void *new_obj;
#if !(defined(sparc) || (defined(DARWIN) && defined(__ppc__)))
    /*
@@ -8442,7 +8457,7 @@ alloc(int nbytes)
	    set_current_region_free((lispobj) new_free_pointer);
            break;
	} else if (bytes_allocated <= auto_gc_trigger) {
#if defined(i386) || defined(__x86_64)
#if 1 && (defined(i386) || defined(__x86_64))
    /*
     * Need to save and restore the FPU registers on x86, but only for
     * sse2.  See Ticket #61.
@@ -8466,7 +8481,7 @@ alloc(int nbytes)
	    set_current_region_free((lispobj) boxed_region.free_pointer);
	    set_current_region_end((lispobj) boxed_region.end_addr);

#if defined(i386) || defined(__x86_64)
#if 1 && (defined(i386) || defined(__x86_64))
    if (fpu_mode == SSE2) {
        restore_fpu_state(fpu_state);
    }
@@ -8484,8 +8499,14 @@ alloc(int nbytes)
	}
    }

#if 0 && (defined(i386) || defined(__x86_64))
    if (fpu_mode == SSE2) {
        restore_fpu_state(fpu_state);
    }
#endif
    return new_obj;
}
#pragma GCC optimize ("-O2")

char *
alloc_pseudo_atomic(int nbytes)
@@ -8545,6 +8566,7 @@ component_ptr_from_pc(lispobj * pc)
    return NULL;
}

#pragma GCC optimize ("-O1")
/*
 * Get lower and upper(middle) 28 bits of total allocation
 */
+2 −2
Original line number Diff line number Diff line
@@ -21,12 +21,12 @@ extern boolean os_support_sse2(void);
 * 512+16 bytes of space and let the routine adjust the appropriate
 * alignment.
 */
#define SSE_STATE_SIZE ((512+16)/4)
#define SSE_STATE_SIZE 512

/*
 * Just use the SSE size for both x87 and sse2 since the SSE size is
 * enough for either.
 */
#define FPU_STATE(name)    int name[SSE_STATE_SIZE];
#define FPU_STATE(name)    u_int8_t name[SSE_STATE_SIZE] __attribute__((aligned(16)))

#endif