Skip to content

Commit e444a91

Browse files
livecodefraserrunrevmark
authored andcommitted
[[ Win64 ]] Update engine to compile for win32 x86-64
This patch tweaks the engine code to compile for win32 x86-64. Mainly it uses intptr_t in the gentle related toolchain code rather than long, and DWORD_PTR / LONG_PTR appropriately in Win32 APIs. Additionally, it updates the build-libs.bat script to use v140 toolset (even if VS 15 is requested - this is because VS2017 does not have the same structure, and it only bumps the toolset version by 1, not 10 - i.e. v141 and not v150). Finally, it modifies fetch-libraries.sh to ensure that the win32 prebuilts have the correct names. The system expects the toolset to be v141, and for 64-bit it expects the arch to be x64.
1 parent d06949e commit e444a91

38 files changed

+536
-506
lines changed

config/win32.gypi

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
'silence_warnings': 0,
2626
},
2727

28+
'include_dirs':
29+
[
30+
'$(foo)C:/WinDDK/7600.16385.1/inc/atl71',
31+
'$(foo)C:/WinDDK/7600.16385.1/inc/mfc42',
32+
],
33+
34+
'library_dirs':
35+
[
36+
'$(foo)C:/WinDDK/7600.16385.1/lib/ATL/i386',
37+
'$(foo)C:/WinDDK/7600.16385.1/lib/MFC/i386',
38+
],
39+
2840
# Don't assume a Cygwin environment when invoking actions
2941
'msvs_cygwin_shell': 0,
3042

@@ -33,6 +45,18 @@
3345
"msvs_target_platform_version" : "10.0.14393.0",
3446
"msbuild_toolset" : "v141",
3547

48+
# WIN64-CHECK
49+
'conditions':
50+
[
51+
[
52+
'target_arch == "x64"',
53+
{
54+
'msvs_target_platform': 'x64',
55+
'msvs_configuration_platform': 'x64',
56+
},
57+
],
58+
],
59+
3660
'configurations':
3761
{
3862
'Debug':
@@ -125,8 +149,8 @@
125149
'_CRT_SECURE_NO_DEPRECATE',
126150
'_CRT_DISABLE_PERFCRIT_LOCKS',
127151
'__LITTLE_ENDIAN__',
128-
'WINVER=0x0501', # Windows XP
129-
'_WIN32_WINNT=0x0501', # Windows XP
152+
'WINVER=0x0601', # Windows 7
153+
'_WIN32_WINNT=0x0601', # Windows 7
130154
],
131155

132156
'target_conditions':
@@ -185,7 +209,7 @@
185209
'ExceptionHandling': '0',
186210
'BufferSecurityCheck': 'false',
187211
'RuntimeTypeInfo': 'false',
188-
'Detect64BitPortabilityProblems': 'false',
212+
'Detect64BitPortabilityProblems': 'true',
189213

190214
# Silence abundent warnings to speed up build:
191215
# 4577: exception handling mode mismatch

configure.bat

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ IF %TARGET_ARCH%==x86_64 (
2222
SET MSVC_ARCH=%TARGET_ARCH%
2323
)
2424

25+
REM The LiveCode name for x86_64 is x86_64
26+
IF %MSVC_ARCH%==x64 (
27+
SET LC_ARCH=x86_64
28+
) ELSE (
29+
SET LC_ARCH=x86
30+
)
31+
2532
REM Note: to test whether a directory exists in batch script, you need to check
2633
REM whether a file within that directory exists. Easiest way to do this is to
2734
REM add the "*" wildcard after the directory
@@ -54,7 +61,7 @@ REM Pause so any warnings can be seen
5461
IF %warnings% NEQ 0 PAUSE
5562

5663
REM Run the configure step
57-
%python% config.py --platform win-x86 -Dtarget_arch=%MSVC_ARCH% %extra_options% %gypfile%
64+
%python% config.py --platform win-%LC_ARCH% -Dtarget_arch=%MSVC_ARCH% %extra_options% %gypfile%
5865
PAUSE
5966

6067
REM Pause if there was an error so that the user gets a chance to see it

engine/rsrc/w32-manifest-template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
type="win32"
88
name="Microsoft.Windows.Common-Controls"
99
version="6.0.0.0"
10-
processorArchitecture="X86"
10+
processorArchitecture="*"
1111
publicKeyToken="6595b64144ccf1df"
1212
language="*"
1313
/>

engine/src/combiners.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -301,32 +301,9 @@ static INLINE uint16_t long_scaled_divide(uint32_t n, uint8_t s, uint16_t d)
301301
return d != 0 ? uint16_t((n * s) / d) : 0;
302302
}
303303

