Re: [HACKERS] ECPG thread-safety

Поиск
Список
Период
Сортировка
Искать

Re: [HACKERS] ECPG thread-safety

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Shridhar Daithankar wrote:
> On Friday 28 March 2003 21:45, you wrote:
> > For testing the library, I think it is enough to init an thread attr. like
> > pthread_init_attr, that should be enough to test header and library.
> 
> And compiler flags, I forgot.. -pthread on freeBSD/gcc and -D_REENTRANT on 
> linux at least. FreeBSD needs _THREAD_SAFE as well IIRC.

Are you saying FreeBSD actually has a -pthread compiler flag?  And Linux
needs REENTRANT.  We can do that.  Here is an updated patch.  Of course,
I need to run autoconf too.

-- 
  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
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.253
diff -c -c -r1.253 configure.in
*** configure.in	22 May 2003 16:39:28 -0000	1.253
--- configure.in	26 May 2003 17:05:52 -0000
***************
*** 506,511 ****
--- 506,514 ----
                [  --without-zlib          do not use Zlib])
  
  
+ #
+ # Elf
+ #
  
  # Assume system is ELF if it predefines __ELF__ as 1,
  # otherwise believe host_os based default.
***************
*** 527,533 ****
--- 530,560 ----
  fi])
  AC_SUBST(ELF_SYS)
  
+ #
+ # Pthreads
+ #
  
+ AC_CHECK_HEADER(pthread.h,
+ 	[AC_DEFINE(HAVE_THREADS, 1, [Define to 1 if you have the threads interface.])])
+ if test ! -z "$HAVE_THREADS"
+ then	
+ 	case $host_os in
+ 		# BSD/OS and NetBSD require no special libraries or flags
+ 		netbsd*|bsdi*) ;;
+ 		freebsd*) THREAD_LIBS="-lc_r"
+ 			  THREAD_CFLAGS="-pthread" ;;
+ 		linux*) THREAD_LIBS="-lpthread"
+ 			THREAD_CFLAGS="-D_REENTRANT" ;;
+ 	# other operating systems might fail because they have pthread.h but need
+ 	# special libs we don't know about yet.
+ 	esac
+ fi
+ AC_SUBST(THREAD_LIBS)
+ AC_SUBST(THREAD_CFLAGS)
+ 
+ #
+ # Assignments
+ #
  
  CPPFLAGS="$CPPFLAGS $INCLUDES"
  LDFLAGS="$LDFLAGS $LIBDIRS"
Index: src/Makefile.global.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/Makefile.global.in,v
retrieving revision 1.162
diff -c -c -r1.162 Makefile.global.in
*** src/Makefile.global.in	11 May 2003 20:50:53 -0000	1.162
--- src/Makefile.global.in	26 May 2003 17:05:54 -0000
***************
*** 152,157 ****
--- 152,160 ----
  TK_LIB_SPEC		= @TK_LIB_SPEC@
  TK_XINCLUDES		= @TK_XINCLUDES@
  
+ THREAD_CFLAGS		= @THREAD_CFLAGS@
+ THREAD_LIBS		= @THREAD_LIBS@
+ 
  have_docbook	= @have_docbook@
  DOCBOOKSTYLE	= @DOCBOOKSTYLE@
  COLLATEINDEX	= @COLLATEINDEX@
Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.47
diff -c -c -r1.47 pg_config.h.in
*** src/include/pg_config.h.in	22 May 2003 16:39:30 -0000	1.47
--- src/include/pg_config.h.in	26 May 2003 17:05:56 -0000
***************
*** 465,470 ****
--- 465,473 ----
  /* Define to 1 if you have the  header file. */
  #undef HAVE_TERMIOS_H
  
+ /* Define to 1 if you have the  header file. */
+ #undef HAVE_THREADS
+ 
  /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
     `HAVE_STRUCT_TM_TM_ZONE' instead. */
  #undef HAVE_TM_ZONE

Re: [HACKERS] ECPG thread-safety

От:
Rod Taylor <rbt@rbt.ca>
Дата:
Вложения:
On Mon, 2003-05-26 at 13:06, Bruce Momjian wrote:
> Shridhar Daithankar wrote:
> > On Friday 28 March 2003 21:45, you wrote:
> > > For testing the library, I think it is enough to init an thread attr. like
> > > pthread_init_attr, that should be enough to test header and library.
> > 
> > And compiler flags, I forgot.. -pthread on freeBSD/gcc and -D_REENTRANT on 
> > linux at least. FreeBSD needs _THREAD_SAFE as well IIRC.
> 
> Are you saying FreeBSD actually has a -pthread compiler flag?  And Linux
> needs REENTRANT.  We can do that.  Here is an updated patch.  Of course,
> I need to run autoconf too.

If I'm not mistaken, you use -lpthread on FreeBSD 4.x, and -lc_r on
FreeBSD 5.x.

-- 
Rod Taylor 

PGP Key: http://www.rbt.ca/rbtpub.asc

Re: [HACKERS] ECPG thread-safety

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Rod Taylor wrote:
-- Start of PGP signed section.
> On Mon, 2003-05-26 at 13:06, Bruce Momjian wrote:
> > Shridhar Daithankar wrote:
> > > On Friday 28 March 2003 21:45, you wrote:
> > > > For testing the library, I think it is enough to init an thread attr. like
> > > > pthread_init_attr, that should be enough to test header and library.
> > > 
> > > And compiler flags, I forgot.. -pthread on freeBSD/gcc and -D_REENTRANT on 
> > > linux at least. FreeBSD needs _THREAD_SAFE as well IIRC.
> > 
> > Are you saying FreeBSD actually has a -pthread compiler flag?  And Linux
> > needs REENTRANT.  We can do that.  Here is an updated patch.  Of course,
> > I need to run autoconf too.
> 
> If I'm not mistaken, you use -lpthread on FreeBSD 4.x, and -lc_r on
> FreeBSD 5.x.

Thanks.  Patch updated and attached.  Are there any FreeBSD 3.X machines
still around that have pthread.h?

-- 
  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
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.253
diff -c -c -r1.253 configure.in
*** configure.in	22 May 2003 16:39:28 -0000	1.253
--- configure.in	26 May 2003 17:38:28 -0000
***************
*** 506,511 ****
--- 506,514 ----
                [  --without-zlib          do not use Zlib])
  
  
+ #
+ # Elf
+ #
  
  # Assume system is ELF if it predefines __ELF__ as 1,
  # otherwise believe host_os based default.
***************
*** 527,533 ****
--- 530,560 ----
  fi])
  AC_SUBST(ELF_SYS)
  
+ #
+ # Pthreads
+ #
  
+ AC_CHECK_HEADER(pthread.h,
+ 	[AC_DEFINE(HAVE_THREADS, 1, [Define to 1 if you have the threads interface.])])
+ if test ! -z "$HAVE_THREADS"
+ then	
+ 	case $host_os in
+ 		# BSD/OS and NetBSD require no special libraries or flags
+ 		netbsd*|bsdi*) ;;
+ 		freebsd4*) THREAD_CFLAGS="-pthread" ;;
+ 		freebsd*) THREAD_LIBS="-lc_r" ;;
+ 		linux*) THREAD_LIBS="-lpthread"
+ 			THREAD_CFLAGS="-D_REENTRANT" ;;
+ 	# other operating systems might fail because they have pthread.h but need
+ 	# special libs we don't know about yet.
+ 	esac
+ fi
+ AC_SUBST(THREAD_LIBS)
+ AC_SUBST(THREAD_CFLAGS)
+ 
+ #
+ # Assignments
+ #
  
  CPPFLAGS="$CPPFLAGS $INCLUDES"
  LDFLAGS="$LDFLAGS $LIBDIRS"
Index: src/Makefile.global.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/Makefile.global.in,v
retrieving revision 1.162
diff -c -c -r1.162 Makefile.global.in
*** src/Makefile.global.in	11 May 2003 20:50:53 -0000	1.162
--- src/Makefile.global.in	26 May 2003 17:38:31 -0000
***************
*** 152,157 ****
--- 152,160 ----
  TK_LIB_SPEC		= @TK_LIB_SPEC@
  TK_XINCLUDES		= @TK_XINCLUDES@
  
+ THREAD_CFLAGS		= @THREAD_CFLAGS@
+ THREAD_LIBS		= @THREAD_LIBS@
+ 
  have_docbook	= @have_docbook@
  DOCBOOKSTYLE	= @DOCBOOKSTYLE@
  COLLATEINDEX	= @COLLATEINDEX@
Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.47
diff -c -c -r1.47 pg_config.h.in
*** src/include/pg_config.h.in	22 May 2003 16:39:30 -0000	1.47
--- src/include/pg_config.h.in	26 May 2003 17:38:32 -0000
***************
*** 465,470 ****
--- 465,473 ----
  /* Define to 1 if you have the  header file. */
  #undef HAVE_TERMIOS_H
  
+ /* Define to 1 if you have the  header file. */
+ #undef HAVE_THREADS
+ 
  /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
     `HAVE_STRUCT_TM_TM_ZONE' instead. */
  #undef HAVE_TM_ZONE

