1From ab24f236cbc0aa8a3eadde5d71d9d7ea1d979a51 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Fri, 31 Aug 2018 11:33:51 +0200
4Subject: [PATCH] kexec-syscall.h: work around missing syscall() wrapper
5
6Fix
7
8 kexec-syscall.h: In function 'kexec_load':
9 kexec-syscall.h:80:16: warning: implicit declaration of function 'syscall'
10
11Upstream-Status: Inappropriate [klibc specific]
12Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
13
14---
15 kexec/kexec-syscall.h | 21 +++++++++++++++++++++
16 1 file changed, 21 insertions(+)
17
18diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h
19index b96e02a..2a3794d 100644
20--- a/kexec/kexec-syscall.h
21+++ b/kexec/kexec-syscall.h
22@@ -77,11 +77,16 @@
23
24 struct kexec_segment;
25
26+#ifndef __KLIBC__
27 static inline long kexec_load(void *entry, unsigned long nr_segments,
28 			struct kexec_segment *segments, unsigned long flags)
29 {
30 	return (long) syscall(__NR_kexec_load, entry, nr_segments, segments, flags);
31 }
32+#else
33+extern long kexec_load(void *entry, unsigned long nr_segments,
34+			struct kexec_segment *segments, unsigned long flags);
35+#endif
36
37 static inline int is_kexec_file_load_implemented(void) {
38 	if (__NR_kexec_file_load != 0xffffffff)
39@@ -89,6 +94,21 @@ static inline int is_kexec_file_load_implemented(void) {
40 	return 0;
41 }
42
43+#ifdef __KLIBC__
44+/* Stub provided by klibc only for the following archs */
45+#if defined (__x86_64__) || defined (__powerpc_64__) || defined (__s390x__)
46+extern long kexec_file_load(int kernel_fd, int initrd_fd,
47+			unsigned long cmdline_len, const char *cmdline_ptr,
48+			unsigned long flags);
49+#else
50+static inline long kexec_file_load(int kernel_fd, int initrd_fd,
51+			unsigned long cmdline_len, const char *cmdline_ptr,
52+			unsigned long flags)
53+{
54+	return -1;
55+}
56+#endif
57+#else
58 static inline long kexec_file_load(int kernel_fd, int initrd_fd,
59 			unsigned long cmdline_len, const char *cmdline_ptr,
60 			unsigned long flags)
61@@ -96,6 +116,7 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd,
62 	return (long) syscall(__NR_kexec_file_load, kernel_fd, initrd_fd,
63 				cmdline_len, cmdline_ptr, flags);
64 }
65+#endif
66
67 #define KEXEC_ON_CRASH		0x00000001
68 #define KEXEC_PRESERVE_CONTEXT	0x00000002
69