Integrate libc and dlmalloc to opteesp and sp environments

Replace newlib with libc and dlmalloc components in the optee and sp
environments and implement required interfaces. Using the libc component
also required the following changes:
* Fix duplicate __maybe_unused in compiler.h
* Change external/tf_a/include/cdefs.h to point to new cdefs.h
* Resolve __packed usage issues

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: Ie798eb426378529b5d84f1708beebe85cd061fb3
diff --git a/components/common/libc/component.cmake b/components/common/libc/component.cmake
deleted file mode 100644
index 042117b..0000000
--- a/components/common/libc/component.cmake
+++ /dev/null
@@ -1,13 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-if (NOT DEFINED TGT)
-	message(FATAL_ERROR "mandatory parameter TGT is not defined.")
-endif()
-
-target_include_directories(${TGT} PRIVATE
-	"${CMAKE_CURRENT_LIST_DIR}/include"
-)
diff --git a/components/common/libc/include/assert_fail_handler.h b/components/common/libc/include/assert_fail_handler.h
deleted file mode 100644
index 7f36f25..0000000
--- a/components/common/libc/include/assert_fail_handler.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
- */
-
-#ifndef ASSERT_FAIL_HANDLER_H_
-#define ASSERT_FAIL_HANDLER_H_
-
-#include "compiler.h"
-
-/*
- * Generic assert fail handler function definition. Should be implemented by the environment.
- */
-void __noreturn assert_fail_handler(const char *file, int line,
-				    const char *func, const char *failedexpr);
-
-#endif /* ASSERT_FAIL_HANDLER_H_ */
diff --git a/components/common/libc/include/libc_init.h b/components/common/libc/include/libc_init.h
deleted file mode 100644
index 28988d5..0000000
--- a/components/common/libc/include/libc_init.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
- */
-
-#ifndef LIBC_INIT_H_
-#define LIBC_INIT_H_
-
-/*
- * Generic libc init function. Implemented by the newlib external, should be called by the
- * environment on boot.
- */
-void libc_init(void);
-
-#endif /* LIBC_INIT_H_ */
diff --git a/components/common/utils/include/compiler.h b/components/common/utils/include/compiler.h
index 075530b..185872e 100644
--- a/components/common/utils/include/compiler.h
+++ b/components/common/utils/include/compiler.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-2-Clause */
 /*
  * Copyright (c) 2014, STMicroelectronics International N.V.
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
  */
 
 #ifndef COMPILER_H
@@ -14,7 +14,7 @@
  * definitive owner and thus solves the problem.
  */
 #ifdef ENABLE_CDEFSH_FIX
-#include <sys/cdefs.h>
+#include <cdefs.h>
 #endif
 
 /*
@@ -56,7 +56,9 @@
 #ifndef __unused
 #define __unused	__attribute__((unused))
 #endif
+#ifndef __maybe_unused
 #define __maybe_unused	__attribute__((unused))
+#endif
 #ifndef __used
 #define __used		__attribute__((__used__))
 #endif
diff --git a/components/service/crypto/backend/psa_ipc/crypto_ipc_backend.h b/components/service/crypto/backend/psa_ipc/crypto_ipc_backend.h
index 27ac598..f9bbf84 100644
--- a/components/service/crypto/backend/psa_ipc/crypto_ipc_backend.h
+++ b/components/service/crypto/backend/psa_ipc/crypto_ipc_backend.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021-2023, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -44,7 +44,7 @@
                               *   See tfm_crypto_func_sid for detail
                               */
     uint16_t step;           /*!< Key derivation step */
-}__packed;
+} __attribute__((__packed__));
 
 #define iov_size sizeof(struct psa_ipc_crypto_pack_iovec)