Re: [HACKERS] ECPG thread-safety

От:
Rod Taylor <rbt@rbt.ca>
Дата:
Вложения:
On Mon, 2003-05-26 at 13:44, Bruce Momjian wrote:
> Rod Taylor wrote:
> -- Start of PGP signed section.
> > On Mon, 2003-05-26 at 13:06, Bruce Momjian wrote:
> > > Shridhar Daithankar wrote:
> > > > On Friday 28 March 2003 21:45, you wrote:
> > > > > For testing the library, I think it is enough to init an thread attr. like
> > > > > pthread_init_attr, that should be enough to test header and library.
> > > > 
> > > > And compiler flags, I forgot.. -pthread on freeBSD/gcc and -D_REENTRANT on 
> > > > linux at least. FreeBSD needs _THREAD_SAFE as well IIRC.
> > > 
> > > Are you saying FreeBSD actually has a -pthread compiler flag?  And Linux
> > > needs REENTRANT.  We can do that.  Here is an updated patch.  Of course,
> > > I need to run autoconf too.
> > 
> > If I'm not mistaken, you use -lpthread on FreeBSD 4.x, and -lc_r on
> > FreeBSD 5.x.
> 
> Thanks.  Patch updated and attached.  Are there any FreeBSD 3.X machines
> still around that have pthread.h?

You're more likely to run into a 2.x BSD box than a 3.x one :) Early
releases of 4.x were unusually good and very pain free for an upgrade
from 3.x.

I couldn't tell you about 3.x as I never did anything outside of
installing ports.
-- 
Rod Taylor 

PGP Key: http://www.rbt.ca/rbtpub.asc

Re: [HACKERS] ECPG thread-safety

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Rod Taylor wrote:
-- Start of PGP signed section.
> On Mon, 2003-05-26 at 13:44, Bruce Momjian wrote:
> > Rod Taylor wrote:
> > -- Start of PGP signed section.
> > > On Mon, 2003-05-26 at 13:06, Bruce Momjian wrote:
> > > > Shridhar Daithankar wrote:
> > > > > On Friday 28 March 2003 21:45, you wrote:
> > > > > > For testing the library, I think it is enough to init an thread attr. like
> > > > > > pthread_init_attr, that should be enough to test header and library.
> > > > > 
> > > > > And compiler flags, I forgot.. -pthread on freeBSD/gcc and -D_REENTRANT on 
> > > > > linux at least. FreeBSD needs _THREAD_SAFE as well IIRC.
> > > > 
> > > > Are you saying FreeBSD actually has a -pthread compiler flag?  And Linux
> > > > needs REENTRANT.  We can do that.  Here is an updated patch.  Of course,
> > > > I need to run autoconf too.
> > > 
> > > If I'm not mistaken, you use -lpthread on FreeBSD 4.x, and -lc_r on
> > > FreeBSD 5.x.
> > 
> > Thanks.  Patch updated and attached.  Are there any FreeBSD 3.X machines
> > still around that have pthread.h?
> 
> You're more likely to run into a 2.x BSD box than a 3.x one :) Early
> releases of 4.x were unusually good and very pain free for an upgrade
> from 3.x.
> 
> I couldn't tell you about 3.x as I never did anything outside of
> installing ports.

When did pthread.h appear in FreeBSD?

-- 
  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

Re: [HACKERS] ECPG thread-safety

От:
Rod Taylor <rbt@rbt.ca>
Дата:
Вложения:
On Mon, 2003-05-26 at 14:16, Bruce Momjian wrote:
> Rod Taylor wrote:
> -- Start of PGP signed section.
> > On Mon, 2003-05-26 at 13:44, Bruce Momjian wrote:
> > > Rod Taylor wrote:
> > > -- Start of PGP signed section.
> > > > On Mon, 2003-05-26 at 13:06, Bruce Momjian wrote:
> > > > > Shridhar Daithankar wrote:
> > > > > > On Friday 28 March 2003 21:45, you wrote:
> > > > > > > For testing the library, I think it is enough to init an thread attr. like
> > > > > > > pthread_init_attr, that should be enough to test header and library.
> > > > > > 
> > > > > > And compiler flags, I forgot.. -pthread on freeBSD/gcc and -D_REENTRANT on 
> > > > > > linux at least. FreeBSD needs _THREAD_SAFE as well IIRC.
> > > > > 
> > > > > Are you saying FreeBSD actually has a -pthread compiler flag?  And Linux
> > > > > needs REENTRANT.  We can do that.  Here is an updated patch.  Of course,
> > > > > I need to run autoconf too.
> > > > 
> > > > If I'm not mistaken, you use -lpthread on FreeBSD 4.x, and -lc_r on
> > > > FreeBSD 5.x.
> > > 
> > > Thanks.  Patch updated and attached.  Are there any FreeBSD 3.X machines
> > > still around that have pthread.h?
> > 
> > You're more likely to run into a 2.x BSD box than a 3.x one :) Early
> > releases of 4.x were unusually good and very pain free for an upgrade
> > from 3.x.
> > 
> > I couldn't tell you about 3.x as I never did anything outside of
> > installing ports.
> 
> When did pthread.h appear in FreeBSD?

