diff options
author | pommicket <pommicket@gmail.com> | 2023-01-02 14:22:10 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-01-02 14:22:10 -0500 |
commit | 9278c63caff34a8c264416705a5658ee0b5210ef (patch) | |
tree | f3d3e6f8cc077e33348cc0a1ea7c1938848403d4 /lsp.c | |
parent | f791aa01fad7e81223808584212c6a1a4c80ca07 (diff) |
fix tcc build problems
Diffstat (limited to 'lsp.c')
-rw-r--r-- | lsp.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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 |