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
d1852da7
Commit
d1852da7
authored
Oct 21, 2006
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
less confusing and more correct name for my_atomic_swap
parent
fb818dd7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
18 deletions
+18
-18
include/atomic/rwlock.h
include/atomic/rwlock.h
+1
-1
include/atomic/x86-gcc.h
include/atomic/x86-gcc.h
+1
-1
include/atomic/x86-msvc.h
include/atomic/x86-msvc.h
+1
-1
include/my_atomic.h
include/my_atomic.h
+11
-11
unittest/mysys/my_atomic-t.c
unittest/mysys/my_atomic-t.c
+4
-4
No files found.
include/atomic/rwlock.h
View file @
d1852da7
...
...
@@ -47,7 +47,7 @@ typedef struct {pthread_mutex_t rw;} my_atomic_rwlock_t;
#endif
#define make_atomic_add_body(S) int ## S sav; sav= *a; *a+= v; v=sav;
#define make_atomic_
swap_body(S)
int ## S sav; sav= *a; *a= v; v=sav;
#define make_atomic_
fas_body(S)
int ## S sav; sav= *a; *a= v; v=sav;
#define make_atomic_cas_body(S) if ((ret= (*a == *cmp))) *a= set; else *cmp=*a;
#define make_atomic_load_body(S) ret= *a;
#define make_atomic_store_body(S) *a= v;
...
...
include/atomic/x86-gcc.h
View file @
d1852da7
...
...
@@ -43,7 +43,7 @@
#define make_atomic_add_body(S) \
asm volatile (LOCK_prefix "; xadd %0, %1;" : "+r" (v) , "+m" (*a))
#endif
#define make_atomic_
swap
_body(S) \
#define make_atomic_
fas
_body(S) \
asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (*a))
#define make_atomic_cas_body(S) \
asm volatile (LOCK_prefix "; cmpxchg %3, %0; setz %2;" \
...
...
include/atomic/x86-msvc.h
View file @
d1852da7
...
...
@@ -43,7 +43,7 @@
_asm setz al \
_asm movzx ret, al \
}
#define make_atomic_
swap_body(S)
\
#define make_atomic_
fas_body(S)
\
_asm { \
_asm mov reg_ ## S, v \
_asm xchg *a, reg_ ## S \
...
...
include/my_atomic.h
View file @
d1852da7
...
...
@@ -43,11 +43,11 @@ STATIC_INLINE int ## S my_atomic_add ## S( \
return v; \
}
#define make_atomic_
swap
(S) \
STATIC_INLINE int ## S my_atomic_
swap
## S( \
#define make_atomic_
fas
(S) \
STATIC_INLINE int ## S my_atomic_
fas
## S( \
int ## S volatile *a, int ## S v) \
{ \
make_atomic_
swap
_body(S); \
make_atomic_
fas
_body(S); \
return v; \
}
...
...
@@ -80,8 +80,8 @@ STATIC_INLINE void my_atomic_store ## S( \
#define make_atomic_add(S) \
extern int ## S my_atomic_add ## S(int ## S volatile *a, int ## S v);
#define make_atomic_
swap
(S) \
extern int ## S my_atomic_
swap
## S(int ## S volatile *a, int ## S v);
#define make_atomic_
fas
(S) \
extern int ## S my_atomic_
fas
## S(int ## S volatile *a, int ## S v);
#define make_atomic_cas(S) \
extern int my_atomic_cas ## S(int ## S volatile *a, int ## S *cmp, int ## S set);
...
...
@@ -113,10 +113,10 @@ make_atomic_store(16)
make_atomic_store
(
32
)
make_atomic_store
(
ptr
)
make_atomic_
swap
(
8
)
make_atomic_
swap
(
16
)
make_atomic_
swap
(
32
)
make_atomic_
swap
(
ptr
)
make_atomic_
fas
(
8
)
make_atomic_
fas
(
16
)
make_atomic_
fas
(
32
)
make_atomic_
fas
(
ptr
)
#ifdef _atomic_h_cleanup_
#include _atomic_h_cleanup_
...
...
@@ -127,12 +127,12 @@ make_atomic_swap(ptr)
#undef make_atomic_cas
#undef make_atomic_load
#undef make_atomic_store
#undef make_atomic_
swap
#undef make_atomic_
fas
#undef make_atomic_add_body
#undef make_atomic_cas_body
#undef make_atomic_load_body
#undef make_atomic_store_body
#undef make_atomic_
swap
_body
#undef make_atomic_
fas
_body
#undef intptr
#ifndef LF_BACKOFF
...
...
unittest/mysys/my_atomic-t.c
View file @
d1852da7
...
...
@@ -62,7 +62,7 @@ pthread_handler_t test_atomic_add_handler(void *arg)
5. subtract result from a32
must get 0 in a32 at the end
*/
pthread_handler_t
test_atomic_
swap
_handler
(
void
*
arg
)
pthread_handler_t
test_atomic_
fas
_handler
(
void
*
arg
)
{
int
m
=*
(
int
*
)
arg
;
uint32
x
=
my_atomic_add32
(
&
b32
,
1
);
...
...
@@ -72,14 +72,14 @@ pthread_handler_t test_atomic_swap_handler(void *arg)
for
(;
m
;
m
--
)
{
my_atomic_rwlock_wrlock
(
&
rwl
);
x
=
my_atomic_
swap
32
(
&
c32
,
x
);
x
=
my_atomic_
fas
32
(
&
c32
,
x
);
my_atomic_rwlock_wrunlock
(
&
rwl
);
}
if
(
!
x
)
{
my_atomic_rwlock_wrlock
(
&
rwl
);
x
=
my_atomic_
swap
32
(
&
c32
,
x
);
x
=
my_atomic_
fas
32
(
&
c32
,
x
);
my_atomic_rwlock_wrunlock
(
&
rwl
);
}
...
...
@@ -306,7 +306,7 @@ int main()
#define THREADS 100
test_atomic
(
"my_atomic_add32"
,
test_atomic_add_handler
,
THREADS
,
CYCLES
);
test_atomic
(
"my_atomic_
swap32"
,
test_atomic_swap_handler
,
THREADS
,
CYCLES
);
test_atomic
(
"my_atomic_
fas32"
,
test_atomic_fas_handler
,
THREADS
,
CYCLES
);
test_atomic
(
"my_atomic_cas32"
,
test_atomic_cas_handler
,
THREADS
,
CYCLES
);
test_atomic
(
"lf_pinbox"
,
test_lf_pinbox
,
THREADS
,
CYCLES
);
test_atomic
(
"lf_alloc"
,
test_lf_alloc
,
THREADS
,
CYCLES
);
...
...
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