2.2.0

-- 
Rod Taylor 

PGP Key: http://www.rbt.ca/rbtpub.asc

Re: [HACKERS] ECPG thread-safety

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Rod Taylor wrote:
> > > You're more likely to run into a 2.x BSD box than a 3.x one :) Early
> > > releases of 4.x were unusually good and very pain free for an upgrade
> > > from 3.x.
> > > 
> > > I couldn't tell you about 3.x as I never did anything outside of
> > > installing ports.
> > 
> > When did pthread.h appear in FreeBSD?
> 
> 2.2.0

OK, updated patch for FreeBSD 2-4.

-- 
  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
Index: configure.in
===================================================================
RCS file: /cvsroot/pgsql-server/configure.in,v
retrieving revision 1.253
diff -c -c -r1.253 configure.in
*** configure.in	22 May 2003 16:39:28 -0000	1.253
--- configure.in	26 May 2003 18:27:14 -0000
***************
*** 506,511 ****
--- 506,514 ----
                [  --without-zlib          do not use Zlib])
  
  
+ #
+ # Elf
+ #
  
  # Assume system is ELF if it predefines __ELF__ as 1,
  # otherwise believe host_os based default.
***************
*** 527,533 ****
--- 530,560 ----
  fi])
  AC_SUBST(ELF_SYS)
  
+ #
+ # Pthreads
+ #
  
+ AC_CHECK_HEADER(pthread.h,
+ 	[AC_DEFINE(HAVE_THREADS, 1, [Define to 1 if you have the threads interface.])])
+ if test ! -z "$HAVE_THREADS"
+ then	
+ 	case $host_os in
+ 		# BSD/OS and NetBSD require no special libraries or flags
+ 		netbsd*|bsdi*) ;;
+ 		freebsd2*|freebsd3*|freebsd4*) THREAD_CFLAGS="-pthread" ;;
+ 		freebsd*) THREAD_LIBS="-lc_r" ;;
+ 		linux*) THREAD_LIBS="-lpthread"
+ 			THREAD_CFLAGS="-D_REENTRANT" ;;
+ 	# other operating systems might fail because they have pthread.h but need
+ 	# special libs we don't know about yet.
+ 	esac
+ fi
+ AC_SUBST(THREAD_LIBS)
+ AC_SUBST(THREAD_CFLAGS)
+ 
+ #
+ # Assignments
+ #
  
  CPPFLAGS="$CPPFLAGS $INCLUDES"
  LDFLAGS="$LDFLAGS $LIBDIRS"
Index: src/Makefile.global.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/Makefile.global.in,v
retrieving revision 1.162
diff -c -c -r1.162 Makefile.global.in
*** src/Makefile.global.in	11 May 2003 20:50:53 -0000	1.162
--- src/Makefile.global.in	26 May 2003 18:27:16 -0000
***************
*** 152,157 ****
--- 152,160 ----
  TK_LIB_SPEC		= @TK_LIB_SPEC@
  TK_XINCLUDES		= @TK_XINCLUDES@
  
+ THREAD_CFLAGS		= @THREAD_CFLAGS@
+ THREAD_LIBS		= @THREAD_LIBS@
+ 
  have_docbook	= @have_docbook@
  DOCBOOKSTYLE	= @DOCBOOKSTYLE@
  COLLATEINDEX	= @COLLATEINDEX@
Index: src/include/pg_config.h.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v
retrieving revision 1.47
diff -c -c -r1.47 pg_config.h.in
*** src/include/pg_config.h.in	22 May 2003 16:39:30 -0000	1.47
--- src/include/pg_config.h.in	26 May 2003 18:27:19 -0000
***************
*** 465,470 ****
--- 465,473 ----
  /* Define to 1 if you have the  header file. */
  #undef HAVE_TERMIOS_H
  
+ /* Define to 1 if you have the threads interface. */
+ #undef HAVE_THREADS
+ 
  /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
     `HAVE_STRUCT_TM_TM_ZONE' instead. */
  #undef HAVE_TM_ZONE
FAQ