Skip to content

Commit f73d638

Browse files
author
Mitsutoshi Aoe
committed
Use appropriate calling convention on Windows depending on the host architecture
@Mistuke pointed out that we can't use the ccall calling convention on x86. 299546b#commitcomment-23352756
1 parent 34cf9dc commit f73d638

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

GUI/GtkExtras.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import System.Glib.GError
2020
import Control.Monad
2121
#endif
2222

23+
#include "windows_cconv.h"
24+
2325
waitGUI :: IO ()
2426
waitGUI = do
2527
resultVar <- newEmptyMVar
@@ -94,7 +96,7 @@ launchProgramForURI uri = do
9496
1 -- SW_SHOWNORMAL
9597
return True
9698

97-
foreign import ccall unsafe "shlobj.h ShellExecuteA"
99+
foreign import WINDOWS_CCONV unsafe "shlobj.h ShellExecuteA"
98100
c_ShellExecuteA :: Ptr () -- HWND hwnd
99101
-> CString -- LPCTSTR lpOperation
100102
-> CString -- LPCTSTR lpFile

include/windows_cconv.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef __WINDOWS_CCONV_H
2+
#define __WINDOWS_CCONV_H
3+
4+
#if defined(i386_HOST_ARCH)
5+
# define WINDOWS_CCONV stdcall
6+
#elif defined(x86_64_HOST_ARCH)
7+
# define WINDOWS_CCONV ccall
8+
#else
9+
# error Unknown mingw32 arch
10+
#endif
11+
12+
#endif

threadscope.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Bug-reports: https://github.com/haskell/ThreadScope/issues
3333
Build-Type: Simple
3434
Cabal-version: >= 1.6
3535
Data-files: threadscope.ui, threadscope.png
36+
Extra-source-files: include/windows_cconv.h
3637
Tested-with: GHC == 7.6.3,
3738
GHC == 7.8.3,
3839
GHC == 7.10.2,
@@ -62,6 +63,7 @@ Executable threadscope
6263
if os(osx)
6364
build-depends: gtk-mac-integration
6465

66+
include-dirs: include
6567
Extensions: RecordWildCards, NamedFieldPuns, BangPatterns, PatternGuards
6668
Other-Modules: Events.HECs,
6769
Events.EventDuration,

0 commit comments

Comments
 (0)