More ARM stuffs

svn-id: r18754
This commit is contained in:
Chris Apers 2005-09-03 17:14:41 +00:00
parent 80a5644c79
commit 20e088801e
6 changed files with 47 additions and 17 deletions

View File

@ -23,10 +23,15 @@
#include <stdlib.h>
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);

View File

@ -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

View File

@ -23,8 +23,15 @@
#ifndef STDLIB_H
#define STDLIB_H
#include <PalmOS.h>
#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))

View File

@ -19,8 +19,10 @@
* $Header$
*
*/
#ifndef STRING_H
#define STRING_H
#include <PalmOS.h>
#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
#define StrTok strtok
#endif

View File

@ -23,7 +23,7 @@
#define __TIME_H__
#include <PalmOS.h>
#include "palmversion.h"
typedef UInt32 time_t;

View File

@ -23,10 +23,10 @@
#ifndef __UNISTD_H__
#define __UNISTD_H__
#include <PalmOS.h>
#include "palmversion.h"
extern const Char *gUnistdCWD;
Char *getcwd(Char *buf, UInt32 size);
Char *getcwd(Char *buf, UInt32 size);
#endif
#endif