1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-01-14 12:17:08 +00:00

[iQue] Match libultra/libc (#2407)

This commit is contained in:
Tharo 2025-01-07 09:19:18 +00:00 committed by GitHub
parent 727b61aaf8
commit a3c3c38fea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 25 deletions

View file

@ -645,6 +645,9 @@ $(BUILD_DIR)/src/libultra/%.o: CFLAGS := $(EGCS_CFLAGS) -mno-abicalls
$(BUILD_DIR)/src/libultra/%.o: CCASFLAGS := $(EGCS_CCASFLAGS)
$(BUILD_DIR)/src/libultra/%.o: ASOPTFLAGS := $(EGCS_ASOPTFLAGS)
$(BUILD_DIR)/src/libultra/libc/ll.o: OPTFLAGS := -O0
$(BUILD_DIR)/src/libultra/libc/llcvt.o: OPTFLAGS := -O0
$(BUILD_DIR)/src/libultra/os/exceptasm.o: MIPS_VERSION := -mips3
$(BUILD_DIR)/src/libultra/os/invaldcache.o: MIPS_VERSION := -mips3
$(BUILD_DIR)/src/libultra/os/invalicache.o: MIPS_VERSION := -mips3

View file

@ -66,11 +66,12 @@ typedef char * __gnuc_va_list;
/* We cast to void * and then to TYPE * because this avoids
a warning about increasing the alignment requirement. */
#define va_arg(__AP, __type) \
((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4 \
? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \
: ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \
+ __va_rounded_size(__type))))[-1]
#define va_arg(__AP, __type) \
((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4 \
? ((__PTRDIFF_TYPE__)__AP + 8 - 1) & -8 \
: ((__PTRDIFF_TYPE__)__AP + 4 - 1) & -4) \
+ __va_rounded_size (__type))), \
*(__type *) (void *) (__AP - __va_rounded_size (__type)))
typedef __gnuc_va_list va_list;

View file

@ -61,8 +61,8 @@ partaligncmp:
addu a3, a3, a0
1:
lwl v0, (a0)
lw v1, (a1)
lwr v0, 3(a0)
lw v1, (a1)
addu a0, a0, 4
addu a1, a1, 4
bne v0, v1, cmpne

View file

@ -51,8 +51,8 @@ bytezero:
/* zero one byte at a time */
addu a1, a1, a0
1:
sb zero, (a0)
addiu a0, a0, 1
sb zero, -1(a0)
bne a0, a1, 1b
zerodone:
jr ra

View file

@ -56,7 +56,7 @@ void _Ldtob(_Pft* args, char code) {
} else if (args->prec == 0 && (code == 'g' || code == 'G')) {
args->prec = 1;
}
err = _Ldunscale(&exp, (_Pft*)args);
err = _Ldunscale(&exp, args);
if (err > 0) {
memcpy(args->s, err == 2 ? "NaN" : "Inf", args->n1 = 3);
return;
@ -76,7 +76,7 @@ void _Ldtob(_Pft* args, char code) {
exp = exp * 30103 / 100000 - 4;
if (exp < 0) {
n = (3 - exp) & ~3;
n = (-exp + 3) & ~3;
exp = -n;
for (i = 0; n > 0; n >>= 1, i++) {
if ((n & 1) != 0) {
@ -95,7 +95,7 @@ void _Ldtob(_Pft* args, char code) {
val /= factor;
}
gen = ((code == 'f') ? exp + 10 : 6) + args->prec;
gen = args->prec + ((code == 'f') ? exp + 10 : 6);
if (gen > 0x13) {
gen = 0x13;
}
@ -128,20 +128,14 @@ void _Ldtob(_Pft* args, char code) {
--gen, --exp;
}
nsig = ((code == 'f') ? exp + 1 : ((code == 'e' || code == 'E') ? 1 : 0)) + args->prec;
nsig = args->prec + ((code == 'f') ? exp + 1 : ((code == 'e' || code == 'E') ? 1 : 0));
if (gen < nsig) {
nsig = gen;
}
if (nsig > 0) {
char drop;
char drop = (nsig < gen && ptr[nsig] > '4') ? '9' : '0';
int n2;
if (nsig < gen && ptr[nsig] > '4') {
drop = '9';
} else {
drop = '0';
}
for (n2 = nsig; ptr[--n2] == drop;) {
nsig--;
}

View file

@ -11,7 +11,7 @@
#define ATOI(i, a) \
for (i = 0; isdigit(*a); a++) \
if (i < 999) \
i = *a + i * 10 - '0';
i = i * 10 + *a - '0';
#define PUT(fmt, _size) \
if (_size > 0) { \
@ -93,11 +93,7 @@ int _Printf(PrintCallback pfn, void* arg, const char* fmt, va_list ap) {
}
}
if (strchr("hlL", *s) != NULL) {
x.qual = *s++;
} else {
x.qual = '\0';
}
x.qual = (strchr("hlL", *s) != NULL) ? *s++ : '\0';
if (x.qual == 'l' && *s == 'l') {
x.qual = 'L';
@ -126,7 +122,7 @@ static void _Putfld(_Pft* px, va_list* pap, char code, char* ac) {
switch (code) {
case 'c':
ac[px->n0++] = va_arg(*pap, unsigned int);
ac[px->n0++] = va_arg(*pap, int);
break;
case 'd':