PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 1ms 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
 1use Inline C => DATA => LIBS => `sdl-config --libs` => INC => `sdl-config --cflags`;
 2
 3my $fp = get_function_pointer();
 4print '[Perl] In perl we got :' . $fp . "\n";
 5print '[Perl] Making Thread.';
 6
 7make_thread( get_function_pointer(), 'I AM THE OVERLOARD XENU!!!' );
 8
 9__END__    
10__C__
11
12#include <SDL.h>
13#include <SDL_thread.h>
14
15char DoIt(char* c){ 
16	int threadID = SDL_ThreadID(); 
17	printf("[C-Thread] we are in %d \n", &threadID);
18	printf("[C-Thread] Called with %s \n", c); 
19	return c;
20}
21
22int get_function_pointer() {
23	printf("[C] Function Pointer is at %d!\n", &DoIt);
24	return PTR2IV(&DoIt);
25}
26
27
28int make_thread(IV pointer, char* c)
29{
30	void * fp = INT2PTR( void *, pointer);
31	void * data = c;
32	SDL_CreateThread( fp, data );
33	printf("[C] Created thread: \n");
34}
35