Skip to content

Commit c92c2b3

Browse files
author
Matthias Loy
committed
Headers for Kernel
After undefining MPACK_STDLIB and MPACK_STDIO, the following has to be changed. -Replace some header that are not known in kernel. -__attribute__((noinline)) makes problems (This I do not understand).
1 parent f9ec219 commit c92c2b3

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/mpack/mpack-platform.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,32 @@
121121
#define __STDC_CONSTANT_MACROS 1
122122
#endif
123123

124+
#ifndef __KERNEL__
124125
#include <stddef.h>
125126
#include <stdint.h>
126127
#include <stdbool.h>
127128
#include <inttypes.h>
128129
#include <limits.h>
130+
#else
131+
#include <linux/types.h>
132+
#include <linux/limits.h>
133+
#define UINT8_MAX U8_MAX
134+
#define UINT16_MAX U16_MAX
135+
#define UINT32_MAX U32_MAX
136+
137+
#define INT8_MAX S8_MAX
138+
#define INT16_MAX S16_MAX
139+
#define INT32_MAX S32_MAX
140+
141+
#define UINT8_MIN U8_MIN
142+
#define UINT16_MIN U16_MIN
143+
#define UINT32_MIN U32_MIN
144+
145+
#define INT8_MIN S8_MIN
146+
#define INT16_MIN S16_MIN
147+
#define INT32_MIN S32_MIN
148+
#endif
149+
129150

130151
#if MPACK_STDLIB
131152
#include <string.h>
@@ -337,7 +358,11 @@ MPACK_EXTERN_C_START
337358
#if defined(_MSC_VER)
338359
#define MPACK_NOINLINE __declspec(noinline)
339360
#elif defined(__GNUC__) || defined(__clang__)
340-
#define MPACK_NOINLINE __attribute__((noinline))
361+
#ifndef __KERNEL__
362+
#define MPACK_NOINLINE __attribute__((noinline))
363+
#else
364+
#define MPACK_NOINLINE
365+
#endif
341366
#endif
342367
#endif
343368
#ifndef MPACK_NOINLINE

0 commit comments

Comments
 (0)