[HACKERS] s_lock.h cleanup

2001-01-18 Thread Bruce Momjian

In looking at the VAX ASM problem, I realized that the ASM in s_lock.h
is all formatted differently, making it even more confusing.  I have
applied the following patch to s_lock.h to try and clean it up.

The new standard format is:

/*
 * Standard __asm__ format:
 *
 *  __asm__(
 *  "command;"
 *  "command;"
 *  "command;"
 *  :   "=r"(_res)  return value, in register
 *  :   "r"(lock)   argument, 'lock pointer', in register
 *  :   "r0");  inline code uses this register
 */

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026


? config.log
? config.cache
? config.status
? GNUmakefile
? src/Makefile.custom
? src/GNUmakefile
? src/Makefile.global
? src/log
? src/crtags
? src/backend/postgres
? src/backend/catalog/global.bki
? src/backend/catalog/global.description
? src/backend/catalog/template1.bki
? src/backend/catalog/template1.description
? src/backend/port/Makefile
? src/bin/initdb/initdb
? src/bin/initlocation/initlocation
? src/bin/ipcclean/ipcclean
? src/bin/pg_config/pg_config
? src/bin/pg_ctl/pg_ctl
? src/bin/pg_dump/pg_dump
? src/bin/pg_dump/pg_restore
? src/bin/pg_dump/pg_dumpall
? src/bin/pg_id/pg_id
? src/bin/pg_passwd/pg_passwd
? src/bin/pgaccess/pgaccess
? src/bin/pgtclsh/Makefile.tkdefs
? src/bin/pgtclsh/Makefile.tcldefs
? src/bin/pgtclsh/pgtclsh
? src/bin/pgtclsh/pgtksh
? src/bin/psql/psql
? src/bin/scripts/createlang
? src/include/config.h
? src/include/stamp-h
? src/interfaces/ecpg/lib/libecpg.so.3.2.0
? src/interfaces/ecpg/preproc/ecpg
? src/interfaces/libpgeasy/libpgeasy.so.2.1
? src/interfaces/libpgtcl/libpgtcl.so.2.1
? src/interfaces/libpq/libpq.so.2.1
? src/interfaces/perl5/blib
? src/interfaces/perl5/Makefile
? src/interfaces/perl5/pm_to_blib
? src/interfaces/perl5/Pg.c
? src/interfaces/perl5/Pg.bs
? src/pl/plperl/blib
? src/pl/plperl/Makefile
? src/pl/plperl/pm_to_blib
? src/pl/plperl/SPI.c
? src/pl/plperl/plperl.bs
? src/pl/plpgsql/src/libplpgsql.so.1.0
? src/pl/tcl/Makefile.tcldefs
Index: src/include/storage/s_lock.h
===
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/include/storage/s_lock.h,v
retrieving revision 1.78
diff -c -r1.78 s_lock.h
*** src/include/storage/s_lock.h2001/01/18 23:40:26 1.78
--- src/include/storage/s_lock.h2001/01/19 02:52:49
***
*** 35,41 
   *
   *int TAS(slock_t *lock)
   *Atomic test-and-set instruction.  Attempt to acquire the lock,
!  *but do *not* wait.  Returns 0 if successful, nonzero if unable
   *to acquire the lock.
   *
   *TAS() is a lower-level part of the API, but is used directly in a
--- 35,41 
   *
   *int TAS(slock_t *lock)
   *Atomic test-and-set instruction.  Attempt to acquire the lock,
!  *but do *not* wait.  Returns 0 if successful, nonzero if unable
   *to acquire the lock.
   *
   *TAS() is a lower-level part of the API, but is used directly in a
***
*** 48,56 
   *unsignedspins = 0;
   *
   *while (TAS(lock))
-  *{
   *S_LOCK_SLEEP(lock, spins++);
-  *}
   *}
   *
   *where S_LOCK_SLEEP() checks for timeout and sleeps for a short
--- 48,54 
***
*** 87,96 
  
  /* Platform-independent out-of-line support routines */
  extern void s_lock(volatile slock_t *lock,
!  const char *file, const int line);
  extern void s_lock_sleep(unsigned spins, int microsec,
!volatile slock_t *lock,
!const char *file, const int line);
  
  
  #if defined(HAS_TEST_AND_SET)
--- 85,94 
  
  /* Platform-independent out-of-line support routines */
  extern void s_lock(volatile slock_t *lock,
!  const char *file, const int line);
  extern void s_lock_sleep(unsigned spins, int microsec,
!volatile slock_t *lock,
!const char *file, const int line);
  
  
  #if defined(HAS_TEST_AND_SET)
***
*** 101,106 
--- 99,116 
   * All the gcc inlines
   */
  
+ /*
+  * Standard __asm__ format:
+  *
+  *__asm__(
+  *"command;"
+  *"command;"
+  *"command;"
+  *:   "=r"(_res)  return value, in register
+  *:   "r"(lock)   argument, 'lock pointer', in 
+register
+  *:   "r0");  inline code uses this register
+  */
+ 
  
  #if 

Re: [HACKERS] s_lock.h cleanup

2001-01-18 Thread Tom Lane

As long as we're cleaning things up, I would suggest that all the ports
that use gcc assembler be made to declare it uniformly, as

__asm__ __volatile__ ( ... );

As I read the GCC manual, there's some risk of the asm sections getting
moved around in the program flow if they are not marked volatile.  Also
we oughta be consistent about using the double-underscore keywords IMHO.

regards, tom lane



Re: [HACKERS] s_lock.h cleanup

2001-01-18 Thread Bruce Momjian

Done and applied.

 As long as we're cleaning things up, I would suggest that all the ports
 that use gcc assembler be made to declare it uniformly, as
 
   __asm__ __volatile__ ( ... );
 
 As I read the GCC manual, there's some risk of the asm sections getting
 moved around in the program flow if they are not marked volatile.  Also
 we oughta be consistent about using the double-underscore keywords IMHO.
 
   regards, tom lane
 


-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026