freemyipod r925 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r924‎ | r925 | r926 >
Date:21:45, 6 May 2014
Author:theseven
Status:new
Tags:
Comment:
UMSboot: Some minor fixes to make this compile with newer gcc versions
Modified paths:
  • /umsboot/src/cpu/arm/target.h (modified) (history)
  • /umsboot/src/sys/util.c (modified) (history)
  • /umsboot/src/sys/util.h (modified) (history)

Diff [purge]

Index: umsboot/src/cpu/arm/target.h
@@ -2,6 +2,6 @@
33 #define __CPU_ARM_TARGET_H__
44
55 #define CPU_ARM
6 -#define LITTLE_ENDIAN
 6+#define ENDIANNESS_LITTLE
77
88 #endif
Index: umsboot/src/sys/util.h
@@ -58,7 +58,7 @@
5959 (((unsigned long)(x) & 0x4ul) << 27) | \
6060 (((unsigned long)(x) & 0x2ul) << 29) | \
6161 (((unsigned long)(x) & 0x1ul) << 31)))
62 -#ifdef LITTLE_ENDIAN
 62+#ifdef ENDIANNESS_LITTLE
6363 #define LE_TO_H16(x) (x)
6464 #define LE_TO_H32(x) (x)
6565 #define H_TO_LE16(x) (x)
@@ -124,7 +124,8 @@
125125 extern void* memcpy(void* dst, const void* src, size_t len);
126126 extern void* memmove(void* dst, const void* src, size_t len);
127127 extern void* memset(void* dst, int val, size_t len);
128 -extern int strlen(const char* string);
 128+extern int memcmp(const void* a, const void* b, size_t len);
 129+extern size_t strlen(const char* string);
129130 extern void to_hex(char* dest, int len, uint32_t value);
130131
131132 static inline void discard(uint32_t data)
Index: umsboot/src/sys/util.c
@@ -143,11 +143,23 @@
144144
145145 __attribute__((weak,alias("memmove"))) void* memcpy(void* dst, const void* src, size_t len);
146146 */
147 -__attribute__((weak)) int strlen(const char* string)
 147+
 148+__attribute__((weak)) int memcmp(const void* ptr1, const void* ptr2, size_t len)
148149 {
 150+ uint8_t* a = (uint8_t*)ptr1;
 151+ uint8_t* b = (uint8_t*)ptr2;
 152+ int d;
 153+ while (len--)
 154+ if ((d = *a++ - *b++))
 155+ return d;
 156+ return 0;
 157+}
 158+
 159+__attribute__((weak)) size_t strlen(const char* string)
 160+{
149161 const char* pos = string;
150162 while (*pos++);
151 - return pos - string;
 163+ return pos - string - 1;
152164 }
153165
154166 static const char hextab[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};