vm: Simplify strerror code.

db4
Doug Coleman 2014-07-05 18:58:24 -07:00
parent 451a621dad
commit 6244b925c7
5 changed files with 4 additions and 16 deletions

View File

@ -203,12 +203,9 @@ bool factor_vm::read_embedded_image_footer(FILE* file,
char *threadsafe_strerror(int errnum) {
char *buf = (char *) malloc(STRERROR_BUFFER_SIZE);
if(!buf) {
fatal_error("Out of memory in threadsafe_strerror", 0);
}
int ret = THREADSAFE_STRERROR(errnum, buf, STRERROR_BUFFER_SIZE);
if(ret != 0) {
std::cout << "Truncated output from THREADSAFE_STRERROR, error code:" << errnum << ", ret: " << ret << std::endl;
fatal_error("Out of memory in threadsafe_strerror, errno", errnum);
}
THREADSAFE_STRERROR(errnum, buf, STRERROR_BUFFER_SIZE);
return buf;
}

View File

@ -502,8 +502,4 @@ void abort() {
::abort();
}
int THREADSAFE_STRERROR(int errnum, char *buf, size_t buflen) {
return strerror_r(errnum, buf, buflen);
}
}

View File

@ -31,6 +31,7 @@ typedef char symbol_char;
#define OPEN_READ(path) fopen(path, "rb")
#define OPEN_WRITE(path) fopen(path, "wb")
#define THREADSAFE_STRERROR(errnum, buf, buflen) strerror_r(errnum, buf, buflen)
#define print_native_string(string) print_string(string)
@ -46,6 +47,4 @@ void move_file(const vm_char* path1, const vm_char* path2);
static inline void breakpoint() { __builtin_trap(); }
int THREADSAFE_STRERROR(int errnum, char *buf, size_t buflen);
}

View File

@ -373,8 +373,4 @@ void factor_vm::end_sampling_profiler_timer() {
void abort() { ::abort(); }
int THREADSAFE_STRERROR(int errnum, char *buf, size_t buflen) {
return strerror_s(buf, buflen, errnum);
}
}

View File

@ -66,6 +66,7 @@ typedef HANDLE THREADHANDLE;
#define OPEN_READ(path) _wfopen((path), L"rb")
#define OPEN_WRITE(path) _wfopen((path), L"wb")
#define THREADSAFE_STRERROR(errnum, buf, buflen) strerror_s(buf, buflen, errnum)
inline static void early_init() {}
uint64_t nano_count();
@ -94,5 +95,4 @@ inline static void breakpoint() { DebugBreak(); }
extern HANDLE boot_thread;
int THREADSAFE_STRERROR(int errnum, char *buf, size_t buflen);
}