libc: Fix all includes in codebase

The codebase was using non-standard headers. It is needed to replace
them by the correct ones so that we can use the new libc headers.

Change-Id: I530f71d9510cb036e69fe79823c8230afe890b9d
Acked-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
diff --git a/include/bl31/ehf.h b/include/bl31/ehf.h
index 1446279..c60b04c 100644
--- a/include/bl31/ehf.h
+++ b/include/bl31/ehf.h
@@ -9,6 +9,7 @@
 
 #ifndef __ASSEMBLY__
 
+#include <cdefs.h>
 #include <stdint.h>
 #include <utils_def.h>
 
diff --git a/include/common/bl_common.h b/include/common/bl_common.h
index f64e6ae..6478f12 100644
--- a/include/common/bl_common.h
+++ b/include/common/bl_common.h
@@ -61,7 +61,6 @@
 #include <cassert.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <types.h>
 #include <utils_def.h> /* To retain compatibility */
 
 
diff --git a/include/common/debug.h b/include/common/debug.h
index 99f402c..f60dfc1 100644
--- a/include/common/debug.h
+++ b/include/common/debug.h
@@ -26,6 +26,7 @@
 #define LOG_LEVEL_VERBOSE		50
 
 #ifndef __ASSEMBLY__
+#include <cdefs.h>
 #include <stdarg.h>
 #include <stdio.h>
 
diff --git a/include/common/ep_info.h b/include/common/ep_info.h
index 99a0390..bf3f782 100644
--- a/include/common/ep_info.h
+++ b/include/common/ep_info.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -65,7 +65,7 @@
 #ifndef __ASSEMBLY__
 
 #include <cassert.h>
