summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-02 14:22:10 -0500
committerpommicket <pommicket@gmail.com>2023-01-02 14:22:10 -0500
commit9278c63caff34a8c264416705a5658ee0b5210ef (patch)
treef3d3e6f8cc077e33348cc0a1ea7c1938848403d4
parentf791aa01fad7e81223808584212c6a1a4c80ca07 (diff)
fix tcc build problems
-rw-r--r--lsp.c16
-rw-r--r--lsp.h7
-rw-r--r--stb_image.c3
3 files changed, 21 insertions, 5 deletions
diff --git a/lsp.c b/lsp.c
index 2fea94b..1bee23f 100644
--- a/lsp.c
+++ b/lsp.c
@@ -4,11 +4,18 @@
const char *language_to_str(Language language);
+static LSPMutex id_mutex;
+
// it's nice to have request IDs be totally unique, including across LSP servers.
static LSPRequestID get_request_id(void) {
- static _Atomic LSPRequestID last_request_id;
// it's important that this never returns 0, since that's reserved for "no ID"
- return ++last_request_id;
+ static LSPRequestID last_request_id;
+ LSPRequestID id = 0;
+ assert(id_mutex);
+ SDL_LockMutex(id_mutex);
+ id = ++last_request_id;
+ SDL_UnlockMutex(id_mutex);
+ return id;
}
bool lsp_get_error(LSP *lsp, char *error, size_t error_size, bool clear) {
@@ -429,7 +436,10 @@ LSP *lsp_create(const char *root_dir, Language language, const char *analyzer_co
LSP *lsp = calloc(1, sizeof *lsp);
if (!lsp) return NULL;
- static _Atomic LSPID curr_id = 1;
+ if (!id_mutex)
+ id_mutex = SDL_CreateMutex();
+
+ static LSPID curr_id = 1;
lsp->id = curr_id++;
#if DEBUG
diff --git a/lsp.h b/lsp.h
index 5c35113..8218cdc 100644
--- a/lsp.h
+++ b/lsp.h
@@ -1,3 +1,6 @@
+// functions for dealing with LSP (Language Server Protocol) servers.
+// don't assume any of the public functions defined here are thread-safe.
+
#ifndef LSP_H_
#define LSP_H_
@@ -515,9 +518,9 @@ typedef struct LSP {
// this also lets us re-send requests if that's ever necessary.
LSPRequest *requests_sent;
// has the response to the initialize request been sent?
- // thread-safety: this is atomic. it starts out false, and only gets set to true once
+ // thread-safety: this starts out false, and only gets set to true once
// (when the initialize response is received)
- _Atomic bool initialized;
+ bool initialized;
// thread-safety: only set once in lsp_create.
Language language;
LSPThread communication_thread;
diff --git a/stb_image.c b/stb_image.c
index 2fa181b..ae13415 100644
--- a/stb_image.c
+++ b/stb_image.c
@@ -1,4 +1,7 @@
// used for debug build to speed things up
// just exports everything in stb_image.h
#define STB_IMAGE_IMPLEMENTATION
+#if __TINYC__
+#define STBI_NO_SIMD
+#endif
#include "lib/stb_image.h"