(* * LANGUAGE : ANS Forth * PROJECT : Forth Environments * DESCRIPTION : Interface to Giant Integer Library * CATEGORY : Configuration * AUTHORS : J. P. Buhler, R. McIntosh, G. Woltman, A. Powell and many others. * LAST CHANGE : Sunday, January 12, 2003 5:58 PM, mhx *) NEEDS -dynlink REVISION -gint "ÄÄÄ GINT Bignum library Version 0.02 ÄÄÄ" PRIVATES 0 VALUE gintlib PRIVATE : UNLOAD-GINT ( -- ) gintlib 0= IF exit ENDIF gintlib CLEAR gintlib library-close [ LINUX? ] [IF] ABORT" libgint.so.x :: close failed" [ELSE] ABORT" gint.dll :: close failed" [THEN] ; -- This assumes GINT.DLL is in the path : LOAD-GINT ( -- ) gintlib IF exit ENDIF [ LINUX? ] [IF] S" /lib/libgint.so.1.0" library-open ?DUP IF library-error CR TYPE ABORT" libgint.so.1.0 :: open failed" ENDIF [ELSE] S" gint.dll" library-open ?DUP IF library-error CR TYPE ABORT" gint.dll :: open failed" ENDIF [THEN] TO gintlib ;P : [GINT-LIB] ( c-addr1 u1 -- addr2 ) LOAD-GINT gintlib library-find ABORT" library-find: not in GINT" ; : GINT-LIB: ( "name" -- ) BL [GINT-LIB] ALITERAL ; IMMEDIATE : ?GINT-WARNING ( flag -- ) 0= IF exit ENDIF 0 GINT-LIB: GetGINTinfo FOREIGN @+ IF CR ." GINT error :: " DUP CELL+ @ COUNT TYPE ." parameter: " @ DEC. ELSE DROP ENDIF ; : ?GINT-ERROR ( flag -- ) DUP 0= IF DROP exit ENDIF ?GINT-WARNING #-4091 THROW ; \ Use this for GINT functions that don't return error info. : GINT-FAILED? ( -- flag ) 0 GINT-LIB: GetGINTinfo FOREIGN @ 0<> ; : .GINT-INFO ( -- ) 0 GINT-LIB: GetGINTinfo FOREIGN DUP 3 CELL[] @ BEGIN C@+ ?DUP WHILE EMIT REPEAT DROP @ ?GINT-WARNING ; : GINT-RESET ( -- ) 0 GINT-LIB: ResetGINTerror FOREIGN DROP ; :ABOUT CR ." ** optimum Large Integer GINT library ** " ; DEPRIVE (* End GINT code *)