-#include <types.h>
+#include <stdint.h>
 
 typedef struct aapcs64_params {
 	u_register_t arg0;
diff --git a/include/common/param_header.h b/include/common/param_header.h
index 4e61fad..a5a08ec 100644
--- a/include/common/param_header.h
+++ b/include/common/param_header.h
@@ -36,7 +36,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <types.h>
+#include <stdint.h>
 
 /***************************************************************************
  * This structure provides version information and the size of the
diff --git a/include/drivers/arm/arm_gic.h b/include/drivers/arm/arm_gic.h
index 019159f..8d2a232 100644
--- a/include/drivers/arm/arm_gic.h
+++ b/include/drivers/arm/arm_gic.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -7,6 +7,7 @@
 #ifndef __ARM_GIC_H__
 #define __ARM_GIC_H__
 
+#include <cdefs.h>
 #include <stdint.h>
 
 /*******************************************************************************
diff --git a/include/drivers/arm/gic_v3.h b/include/drivers/arm/gic_v3.h
index 02f9006..549b4d9 100644
--- a/include/drivers/arm/gic_v3.h
+++ b/include/drivers/arm/gic_v3.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -17,8 +17,6 @@
 
 #include <mmio.h>
 #include <stdint.h>
-#include <types.h>
-
 
 /* GICv3 Re-distributor interface registers & shifts */
 #define GICR_PCPUBASE_SHIFT	0x11
diff --git a/include/drivers/arm/gicv2.h b/include/drivers/arm/gicv2.h
index 39c7302..925d1c2 100644
--- a/include/drivers/arm/gicv2.h
+++ b/include/drivers/arm/gicv2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -116,6 +116,7 @@
 
 #ifndef __ASSEMBLY__
 
+#include <cdefs.h>
 #include <interrupt_props.h>
 #include <stdint.h>
 
diff --git a/include/drivers/arm/gicv3.h b/include/drivers/arm/gicv3.h
index 37c92e4..c13a5c9 100644
--- a/include/drivers/arm/gicv3.h
+++ b/include/drivers/arm/gicv3.h
@@ -212,7 +212,6 @@
 #include <gic_common.h>
 #include <interrupt_props.h>
 #include <stdint.h>
-#include <types.h>
 #include <utils_def.h>
 
 #define gicv3_is_intr_id_special_identifier(id)	\
diff --git a/include/drivers/arm/pl011.h b/include/drivers/arm/pl011.h
index 06d7543..137764d 100644
--- a/include/drivers/arm/pl011.h
+++ b/include/drivers/arm/pl011.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -85,7 +85,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <types.h>
+#include <stdint.h>
 
 typedef struct {
 	console_t console;
diff --git a/include/drivers/cadence/cdns_uart.h b/include/drivers/cadence/cdns_uart.h
index 7ab6df0..51de8e3 100644
--- a/include/drivers/cadence/cdns_uart.h
+++ b/include/drivers/cadence/cdns_uart.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -29,7 +29,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <types.h>
+#include <stdint.h>
 
 typedef struct {
 	console_t console;
diff --git a/include/drivers/console.h b/include/drivers/console.h
index f9ed2e5..1f041b9 100644
--- a/include/drivers/console.h
+++ b/include/drivers/console.h
@@ -30,7 +30,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <types.h>
+#include <stdint.h>
 
 typedef struct console {
 	struct console *next;
diff --git a/include/drivers/dw_ufs.h b/include/drivers/dw_ufs.h
index b05c7f5..a9774cf 100644
--- a/include/drivers/dw_ufs.h
+++ b/include/drivers/dw_ufs.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -7,7 +7,7 @@
 #ifndef __DW_UFS_H__
 #define __DW_UFS_H__
 
-#include <sys/types.h>
+#include <stdint.h>
 
 /* Bus Throtting */
 #define BUSTHRTL				0xC0
diff --git a/include/drivers/partition/partition.h b/include/drivers/partition/partition.h
index 4951f8c..047c7dd 100644
--- a/include/drivers/partition/partition.h
+++ b/include/drivers/partition/partition.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -8,7 +8,7 @@
 #define __PARTITION_H__
 
 #include <cassert.h>
-#include <types.h>
+#include <stdint.h>
 
 #if !PLAT_PARTITION_MAX_ENTRIES
 # define PLAT_PARTITION_MAX_ENTRIES	128
diff --git a/include/drivers/ti/uart/uart_16550.h b/include/drivers/ti/uart/uart_16550.h
index b00f664..9ee2a33 100644
--- a/include/drivers/ti/uart/uart_16550.h
+++ b/include/drivers/ti/uart/uart_16550.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -75,7 +75,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <types.h>
+#include <stdint.h>
 
 typedef struct {
 	console_t console;
diff --git a/include/lib/aarch32/arch_helpers.h b/include/lib/aarch32/arch_helpers.h
index aa68bcb..8eda5cb 100644
--- a/include/lib/aarch32/arch_helpers.h
+++ b/include/lib/aarch32/arch_helpers.h
@@ -8,8 +8,9 @@
 #define __ARCH_HELPERS_H__
 
 #include <arch.h>	/* for additional register definitions */
+#include <cdefs.h>
 #include <stdint.h>
-#include <sys/types.h>
+#include <string.h>
 
 /**********************************************************************
  * Macros which create inline functions to read or write CPU system
diff --git a/include/lib/aarch32/smccc_helpers.h b/include/lib/aarch32/smccc_helpers.h
index 731c26f..d6e525f 100644
--- a/include/lib/aarch32/smccc_helpers.h
+++ b/include/lib/aarch32/smccc_helpers.h
@@ -26,7 +26,7 @@
 
 #ifndef __ASSEMBLY__
 #include <cassert.h>
-#include <types.h>
+#include <stdint.h>
 
 /*
  * The generic structure to save arguments and callee saved registers during
diff --git a/include/lib/aarch64/arch_helpers.h b/include/lib/aarch64/arch_helpers.h
index 8e82dbd..067c374 100644
--- a/include/lib/aarch64/arch_helpers.h
+++ b/include/lib/aarch64/arch_helpers.h
@@ -10,7 +10,7 @@
 #include <arch.h>	/* for additional register definitions */
 #include <cdefs.h>	/* For __dead2 */
 #include <stdint.h>
-#include <sys/types.h>
+#include <string.h>
 
 /**********************************************************************
  * Macros which create inline functions to read or write CPU system
diff --git a/include/lib/bakery_lock.h b/include/lib/bakery_lock.h
index d4645c3..c80082e 100644
--- a/include/lib/bakery_lock.h
+++ b/include/lib/bakery_lock.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -12,6 +12,7 @@
 #define BAKERY_LOCK_MAX_CPUS		PLATFORM_CORE_COUNT
 
 #ifndef __ASSEMBLY__
+#include <cdefs.h>
 #include <stdint.h>
 
 /*****************************************************************************
diff --git a/include/lib/cassert.h b/include/lib/cassert.h
index 40cb483..3119e1f 100644
--- a/include/lib/cassert.h
+++ b/include/lib/cassert.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -7,6 +7,8 @@
 #ifndef __CASSERT_H__
 #define __CASSERT_H__
 
+#include <cdefs.h>
+
 /*******************************************************************************
  * Macro to flag a compile time assertion. It uses the preprocessor to generate
  * an invalid C construct if 'cond' evaluates to false.
diff --git a/include/lib/coreboot.h b/include/lib/coreboot.h
index 4b1f200..f8fbd93 100644
--- a/include/lib/coreboot.h
+++ b/include/lib/coreboot.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -7,7 +7,7 @@
 #ifndef __COREBOOT_H__
 #define __COREBOOT_H__
 
-#include <types.h>
+#include <stdint.h>
 
 typedef struct {
 	uint32_t type;			/* always 2 (memory-mapped) on ARM */
diff --git a/include/lib/extensions/amu.h b/include/lib/extensions/amu.h
index 559c8f1..46d5e15 100644
--- a/include/lib/extensions/amu.h
+++ b/include/lib/extensions/amu.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -10,7 +10,6 @@
 #include <cassert.h>
 #include <platform_def.h>
 #include <stdint.h>
-#include <sys/cdefs.h> /* for CASSERT() */
 
 /* All group 0 counters */
 #define AMU_GROUP0_COUNTERS_MASK	0xf
diff --git a/include/lib/psci/psci.h b/include/lib/psci/psci.h
index 71d605d..fa0da9f 100644
--- a/include/lib/psci/psci.h
+++ b/include/lib/psci/psci.h
@@ -171,7 +171,6 @@
 #ifndef __ASSEMBLY__
 
 #include <stdint.h>
-#include <types.h>
 
 /* Function to help build the psci capabilities bitfield */
 
diff --git a/include/lib/psci/psci_lib.h b/include/lib/psci/psci_lib.h
index 5b30f55..134cad9 100644
--- a/include/lib/psci/psci_lib.h
+++ b/include/lib/psci/psci_lib.h
@@ -10,7 +10,8 @@
 #include <ep_info.h>
 
 #ifndef __ASSEMBLY__
-#include <types.h>
+#include <cdefs.h>
+#include <stdint.h>
 
 /*******************************************************************************
  * Optional structure populated by the Secure Payload Dispatcher to be given a
diff --git a/include/lib/spinlock.h b/include/lib/spinlock.h
index a7b0d39..8aec707 100644
--- a/include/lib/spinlock.h
+++ b/include/lib/spinlock.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -9,7 +9,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <types.h>
+#include <stdint.h>
 
 typedef struct spinlock {
 	volatile uint32_t lock;
diff --git a/include/lib/utils.h b/include/lib/utils.h
index 5f13e99..09ec8d9 100644
--- a/include/lib/utils.h
+++ b/include/lib/utils.h
@@ -17,7 +17,7 @@
  */
 #if !(defined(__LINKER__) || defined(__ASSEMBLY__))
 
-#include <types.h>
+#include <stdint.h>
 
 typedef struct mem_region {
 	uintptr_t base;
diff --git a/include/lib/xlat_tables/xlat_mmu_helpers.h b/include/lib/xlat_tables/xlat_mmu_helpers.h
index e1d0227..ab491e3 100644
--- a/include/lib/xlat_tables/xlat_mmu_helpers.h
+++ b/include/lib/xlat_tables/xlat_mmu_helpers.h
@@ -54,7 +54,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
-#include <sys/types.h>
+#include <string.h>
 
 /*
  * Return the values that the MMU configuration registers must contain for the
diff --git a/include/plat/arm/css/common/css_pm.h b/include/plat/arm/css/common/css_pm.h
index e834fff..a243671 100644
--- a/include/plat/arm/css/common/css_pm.h
+++ b/include/plat/arm/css/common/css_pm.h
@@ -9,7 +9,7 @@
 
 #include <cdefs.h>
 #include <psci.h>
-#include <types.h>
+#include <stdint.h>
 
 /* System power domain at level 2, as currently implemented by CSS platforms */
 #define CSS_SYSTEM_PWR_DMN_LVL		ARM_PWR_LVL2
diff --git a/include/plat/common/common_def.h b/include/plat/common/common_def.h
index 827d416..e66af78 100644
--- a/include/plat/common/common_def.h
+++ b/include/plat/common/common_def.h
@@ -8,6 +8,7 @@
 
 #include <bl_common.h>
 #include <platform_def.h>
+#include <xlat_tables_defs.h>
 
 /******************************************************************************
  * Required platform porting definitions that are expected to be common to
diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h
index 12eac60..dae9589 100644
--- a/include/plat/common/platform.h
+++ b/include/plat/common/platform.h
@@ -9,8 +9,6 @@
 
 #include <psci.h>
 #include <stdint.h>
-#include <types.h>
-
 
 /*******************************************************************************
  * Forward declarations
diff --git a/include/services/secure_partition.h b/include/services/secure_partition.h
index d4aff1c..8b0adc8 100644
--- a/include/services/secure_partition.h
+++ b/include/services/secure_partition.h
@@ -7,7 +7,7 @@
 #ifndef __SECURE_PARTITION_H__
 #define __SECURE_PARTITION_H__
 
-#include <types.h>
+#include <stdint.h>
 #include <utils_def.h>
 
 /*