Compare commits

...

2 Commits

Author SHA1 Message Date
Bananymous 14f1c1a358 LibC: Implement vsyslog 2026-03-23 19:13:38 +02:00
Bananymous 5be9bc64a2 ports/libxml2: Configure with -shared-libgcc
otherwise it doesn't seem to find libiconv due to __divdc3
2026-03-23 19:09:33 +02:00
3 changed files with 26 additions and 16 deletions

View File

@ -10,6 +10,7 @@ CONFIGURE_OPTIONS=(
)
configure() {
CFLAGS='-shared-libgcc' \
meson setup \
--reconfigure \
--cross-file "$MESON_CROSS_FILE" \

View File

@ -5,6 +5,8 @@
#include <sys/cdefs.h>
#include <stdarg.h>
__BEGIN_DECLS
#define LOG_PID 0x01
@ -47,6 +49,7 @@ void closelog(void);
void openlog(const char* ident, int logopt, int facility);
int setlogmask(int maskpri);
void syslog(int priority, const char* message, ...);
void vsyslog(int priority, const char* format, va_list ap);
__END_DECLS

View File

@ -1,4 +1,3 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
@ -17,24 +16,31 @@ void openlog(const char* ident, int option, int facility)
s_ident = ident;
}
void syslog(int priority, const char* format, ...)
{
(void)priority;
if (s_ident)
fprintf(s_log_file, "%s: ", s_ident);
va_list args;
va_start(args, format);
vfprintf(s_log_file, format, args);
va_end(args);
const size_t format_len = strlen(format);
if (format_len && format[format_len - 1] != '\n')
fputc('\n', s_log_file);
}
void closelog()
{
fclose(s_log_file);
s_log_file = nullptr;
s_ident = nullptr;
}
void syslog(int priority, const char* format, ...)
{
va_list args;
va_start(args, format);
vsyslog(priority, format, args);
va_end(args);
}
void vsyslog(int priority, const char* format, va_list ap)
{
(void)priority;
if (s_ident)
fprintf(s_log_file, "%s: ", s_ident);
vfprintf(s_log_file, format, ap);
const size_t format_len = strlen(format);
if (format_len && format[format_len - 1] != '\n')
fputc('\n', s_log_file);
}