304-
extern uint16_t g_sqrt_table[1024];
305304
static INLINE uint8_t sqrt(uint16_t n)
306305
{
307-
#ifdef __VISUALC__
308-
__asm
309-
{
310-
xor ebx, ebx
311-
mov bx, n
312-
mov dx, 11
313-
bsr cx, bx
314-
sub cx, 9
315-
jle less_than_9_bits
316-
shr cx, 1
317-
adc cx, 0
318-
sub dx, cx
319-
shl cx, 1
320-
shr bx, cl
321-
less_than_9_bits:
322-
xor ax, ax
323-
mov ax, g_sqrt_table[ebx*2]
324-
mov cx, dx
325-
shr ax, cl
326-
}
327-
#else
328306
return 1;
329-
#endif
330307
}
331308

332309
template<typename Type> INLINE Type fastmin(Type a, Type b)

engine/src/dskw32.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class MCAutoRegistryKey
442442
///////////////////////////////////////////////////////////////////////////////
443443
static MMRESULT tid;
444444

445-
void CALLBACK MCS_tp(UINT id, UINT msg, DWORD user, DWORD dw1, DWORD dw2)
445+
void CALLBACK MCS_tp(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2)
446446
{
447447
MCalarm = True;
448448
}
@@ -1615,13 +1615,19 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
16151615

16161616
virtual bool GetMachine(MCStringRef& r_string)
16171617
{
1618-
r_string = MCValueRetain(MCNameGetString(MCN_x86));
1618+
r_string = MCValueRetain(MCNameGetString(GetProcessor()));
16191619
return true;
16201620
}
16211621

16221622
virtual MCNameRef GetProcessor(void)
16231623
{
1624+
#if defined _M_IX86
16241625
return MCN_x86;
1626+
#elif defined _M_AMD64
1627+
return MCN_x86_64;
1628+
#else
1629+
# error Unknown processor
1630+
#endif
16251631
}
16261632

16271633
virtual bool GetAddress(MCStringRef& r_address)

engine/src/engine.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
type="win32"
1212
name="Microsoft.Windows.Common-Controls"
1313
version="6.0.0.0"
14-
processorArchitecture="X86"
14+
processorArchitecture="*"
1515
publicKeyToken="6595b64144ccf1df"
1616
language="*"
1717
/>

engine/src/typedefs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3535
#endif
3636

3737
#define _DBL_RADIX 2 /* exponent radix */
38-
#define _DBL_ROUNDS 1 /* addition rounding: near */
3938

4039
#ifndef FLT_DIG
4140
#define FLT_DIG 6 /* # of decimal digits of precision */

engine/src/w32dcw32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void MCScreenDC::appendevent(MCEventnode *tptr)
133133
tptr->appendto(pendingevents);
134134
}
135135

136-
void CALLBACK mouseproc(UINT id, UINT msg, DWORD user, DWORD dw1, DWORD dw2)
136+
void CALLBACK mouseproc(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2)
137137
{
138138
MCScreenDC *pms = (MCScreenDC *)MCscreen;
139139
pms->setmousetimer(0);

engine/src/w32relaunch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static char *concatenate(char *p_first, bool p_free_first, char *p_last, bool p_
210210
bool message_send_with_data(message_t *p_message, unsigned int *r_reply)
211211
{
212212
COPYDATASTRUCT t_data;
213-
DWORD t_result;
213+
DWORD_PTR t_result;
214214

215215
t_data . dwData = CWM_RELAUNCH;
216216
t_data . cbData = p_message -> data_length;

engine/src/w32stack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void MCStack::setopacity(uint1 p_level)
315315
// MW-2010-10-22: [[ Bug 8151 ]] Make sure we update the title string.
316316
MCscreen -> setname(window, titlestring);
317317

318-
SetWindowLongA((HWND)window->handle.window, GWL_USERDATA, mode);
318+
SetWindowLongPtrA((HWND)window->handle.window, GWLP_USERDATA, mode);
319319

320320
if (flags & F_DECORATIONS && !(decorations & WD_SHAPE) && !(decorations & WD_CLOSE))
321321
EnableMenuItem(GetSystemMenu((HWND)window->handle.window, False), SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
@@ -433,7 +433,7 @@ void MCStack::realize()
433433
window -> handle . window = (MCSysWindowHandle)CreateWindowExW(exstyle, MC_WIN_CLASS_NAME_W, *t_window_name, wstyle | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, x, y, width, height,
434434
t_parenthwnd, NULL, MChInst, NULL);
435435

436-
SetWindowLongA((HWND)window->handle.window, GWL_USERDATA, mode);
436+
SetWindowLongPtrA((HWND)window->handle.window, GWLP_USERDATA, mode);
437437

438438
if (flags & F_DECORATIONS && !(decorations & WD_SHAPE) && !(decorations & WD_CLOSE))
439439
EnableMenuItem(GetSystemMenu((HWND)window->handle.window, False), SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);

0 commit comments

Comments
 (0)