From 20e088801e17fbb0b5176764cbcd6fb1f8475761 Mon Sep 17 00:00:00 2001 From: Chris Apers Date: Sat, 3 Sep 2005 17:14:41 +0000 Subject: More ARM stuffs svn-id: r18754 --- backends/PalmOS/Src/missing/_stdlib.cpp | 22 ++++++++++++++++------ backends/PalmOS/Src/missing/math.h | 6 +++++- backends/PalmOS/Src/missing/stdlib.h | 19 +++++++++++++++---- backends/PalmOS/Src/missing/string.h | 9 +++++++-- backends/PalmOS/Src/missing/time.h | 2 +- backends/PalmOS/Src/missing/unistd.h | 6 +++--- 6 files changed, 47 insertions(+), 17 deletions(-) (limited to 'backends/PalmOS/Src') diff --git a/backends/PalmOS/Src/missing/_stdlib.cpp b/backends/PalmOS/Src/missing/_stdlib.cpp index e91f9eb93c..e116aa0f06 100644 --- a/backends/PalmOS/Src/missing/_stdlib.cpp +++ b/backends/PalmOS/Src/missing/_stdlib.cpp @@ -23,10 +23,15 @@ #include void *bsearch(const void *key, const void *base, UInt32 nmemb, UInt32 size, int (*compar)(const void *, const void *)) { +#ifdef PALMOS_68K Int32 position; - if (SysBinarySearch(base, nmemb, size, (SearchFuncPtr)compar, key, 0, &position, true)) return (void *)((UInt32)base + size * position); +#else + for (int i = 0; i < nmemb; i++) + if (compar(key, (void*)((UInt32)base + size * i)) == 0) + return (void*)((UInt32)base + size * i); +#endif return NULL; } @@ -34,11 +39,11 @@ void *bsearch(const void *key, const void *base, UInt32 nmemb, UInt32 size, int long strtol(const char *s, char **endptr, int base) { // WARNING : only base = 10 supported long val = StrAToI(s); - + if (endptr) { Char str[maxStrIToALen]; StrIToA(str, val); - + if (StrNCompare(s, str, StrLen(str)) == 0) *endptr = (char *)s + StrLen(str); } @@ -65,18 +70,18 @@ Err free(MemPtr memP) { } MemPtr realloc(MemPtr oldP, UInt32 size) { - + if (oldP != NULL) if (MemPtrResize(oldP,size) == 0) return oldP; MemPtr newP = MemPtrNew(size); - + if (oldP!=NULL) { MemMove(newP,oldP,MemPtrSize(oldP)); MemPtrFree(oldP); - } + } return newP; } @@ -84,8 +89,13 @@ ErrJumpBuf stdlib_errJumpBuf; #define ERR_MAGIC 0xDADA void exit(Int16 status) { +#ifdef PALMOS_68K EventType event; event.eType = keyDownEvent; +#else + SysEventType event; + event.eType = sysEventKeyDownEvent; +#endif event.data.keyDown.chr = vchrLaunch; event.data.keyDown.modifiers = commandKeyMask; EvtAddUniqueEventToQueue(&event, 0, true); diff --git a/backends/PalmOS/Src/missing/math.h b/backends/PalmOS/Src/missing/math.h index aac0ad60ff..aa3dc8e02d 100644 --- a/backends/PalmOS/Src/missing/math.h +++ b/backends/PalmOS/Src/missing/math.h @@ -23,7 +23,11 @@ #ifndef __MATH_H__ #define __MATH_H__ -#include "mathlib.h" +#ifndef PALMOS_ARM +# include "mathlib.h" +#else +# include "matharm.h" +#endif #ifndef M_PI # define M_PI 3.14159265358979323846 diff --git a/backends/PalmOS/Src/missing/stdlib.h b/backends/PalmOS/Src/missing/stdlib.h index 56a485f487..76395b0ae0 100644 --- a/backends/PalmOS/Src/missing/stdlib.h +++ b/backends/PalmOS/Src/missing/stdlib.h @@ -23,8 +23,15 @@ #ifndef STDLIB_H #define STDLIB_H -#include +#include "palmversion.h" + +#ifdef PALMOS_68K #include "MemGlue.h" +#endif + +#if defined(COMPILE_ZODIAC) && defined(PALMOS_ARM) +#define MemGluePtrNew MemPtrNew +#endif extern ErrJumpBuf stdlib_errJumpBuf; @@ -34,11 +41,15 @@ extern ErrJumpBuf stdlib_errJumpBuf; #define atoi StrAToI #define atol StrAToI #define abs(a) ((a) < 0 ? -(a) : (a)) -//#define abs fabs #define malloc(a) MemGluePtrNew(a) -//#define free MemPtrFree -//#define strtol(a,b,c) StrAToI(a) + +#ifdef PALMOS_68K #define qsort(a,b,c,d) SysQSort((a), (b), (c), (CmpFuncPtr)(&d), 0); +#else +typedef int (*_compare_function)(const void*, const void*); +extern "C" void qsort(void * table_base, size_t num_members, size_t member_size, _compare_function compare_members); +#endif + #define rand() SysRandom(0) #define abort() #define strtoul(a,b,c) ((unsigned long)strtol(a,b,c)) diff --git a/backends/PalmOS/Src/missing/string.h b/backends/PalmOS/Src/missing/string.h index 230837d464..161400f601 100644 --- a/backends/PalmOS/Src/missing/string.h +++ b/backends/PalmOS/Src/missing/string.h @@ -19,8 +19,10 @@ * $Header$ * */ +#ifndef STRING_H +#define STRING_H -#include +#include "palmversion.h" #define memcmp MemCmp #define memcpy MemMove @@ -38,6 +40,7 @@ #define strncmp StrNCompare #define strstr StrStr + void *memchr (const void *s, int c, UInt32 n); Char *strtok (Char *str, const Char *sep); Char *strrchr (const Char *s, int c); @@ -45,4 +48,6 @@ Char *strdup (const Char *strSource); Char *strpbrk (const Char *s1, const Char *s2); UInt32 strspn (const char *s1, const char *s2); -#define StrTok strtok \ No newline at end of file +#define StrTok strtok + +#endif diff --git a/backends/PalmOS/Src/missing/time.h b/backends/PalmOS/Src/missing/time.h index d9312f493f..825482eeb3 100644 --- a/backends/PalmOS/Src/missing/time.h +++ b/backends/PalmOS/Src/missing/time.h @@ -23,7 +23,7 @@ #define __TIME_H__ -#include +#include "palmversion.h" typedef UInt32 time_t; diff --git a/backends/PalmOS/Src/missing/unistd.h b/backends/PalmOS/Src/missing/unistd.h index ca43602c37..ab64869fcb 100644 --- a/backends/PalmOS/Src/missing/unistd.h +++ b/backends/PalmOS/Src/missing/unistd.h @@ -23,10 +23,10 @@ #ifndef __UNISTD_H__ #define __UNISTD_H__ -#include +#include "palmversion.h" extern const Char *gUnistdCWD; -Char *getcwd(Char *buf, UInt32 size); +Char *getcwd(Char *buf, UInt32 size); -#endif \ No newline at end of file +#endif -- cgit v1.2.3