decNumber pbi
Posted: Sun Feb 12, 2017 12:36 pm
here are the decNumber header translations http://speleotrove.com/decimal/decnumber.html
you need to correct the path and lib name in ImportC "/usr/local/lib/libdecnumber.a"
also, depending on how your C compiler mangles the symbols you may need to add or remove underscores in the imports.
compiling using VC, you need to correct the path and version
for 32-bit
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
cl /MD /O2 /c /GS- decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
lib /OUT:libdecNumber.lib *.obj
for 64-bit
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
cl /MD /O2 /c /GS- decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
lib /OUT:libdecNumber.lib *.obj
compiling using gcc
gcc -c -O2 decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
ar rcs libdecnumber.a *.o
decContext.pbi
you need to correct the path and lib name in ImportC "/usr/local/lib/libdecnumber.a"
also, depending on how your C compiler mangles the symbols you may need to add or remove underscores in the imports.
compiling using VC, you need to correct the path and version
for 32-bit
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86
cl /MD /O2 /c /GS- decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
lib /OUT:libdecNumber.lib *.obj
for 64-bit
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
cl /MD /O2 /c /GS- decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
lib /OUT:libdecNumber.lib *.obj
compiling using gcc
gcc -c -O2 decContext.c decDouble.c decimal32.c decimal64.c decimal128.c decNumber.c decPacked.c decSingle.c decQuad.c
ar rcs libdecnumber.a *.o
decContext.pbi
Code: Select all
;/* ------------------------------------------------------------------ */
;/* Decimal Context module header */
;/* ------------------------------------------------------------------ */
;/* Copyright (c) IBM Corporation, 2000, 2007. All rights reserved. */
;/* */
;/* This software is made available under the terms of the */
;/* ICU License -- ICU 1.8.1 and later. */
;/* */
;/* The description and User's Guide ("The decNumber C Library") for */
;/* this software is called decNumber.pdf. This document is */
;/* available, together with arithmetic and format specifications, */
;/* testcases, and Web links, at: http://www2.hursley.ibm.com/decimal */
;/* */
;/* Please send comments, suggestions, and corrections to the author: */
;/* mfc@uk.ibm.com */
;/* Mike Cowlishaw, IBM Fellow */
;/* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
;/* ------------------------------------------------------------------ */
;/* */
;/* Context variables must always have valid values: */
;/* */
;/* status -- [any bits may be cleared, but not set, by user] */
;/* round -- must be one of the Enumerationerated rounding modes */
;/* */
;/* The following variables are implied for fixed size formats (i.e., */
;/* they are ignored) but should still be set correctly in case used */
;/* with decNumber functions: */
;/* */
;/* clamp -- must be either 0 or 1 */
;/* digits -- must be in the range 1 through 999999999 */
;/* emax -- must be in the range 0 through 999999999 */
;/* emin -- must be in the range 0 through -999999999 */
;/* extended -- must be either 0 or 1 [present only if DECSUBSET] */
;/* traps -- only defined bits may be set */
;/* */
;/* ------------------------------------------------------------------ */
CompilerIf Defined(DECCONTEXT,#PB_Constant)=0
#DECCONTEXT = 1
#DECCNAME = "decContext" ;/* Short name */
#DECCFULLNAME = "Decimal Context Descriptor" ;/* Verbose name */
#DECCAUTHOR = "Mike Cowlishaw" ;/* Who to blame */
Macro int8_t
b
EndMacro
Macro uint8_t
b
EndMacro
Macro int16_t
w
EndMacro
Macro uint16_t
w
EndMacro
Macro int32_t
l
EndMacro
Macro uint32_t
l
EndMacro
Macro int64_t
q
EndMacro
Macro uint64_t
q
EndMacro
#DECUSE64 = 1 ;defined in decNumberLocal.h
;/* Extended flags setting -- set this to 0 to use only IEEE flags */
CompilerIf Defined(DECEXTFLAG,#PB_Constant)=0
#DECEXTFLAG = 1 ;/* 1=enable extended flags */
CompilerEndIf
;/* Conditional code flag -- set this to 0 for best performance */
CompilerIf Defined(DECSUBSET,#PB_Constant)=0
#DECSUBSET = 0 ;/* 1=enable subset arithmetic */
CompilerEndIf
;/* Context for operations, with associated constants */
Enumeration ;rounding
#DEC_ROUND_CEILING ;/* round towards +infinity */
#DEC_ROUND_UP ;/* round away from 0 */
#DEC_ROUND_HALF_UP ;/* 0.5 rounds up */
#DEC_ROUND_HALF_EVEN ;/* 0.5 rounds to nearest even */
#DEC_ROUND_HALF_DOWN ;/* 0.5 rounds down */
#DEC_ROUND_DOWN ;/* round towards 0 (truncate) */
#DEC_ROUND_FLOOR ;/* round towards -infinity */
#DEC_ROUND_05UP ;/* round for reround */
#DEC_ROUND_MAX ;/* Enumeration must be less than this */
EndEnumeration
#DEC_ROUND_DEFAULT = #DEC_ROUND_HALF_EVEN
Structure decContext
digits.int32_t ;/* working precision */
emax.int32_t ;/* maximum positive exponent */
emin.int32_t ;/* minimum negative exponent */
rounding.l ;/* rounding mode */
traps.uint32_t ;/* trap-enabler flags */
Status.uint32_t ;/* status flags */
clamp.uint8_t ;/* flag: apply IEEE exponent clamp */
CompilerIf #DECSUBSET
extended.uint8_t ;/* flag: special-values allowed */
CompilerEndIf
EndStructure
;/* Maxima and Minima for context settings */
#DEC_MAX_DIGITS = 999999999
#DEC_MIN_DIGITS = 1
#DEC_MAX_EMAX = 999999999
#DEC_MIN_EMAX = 0
#DEC_MAX_EMIN = 0
#DEC_MIN_EMIN = -999999999
#DEC_MAX_MATH = 999999 ;/* max emax, etc., for math funcs. */
;/* Classifications for decimal numbers, aligned with 754r (note */
;/* that 'normal' and 'subnormal' are meaningful only with a */
;/* decContext or a fixed size format). */
Enumeration ;decClass
#DEC_CLASS_SNAN
#DEC_CLASS_QNAN
#DEC_CLASS_NEG_INF
#DEC_CLASS_NEG_NORMAL
#DEC_CLASS_NEG_SUBNORMAL
#DEC_CLASS_NEG_ZERO
#DEC_CLASS_POS_ZERO
#DEC_CLASS_POS_SUBNORMAL
#DEC_CLASS_POS_NORMAL
#DEC_CLASS_POS_INF
EndEnumeration
;/* Strings for the decClasses */
#DEC_ClassString_SN = "sNaN"
#DEC_ClassString_QN = "NaN"
#DEC_ClassString_NI = "-Infinity"
#DEC_ClassString_NN = "-Normal"
#DEC_ClassString_NS = "-Subnormal"
#DEC_ClassString_NZ = "-Zero"
#DEC_ClassString_PZ = "+Zero"
#DEC_ClassString_PS = "+Subnormal"
#DEC_ClassString_PN = "+Normal"
#DEC_ClassString_PI = "+Infinity"
#DEC_ClassString_UN = "Invalid"
;/* Trap-enabler and Status flags (exceptional conditions), and */
;/* their names. The top byte is reserved for internal use */
CompilerIf #DECEXTFLAG
;/* Extended flags */
#DEC_Conversion_syntax = $00000001
#DEC_Division_by_zero = $00000002
#DEC_Division_impossible = $00000004
#DEC_Division_undefined = $00000008
#DEC_Insufficient_storage = $00000010 ;/* [when malloc fails] */
#DEC_Inexact = $00000020
#DEC_Invalid_context = $00000040
#DEC_Invalid_operation = $00000080
CompilerIf #DECSUBSET
#DEC_Lost_digits = $00000100
CompilerEndIf
#DEC_Overflow = $00000200
#DEC_Clamped = $00000400
#DEC_Rounded = $00000800
#DEC_Subnormal = $00001000
#DEC_Underflow = $00002000
CompilerElse
;/* IEEE flags only */
#DEC_Conversion_syntax = $00000010
#DEC_Division_by_zero = $00000002
#DEC_Division_impossible = $00000010
#DEC_Division_undefined = $00000010
#DEC_Insufficient_storage = $00000010 ;/* [when malloc fails] */
#DEC_Inexact = $00000001
#DEC_Invalid_context = $00000010
#DEC_Invalid_operation = $00000010
CompilerIf #DECSUBSET
#DEC_Lost_digits = $00000000
CompilerEndIf
#DEC_Overflow = $00000008
#DEC_Clamped = $00000000
#DEC_Rounded = $00000000
#DEC_Subnormal = $00000000
#DEC_Underflow = $00000004
CompilerEndIf
;/* IEEE 854 groupings for the flags */
;/* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal */
;/* are not in IEEE 854] */
#DEC_IEEE_854_Division_by_zero =(#DEC_Division_by_zero)
CompilerIf #DECSUBSET
#DEC_IEEE_854_Inexact =(#DEC_Inexact | #DEC_Lost_digits)
CompilerElse
#DEC_IEEE_854_Inexact =(#DEC_Inexact)
CompilerEndIf
#DEC_IEEE_854_Invalid_operation =(#DEC_Conversion_syntax | #DEC_Division_impossible | #DEC_Division_undefined | #DEC_Insufficient_storage | #DEC_Invalid_context | #DEC_Invalid_operation)
#DEC_IEEE_854_Overflow =(#DEC_Overflow)
#DEC_IEEE_854_Underflow =(#DEC_Underflow)
;/* flags which are normally errors (result is qNaN, infinite, or 0) */
#DEC_Errors =(#DEC_IEEE_854_Division_by_zero | #DEC_IEEE_854_Invalid_operation | #DEC_IEEE_854_Overflow | #DEC_IEEE_854_Underflow)
;/* flags which cause a result to become qNaN */
#DEC_NaNs =#DEC_IEEE_854_Invalid_operation
;/* flags which are normally for information only (finite results) */
CompilerIf #DECSUBSET
#DEC_Information =(#DEC_Clamped | #DEC_Rounded | #DEC_Inexact | #DEC_Lost_digits)
CompilerElse
#DEC_Information =(#DEC_Clamped | #DEC_Rounded | #DEC_Inexact)
CompilerEndIf
;/* Name strings for the exceptional conditions */
#DEC_Condition_CS = "Conversion syntax"
#DEC_Condition_DZ = "Division by zero"
#DEC_Condition_DI = "Division impossible"
#DEC_Condition_DU = "Division undefined"
#DEC_Condition_IE = "Inexact"
#DEC_Condition_IS = "Insufficient storage"
#DEC_Condition_IC = "Invalid context"
#DEC_Condition_IO = "Invalid operation"
CompilerIf #DECSUBSET
#DEC_Condition_LD = "Lost digits"
CompilerEndIf
#DEC_Condition_OV = "Overflow"
#DEC_Condition_PA = "Clamped"
#DEC_Condition_RO = "Rounded"
#DEC_Condition_SU = "Subnormal"
#DEC_Condition_UN = "Underflow"
#DEC_Condition_ZE = "No status"
#DEC_Condition_MU = "Multiple status"
#DEC_Condition_Length = 21 ;/* length of the longest string, */
;/* including terminator */
;/* Initialization descriptors, used by decContextDefault */
#DEC_INIT_BASE = 0
#DEC_INIT_DECIMAL32 = 32
#DEC_INIT_DECIMAL64 = 64
#DEC_INIT_DECIMAL128 = 128
;/* Synonyms */
#DEC_INIT_DECSINGLE = #DEC_INIT_DECIMAL32
#DEC_INIT_DECDOUBLE = #DEC_INIT_DECIMAL64
#DEC_INIT_DECQUAD = #DEC_INIT_DECIMAL128
;/* decContext routines */
ImportC "/usr/local/lib/libdecnumber.a"
decContextClearStatus(*a.decContext, b.uint32_t);decContext *
decContextDefault(*a.decContext , b.int32_t); As "_decContextDefault";decContext *
decContextGetRounding(*a.decContext);enum rounding
decContextGetStatus(*a.decContext);uint32_t
decContextRestoreStatus(*a.decContext , b.uint32_t, c.uint32_t);decContext *
decContextSaveStatus(*a.decContext , b.uint32_t);uint32_t
decContextSetRounding(*a.decContext , rounding.l);decContext *
decContextSetStatus(*a.decContext , b.uint32_t);decContext *
decContextSetStatusFromString(*a.decContext , s.s);decContext *
decContextSetStatusFromStringQuiet(*a.decContext , s.s);decContext *
decContextSetStatusQuiet(*a.decContext , b.uint32_t);decContext *
decContextStatusToString(*a.decContext);const char *
decContextTestEndian(a.uint8_t);int32_t
decContextTestSavedStatus(a.uint32_t, b.uint32_t);uint32_t
decContextTestStatus(*a.decContext , b.uint32_t);uint32_t
decContextZeroStatus(*a.decContext);decContext *
EndImport
CompilerEndIf