]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[libc] Centralise architecture-independent portions of setjmp.h
authorMichael Brown <mcb30@ipxe.org>
Thu, 12 Sep 2024 13:17:20 +0000 (14:17 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 12 Sep 2024 14:01:04 +0000 (15:01 +0100)
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>
src/arch/arm32/include/bits/setjmp.h [moved from src/arch/arm32/include/setjmp.h with 68% similarity]
src/arch/arm64/include/bits/setjmp.h [moved from src/arch/arm64/include/setjmp.h with 72% similarity]
src/arch/i386/include/bits/setjmp.h [moved from src/arch/i386/include/setjmp.h with 60% similarity]
src/arch/loong64/include/bits/setjmp.h [new file with mode: 0644]
src/arch/x86_64/include/bits/setjmp.h [moved from src/arch/x86_64/include/setjmp.h with 64% similarity]
src/include/setjmp.h [moved from src/arch/loong64/include/setjmp.h with 52% similarity]

similarity index 68%
rename from src/arch/arm32/include/setjmp.h
rename to src/arch/arm32/include/bits/setjmp.h
index 4828b47a2d616ca5c46d03bb48a56bd28f4c9196..9ee264ecd2d166149c6d4d9745bca956ef99f6d0 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _SETJMP_H
-#define _SETJMP_H
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
@@ -29,10 +29,4 @@ typedef struct {
        uint32_t lr;
 } jmp_buf[1];
 
-extern int __asmcall __attribute__ (( returns_twice ))
-setjmp ( jmp_buf env );
-
-extern void __asmcall __attribute__ (( noreturn ))
-longjmp ( jmp_buf env, int val );
-
-#endif /* _SETJMP_H */
+#endif /* _BITS_SETJMP_H */
similarity index 72%
rename from src/arch/arm64/include/setjmp.h
rename to src/arch/arm64/include/bits/setjmp.h
index 85a7a9cadaece748180dde7cc82937378afd7fa8..6ffd2fb0afad444bcdce4899f16dfcd86be8e4c9 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _SETJMP_H
-#define _SETJMP_H
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
@@ -35,10 +35,4 @@ typedef struct {
        uint64_t sp;
 } jmp_buf[1];
 
-extern int __asmcall __attribute__ (( returns_twice ))
-setjmp ( jmp_buf env );
-
-extern void __asmcall __attribute__ (( noreturn ))
-longjmp ( jmp_buf env, int val );
-
-#endif /* _SETJMP_H */
+#endif /* _BITS_SETJMP_H */
similarity index 60%
rename from src/arch/i386/include/setjmp.h
rename to src/arch/i386/include/bits/setjmp.h
index 98566696a04a2848323368bcf3bc98df538f2cc6..6b2ec9613d1f4e78e5fba5cc6fadc66e2110544a 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _SETJMP_H
-#define _SETJMP_H
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
@@ -21,10 +21,4 @@ typedef struct {
        uint32_t ebp;
 } jmp_buf[1];
 
-extern int __asmcall __attribute__ (( returns_twice ))
-setjmp ( jmp_buf env );
-
-extern void __asmcall __attribute__ (( noreturn ))
-longjmp ( jmp_buf env, int val );
-
-#endif /* _SETJMP_H */
+#endif /* _BITS_SETJMP_H */
diff --git a/src/arch/loong64/include/bits/setjmp.h b/src/arch/loong64/include/bits/setjmp.h
new file mode 100644 (file)
index 0000000..c8d7cef
--- /dev/null
@@ -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 */
similarity index 64%
rename from src/arch/x86_64/include/setjmp.h
rename to src/arch/x86_64/include/bits/setjmp.h
index 69835d9faf16cd2acf4a5d6a8a4b1aaef69a76d7..adfb869ead4f9deb342134e8ad1dc7ae024e9c37 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _SETJMP_H
-#define _SETJMP_H
+#ifndef _BITS_SETJMP_H
+#define _BITS_SETJMP_H
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
@@ -25,10 +25,4 @@ typedef struct {
        uint64_t r15;
 } jmp_buf[1];
 
-extern int __asmcall __attribute__ (( returns_twice ))
-setjmp ( jmp_buf env );
-
-extern void __asmcall __attribute__ (( noreturn ))
-longjmp ( jmp_buf env, int val );
-
-#endif /* _SETJMP_H */
+#endif /* _BITS_SETJMP_H */
similarity index 52%
rename from src/arch/loong64/include/setjmp.h
rename to src/include/setjmp.h
index 1e5168338713483eb8b8f12647ee7f6d78e357dd..d8cd02f462b899ce5038dcc73857adcde96490e1 100644 (file)
@@ -3,24 +3,7 @@
 
 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
-#include <stdint.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];
+#include <bits/setjmp.h>
 
 extern int __asmcall __attribute__ (( returns_twice ))
 setjmp ( jmp_buf env );