Skip to content

Commit 2998cfc

Browse files
committed
Add support for win x86-32
1 parent a02f27e commit 2998cfc

10 files changed

Lines changed: 684 additions & 56 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
# Libraries
88
*.lib
99
*.la
10-
*.a
1110
*.lo
11+
*.a
12+
!libs/*/libffi.a
1213

1314
# Shared objects (inc. Windows DLLs)
1415
*.dll

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CC = gcc
22
RM = rm
33

4-
CFLAGS = -Wall -g -Wextra -m64 -fpic
4+
CFLAGS = -Wall -Wextra -fpic -O2 -fno-strict-aliasing
55

66
SYS := $(shell gcc -dumpmachine)
77
ifneq (, $(findstring linux, $(SYS)))
@@ -15,11 +15,15 @@ ifneq (, $(findstring linux, $(SYS)))
1515
endif
1616

1717
else ifneq (, $(findstring mingw, $(SYS)))
18-
18+
ifneq (, $(findstring x86_64, $(SYS)))
19+
PLATFORM = x86-64
20+
else
21+
PLATFORM = x86-32
22+
endif
1923
SUFFIX = dll
2024
LDFLAGS = -mdll
21-
LIBS = -L./libs -lffi
22-
CFLAGS += -I./libs/include
25+
LIBS = -L./libs/$(PLATFORM)/ -lffi
26+
CFLAGS += -I./libs/$(PLATFORM)/include/
2327
ifndef GLOBALS_HOME
2428
GLOBALS_HOME = C:/InterSystems/Cache
2529
endif

cna.c

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,35 @@
2828
#define FIND_ENTRY(HANDLE, NAME) dlsym(HANDLE, NAME)
2929
#endif /* _WIN32 */
3030

31-
void
31+
inline void
3232
logger(const char *format, ...)
3333
{
34-
va_list args;
35-
va_start(args, format);
36-
37-
#ifdef _WIN32
38-
char path[MAX_PATH];
39-
HMODULE hm;
40-
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR) &logger, &hm);
41-
GetModuleFileNameA(hm, path, sizeof(path));
42-
strcpy(strrchr(path, '\\') + 1, "log.txt");
43-
44-
FILE *fd = fopen(path, "a");
45-
if (!fd) {
46-
return;
47-
}
48-
time_t now;
49-
time(&now);
50-
fprintf(fd, "%s\t", ctime(&now));
51-
vfprintf(fd, format, args);
52-
fclose(fd);
53-
#else
54-
vprintf(format, args);
55-
#endif /* _WIN32 */
56-
57-
va_end(args);
34+
#ifdef DEBUG
35+
va_list args;
36+
va_start(args, format);
37+
38+
#ifdef _WIN32
39+
char path[MAX_PATH];
40+
HMODULE hm;
41+
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR) &logger, &hm);
42+
GetModuleFileNameA(hm, path, sizeof(path));
43+
strcpy(strrchr(path, '\\') + 1, "log.txt");
44+
45+
FILE *fd = fopen(path, "a");
46+
if (!fd) {
47+
return;
48+
}
49+
time_t now;
50+
time(&now);
51+
fprintf(fd, "%s\t", ctime(&now));
52+
vfprintf(fd, format, args);
53+
fclose(fd);
54+
#else
55+
vprintf(format, args);
56+
#endif /* _WIN32 */
57+
58+
va_end(args);
59+
#endif /* DEBUG */
5860
}
5961

6062

@@ -302,7 +304,7 @@ call_function(ZARRAYP libID, const char *funcname, ZARRAYP argtypes, ZARRAYP arg
302304
void *ffi_values[maxargs];
303305

304306
int i, j;
305-
size_t fullsize = 0, size;
307+
size_t fullsize = 0, size = 0;
306308
storage mem;
307309
init_storage(&mem);
308310

0 commit comments

Comments
 (0)