indent patch.c patch.h
This commit is contained in:
parent
7c0c9d2471
commit
b8d199fef7
2 changed files with 253 additions and 253 deletions
|
|
@ -17,27 +17,27 @@
|
||||||
|
|
||||||
|
|
||||||
// missing from wchar.h on Mac
|
// missing from wchar.h on Mac
|
||||||
wchar_t* wcsdup(const wchar_t* ws)
|
wchar_t *wcsdup(const wchar_t * ws)
|
||||||
{
|
{
|
||||||
wchar_t *ret;
|
wchar_t *ret;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = wcslen (ws);
|
len = wcslen(ws);
|
||||||
ret = malloc ((len + 1) * sizeof (wchar_t));
|
ret = malloc((len + 1) * sizeof(wchar_t));
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
return ret;
|
return ret;
|
||||||
return (wcscpy (ret, ws));
|
return (wcscpy(ret, ws));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// missing, needed by __nl_find_msg in libintl.a(dcigettext.o)
|
// missing, needed by __nl_find_msg in libintl.a(dcigettext.o)
|
||||||
// http://forums.macrumors.com/showthread.php?t=1284479
|
// http://forums.macrumors.com/showthread.php?t=1284479
|
||||||
#undef iconv_t
|
#undef iconv_t
|
||||||
typedef void* iconv_t;
|
typedef void *iconv_t;
|
||||||
extern size_t libiconv(iconv_t cd, char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
|
extern size_t libiconv(iconv_t cd, char * *inbuf, size_t * inbytesleft, char * *outbuf, size_t * outbytesleft);
|
||||||
extern iconv_t libiconv_open(const char* tocode, const char* fromcode);
|
extern iconv_t libiconv_open(const char *tocode, const char *fromcode);
|
||||||
|
|
||||||
size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
|
size_t iconv(iconv_t cd, char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft)
|
||||||
{
|
{
|
||||||
return libiconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
|
return libiconv(cd, inbuf, inbytesleft, outbuf, outbytesleft);
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ iconv_t iconv_open(const char *tocode, const char *fromcode)
|
||||||
|
|
||||||
// to fix ineffective setlocale() in i18n.c or force language to Inuktitut
|
// to fix ineffective setlocale() in i18n.c or force language to Inuktitut
|
||||||
// must be called prior to setup_i18n()
|
// must be called prior to setup_i18n()
|
||||||
patch_i18n(const char* locale)
|
patch_i18n(const char *locale)
|
||||||
{
|
{
|
||||||
setenv("LANG", locale, 1); // takes language passed as an argument
|
setenv("LANG", locale, 1); // takes language passed as an argument
|
||||||
// setenv("LANG", "iu_CA.UTF-8", 1); // forces language to Inuktitut
|
// setenv("LANG", "iu_CA.UTF-8", 1); // forces language to Inuktitut
|
||||||
|
|
@ -64,12 +64,13 @@ patch_i18n(const char* locale)
|
||||||
typedef unsigned su_int;
|
typedef unsigned su_int;
|
||||||
typedef long long di_int;
|
typedef long long di_int;
|
||||||
typedef unsigned long long du_int;
|
typedef unsigned long long du_int;
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
typedef int ti_int __attribute__ ((mode (DI)));
|
typedef int ti_int __attribute__ ((mode(DI)));
|
||||||
typedef unsigned tu_int __attribute__ ((mode (DI)));
|
typedef unsigned tu_int __attribute__ ((mode(DI)));
|
||||||
#else
|
#else
|
||||||
typedef int ti_int __attribute__ ((mode (TI)));
|
typedef int ti_int __attribute__ ((mode(TI)));
|
||||||
typedef unsigned tu_int __attribute__ ((mode (TI)));
|
typedef unsigned tu_int __attribute__ ((mode(TI)));
|
||||||
#endif
|
#endif
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
|
|
@ -83,22 +84,25 @@ typedef union
|
||||||
du_int high;
|
du_int high;
|
||||||
du_int low;
|
du_int low;
|
||||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
#endif /* _YUGA_LITTLE_ENDIAN */
|
||||||
}s;
|
} s;
|
||||||
} utwords;
|
} utwords;
|
||||||
|
|
||||||
// missing, needed by __umodti3 and __udivti3
|
// missing, needed by __umodti3 and __udivti3
|
||||||
// http://www.publicsource.apple.com/source/clang/clang-137/src/projects/compiler-rt/lib/udivmodti4.c
|
// http://www.publicsource.apple.com/source/clang/clang-137/src/projects/compiler-rt/lib/udivmodti4.c
|
||||||
tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem)
|
tu_int __udivmodti4(tu_int a, tu_int b, tu_int * rem)
|
||||||
{
|
{
|
||||||
const unsigned n_udword_bits = sizeof(du_int) * CHAR_BIT;
|
const unsigned n_udword_bits = sizeof(du_int) * CHAR_BIT;
|
||||||
const unsigned n_utword_bits = sizeof(tu_int) * CHAR_BIT;
|
const unsigned n_utword_bits = sizeof(tu_int) * CHAR_BIT;
|
||||||
utwords n;
|
utwords n;
|
||||||
|
|
||||||
n.all = a;
|
n.all = a;
|
||||||
utwords d;
|
utwords d;
|
||||||
|
|
||||||
d.all = b;
|
d.all = b;
|
||||||
utwords q;
|
utwords q;
|
||||||
utwords r;
|
utwords r;
|
||||||
unsigned sr;
|
unsigned sr;
|
||||||
|
|
||||||
/* special cases, X is unknown, K != 0 */
|
/* special cases, X is unknown, K != 0 */
|
||||||
if (n.s.high == 0)
|
if (n.s.high == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -198,6 +202,7 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem)
|
||||||
if (d.s.low == 1)
|
if (d.s.low == 1)
|
||||||
return n.all;
|
return n.all;
|
||||||
unsigned sr = __builtin_ctzll(d.s.low);
|
unsigned sr = __builtin_ctzll(d.s.low);
|
||||||
|
|
||||||
q.s.high = n.s.high >> sr;
|
q.s.high = n.s.high >> sr;
|
||||||
q.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr);
|
q.s.low = (n.s.high << (n_udword_bits - sr)) | (n.s.low >> sr);
|
||||||
return q.all;
|
return q.all;
|
||||||
|
|
@ -206,8 +211,7 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem)
|
||||||
* ---
|
* ---
|
||||||
* 0 K
|
* 0 K
|
||||||
*/
|
*/
|
||||||
sr = 1 + n_udword_bits + __builtin_clzll(d.s.low)
|
sr = 1 + n_udword_bits + __builtin_clzll(d.s.low) - __builtin_clzll(n.s.high);
|
||||||
- __builtin_clzll(n.s.high);
|
|
||||||
/* 2 <= sr <= n_utword_bits - 1
|
/* 2 <= sr <= n_utword_bits - 1
|
||||||
* q.all = n.all << (n_utword_bits - sr);
|
* q.all = n.all << (n_utword_bits - sr);
|
||||||
* r.all = n.all >> sr;
|
* r.all = n.all >> sr;
|
||||||
|
|
@ -234,20 +238,16 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem)
|
||||||
* r.s.low = n.s.high >> (sr - n_udword_bits);
|
* r.s.low = n.s.high >> (sr - n_udword_bits);
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
q.s.low = (n.s.low << (n_utword_bits - sr)) &
|
q.s.low = (n.s.low << (n_utword_bits - sr)) & ((di_int) (int)(n_udword_bits - sr) >> (n_udword_bits - 1));
|
||||||
((di_int)(int)(n_udword_bits - sr) >> (n_udword_bits-1));
|
q.s.high = ((n.s.low << (n_udword_bits - sr)) &
|
||||||
q.s.high = ((n.s.low << ( n_udword_bits - sr)) &
|
((di_int) (int)(sr - n_udword_bits - 1) >> (n_udword_bits - 1))) |
|
||||||
((di_int)(int)(sr - n_udword_bits - 1) >> (n_udword_bits-1))) |
|
|
||||||
(((n.s.high << (n_utword_bits - sr)) |
|
(((n.s.high << (n_utword_bits - sr)) |
|
||||||
(n.s.low >> (sr - n_udword_bits))) &
|
(n.s.low >> (sr - n_udword_bits))) & ((di_int) (int)(n_udword_bits - sr) >> (n_udword_bits - 1)));
|
||||||
((di_int)(int)(n_udword_bits - sr) >> (n_udword_bits-1)));
|
r.s.high = (n.s.high >> sr) & ((di_int) (int)(sr - n_udword_bits) >> (n_udword_bits - 1));
|
||||||
r.s.high = (n.s.high >> sr) &
|
|
||||||
((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1));
|
|
||||||
r.s.low = ((n.s.high >> (sr - n_udword_bits)) &
|
r.s.low = ((n.s.high >> (sr - n_udword_bits)) &
|
||||||
((di_int)(int)(n_udword_bits - sr - 1) >> (n_udword_bits-1))) |
|
((di_int) (int)(n_udword_bits - sr - 1) >> (n_udword_bits - 1))) |
|
||||||
(((n.s.high << (n_udword_bits - sr)) |
|
(((n.s.high << (n_udword_bits - sr)) |
|
||||||
(n.s.low >> sr)) &
|
(n.s.low >> sr)) & ((di_int) (int)(sr - n_udword_bits) >> (n_udword_bits - 1)));
|
||||||
((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1)));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -280,11 +280,9 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem)
|
||||||
* r.s.low = n.s.high;
|
* r.s.low = n.s.high;
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
r.s.high = (n.s.high >> sr) &
|
r.s.high = (n.s.high >> sr) & ((di_int) (int)(sr - n_udword_bits) >> (n_udword_bits - 1));
|
||||||
((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1));
|
|
||||||
r.s.low = (n.s.high << (n_udword_bits - sr)) |
|
r.s.low = (n.s.high << (n_udword_bits - sr)) |
|
||||||
((n.s.low >> sr) &
|
((n.s.low >> sr) & ((di_int) (int)(sr - n_udword_bits) >> (n_udword_bits - 1)));
|
||||||
((di_int)(int)(sr - n_udword_bits) >> (n_udword_bits-1)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Not a special case
|
/* Not a special case
|
||||||
|
|
@ -294,6 +292,7 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem)
|
||||||
* 1 <= sr <= n_utword_bits - 1
|
* 1 <= sr <= n_utword_bits - 1
|
||||||
*/
|
*/
|
||||||
su_int carry = 0;
|
su_int carry = 0;
|
||||||
|
|
||||||
for (; sr > 0; --sr)
|
for (; sr > 0; --sr)
|
||||||
{
|
{
|
||||||
/* r:q = ((r:q) << 1) | carry */
|
/* r:q = ((r:q) << 1) | carry */
|
||||||
|
|
@ -308,7 +307,8 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem)
|
||||||
* carry = 1;
|
* carry = 1;
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
const ti_int s = (ti_int)(d.all - r.all - 1) >> (n_utword_bits - 1);
|
const ti_int s = (ti_int) (d.all - r.all - 1) >> (n_utword_bits - 1);
|
||||||
|
|
||||||
carry = s & 1;
|
carry = s & 1;
|
||||||
r.all -= d.all & s;
|
r.all -= d.all & s;
|
||||||
}
|
}
|
||||||
|
|
@ -323,6 +323,7 @@ tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem)
|
||||||
tu_int __umodti3(tu_int a, tu_int b)
|
tu_int __umodti3(tu_int a, tu_int b)
|
||||||
{
|
{
|
||||||
tu_int r;
|
tu_int r;
|
||||||
|
|
||||||
__udivmodti4(a, b, &r);
|
__udivmodti4(a, b, &r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
@ -335,7 +336,7 @@ tu_int __udivti3(tu_int a, tu_int b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// missing, needed by __nl_log_untranslated in libintl.a(log.o) for 10.5
|
// missing, needed by __nl_log_untranslated in libintl.a(log.o) for 10.5
|
||||||
FILE* fopen$DARWIN_EXTSN(const char *filename, const char *mode)
|
FILE *fopen$DARWIN_EXTSN(const char *filename, const char *mode)
|
||||||
{
|
{
|
||||||
return fopen(filename, mode);
|
return fopen(filename, mode);
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +348,7 @@ int posix_memalign(void **ptr, size_t align, size_t size)
|
||||||
{
|
{
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
*ptr = _mm_malloc (size, align);
|
*ptr = _mm_malloc(size, align);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -359,7 +360,6 @@ int posix_memalign(void **ptr, size_t align, size_t size)
|
||||||
// missing in libpng<1.5, needed by _Load_SBit_Png in libfreetype.a(sfnt.o), _error_callback in libfreetype.a(sfnt.o)
|
// missing in libpng<1.5, needed by _Load_SBit_Png in libfreetype.a(sfnt.o), _error_callback in libfreetype.a(sfnt.o)
|
||||||
// http://stackoverflow.com/questions/5190554/unresolved-external-png-set-longjmp-fn-in-libpng
|
// http://stackoverflow.com/questions/5190554/unresolved-external-png-set-longjmp-fn-in-libpng
|
||||||
// http://cpansearch.perl.org/src/JTPALMER/Alien-SDL-1.439_1/patches/SDL_image-1.2.10-libpng15.patch
|
// http://cpansearch.perl.org/src/JTPALMER/Alien-SDL-1.439_1/patches/SDL_image-1.2.10-libpng15.patch
|
||||||
typedef jmp_buf* (*png_set_longjmp_fnPtr)(png_structp, void*, size_t);
|
typedef jmp_buf *(*png_set_longjmp_fnPtr) (png_structp, void *, size_t);
|
||||||
png_set_longjmp_fnPtr png_set_longjmp_fn = 0;
|
png_set_longjmp_fnPtr png_set_longjmp_fn = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,4 @@
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
wchar_t* wcsdup(const wchar_t*);
|
wchar_t *wcsdup(const wchar_t *);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue