From 6210eb056f880a52edfe9de64c6839154a5c7429 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Mon, 12 Feb 2018 15:26:45 +0100
Subject: [PATCH] bugfix: fix ue_ip.ko compilation

Not sure that the use of __KERNEL__ is the correct solution.
To be checked at some point.

After this commit, the following works:
./build_oai --UE -c
---
 cmake_targets/CMakeLists.txt   |  2 +-
 common/utils/itti/itti_types.h | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 616adf3a82..31b3f8e4c7 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -2297,7 +2297,7 @@ add_custom_command (
 # retrieve the compiler options to send it to gccxml
 get_directory_property(DirDefs COMPILE_DEFINITIONS )
 foreach( d ${DirDefs} )
-  set(module_cc_opt_tmp "${module_cc_opt_tmp} -D${d}")
+  set(module_cc_opt "${module_cc_opt} -D${d}")
 endforeach()
 get_directory_property( DirDefs INCLUDE_DIRECTORIES )
 foreach( d ${DirDefs} )
diff --git a/common/utils/itti/itti_types.h b/common/utils/itti/itti_types.h
index d07853133b..2607c003b1 100644
--- a/common/utils/itti/itti_types.h
+++ b/common/utils/itti/itti_types.h
@@ -27,7 +27,18 @@
 #ifndef _ITTI_TYPES_H_
 #define _ITTI_TYPES_H_
 
-#include <stdint.h>
+/* The current file is included in the ue_ip.ko compilation.
+ * For it to work we need to include linux/types.h and
+ * not stdint.h.
+ * A solution to this problem is to use #ifndef __KERNEL__.
+ * Maybe a better solution would be to clean things up
+ * so that ue_ip.ko does not include the current file.
+ */
+#ifndef __KERNEL__
+#  include <stdint.h>
+#else
+#  include <linux/types.h>
+#endif
 
 #define CHARS_TO_UINT32(c1, c2, c3, c4) (((c4) << 24) | ((c3) << 16) | ((c2) << 8) | (c1))
 
-- 
2.26.2