lib: Remove unused <stdlib.h> and use <types.h> when appropriate

Unused <stdlib.h> found using:
diff <(git grep -l '#include <stdlib.h>' -- src/) <(git grep -l 'memalign(\|malloc(\|calloc(\|free(' -- src/)

Change-Id: I5ad171679cbfa67d522bd1105fb58e0f84b9cb89
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/60621
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <martinroth@google.com>
diff --git a/src/lib/bootmem.c b/src/lib/bootmem.c
index d4462d8..078f9609 100644
--- a/src/lib/bootmem.c
+++ b/src/lib/bootmem.c
@@ -4,9 +4,9 @@
 #include <bootmem.h>
 #include <cbmem.h>
 #include <device/resource.h>
-#include <stdlib.h>
 #include <symbols.h>
 #include <assert.h>
+#include <types.h>
 
 static int initialized;
 static int table_written;
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index 698118c..ebaa3a5 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -15,7 +15,6 @@
 #include <drivers/tpm/tpm_ppi.h>
 #include <fmap.h>
 #include <fw_config.h>
-#include <stdlib.h>
 #include <cbfs.h>
 #include <cbmem.h>
 #include <bootmem.h>
@@ -23,6 +22,7 @@
 #include <inttypes.h>
 #include <spi_flash.h>
 #include <smmstore.h>
+#include <types.h>
 
 #if CONFIG(USE_OPTION_TABLE)
 #include <option_table.h>
diff --git a/src/lib/fit.c b/src/lib/fit.c
index 08fd045..6b4067e 100644
--- a/src/lib/fit.c
+++ b/src/lib/fit.c
@@ -5,15 +5,14 @@
 #include <console/console.h>
 #include <ctype.h>
 #include <endian.h>
-#include <stdint.h>
 #include <bootmem.h>
-#include <stdlib.h>
 #include <string.h>
 #include <program_loading.h>
 #include <memrange.h>
 #include <fit.h>
 #include <boardid.h>
 #include <commonlib/stdlib.h>
+#include <types.h>
 
 static struct list_node image_nodes;
 static struct list_node config_nodes;
diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c
index b5ed6e0..4a5b2f7 100644
--- a/src/lib/hardwaremain.c
+++ b/src/lib/hardwaremain.c
@@ -19,7 +19,6 @@
 #include <device/device.h>
 #include <device/pci.h>
 #include <program_loading.h>
-#include <stdlib.h>
 #include <thread.h>
 #include <timer.h>
 #include <timestamp.h>
diff --git a/src/lib/imd.c b/src/lib/imd.c
index ac19d76..5cba121 100644
--- a/src/lib/imd.c
+++ b/src/lib/imd.c
@@ -4,7 +4,6 @@
 #include <cbmem.h>
 #include <console/console.h>
 #include <imd.h>
-#include <stdlib.h>
 #include <string.h>
 #include <types.h>
 #include <imd_private.h>
diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c
index 4b7c412..453b0c1 100644
--- a/src/lib/imd_cbmem.c
+++ b/src/lib/imd_cbmem.c
@@ -7,7 +7,7 @@
 #include <cbmem.h>
 #include <imd.h>
 #include <lib.h>
-#include <stdlib.h>
+#include <types.h>
 
 /* The program loader passes on cbmem_top and the program entry point
    has to fill in the _cbmem_top_ptr symbol based on the calling arguments. */
diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c
index 0e175c6..18d54f5 100644
--- a/src/lib/prog_loaders.c
+++ b/src/lib/prog_loaders.c
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
-
-#include <stdlib.h>
 #include <cbfs.h>
 #include <cbmem.h>
 #include <console/console.h>
diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c
index 31bf141..bee71d8 100644
--- a/src/lib/rmodule.c
+++ b/src/lib/rmodule.c
@@ -1,13 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
+
 #include <assert.h>
 #include <cbmem.h>
 #include <cbfs.h>
-#include <stdint.h>
-#include <stdlib.h>
 #include <string.h>
 #include <console/console.h>
 #include <program_loading.h>
 #include <rmodule.h>
+#include <types.h>
 
 /* Change this define to get more verbose debugging for module loading. */
 #define PK_ADJ_LEVEL BIOS_NEVER
diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c
index 70ab719..637ad13 100644
--- a/src/lib/selfboot.c
+++ b/src/lib/selfboot.c
@@ -3,8 +3,6 @@
 #include <commonlib/bsd/compression.h>
 #include <commonlib/endian.h>
 #include <console/console.h>
-#include <stdint.h>
-#include <stdlib.h>
 #include <string.h>
 #include <symbols.h>
 #include <cbfs.h>
@@ -13,6 +11,7 @@
 #include <program_loading.h>
 #include <timestamp.h>
 #include <cbmem.h>
+#include <types.h>
 
 /* The type syntax for C is essentially unparsable. -- Rob Pike */
 typedef int (*checker_t)(struct cbfs_payload_segment *cbfssegs, void *args);
diff --git a/src/lib/thread.c b/src/lib/thread.c
index adfc298..dc83df0 100644
--- a/src/lib/thread.c
+++ b/src/lib/thread.c
@@ -1,14 +1,12 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
 #include <assert.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
 #include <bootstate.h>
 #include <console/console.h>
 #include <smp/node.h>
 #include <thread.h>
 #include <timer.h>
+#include <types.h>
 
 static u8 thread_stacks[CONFIG_STACK_SIZE * CONFIG_NUM_THREADS] __aligned(sizeof(uint64_t));
 static bool initialized;