From 02ff85f2f355127f264b3203e1f95237bbac657f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 16 May 2024 10:07:02 -0700 Subject: [PATCH] Renamed SDL_SIMDGetAlignment() to SDL_GetSIMDAlignment() --- build-scripts/SDL_migration.cocci | 5 +++++ docs/README-migration.md | 5 ++++- include/SDL3/SDL_cpuinfo.h | 2 +- include/SDL3/SDL_oldnames.h | 6 ++++++ src/audio/SDL_audio.c | 12 ++++++------ src/audio/SDL_audiocvt.c | 4 ++-- src/audio/SDL_audioqueue.c | 2 +- src/audio/aaudio/SDL_aaudio.c | 2 +- src/camera/SDL_camera.c | 2 +- src/camera/android/SDL_camera_android.c | 2 +- src/camera/coremedia/SDL_camera_coremedia.m | 4 ++-- .../mediafoundation/SDL_camera_mediafoundation.c | 6 +++--- src/cpuinfo/SDL_cpuinfo.c | 2 +- src/dynapi/SDL_dynapi.sym | 2 +- src/dynapi/SDL_dynapi_overrides.h | 2 +- src/dynapi/SDL_dynapi_procs.h | 2 +- src/render/SDL_yuv_sw.c | 2 +- src/video/SDL_RLEaccel.c | 4 ++-- src/video/SDL_surface.c | 2 +- 19 files changed, 41 insertions(+), 27 deletions(-) diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index 83f8165a6..a939f7324 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -3179,3 +3179,8 @@ typedef SDL_Colour, SDL_Color; - SDL_LogResetPriorities + SDL_ResetLogPriorities (...) +@@ +@@ +- SDL_SIMDGetAlignment ++ SDL_GetSIMDAlignment + (...) diff --git a/docs/README-migration.md b/docs/README-migration.md index 1c9c8ef07..985e4f726 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -302,7 +302,10 @@ SDL_Has3DNow() has been removed; there is no replacement. SDL_HasRDTSC() has been removed; there is no replacement. Don't use the RDTSC opcode in modern times, use SDL_GetPerformanceCounter and SDL_GetPerformanceFrequency instead. -SDL_SIMDAlloc(), SDL_SIMDRealloc(), and SDL_SIMDFree() have been removed. You can use SDL_aligned_alloc() and SDL_aligned_free() with SDL_SIMDGetAlignment() to get the same functionality. +SDL_SIMDAlloc(), SDL_SIMDRealloc(), and SDL_SIMDFree() have been removed. You can use SDL_aligned_alloc() and SDL_aligned_free() with SDL_GetSIMDAlignment() to get the same functionality. + +The following functions have been renamed: +* SDL_SIMDGetAlignment() => SDL_GetSIMDAlignment() ## SDL_error.h diff --git a/include/SDL3/SDL_cpuinfo.h b/include/SDL3/SDL_cpuinfo.h index ccb0db180..356acc260 100644 --- a/include/SDL3/SDL_cpuinfo.h +++ b/include/SDL3/SDL_cpuinfo.h @@ -302,7 +302,7 @@ extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); * \sa SDL_aligned_alloc * \sa SDL_aligned_free */ -extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); +extern DECLSPEC size_t SDLCALL SDL_GetSIMDAlignment(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index c345acceb..1c774dfd5 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -70,6 +70,9 @@ #define SDL_LoadWAV_RW SDL_LoadWAV_IO #define SDL_NewAudioStream SDL_CreateAudioStream +/* ##SDL_cpuinfo.h */ +#define SDL_SIMDGetAlignment SDL_GetSIMDAlignment + /* ##SDL_events.h */ #define SDL_APP_DIDENTERBACKGROUND SDL_EVENT_DID_ENTER_BACKGROUND #define SDL_APP_DIDENTERFOREGROUND SDL_EVENT_DID_ENTER_FOREGROUND @@ -583,6 +586,9 @@ #define SDL_LoadWAV_RW SDL_LoadWAV_RW_renamed_SDL_LoadWAV_IO #define SDL_NewAudioStream SDL_NewAudioStream_renamed_SDL_CreateAudioStream +/* ##SDL_cpuinfo.h */ +#define SDL_SIMDGetAlignment SDL_SIMDGetAlignment_renamed_SDL_GetSIMDAlignment + /* ##SDL_events.h */ #define SDL_APP_DIDENTERBACKGROUND SDL_APP_DIDENTERBACKGROUND_renamed_SDL_EVENT_DID_ENTER_BACKGROUND #define SDL_APP_DIDENTERFOREGROUND SDL_APP_DIDENTERFOREGROUND_renamed_SDL_EVENT_DID_ENTER_FOREGROUND diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index e5d685711..47ee655f5 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -1617,14 +1617,14 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec SDL_UpdatedAudioDeviceFormat(device); // in case the backend changed things and forgot to call this. // Allocate a scratch audio buffer - device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); + device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->work_buffer) { ClosePhysicalAudioDevice(device); return -1; } if (device->spec.format != SDL_AUDIO_F32) { - device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); + device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->mix_buffer) { ClosePhysicalAudioDevice(device); return -1; @@ -1748,7 +1748,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac int retval = 0; if (logdev) { if (callback && !device->postmix_buffer) { - device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); + device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->postmix_buffer) { retval = -1; } @@ -2214,14 +2214,14 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL SDL_UpdatedAudioDeviceFormat(device); if (device->work_buffer && (device->work_buffer_size > orig_work_buffer_size)) { SDL_aligned_free(device->work_buffer); - device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); + device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->work_buffer) { kill_device = SDL_TRUE; } if (device->postmix_buffer) { SDL_aligned_free(device->postmix_buffer); - device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); + device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->postmix_buffer) { kill_device = SDL_TRUE; } @@ -2230,7 +2230,7 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL SDL_aligned_free(device->mix_buffer); device->mix_buffer = NULL; if (device->spec.format != SDL_AUDIO_F32) { - device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); + device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), device->work_buffer_size); if (!device->mix_buffer) { kill_device = SDL_TRUE; } diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index c1d920934..a59e08087 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -655,7 +655,7 @@ static Uint8 *EnsureAudioStreamWorkBufferSize(SDL_AudioStream *stream, size_t ne return stream->work_buffer; } - Uint8 *ptr = (Uint8 *) SDL_aligned_alloc(SDL_SIMDGetAlignment(), newlen); + Uint8 *ptr = (Uint8 *) SDL_aligned_alloc(SDL_GetSIMDAlignment(), newlen); if (!ptr) { return NULL; // previous work buffer is still valid! } @@ -838,7 +838,7 @@ static int GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int ou work_buffer_capacity = SDL_max(work_buffer_capacity, resample_convert_bytes); // SIMD-align the buffer - int simd_alignment = (int) SDL_SIMDGetAlignment(); + int simd_alignment = (int) SDL_GetSIMDAlignment(); work_buffer_capacity += simd_alignment - 1; work_buffer_capacity -= work_buffer_capacity % simd_alignment; diff --git a/src/audio/SDL_audioqueue.c b/src/audio/SDL_audioqueue.c index df16919bf..53ddddb17 100644 --- a/src/audio/SDL_audioqueue.c +++ b/src/audio/SDL_audioqueue.c @@ -625,7 +625,7 @@ int SDL_ResetAudioQueueHistory(SDL_AudioQueue *queue, int num_frames) Uint8 *history_buffer = queue->history_buffer; if (queue->history_capacity < length) { - history_buffer = SDL_aligned_alloc(SDL_SIMDGetAlignment(), length); + history_buffer = SDL_aligned_alloc(SDL_GetSIMDAlignment(), length); if (!history_buffer) { return -1; } diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index 265eaacaf..41a9f3b8c 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -353,7 +353,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device) // Allocate a double buffered mixing buffer hidden->num_buffers = 2; hidden->mixbuf_bytes = (hidden->num_buffers * device->buffer_size); - hidden->mixbuf = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), hidden->mixbuf_bytes); + hidden->mixbuf = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), hidden->mixbuf_bytes); if (!hidden->mixbuf) { return -1; } diff --git a/src/camera/SDL_camera.c b/src/camera/SDL_camera.c index fcc597585..081b3df40 100644 --- a/src/camera/SDL_camera.c +++ b/src/camera/SDL_camera.c @@ -151,7 +151,7 @@ static int ZombieAcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint if (!device->zombie_pixels) { // attempt to allocate and initialize a fake frame of pixels. const size_t buflen = GetFrameBufLen(&device->actual_spec); - device->zombie_pixels = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen); + device->zombie_pixels = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen); if (!device->zombie_pixels) { *timestampNS = 0; return 0; // oh well, say there isn't a frame yet, so we'll go back to waiting. Maybe allocation will succeed later...? diff --git a/src/camera/android/SDL_camera_android.c b/src/camera/android/SDL_camera_android.c index f96990eef..fd04bb36a 100644 --- a/src/camera/android/SDL_camera_android.c +++ b/src/camera/android/SDL_camera_android.c @@ -335,7 +335,7 @@ static int ANDROIDCAMERA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *fra buflen += (int) datalen; } - frame->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen); + frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen); if (frame->pixels == NULL) { retval = -1; } else { diff --git a/src/camera/coremedia/SDL_camera_coremedia.m b/src/camera/coremedia/SDL_camera_coremedia.m index 049c4a406..0b1b7ad98 100644 --- a/src/camera/coremedia/SDL_camera_coremedia.m +++ b/src/camera/coremedia/SDL_camera_coremedia.m @@ -175,7 +175,7 @@ static int COREMEDIA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, if ((planar == 0) && (numPlanes == 0)) { const int pitch = (int) CVPixelBufferGetBytesPerRow(image); const size_t buflen = pitch * frame->h; - frame->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen); + frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen); if (frame->pixels == NULL) { retval = -1; } else { @@ -190,7 +190,7 @@ static int COREMEDIA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, } buflen *= frame->h; - frame->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen); + frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen); if (frame->pixels == NULL) { retval = -1; } else { diff --git a/src/camera/mediafoundation/SDL_camera_mediafoundation.c b/src/camera/mediafoundation/SDL_camera_mediafoundation.c index 70b6c946f..6a7f97a3a 100644 --- a/src/camera/mediafoundation/SDL_camera_mediafoundation.c +++ b/src/camera/mediafoundation/SDL_camera_mediafoundation.c @@ -368,7 +368,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *f if (FAILED(ret)) { retval = -1; } else { - frame->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen); + frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen); if (frame->pixels == NULL) { retval = -1; } else { @@ -388,7 +388,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *f if (pitch < 0) { // image rows are reversed. bufstart += -pitch * (frame->h - 1); } - frame->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen); + frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen); if (frame->pixels == NULL) { retval = -1; } else { @@ -410,7 +410,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *f if (pitch < 0) { // image rows are reversed. bufstart += -pitch * (frame->h - 1); } - frame->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), buflen); + frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), buflen); if (frame->pixels == NULL) { retval = -1; } else { diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 6366f7c99..80790db9f 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -1158,7 +1158,7 @@ int SDL_GetSystemRAM(void) return SDL_SystemRAM; } -size_t SDL_SIMDGetAlignment(void) +size_t SDL_GetSIMDAlignment(void) { if (SDL_SIMDAlignment == 0xFFFFFFFF) { SDL_GetCPUFeatures(); /* make sure this has been calculated */ diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index b8d8d266f..027f3e15c 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -672,7 +672,7 @@ SDL3_0.0.0 { SDL_RumbleJoystickTriggers; SDL_RunApp; SDL_RunHapticEffect; - SDL_SIMDGetAlignment; + SDL_GetSIMDAlignment; SDL_SaveBMP; SDL_SaveBMP_IO; SDL_ScreenKeyboardShown; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 9d4d6415d..c9b7be376 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -697,7 +697,7 @@ #define SDL_RumbleJoystickTriggers SDL_RumbleJoystickTriggers_REAL #define SDL_RunApp SDL_RunApp_REAL #define SDL_RunHapticEffect SDL_RunHapticEffect_REAL -#define SDL_SIMDGetAlignment SDL_SIMDGetAlignment_REAL +#define SDL_GetSIMDAlignment SDL_GetSIMDAlignment_REAL #define SDL_SaveBMP SDL_SaveBMP_REAL #define SDL_SaveBMP_IO SDL_SaveBMP_IO_REAL #define SDL_ScreenKeyboardShown SDL_ScreenKeyboardShown_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 26a022388..1a931349a 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -718,7 +718,7 @@ SDL_DYNAPI_PROC(int,SDL_RumbleJoystick,(SDL_Joystick *a, Uint16 b, Uint16 c, Uin SDL_DYNAPI_PROC(int,SDL_RumbleJoystickTriggers,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_RunApp,(int a, char *b[], SDL_main_func c, void *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_RunHapticEffect,(SDL_Haptic *a, int b, Uint32 c),(a,b,c),return) -SDL_DYNAPI_PROC(size_t,SDL_SIMDGetAlignment,(void),(),return) +SDL_DYNAPI_PROC(size_t,SDL_GetSIMDAlignment,(void),(),return) SDL_DYNAPI_PROC(int,SDL_SaveBMP,(SDL_Surface *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SaveBMP_IO,(SDL_Surface *a, SDL_IOStream *b, SDL_bool c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenKeyboardShown,(SDL_Window *a),(a),return) diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index a72f1e1a8..8fa532d89 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -60,7 +60,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormatEnum format, int w, in SDL_SW_DestroyYUVTexture(swdata); return NULL; } - swdata->pixels = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), dst_size); + swdata->pixels = (Uint8 *)SDL_aligned_alloc(SDL_GetSIMDAlignment(), dst_size); if (!swdata->pixels) { SDL_SW_DestroyYUVTexture(swdata); return NULL; diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 83fdb8459..3d6830408 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1495,7 +1495,7 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) return SDL_FALSE; } - surface->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), size); + surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size); if (!surface->pixels) { return SDL_FALSE; } @@ -1567,7 +1567,7 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode) surface->flags |= SDL_RLEACCEL; return; } - surface->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), size); + surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size); if (!surface->pixels) { /* Oh crap... */ surface->flags |= SDL_RLEACCEL; diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 8b7e31192..24ebf4b30 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -171,7 +171,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormatEnum format /* Get the pixels */ if (surface->w && surface->h) { - surface->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), size); + surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size); if (!surface->pixels) { SDL_DestroySurface(surface); return NULL;