Skip to content

Commit ada09f5

Browse files
committed
fbc: thiscall, add the '-z nothiscall' option
- when '-z nothiscall' option is specified, fbc will not use 'thiscall' calling convention.
1 parent 39aee26 commit ada09f5

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/compiler/fb.bas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ sub fbSetOption( byval opt as integer, byval value as integer )
623623
env.clopt.gosubsetjmp = value
624624
case FB_COMPOPT_VALISTASPTR
625625
env.clopt.valistasptr = value
626+
case FB_COMPOPT_NOTHISCALL
627+
env.clopt.nothiscall = value
626628
case FB_COMPOPT_EXPORT
627629
env.clopt.export = value
628630
case FB_COMPOPT_MSBITFIELDS
@@ -719,6 +721,8 @@ function fbGetOption( byval opt as integer ) as integer
719721
function = env.clopt.gosubsetjmp
720722
case FB_COMPOPT_VALISTASPTR
721723
function = env.clopt.valistasptr
724+
case FB_COMPOPT_NOTHISCALL
725+
function = env.clopt.valistasptr
722726
case FB_COMPOPT_EXPORT
723727
function = env.clopt.export
724728
case FB_COMPOPT_MSBITFIELDS

src/compiler/fb.bi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ enum FB_COMPOPT
9696
'' the rest
9797
FB_COMPOPT_GOSUBSETJMP '' boolean: implement GOSUB using setjmp/longjump?
9898
FB_COMPOPT_VALISTASPTR '' boolean: implement CVA_* using pointer expressions only?
99+
FB_COMPOPT_NOTHISCALL '' boolean: don't use 'thiscall' calling convention?
99100
FB_COMPOPT_EXPORT '' boolean: export all symbols declared as EXPORT?
100101
FB_COMPOPT_MSBITFIELDS '' boolean: use M$'s bitfields packing?
101102
FB_COMPOPT_MULTITHREADED '' boolean: -mt
@@ -289,6 +290,7 @@ type FBCMMLINEOPT
289290
'' the rest
290291
gosubsetjmp as integer '' implement GOSUB using setjmp/longjump? (default = false)
291292
valistasptr as integer '' implement CVA_* using pointer expressions only?
293+
nothiscall as integer '' do not use thiscall calling convention (default = false)
292294
export as integer '' export all symbols declared as EXPORT (default = true)
293295
msbitfields as integer '' use M$'s bitfields packing
294296
multithreaded as integer '' link against thread-safe runtime library (default = false)

src/compiler/fbc.bas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,6 +2035,8 @@ private sub handleOpt(byval optid as integer, byref arg as string)
20352035
fbSetOption( FB_COMPOPT_GOSUBSETJMP, TRUE )
20362036
case "valist-as-ptr"
20372037
fbSetOption( FB_COMPOPT_VALISTASPTR, TRUE )
2038+
case "no-thiscall"
2039+
fbSetOption( FB_COMPOPT_NOTHISCALL, TRUE )
20382040
case else
20392041
hFatalInvalidOption( arg )
20402042
end select

src/compiler/parser-proc.bas

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,10 @@ function cProcCallingConv( byval default as FB_FUNCMODE ) as FB_FUNCMODE
526526
lexSkipToken( LEXCHECK_POST_SUFFIX )
527527

528528
case FB_TK_THISCALL
529-
function = FB_FUNCMODE_THISCALL
529+
'' ignore thiscall if '-z no-thiscall' was given
530+
if( env.clopt.nothiscall = FALSE ) then
531+
function = FB_FUNCMODE_THISCALL
532+
end if
530533
lexSkipToken( )
531534

532535
case else

0 commit comments

Comments
 (0)