From 04fc0f720ee45f68b58b1e12b7cd08cdc4b508f7 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 7 Feb 2012 02:11:15 -0500 Subject: [PATCH] Replaced some assert macros with SDL_assert. --- src/audio/SDL_audiocvt.c | 13 +++++------ src/audio/coreaudio/SDL_coreaudio.c | 5 +++-- src/stdlib/SDL_qsort.c | 3 ++- src/video/SDL_blit_A.c | 1 - src/video/SDL_blit_N.c | 35 ++++++++++++++--------------- src/video/cocoa/SDL_cocoashape.m | 5 +++-- src/video/x11/SDL_x11opengl.c | 2 +- 7 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 870d8cd28..b069543e0 100755 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -25,12 +25,9 @@ #include "SDL_audio.h" #include "SDL_audio_c.h" -/* #define DEBUG_CONVERT */ +#include "SDL_assert.h" -/* !!! FIXME */ -#ifndef assert -#define assert(x) -#endif +/* #define DEBUG_CONVERT */ /* Effectively mix right and left channels into a single channel */ static void SDLCALL @@ -881,9 +878,9 @@ SDL_FindFrequencyMultiple(const int src_rate, const int dst_rate) int lo, hi; int div; - assert(src_rate != 0); - assert(dst_rate != 0); - assert(src_rate != dst_rate); + SDL_assert(src_rate != 0); + SDL_assert(dst_rate != 0); + SDL_assert(src_rate != dst_rate); if (src_rate < dst_rate) { lo = src_rate; diff --git a/src/audio/coreaudio/SDL_coreaudio.c b/src/audio/coreaudio/SDL_coreaudio.c index dfcbe3899..53d3a08f1 100755 --- a/src/audio/coreaudio/SDL_coreaudio.c +++ b/src/audio/coreaudio/SDL_coreaudio.c @@ -23,6 +23,7 @@ #include "../SDL_audio_c.h" #include "../SDL_sysaudio.h" #include "SDL_coreaudio.h" +#include "SDL_assert.h" #define DEBUG_COREAUDIO 0 @@ -268,8 +269,8 @@ outputCallback(void *inRefCon, any input format in OpenAudio, and leave the conversion to CoreAudio. */ /* - assert(!this->convert.needed); - assert(this->spec.channels == ioData->mNumberChannels); + SDL_assert(!this->convert.needed); + SDL_assert(this->spec.channels == ioData->mNumberChannels); */ for (i = 0; i < ioData->mNumberBuffers; i++) { diff --git a/src/stdlib/SDL_qsort.c b/src/stdlib/SDL_qsort.c index b91be69ca..6d56c6758 100644 --- a/src/stdlib/SDL_qsort.c +++ b/src/stdlib/SDL_qsort.c @@ -49,11 +49,12 @@ #include */ #include "SDL_stdinc.h" +#include "SDL_assert.h" #ifdef assert #undef assert #endif -#define assert(X) +#define assert(X) SDL_assert(X) #ifdef malloc #undef malloc #endif diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index 9242be7f1..d8537ee74 100755 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -424,7 +424,6 @@ BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo * info) #if HAVE_ALTIVEC_H #include #endif -#include #if (defined(__MACOSX__) && (__GNUC__ < 4)) #define VECUINT8_LITERAL(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \ diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index b52e2fe50..309cdeb72 100755 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -25,13 +25,14 @@ #include "SDL_cpuinfo.h" #include "SDL_blit.h" +#include "SDL_assert.h" + /* Functions to blit from N-bit surfaces to other surfaces */ #if SDL_ALTIVEC_BLITTERS #ifdef HAVE_ALTIVEC_H #include #endif -#define assert(X) #ifdef __MACOSX__ #include static size_t @@ -243,7 +244,7 @@ Blit_RGB888_RGB565Altivec(SDL_BlitInfo * info) vsrc = voverflow; } - assert(width == 0); + SDL_assert(width == 0); /* do scalar until we can align... */ ONE_PIXEL_BLEND((extrawidth), extrawidth); @@ -312,9 +313,8 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8, v8)) ); - - assert(srcfmt->BytesPerPixel == 2); - assert(dstfmt->BytesPerPixel == 4); + SDL_assert(srcfmt->BytesPerPixel == 2); + SDL_assert(dstfmt->BytesPerPixel == 4); vf800 = (vector unsigned short) vec_splat_u8(-7); vf800 = vec_sl(vf800, vec_splat_u16(8)); @@ -390,7 +390,7 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) vsrc = voverflow; } - assert(width == 0); + SDL_assert(width == 0); /* do scalar until we can align... */ @@ -460,9 +460,8 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) char) (vec_add((vector unsigned int) vgreen1, vec_sl(v8, v8)) ); - - assert(srcfmt->BytesPerPixel == 2); - assert(dstfmt->BytesPerPixel == 4); + SDL_assert(srcfmt->BytesPerPixel == 2); + SDL_assert(dstfmt->BytesPerPixel == 4); vf800 = (vector unsigned short) vec_splat_u8(-7); vf800 = vec_sl(vf800, vec_splat_u16(8)); @@ -538,7 +537,7 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) vsrc = voverflow; } - assert(width == 0); + SDL_assert(width == 0); /* do scalar until we can align... */ @@ -630,13 +629,13 @@ Blit32to32KeyAltivec(SDL_BlitInfo * info) } int width = info->dst_w; ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); - assert(width > 0); + SDL_assert(width > 0); if (width > 0) { int extrawidth = (width % 4); vector unsigned char valigner = VEC_ALIGNER(srcp); vector unsigned int vs = vec_ld(0, srcp); width -= extrawidth; - assert(width >= 4); + SDL_assert(width >= 4); while (width) { vector unsigned char vsel; vector unsigned int vd; @@ -691,8 +690,8 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) } } - assert(srcfmt->BytesPerPixel == 4); - assert(dstfmt->BytesPerPixel == 4); + SDL_assert(srcfmt->BytesPerPixel == 4); + SDL_assert(dstfmt->BytesPerPixel == 4); while (height--) { vector unsigned char valigner; @@ -729,7 +728,7 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) vbits = voverflow; } - assert(width == 0); + SDL_assert(width == 0); /* cover pixels at the end of the row that didn't fit in 16 bytes. */ while (extrawidth) { @@ -770,8 +769,8 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) } } - assert(srcfmt->BytesPerPixel == 4); - assert(dstfmt->BytesPerPixel == 4); + SDL_assert(srcfmt->BytesPerPixel == 4); + SDL_assert(dstfmt->BytesPerPixel == 4); while (height--) { vector unsigned char valigner; @@ -816,7 +815,7 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) vbits = voverflow; } - assert(width == 0); + SDL_assert(width == 0); /* cover pixels at the end of the row that didn't fit in 16 bytes. */ while (extrawidth) { diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index da62f1ec2..afada6cc6 100755 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -27,6 +27,7 @@ #include "SDL_shape.h" #include "SDL_cocoashape.h" #include "../SDL_sysvideo.h" +#include "SDL_assert.h" SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { @@ -49,7 +50,7 @@ data->shape = NULL; int resized_properly = Cocoa_ResizeWindowShape(window); - assert(resized_properly == 0); + SDL_assert(resized_properly == 0); return result; } @@ -100,7 +101,7 @@ int Cocoa_ResizeWindowShape(SDL_Window *window) { SDL_ShapeData* data = window->shaper->driverdata; - assert(data != NULL); + SDL_assert(data != NULL); return 0; } diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index f3875f0c5..08a189718 100755 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -311,7 +311,7 @@ X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int si int i = 0; /* assert buffer is large enough to hold all SDL attributes. */ - /* assert(size >= 32);*/ + SDL_assert(size >= 32); /* Setup our GLX attributes according to the gl_config. */ attribs[i++] = GLX_RGBA;