From 2f1bf94956d3fe3e668d961403094aa32964d7c1 Mon Sep 17 00:00:00 2001 From: Dan McDonald Date: Thu, 11 Feb 2021 11:18:55 -0500 Subject: OS-8267 New ksh93 breaks gcc4 build Reviewed by: Jason King Approved by: Jason King --- usr/src/cmd/ast/libast/amd64/FEATURE/aso | 28 ++++++++++++++++++++++++++++ usr/src/cmd/ast/libast/i386/FEATURE/aso | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/usr/src/cmd/ast/libast/amd64/FEATURE/aso b/usr/src/cmd/ast/libast/amd64/FEATURE/aso index 8baa447c72..af56c08611 100644 --- a/usr/src/cmd/ast/libast/amd64/FEATURE/aso +++ b/usr/src/cmd/ast/libast/amd64/FEATURE/aso @@ -2,6 +2,33 @@ #ifndef _def_aso_ast #define _def_aso_ast 1 #define _sys_types 1 /* #include ok */ + +/* + * This is horrible, but since SmartOS still compiles with gcc4 in its + * Jenkins pipeline (and for building modern smartos on older systems), + * we need to use sparc-style workaround for the illumos gcc4 compiler. + */ +#if defined (__GNUC__) && (__GNUC__ == 4) +/* atomic_cas_64 */ +#include +#define _aso_cas8(p,o,n) atomic_cas_8(p,o,n) +#define _aso_inc8(p) (atomic_add_8_nv(p,1)-1) +#define _aso_dec8(p) (atomic_add_8_nv(p,-1)+1) +#define _aso_cas16(p,o,n) atomic_cas_16(p,o,n) +#define _aso_inc16(p) (atomic_add_16_nv(p,1)-1) +#define _aso_dec16(p) (atomic_add_16_nv(p,-1)+1) +#define _aso_cas32(p,o,n) atomic_cas_32(p,o,n) +#define _aso_inc32(p) (atomic_add_32_nv(p,1)-1) +#define _aso_dec32(p) (atomic_add_32_nv(p,-1)+1) +#define _aso_cas64(p,o,n) atomic_cas_64(p,o,n) +#define _aso_inc64(p) (atomic_add_64_nv(p,1)-1) +#define _aso_dec64(p) (atomic_add_64_nv(p,-1)+1) +#if _ast_sizeof_pointer == 8 +#define _aso_casptr(p,o,n) ((void*)atomic_cas_64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) +#else +#define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) +#endif +#else /* illumos-gcc4 */ /* gcc 4.1+ 64 bit memory atomic operations model */ #define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n) #define _aso_inc8(p) __sync_fetch_and_add(p,1) @@ -20,5 +47,6 @@ #else #define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint32_t)o,(uint32_t)n)) #endif +#endif /* illumos-gcc4 */ #endif diff --git a/usr/src/cmd/ast/libast/i386/FEATURE/aso b/usr/src/cmd/ast/libast/i386/FEATURE/aso index 8baa447c72..af56c08611 100644 --- a/usr/src/cmd/ast/libast/i386/FEATURE/aso +++ b/usr/src/cmd/ast/libast/i386/FEATURE/aso @@ -2,6 +2,33 @@ #ifndef _def_aso_ast #define _def_aso_ast 1 #define _sys_types 1 /* #include ok */ + +/* + * This is horrible, but since SmartOS still compiles with gcc4 in its + * Jenkins pipeline (and for building modern smartos on older systems), + * we need to use sparc-style workaround for the illumos gcc4 compiler. + */ +#if defined (__GNUC__) && (__GNUC__ == 4) +/* atomic_cas_64 */ +#include +#define _aso_cas8(p,o,n) atomic_cas_8(p,o,n) +#define _aso_inc8(p) (atomic_add_8_nv(p,1)-1) +#define _aso_dec8(p) (atomic_add_8_nv(p,-1)+1) +#define _aso_cas16(p,o,n) atomic_cas_16(p,o,n) +#define _aso_inc16(p) (atomic_add_16_nv(p,1)-1) +#define _aso_dec16(p) (atomic_add_16_nv(p,-1)+1) +#define _aso_cas32(p,o,n) atomic_cas_32(p,o,n) +#define _aso_inc32(p) (atomic_add_32_nv(p,1)-1) +#define _aso_dec32(p) (atomic_add_32_nv(p,-1)+1) +#define _aso_cas64(p,o,n) atomic_cas_64(p,o,n) +#define _aso_inc64(p) (atomic_add_64_nv(p,1)-1) +#define _aso_dec64(p) (atomic_add_64_nv(p,-1)+1) +#if _ast_sizeof_pointer == 8 +#define _aso_casptr(p,o,n) ((void*)atomic_cas_64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) +#else +#define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) +#endif +#else /* illumos-gcc4 */ /* gcc 4.1+ 64 bit memory atomic operations model */ #define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n) #define _aso_inc8(p) __sync_fetch_and_add(p,1) @@ -20,5 +47,6 @@ #else #define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint32_t)o,(uint32_t)n)) #endif +#endif /* illumos-gcc4 */ #endif -- cgit v1.2.3