[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Seeking help with porting postgresql+gcc 4 to MIPS



Martin Pitt wrote:
> Hi Aurelien!
> 
> Aurelien Jarno [2005-08-18  0:36 +0200]:
> > As I am only a Debian developer with a mips machine, I can't install
> > those packages. However, I have found the problem from postgresql-7.4.
> > You will find attached a patch to fix it. Basically the problems comes
> > from the -funit-at-a-time option which is now enabled by default by gcc
> > with the -O2 option. Here is a part of the manpage:
> 
> Argh, tricky. Thanks a lot for finding that out! 
> 
> > My patch fixes that by passing the -fno-unit-at-a-time option when 
> > building s_lock.c. A proper fix would be to write inline code that will
> > go to s_lock.h, but I don't have enough knowledge in the mips assembly
> > to write such a code.
> 
> That patch is already much better than my gcc 3.3 workaround, so I'll
> apply it in the next upload. Now that we know the source of the problem,
> I'll prod upstream about it.

The appended patch seems to work for 7.4.8.

> > For postgresql-8.0, I suppose the problem is the same, I'll have a look
> > tomorrow.
> 
> Certainly, the locking code didn't change significantly.

Then I guess it's also ok for 8.0.


Thiemo


--- postgresql-7.4.8/src/include/storage/s_lock.h.old	2005-08-18 09:08:06.000000000 +0200
+++ postgresql-7.4.8/src/include/storage/s_lock.h	2005-08-18 09:21:25.000000000 +0200
@@ -361,6 +361,33 @@ tas(volatile slock_t *lock)
 #endif	 /* NEED_NS32K_TAS_ASM */
 
 
+#if defined(__mips__) && defined(__linux__)
+#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));
+	return __r;
+}
+
+#endif /* mips */
+
 
 #else							/* !__GNUC__ */
 
--- postgresql-7.4.8/src/backend/storage/lmgr/s_lock.c.old	2003-08-08 23:42:00.000000000 +0200
+++ postgresql-7.4.8/src/backend/storage/lmgr/s_lock.c	2005-08-18 09:21:09.000000000 +0200
@@ -148,7 +148,7 @@ _success:						\n\
 }
 #endif   /* __m68k__ */
 
-#if defined(__mips__) && !defined(__sgi)
+#if defined(__mips__) && !defined(__sgi) && !defined(__linux__)
 static void
 tas_dummy()
 {

Attachment: signature.asc
Description: Digital signature


Reply to: