mirror of
https://github.com/siemens-mobile-hacks/sdk.git
synced 2026-11-25 22:27:39 +00:00
Refactor swi macroses
This commit is contained in:
parent
9397b068f6
commit
1ab586f265
37 changed files with 222 additions and 254 deletions
|
|
@ -20,10 +20,10 @@ int memcmp(const void *dst, const void *src, size_t count) {
|
|||
return 0;
|
||||
}
|
||||
#else
|
||||
int memcmp(const void *dst, const void *src, size_t count)
|
||||
{
|
||||
__def_noinline(0x011C, int, dst, src, count)
|
||||
}
|
||||
int memcmp(const void *dst, const void *src, size_t count)
|
||||
{
|
||||
return __swi_invoke(0x011C, memcmp, dst, src, count);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -54,10 +54,10 @@ memcpy (void *dst, const void *src, size_t n)
|
|||
#else
|
||||
|
||||
void *
|
||||
memcpy (void *dst, const void *src, size_t n)
|
||||
{
|
||||
__def_noinline(0x011E, void*, dst, src, n)
|
||||
}
|
||||
memcpy (void *dst, const void *src, size_t n)
|
||||
{
|
||||
return __swi_invoke(0x011E, memcpy, dst, src, n);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ void *memmove(void *dst, const void *src, size_t count)
|
|||
}
|
||||
#else
|
||||
|
||||
void *memmove(void *dst, const void *src, size_t count)
|
||||
{
|
||||
__def_noinline(0x0132, void *, dst, src, count)
|
||||
}
|
||||
void *memmove(void *dst, const void *src, size_t count)
|
||||
{
|
||||
return __swi_invoke(0x0132, memmove, dst, src, count);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ char* strcat(register char* s,register const char* t)
|
|||
}
|
||||
#else
|
||||
|
||||
char* strcat(register char* s,register const char* t)
|
||||
{
|
||||
// syscall strcat
|
||||
__def_noinline( 23, char*, s, t);
|
||||
}
|
||||
char* strcat(register char* s,register const char* t)
|
||||
{
|
||||
// syscall strcat
|
||||
return __swi_invoke(23, strcat, s, t);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ char *strchr(register const char *t, int c) {
|
|||
return (char*)t;
|
||||
}
|
||||
#else
|
||||
char *strchr(register const char *t, int c)
|
||||
{
|
||||
__def_noinline(24, char*, t, c)
|
||||
}
|
||||
char *strchr(register const char *t, int c)
|
||||
{
|
||||
return __swi_invoke(24, strchr, t, c);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *index(char *t,int c) __attribute__((weak,alias("strchr")));
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ strcmp (const char *s1, const char *s2)
|
|||
}
|
||||
#else
|
||||
int
|
||||
strcmp (const char *s1, const char *s2)
|
||||
{
|
||||
__def_noinline(25, int, s1, s2)
|
||||
}
|
||||
strcmp (const char *s1, const char *s2)
|
||||
{
|
||||
return __swi_invoke(25, strcmp, s1, s2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -41,10 +41,9 @@ strcpy (char *s1, const char *s2)
|
|||
}
|
||||
#else
|
||||
char *
|
||||
strcpy (char *s1, const char *s2)
|
||||
{
|
||||
__def_noinline(26, char *, s1, s2)
|
||||
}
|
||||
strcpy (char *s1, const char *s2)
|
||||
{
|
||||
return __swi_invoke(26, strcpy, s1, s2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -101,10 +101,10 @@ size_t strlen(const char *s)
|
|||
}
|
||||
#endif
|
||||
#else
|
||||
size_t strlen(const char *s)
|
||||
{
|
||||
__def_noinline(27, size_t, s)
|
||||
}
|
||||
size_t strlen(const char *s)
|
||||
{
|
||||
return __swi_invoke(27, strlen, s);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ fini:
|
|||
return dest;
|
||||
}
|
||||
#else
|
||||
char *strncat(char *s, const char *t, size_t n) {
|
||||
__def_noinline(0x0114, char *, s, t, n)
|
||||
}
|
||||
char *strncat(char *s, const char *t, size_t n) {
|
||||
return __swi_invoke(0x0114, strncat, s, t, n);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ int strncmp(const char *s1, const char *s2, size_t n) {
|
|||
return 0;
|
||||
}
|
||||
#else
|
||||
int strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
__def_noinline(0x0115, int, s1, s2, n)
|
||||
}
|
||||
int strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
return __swi_invoke(0x0115, strncmp, s1, s2, n);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ char *strncpy(char *dest, const char *src, size_t n) {
|
|||
return dest;
|
||||
}
|
||||
#else
|
||||
char *strncpy(char *dest, const char *src, size_t n)
|
||||
{
|
||||
__def_noinline(0x0116, char *, dest, src, n)
|
||||
}
|
||||
char *strncpy(char *dest, const char *src, size_t n)
|
||||
{
|
||||
return __swi_invoke(0x0116, strncpy, dest, src, n);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ char *strrchr(const char *t, int c) {
|
|||
return (char*)l;
|
||||
}
|
||||
#else
|
||||
char *strrchr(const char *t, int c)
|
||||
{
|
||||
__def_noinline(0x0117, char *, t, c)
|
||||
}
|
||||
char *strrchr(const char *t, int c)
|
||||
{
|
||||
return __swi_invoke(0x0117, strrchr, t, c);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ found:
|
|||
}
|
||||
#else
|
||||
|
||||
char *strstr(const char *haystack, const char *needle)
|
||||
{
|
||||
__def_noinline(0x0118, char *, haystack, needle)
|
||||
}
|
||||
char *strstr(const char *haystack, const char *needle)
|
||||
{
|
||||
return __swi_invoke(0x0118, strstr, haystack, needle);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ long int strtol(const char *nptr, char **endptr, int base)
|
|||
return (neg?-v:v);
|
||||
}
|
||||
#else
|
||||
long int strtol(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
__def_noinline(0x0119, long int, nptr, endptr, base)
|
||||
}
|
||||
long int strtol(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
return __swi_invoke(0x0119, strtol, nptr, endptr, base);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
|
||||
__inl
|
||||
int __dlclose(int handle)
|
||||
__def( 0x2F1, int, handle)
|
||||
static inline
|
||||
int __dlclose(int handle)
|
||||
{
|
||||
return __swi_invoke(0x2F1, __dlclose, handle);
|
||||
}
|
||||
|
||||
int dlclose(void * handle)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
#include <swilib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
__inl
|
||||
int __dlopen(const char *name)
|
||||
__def( 0x2EF, int, name)
|
||||
static inline
|
||||
int __dlopen(const char *name)
|
||||
{
|
||||
return __swi_invoke(0x2EF, __dlopen, name);
|
||||
}
|
||||
|
||||
void *dlopen(const char *filename, int flags)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
|
||||
#include <swilib.h>
|
||||
|
||||
__inl
|
||||
void* __dlsym(int handle, const char *name)
|
||||
__def( 0x2F0, void *, handle, name)
|
||||
static inline
|
||||
void* __dlsym(int handle, const char *name)
|
||||
{
|
||||
return __swi_invoke(0x2F0, __dlsym, handle, name);
|
||||
}
|
||||
|
||||
|
||||
void *dlsym(void *handle, const char *sym)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
#include <stddef.h>
|
||||
|
||||
|
||||
void *calloc(size_t nelem, size_t elsize)
|
||||
{
|
||||
__def_noinline(146, void*, nelem, elsize);
|
||||
}
|
||||
void *calloc(size_t nelem, size_t elsize)
|
||||
{
|
||||
return __swi_invoke(146, calloc, nelem, elsize);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,26 +10,26 @@
|
|||
#include <errno.h>
|
||||
|
||||
|
||||
int setenv(const char *name, const char *value, int replace)
|
||||
{
|
||||
__def_noinline( 0x2F2, int, name, value, replace)
|
||||
}
|
||||
int setenv(const char *name, const char *value, int replace)
|
||||
{
|
||||
return __swi_invoke(0x2F2, setenv, name, value, replace);
|
||||
}
|
||||
|
||||
|
||||
int unsetenv(const char *name)
|
||||
{
|
||||
__def_noinline( 0x2F3, int, name)
|
||||
}
|
||||
int unsetenv(const char *name)
|
||||
{
|
||||
return __swi_invoke(0x2F3, unsetenv, name);
|
||||
}
|
||||
|
||||
|
||||
char * getenv(const char *var)
|
||||
{
|
||||
__def_noinline( 0x2F4, char *, var)
|
||||
}
|
||||
char * getenv(const char *var)
|
||||
{
|
||||
return __swi_invoke(0x2F4, getenv, var);
|
||||
}
|
||||
|
||||
|
||||
int clearenv(void)
|
||||
{
|
||||
__def_noinline( 0x2F5, int)
|
||||
}
|
||||
int clearenv(void)
|
||||
{
|
||||
return __swi_invoke(0x2F5, clearenv);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <stddef.h>
|
||||
|
||||
|
||||
void free(void * data)
|
||||
{
|
||||
__def_noinline(21, void, data);
|
||||
}
|
||||
void free(void * data)
|
||||
{
|
||||
__swi_invoke(21, free, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include <stddef.h>
|
||||
|
||||
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
__def_noinline(20, void*, size);
|
||||
}
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
return __swi_invoke(20, malloc, size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
|
||||
void *realloc(void *ptr, size_t size)
|
||||
{
|
||||
__def_noinline(186, void *, ptr, size);
|
||||
}
|
||||
void *realloc(void *ptr, size_t size)
|
||||
{
|
||||
return __swi_invoke(186, realloc, ptr, size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel(image_t *img, int x, int y, color32_t c)
|
||||
{
|
||||
if( x < 0 || y < 0 || x >= img->w || y >= img->h ) return;
|
||||
|
|
@ -25,7 +25,7 @@ void plPutPixel(image_t *img, int x, int y, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelf(image_t *img, int x, int y, color32_t c)
|
||||
{
|
||||
switch(img->bpnum)
|
||||
|
|
@ -41,7 +41,7 @@ void plPutPixelf(image_t *img, int x, int y, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend(image_t *img, int x, int y, color32_t c)
|
||||
{
|
||||
if( x < 0 || y < 0 || x >= img->w || y >= img->h ) return;
|
||||
|
|
@ -58,7 +58,7 @@ void plPutPixelBlend(image_t *img, int x, int y, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixeli(image_t *img, int i, color32_t c)
|
||||
{
|
||||
if(i < 0) return;
|
||||
|
|
@ -78,7 +78,7 @@ void plPutPixeli(image_t *img, int i, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelif(image_t *img, int i, color32_t c)
|
||||
{
|
||||
switch(img->bpnum)
|
||||
|
|
@ -94,7 +94,7 @@ void plPutPixelif(image_t *img, int i, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlendi(image_t *img, int i, color32_t c)
|
||||
{
|
||||
if(i < 0) return;
|
||||
|
|
@ -112,7 +112,7 @@ void plPutPixelBlendi(image_t *img, int i, color32_t c)
|
|||
}
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlendif(image_t *img, int i, color32_t c)
|
||||
{
|
||||
switch(img->bpnum)
|
||||
|
|
@ -128,7 +128,7 @@ void plPutPixelBlendif(image_t *img, int i, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixela(image_t *img, int x, int y, color32_t c)
|
||||
{
|
||||
if(img->blend && plAlpha(c))
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ color16_t plAlphaBlend16(color16_t _color, color16_t _background, uint8_t alpha)
|
|||
|
||||
|
||||
/* put color */
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel16(image_t *img, int x, int y, color16_t c)
|
||||
{
|
||||
if(x < 0 || y < 0 || x >= img->w || y >= img->h || img->bpnum != 16) return;
|
||||
|
|
@ -21,7 +21,7 @@ void plPutPixel16(image_t *img, int x, int y, color16_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel16i(image_t *img, int i, color16_t c)
|
||||
{
|
||||
if(i < 0 || i > plCalcSeek(img->w, img->h, img)*2) return;
|
||||
|
|
@ -31,7 +31,7 @@ void plPutPixel16i(image_t *img, int i, color16_t c)
|
|||
|
||||
|
||||
/* put color with blend */
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend16(image_t *img, int x, int y, color16_t c, uint8_t alpha)
|
||||
{
|
||||
if(x < 0 || y < 0 || x >= img->w || y >= img->h || img->bpnum != 16) return;
|
||||
|
|
@ -42,7 +42,7 @@ void plPutPixelBlend16(image_t *img, int x, int y, color16_t c, uint8_t alpha)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend16i(image_t *img, int i, color16_t c, uint8_t alpha)
|
||||
{
|
||||
if(i < 0 || i > plCalcSeek(img->w, img->h, img)*2) return;
|
||||
|
|
@ -51,7 +51,7 @@ void plPutPixelBlend16i(image_t *img, int i, color16_t c, uint8_t alpha)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
color16_t plGetPixel16(image_t *img, int x, int y)
|
||||
{
|
||||
if(x < 0 || y < 0 || x >= img->w || y >= img->h || img->bpnum != 16) return 0;
|
||||
|
|
@ -60,7 +60,7 @@ color16_t plGetPixel16(image_t *img, int x, int y)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
color16_t plGetPixel16i(image_t *img, int i)
|
||||
{
|
||||
if(i < 0 || i > plCalcSeek(img->w, img->h, img)*2) return 0;
|
||||
|
|
@ -70,21 +70,21 @@ color16_t plGetPixel16i(image_t *img, int i)
|
|||
|
||||
|
||||
/* терь тоже самое но без проверок */
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel16f(image_t *img, int x, int y, color16_t c)
|
||||
{
|
||||
color16_t *map = (color16_t *)img->bitmap;
|
||||
map[ plCalcSeek(x, y, img) ] = c;
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel16if(image_t *img, int i, color16_t c)
|
||||
{
|
||||
color16_t *map = (color16_t *)img->bitmap;
|
||||
map[i] = c;
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend16f(image_t *img, int x, int y, color16_t c, uint8_t alpha)
|
||||
{
|
||||
color16_t *map = (color16_t *)img->bitmap;
|
||||
|
|
@ -92,21 +92,21 @@ void plPutPixelBlend16f(image_t *img, int x, int y, color16_t c, uint8_t alpha)
|
|||
map[s] = plAlphaBlend16(c, map[s], alpha);
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend16if(image_t *img, int i, color16_t c, uint8_t alpha)
|
||||
{
|
||||
color16_t *map = (color16_t *)img->bitmap;
|
||||
map[i] = plAlphaBlend16(c, map[i], alpha);
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
color16_t plGetPixel16f(image_t *img, int x, int y)
|
||||
{
|
||||
color16_t *map = (color16_t *)img->bitmap;
|
||||
return map[plCalcSeek(x, y, img)];
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
color16_t plGetPixel16if(image_t *img, int i)
|
||||
{
|
||||
color16_t *map = (color16_t *)img->bitmap;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ color32_t plAlphaBlend32(color32_t color, color32_t background, uint8_t alpha);
|
|||
|
||||
|
||||
/* put color */
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel32(image_t *img, int x, int y, color32_t c)
|
||||
{
|
||||
if(x < 0 || y < 0 || x >= img->w || y >= img->h || img->bpnum != 32) return;
|
||||
|
|
@ -22,7 +22,7 @@ void plPutPixel32(image_t *img, int x, int y, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel32i(image_t *img, int i, color32_t c)
|
||||
{
|
||||
if(i < 0 || i > plCalcSeek(img->w, img->h, img)*4) return;
|
||||
|
|
@ -32,7 +32,7 @@ void plPutPixel32i(image_t *img, int i, color32_t c)
|
|||
|
||||
|
||||
/* put color with blend */
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend32(image_t *img, int x, int y, color32_t c)
|
||||
{
|
||||
if(x < 0 || y < 0 || x >= img->w || y >= img->h || img->bpnum != 32) return;
|
||||
|
|
@ -43,7 +43,7 @@ void plPutPixelBlend32(image_t *img, int x, int y, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend32i(image_t *img, int i, color32_t c)
|
||||
{
|
||||
if(i < 0 || i > plCalcSeek(img->w, img->h, img)*4) return;
|
||||
|
|
@ -52,7 +52,7 @@ void plPutPixelBlend32i(image_t *img, int i, color32_t c)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
color32_t plGetPixel32(image_t *img, int x, int y)
|
||||
{
|
||||
if(x < 0 || y < 0 || x >= img->w || y >= img->h || img->bpnum != 32) return 0;
|
||||
|
|
@ -61,7 +61,7 @@ color32_t plGetPixel32(image_t *img, int x, int y)
|
|||
}
|
||||
|
||||
|
||||
__inl
|
||||
static inline
|
||||
color32_t plGetPixel32i(image_t *img, int i)
|
||||
{
|
||||
if(i < 0 || i > plCalcSeek(img->w, img->h, img)*4) return 0;
|
||||
|
|
@ -71,21 +71,21 @@ color32_t plGetPixel32i(image_t *img, int i)
|
|||
|
||||
|
||||
/* терь тоже самое но без проверок */
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel32f(image_t *img, int x, int y, color32_t c)
|
||||
{
|
||||
color32_t *map = (color32_t *)img->bitmap;
|
||||
map[ plCalcSeek(x, y, img) ] = c;
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixel32if(image_t *img, int i, color32_t c)
|
||||
{
|
||||
color32_t *map = (color32_t *)img->bitmap;
|
||||
map[i] = c;
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend32f(image_t *img, int x, int y, color32_t c)
|
||||
{
|
||||
color32_t *map = (color32_t *)img->bitmap;
|
||||
|
|
@ -97,21 +97,21 @@ void plPutPixelBlend32f(image_t *img, int x, int y, color32_t c)
|
|||
map[s] = c;
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
void plPutPixelBlend32if(image_t *img, int i, color32_t c)
|
||||
{
|
||||
color32_t *map = (color32_t *)img->bitmap;
|
||||
map[i] = plAlphaBlend32(c, map[i], plAlpha(c));
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
color32_t plGetPixel32f(image_t *img, int x, int y)
|
||||
{
|
||||
color32_t *map = (color32_t *)img->bitmap;
|
||||
return map[plCalcSeek(x, y, img)];
|
||||
}
|
||||
|
||||
__inl
|
||||
static inline
|
||||
color32_t plGetPixel32if(image_t *img, int i)
|
||||
{
|
||||
color32_t *map = (color32_t *)img->bitmap;
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@
|
|||
#include "pixtypes.h"
|
||||
|
||||
|
||||
#ifndef __inl
|
||||
#define __inl static inline
|
||||
#endif
|
||||
|
||||
|
||||
#define plCalcSeek(x, y, img) ((y * img->w) + x)
|
||||
#define plAlpha(color32) (color32 >> 24 & 0xff)
|
||||
|
|
|
|||
|
|
@ -35,18 +35,9 @@ Format of the variadic function definition:
|
|||
* @param cepid destination CEPID.
|
||||
* @param msg ID of the message
|
||||
*/ // <--- Short documentation in Doxygen format
|
||||
#ifdef SWILIB_MODE_DIRECT // <-- for GCC
|
||||
|
||||
#define GBS_SendMessage(_cepid, _msg, ...) \
|
||||
__swi_call(0x100, void, (int cepid, int msg, ...), (_cepid, _msg, ## __VA_ARGS__)); // <-- function definition
|
||||
|
||||
#else // <-- for IAR
|
||||
|
||||
__swi_begin(0x100) // <-- swi number for IAR
|
||||
__swi_variadic_begin(0x100) // <-- swi number for IAR
|
||||
void GBS_SendMessage(int cepid, int msg, ...) // <-- function definition
|
||||
__swi_end(0x100, GBS_SendMessage, (cepid, msg)); // <-- swi number for others (actually stub)
|
||||
|
||||
#endif
|
||||
__swi_variadic_end(0x100, GBS_SendMessage, cepid, msg); // <-- swi number and fixed arguments for GCC
|
||||
|
||||
```
|
||||
|
||||
|
|
@ -57,9 +48,10 @@ Macroses:
|
|||
- swi_num - SWI number
|
||||
- function_name - name of the function
|
||||
- function_arguments - list of the function arguments in braces `()`
|
||||
- `__swi_call(swi_num, return_type, function_signature, function_arguments)` - variadic support for GCC
|
||||
- `__swi_variadic_begin(swi_num)` - variadic function declaration start
|
||||
- swi_num - SWI number
|
||||
- return_type - return type of the function
|
||||
- function_signature - function arguments definition in braces `()`
|
||||
- function_arguments - list of the function arguments in braces `()`
|
||||
- `__swi_variadic_end(swi_num, function_name, fixed_arguments...)` - variadic function declaration end
|
||||
- swi_num - SWI number
|
||||
- function_name - name of the function
|
||||
- fixed_arguments - named arguments before `...`
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@
|
|||
#define __swi_noreturn_begin(number) __swi_begin
|
||||
#define __swi_noreturn_end(number, func, call) __swi_end(number, func)
|
||||
|
||||
#define __swi_value_begin(number) __swi_begin
|
||||
#define __swi_value_end(number, func) __swi_end(number, func)
|
||||
#define __swi_variadic_begin(number) __swi_begin
|
||||
#define __swi_variadic_end(number, func, ...) __swi_end(number, func)
|
||||
|
||||
#else
|
||||
#define __swilib_begin
|
||||
#define __swilib_end
|
||||
|
|
@ -32,6 +33,9 @@
|
|||
#define __swi_noreturn_begin(number)
|
||||
#define __swi_noreturn_end(number, func, call)
|
||||
|
||||
#define __swi_value_begin(number)
|
||||
#define __swi_value_end(number, func)
|
||||
#define __swi_variadic_begin(number)
|
||||
#define __swi_variadic_end(number, func, ...)
|
||||
|
||||
#endif
|
||||
|
||||
#define __swi_format(type, ...)
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ extern "C" const int __sys_switab_addres[];
|
|||
extern const int __sys_switab_addres[];
|
||||
#endif
|
||||
|
||||
#define SWILIB_MODE_DIRECT 1
|
||||
|
||||
/* Modern */
|
||||
#ifdef __cplusplus
|
||||
#define __swilib_begin \
|
||||
|
|
@ -31,51 +29,48 @@ extern const int __sys_switab_addres[];
|
|||
_Pragma("GCC diagnostic pop")
|
||||
#endif
|
||||
|
||||
#define __swi_begin(number) static inline __attribute__((flatten))
|
||||
#define __swi_end(number, func, call) { \
|
||||
if (number < 0x8000) { \
|
||||
return ((__typeof__(&func)) __sys_switab_addres[number])call; \
|
||||
} else { \
|
||||
return ((__typeof__(func call)) __sys_switab_addres[number - 0x8000]); \
|
||||
} \
|
||||
}
|
||||
#ifdef SWILIB_NAMED_IMPORTS
|
||||
#define __swi_stringify_(value) #value
|
||||
#define __swi_stringify(value) __swi_stringify_(value)
|
||||
#define __swi_import_name(number) "\"#" __swi_stringify(number) "\""
|
||||
|
||||
#define __swi_noreturn_begin(number) static inline __attribute__((flatten, noreturn))
|
||||
#define __swi_noreturn_end(number, func, call) { \
|
||||
((__typeof__(&func)) __sys_switab_addres[number])call; \
|
||||
}
|
||||
#define __swi_begin(number)
|
||||
#define __swi_end(number, func, call) __asm__(__swi_import_name(number)) __attribute__((weak))
|
||||
|
||||
#define __swi_call(number, ret, signature, call) \
|
||||
(((ret (*)signature)(__sys_switab_addres[number]))call)
|
||||
#define __swi_noreturn_begin(number)
|
||||
#define __swi_noreturn_end(number, func, call) \
|
||||
__asm__(__swi_import_name(number)) __attribute__((weak, noreturn))
|
||||
|
||||
#define __swi_variadic_begin(number)
|
||||
#define __swi_variadic_end(number, func, ...) \
|
||||
__asm__(__swi_import_name(number)) __attribute__((weak))
|
||||
#else
|
||||
#define __swi_begin(number) static inline __attribute__((flatten))
|
||||
#define __swi_end(number, func, call) { \
|
||||
if (number < 0x8000) { \
|
||||
return ((__typeof__(&func)) __sys_switab_addres[number])call; \
|
||||
} else { \
|
||||
return ((__typeof__(func call)) __sys_switab_addres[number - 0x8000]); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define __swi_noreturn_begin(number) static inline __attribute__((flatten, noreturn))
|
||||
#define __swi_noreturn_end(number, func, call) { \
|
||||
((__typeof__(&func)) __sys_switab_addres[number])call; \
|
||||
}
|
||||
|
||||
#define __swi_variadic_begin(number) \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") \
|
||||
static inline __attribute__((always_inline))
|
||||
#define __swi_variadic_end(number, func, ...) { \
|
||||
return ((__typeof__(&func)) __sys_switab_addres[number])(__VA_ARGS__, __builtin_va_arg_pack()); \
|
||||
} \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
#endif
|
||||
|
||||
#define __swi_format(type, ...) \
|
||||
__attribute__((format(type, ##__VA_ARGS__)))
|
||||
|
||||
#define __swi_noreturn __attribute__((noreturn))
|
||||
|
||||
/* Legacy */
|
||||
#define __inl static inline
|
||||
|
||||
#define __def(id, ret, ...) \
|
||||
{ \
|
||||
if (id >= 0x8000) { \
|
||||
return (ret)(__sys_switab_addres[id - 0x8000]); \
|
||||
} else { \
|
||||
return ((ret (*)(...))((__sys_switab_addres[id])))(__VA_ARGS__); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define __defn(id, ...) { ((void (*)(...))((__sys_switab_addres[id])))(__VA_ARGS__); }
|
||||
|
||||
#define __cdef(id, ret, ...) (ret)((ret (*)(...))((__sys_switab_addres[id])))(__VA_ARGS__)
|
||||
#define __cdefn(id, ...) ((void (*)(...))((__sys_switab_addres[id])))(__VA_ARGS__)
|
||||
|
||||
#define __nul_def(id, ret) { return ((ret (*)())((__sys_switab_addres[id])))(); }
|
||||
#define __nul_defn(id) { ((void (*)())((__sys_switab_addres[id])))(); }
|
||||
|
||||
#define __def_noinline(id, ret, ...) \
|
||||
if (id >= 0x8000) { \
|
||||
return (ret)(__sys_switab_addres[id - 0x8000]); \
|
||||
} else { \
|
||||
return ((ret (*)(...))((__sys_switab_addres[id])))(__VA_ARGS__); \
|
||||
}
|
||||
#define __swi_invoke(number, func, ...) \
|
||||
((__typeof__(&(func))) __sys_switab_addres[number])(__VA_ARGS__)
|
||||
|
|
|
|||
|
|
@ -25,3 +25,8 @@
|
|||
|
||||
#define __swi_noreturn_begin(number)
|
||||
#define __swi_noreturn_end(number, func, call)
|
||||
|
||||
#define __swi_variadic_begin(number)
|
||||
#define __swi_variadic_end(number, func, ...)
|
||||
|
||||
#define __swi_format(type, ...) __attribute__((format(type, ##__VA_ARGS__)))
|
||||
|
|
|
|||
|
|
@ -28,4 +28,7 @@ unsigned int __attribute__((warning("Function not found in swilib."))) ___bad_sw
|
|||
#define __swi_noreturn_begin(number)
|
||||
#define __swi_noreturn_end(number, func, call)
|
||||
|
||||
#define __longcall__ __attribute__((long_call))
|
||||
#define __swi_variadic_begin(number)
|
||||
#define __swi_variadic_end(number, func, ...)
|
||||
|
||||
#define __swi_format(type, ...) __attribute__((format(type, ##__VA_ARGS__)))
|
||||
|
|
|
|||
|
|
@ -19,3 +19,8 @@
|
|||
|
||||
#define __swi_noreturn_begin(number) __swi_pragma(swi_number=number) __swi __arm
|
||||
#define __swi_noreturn_end(number, func, call)
|
||||
|
||||
#define __swi_variadic_begin(number) __swi_begin(number)
|
||||
#define __swi_variadic_end(number, func, ...)
|
||||
|
||||
#define __swi_format(type, ...)
|
||||
|
|
|
|||
|
|
@ -234,14 +234,9 @@ __swi_end(0x18C, GBS_DelTimer, (timer));
|
|||
* @param cepid destination CEPID.
|
||||
* @param msg ID of the message
|
||||
*/
|
||||
#ifdef SWILIB_MODE_DIRECT
|
||||
#define GBS_SendMessage(_cepid, _msg, ...) \
|
||||
__swi_call(0x100, void, (int cepid, int msg, ...), (_cepid, _msg, ## __VA_ARGS__));
|
||||
#else
|
||||
__swi_begin(0x100)
|
||||
__swi_variadic_begin(0x100)
|
||||
void GBS_SendMessage(int cepid, int msg, ...)
|
||||
__swi_end(0x100, GBS_SendMessage, (cepid, msg)); // (int cepid, int msg, int submess, void *data0, void *data1)
|
||||
#endif
|
||||
__swi_variadic_end(0x100, GBS_SendMessage, cepid, msg); // (int cepid, int msg, int submess, void *data0, void *data1)
|
||||
|
||||
/**
|
||||
* Receive GBS message inside GBS processor.
|
||||
|
|
|
|||
|
|
@ -48,14 +48,9 @@ __swi_end(0x031, strrchr_2, (str, character));
|
|||
* @copydoc wsprintf
|
||||
* @deprecated use #wsprintf
|
||||
* */
|
||||
#ifdef SWILIB_MODE_DIRECT
|
||||
#define wsprintf_2(_s, _format, ...) \
|
||||
__swi_call(0x0A0, int, (WSHDR *s, const char *format, ...), (_s, _format, ## __VA_ARGS__));
|
||||
#else
|
||||
__swi_begin(0x0A0)
|
||||
__swi_variadic_begin(0x0A0)
|
||||
int wsprintf_2(WSHDR *s, const char *format, ...)
|
||||
__swi_end(0x0A0, wsprintf_2, (s, format));
|
||||
#endif
|
||||
__swi_variadic_end(0x0A0, wsprintf_2, s, format);
|
||||
|
||||
/**
|
||||
* @copydoc AllocWS
|
||||
|
|
|
|||
|
|
@ -276,14 +276,10 @@ __swi_end(0x07E, rand, ());
|
|||
* @return Notice that only when this returned value is non-negative and less than n, the string has been completely written.
|
||||
* */
|
||||
|
||||
#ifdef SWILIB_MODE_DIRECT
|
||||
#define snprintf(_s, _n, _format, ...) \
|
||||
__swi_call(0x11B, __swi_format(printf, 3, 4) int, (char *s, size_t n, const char *format, ...), (_s, _n, _format, ## __VA_ARGS__));
|
||||
#else
|
||||
__swi_begin(0x11B)
|
||||
__swi_variadic_begin(0x11B)
|
||||
__swi_format(printf, 3, 4)
|
||||
int snprintf(char *s, size_t n, const char *format, ...)
|
||||
__swi_end(0x11B, snprintf, (s, n, format));
|
||||
#endif
|
||||
__swi_variadic_end(0x11B, snprintf, s, n, format);
|
||||
|
||||
/**
|
||||
* Write formatted output to buffer.
|
||||
|
|
@ -293,14 +289,10 @@ __swi_end(0x11B, snprintf, (s, n, format));
|
|||
* @return If an encoding error occurs, a negative number is returned.
|
||||
* @return Notice that only when this returned value is non-negative and less than n, the string has been completely written.
|
||||
* */
|
||||
#ifdef SWILIB_MODE_DIRECT
|
||||
#define sprintf(_s, _format, ...) \
|
||||
__swi_call(0x016, __swi_format(printf, 2, 3) int, (char *s, const char *format, ...), (_s, _format, ## __VA_ARGS__));
|
||||
#else
|
||||
__swi_begin(0x016)
|
||||
__swi_variadic_begin(0x016)
|
||||
__swi_format(printf, 2, 3)
|
||||
int sprintf(char *s, const char *format, ...)
|
||||
__swi_end(0x016, sprintf, (s, format));
|
||||
#endif
|
||||
__swi_variadic_end(0x016, sprintf, s, format);
|
||||
|
||||
/**
|
||||
* Read formatted data from string.
|
||||
|
|
@ -310,14 +302,10 @@ __swi_end(0x016, sprintf, (s, format));
|
|||
* @return This count can match the expected number of items or be less (even zero) in the case of a matching failure.
|
||||
* @return In the case of an input failure before any data could be successfully interpreted, EOF is returned.
|
||||
* */
|
||||
#ifdef SWILIB_MODE_DIRECT
|
||||
#define sscanf(_s, _format, ...) \
|
||||
__swi_call(0x1F5, __swi_format(printf, 2, 3) int, (const char *s, const char *format, ...), (_s, _format, ## __VA_ARGS__));
|
||||
#else
|
||||
__swi_begin(0x1F5)
|
||||
__swi_variadic_begin(0x1F5)
|
||||
__swi_format(scanf, 2, 3)
|
||||
int sscanf(const char *s, const char *format, ...)
|
||||
__swi_end(0x1F5, sscanf, (s, format));
|
||||
#endif
|
||||
__swi_variadic_end(0x1F5, sscanf, s, format);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -60,14 +60,9 @@ __swi_end(0x81B5, isnewSGold, ());
|
|||
* SUBPROC(test_func, 1, 2);
|
||||
* ```
|
||||
* */
|
||||
#ifdef SWILIB_MODE_DIRECT
|
||||
#define SUBPROC(_callback, ...) \
|
||||
__swi_call(0x171, void, (void *callback, ...), (_callback, ## __VA_ARGS__));
|
||||
#else
|
||||
__swi_begin(0x171)
|
||||
__swi_variadic_begin(0x171)
|
||||
void SUBPROC(void *callback, ...)
|
||||
__swi_end(0x171, SUBPROC, (callback));
|
||||
#endif
|
||||
__swi_variadic_end(0x171, SUBPROC, callback);
|
||||
|
||||
/**
|
||||
* Get phone uptime in the ticks (1 tick=4.615 ms).
|
||||
|
|
|
|||
|
|
@ -323,14 +323,9 @@ __swi_end(0x3DB, wstrreplace, (dest, src, pos));
|
|||
* @return If an encoding error occurs, a negative number is returned.
|
||||
* @return Notice that only when this returned value is non-negative and less than n, the string has been completely written.
|
||||
* */
|
||||
#ifdef SWILIB_MODE_DIRECT
|
||||
#define wsprintf(_s, _format, ...) \
|
||||
__swi_call(0x124, int, (WSHDR *s, const char *format, ...), (_s, _format, ## __VA_ARGS__));
|
||||
#else
|
||||
__swi_begin(0x124)
|
||||
__swi_variadic_begin(0x124)
|
||||
int wsprintf(WSHDR *s, const char *format, ...)
|
||||
__swi_end(0x124, wsprintf, (s, format));
|
||||
#endif
|
||||
__swi_variadic_end(0x124, wsprintf, s, format);
|
||||
|
||||
/**
|
||||
* Append formatted output to the end of WSHDR.
|
||||
|
|
@ -343,14 +338,9 @@ __swi_end(0x124, wsprintf, (s, format));
|
|||
* @param[out] s pointer to a WSHDR where the resulting string is stored, the buffer should be large enough to contain the resulting string
|
||||
* @param format C-string that contains a format string that follows the same specifications as standart format in any sprintf/printf (CP1252, latin)
|
||||
* */
|
||||
#ifdef SWILIB_MODE_DIRECT
|
||||
#define wstrcatprintf(_s, _format, ...) \
|
||||
__swi_call(0x216, int, (WSHDR *s, const char *format, ...), (_s, _format, ## __VA_ARGS__));
|
||||
#else
|
||||
__swi_begin(0x216)
|
||||
__swi_variadic_begin(0x216)
|
||||
void wstrcatprintf(WSHDR *s, const char *format, ...)
|
||||
__swi_end(0x216, wstrcatprintf, (s, format));
|
||||
#endif
|
||||
__swi_variadic_end(0x216, wstrcatprintf, s, format);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue