xtest: remove deprecated USER_SPACE

Legacy USER_SPACE enables thread support in xtest. Withdraw as always
set.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
diff --git a/host/xtest/Makefile b/host/xtest/Makefile
index 308019d..a0661dd 100644
--- a/host/xtest/Makefile
+++ b/host/xtest/Makefile
@@ -110,8 +110,6 @@
 
 endif
 
-# FIXME: Check if and why we need this flag?
-CFLAGS += -DUSER_SPACE
 # Include configuration file generated by OP-TEE OS (CFG_* macros)
 CFLAGS += -include conf.h
 
diff --git a/host/xtest/xml/include/xml_client_api.h b/host/xtest/xml/include/xml_client_api.h
index 6bc5ea9..09ac263 100644
--- a/host/xtest/xml/include/xml_client_api.h
+++ b/host/xtest/xml/include/xml_client_api.h
@@ -14,15 +14,13 @@
 #ifndef XML_CLIENT_API_H_
 #define XML_CLIENT_API_H_
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include "tee_client_api.h"
-#ifdef USER_SPACE
 #include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <tee_client_api.h>
 #include <unistd.h>
-#endif
 
 #define CLIENT_APP01                    NULL
 
@@ -32,10 +30,8 @@
 
 #define OFFSET0 0
 
-#ifdef USER_SPACE
 /*Test data defines*/
 static pthread_t THREAD02;
-#endif
 
 static TEEC_SharedMemory *SHARE_MEM01;
 static TEEC_SharedMemory *SHARE_MEM02;
@@ -275,16 +271,11 @@
 			ADBG_EXPECT(c, (int)returnOrigin, ret_orig); \
 	} while (0)
 
-#ifdef USER_SPACE
 #define RequestCancellation(op) \
 	(void)ADBG_EXPECT(c, 0, \
 			  pthread_create(&THREAD02, NULL, cancellation_thread, \
 					 (void *)op)); \
 	(void)ADBG_EXPECT(c, 0, pthread_join(THREAD02, NULL));
