// dltest.cpp
#include "myso.h"
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>^M#include <pthread.h>
int featurethread_count = 0;
static int libnum = 1;
pthread_mutex_t featurethread_count_mutex = PTHREAD_MUTEX_INITIALIZER;^M
void* FeatureThread( void* p )^M
{
const char *dlError;
void *PornLib;
char lib[10];
pthread_mutex_lock(&featurethread_count_mutex);
sprintf(lib, "./libmyso%d.so", libnum);
libnum++;
PornLib = dlopen(lib, RTLD_LAZY);
dlError = dlerror();
// fprintf(stderr, "%s \n", dlError);
pthread_mutex_unlock(&featurethread_count_mutex);
void (*sofun) (ssd &) ;
*(void**)(&sofun) = dlsym(PornLib, "test");
dlError = dlerror();
// fprintf(stderr, "%s \n", dlError);
ssd myssd1;
while(1)
{
sofun(myssd1);
fprintf(stdout, "%s \n", lib);
}
}
int main()
{
pthread_t tmp ;
pthread_create(&tmp,NULL,FeatureThread,NULL);
pthread_create(&tmp,NULL,FeatureThread,NULL);
pthread_create(&tmp,NULL,FeatureThread,NULL);
pthread_create(&tmp,NULL,FeatureThread,NULL);
while(1);
}
|