I need to put some datastructures into a shared library, and have
programs linking with it share the data for real
This is trivial, as long as these structures don't contain any
pointers.
Build this into a library:
struct s1{
int i,j;
int pad[1<<20];
struct s2{Quote:};
int i;
const struct s1 * ss1p;
const struct s1 s1var={Quote:};
1,2,{1}
const struct s2 s2var={Quote:};
1,
&s1var,
Make a program that access the s2var from the library, and instancesQuote:};
of the program will actually share the data. That is, they will share
s1var, and hold s2var in private pages. (If you do change s2
to contain a lot of data istelf, you will see the size required by the
running processes increase.)
struct s2{
int i;
const struct s1 * ss1p;
int pad[1<<20];
This indicates to me that I'm unable to make the structures containingQuote:};
poiters truly shared. Am I right, or is there a way around it?
I'm running Solaris 2.4, cc: SC3.0.1
The Makefile:
use_bar: libbar.so use_bar.c
cc -xstrconst -R. -L. use_bar.c -o use_bar -lbar
libbar.so: bar.c
cc -xstrconst -c -K PIC bar.c
cc -xstrconst -G -z text -o libbar.so bar.o
Thanks
Tonnes Ingebrigtsen
Consultant
Skrivervik Data AS
Norway