Make this buildable on SunOS
Some checks failed
CMake / ubuntu-latest - shared=OFF, pthread=OFF, posix=OFF (push) Failing after 16s
CMake / ubuntu-latest - shared=ON, pthread=OFF, posix=OFF (push) Failing after 19s
CMake / ubuntu-latest - shared=OFF, pthread=OFF, posix=ON (push) Failing after 20s
CMake / ubuntu-latest - shared=ON, pthread=OFF, posix=ON (push) Failing after 17s
CMake / ubuntu-latest - shared=OFF, pthread=ON, posix=ON (push) Failing after 13s
CMake / ubuntu-latest - shared=ON, pthread=ON, posix=ON (push) Failing after 11s

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-08-07 00:23:46 +03:00
parent da1725982c
commit b1e03148b7
2 changed files with 63 additions and 39 deletions

View File

@@ -26,9 +26,6 @@
# define DCFG_UTF8_SUPPORT 1
#endif
#include <inttypes.h>
#include <stdio.h>
#include "meta.h"
#if DCFG_UTF8_SUPPORT
@@ -37,10 +34,6 @@
#include "vendor/vec.h"
#if DCFG_POSIX_SUPPORT
# ifdef __sun
// FIXME: Fix this stupid shit!
# error "realpath() is dumb and stupid on sun. sorry not sorry."
# endif
# define _POSIX_C_SOURCE 200809L
#else
# ifdef _POSIX_C_SOURCE
@@ -68,18 +61,21 @@ typedef struct {
# define PTHREAD_MUTEX_RECURSIVE_NP 0
# endif
static void pthread_mutex_init(pthread_mutex_t *, void *) { }
static void pthread_mutex_destroy(pthread_mutex_t *) { }
static void pthread_mutex_lock(pthread_mutex_t *) { }
static void pthread_mutex_unlock(pthread_mutex_t *) { }
pthread_mutexattr_init(pthread_mutexattr_t *);
static void pthread_mutexattr_settype(pthread_mutexattr_t *, int) { }
static void pthread_mutex_init(pthread_mutex_t *m, void *data) { }
static void pthread_mutex_destroy(pthread_mutex_t *m) { }
static void pthread_mutex_lock(pthread_mutex_t *m) { }
static void pthread_mutex_unlock(pthread_mutex_t *m) { }
void pthread_mutexattr_init(pthread_mutexattr_t *attr);
static void pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { }
#endif
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -387,7 +383,10 @@ struct dcfg_Instance {
static void *alloc(size_t size) { return calloc(1, size); }
#if DCFG_POSIX_SUPPORT
static char *realpath_(char const *s) { return realpath(s, NULL); }
static char *realpath_(char const *s) {
char buf[PATH_MAX];
return strdup(realpath(s, buf));
}
void *fopen_(char const *f, char const *a) { return fopen(f, a); }
int fseek_(void *f, size_t p, int o) { return fseek(f, p, o); }
long ftell_(void *f) { return ftell(f); }
@@ -2052,6 +2051,8 @@ bool dcfg_Value_evaluate_toplevel(dcfg_Value *top, dcfg_Value **out_value,
lib->type = dcfg_ValueType_Object;
lib->v.o.entryv = vector_create();
if (!lib->v.o.entryv) {
strcpy(
top->instance->last_error, "Failed to allocate standard library");
inst->free(lib);
return false;
}
@@ -2059,6 +2060,7 @@ bool dcfg_Value_evaluate_toplevel(dcfg_Value *top, dcfg_Value **out_value,
for (size_t i = 0; i < function_count; ++i) {
Value *fn = inst->alloc(sizeof *fn);
if (!fn) {
strcpy(top->instance->last_error, "Failed to allocate function");
dcfg_destroy(lib);
return false;
}