summaryrefslogtreecommitdiffstats
path: root/src/misc/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc/util')
-rw-r--r--src/misc/util/abc_global.h4
-rw-r--r--src/misc/util/utilFile.c28
-rw-r--r--src/misc/util/utilSignal.c4
3 files changed, 34 insertions, 2 deletions
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h
index d1a9b4d3..2217bb87 100644
--- a/src/misc/util/abc_global.h
+++ b/src/misc/util/abc_global.h
@@ -94,8 +94,6 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-ABC_NAMESPACE_HEADER_START
-
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
@@ -143,6 +141,8 @@ ABC_NAMESPACE_HEADER_START
#endif
+ABC_NAMESPACE_HEADER_START
+
/**
* Pointer difference type; replacement for ptrdiff_t.
* This is a signed integral type that is the same size as a pointer.
diff --git a/src/misc/util/utilFile.c b/src/misc/util/utilFile.c
index 4bb2f4c6..f64d71c2 100644
--- a/src/misc/util/utilFile.c
+++ b/src/misc/util/utilFile.c
@@ -25,6 +25,23 @@
#include <fcntl.h>
#include <sys/stat.h>
+// Handle legacy macros
+#if !defined(S_IREAD)
+#if defined(S_IRUSR)
+#define S_IREAD S_IRUSR
+#else
+#error S_IREAD is undefined
+#endif
+#endif
+
+#if !defined(S_IWRITE)
+#if defined(S_IWUSR)
+#define S_IWRITE S_IWUSR
+#else
+#error S_IWRITE is undefined
+#endif
+#endif
+
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <windows.h>
#include <process.h>
@@ -102,6 +119,17 @@ int tmpFile(const char* prefix, const char* suffix, char** out_name)
}
assert(0); // -- could not open temporary file
return 0;
+#elif defined(__wasm)
+ static int seq = 0; // no risk of collision since we're in a sandbox
+ int fd;
+ *out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 9);
+ sprintf(*out_name, "%s%08d%s", prefix, seq++, suffix);
+ fd = open(*out_name, O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE);
+ if (fd == -1){
+ free(*out_name);
+ *out_name = NULL;
+ }
+ return fd;
#else
int fd;
*out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 7);
diff --git a/src/misc/util/utilSignal.c b/src/misc/util/utilSignal.c
index 03af81d1..137ff54b 100644
--- a/src/misc/util/utilSignal.c
+++ b/src/misc/util/utilSignal.c
@@ -43,7 +43,11 @@ ABC_NAMESPACE_IMPL_START
int Util_SignalSystem(const char* cmd)
{
+#if defined(__wasm)
+ return -1;
+#else
return system(cmd);
+#endif
}
int tmpFile(const char* prefix, const char* suffix, char** out_name);