PageRenderTime 29ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/scripts/MultiThreadPOC.pl

http://github.com/PerlGameDev/SDL
Perl | 35 lines | 24 code | 9 blank | 2 comment | 0 complexity | 76a0f9cd42e52ed2407a5724b72b4d86 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0
  1. use Inline C => DATA => LIBS => `sdl-config --libs` => INC => `sdl-config --cflags`;
  2. my $fp = get_function_pointer();
  3. print '[Perl] In perl we got :' . $fp . "\n";
  4. print '[Perl] Making Thread.';
  5. make_thread( get_function_pointer(), 'I AM THE OVERLOARD XENU!!!' );
  6. __END__
  7. __C__
  8. #include <SDL.h>
  9. #include <SDL_thread.h>
  10. char DoIt(char* c){
  11. int threadID = SDL_ThreadID();
  12. printf("[C-Thread] we are in %d \n", &threadID);
  13. printf("[C-Thread] Called with %s \n", c);
  14. return c;
  15. }
  16. int get_function_pointer() {
  17. printf("[C] Function Pointer is at %d!\n", &DoIt);
  18. return PTR2IV(&DoIt);
  19. }
  20. int make_thread(IV pointer, char* c)
  21. {
  22. void * fp = INT2PTR( void *, pointer);
  23. void * data = c;
  24. SDL_CreateThread( fp, data );
  25. printf("[C] Created thread: \n");
  26. }