Hi All,

The following patch fixes building PostgreSQL 7.4.2 under Sun (Sparc)
Solaris 7 and 8 (possibly earlier and later versions, as well) with
--enable-thread-safety.

The first addresses what would appear to be a coding error in
thread.c.  The second ensures the proper pthread function call
semantics.

Build tested using GCC 3.3.1 under Solaris 7 and 8.  Tested with
ancient version of Sun's commercial development package under Solaris
8.

Note: I don't know that --enable-thread-safety actually *works* on
these platforms.  But the package now builds.

Regards,
Jim


*** ./src/port/thread.c-orig	Tue Mar  2 13:38:28 2004
--- ./src/port/thread.c	Sun Mar 14 10:07:04 2004
***************
*** 186,192 ****
  	 * broken (well early POSIX draft) gethostbyname_r() which returns
  	 * 'struct hostent *'
  	 */
! 	*result = gethostbyname_r(name, resbuf, buffer, buflen, herrno);
  	return (*result == NULL) ? -1 : 0;
  
  #else
--- 186,192 ----
  	 * broken (well early POSIX draft) gethostbyname_r() which returns
  	 * 'struct hostent *'
  	 */
! 	*result = gethostbyname_r(name, resultbuf, buffer, buflen, herrno);
  	return (*result == NULL) ? -1 : 0;
  
  #else
*** ./src/template/solaris-orig	Wed Jan  7 23:21:20 2004
--- ./src/template/solaris	Sun Mar 14 14:39:40 2004
***************
*** 12,19 ****
  THREAD_SUPPORT=yes
  NEED_REENTRANT_FUNCS=yes	# 5.6 2003-09-13
  if test "$GCC" = yes 
! then	THREAD_LIBS="-pthread"
! else	THREAD_CPPFLAGS="-mt"
  	THREAD_LIBS="-lpthread"
  fi
  
--- 12,20 ----
  THREAD_SUPPORT=yes
  NEED_REENTRANT_FUNCS=yes	# 5.6 2003-09-13
  if test "$GCC" = yes 
! then	THREAD_CPPFLAGS="-D_POSIX_PTHREAD_SEMANTICS"
! 	THREAD_LIBS="-pthread"
! else	THREAD_CPPFLAGS="-mt -D_POSIX_PTHREAD_SEMANTICS"
  	THREAD_LIBS="-lpthread"
  fi
  

Sun, 14 Mar 2004 15:06:59 -0500 (EST)
jseymour@LinxNet.com (Jim Seymour)
Patch for: 7.4.2 build broken on Solaris 7 and 8 with
	--enable-thread-safety

I have updated the solaris template file in CVS HEAD and 7.4.X to
reflect your changes.  I had already fixed the thread.c typo.

Thanks.

---------------------------------------------------------------------------

Jim Seymour wrote:
> Hi All,
> 
> The following patch fixes building PostgreSQL 7.4.2 under Sun (Sparc)
> Solaris 7 and 8 (possibly earlier and later versions, as well) with
> --enable-thread-safety.
> 
> The first addresses what would appear to be a coding error in
> thread.c.  The second ensures the proper pthread function call
> semantics.
> 
> Build tested using GCC 3.3.1 under Solaris 7 and 8.  Tested with
> ancient version of Sun's commercial development package under Solaris
> 8.
> 
> Note: I don't know that --enable-thread-safety actually *works* on
> these platforms.  But the package now builds.
> 
> Regards,
> Jim
> 
> 
> *** ./src/port/thread.c-orig	Tue Mar  2 13:38:28 2004
> --- ./src/port/thread.c	Sun Mar 14 10:07:04 2004
> ***************
> *** 186,192 ****
>   	 * broken (well early POSIX draft) gethostbyname_r() which returns
>   	 * 'struct hostent *'
>   	 */
> ! 	*result = gethostbyname_r(name, resbuf, buffer, buflen, herrno);
>   	return (*result == NULL) ? -1 : 0;
>   
>   #else
> --- 186,192 ----
>   	 * broken (well early POSIX draft) gethostbyname_r() which returns
>   	 * 'struct hostent *'
>   	 */
> ! 	*result = gethostbyname_r(name, resultbuf, buffer, buflen, herrno);
>   	return (*result == NULL) ? -1 : 0;
>   
>   #else
> *** ./src/template/solaris-orig	Wed Jan  7 23:21:20 2004
> --- ./src/template/solaris	Sun Mar 14 14:39:40 2004
> ***************
> *** 12,19 ****
>   THREAD_SUPPORT=yes
>   NEED_REENTRANT_FUNCS=yes	# 5.6 2003-09-13
>   if test "$GCC" = yes 
> ! then	THREAD_LIBS="-pthread"
> ! else	THREAD_CPPFLAGS="-mt"
>   	THREAD_LIBS="-lpthread"
>   fi
>   
> --- 12,20 ----
>   THREAD_SUPPORT=yes
>   NEED_REENTRANT_FUNCS=yes	# 5.6 2003-09-13
>   if test "$GCC" = yes 
> ! then	THREAD_CPPFLAGS="-D_POSIX_PTHREAD_SEMANTICS"
> ! 	THREAD_LIBS="-pthread"
> ! else	THREAD_CPPFLAGS="-mt -D_POSIX_PTHREAD_SEMANTICS"
>   	THREAD_LIBS="-lpthread"
>   fi
>   
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>                http://archives.postgresql.org
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Sun, 14 Mar 2004 18:51:46 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Patch for: 7.4.2 build broken on Solaris 7 and 8 with