3 ms·
Chello is nice proof of concept, but personally i'd like to see only one or two changes to C standard: 1. sizeof(function) -> would give user ability to copy f
by popee 13y ago
Chello is nice proof of concept, but personally i'd like to see only one or two changes to C standard:
1. sizeof(function) -> would give user ability to copy functions around.
2. maybe new reserved keyword _Func -> function tagged with _Func would indicate that function must be compiled as function object (defined sizeof) and compiler needs to address fact that function may be moved around and used (relative addressing and i guess bunch or others problems that would arise). Only code, nothing to do with ELF or other formats.
Another interesting thing to do would be to, somehow, eliminate function pointers with _Func.
In any case, user would be responsible for creating environment for that (lambda?) functions, like manually setting mprotect or setting up stack (prologue.h & epilogue.h ???).
_Func int example_prototype(int i, int j) {
return i + j;
}
And then do something like:
example_prototype func0;
memcpy(&func0, example_prototype, sizeof(example_prototype));
struct prologue_t *p_ptr = &func0;
p_ptr->sp = 0xdeedbeef; // Or some address that is used as stack
z = func0(5, 6)
So, what do you thing how hard would it be to implement something like that?
- groue 13y agoDo you know C blocks ?http://en.wikipedia.org/wiki/Blocks_(C_language_extension) http://en.wikipedia.org/wiki/Blocks_(C_language_extension)