From 8d25436d70a0e5f286a48cf60f4ad3899251eff9 Mon Sep 17 00:00:00 2001 From: Bruce Momjian <bruce@momjian.us> Date: Tue, 29 Jul 1997 14:09:11 +0000 Subject: [PATCH] mkLinux patches from Tatsuo Ishii. --- src/backend/storage/ipc/s_lock.c | 42 +++++++++++++++++++++++++++++++- src/backend/utils/adt/dt.c | 29 +++++++++++++++++++++- src/include/port/linux.h | 15 +++++++++--- src/include/utils/dt.h | 12 ++++++++- src/interfaces/libpq/Makefile | 3 ++- src/makefiles/Makefile.linux | 2 +- src/test/regress/GNUmakefile | 4 +-- 7 files changed, 97 insertions(+), 10 deletions(-) diff --git a/src/backend/storage/ipc/s_lock.c b/src/backend/storage/ipc/s_lock.c index 449b34d12c7..de9b8689f09 100644 --- a/src/backend/storage/ipc/s_lock.c +++ b/src/backend/storage/ipc/s_lock.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.14 1997/06/06 01:37:14 scrappy Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.15 1997/07/29 14:07:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -521,5 +521,45 @@ S_INIT_LOCK(slock_t *lock) #endif /* NEED_NS32K_TAS_ASM */ +#if defined(linux) && defined(PPC) + +static int tas_dummy() +{ + __asm__(" +tas: /* r3 points to the location of p */ + lwarx 5,0,3 /* r5 = *p */ + cmpwi 5,0 /* r5 == 0 ? */ + bne fail /* if not 0, jump to fail */ + addi 5,5,1 /* set 1 to r5 */ + stwcx. 5,0,3 /* try update p atomically */ + beq success /* jump if scceed */ +fail: li 3,1 /* set 1 to r3 */ + blr +success: + li 3,0 /* set 0 to r3 */ + blr + "); +} + +void +S_LOCK(slock_t *lock) +{ + while (tas(lock)) + ; +} + +void +S_UNLOCK(slock_t *lock) +{ + *lock = 0; +} + +void +S_INIT_LOCK(slock_t *lock) +{ + S_UNLOCK(lock); +} + +#endif /* defined(linux) && defined(PPC) */ #endif /* HAS_TEST_AND_SET */ diff --git a/src/backend/utils/adt/dt.c b/src/backend/utils/adt/dt.c index 4c45d85753c..bf4bb3feb83 100644 --- a/src/backend/utils/adt/dt.c +++ b/src/backend/utils/adt/dt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.29 1997/07/24 20:15:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.30 1997/07/29 14:07:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -3758,3 +3758,30 @@ printf( "EncodeTimeSpan- result is %s\n", str); return 0; } /* EncodeTimeSpan() */ + + +#if defined(linux) && defined(PPC) +int datetime_is_epoch(double j) +{ + static union { + double epoch; + unsigned char c[8]; + } u; + + u.c[0] = 0x80; /* sign bit */ + u.c[1] = 0x10; /* DBL_MIN */ + + return(j == u.epoch); +} +int datetime_is_current(double j) +{ + static union { + double current; + unsigned char c[8]; + } u; + + u.c[1] = 0x10; /* DBL_MIN */ + + return(j == u.current); +} +#endif diff --git a/src/include/port/linux.h b/src/include/port/linux.h index 7735f3ab0fd..261ce240a5f 100644 --- a/src/include/port/linux.h +++ b/src/include/port/linux.h @@ -7,11 +7,20 @@ # define JMP_BUF # define USE_POSIX_TIME # define USE_POSIX_SIGNALS -# if !defined(PPC) -# define NEED_I386_TAS_ASM -# define HAS_TEST_AND_SET +# define NEED_I386_TAS_ASM +# define HAS_TEST_AND_SET + +# if defined(PPC) + typedef unsigned int slock_t; +# else typedef unsigned char slock_t; # endif + +# if defined(PPC) +# undef NEED_I386_TAS_ASM +# undef HAVE_INT_TIMEZONE +# endif + # if defined(sparc) # undef NEED_I386_TAS_ASM # endif diff --git a/src/include/utils/dt.h b/src/include/utils/dt.h index 1de22f70df2..edf9715f931 100644 --- a/src/include/utils/dt.h +++ b/src/include/utils/dt.h @@ -8,7 +8,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dt.h,v 1.13 1997/07/01 00:25:30 thomas Exp $ + * $Id: dt.h,v 1.14 1997/07/29 14:08:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -215,10 +215,20 @@ typedef struct { #define DATETIME_IS_NOEND(j) (j == DT_NOEND) #define DATETIME_CURRENT(j) {j = DT_CURRENT;} +#if defined(linux) && defined(PPC) +extern int datetime_is_current(double j); +#define DATETIME_IS_CURRENT(j) datetime_is_current(j) +#else #define DATETIME_IS_CURRENT(j) (j == DT_CURRENT) +#endif #define DATETIME_EPOCH(j) {j = DT_EPOCH;} +#if defined(linux) && defined(PPC) +extern int datetime_is_epoch(double j); +#define DATETIME_IS_EPOCH(j) datetime_is_epoch(j) +#else #define DATETIME_IS_EPOCH(j) (j == DT_EPOCH) +#endif #define DATETIME_IS_RELATIVE(j) (DATETIME_IS_CURRENT(j) || DATETIME_IS_EPOCH(j)) #define DATETIME_NOT_FINITE(j) (DATETIME_IS_INVALID(j) \ diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile index c9a095de77b..32510ddf883 100644 --- a/src/interfaces/libpq/Makefile +++ b/src/interfaces/libpq/Makefile @@ -7,7 +7,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.35 1997/04/04 10:42:34 scrappy Exp $ +# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.36 1997/07/29 14:08:34 momjian Exp $ # #------------------------------------------------------------------------- @@ -34,6 +34,7 @@ ifeq ($(PORTNAME), linux) install-shlib-dep := install-shlib shlib := libpq.so.1 LDFLAGS_SL = -shared + CFLAGS += $(CFLAGS_SL) endif endif ifeq ($(PORTNAME), BSD44_derived) diff --git a/src/makefiles/Makefile.linux b/src/makefiles/Makefile.linux index 528423701c0..7179f0b0ad6 100644 --- a/src/makefiles/Makefile.linux +++ b/src/makefiles/Makefile.linux @@ -1,5 +1,5 @@ ifdef LINUX_ELF -LDFLAGS+= -rdynamic -Wl,-rpath -Wl,$(DESTDIR)$(LIBDIR) +LDFLAGS+= -export-dynamic -Wl,-rpath -Wl,$(DESTDIR)$(LIBDIR) endif MK_NO_LORDER= true diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile index 9f26ab11b14..6cab363a6e4 100644 --- a/src/test/regress/GNUmakefile +++ b/src/test/regress/GNUmakefile @@ -7,14 +7,14 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.8 1997/06/06 01:35:57 scrappy Exp $ +# $Header: /cvsroot/pgsql/src/test/regress/GNUmakefile,v 1.9 1997/07/29 14:09:11 momjian Exp $ # #------------------------------------------------------------------------- SRCDIR= ../.. include ../../Makefile.global -CFLAGS+= -I$(LIBPQDIR) -I../../include +CFLAGS+= -I$(LIBPQDIR) -I../../include $(CFLAGS_SL) LDADD+= -L$(LIBPQDIR) -lpq -- GitLab