Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] c_call like c_func / fmt_c_decl #168

Open
JasonGross opened this issue Nov 10, 2020 · 2 comments
Open

[request] c_call like c_func / fmt_c_decl #168

JasonGross opened this issue Nov 10, 2020 · 2 comments

Comments

@JasonGross
Copy link
Contributor

In usage in fiat-crypto, I find myself needing to recreate some of the logic from

match rets with
| nil => (fmt_c_decl "void" args name nil, None, nil)
| cons r0 _ =>
let r0 := List.last rets r0 in
let rets' := List.removelast rets in
let retrenames := fst (rename_outs rets' (cmd.vars body)) in
(fmt_c_decl "uintptr_t" args name (List.map snd retrenames), Some r0, retrenames)
end in

I would like a function like

c_arrange_arguments {A R} (args : list A) (rets : list R) : option R * list (A + R)

which factors out the logic about which return gets returned and which returns get added to the argument list, and the logic about which order things get added. (I can make a PR for this if you'd like.) See also mit-plv/fiat-crypto#895

@andres-erbsen
Copy link
Contributor

So do you actually want c_arrange_arguments or just c_call?

@JasonGross
Copy link
Contributor Author

I think c_arrange_arguments would be better; I need access to things that operate not just on strings (I need to bundle the type info with names).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants