Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
8f205278
Commit
8f205278
authored
Feb 08, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
It's now possible to disable the fast atomic operations, at a huge performance penalty.
parent
82536588
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
1 deletion
+30
-1
configure.in
configure.in
+6
-0
SDL_atomic.h
include/SDL_atomic.h
+3
-0
SDL_config.h.in
include/SDL_config.h.in
+1
-0
SDL_spinlock.c
src/atomic/SDL_spinlock.c
+20
-1
No files found.
configure.in
View file @
8f205278
...
...
@@ -422,6 +422,12 @@ AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]
if test x$enable_cpuinfo != xyes; then
AC_DEFINE(SDL_CPUINFO_DISABLED)
fi
AC_ARG_ENABLE(atomic,
AC_HELP_STRING([--enable-atomic], [Enable the atomic operations [[default=yes]]]),
, enable_atomic=yes)
if test x$enable_atomic != xyes; then
AC_DEFINE(SDL_ATOMIC_DISABLED)
fi
AC_ARG_ENABLE(assembly,
AC_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
, enable_assembly=yes)
...
...
include/SDL_atomic.h
View file @
8f205278
...
...
@@ -141,6 +141,9 @@ void _ReadWriteBarrier(void);
/* Platform specific optimized versions of the atomic functions,
* you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
*/
#if SDL_ATOMIC_DISABLED
#define SDL_DISABLE_ATOMIC_INLINE
#endif
#ifndef SDL_DISABLE_ATOMIC_INLINE
#ifdef HAVE_MSC_ATOMICS
...
...
include/SDL_config.h.in
View file @
8f205278
...
...
@@ -171,6 +171,7 @@
#undef SDL_DEFAULT_ASSERT_LEVEL
/* Allow disabling of core subsystems */
#undef SDL_ATOMIC_DISABLED
#undef SDL_AUDIO_DISABLED
#undef SDL_CPUINFO_DISABLED
#undef SDL_EVENTS_DISABLED
...
...
src/atomic/SDL_spinlock.c
View file @
8f205278
...
...
@@ -22,6 +22,7 @@
#include "SDL_stdinc.h"
#include "SDL_atomic.h"
#include "SDL_mutex.h"
#include "SDL_timer.h"
/* Don't do the check for Visual Studio 2005, it's safe here */
...
...
@@ -33,7 +34,25 @@
SDL_bool
SDL_AtomicTryLock
(
SDL_SpinLock
*
lock
)
{
#if defined(_MSC_VER)
#if SDL_ATOMIC_DISABLED
/* Terrible terrible damage */
static
SDL_mutex
*
_spinlock_mutex
;
if
(
!
_spinlock_mutex
)
{
/* Race condition on first lock... */
_spinlock_mutex
=
SDL_CreateMutex
();
}
SDL_mutexP
(
_spinlock_mutex
);
if
(
*
lock
==
0
)
{
*
lock
=
1
;
SDL_mutexV
(
_spinlock_mutex
);
return
SDL_TRUE
;
}
else
{
SDL_mutexV
(
_spinlock_mutex
);
return
SDL_FALSE
;
}
#elif defined(_MSC_VER)
SDL_COMPILE_TIME_ASSERT
(
locksize
,
sizeof
(
*
lock
)
==
sizeof
(
long
));
return
(
InterlockedExchange
((
long
*
)
lock
,
1
)
==
0
);
...
...
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