Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stunserver
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
nanahira
Stunserver
Commits
432fbfb5
Commit
432fbfb5
authored
Feb 27, 2013
by
jselbie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quick fix clang
parent
fa01c48a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
39 deletions
+24
-39
common/atomichelpers.cpp
common/atomichelpers.cpp
+24
-25
common/atomichelpers.h
common/atomichelpers.h
+0
-14
No files found.
common/atomichelpers.cpp
View file @
432fbfb5
...
...
@@ -20,9 +20,14 @@
#ifdef ATOMICS_ARE_DEFINED
#if defined(i386) || defined(__i386) || defined(__i386__)
#define ATOMICS_USE_XADD
#endif
extern
"C"
unsigned
int
xadd_4
(
volatile
void
*
pVal
,
unsigned
int
inc
)
#ifdef ATOMICS_USE_XADD
unsigned
int
xadd_4
(
volatile
void
*
pVal
,
unsigned
int
inc
)
{
unsigned
int
result
;
unsigned
int
*
pValInt
=
(
unsigned
int
*
)
pVal
;
...
...
@@ -34,40 +39,28 @@ extern "C" unsigned int xadd_4(volatile void* pVal, unsigned int inc)
:
"memory"
);
return
(
result
);
}
extern
"C"
unsigned
int
__sync_add_and_fetch_4
(
volatile
void
*
pVal
,
unsigned
int
inc
)
{
return
(
xadd_4
(
pVal
,
inc
)
+
inc
);
}
extern
"C"
unsigned
int
__sync_sub_and_fetch_4
(
volatile
void
*
pVal
,
unsigned
int
inc
)
{
return
(
xadd_4
(
pVal
,
-
inc
)
-
inc
);
}
extern
"C"
unsigned
int
__sync_fetch_and_add_4
(
volatile
void
*
pVal
,
unsigned
int
inc
)
int
AtomicIncrement
(
int
*
pInt
)
{
return
xadd_4
(
pVal
,
inc
);
COMPILE_TIME_ASSERT
(
sizeof
(
int
)
==
4
);
// InterlockedIncrement
unsigned
int
result
=
xadd_4
(
pInt
,
1
)
+
1
;
return
(
int
)
result
;
}
extern
"C"
unsigned
int
__sync_fetch_and_sub_4
(
volatile
void
*
pVal
,
unsigned
int
inc
)
int
AtomicDecrement
(
int
*
pInt
)
{
return
xadd_4
(
pVal
,
-
inc
);
// InterlockedDecrement
unsigned
int
result
=
xadd_4
(
pInt
,
-
1
)
-
1
;
return
(
int
)
result
;
}
#ifdef __GNUC__
#pragma message "atomichelpers.cpp: Defining sync_add_and_fetch helpers for i386 compile"
#endif
#endif
#else
int
AtomicIncrement
(
int
*
pInt
)
{
COMPILE_TIME_ASSERT
(
sizeof
(
int
)
==
4
);
COMPILE_TIME_ASSERT
(
sizeof
(
int
)
==
4
);
// InterlockedIncrement
return
__sync_add_and_fetch
(
pInt
,
1
);
}
...
...
@@ -78,3 +71,9 @@ int AtomicDecrement(int* pInt)
return
__sync_sub_and_fetch
(
pInt
,
1
);
}
#endif
common/atomichelpers.h
View file @
432fbfb5
...
...
@@ -18,20 +18,6 @@
#ifndef ATOMICHELPERS_H
#define ATOMICHELPERS_H
typedef
unsigned
int
(
*
xaddFunctionType
)(
volatile
void
*
,
unsigned
int
);
#if defined(i386) || defined(__i386__) || defined(__i386)
#define ATOMICS_ARE_DEFINED
extern
"C"
unsigned
int
xadd_4
(
volatile
void
*
pVal
,
unsigned
int
inc
);
extern
"C"
unsigned
int
__sync_add_and_fetch_4
(
volatile
void
*
pVal
,
unsigned
int
inc
);
extern
"C"
unsigned
int
__sync_sub_and_fetch_4
(
volatile
void
*
pVal
,
unsigned
int
inc
);
extern
"C"
unsigned
int
__sync_fetch_and_add_4
(
volatile
void
*
pVal
,
unsigned
int
inc
);
extern
"C"
unsigned
int
__sync_fetch_and_sub_4
(
volatile
void
*
pVal
,
unsigned
int
inc
);
#endif
int
AtomicIncrement
(
int
*
pInt
);
int
AtomicDecrement
(
int
*
pInt
);
...
...
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