Address build errors on llvm-mingw to build bqn.exe with no SH, FFI, or repl support
This commit is contained in:
parent
fef8cfaef0
commit
815de4fd97
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,6 +5,8 @@
|
||||
*.wasm
|
||||
*.cwasm
|
||||
libcbqn.so
|
||||
*.exe
|
||||
*.dll
|
||||
|
||||
# build system things
|
||||
/build/obj/
|
||||
|
||||
@ -9,7 +9,11 @@
|
||||
#include "../nfns.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <poll.h>
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
#include <poll.h>
|
||||
#else
|
||||
#include "../windows/getline.c"
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
static bool eqStr(B w, u32* x) {
|
||||
|
||||
@ -899,7 +899,11 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
char* ln = NULL;
|
||||
size_t gl = 0;
|
||||
i64 read = getline(&ln, &gl, stdin);
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
i64 read = 0;
|
||||
#else
|
||||
i64 read = getline(&ln, &gl, stdin);
|
||||
#endif
|
||||
if (read<=0 || ln[0]==0) { if(!silentREPL) putchar('\n'); break; }
|
||||
if (ln[read-1]==10) ln[--read] = 0;
|
||||
cbqn_runLine(ln, read);
|
||||
|
||||
@ -6,6 +6,10 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include "../windows/realpath.c"
|
||||
#endif
|
||||
|
||||
|
||||
FILE* file_open(B path, char* desc, char* mode) { // doesn't consume
|
||||
char* p = toCStr(path);
|
||||
@ -318,7 +322,11 @@ void mmap_init() { }
|
||||
|
||||
bool dir_create(B path) {
|
||||
char* p = toCStr(path);
|
||||
bool r = mkdir(p, S_IRWXU) == 0;
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
bool r = 1;
|
||||
#else
|
||||
bool r = mkdir(p, S_IRWXU) == 0;
|
||||
#endif
|
||||
freeCStr(p);
|
||||
return r;
|
||||
}
|
||||
|
||||
4
src/vm.c
4
src/vm.c
@ -6,6 +6,10 @@
|
||||
#include "utils/interrupt.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#include "windows/sysconf.c"
|
||||
#endif
|
||||
|
||||
#ifndef UNWIND_COMPILER // whether to hide stackframes of the compiler in compiling errors
|
||||
#define UNWIND_COMPILER 1
|
||||
#endif
|
||||
|
||||
41
src/windows/getline.c
Normal file
41
src/windows/getline.c
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
#include "getline.h"
|
||||
|
||||
ssize_t getline (char **lptr, size_t *n, FILE *fp) {
|
||||
wchar_t buf[MAX_LINE_LENGTH/3] = {0};
|
||||
DWORD bytes;
|
||||
DWORD chars, read_chars;
|
||||
|
||||
int convertResult;
|
||||
char *m;
|
||||
|
||||
bytes = MAX_LINE_LENGTH;
|
||||
chars = bytes/3;
|
||||
|
||||
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
|
||||
if (!ReadConsoleW(hIn, &buf, chars, &read_chars, NULL)) {
|
||||
fprintf(stderr, "Failed to read console input: %d", GetLastError());
|
||||
goto error;
|
||||
}
|
||||
|
||||
convertResult = WideCharToMultiByte(CP_ACP, 0, buf, -1, NULL, 0, NULL, NULL);
|
||||
if (convertResult == 0) {
|
||||
fprintf(stderr, "Failed to get MultiByte length: %d", GetLastError());
|
||||
goto error;
|
||||
}
|
||||
|
||||
m = *lptr = (char*) calloc(convertResult, sizeof(char));
|
||||
|
||||
if (WideCharToMultiByte(CP_ACP, 0, buf, -1, m, convertResult, NULL, NULL) == 0 ) {
|
||||
fprintf(stderr, "Failed to convert wide characters: %d", GetLastError());
|
||||
free(m);
|
||||
goto error;
|
||||
}
|
||||
|
||||
return convertResult;
|
||||
|
||||
error:
|
||||
CloseHandle(hIn);
|
||||
return -1;
|
||||
}
|
||||
11
src/windows/getline.h
Normal file
11
src/windows/getline.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef GETLINE_H
|
||||
#define GETLINE_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_LINE_LENGTH 8192
|
||||
|
||||
//ssize_t processinput (char **lptr, size_t *n, FILE *hIn);
|
||||
|
||||
#endif /* GETLINE_H */
|
||||
9
src/windows/realpath.c
Normal file
9
src/windows/realpath.c
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#include "realpath.h"
|
||||
|
||||
char* realpath (const char *__restrict path, char *__restrict resolved_path) {
|
||||
unsigned long len=strlen(path)+1;
|
||||
void* r = malloc(len);
|
||||
memcpy(r, path, len);
|
||||
return r;
|
||||
}
|
||||
9
src/windows/realpath.h
Normal file
9
src/windows/realpath.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef REALPATH_H
|
||||
#define REALPATH_H
|
||||
|
||||
#define S_ISLNK(m) (0)
|
||||
#define S_ISSOCK(m) (0)
|
||||
|
||||
char* realpath (const char *__restrict path, char *__restrict resolved_path);
|
||||
|
||||
#endif /* REALPATH_H */
|
||||
6
src/windows/sysconf.c
Normal file
6
src/windows/sysconf.c
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
#include "sysconf.h"
|
||||
|
||||
long int sysconf (int in) {
|
||||
return 1L;
|
||||
}
|
||||
8
src/windows/sysconf.h
Normal file
8
src/windows/sysconf.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef SYSCONF_H
|
||||
#define SYSCONF_H
|
||||
|
||||
#define _SC_PAGESIZE 8
|
||||
|
||||
long int sysconf (int in);
|
||||
|
||||
#endif /* SYSCONF_H */
|
||||
Loading…
Reference in New Issue
Block a user