Changeset 16364


Ignore:
Timestamp:
Apr 3, 2015, 10:27:22 PM (5 years ago)
Author:
gb
Message:

for 64-bit Linux: copy_fpregs() copies the secret AVX state correctly.
fixes ticket:1271 in the trunk. TODO: look at x8632, Darwin, Solaris,
and Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/x86-exceptions.c

    r16138 r16364  
    15161516#ifdef LINUX
    15171517/* type of pointer to saved fp state */
    1518 #ifdef X8664
    1519 typedef fpregset_t FPREGS;
    1520 #else
     1518
    15211519typedef struct _fpstate *FPREGS;
    1522 #endif
     1520#define FPREGSsize_in_bytes(f) linux_fpstate_size_in_bytes(f)
     1521
     1522size_t
     1523linux_fpstate_size_in_bytes(FPREGS state)
     1524{
     1525  if (WORD_SIZE == 64){
     1526    /* see <asm/sigcontext.h> It would be way too useful if we could
     1527       include that file without conflicting with <bits/sigcontext.h> */
     1528    /* I didn't make this stuff up */
     1529    struct _fpx_sw_bytes * sw = (struct _fpx_sw_bytes *) (((char *)state)+464);
     1530    if (sw->magic1 == FP_XSTATE_MAGIC1) {
     1531      return sw->extended_size;
     1532    }
     1533
     1534  }
     1535  return (sizeof (*state));
     1536}
     1537
    15231538LispObj *
    15241539copy_fpregs(ExceptionInformation *xp, LispObj *current, FPREGS *destptr)
    15251540{
    15261541  FPREGS src = (FPREGS)(xp->uc_mcontext.fpregs), dest;
    1527  
     1542  size_t nbytes = FPREGSsize_in_bytes(src);
    15281543  if (src) {
    1529     dest = ((FPREGS)current)-1;
    1530     *dest = *src;
     1544    BytePtr bc = (BytePtr)current - nbytes;
     1545    dest = (FPREGS) (truncate_to_power_of_2(bc,6));
     1546    memcpy(dest,src,nbytes);
    15311547    *destptr = dest;
    1532     current = (LispObj *) dest;
     1548    current = (LispObj *)dest;
    15331549  }
    15341550  return current;
    15351551}
     1552
    15361553#endif
    15371554
Note: See TracChangeset for help on using the changeset viewer.