Merge pull request #1392 from bytecodealliance/main

Merge main into dev/socket
This commit is contained in:
Wenyong Huang
2022-08-20 12:31:10 +08:00
committed by GitHub
209 changed files with 26189 additions and 1212 deletions

View File

@ -50,8 +50,9 @@ typedef pthread_t korp_thread;
typedef pthread_t korp_tid;
typedef pthread_mutex_t korp_mutex;
typedef pthread_cond_t korp_cond;
typedef unsigned int korp_sem;
typedef void (*os_print_function_t)(const char *message);
typedef int (*os_print_function_t)(const char *message);
void
os_set_print_function(os_print_function_t pf);

View File

@ -7,8 +7,6 @@
#include "platform_api_extension.h"
#include "sgx_rsrv_mem_mngr.h"
#define FIXED_BUFFER_SIZE (1 << 9)
static os_print_function_t print_function = NULL;
int
@ -57,31 +55,37 @@ os_set_print_function(os_print_function_t pf)
print_function = pf;
}
#define FIXED_BUFFER_SIZE 4096
int
os_printf(const char *message, ...)
{
int bytes_written = 0;
if (print_function != NULL) {
char msg[FIXED_BUFFER_SIZE] = { '\0' };
va_list ap;
va_start(ap, message);
vsnprintf(msg, FIXED_BUFFER_SIZE, message, ap);
va_end(ap);
print_function(msg);
bytes_written += print_function(msg);
}
return 0;
return bytes_written;
}
int
os_vprintf(const char *format, va_list arg)
{
int bytes_written = 0;
if (print_function != NULL) {
char msg[FIXED_BUFFER_SIZE] = { '\0' };
vsnprintf(msg, FIXED_BUFFER_SIZE, format, arg);
print_function(msg);
bytes_written += print_function(msg);
}
return 0;
return bytes_written;
}
char *