Re: gcc 4.0 build failures on m68k, mips, and mipsel - Mailing list pgsql-ports

From Tom Lane
Subject Re: gcc 4.0 build failures on m68k, mips, and mipsel
Date
Msg-id 331.1124990629@sss.pgh.pa.us
Whole thread Raw
In response to Re: gcc 4.0 build failures on m68k, mips, and mipsel  (Martin Pitt <martin@piware.de>)
List pgsql-ports
Martin Pitt <martin@piware.de> writes:
>>> However, Thiemo Seufer dealt with this and created a proper tas()
>>> function for PostgreSQL on mips, which also works with gcc 4. Of
>>> course this is much better, so I applied his patch in Debian.
>>> I attach the patch. Do you consider applying it upstream?
>>
>> Hm, does this patch actually compile as-is?  I'd think you'd need to
>> have the MIPS definition of slock_t placed earlier than the assembly
>> code fragment.

> I attach the updated patch against 8.0.

OK, better, but I think not quite there yet.  AFAICS the s_lock.c code
should simply go away, as there are no platforms for which it'd be used.
Also, the constraints for the inline assembler ought to include memory
and cc clobbers, according to the comments near the head of s_lock.h.
I've applied the attached modified patch to CVS HEAD, but can't test it
without a MIPS machine ... could you double-check it?

            regards, tom lane

*** src/backend/storage/lmgr/s_lock.c.orig    Fri Jul 29 23:07:40 2005
--- src/backend/storage/lmgr/s_lock.c    Thu Aug 25 13:14:27 2005
***************
*** 172,205 ****
  #endif   /* __m68k__ */


- #if defined(__mips__) && !defined(__sgi)
- static void
- tas_dummy()
- {
-     __asm__        __volatile__(
-                                          "\
- .global    tas                        \n\
- tas:                            \n\
-             .frame    $sp, 0, $31    \n\
-             .set push        \n\
-             .set mips2        \n\
-             ll        $14, 0($4)    \n\
-             or        $15, $14, 1    \n\
-             sc        $15, 0($4)    \n\
-             .set pop            \n\
-             beq        $15, 0, fail\n\
-             bne        $14, 0, fail\n\
-             li        $2, 0        \n\
-             .livereg 0x2000FF0E,0x00000FFF    \n\
-             j        $31            \n\
- fail:                            \n\
-             li        $2, 1        \n\
-             j       $31            \n\
- ");
- }
- #endif   /* __mips__ && !__sgi */
-
-
  #else                            /* not __GNUC__ */

  /*
--- 172,177 ----
*** src/include/storage/s_lock.h.orig    Thu Mar 10 16:41:01 2005
--- src/include/storage/s_lock.h    Thu Aug 25 13:14:21 2005
***************
*** 453,472 ****
  #endif /* __alpha || __alpha__ */


! /* These live in s_lock.c, but only for gcc */


! #if defined(__m68k__)
! #define HAS_TEST_AND_SET

! typedef unsigned char slock_t;
! #endif


! #if defined(__mips__) && !defined(__sgi)
  #define HAS_TEST_AND_SET

! typedef unsigned int slock_t;
  #endif


--- 453,500 ----
  #endif /* __alpha || __alpha__ */


! #if defined(__mips__) && !defined(__sgi)
! /* Note: on SGI we use the OS' mutex ABI, see below */
! #define HAS_TEST_AND_SET

+ typedef unsigned int slock_t;

! #define TAS(lock) tas(lock)

! static __inline__ int
! tas(volatile slock_t *lock)
! {
!     register volatile slock_t *__l = lock;
!     register int __r;
!
!     __asm__ __volatile__(
!         "       .set push           \n"
!         "       .set mips2          \n"
!         "       .set noreorder      \n"
!         "       .set nomacro        \n"
!         "1:     ll      %0, %1      \n"
!         "       bne     %0, $0, 1f  \n"
!         "        xori   %0, 1       \n"
!         "       sc      %0, %1      \n"
!         "       beq     %0, $0, 1b  \n"
!         "        sync               \n"
!         "1:     .set pop              "
! :        "=&r" (__r), "+R" (*__l)
! :
! :        "memory", "cc");
!     return __r;
! }

+ #endif /* __mips__ && !__sgi */

!
! /* These live in s_lock.c, but only for gcc */
!
!
! #if defined(__m68k__)
  #define HAS_TEST_AND_SET

! typedef unsigned char slock_t;
  #endif



pgsql-ports by date:

Previous
From: Martin Pitt
Date:
Subject: Re: gcc 4.0 build failures on m68k, mips, and mipsel
Next
From: tzacos
Date:
Subject: compiling problem