File: MultiThreadPOC.pl

package info (click to toggle)
libsdl-perl 2.548-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,972 kB
  • sloc: perl: 13,985; ansic: 583; makefile: 35
file content (35 lines) | stat: -rw-r--r-- 765 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use Inline C => DATA => LIBS => `sdl-config --libs` => INC => `sdl-config --cflags`;

my $fp = get_function_pointer();
print '[Perl] In perl we got :' . $fp . "\n";
print '[Perl] Making Thread.';

make_thread( get_function_pointer(), 'I AM THE OVERLOARD XENU!!!' );

__END__    
__C__

#include <SDL.h>
#include <SDL_thread.h>

char DoIt(char* c){ 
	int threadID = SDL_ThreadID(); 
	printf("[C-Thread] we are in %d \n", &threadID);
	printf("[C-Thread] Called with %s \n", c); 
	return c;
}

int get_function_pointer() {
	printf("[C] Function Pointer is at %d!\n", &DoIt);
	return PTR2IV(&DoIt);
}


int make_thread(IV pointer, char* c)
{
	void * fp = INT2PTR( void *, pointer);
	void * data = c;
	SDL_CreateThread( fp, data );
	printf("[C] Created thread: \n");
}