aboutsummaryrefslogtreecommitdiff
path: root/payloads/libpayload/libc
diff options
context:
space:
mode:
Diffstat (limited to 'payloads/libpayload/libc')
-rw-r--r--payloads/libpayload/libc/malloc.c16
-rw-r--r--payloads/libpayload/libc/time.c12
2 files changed, 23 insertions, 5 deletions
diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c
index 24daf0e680..d18b289adf 100644
--- a/payloads/libpayload/libc/malloc.c
+++ b/payloads/libpayload/libc/malloc.c
@@ -103,16 +103,22 @@ static void *alloc(int len)
void *nptr = ptr + (HDRSIZE + len);
int nsize = size - (HDRSIZE + len);
- /* Mark the block as used. */
- *((hdrtype_t *) ptr) = USED_BLOCK(len);
-
/* If there is still room in this block,
- * then mark it as such.
+ * then mark it as such otherwise account
+ * the whole space for that block.
*/
- if (nsize > 0)
+ if (nsize > 0) {
+ /* Mark the block as used. */
+ *((hdrtype_t *) ptr) = USED_BLOCK(len);
+
+ /* Create a new free block. */
*((hdrtype_t *) nptr) =
FREE_BLOCK(nsize);
+ } else {
+ /* Mark the block as used. */
+ *((hdrtype_t *) ptr) = USED_BLOCK(size);
+ }
return (void *)(ptr + HDRSIZE);
}
diff --git a/payloads/libpayload/libc/time.c b/payloads/libpayload/libc/time.c
index 2d19bd173f..67675623a4 100644
--- a/payloads/libpayload/libc/time.c
+++ b/payloads/libpayload/libc/time.c
@@ -34,7 +34,9 @@
#include <libpayload-config.h>
#include <libpayload.h>
+#ifdef CONFIG_TARGET_I386
#include <arch/rdtsc.h>
+#endif
extern u32 cpu_khz;
@@ -47,6 +49,7 @@ static struct {
#define TICKS_PER_SEC (cpu_khz * 1000)
#define TICKS_PER_USEC (cpu_khz / 1000)
+#ifdef CONFIG_TARGET_I386
static void update_clock(void)
{
u64 delta = rdtsc() - clock.ticks;
@@ -114,7 +117,16 @@ static void gettimeofday_init(void)
clock.ticks = rdtsc();
}
#endif
+#endif
+#ifdef CONFIG_TARGET_POWERPC
+static void update_clock(void)
+{
+}
+static void gettimeofday_init(void)
+{
+}
+#endif
/**
* Return the current time broken into a timeval structure.
*