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

[question] Automating creation of C-call redirect table #70

Closed
sergei-mironov opened this issue Mar 22, 2016 · 2 comments
Closed

[question] Automating creation of C-call redirect table #70

sergei-mironov opened this issue Mar 22, 2016 · 2 comments

Comments

@sergei-mironov
Copy link

Hi. Lets say I have several procedures sharing same signature. I'd like Ivory to build a procedure which would act as a call gate - select the right call branch by analyzing a selector variable. Here is the illustration:

syscalls_1 :: [ Def ('[Inp1] :-> Out1) ]
syscalls_1 = [
   proc "proc11" $ \a -> body ... ,
   proc "proc12" $ \a -> body ...
]

syscalls_2 :: [ Def ('[Inp2, Inp2] :-> Out2) ]
syscalls_2 = [
   proc "proc21" $ \a b -> body ... ,
   proc "proc22" $ \a b -> body ...
]

gate :: [(Int, Def (a :-> b))] -> Def ( (Uint32 ': a) :-> b)
gate pset = proc "gate" $ \ ??? (selector:args) ->
    ???  switch (selector) { 
              case 0 : call (pset !! 0) args ; break;
              case 1 : call (pset !! 1) args ; break ;
              ...
            }
    ???


Now I want to use gate to build a wrapper for all my syscalls. The resulting function should take additional argument describing an implementation to call :

syscall_1 :: Def ('[Uint32, Inp1] :-> Out1)
syscall_1= gate syscalls_1

syscall_2 :: Def ('[Uint32, Inp2, Inp2] :-> Out2)
syscall_2 = gate syscalls_2

Could you please help me to design the implementation of gate in Haskell ?
Thanks in advance.

@leepike
Copy link
Contributor

leepike commented Mar 25, 2016

Have you tried using procPtr in Ivory?

@leepike
Copy link
Contributor

leepike commented Oct 24, 2016

@grwlf let me know if this still an issue. Otherwise, as it's not really a bug or enhancement request for Ivory, I'm closing this for now. Please feel free to email me directly.

@leepike leepike closed this as completed Oct 24, 2016
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