mirror of
https://github.com/wiiu-env/launchiine.git
synced 2024-11-22 01:39:18 +01:00
Move the UDP logger to C++ and use a std::recursive_mutex instead of a basic volatile int.
This commit is contained in:
parent
c71d820202
commit
052a6e8cb6
@ -1,3 +1,5 @@
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -13,6 +15,7 @@
|
||||
static int32_t log_socket __attribute__((section(".data")))= -1;
|
||||
static struct sockaddr_in connect_addr __attribute__((section(".data")));
|
||||
static volatile int32_t log_lock __attribute__((section(".data"))) = 0;
|
||||
static std::recursive_mutex _lock;
|
||||
|
||||
void log_init_() {
|
||||
int32_t broadcastEnable = 1;
|
||||
@ -34,9 +37,7 @@ void log_print_(const char *str) {
|
||||
return;
|
||||
}
|
||||
|
||||
while(log_lock)
|
||||
OSSleepTicks(OSMicrosecondsToTicks(1000));
|
||||
log_lock = 1;
|
||||
_lock.lock();
|
||||
|
||||
int32_t len = strlen(str);
|
||||
int32_t ret;
|
||||
@ -50,7 +51,7 @@ void log_print_(const char *str) {
|
||||
str += ret;
|
||||
}
|
||||
|
||||
log_lock = 0;
|
||||
_lock.unlock();
|
||||
}
|
||||
|
||||
void OSFatal_printf(const char *format, ...) {
|
Loading…
Reference in New Issue
Block a user