Skip to content

Commit acaf284

Browse files
committed
Win32:
Guard some fdlibm.h defines to avoid warnings on Win32. Make sure the msvc makefile suite builds a UNICODE VM (why doesn't the cygwin makefile suite do the same?!?!?). Don't add ".dll" to the end of module names that already have ".dll" added.
1 parent 6d13e91 commit acaf284

File tree

4 files changed

+42
-30
lines changed

4 files changed

+42
-30
lines changed

build.win32x86/common/Makefile.msvc.tools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ NOBUILTIN:=-D_MT
6262
MACHINE:=x86
6363

6464
DEFS:= $(COGDEFS) $(MEMACCESS) $(WINVER) \
65-
-DWIN32=1 -DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
65+
-DWIN32=1 -DUNICODE=1 -DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
6666
$(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET)
6767

6868
#############################################################################

build.win64x64/common/Makefile.msvc.tools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ NOBUILTIN:=-D_MT
7070
MACHINE:=x64
7171

7272
DEFS:= -D$(VM)VM=1 $(COGDEFS) $(MEMACCESS) $(WINVER) \
73-
-DWIN32=1 -DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
73+
-DWIN32=1 -DUNICODE=1 -DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
7474
$(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET)
7575

7676
#############################################################################

platforms/Cross/third-party/fdlibm/fdlibm.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ struct exception {
8181

8282
#define X_TLOSS 1.41484755040568800000e+16
8383

84-
#define DOMAIN 1
85-
#define SING 2
86-
#define OVERFLOW 3
87-
#define UNDERFLOW 4
88-
#define TLOSS 5
89-
#define PLOSS 6
84+
#if !defined(DOMAIN)
85+
# define DOMAIN 1
86+
# define SING 2
87+
# define OVERFLOW 3
88+
# define UNDERFLOW 4
89+
# define TLOSS 5
90+
# define PLOSS 6
91+
#endif
9092

9193
/*
9294
* ANSI/POSIX

platforms/win32/vm/sqWin32ExternalPrims.c

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
* 1) Currently, we're looking for DLLs named either sample.dll or sample32.dll
1212
*
1313
*****************************************************************************/
14+
1415
#include <Windows.h>
1516
#include <stdio.h>
1617
#include <assert.h>
1718
#include "sq.h"
1819

19-
HANDLE tryLoading(TCHAR *prefix, TCHAR *baseName, TCHAR *postfix)
20+
static HANDLE
21+
tryLoading(TCHAR *prefix, TCHAR *baseName, TCHAR *postfix)
2022
{
2123
TCHAR libName[300];
2224
HANDLE h;
@@ -34,33 +36,42 @@ HANDLE tryLoading(TCHAR *prefix, TCHAR *baseName, TCHAR *postfix)
3436
return h;
3537
}
3638

37-
/* Return the module entry for the given module name */
38-
void *ioLoadModule(char *pluginName)
39+
/* Return the module entry for the given module name, or null if not found */
40+
void *
41+
ioLoadModule(char *pluginName)
3942
{
4043
HANDLE handle;
4144
TCHAR *name;
42-
45+
int nameLen = pluginName ? (int)strlen(pluginName) : 0;
46+
int endsInDLL = nameLen > 4 && !strcmp(pluginName + nameLen - 4, ".dll");
47+
4348
#ifdef UNICODE
4449
int len = MultiByteToWideChar(CP_UTF8, 0, pluginName, -1, NULL, 0);
45-
if (len <= 0) return 0; /* invalid UTF8 ? */
50+
if (len <= 0)
51+
return 0; /* invalid UTF8 ? */
4652
name = alloca(len*sizeof(WCHAR));
47-
if (MultiByteToWideChar(CP_UTF8, 0, pluginName, -1, name, len) == 0) return 0;
53+
if (MultiByteToWideChar(CP_UTF8, 0, pluginName, -1, name, len) == 0)
54+
return 0;
4855
#else
4956
name = pluginName;
5057
#endif
5158

52-
handle = tryLoading(TEXT(""),name,TEXT(""));
53-
if(handle) return handle;
54-
handle = tryLoading(TEXT(""),name,TEXT(".dll"));
55-
if(handle) return handle;
56-
handle = tryLoading(TEXT(""),name,TEXT("32.dll"));
57-
if(handle) return handle;
58-
handle = tryLoading(imagePath,name,TEXT(""));
59-
if(handle) return handle;
60-
handle = tryLoading(imagePath,name,TEXT(".dll"));
61-
if(handle) return handle;
62-
handle = tryLoading(imagePath,name,TEXT("32.dll"));
63-
if(handle) return handle;
59+
if ((handle = tryLoading(TEXT(""),name,TEXT(""))))
60+
return handle;
61+
if (!endsInDLL) {
62+
if ((handle = tryLoading(TEXT(""),name,TEXT(".dll"))))
63+
return handle;
64+
if ((handle = tryLoading(TEXT(""),name,TEXT("32.dll"))))
65+
return handle;
66+
}
67+
if ((handle = tryLoading(imagePath,name,TEXT(""))))
68+
return handle;
69+
if (!endsInDLL) {
70+
if ((handle = tryLoading(imagePath,name,TEXT(".dll"))))
71+
return handle;
72+
if ((handle = tryLoading(imagePath,name,TEXT("32.dll"))))
73+
return handle;
74+
}
6475
return 0;
6576
}
6677

@@ -94,7 +105,6 @@ ioFindExternalFunctionIn(char *lookupName, void *moduleHandle)
94105
}
95106
#endif /* SPURVM */
96107

97-
sqInt ioFreeModule(void *moduleHandle)
98-
{
99-
return FreeLibrary((HANDLE) moduleHandle);
100-
}
108+
sqInt
109+
ioFreeModule(void *moduleHandle)
110+
{ return FreeLibrary((HANDLE) moduleHandle); }

0 commit comments

Comments
 (0)