[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

4732.0. "XTI: t_listen says -1 and t_errno=0" by FORTY2::JONES (Neil) Wed Mar 13 1996 12:28

T.RTitleUserPersonal
Name
DateLines
4732.1ah! but more woesFORTY2::JONESNeilThu Mar 14 1996 06:228
4732.2?FORTY2::JONESNeilThu Mar 14 1996 06:237
4732.3SMURF::MENNERi'm gonna plant a weeEEping willow...Fri Mar 15 1996 08:482
4732.4doneFORTY2::JONESNeilFri Mar 15 1996 09:509
4732.5news about that? VARESE::BIOTTIFri Jan 31 1997 10:0111
 Looking into the QAR db the problem doesn't look solved .. or not? 

 I'm having the problem with t_connect.

 I get t_errno 0 only with executable built on 3.2 and run on 4.0.
 If I compile and run on 4.0 no problem. 

 Looking at xti.h the t_errno definition has changed. 


4732.6Are you using threads?WTFN::SCALESDespair is appropriate and inevitable.Fri Jan 31 1997 11:455
Are you using threads?  If so, are you compiling using the proper switches
(i.e., -threads or -pthread or equiv.)?


				Webb
4732.7that's what I'm doingVARESE::BIOTTIMon Feb 03 1997 11:0710
    
     Yes I'm using threads.
    
     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 
    
    
4732.8DCETHD::BUTENHOFDave Butenhof, DECthreadsTue Feb 04 1997 04:4324
>     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
4732.9Found a workaroundVARESE::ZOCCOLADeprimitElatosLevatAlexandriaStratosTue Feb 04 1997 06:2749
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 >