0001-AIX-support.tas.memset.diffs

application/octet-stream

Filename: 0001-AIX-support.tas.memset.diffs
Type: application/octet-stream
Part: 0
Message: RE: AIX support
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 5da9b3acda4..ba120c08d14 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -398,54 +398,18 @@ typedef unsigned int slock_t;

 #define TAS(lock) tas(lock)

-/* On PPC, it's a win to use a non-locking test before the lwarx */
+/* On PPC, use the compiler provided Built-in functions for atomic memory
+ * exchange operations.
+ */
 #define TAS_SPIN(lock) (*(lock) ? 1 : TAS(lock))

-/*
- * The second operand of addi can hold a constant zero or a register number,
- * hence constraint "=&b" to avoid allocating r0.  "b" stands for "address
- * base register"; most operands having this register-or-zero property are
- * address bases, e.g. the second operand of lwax.
- *
- * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
- * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
- * But if the spinlock is in ordinary memory, we can use lwsync instead for
- * better performance.
- */
 static __inline__ int
 tas(volatile slock_t *lock)
 {
-       slock_t _t;
-       int _res;
-
-       __asm__ __volatile__(
-"      lwarx   %0,0,%3,1       \n"
-"      cmpwi   %0,0            \n"
-"      bne     $+16            \n"             /* branch to li %1,1 */
-"      addi    %0,%0,1         \n"
-"      stwcx.  %0,0,%3         \n"
-"      beq     $+12            \n"             /* branch to lwsync */
-"      li      %1,1            \n"
-"      b       $+12            \n"             /* branch to end of asm sequence */
-"      lwsync                          \n"
-"      li      %1,0            \n"
-
-:      "=&b"(_t), "=r"(_res), "+m"(*lock)
-:      "r"(lock)
-:      "memory", "cc");
-       return _res;
+       return __sync_lock_test_and_set(lock, 1);
 }

-/*
- * PowerPC S_UNLOCK is almost standard but requires a "sync" instruction.
- * But we can use lwsync instead for better performance.
- */
-#define S_UNLOCK(lock) \
-do \
-{ \
-       __asm__ __volatile__ (" lwsync \n" ::: "memory"); \
-       *((volatile slock_t *) (lock)) = 0; \
-} while (0)
+#define S_UNLOCK(lock) __sync_lock_release(lock)

 #endif /* powerpc */

diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
index ab6581533d8..4c4de8b0be7 100644
--- a/src/makefiles/Makefile.aix
+++ b/src/makefiles/Makefile.aix
@@ -1,3 +1,8 @@
+# -blibpath:
+# The path to be inserted into the default path (Index 0 path) field of the
+# loader section. When this flag is presented, the -L paths will not be stored.
+# AIX uses a stricter, more explicit approach. The runtime linker expects to
+# tell it exactly where to look using -blibpath.
 # -blibpath must contain ALL directories where we should look for libraries
 libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/usr/lib:/lib

diff --git a/src/template/aix b/src/template/aix
index 48a3ce55cf7..ea7f7fb3487 100644
--- a/src/template/aix
+++ b/src/template/aix
@@ -1,7 +1,8 @@
+# This file is referred for specific flags wrt to AIX build process like
+# cflags.
 # src/template/aix

 # Extra CFLAGS for code that will go into a shared library
-CFLAGS_SL=""
+# With optimization, the MemSet() and MemSetAlign() perform better.
+CFLAGS_SL=" -O2 "

-# Native memset() is faster.
-MEMSET_LOOP_LIMIT=0