-#else
-#define RequestCancellation(op) \
-	IDENTIFIER_NOT_USED(op)
-#endif
 
 struct ctx_thr {
 	ADBG_Case_t *c;
@@ -293,7 +284,6 @@
 
 static struct ctx_thr thr2_ctx;
 
-#ifdef USER_SPACE
 static void *context_thread(void *arg)
 {
 	/*
@@ -306,18 +296,12 @@
 
 	return NULL;
 }
-#endif
 
-#ifdef USER_SPACE
 #define ctx_init_finalize(t_ctx) \
 	(void)ADBG_EXPECT(c, 0, \
 			  pthread_create(&THREAD02, NULL, context_thread, \
 					 (void *)&t_ctx)); \
 	(void)ADBG_EXPECT(c, 0, pthread_join(THREAD02, NULL));
-#else
-#define ctx_init_finalize(t_ctx) \
-	IDENTIFIER_NOT_USED(t_ctx)
-#endif
 
 #ifdef WITH_GP_TESTS
 /*
@@ -339,13 +323,11 @@
 	{ 0x4C, 0x54, 0x2D, 0x54, 0x41, 0x2D, 0x53, 0x54 }
 };
 
-#ifdef USER_SPACE
 static void *cancellation_thread(void *arg)
 {
 	TEEC_RequestCancellation((TEEC_Operation *)arg);
 	return NULL;
 }
-#endif
 
 /* Assigns parent, offset and size to the memref parameter */
 static void TEEC_prepare_OperationEachParameter_memref(TEEC_Operation *op,
diff --git a/host/xtest/xml/include/xml_datastorage_api.h b/host/xtest/xml/include/xml_datastorage_api.h
index ba309c3..04cfa2a 100644
--- a/host/xtest/xml/include/xml_datastorage_api.h
+++ b/host/xtest/xml/include/xml_datastorage_api.h
@@ -14,15 +14,12 @@
 #ifndef XML_DATASTORAGE_API_H_
 #define XML_DATASTORAGE_API_H_
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-
-#ifdef USER_SPACE
 #include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
 #include <unistd.h>
-#endif
 
 #include "tee_client_api.h"
 #undef TA_UUID
@@ -108,10 +105,8 @@
 #define BUFFER_ATTRIBUTE 0
 #define VALUE_ATTRIBUTE 1
 
-#ifdef USER_SPACE
 /* Test data defines */
 static pthread_t THREAD01_DEFAULT;
-#endif
 
 /* Return ORIGIN */
 static uint32_t ret_orig;
diff --git a/host/xtest/xml/include/xml_internal_api.h b/host/xtest/xml/include/xml_internal_api.h
index 14e36f3..f58704e 100644
--- a/host/xtest/xml/include/xml_internal_api.h
+++ b/host/xtest/xml/include/xml_internal_api.h
@@ -14,14 +14,11 @@
 #ifndef XML_INTERNAL_API_H_
 #define XML_INTERNAL_API_H_
 
+#include <pthread.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <stdlib.h>
-
-#ifdef USER_SPACE
-#include <pthread.h>
 #include <unistd.h>
-#endif
 
 #include <sys/types.h>
 #include "tee_client_api.h"
@@ -63,11 +60,9 @@
 
 #define TEE_ERROR_TOO_SHORT_BUFFER TEE_ERROR_SHORT_BUFFER
 
-#ifdef USER_SPACE
 /* Test data defines */
 static pthread_t THREAD01_DEFAULT;
 static pthread_t THREAD02;
-#endif
 
 static TEEC_SharedMemory *SHARE_MEM01;
 static TEEC_SharedMemory *SHARE_MEM02;
@@ -253,24 +248,17 @@
 #define TEEC_SelectApp(a, b)    /* do nothing for now */
 #define TEEC_createThread(a, b) /* do nothing for now */
 
-#ifdef USER_SPACE
 static void *cancellation_thread(void *arg)
 {
 	TEEC_RequestCancellation((TEEC_Operation *)arg);
 	return NULL;
 }
-#endif
 
-#ifdef USER_SPACE
 #define RequestCancellation(op) \
 	(void)ADBG_EXPECT(c, 0, \
 			  pthread_create(&THREAD02, NULL, cancellation_thread, \
 					 (void *)op)); \
 	(void)ADBG_EXPECT(c, 0, pthread_join(THREAD02, NULL));
-#else
-#define RequestCancellation(op) \
-	IDENTIFIER_NOT_USED(op)
-#endif
 
 /* Allocates TEEC_SharedMemory inside of the TEE */
 static TEEC_Result AllocateSharedMemory(TEEC_Context *ctx,
diff --git a/host/xtest/xml/include/xml_timearithm_api.h b/host/xtest/xml/include/xml_timearithm_api.h
index e1ed2fd..55be19e 100644
--- a/host/xtest/xml/include/xml_timearithm_api.h
+++ b/host/xtest/xml/include/xml_timearithm_api.h
@@ -54,11 +54,9 @@
 /* Return ORIGIN */
 static uint32_t ret_orig;
 
-#ifdef USER_SPACE
 /*Test data defines*/
 static pthread_t THREAD01_DEFAULT;
 static pthread_t THREAD02;
-#endif
 
 #define BIT0_MASK 1
 #define BIT1_MASK 2
@@ -443,24 +441,17 @@
 #define TEEC_SelectApp(a, b)    /*do nothing for now*/
 #define TEEC_createThread(a, b) /*do nothing for now*/
 
-#ifdef USER_SPACE
 static void *cancellation_thread(void *arg)
 {
 	TEEC_RequestCancellation((TEEC_Operation *)arg);
 	return NULL;
 }
-#endif
 
-#ifdef USER_SPACE
 #define RequestCancellation(op) \
 	(void)ADBG_EXPECT(c, 0, \
 			  pthread_create(&THREAD02, NULL, cancellation_thread, \
 					 (void *)op)); \
 	(void)ADBG_EXPECT(c, 0, pthread_join(THREAD02, NULL));
-#else
-#define RequestCancellation(op) \
-	IDENTIFIER_NOT_USED(op)
-#endif
 
 /*Allocates TEEC_SharedMemory inside of the TEE*/
 static TEEC_Result AllocateSharedMemory(TEEC_Context *ctx,
diff --git a/host/xtest/xtest_1000.c b/host/xtest/xtest_1000.c
index 9c92195..c8e5e29 100644
--- a/host/xtest/xtest_1000.c
+++ b/host/xtest/xtest_1000.c
@@ -11,16 +11,13 @@
  * GNU General Public License for more details.
  */
 
+#include <limits.h>
+#include <pthread.h>
 #include <stdio.h>
 #include <string.h>
-#include <limits.h>
-
-#ifdef USER_SPACE
-#include <pthread.h>
-#include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#endif
+#include <unistd.h>
 
 #include "xtest_test.h"
 #include "xtest_helpers.h"
@@ -650,7 +647,6 @@
 	Do_ADBG_EndSubCase(c, "Load corrupt TA");
 }
 
-#ifdef USER_SPACE
 static void *cancellation_thread(void *arg)
 {
 	/*
@@ -661,16 +657,13 @@
 	TEEC_RequestCancellation(arg);
 	return NULL;
 }
-#endif
 
 static void xtest_tee_test_1009_subcase(ADBG_Case_t *c, const char *subcase,
                                         uint32_t timeout, bool cancel)
 {
 	TEEC_Session session = { 0 };
 	uint32_t ret_orig;
-#ifdef USER_SPACE
 	pthread_t thr;
-#endif
 
 	Do_ADBG_BeginSubCase(c, "%s", subcase);
 	{
@@ -688,7 +681,6 @@
 			op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
 			                                 TEEC_NONE,
 			                                 TEEC_NONE, TEEC_NONE);
-#ifdef USER_SPACE
 			if (cancel) {
 				(void)ADBG_EXPECT(c, 0,
 				      pthread_create(&thr, NULL,
@@ -701,17 +693,14 @@
 			                                  &op,
 			                                  &ret_orig));
 			} else
-#endif
 
 			(void)ADBG_EXPECT_TEEC_SUCCESS(c,
 			           TEEC_InvokeCommand(&session,
 			                              TA_OS_TEST_CMD_WAIT,
 			                              &op,
 			                              &ret_orig));
-#ifdef USER_SPACE
 			if (cancel)
 				(void)ADBG_EXPECT(c, 0, pthread_join(thr, NULL));
-#endif
 
 			TEEC_CloseSession(&session);
 		}
@@ -723,9 +712,7 @@
 {
 	xtest_tee_test_1009_subcase(c, "TEE Wait 0.1s", 100, false);
 	xtest_tee_test_1009_subcase(c, "TEE Wait 0.5s", 500, false);
-#ifdef USER_SPACE
 	xtest_tee_test_1009_subcase(c, "TEE Wait 2s cancel", 2000, true);
-#endif
 	xtest_tee_test_1009_subcase(c, "TEE Wait 2s", 2000, false);
 }
 
diff --git a/host/xtest/xtest_main.c b/host/xtest/xtest_main.c
index ec1c9a8..e696752 100644
--- a/host/xtest/xtest_main.c
+++ b/host/xtest/xtest_main.c
@@ -55,7 +55,6 @@
 ADBG_SUITE_ENTRY(XTEST_TEE_4010)
 ADBG_SUITE_ENTRY(XTEST_TEE_4011)
 ADBG_SUITE_ENTRY(XTEST_TEE_5006)
-#ifdef USER_SPACE
 ADBG_SUITE_ENTRY(XTEST_TEE_6001)
 ADBG_SUITE_ENTRY(XTEST_TEE_6002)
 ADBG_SUITE_ENTRY(XTEST_TEE_6003)
@@ -92,9 +91,7 @@
 ADBG_SUITE_ENTRY(XTEST_TEE_7019)
 #ifdef WITH_GP_TESTS
 ADBG_ENTRY_AUTO_GENERATED_TESTS()
-#else
 #endif
-#endif /*USER_SPACE*/
 ADBG_SUITE_ENTRY(XTEST_TEE_10001)
 ADBG_SUITE_ENTRY(XTEST_TEE_10002)