sodium: add startup initialization hook

factor-shell
Alexander Iljin 2017-03-01 21:04:27 +03:00 committed by John Benediktsson
parent 868e718b66
commit d31d42e8c5
2 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,7 @@
! Copyright (C) 2017 Alexander Ilin. ! Copyright (C) 2017 Alexander Ilin.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.libraries alien.syntax combinators system ; USING: alien alien.c-types alien.libraries alien.syntax
combinators system ;
IN: sodium.ffi IN: sodium.ffi
<< "sodium" { << "sodium" {
@ -10,3 +11,5 @@ IN: sodium.ffi
} cond cdecl add-library >> } cond cdecl add-library >>
LIBRARY: sodium LIBRARY: sodium
FUNCTION: int sodium_init ( )

View File

@ -0,0 +1,11 @@
! Copyright (C) 2017 Alexander Ilin.
! See http://factorcode.org/license.txt for BSD license.
USING: init kernel math sodium.ffi ;
IN: sodium
ERROR: sodium-init-fail ;
! Call this before any other function, may be called multiple times.
: sodium-init ( -- ) sodium_init 0 < [ sodium-init-fail ] when ;
[ sodium-init ] "sodium" add-startup-hook