From 54ffd4677aaf56e928af9e3f689297d6c06d1fe9 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 23 Nov 1999 19:47:14 +0000 Subject: [PATCH] ecpg ECPGFree fix from Rene Hogendoorn. --- src/include/storage/s_lock.h | 91 ++++++++++++++------------- src/interfaces/ecpg/preproc/preproc.y | 2 +- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index e23e2076e4..fd9d1dbf85 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.66 1999/11/18 21:47:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.67 1999/11/23 19:47:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,35 +78,6 @@ extern void s_lock_sleep(unsigned spin); * All the gcc inlines */ -#if defined(__alpha__) -#define TAS(lock) tas(lock) -#define S_UNLOCK(lock) { __asm__("mb"); *(lock) = 0; } - -static __inline__ int -tas(volatile slock_t *lock) -{ - register slock_t _res; - -__asm__(" ldq $0, %0 \n\ - bne $0, 3f \n\ - ldq_l $0, %0 \n\ - bne $0, 3f \n\ - or $31, 1, $0 \n\ - stq_c $0, %0 \n\ - beq $0, 2f \n\ - bis $31, $31, %1 \n\ - mb \n\ - jmp $31, 4f \n\ - 2: or $31, 1, $0 \n\ - 3: bis $0, $0, %1 \n\ - 4: nop ": "=m"(*lock), "=r"(_res): :"0"); - - return (int) _res; -} - -#endif /* __alpha__ */ - - #if defined(__i386__) #define TAS(lock) tas(lock) @@ -226,20 +197,6 @@ tas(volatile slock_t *lock) * All non gcc */ -#if defined(__alpha__) -/* - * OSF/1 (Alpha AXP) - * - * Note that slock_t on the Alpha AXP is msemaphore instead of char - * (see storage/ipc.h). - */ -#define TAS(lock) (msem_lock((lock), MSEM_IF_NOWAIT) < 0) -#define S_UNLOCK(lock) msem_unlock((lock), 0) -#define S_INIT_LOCK(lock) msem_init((lock), MSEM_UNLOCKED) -#define S_LOCK_FREE(lock) (!(lock)->msem_state) -#endif /* __alpha__ */ - - #if defined(NEED_I386_TAS_ASM) /* non gcc i386 based things */ @@ -272,6 +229,52 @@ tas(slock_t *s_lock) * These are the platforms that have common code for gcc and non-gcc */ + +#if defined(__alpha) + +#if defined(__osf__) +/* + * OSF/1 (Alpha AXP) + * + * Note that slock_t on the Alpha AXP is msemaphore instead of char + * (see storage/ipc.h). + */ +#define TAS(lock) (msem_lock((lock), MSEM_IF_NOWAIT) < 0) +#define S_UNLOCK(lock) msem_unlock((lock), 0) +#define S_INIT_LOCK(lock) msem_init((lock), MSEM_UNLOCKED) +#define S_LOCK_FREE(lock) (!(lock)->msem_state) + +#else /* i.e. not __osf__ */ + +#define TAS(lock) tas(lock) +#define S_UNLOCK(lock) { __asm__("mb"); *(lock) = 0; } + +static __inline__ int +tas(volatile slock_t *lock) +{ + register slock_t _res; + +__asm__(" ldq $0, %0 \n\ + bne $0, 3f \n\ + ldq_l $0, %0 \n\ + bne $0, 3f \n\ + or $31, 1, $0 \n\ + stq_c $0, %0 \n\ + beq $0, 2f \n\ + bis $31, $31, %1 \n\ + mb \n\ + jmp $31, 4f \n\ + 2: or $31, 1, $0 \n\ + 3: bis $0, $0, %1 \n\ + 4: nop ": "=m"(*lock), "=r"(_res): :"0"); + + return (int) _res; +} +#endif /* __osf__ */ + +#endif /* __alpha */ + + #if defined(__hpux) /* * HP-UX (PA-RISC) diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y index eb7e79fac8..0d52ec6fe6 100644 --- a/src/interfaces/ecpg/preproc/preproc.y +++ b/src/interfaces/ecpg/preproc/preproc.y @@ -969,7 +969,7 @@ stmt: AddAttrStmt { output_statement($1, 0); } output_statement($1, 0); } | ECPGFree { - fprintf(yyout, "{ ECPGdeallocate(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1); + fprintf(yyout, "{ ECPGdeallocate(__LINE__, \"%s\");", $1); whenever_action(2); free($1); }