Skip to content

Foreign Function Interface#1376

Merged
yav merged 65 commits intomasterfrom
ffi
Aug 12, 2022
Merged

Foreign Function Interface#1376
yav merged 65 commits intomasterfrom
ffi

Conversation

@qsctr
Copy link
Collaborator

@qsctr qsctr commented Jun 25, 2022

This PR adds a foreign function interface (FFI) to Cryptol. This allows Cryptol to call functions written in C.

For instance, we can declare this foreign function in Cryptol

foreign add : [32] -> [32] -> [32]

and implement it in C

uint32_t add(uint32_t x, uint32_t y) {
  return x + y;
}

and then call it like any other Cryptol function.

Main> add 1 2
0x00000003

See the FFI docs for more information.

@qsctr qsctr marked this pull request as ready for review June 28, 2022 23:39
Copy link
Member

@yav yav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I made a few suggestion for stylistic improvements. On the topic of style, I really prefer the case expressions that do not use inverted indentation because it is quite a bit easier to see what is being matched where. For example like this:

I like:

function = some long prefix thing
   case expr of
       A -> thing1
       B -> thing2

rather than:

function = some long prefix thing case expr of
  A -> thing1
  B -> thing2

@qsctr qsctr changed the title Basic FFI Implementation Foreign Function Interface Aug 11, 2022
@yav yav merged commit 8298ca3 into master Aug 12, 2022
@qsctr qsctr mentioned this pull request Aug 12, 2022
@qsctr qsctr deleted the ffi branch August 12, 2022 21:04
@RyanGlScott RyanGlScott added the FFI Foreign function interface label Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FFI Foreign function interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants