Commit graph

48 commits

Author SHA1 Message Date
Ryan C. Gordon
d2fcd08e53 atomic: Fight with all the assemblers that don't like REP NOP. :/ 2018-06-25 16:34:16 -04:00
Ryan C. Gordon
db4f3793c0 atomic: Spin locks now try to use the x86 PAUSE instruction for short waits.
Fixes Bugzilla #4151.
2018-06-25 15:58:35 -04:00
Sam Lantinga
346af016a5 Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Ozkan Sezer
29941a2a2b Add atomics for Watcom/x86 as inline asm
Partially fixes Bugzilla #3758.
2017-08-18 16:35:55 -04:00
Sam Lantinga
1b24bfad38 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
7ee8dda270 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
56b58afdbe Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Sam Lantinga
0fb3ac0853 Fixed bug 2618 - incomplete pthread-based lock support should be removed
binarycrusader

Since changeset 358696c354a8, SDL 2.0 has been broken on Solaris when compiling with the Solaris Studio compiler (which uses the pthread implementation of SDL_AtomicLock).

Notably, it gets stuck at the MemoryBarrierRelease in SDL_GetErrBuf:

6585 # 218
6586     if (!tls_errbuf && !tls_being_created) {
6587          SDL_AtomicLock_REAL ( & tls_lock );
6588         if (!tls_errbuf) {
6589             SDL_TLSID slot;
6590             tls_being_created = SDL_TRUE;
6591             slot =  SDL_TLSCreate_REAL ( );
6592             tls_being_created = SDL_FALSE;
6593              { SDL_SpinLock _tmp = 0 ; SDL_AtomicLock_REAL ( & _tmp ) ; SDL_AtomicUnlock_REAL ( & _tmp ) ; };
^^^ loops forever above
6594             tls_errbuf = slot;
6595         }
6596          SDL_AtomicUnlock_REAL ( & tls_lock );
6597     }


Running: testthread
(process id 28926)
^Cdbx: warning: Interrupt ignored but forwarded to child.
signal INT (Interrupt) in __nanosleep at 0xfe52a875
0xfe52a875: __nanosleep+0x0015: jae      __nanosleep+0x23   [ 0xfe52a883, .+0xe ]
Current function is SDL_Delay_REAL
  204           was_error = nanosleep(&tv, &elapsed);
(dbx) where
  [1] __nanosleep(0xfeffe848, 0xfeffe850, 0xfe75a5ac, 0xfe5169d8), at 0xfe52a875
  [2] nanosleep(0xfeffe848, 0xfeffe850), at 0xfe516a3b
=>[3] SDL_Delay_REAL(ms = 0), line 204 in "SDL_systimer.c"
  [4] SDL_AtomicLock_REAL(lock = 0xfeffe88c), line 104 in "SDL_spinlock.c"
  [5] SDL_GetErrBuf(), line 225 in "SDL_thread.c"
  [6] SDL_ClearError_REAL(), line 216 in "SDL_error.c"
  [7] SDL_InitSubSystem_REAL(flags = 0), line 116 in "SDL.c"
  [8] SDL_Init_REAL(flags = 0), line 244 in "SDL.c"
  [9] SDL_Init(a = 0), line 89 in "SDL_dynapi_procs.h"
  [10] main(argc = 1, argv = 0xfeffe948), line 65 in "testthread.c"

As far as I can tell, this is because pthread_spin_trylock() always returns EBUSY for this particular lock; since it works in other places, I'm suspicious.

Different Solaris Studio compiler versions seem to make no difference.

I've verified this is broken on Linux as well if SDL_spinlock.c is modified to use the pthread implementation.

This appears to be because pthread_spin_init() and pthread_spin_destroy() are not used with the locks as required.
2014-07-07 21:27:42 -07:00
Shawn Walker
f2c61cdaa5 2620 solaris port missing atomics if not using gcc 2014-07-05 16:11:23 -07:00
Sam Lantinga
a7d2ebb8d6 Integrated David Ludwig's support for Windows RT 2014-03-09 11:36:47 -07:00
Sam Lantinga
211b54deef Fixed line endings on WinRT source code 2014-03-09 11:06:11 -07:00
Sam Lantinga
d7940a513e Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2014-02-02 00:53:27 -08:00
Ryan C. Gordon
82edee6971 Make internal SDL sources include SDL_internal.h instead of SDL_config.h
The new header will include SDL_config.h, but allows for other global stuff.

--HG--
extra : rebase_source : ddf4a4c0dc2c554b98c82700798f343cd91b16e3
2013-11-24 23:56:17 -05:00
David Ludwig
3f62c9892a WinRT: build fixes, post SDL 2.0.1 update 2013-10-27 23:03:11 -04:00
David Ludwig
59df93166d WinRT: merged with SDL 2.0.1 codebase 2013-10-27 21:26:46 -04:00
Sam Lantinga
a999af88e9 Fixed building using MinGW
Our SDL_windows.h needed to be included before anything else so UNICODE is defined.
2013-10-17 23:02:29 -07:00
David Ludwig
88461d442a WinRT: merged with SDL 2.0.0 codebase (aka. SDL hg rev d6a8fa507a45)
--HG--
rename : README.iOS => README-ios.txt
2013-08-12 22:29:55 -04:00
Sam Lantinga
0cb6385637 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
David Ludwig
41ce3814e2 WinRT: merged with latest, official, SDL 2.x sources (at rev. bea100d73d13) 2013-04-14 11:42:55 -04:00
Sam Lantinga
c6388c87c1 Changed the name of SDL_mutexP() SDL_mutexV() 2013-03-07 20:12:40 -08:00
David Ludwig
776ebe3bda WinRT: merged with latest, official, SDL 2.x code 2013-02-23 20:01:46 -05:00
Sam Lantinga
95dcfa4c28 Happy New Year! 2013-02-15 08:47:44 -08:00
David Ludwig
54b4201aa0 Got a bare-bones version of SDL compiling for Windows RT. Dummy drivers are used in some places. Very little Windows-specific code (from the Win32 version of SDL) is used. 2012-10-17 21:43:20 -04:00
Sam Lantinga
f380ecb137 Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Sam Lantinga
9033bb050f Make sure that we use consistent configuration options on platforms like Windows so that command line builds and IDE builds have ABI compatibility.
Make sure we don't clobber SDL_revision.h when building from Mercurial

--HG--
rename : include/SDL_config.h.in => include/SDL_config_generated.h.in
2012-01-14 13:21:19 -05:00
Sam Lantinga
028e5dcdbd Happy New Year! 2011-12-31 09:28:07 -05:00
Ryan C. Gordon
3d70224c40 Check for __ARM_ARCH_5TEJ__ in spinlock atomics.
Fixes Bugzilla #1264.

Thanks to Gueniffey for the patch!
2011-10-16 03:27:48 -04:00
Ryan C. Gordon
5a652760ab Let iOS use OSAtomicCompareAndSwap32Barrier() if nothing else is available. 2011-10-16 03:02:46 -04:00
Ryan C. Gordon
82283b7279 Implemented x86 and x86-64 spinlock inline asm.
Favor it over Mac OS X API for Intel systems (but not GCC atomic intrinsics).

This might get us a little further on Cygwin builds, too.
2011-09-18 03:19:41 -04:00
Ryan C. Gordon
6fcfc35b50 Use an actual #error instead of a bogus symbol if there's no spinlock support. 2011-09-18 02:55:45 -04:00
Nathan Heisey
dfe639930e Implemented pthread spinlocks. 2011-06-22 10:33:48 +00:00
Sam Lantinga
b0660ba5ff SDL 1.3 is now under the zlib license. 2011-04-08 13:03:26 -07:00
Sam Lantinga
1cbbefce43 Fixed bug 1122 (spinlock fails to compile with -march=armv4t) 2011-02-16 17:17:21 -08:00
Sam Lantinga
f9a5f416fb Frank Zago to SDL
On 02/12/2011 01:44 PM, Sam Lantinga wrote:
> BTW, you probably want to nuke the NDS renderer and just implement these three
> functions instead:
>     int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 *
> format, void ** pixels, int *pitch);
>     int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, int numrects,
> SDL_Rect * rects);
>     void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window);

Patch attached. The renderer for the DS is not used anymore, but I left the
file in place if someone wants to finish it.

I've also added a README.ds and fixed the spinlocks.
2011-02-13 14:01:02 -08:00
Sam Lantinga
e5803d148c Happy 2011! :) 2011-02-11 22:37:15 -08:00
Sam Lantinga
8f205278b1 It's now possible to disable the fast atomic operations, at a huge performance penalty. 2011-02-07 22:57:33 -08:00
Sam Lantinga
fc5dc0ddb2 More fixes for compilation on Visual Studio 2011-01-25 18:02:41 -08:00
Sam Lantinga
29e0bf97e0 Improvements based on feedback from Anthony Williams 2011-01-25 17:40:06 -08:00
Sam Lantinga
f98d804282 Only include windows.h on Windows. :) 2011-01-24 21:22:00 -08:00
Sam Lantinga
b4497865bd Include windows.h in a single point in the source, so we can be consistent about the definition of UNICODE and have core utility functions for Windows that all modules can share.
I think this also fixes the bug relating to non-latin characters in filenames, since UNICODE wasn't defined in SDL_rwops.c

--HG--
rename : src/SDL_android.cpp => src/core/android/SDL_android.cpp
rename : src/SDL_android.h => src/core/android/SDL_android.h
2011-01-24 21:20:30 -08:00
Sam Lantinga
10b8372bd3 Fixed compiling on Windows Mobile SDK 5.0 with Visual Studio 2008 2011-01-24 15:46:11 -08:00
Sam Lantinga
c4bf458e47 Fixed bug #1097
There are problems with including intrin.h in C linkage in C++ compilation,
and further conflicts between intrin.h and winnt.h on Visual Studio 2005.
2011-01-21 23:46:51 -08:00
Sam Lantinga
daecbfdc17 HAVE_GCC_ATOMICS covers the test and set 2011-01-21 21:45:55 -08:00
Sam Lantinga
2c31531800 Separated out the minimum functionality that we need from gcc for our spinlock fallback. 2011-01-21 21:42:04 -08:00
Sam Lantinga
5601ecaeae Whoops, good catch from Greg Jandl 2011-01-18 22:10:37 -08:00
Sam Lantinga
cdb1bda300 Use compiler intrinsics on Windows 2011-01-17 14:05:43 -08:00
Sam Lantinga
b0e0f61c7e Added native atomic operations for Windows, Mac OS X, and gcc compiler intrinsics.
Changed the CAS return value to bool, so it's efficient with OSAtomicCompareAndSwap32Barrier()
Added an atomic test adapted from code by Michael Davidsaver
2011-01-16 15:16:39 -08:00
Sam Lantinga
1bc8fe69ce Updated the atomic API for better use cases 2011-01-15 12:41:59 -08:00