Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
18d08210
Commit
18d08210
authored
Dec 23, 2009
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix atomic/solaris.h to conform
remove duplicated boilerplate code
parent
d14aefa6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
226 deletions
+32
-226
include/atomic/nolock.h
include/atomic/nolock.h
+1
-5
include/atomic/solaris.h
include/atomic/solaris.h
+30
-218
include/my_atomic.h
include/my_atomic.h
+1
-3
No files found.
include/atomic/nolock.h
View file @
18d08210
...
@@ -50,11 +50,7 @@
...
@@ -50,11 +50,7 @@
# endif
# endif
#endif
#endif
#if defined(make_atomic_cas_body) || defined(MY_ATOMICS_MADE)
#if defined(make_atomic_cas_body)
/*
* We have atomics that require no locking
*/
#define MY_ATOMIC_NOLOCK
/*
/*
Type not used so minimal size (emptry struct has different size between C
Type not used so minimal size (emptry struct has different size between C
and C++, zero-length array is gcc-specific).
and C++, zero-length array is gcc-specific).
...
...
include/atomic/solaris.h
View file @
18d08210
...
@@ -13,242 +13,54 @@
...
@@ -13,242 +13,54 @@
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef _atomic_h_cleanup_
#define _atomic_h_cleanup_ "atomic/solaris.h"
#include <atomic.h>
#include <atomic.h>
#define MY_ATOMIC_MODE "solaris-atomic"
#define MY_ATOMIC_MODE "solaris-atomic"
/*
#define uintptr_t void *
* This is defined to indicate we fully define the my_atomic_* (inline)
#define atomic_or_ptr_nv(X,Y) (void *)atomic_or_ulong_nv((volatile ulong_t *)X, Y)
* functions here, so there is no need to "make" them in my_atomic.h
* using make_atomic_* and make_atomic_*_body.
*/
#define MY_ATOMICS_MADE
STATIC_INLINE
int
my_atomic_cas8
(
int8
volatile
*
a
,
int8
*
cmp
,
int8
set
)
{
int
ret
;
int8
sav
;
sav
=
(
int8
)
atomic_cas_8
((
volatile
uint8_t
*
)
a
,
(
uint8_t
)
*
cmp
,
(
uint8_t
)
set
);
if
(
!
(
ret
=
(
sav
==
*
cmp
)))
*
cmp
=
sav
;
return
ret
;
}
STATIC_INLINE
int
my_atomic_cas16
(
int16
volatile
*
a
,
int16
*
cmp
,
int16
set
)
{
int
ret
;
int16
sav
;
sav
=
(
int16
)
atomic_cas_16
((
volatile
uint16_t
*
)
a
,
(
uint16_t
)
*
cmp
,
(
uint16_t
)
set
);
if
(
!
(
ret
=
(
sav
==
*
cmp
)))
*
cmp
=
sav
;
return
ret
;
}
STATIC_INLINE
int
my_atomic_cas32
(
int32
volatile
*
a
,
int32
*
cmp
,
int32
set
)
{
int
ret
;
int32
sav
;
sav
=
(
int32
)
atomic_cas_32
((
volatile
uint32_t
*
)
a
,
(
uint32_t
)
*
cmp
,
(
uint32_t
)
set
);
if
(
!
(
ret
=
(
sav
==
*
cmp
)))
*
cmp
=
sav
;
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
)
{
int
ret
;
void
*
sav
;
sav
=
atomic_cas_ptr
(
a
,
*
cmp
,
set
);
if
(
!
(
ret
=
(
sav
==
*
cmp
)))
*
cmp
=
sav
;
return
ret
;
}
/* ------------------------------------------------------------------------ */
#define make_atomic_cas_body(S) \
uint ## S ## _t sav; \
sav = atomic_cas_ ## S( \
(volatile uint ## S ## _t *)a, \
(uint ## S ## _t)*cmp, \
(uint ## S ## _t)set); \
if (! (ret= (sav == *cmp))) \
*cmp= sav;
STATIC_INLINE
int8
#define make_atomic_add_body(S) \
my_atomic_add8
(
int8
volatile
*
a
,
int8
v
)
int ## S nv;
/* new value */
\
{
nv= atomic_add_ ## S ## _nv((volatile uint ## S ## _t *)a, v); \
int8
nv
;
v= nv - v
nv
=
atomic_add_8_nv
((
volatile
uint8_t
*
)
a
,
v
);
return
(
nv
-
v
);
}
STATIC_INLINE
int16
my_atomic_add16
(
int16
volatile
*
a
,
int16
v
)
{
int16
nv
;
nv
=
atomic_add_16_nv
((
volatile
uint16_t
*
)
a
,
v
);
return
(
nv
-
v
);
}
STATIC_INLINE
int32
my_atomic_add32
(
int32
volatile
*
a
,
int32
v
)
{
int32
nv
;
nv
=
atomic_add_32_nv
((
volatile
uint32_t
*
)
a
,
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
#ifdef MY_ATOMIC_MODE_DUMMY
STATIC_INLINE
int8
#define make_atomic_load_body(S) ret= *a
my_atomic_load8
(
int8
volatile
*
a
)
{
return
(
*
a
);
}
#define make_atomic_store_body(S) *a= v
STATIC_INLINE
int16
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
);
}
/* ------------------------------------------------------------------------ */
STATIC_INLINE
void
my_atomic_store8
(
int8
volatile
*
a
,
int8
v
)
{
*
a
=
v
;
}
STATIC_INLINE
void
#else
/* MY_ATOMIC_MODE_DUMMY */
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
#define make_atomic_load_body(S) \
my_atomic_store64
(
int64
volatile
*
a
,
int64
v
)
{
*
a
=
v
;
}
ret= atomic_or_ ## S ## _nv((volatile uint ## S ## _t *)a, 0)
STATIC_INLINE
void
#define make_atomic_store_body(S) \
my_atomic_storeptr
(
void
*
volatile
*
a
,
void
*
v
)
{
*
a
=
v
;
}
(void) atomic_swap_ ## S((volatile uint ## S ## _t *)a, (uint ## S ## _t)v)
/* ------------------------------------------------------------------------ */
#endif
#else
/* MY_ATOMIC_MODE_DUMMY */
STATIC_INLINE
int8
#define make_atomic_fas_body(S) \
my_atomic_load8
(
int8
volatile
*
a
)
v= atomic_swap_ ## S((volatile uint ## S ## _t *)a, (uint ## S ## _t)v)
{
return
((
int8
)
atomic_or_8_nv
((
volatile
uint8_t
*
)
a
,
0
));
}
STATIC_INLINE
int16
my_atomic_load16
(
int16
volatile
*
a
)
{
return
((
int16
)
atomic_or_16_nv
((
volatile
uint16_t
*
)
a
,
0
));
}
STATIC_INLINE
int32
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
)
{
return
((
void
*
)
atomic_or_ulong_nv
((
volatile
ulong_t
*
)
a
,
0
));
}
/* ------------------------------------------------------------------------
*/
#else
/* cleanup
*/
STATIC_INLINE
void
#undef uintptr_t
my_atomic_store8
(
int8
volatile
*
a
,
int8
v
)
#undef atomic_or_ptr_nv
{
(
void
)
atomic_swap_8
((
volatile
uint8_t
*
)
a
,
(
uint8_t
)
v
);
}
STATIC_INLINE
void
my_atomic_store16
(
int16
volatile
*
a
,
int16
v
)
{
(
void
)
atomic_swap_16
((
volatile
uint16_t
*
)
a
,
(
uint16_t
)
v
);
}
STATIC_INLINE
void
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
)
{
(
void
)
atomic_swap_ptr
(
a
,
v
);
}
#endif
#endif
/* ------------------------------------------------------------------------ */
STATIC_INLINE
int8
my_atomic_fas8
(
int8
volatile
*
a
,
int8
v
)
{
return
((
int8
)
atomic_swap_8
((
volatile
uint8_t
*
)
a
,
(
uint8_t
)
v
));
}
STATIC_INLINE
int16
my_atomic_fas16
(
int16
volatile
*
a
,
int16
v
)
{
return
((
int16
)
atomic_swap_16
((
volatile
uint16_t
*
)
a
,
(
uint16_t
)
v
));
}
STATIC_INLINE
int32
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
)
{
return
(
atomic_swap_ptr
(
a
,
v
));
}
include/my_atomic.h
View file @
18d08210
...
@@ -68,12 +68,11 @@
...
@@ -68,12 +68,11 @@
#include "atomic/nolock.h"
#include "atomic/nolock.h"
#endif
#endif
#ifndef
MY_ATOMIC_NOLOCK
#ifndef
make_atomic_cas_body
/* nolock.h was not able to generate even a CAS function, fall back */
/* nolock.h was not able to generate even a CAS function, fall back */
#include "atomic/rwlock.h"
#include "atomic/rwlock.h"
#endif
#endif
#ifndef MY_ATOMICS_MADE
/* define missing functions by using the already generated ones */
/* define missing functions by using the already generated ones */
#ifndef make_atomic_add_body
#ifndef make_atomic_add_body
#define make_atomic_add_body(S) \
#define make_atomic_add_body(S) \
...
@@ -287,7 +286,6 @@ make_atomic_store(ptr)
...
@@ -287,7 +286,6 @@ make_atomic_store(ptr)
#undef make_atomic_load_body
#undef make_atomic_load_body
#undef make_atomic_store_body
#undef make_atomic_store_body
#undef make_atomic_fas_body
#undef make_atomic_fas_body
#endif
#undef intptr
#undef intptr
/*
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment