Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* dlopen limits
@ 1995-11-17  5:00 Marinos Yannikos
  1995-11-21  5:00 `  Steven Winikoff 
  1995-11-21  5:00 ` David Metsky
  0 siblings, 2 replies; 3+ messages in thread
From: Marinos Yannikos @ 1995-11-17  5:00 UTC (permalink / raw)


I noticed that it is not possible to dlopen() more than 95 shared libraries
at the same time under Digital Unix 3.2a. Is this an arbitrary limit, or 
is there some other reason, like efficiency problems, for this? Appended 
below is a program that shows the problem (it will fill up your current
directory with func_*.{c,o,so} files).

Thanks,
-nino

PS. If you can get this to work with more than 95 functions on 3.2c or better,
please let me know!
--- 8< ---
#include <stdio.h>
#include <dlfcn.h>

#define N 200
void *h[N];
int (*func[N])();
main()
{
	FILE *f;
	int i;
	char s[100];
	for (i=0; i<N; i++)
	{
		fprintf(stderr, "Function %d\r",i);
		sprintf(s,"func_%d.c",i);
		f=fopen(s,"w");
		fprintf (f,"func_%d(){return 1+%d;}",i,i);
		fclose(f);
		sprintf(s,"cc -c func_%d.c; ld -shared func_%d.o -o func_%d.so -lc",i,i,i);
		system(s);
		sprintf(s,"func_%d.so",i);
		h[i]=dlopen(s, RTLD_LAZY);
		if (h[i]==NULL) {fprintf(stderr, "\nError: %s\n", dlerror()); exit(1);}
		sprintf(s,"func_%d",i);
		func[i]=dlsym(h[i],s);
	}
	for (i=0; i<N; i++)
	{
		fprintf (stderr, "Testing %d\r",i);
		if (func[i]() != 1+i)
			fprintf (stderr, "\nError in function %d!\n",i);
	}
}
--- >8 ---
-- 
http://www.complang.tuwien.ac.at/nino




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1995-11-21  5:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-11-17  5:00 dlopen limits Marinos Yannikos
1995-11-21  5:00 `  Steven Winikoff 
1995-11-21  5:00 ` David Metsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox