Commit d813a7ea authored by Bob Pendleton's avatar Bob Pendleton

First commit for SDL atomic operations.

On my linux box it compiles and installs correctly and testatomic runs without errors.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403638
parent d083f30b
...@@ -42,7 +42,7 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@ ...@@ -42,7 +42,7 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode
HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h HDRS = SDL.h SDL_atomic.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_power.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
LT_AGE = @LT_AGE@ LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@ LT_CURRENT = @LT_CURRENT@
......
...@@ -159,6 +159,7 @@ if test x$enable_libc = xyes; then ...@@ -159,6 +159,7 @@ if test x$enable_libc = xyes; then
AC_CHECK_FUNCS(iconv) AC_CHECK_FUNCS(iconv)
fi fi
AC_CHECK_SIZEOF(void*)
if test x$have_inttypes != xyes; then if test x$have_inttypes != xyes; then
AC_CHECK_SIZEOF(char, 1) AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(short, 2)
......
...@@ -76,6 +76,7 @@ Enjoy! ...@@ -76,6 +76,7 @@ Enjoy!
#include "SDL_main.h" #include "SDL_main.h"
#include "SDL_stdinc.h" #include "SDL_stdinc.h"
#include "SDL_atomic.h"
#include "SDL_audio.h" #include "SDL_audio.h"
#include "SDL_cdrom.h" #include "SDL_cdrom.h"
#include "SDL_cpuinfo.h" #include "SDL_cpuinfo.h"
......
This diff is collapsed.
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#undef int64_t #undef int64_t
#undef uint64_t #undef uint64_t
#undef uintptr_t #undef uintptr_t
#undef SIZEOF_VOIDP
#undef SDL_HAS_64BIT_TYPE #undef SDL_HAS_64BIT_TYPE
/* Endianness */ /* Endianness */
......
...@@ -36,6 +36,7 @@ typedef unsigned int uint32_t; ...@@ -36,6 +36,7 @@ typedef unsigned int uint32_t;
typedef signed long long int64_t; typedef signed long long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
typedef unsigned long uintptr_t; typedef unsigned long uintptr_t;
#define SIZEOF_VOIDP 4
#define SDL_HAS_64BIT_TYPE 1 #define SDL_HAS_64BIT_TYPE 1
/* Useful headers */ /* Useful headers */
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
/* This is a set of defines to configure the SDL features */ /* This is a set of defines to configure the SDL features */
#define SIZEOF_VOIDP 4
#define SDL_HAS_64BIT_TYPE 1 #define SDL_HAS_64BIT_TYPE 1
/* Useful headers */ /* Useful headers */
......
...@@ -38,6 +38,7 @@ typedef unsigned long uintptr_t; ...@@ -38,6 +38,7 @@ typedef unsigned long uintptr_t;
typedef signed long long int64_t; typedef signed long long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
#define SIZEOF_VOIDP 4
#define SDL_HAS_64BIT_TYPE 1 #define SDL_HAS_64BIT_TYPE 1
/* Use Watcom's LIBC */ /* Use Watcom's LIBC */
......
...@@ -68,6 +68,12 @@ typedef unsigned int size_t; ...@@ -68,6 +68,12 @@ typedef unsigned int size_t;
#endif #endif
typedef unsigned int uintptr_t; typedef unsigned int uintptr_t;
#endif /* __GNUC__ || _MSC_VER */ #endif /* __GNUC__ || _MSC_VER */
#ifdef _WIN64
# define SIZEOF_VOIDP 8
#else
# define SIZEOF_VOIDP 4
#endif
#define SDL_HAS_64BIT_TYPE 1 #define SDL_HAS_64BIT_TYPE 1
/* Enabled for SDL 1.2 (binary compatibility) */ /* Enabled for SDL 1.2 (binary compatibility) */
......
...@@ -7,7 +7,7 @@ EXE = @EXE@ ...@@ -7,7 +7,7 @@ EXE = @EXE@
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
LIBS = @LIBS@ LIBS = @LIBS@
TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testresample$(EXE) testaudioinfo$(EXE) testmultiaudio$(EXE) testpower$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testintersections$(EXE) testdraw2$(EXE) testdyngl$(EXE) testdyngles$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testgl2$(EXE) testgles$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testsprite2$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) testwm2$(EXE) threadwin$(EXE) torturethread$(EXE) testloadso$(EXE) testhaptic$(EXE) testmmousetablet$(EXE) TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testresample$(EXE) testaudioinfo$(EXE) testmultiaudio$(EXE) testpower$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testintersections$(EXE) testdraw2$(EXE) testdyngl$(EXE) testdyngles$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testgl2$(EXE) testgles$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testsprite2$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) testwm2$(EXE) threadwin$(EXE) torturethread$(EXE) testloadso$(EXE) testhaptic$(EXE) testmmousetablet$(EXE) testatomic$(EXE)
all: Makefile $(TARGETS) all: Makefile $(TARGETS)
...@@ -149,6 +149,9 @@ testhaptic$(EXE): $(srcdir)/testhaptic.c ...@@ -149,6 +149,9 @@ testhaptic$(EXE): $(srcdir)/testhaptic.c
testmmousetablet$(EXE): $(srcdir)/testmmousetablet.c testmmousetablet$(EXE): $(srcdir)/testmmousetablet.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS) $(CC) -o $@ $? $(CFLAGS) $(LIBS)
testatomic$(EXE): $(srcdir)/testatomic.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS)
clean: clean:
rm -f $(TARGETS) rm -f $(TARGETS)
......
#include "SDL.h"
int
main(int argc, char** argv)
{
int rv = 10;
volatile int atomic;
SDL_atomic_int_set(&atomic, 10);
if(SDL_atomic_int_get(&atomic) != 10)
printf("Error: ");
printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n",
SDL_atomic_int_get(&atomic));
SDL_atomic_int_add(&atomic, 10);
if(SDL_atomic_int_get(&atomic) != 20)
printf("Error: ");
printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n",
SDL_atomic_int_get(&atomic));
rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
if(rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30)
printf("Error: ");
printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n",
rv, SDL_atomic_int_get(&atomic));
rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
if(rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30)
printf("Error: ");
printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n",
rv, SDL_atomic_int_get(&atomic));
rv = SDL_atomic_int_xchg_add(&atomic, 10);
if(rv != 30 || SDL_atomic_int_get(&atomic) != 40)
printf("Error: ");
printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n",
rv, SDL_atomic_int_get(&atomic));
SDL_atomic_int_inc(&atomic);
if(SDL_atomic_int_get(&atomic) != 41)
printf("Error: ");
printf("SDL_atomic_int_inc(atomic): atomic-> %d\n",
SDL_atomic_int_get(&atomic));
rv = SDL_atomic_int_dec_test(&atomic);
if(rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40)
printf("Error: ");
printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
rv, SDL_atomic_int_get(&atomic));
SDL_atomic_int_set(&atomic, 1);
if(SDL_atomic_int_get(&atomic) != 1)
printf("Error: ");
printf("SDL_atomic_int_set(atomic, 1): atomic-> %d\n",
SDL_atomic_int_get(&atomic));
rv = SDL_atomic_int_dec_test(&atomic);
if(rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0)
printf("Error: ");
printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
rv, SDL_atomic_int_get(&atomic));
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment