Merge pull request #2 from coffeepots/win-compatibility

Win compatibility
This commit is contained in:
Alexander Ivanov 2018-02-19 11:21:33 +02:00 committed by GitHub
commit 021c3935b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -893,7 +893,7 @@ namespace ttmath
template<uint value_size> template<uint value_size>
sint UInt<value_size>::FindLeadingBitInWord(uint x) sint UInt<value_size>::FindLeadingBitInWord(uint x)
{ {
sint result; int64_t result;
#ifndef __GNUC__ #ifndef __GNUC__
@ -909,7 +909,7 @@ namespace ttmath
#ifdef __GNUC__ #ifdef __GNUC__
uint dummy; int64_t dummy;
__asm__ ( __asm__ (
@ -918,7 +918,7 @@ namespace ttmath
"cmovz %1, %0 \n" "cmovz %1, %0 \n"
: "=r" (result), "=&r" (dummy) : "=r" (result), "=&r" (dummy)
: "r" (x) : "r" (int64_t(x))
: "cc" ); : "cc" );
#endif #endif

View File

@ -1,10 +1,12 @@
import ttmathuint import ttmathuint
export ttmathuint export ttmathuint
import strutils import strutils
from os import DirSep
{.passC: "-I" & currentSourcePath.rsplit("/", 1)[0].} const ttmathPath = currentSourcePath.rsplit(DirSep, 1)[0]
{.passC: "-I" & ttmathPath.}
const TTMATH_HEADER = "headers/ttmath.h" const TTMATH_HEADER = ttmathPath & DirSep & "headers" & DirSep & "ttmath.h"
type type
Int256* {.importc: "ttmath::Int<4>", header: TTMATH_HEADER.} = object Int256* {.importc: "ttmath::Int<4>", header: TTMATH_HEADER.} = object

View File

@ -1,4 +1,7 @@
const TTMATH_HEADER = "headers/ttmathuint.h" from os import DirSep
from strutils import rsplit
const ttmathPath = currentSourcePath.rsplit(DirSep, 1)[0]
const TTMATH_HEADER = ttmathPath & DirSep & "headers" & DirSep & "ttmath.h"
type type
UInt256* {.importc: "ttmath::UInt<4>", header: TTMATH_HEADER.} = object UInt256* {.importc: "ttmath::UInt<4>", header: TTMATH_HEADER.} = object
@ -36,7 +39,7 @@ proc `or`*(a: UInt256, b: UInt256): UInt256 {.importcpp: "(# | #)".}
proc `xor`*(a: UInt256, b: UInt256): UInt256 {.importcpp: "(# ^ #)".} proc `xor`*(a: UInt256, b: UInt256): UInt256 {.importcpp: "(# ^ #)".}
proc u256*(a: uint64): UInt256 {.importcpp: "ttmath::UInt<4>((uint)#)".} proc u256*(a: uint64): UInt256 {.importcpp: "ttmath::UInt<4>((ttmath::uint)#)".}
proc u256*(a: cstring): UInt256 {.importcpp: "ttmath::UInt<4>(#)".} proc u256*(a: cstring): UInt256 {.importcpp: "ttmath::UInt<4>(#)".}