mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
C: fix minor compiler warnings
This commit is contained in:
parent
4fa3db38a0
commit
f4f80a88ea
|
@ -211,15 +211,19 @@ int64_t teavm_currentTimeNano() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define gmtime_r(a, b) gmtime_s(a, b)
|
#undef gmtime_r
|
||||||
#define localtime_r(a, b) localtime_s(a, b)
|
#undef localtime_r
|
||||||
|
#define gmtime_r(a, b) gmtime_s(b, a)
|
||||||
|
#define localtime_r(a, b) localtime_s(b, a)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t teavm_timeZoneOffset() {
|
int32_t teavm_timeZoneOffset() {
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
time_t local = mktime(localtime_r(&t, &tm));
|
localtime_r(&t, &tm);
|
||||||
time_t utc = mktime(gmtime_r(&t, &tm));
|
time_t local = mktime(&tm);
|
||||||
|
gmtime_r(&t, &tm);
|
||||||
|
time_t utc = mktime(&tm);
|
||||||
return (int32_t) (difftime(utc, local) / 60);
|
return (int32_t) (difftime(utc, local) / 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,15 +365,14 @@ char* teavm_stringToC(void* obj) {
|
||||||
size_t sz = teavm_mbSize(javaChars, charArray->size);
|
size_t sz = teavm_mbSize(javaChars, charArray->size);
|
||||||
char* result = malloc(sz + 1);
|
char* result = malloc(sz + 1);
|
||||||
|
|
||||||
int32_t j = 0;
|
|
||||||
char* dst = result;
|
char* dst = result;
|
||||||
mbstate_t state = {0};
|
mbstate_t state = {0};
|
||||||
for (int32_t i = 0; i < charArray->size; ++i) {
|
for (int32_t i = 0; i < charArray->size; ++i) {
|
||||||
size_t result = c16rtomb(dst, javaChars[i], &state);
|
size_t charResult = c16rtomb(dst, javaChars[i], &state);
|
||||||
if (result == (size_t) -1) {
|
if (charResult == (size_t) -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dst += result;
|
dst += charResult;
|
||||||
}
|
}
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
return result;
|
return result;
|
||||||
|
@ -449,7 +452,6 @@ char* teavm_char16ToMb(char16_t* javaChars, int32_t length) {
|
||||||
size_t sz = teavm_mbSize(javaChars, length);
|
size_t sz = teavm_mbSize(javaChars, length);
|
||||||
char* cchars = malloc(sz + 1);
|
char* cchars = malloc(sz + 1);
|
||||||
|
|
||||||
int32_t j = 0;
|
|
||||||
char* dst = cchars;
|
char* dst = cchars;
|
||||||
mbstate_t state = {0};
|
mbstate_t state = {0};
|
||||||
for (int32_t i = 0; i < length; ++i) {
|
for (int32_t i = 0; i < length; ++i) {
|
||||||
|
@ -548,7 +550,7 @@ TeaVM_StringList* teavm_appendString(TeaVM_StringList* list, char16_t* data, int
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TEAVM_WINDOWS_LOG
|
#ifndef TEAVM_WINDOWS_LOG
|
||||||
void teavm_logchar(char16_t c) {
|
void teavm_logchar(int32_t c) {
|
||||||
putwchar(c);
|
putwchar(c);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -178,7 +178,7 @@ static inline float teavm_getNaN() {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t size;
|
int32_t size;
|
||||||
void* data[0];
|
void* data[1];
|
||||||
} TeaVM_ResourceArray;
|
} TeaVM_ResourceArray;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -188,7 +188,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t size;
|
int32_t size;
|
||||||
TeaVM_ResourceMapEntry entries[0];
|
TeaVM_ResourceMapEntry entries[1];
|
||||||
} TeaVM_ResourceMap;
|
} TeaVM_ResourceMap;
|
||||||
|
|
||||||
extern int32_t teavm_hashCode(TeaVM_String*);
|
extern int32_t teavm_hashCode(TeaVM_String*);
|
||||||
|
@ -332,6 +332,7 @@ extern TeaVM_StringList* teavm_appendString(TeaVM_StringList*, char16_t*, int32_
|
||||||
|
|
||||||
extern int32_t teavm_file_homeDirectory(char16_t**);
|
extern int32_t teavm_file_homeDirectory(char16_t**);
|
||||||
extern int32_t teavm_file_workDirectory(char16_t**);
|
extern int32_t teavm_file_workDirectory(char16_t**);
|
||||||
|
extern int32_t teavm_file_tempDirectory(char16_t**);
|
||||||
extern int32_t teavm_file_isFile(char16_t*, int32_t);
|
extern int32_t teavm_file_isFile(char16_t*, int32_t);
|
||||||
extern int32_t teavm_file_isDir(char16_t*, int32_t);
|
extern int32_t teavm_file_isDir(char16_t*, int32_t);
|
||||||
extern int32_t teavm_file_canRead(char16_t*, int32_t);
|
extern int32_t teavm_file_canRead(char16_t*, int32_t);
|
||||||
|
@ -352,6 +353,7 @@ extern int32_t teavm_file_tell(int64_t);
|
||||||
extern int32_t teavm_file_read(int64_t, int8_t*, int32_t, int32_t);
|
extern int32_t teavm_file_read(int64_t, int8_t*, int32_t, int32_t);
|
||||||
extern int32_t teavm_file_write(int64_t, int8_t*, int32_t, int32_t);
|
extern int32_t teavm_file_write(int64_t, int8_t*, int32_t, int32_t);
|
||||||
extern int32_t teavm_file_isWindows();
|
extern int32_t teavm_file_isWindows();
|
||||||
|
extern int32_t teavm_file_canonicalize(char16_t*, int32_t, char16_t**);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
extern int64_t teavm_unixTimeOffset;
|
extern int64_t teavm_unixTimeOffset;
|
||||||
|
|
|
@ -100,7 +100,7 @@ TeaVM_String* teavm_registerString(TeaVM_String* str) {
|
||||||
if (teavm_stringHashtable[index] == NULL) {
|
if (teavm_stringHashtable[index] == NULL) {
|
||||||
if (teavm_stringHashtableFill >= teavm_stringHashtableThreshold) {
|
if (teavm_stringHashtableFill >= teavm_stringHashtableThreshold) {
|
||||||
teavm_rehashStrings();
|
teavm_rehashStrings();
|
||||||
int32_t index = (uint32_t) hash % teavm_stringHashtableSize;
|
index = (uint32_t) hash % teavm_stringHashtableSize;
|
||||||
}
|
}
|
||||||
teavm_stringHashtableFill++;
|
teavm_stringHashtableFill++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user