[libc] Centralise architecture-independent portions of setjmp.h

The definitions of the setjmp() and longjmp() functions are common to
all architectures, with only the definition of the jump buffer
structure being architecture-specific.

Move the architecture-specific portions to bits/setjmp.h and provide a
common setjmp.h for the function definitions.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2024-09-12 14:17:20 +01:00
parent a1830ff43c
commit 5de5d4626e
6 changed files with 36 additions and 54 deletions

View File

@@ -1,5 +1,5 @@
#ifndef _SETJMP_H #ifndef _BITS_SETJMP_H
#define _SETJMP_H #define _BITS_SETJMP_H
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
@@ -29,10 +29,4 @@ typedef struct {
uint32_t lr; uint32_t lr;
} jmp_buf[1]; } jmp_buf[1];
extern int __asmcall __attribute__ (( returns_twice )) #endif /* _BITS_SETJMP_H */
setjmp ( jmp_buf env );
extern void __asmcall __attribute__ (( noreturn ))
longjmp ( jmp_buf env, int val );
#endif /* _SETJMP_H */

View File

@@ -1,5 +1,5 @@
#ifndef _SETJMP_H #ifndef _BITS_SETJMP_H
#define _SETJMP_H #define _BITS_SETJMP_H
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
@@ -35,10 +35,4 @@ typedef struct {
uint64_t sp; uint64_t sp;
} jmp_buf[1]; } jmp_buf[1];
extern int __asmcall __attribute__ (( returns_twice )) #endif /* _BITS_SETJMP_H */
setjmp ( jmp_buf env );
extern void __asmcall __attribute__ (( noreturn ))
longjmp ( jmp_buf env, int val );
#endif /* _SETJMP_H */

View File

@@ -1,5 +1,5 @@
#ifndef _SETJMP_H #ifndef _BITS_SETJMP_H
#define _SETJMP_H #define _BITS_SETJMP_H
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
@@ -21,10 +21,4 @@ typedef struct {
uint32_t ebp; uint32_t ebp;
} jmp_buf[1]; } jmp_buf[1];
extern int __asmcall __attribute__ (( returns_twice )) #endif /* _BITS_SETJMP_H */
setjmp ( jmp_buf env );
extern void __asmcall __attribute__ (( noreturn ))
longjmp ( jmp_buf env, int val );
#endif /* _SETJMP_H */

View File

@@ -0,0 +1,23 @@
#ifndef _BITS_SETJMP_H
#define _BITS_SETJMP_H
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** A jump buffer */
typedef struct {
uint64_t s0;
uint64_t s1;
uint64_t s2;
uint64_t s3;
uint64_t s4;
uint64_t s5;
uint64_t s6;
uint64_t s7;
uint64_t s8;
uint64_t fp;
uint64_t sp;
uint64_t ra;
} jmp_buf[1];
#endif /* _BITS_SETJMP_H */

View File

@@ -1,5 +1,5 @@
#ifndef _SETJMP_H #ifndef _BITS_SETJMP_H
#define _SETJMP_H #define _BITS_SETJMP_H
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
@@ -25,10 +25,4 @@ typedef struct {
uint64_t r15; uint64_t r15;
} jmp_buf[1]; } jmp_buf[1];
extern int __asmcall __attribute__ (( returns_twice )) #endif /* _BITS_SETJMP_H */
setjmp ( jmp_buf env );
extern void __asmcall __attribute__ (( noreturn ))
longjmp ( jmp_buf env, int val );
#endif /* _SETJMP_H */

View File

@@ -3,24 +3,7 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h> #include <bits/setjmp.h>
/** jump buffer env*/
typedef struct {
uint64_t s0;
uint64_t s1;
uint64_t s2;
uint64_t s3;
uint64_t s4;
uint64_t s5;
uint64_t s6;
uint64_t s7;
uint64_t s8;
uint64_t fp;
uint64_t sp;
uint64_t ra;
} jmp_buf[1];
extern int __asmcall __attribute__ (( returns_twice )) extern int __asmcall __attribute__ (( returns_twice ))
setjmp ( jmp_buf env ); setjmp ( jmp_buf env );