| > On 3.2 I use cc -c -o .. -migrate -O1 -std1 -I/usr/include/dce
> and ld -shared .. -lxti -lxtiosi -lpthreads
>
> On 4.0 I compile with
> cc -c -o .. -migrate -O1 -std1 -threads -DXTI_XPG3
Why the difference? You should be compiling with -threads on 3.2, as well.
When you really must link with ld instead of cc (and yes, you do, because
you're building a shared library), then you must use "-lpthreads -lmach
-lc_r" on the ld line, AND "-threads" on the cc line.
However, the real problem is that XTI wasn't thread-aware on 3.2, and used an
old-fashioned global "extern int t_errno;" cell. On 4.0, XTI provides a
per-thread t_errno. That means that your XTI calls, on 4.0, are setting a
per-thread error value... but your code, built on 3.2, is reading from the
old "extern int t_errno" cell.
I'm not sure of the details of how they implemented t_errno for 4.0. For the
normal errno, when libc sets errno in the main thread, it sets both the main
thread's errno and the global errno cell -- so that old code (running in the
main thread) will also see the proper value. It may be that t_errno doesn't
do that, or that this code wasn't running in the main thread.
/dave
|
|
We have found a workaround.
Basically, our problem was to build a shareable library on 3.2 and run on 3.2
and 4.0.
1) We added to our include files the lines you see in xti.h on 4.0
int *_terrno();
#define t_errno (*_terrno())
so that also our 3.2 executable uses the _terrno() function.
2) We built a simple source file ("t.c") like this:
extern int t_errno;
int *
_terrno()
{
return &t_errno;
}
3) Finally, we created our shared library linking this way on 3.2
ld -shared -o <our library> .... -none -lxti -all t.o -none -lxti
The effect is:
a) On 3.2, the first occurrence of -lxti does not contain the _terrno(), so
our function inside t.o is used: this function returns the same value we
used to have on 3.2
b) On 4.0, the shared lib libxti.so does contain the new _terrno() function
and the libxti.so function is used
So, tha same executable runs on 3.2 and 4.0.
< Aldo >
|