${Int64CmpU} in Util.nsh cannot use LogicLib because the LogicLib Z operators calls ${Int64CmpU} on 64-bit systems

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6717 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2016-03-09 19:26:48 +00:00
parent 0edaf2408c
commit 4a21c7113d
2 changed files with 70 additions and 29 deletions

View file

@ -55,7 +55,7 @@
; ptrdiff_t integer tests ; ptrdiff_t integer tests
; a P= b; a P<> b; a P< b; a P>= b; a P> b; a P<= b ; a P= b; a P<> b; a P< b; a P>= b; a P> b; a P<= b
; size_t integer tests ; size_t integer tests
; a Z= b; a Z<> b ; a Z= b; a Z<> b; a Z< b; a Z>= b; a Z> b; a Z<= b
; Built-in NSIS flag tests: ; Built-in NSIS flag tests:
; ${Abort}; ${Errors}; ${RebootFlag}; ${Silent} ; ${Abort}; ${Errors}; ${RebootFlag}; ${Silent}
; Built-in NSIS other tests: ; Built-in NSIS other tests:
@ -281,26 +281,25 @@
!macro _P<= _a _b _t _f !macro _P<= _a _b _t _f
!insertmacro LogicLib_PtrDiffTest <= `${_a}` `${_b}` `${_t}` `${_f}` !insertmacro LogicLib_PtrDiffTest <= `${_a}` `${_b}` `${_t}` `${_f}`
!macroend !macroend
!include Util.nsh
!macro _Z= _a _b _t _f !macro _Z= _a _b _t _f
!insertmacro LogicLib_PtrDiffTest = `${_a}` `${_b}` `${_t}` `${_f}` !insertmacro LogicLib_PtrDiffTest = `${_a}` `${_b}` `${_t}` `${_f}`
!macroend !macroend
!macro _Z<> _a _b _t _f !macro _Z<> _a _b _t _f
!insertmacro LogicLib_PtrDiffTest <> `${_a}` `${_b}` `${_t}` `${_f}` !insertmacro LogicLib_PtrDiffTest <> `${_a}` `${_b}` `${_t}` `${_f}`
!macroend !macroend
!if "${NSIS_PTR_SIZE}" <= 4 ; BUGBUG: System::Int64Op does not support unsigned operations!
!macro _Z< _a _b _t _f !macro _Z< _a _b _t _f
!insertmacro _U< `${_a}` `${_b}` `${_t}` `${_f}` !insertmacro IntPtrCmpU `${_a}` `${_b}` `${_f}` `${_t}` `${_f}`
!macroend !macroend
!macro _Z>= _a _b _t _f !macro _Z>= _a _b _t _f
!insertmacro _U>= `${_a}` `${_b}` `${_t}` `${_f}` !insertmacro IntPtrCmpU `${_a}` `${_b}` `${_t}` `${_f}` `${_t}`
!macroend !macroend
!macro _Z> _a _b _t _f !macro _Z> _a _b _t _f
!insertmacro _U> `${_a}` `${_b}` `${_t}` `${_f}` !insertmacro IntPtrCmpU `${_a}` `${_b}` `${_f}` `${_f}` `${_t}`
!macroend !macroend
!macro _Z<= _a _b _t _f !macro _Z<= _a _b _t _f
!insertmacro _U<= `${_a}` `${_b}` `${_t}` `${_f}` !insertmacro IntPtrCmpU `${_a}` `${_b}` `${_t}` `${_t}` `${_f}`
!macroend !macroend
!endif
; Flag tests ; Flag tests
!macro _Abort _a _b _t _f !macro _Abort _a _b _t _f

View file

