This change maks using some functions way easier.
All test cases are included in the tests directory.
When test are run p_tests is used as a platform.
+
+## Exceptions
+
+Some C features might be hard to wrap.
+These are allowed even in core code.
+
+- stdarg.h: for va_list va_start and va_end
#include "p_pc/u_assert.c"
#include "p_posix/p_init.c"
#include "p_posix/p_getopt.c"
-#include "p_pc/u_log.c"
#else
#error "No platform is provided"
#endif
+++ /dev/null
-#ifndef P_PC_H__
-#define P_PC_H__
-
-int u_vfprintf(U_FILE* stream, const char *fmt, void *args);
-
-#endif
+++ /dev/null
-#include "../u_log.h"
-#include "../u_stdio.h"
-#include "p_pc.h"
-#include <stdarg.h>
-#include <stdio.h>
-
-int u_log(enum u_log_levels level, const char *fmt, ...) {
- va_list args;
- int res = 0;
-
- if (!u_log_should_log(level)) {
- return 0;
- }
- va_start(args, fmt);
- res = u_fprintf(u_stderr, fmt, args);
- va_end(args);
- return res;
-}
void *u_stderr;
-int u_vfprintf(U_FILE* stream, const char *fmt, void *args) {
+int u_vfprintf(U_FILE* stream, const char *fmt, va_list args) {
return vfprintf(stream, fmt, args);
}
#include "u_log.h"
+#include <stdarg.h>
lrts_bool u_log_should_log(enum u_log_levels level) {
/* TODO: implement log levels */
return LRTS_TRUE;
}
+
+int u_log(enum u_log_levels level, const char *fmt, ...) {
+ va_list args;
+ int res = 0;
+
+ if (!u_log_should_log(level)) {
+ return 0;
+ }
+ va_start(args, fmt);
+ res = u_fprintf(u_stderr, fmt, args);
+ va_end(args);
+ return res;
+}
#ifndef U_STDIO_H__
#define U_STDIO_H__
+#include <stdarg.h>
#define U_FILE void
extern void *u_stdout;
extern void *u_stderr;
+int u_vfprintf(U_FILE* stream, const char *fmt, va_list args);
int u_fprintf(U_FILE* stream, const char *fmt, ...);
int u_fputs(const char *s, U_FILE* stream);