mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Added extra checks of 64-bit atomic support on GCC and Solaris, also added 64-bit support in solaris.h which was missing
This commit is contained in:
parent
4e8d1c6bf3
commit
3ad70924c9
2 changed files with 66 additions and 1 deletions
21
configure.in
21
configure.in
|
@ -1889,6 +1889,7 @@ AC_CACHE_CHECK([whether the compiler provides atomic builtins],
|
|||
],
|
||||
[[
|
||||
int foo= -10; int bar= 10;
|
||||
long long int foo64= -10; long long int bar64= 10;
|
||||
if (!__sync_fetch_and_add(&foo, bar) || foo)
|
||||
return -1;
|
||||
bar= __sync_lock_test_and_set(&foo, bar);
|
||||
|
@ -1897,6 +1898,14 @@ AC_CACHE_CHECK([whether the compiler provides atomic builtins],
|
|||
bar= __sync_val_compare_and_swap(&bar, foo, 15);
|
||||
if (bar)
|
||||
return -1;
|
||||
if (!__sync_fetch_and_add(&foo64, bar64) || foo64)
|
||||
return -1;
|
||||
bar64= __sync_lock_test_and_set(&foo64, bar64);
|
||||
if (bar64 || foo64 != 10)
|
||||
return -1;
|
||||
bar64= __sync_val_compare_and_swap(&bar64, foo, 15);
|
||||
if (bar64)
|
||||
return -1;
|
||||
return 0;
|
||||
]]
|
||||
)],
|
||||
|
@ -1918,6 +1927,7 @@ AC_CACHE_CHECK([whether the OS provides atomic_* functions like Solaris],
|
|||
]
|
||||
[[
|
||||
int foo = -10; int bar = 10;
|
||||
int64_t foo64 = -10; int64_t bar64 = 10;
|
||||
if (atomic_add_int_nv((uint_t *)&foo, bar) || foo)
|
||||
return -1;
|
||||
bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar);
|
||||
|
@ -1926,6 +1936,17 @@ AC_CACHE_CHECK([whether the OS provides atomic_* functions like Solaris],
|
|||
bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15);
|
||||
if (bar)
|
||||
return -1;
|
||||
if (atomic_add_64_nv((volatile uint64_t *)&foo64, bar64) || foo64)
|
||||
return -1;
|
||||
bar64 = atomic_swap_64((volatile uint64_t *)&foo64, (uint64_t)bar64);
|
||||
if (bar64 || foo64 != 10)
|
||||
return -1;
|
||||
bar64 = atomic_cas_64((volatile uint64_t *)&bar64, (uint_t)foo64, 15);
|
||||
if (bar64)
|
||||
return -1;
|
||||
foo64 = atomic_or_64((volatile uint64_t *)&bar64, 0);
|
||||
if (foo64)
|
||||
return -1;
|
||||
return 0;
|
||||
]]
|
||||
)],
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2008 MySQL AB
|
||||
/* Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -60,6 +60,18 @@ my_atomic_cas32(int32 volatile *a, int32 *cmp, int32 set)
|
|||
return ret;
|
||||
}
|
||||
|
||||
STATIC_INLINE int
|
||||
my_atomic_cas64(int64 volatile *a, int64 *cmp, int64 set)
|
||||
{
|
||||
int ret;
|
||||
int64 sav;
|
||||
sav = (int64) atomic_cas_64((volatile uint64_t *)a, (uint64_t)*cmp,
|
||||
(uint64_t)set);
|
||||
if (! (ret = (sav == *cmp)))
|
||||
*cmp = sav;
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC_INLINE int
|
||||
my_atomic_casptr(void * volatile *a, void **cmp, void *set)
|
||||
{
|
||||
|
@ -97,6 +109,14 @@ my_atomic_add32(int32 volatile *a, int32 v)
|
|||
return (nv - v);
|
||||
}
|
||||
|
||||
STATIC_INLINE int64
|
||||
my_atomic_add64(int64 volatile *a, int64 v)
|
||||
{
|
||||
int64 nv;
|
||||
nv = atomic_add_64_nv((volatile uint64_t *)a, v);
|
||||
return (nv - v);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#ifdef MY_ATOMIC_MODE_DUMMY
|
||||
|
@ -110,6 +130,9 @@ my_atomic_load16(int16 volatile *a) { return (*a); }
|
|||
STATIC_INLINE int32
|
||||
my_atomic_load32(int32 volatile *a) { return (*a); }
|
||||
|
||||
STATIC_INLINE int64
|
||||
my_atomic_load64(int64 volatile *a) { return (*a); }
|
||||
|
||||
STATIC_INLINE void *
|
||||
my_atomic_loadptr(void * volatile *a) { return (*a); }
|
||||
|
||||
|
@ -124,6 +147,9 @@ my_atomic_store16(int16 volatile *a, int16 v) { *a = v; }
|
|||
STATIC_INLINE void
|
||||
my_atomic_store32(int32 volatile *a, int32 v) { *a = v; }
|
||||
|
||||
STATIC_INLINE void
|
||||
my_atomic_store64(int64 volatile *a, int64 v) { *a = v; }
|
||||
|
||||
STATIC_INLINE void
|
||||
my_atomic_storeptr(void * volatile *a, void *v) { *a = v; }
|
||||
|
||||
|
@ -149,6 +175,12 @@ my_atomic_load32(int32 volatile *a)
|
|||
return ((int32) atomic_or_32_nv((volatile uint32_t *)a, 0));
|
||||
}
|
||||
|
||||
STATIC_INLINE int64
|
||||
my_atomic_load64(int64 volatile *a)
|
||||
{
|
||||
return ((int64) atomic_or_64_nv((volatile uint64_t *)a, 0));
|
||||
}
|
||||
|
||||
STATIC_INLINE void *
|
||||
my_atomic_loadptr(void * volatile *a)
|
||||
{
|
||||
|
@ -175,6 +207,12 @@ my_atomic_store32(int32 volatile *a, int32 v)
|
|||
(void) atomic_swap_32((volatile uint32_t *)a, (uint32_t)v);
|
||||
}
|
||||
|
||||
STATIC_INLINE void
|
||||
my_atomic_store64(int64 volatile *a, int64 v)
|
||||
{
|
||||
(void) atomic_swap_64((volatile uint64_t *)a, (uint64_t)v);
|
||||
}
|
||||
|
||||
STATIC_INLINE void
|
||||
my_atomic_storeptr(void * volatile *a, void *v)
|
||||
{
|
||||
|
@ -203,6 +241,12 @@ my_atomic_fas32(int32 volatile *a, int32 v)
|
|||
return ((int32) atomic_swap_32((volatile uint32_t *)a, (uint32_t)v));
|
||||
}
|
||||
|
||||
STATIC_INLINE int64
|
||||
my_atomic_fas64(int64 volatile *a, int64 v)
|
||||
{
|
||||
return ((int64) atomic_swap_64((volatile uint64_t *)a, (uint64_t)v));
|
||||
}
|
||||
|
||||
STATIC_INLINE void *
|
||||
my_atomic_fasptr(void * volatile *a, void *v)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue