1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

ia64 ABI breaker:

Don't force 16-byte alignment at run-time. Do it at compile-time.
This saves us the pointer fiddling by the setjmp functions and
reduces complexity. While here, increase the jmp_buf by 16 bytes
to an even 512 bytes. Coincidentally, due to the way alignment
was handled prior to this change, the jmp_buf has not changed in
size, but only in how the space is used. Prior to this change
the 16 bytes were reserved for enforcing alignment; now they are
reserved by us for future extensions.
Therefore, this ABI breaker is relatively save: the failure is
always an alignment trap.
This commit is contained in:
Marcel Moolenaar 2002-11-11 08:11:44 +00:00
parent 1f75c13ee0
commit 7aa65edc75
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106755
4 changed files with 23 additions and 68 deletions

View File

@ -69,13 +69,6 @@
//
ENTRY(_setjmp, 1)
//
// Make sure buffer is aligned at 16byte boundary
//
add r10 = -0x10,r0 ;; // mask the lower 4 bits
and r32 = r32, r10;;
add r32 = 0x10, r32;; // move to next 16 byte boundary
add r10 = J_PREDS, r32 // skip Unats & pfs save area
add r11 = J_BSP, r32
//
@ -199,13 +192,6 @@ END(_setjmp)
WEAK_ALIAS(_longjmp,___longjmp)
ENTRY(___longjmp, 2)
//
// Make sure buffer is aligned at 16byte boundary
//
add r10 = -0x10,r0 ;; // mask the lower 4 bits
and r32 = r32, r10;;
add r32 = 0x10, r32;; // move to next 16 byte boundary
//
// caching the return value as we do invala in the end
//

View File

@ -46,14 +46,10 @@
ENTRY(setjmp, 1)
alloc loc0=ar.pfs,1,2,3,0
mov loc1=rp
//
// Compensate for the pointer twiddling that setjmp does.
//
dep r14=r0,r32,0,4
;;
;;
mov out0=1 // how = SIG_BLOCK
mov out1=0 // set = NULL
add out2=J_SIG0+0x10,r14 // oset = &jb[J_SIG0]
add out2=J_SIG0,in0 // oset = &jb[J_SIG0]
br.call.sptk.few rp=__sys_sigprocmask
;;
mov rp=loc1
@ -69,13 +65,9 @@ END(setjmp)
ENTRY(__longjmp, 2)
alloc loc0=ar.pfs,2,2,3,0
mov loc1=rp
//
// Compensate for the pointer twiddling that setjmp does.
//
dep r14=r0,r32,0,4
;;
mov out0=3 // how = SIG_SETMASK
add out1=J_SIG0+0x10,r14 // set = &jb[J_SIG0]
add out1=J_SIG0,in0 // set = &jb[J_SIG0]
mov out2=0 // oset = NULL
br.call.sptk.few rp=__sys_sigprocmask
;;

View File

@ -45,27 +45,17 @@
*/
ENTRY(sigsetjmp, 2)
//
// Compensate for the pointer twiddling that setjmp does.
//
dep r14=r0,r32,0,4
;;
add r14=J_SIGMASK+0x10,r14 // place to save mask
add r14=J_SIGMASK,in0 // place to save mask
cmp.ne p6,p7=0,in1 // save signal state?
;;
st8 [r14]=in1 // save mask value
cmp.ne p6,p7=0,in1 // save signal state?
(p6) br.cond.dptk.many setjmp
(p7) br.cond.dpnt.many _setjmp
END(sigsetjmp)
WEAK_ALIAS(siglongjmp,__siglongjmp)
ENTRY(__siglongjmp, 2)
//
// Compensate for the pointer twiddling that setjmp does.
//
dep r14=r0,r32,0,4
;;
add r14=J_SIGMASK+0x10,r14 // address of mask value
add r14=J_SIGMASK,in0 // address of mask value
;;
ld8 r14=[r14]
;;

View File

@ -44,26 +44,8 @@
#include <sys/cdefs.h>
/*
* IA64 assembler doesn't like C style comments. This also means we can't
* include other include files to get things like the roundup2() macro.
*
* NOTE: Actual register storage must start on a 16 byte boundary. Both
* setjmp and longjmp make that adjustment before referencing the contents
* of jmp_buf. The macro JMPBUF_ADDR_OF() allows someone to get the address
* of an individual item saved in jmp_buf.
*/
#if __BSD_VISIBLE
#define our_roundup(x, y) (((x)+((y)-1))&(~((y)-1)))
#endif
#define _JMPBUF_ALIGNMENT 0x10
#if __BSD_VISIBLE
#define JMPBUF_ALIGNMENT _JMPBUF_ALIGNMENT
#define JMPBUF_ADDR_OF(buf, item) \
((size_t)((our_roundup((size_t)buf, JMPBUF_ALIGNMENT)) + item))
#define JMPBUF_ADDR_OF(buf, item) ((unsigned long)((char *)buf + item))
#define J_UNAT 0
#define J_NATS 0x8
@ -109,10 +91,11 @@
#define J_SIGMASK 0x1e8
#endif /* __BSD_VISIBLE */
#define _J_END 0x1f0
#if __BSD_VISIBLE
#define J_END _J_END
#endif
/*
* We have 16 bytes left for future use, but it's a nice round,
* but above all large number. Size is in bytes.
*/
#define _JMPBUFSZ 0x200
/*
* XXX this check is wrong, since LOCORE is in the application namespace and
@ -123,20 +106,24 @@
* implementation.
*/
#ifndef LOCORE
/*
* jmp_buf and sigjmp_buf are encapsulated in different structs to force
* compile-time diagnostics for mismatches. The structs are the same
* internally to avoid some run-time errors for mismatches.
*/
#if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE
typedef struct _sigjmp_buf {
char _Buffer[_J_END + _JMPBUF_ALIGNMENT];
} sigjmp_buf[1];
struct _sigjmp_buf {
char _Buffer[_JMPBUFSZ];
} __aligned(16);
typedef struct _sigjmp_buf sigjmp_buf[1];
#endif
typedef struct _jmp_buf {
char _Buffer[ _J_END + _JMPBUF_ALIGNMENT ];
} jmp_buf[1];
#endif
struct _jmp_buf {
char _Buffer[_JMPBUFSZ];
} __aligned(16);
typedef struct _jmp_buf jmp_buf[1];
#endif /* !LOCORE */
#endif /* !_MACHINE_SETJMP_H_ */