From: stephan b. <sg...@us...> - 2004-12-22 19:06:18
|
Update of /cvsroot/pclasses/pclasses2/toc/tests/c In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7192/c Added Files: check_for_dlopen_and_friends.c check_for_ltdlopen_and_friends.c check_for_pthread.c Makefile Log Message: egg --- NEW FILE: check_for_dlopen_and_friends.c --- /** Quick check for dlopen(), dlclose() and dlsym(). toc usage: toc_test_require path/to/this/file -ldl -export-dynamic */ #include <dlfcn.h> #include <stdlib.h> void foo_function() {} int main() { typedef void (*func)(); void * soh = dlopen( 0, RTLD_NOW | RTLD_GLOBAL ); if( ! soh ) { printf( "%s\n", dlerror() ); return 1; } void * sym = (func) dlsym( soh, "foo_function" ); if( 0 == sym ) { printf( "%s\n", dlerror() ); return 2; } int err = dlclose( soh ); if( err ) { printf( "%s\n", dlerror() ); return err; } return 0; } --- NEW FILE: check_for_ltdlopen_and_friends.c --- /** Quick check for lt_dlopen(), lt_dlclose() and lt_dlsym(). toc usage: toc_test_require path/to/this/file -lltdl -export-dynamic */ #include <ltdl.h> #include <stdlib.h> void foo_function() {} int main() { typedef void (*func)(); void * soh = 0; lt_dlinit(); soh = lt_dlopen( 0 ); // , RTLD_NOW | RTLD_GLOBAL ); if( ! soh ) { printf( "could not open main app: %s\n", lt_dlerror() ); return 1; } void * sym = (func) lt_dlsym( soh, "foo_function" ); if( 0 == sym ) { printf( "could not find test symbol: %s\n", lt_dlerror() ); return 2; } return 0; } --- NEW FILE: check_for_pthread.c --- #include <pthread.h> // link with -lpthread #include <stdio.h> void * thread_callback( void * arg ) { printf( "Doing nothing.\n" ); } int main() { pthread_t thread = 0; int thret = pthread_create( &thread, NULL, thread_callback, NULL ); return 0; } --- NEW FILE: Makefile --- include toc.make DIST_FILES += $(wildcard *.c) all: |