@ -47,20 +47,23 @@
!define IntPtrOp '!insertmacro IntPtrOp ' !define IntPtrOp '!insertmacro IntPtrOp '
!macro Int32Op r a o b !macro Int32Op r a o b
!if ${NSIS_PTR_SIZE} <= 4 !if ${NSIS_PTR_SIZE} <= 4
IntOp ${r} ${a} ${o} ${b} IntOp `${r}` `${a}` `${o}` ${b}
!else !else
!error "Int32Op not implemented" !error "Int32Op not implemented"
!endif !endif
!macroend !macroend
!macro Int64Op r a o b !macro Int64Op r a o b
System::Int64Op ${a} ${o} ${b} !echo "Int64Op ${r}=${a}${o}${b}"
!verbose push 2
System::Int64Op `${a}` `${o}` ${b}
Pop ${r} Pop ${r}
!verbose pop
!macroend !macroend
!macro IntPtrOp r a o b !macro IntPtrOp r a o b
!if ${NSIS_PTR_SIZE} <= 4 !if ${NSIS_PTR_SIZE} <= 4
${Int32Op} ${r} ${a} ${o} "${b}" ${Int32Op} `${r}` `${a}` `${o}` `${b}`
!else !else
${Int64Op} ${r} ${a} ${o} "${b}" ${Int64Op} `${r}` `${a}` `${o}` `${b}`
!endif !endif
!macroend !macroend
@ -69,7 +72,7 @@ Pop ${r}
!define IntPtrCmp '!insertmacro IntPtrCmp ' !define IntPtrCmp '!insertmacro IntPtrCmp '
!macro Int32Cmp a b jeek jles jgtr !macro Int32Cmp a b jeek jles jgtr
!if ${NSIS_PTR_SIZE} <= 4 !if ${NSIS_PTR_SIZE} <= 4
IntCmp ${a} ${b} "${jeek}" "${jles}" "${jgtr}" IntCmp `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
!else !else
!error "Int32Cmp not implemented" !error "Int32Cmp not implemented"
!endif !endif
@ -78,17 +81,17 @@ Pop ${r}
!ifmacrondef _LOGICLIB_TEMP !ifmacrondef _LOGICLIB_TEMP
!include LogicLib.nsh !include LogicLib.nsh
!endif !endif
!echo "Int64Cmp ${a} ${b} ${jeek} ${jles} ${jgtr}" !echo "Int64Cmp ${a}:${b} =${jeek}, <${jles}, >${jgtr}"
!verbose push 2 !verbose push 2
${IfThen} ${a} L= ${b} ${|} Goto ${jeek} ${|} ${IfThen} ${a} L= ${b} ${|} Goto ${jeek} ${|}
!insertmacro _L< ${a} ${b} ${jles} ${jgtr} !insertmacro _L< ${a} ${b} `${jles}` `${jgtr}`
!verbose pop !verbose pop
!macroend !macroend
!macro IntPtrCmp a b jeek jles jgtr !macro IntPtrCmp a b jeek jles jgtr
!if ${NSIS_PTR_SIZE} <= 4 !if ${NSIS_PTR_SIZE} <= 4
${Int32Cmp} ${a} ${b} ${jeek} ${jles} ${jgtr} ${Int32Cmp} `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
!else !else
${Int64Cmp} ${a} ${b} ${jeek} ${jles} ${jgtr} ${Int64Cmp} `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
!endif !endif
!macroend !macroend
@ -97,32 +100,71 @@ ${IfThen} ${a} L= ${b} ${|} Goto ${jeek} ${|}
!define IntPtrCmpU '!insertmacro IntPtrCmpU ' !define IntPtrCmpU '!insertmacro IntPtrCmpU '
!macro Int32CmpU a b jeek jles jgtr !macro Int32CmpU a b jeek jles jgtr
!if ${NSIS_PTR_SIZE} <= 4 !if ${NSIS_PTR_SIZE} <= 4
IntCmpU ${a} ${b} "${jeek}" "${jles}" "${jgtr}" IntCmpU `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
!else !else
!error "Int32CmpU not implemented" !error "Int32CmpU not implemented"
!endif !endif
!macroend !macroend
!macro Int64CmpU a b jeek jles jgtr !macro Int64CmpUHelper
; This macro performs "$_LOGICLIB_TEMP = a < b ? -1 : a > b ? 1 : 0" but System::Int64Op does not support unsigned operations so we have to perform multiple steps
!ifmacrondef _LOGICLIB_TEMP !ifmacrondef _LOGICLIB_TEMP
!include LogicLib.nsh !include LogicLib.nsh
!endif !endif
!echo "Int64CmpU ${a} ${b} ${jeek} ${jles} ${jgtr}"
!verbose push 2
!insertmacro _LOGICLIB_TEMP !insertmacro _LOGICLIB_TEMP
${IfThen} ${a} L= ${b} ${|} Goto ${jeek} ${|} Exch $2 ; b
${If} ${a} L> 0 Exch
${IfThen} ${b} L< 0 ${|} Goto ${jles} ${|} Exch $1 ; a
${ElseIf} ${b} L> 0 ; if (a == b) return 0;
${IfThen} ${a} L< 0 ${|} Goto ${jgtr} ${|} ; if (a < 0)
${EndIf} ; {
!insertmacro _L< ${a} ${b} ${jles} ${jgtr} ; if (b >= 0) return 1
; }
; else
; {
; if (b < 0) return -1
; }
; return a < b ? -1 : 1
System::Int64Op $1 ^ $2 ; Using xor so $_LOGICLIB_TEMP ends up as 0 when they are equal
Pop $_LOGICLIB_TEMP
StrCmp $_LOGICLIB_TEMP 0 ret ; NOTE: Must use StrCmp, IntCmp fails on "0x8000000000000001 Z> 1"
System::Int64Op $1 < 0
Pop $_LOGICLIB_TEMP
StrCmp $_LOGICLIB_TEMP 0 checkNegOther
System::Int64Op $2 < 0 ; System::Int64Op does not support the >= operator so we invert the operation
Pop $_LOGICLIB_TEMP
StrCmp $_LOGICLIB_TEMP 0 retPos finalCmp
retPos:
StrCpy $_LOGICLIB_TEMP "1"
Goto ret
checkNegOther:
System::Int64Op $2 < 0
Pop $_LOGICLIB_TEMP
StrCmp $_LOGICLIB_TEMP 0 finalCmp retNeg
retNeg:
StrCpy $_LOGICLIB_TEMP "-1"
Goto ret
finalCmp:
System::Int64Op $1 < $2
Pop $_LOGICLIB_TEMP
StrCmp $_LOGICLIB_TEMP 0 retPos retNeg
ret:
Pop $1
Pop $2
!macroend
!macro Int64CmpU a b jeek jles jgtr
!echo "Int64CmpU ${a}:${b} =${jeek}, <${jles}, >${jgtr}"
!verbose push 2
Push `${a}`
Push `${b}`
!insertmacro CallArtificialFunction Int64CmpUHelper
IntCmp $_LOGICLIB_TEMP 0 `${jeek}` `${jles}` `${jgtr}`
!verbose pop !verbose pop
!macroend !macroend
!macro IntPtrCmpU a b jeek jles jgtr !macro IntPtrCmpU a b jeek jles jgtr
!if ${NSIS_PTR_SIZE} <= 4 !if ${NSIS_PTR_SIZE} <= 4
${Int32CmpU} ${a} ${b} ${jeek} ${jles} ${jgtr} ${Int32CmpU} `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
!else !else
${Int64CmpU} ${a} ${b} ${jeek} ${jles} ${jgtr} ${Int64CmpU} `${a}` `${b}` `${jeek}` `${jles}` `${jgtr}`
!endif !endif
!macroend !macroend