SDL: rwops: Rename everything from SDL_RWxxx to SDL_XxxRW.

From 7d4d8ccde09bd14d839c1cb2b4bac38ce423dda9 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 12 Mar 2024 16:01:59 -0400
Subject: [PATCH] rwops: Rename everything from SDL_RWxxx to SDL_XxxRW.

---
 build-scripts/SDL_migration.cocci |  30 +++++++++
 docs/README-migration.md          |  20 +++---
 include/SDL3/SDL_oldnames.h       |  12 ++++
 include/SDL3/SDL_rwops.h          |  79 ++++++++++++-----------
 src/audio/SDL_wave.c              |  18 +++---
 src/audio/disk/SDL_diskaudio.c    |   4 +-
 src/dynapi/SDL_dynapi.sym         |  10 +--
 src/dynapi/SDL_dynapi_overrides.h |  10 +--
 src/dynapi/SDL_dynapi_procs.h     |  10 +--
 src/file/SDL_rwops.c              |  56 ++++++++---------
 src/test/SDL_test_common.c        |   6 +-
 src/video/SDL_bmp.c               |  34 +++++-----
 test/testautomation_rwops.c       |  96 ++++++++++++++--------------
 test/testfile.c                   | 100 +++++++++++++++---------------
 test/testime.c                    |   6 +-
 test/testoverlay.c                |   2 +-
 test/testresample.c               |   2 +-
 test/teststreaming.c              |   2 +-
 18 files changed, 271 insertions(+), 226 deletions(-)

diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci
index 5ce27a86e1e2e..4a857728e091b 100644
--- a/build-scripts/SDL_migration.cocci
+++ b/build-scripts/SDL_migration.cocci
@@ -3048,3 +3048,33 @@ typedef SDL_version, SDL_Version;
 - SDL_JoystickGetBall
 + SDL_GetJoystickBall
   (...)
+@@
+@@
+- SDL_RWclose
++ SDL_CloseRW
+  (...)
+@@
+@@
+- SDL_RWread
++ SDL_ReadRW
+  (...)
+@@
+@@
+- SDL_RWwrite
++ SDL_WriteRW
+  (...)
+@@
+@@
+- SDL_RWtell
++ SDL_TellRW
+  (...)
+@@
+@@
+- SDL_RWsize
++ SDL_SizeRW
+  (...)
+@@
+@@
+- SDL_RWseek
++ SDL_SeekRW
+  (...)
diff --git a/docs/README-migration.md b/docs/README-migration.md
index b16a41a7c9d51..0bc458dd8329d 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -1156,11 +1156,11 @@ The following symbols have been renamed:
 * RW_SEEK_END => SDL_RW_SEEK_END
 * RW_SEEK_SET => SDL_RW_SEEK_SET
 
-SDL_RWops is now an opaque structure. The existing APIs to create a RWops (SDL_RWFromFile, etc) still function as expected, but to make a custom RWops with app-provided function pointers, call SDL_OpenRW and provide the function pointers through there. To call into a RWops's functionality, use the standard APIs (SDL_RWread, etc) instead of calling into function pointers directly.
+SDL_RWops is now an opaque structure. The existing APIs to create a RWops (SDL_RWFromFile, etc) still function as expected, but to make a custom RWops with app-provided function pointers, call SDL_OpenRW and provide the function pointers through there. To call into a RWops's functionality, use the standard APIs (SDL_ReadRW, etc) instead of calling into function pointers directly.
 
 The RWops function pointers are now in a separate structure called SDL_RWopsInteface, which is provided to SDL_OpenRW. All the functions now take a `void *` userdata argument for their first parameter instead of an SDL_RWops, since that's now an opaque structure.
 
-SDL_RWread and SDL_RWwrite (and SDL_RWopsInterface::read, SDL_RWopsInterface::write) have a different function signature in SDL3.
+SDL_RWread and SDL_RWwrite (and the read and write function pointers) have a different function signature in SDL3 in addition to being renamed.
 
 Previously they looked more like stdio:
 
@@ -1172,8 +1172,8 @@ size_t SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size, size_t maxn
 But now they look more like POSIX:
 
 ```c
-size_t SDL_RWread(void *userdata, void *ptr, size_t size);
-size_t SDL_RWwrite(void *userdata, const void *ptr, size_t size);
+size_t SDL_ReadRW(void *userdata, void *ptr, size_t size);
+size_t SDL_WriteRW(void *userdata, const void *ptr, size_t size);

Code that used to look like this:
@@ -1188,7 +1188,7 @@ should be changed to:
size_t custom_read(void *ptr, size_t size, size_t nitems, SDL_RWops *stream)
{
if (size > 0 && nitems > 0) {

  •    return SDL_RWread(stream, ptr, size * nitems) / size;
    
  •    return SDL_ReadRW(stream, ptr, size * nitems) / size;
    
    }
    return 0;
    }
    @@ -1200,7 +1200,7 @@ SDL_RWopsInterface::close implementations should clean up their own userdata, bu

SDL_RWFromFP has been removed from the API, due to issues when the SDL library uses a different C runtime from the application.

-SDL_AllocRW(), SDL_FreeRW(), SDL_RWclose() and direct access to the ->close function pointer have been removed from the API, so there’s only one path to manage RWops lifetimes now: SDL_OpenRW() and SDL_CloseRW().
+SDL_AllocRW(), SDL_FreeRW(), SDL_CloseRW() and direct access to the ->close function pointer have been removed from the API, so there’s only one path to manage RWops lifetimes now: SDL_OpenRW() and SDL_CloseRW().

You can implement this in your own code easily:
@@ -1286,7 +1286,7 @@ SDL_RWops *SDL_RWFromFP(FILE *fp, SDL_bool autoclose)
}

 SDL_zero(iface);
  • /* There’s no stdio_size because SDL_RWsize emulates it the same way we’d do it for stdio anyhow. */
  • /* There’s no stdio_size because SDL_SizeRW emulates it the same way we’d do it for stdio anyhow. */
    iface.seek = stdio_seek;
    iface.read = stdio_read;
    iface.write = stdio_write;
    @@ -1306,6 +1306,12 @@ SDL_RWops *SDL_RWFromFP(FILE *fp, SDL_bool autoclose)
    The functions SDL_ReadU8(), SDL_ReadU16LE(), SDL_ReadU16BE(), SDL_ReadU32LE(), SDL_ReadU32BE(), SDL_ReadU64LE(), and SDL_ReadU64BE() now return SDL_TRUE if the read succeeded and SDL_FALSE if it didn’t, and store the data in a pointer passed in as a parameter.

The following functions have been renamed:
+* SDL_RWclose() => SDL_CloseRW()
+* SDL_RWread() => SDL_ReadRW()
+* SDL_RWseek() => SDL_SeekRW()
+* SDL_RWsize() => SDL_SizeRW()
+* SDL_RWtell() => SDL_TellRW()
+* SDL_RWwrite() => SDL_WriteRW()

  • SDL_ReadBE16() => SDL_ReadU16BE()
  • SDL_ReadBE32() => SDL_ReadU32BE()
  • SDL_ReadBE64() => SDL_ReadU64BE()
    diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h
    index 1b2be561154aa…345991ba0c5d0 100644
    — a/include/SDL3/SDL_oldnames.h
    +++ b/include/SDL3/SDL_oldnames.h
    @@ -452,6 +452,12 @@
    #define RW_SEEK_CUR SDL_RW_SEEK_CUR
    #define RW_SEEK_END SDL_RW_SEEK_END
    #define RW_SEEK_SET SDL_RW_SEEK_SET
    +#define SDL_RWclose SDL_CloseRW
    +#define SDL_RWread SDL_ReadRW
    +#define SDL_RWseek SDL_SeekRW
    +#define SDL_RWsize SDL_SizeRW
    +#define SDL_RWtell SDL_TellRW
    +#define SDL_RWwrite SDL_WriteRW
    #define SDL_ReadBE16 SDL_ReadU16BE
    #define SDL_ReadBE32 SDL_ReadU32BE
    #define SDL_ReadBE64 SDL_ReadU64BE
    @@ -936,6 +942,12 @@
    #define RW_SEEK_CUR RW_SEEK_CUR_renamed_SDL_RW_SEEK_CUR
    #define RW_SEEK_END RW_SEEK_END_renamed_SDL_RW_SEEK_END
    #define RW_SEEK_SET RW_SEEK_SET_renamed_SDL_RW_SEEK_SET
    +#define SDL_RWclose SDL_RWclose_renamed_SDL_CloseRW
    +#define SDL_RWread SDL_RWread_renamed_SDL_ReadRW
    +#define SDL_RWseek SDL_RWseek_renamed_SDL_SeekRW
    +#define SDL_RWsize SDL_RWsize_renamed_SDL_SizeRW
    +#define SDL_RWtell SDL_RWtell_renamed_SDL_TellRW
    +#define SDL_RWwrite SDL_RWwrite_renamed_SDL_WriteRW
    #define SDL_ReadBE16 SDL_ReadBE16_renamed_SDL_ReadU16BE
    #define SDL_ReadBE32 SDL_ReadBE32_renamed_SDL_ReadU32BE
    #define SDL_ReadBE64 SDL_ReadBE64_renamed_SDL_ReadU64BE
    diff --git a/include/SDL3/SDL_rwops.h b/include/SDL3/SDL_rwops.h
    index 035886e8c49b4…2ac1e34d81616 100644
    — a/include/SDL3/SDL_rwops.h
    +++ b/include/SDL3/SDL_rwops.h
    @@ -160,10 +160,10 @@ typedef struct SDL_RWops SDL_RWops;
  • \sa SDL_RWFromConstMem
  • \sa SDL_RWFromMem
    • \sa SDL_RWread
    • \sa SDL_RWseek
    • \sa SDL_RWtell
    • \sa SDL_RWwrite
    • \sa SDL_ReadRW
    • \sa SDL_SeekRW
    • \sa SDL_TellRW
    • \sa SDL_WriteRW
      */
      extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *mode);

@@ -191,10 +191,10 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *

  • \sa SDL_RWFromConstMem
  • \sa SDL_RWFromFile
  • \sa SDL_RWFromMem
    • \sa SDL_RWread
    • \sa SDL_RWseek
    • \sa SDL_RWtell
    • \sa SDL_RWwrite
    • \sa SDL_ReadRW
    • \sa SDL_SeekRW
    • \sa SDL_TellRW
    • \sa SDL_WriteRW
      */
      extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, size_t size);

@@ -224,9 +224,9 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, size_t size);

  • \sa SDL_RWFromConstMem
  • \sa SDL_RWFromFile
  • \sa SDL_RWFromMem
    • \sa SDL_RWread
    • \sa SDL_RWseek
    • \sa SDL_RWtell
    • \sa SDL_ReadRW
    • \sa SDL_SeekRW
    • \sa SDL_TellRW
      */
      extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, size_t size);

@@ -272,9 +272,9 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_OpenRW(const SDL_RWopsInterface *iface, v

  • \sa SDL_RWFromConstMem
  • \sa SDL_RWFromFile
  • \sa SDL_RWFromMem
    • \sa SDL_RWread
    • \sa SDL_RWseek
    • \sa SDL_RWwrite
    • \sa SDL_ReadRW
    • \sa SDL_SeekRW
    • \sa SDL_WriteRW
      */
      extern DECLSPEC int SDLCALL SDL_CloseRW(SDL_RWops *context);

@@ -306,7 +306,7 @@ extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRWProperties(SDL_RWops *context)
*

  • \since This function is available since SDL 3.0.0.
    */
    -extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
    +extern DECLSPEC Sint64 SDLCALL SDL_SizeRW(SDL_RWops *context);

/**

  • Seek within an SDL_RWops data stream.
    @@ -321,9 +321,6 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
  • If this stream can not seek, it will return -1.
    • SDL_RWseek() is actually a wrapper function that calls the SDL_RWops’s
    • seek method appropriately, to simplify application development.
    • \param context a pointer to an SDL_RWops structure
    • \param offset an offset in bytes, relative to whence location; can be
    •           negative
      

@@ -337,16 +334,16 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);

  • \sa SDL_RWFromConstMem
  • \sa SDL_RWFromFile
  • \sa SDL_RWFromMem
    • \sa SDL_RWread
    • \sa SDL_RWtell
    • \sa SDL_RWwrite
    • \sa SDL_ReadRW
    • \sa SDL_TellRW
    • \sa SDL_WriteRW
      */
      -extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence);
      +extern DECLSPEC Sint64 SDLCALL SDL_SeekRW(SDL_RWops *context, Sint64 offset, int whence);

/**

  • Determine the current read/write offset in an SDL_RWops data stream.
    • SDL_RWtell is actually a wrapper function that calls the SDL_RWops’s seek
    • SDL_TellRW is actually a wrapper function that calls the SDL_RWops’s seek
    • method, with an offset of 0 bytes from SDL_RW_SEEK_CUR, to simplify
    • application development.

@@ -360,11 +357,11 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, Sint64 offset, int

  • \sa SDL_RWFromConstMem
  • \sa SDL_RWFromFile
  • \sa SDL_RWFromMem
    • \sa SDL_RWread
    • \sa SDL_RWseek
    • \sa SDL_RWwrite
    • \sa SDL_ReadRW
    • \sa SDL_SeekRW
    • \sa SDL_WriteRW
      */
      -extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
      +extern DECLSPEC Sint64 SDLCALL SDL_TellRW(SDL_RWops *context);

/**

  • Read from a data source.
    @@ -377,7 +374,7 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
  • that this is not an error or end-of-file, and the caller can try again
  • later.
    • SDL_RWread() is actually a function wrapper that calls the SDL_RWops’s
    • SDL_ReadRW() is actually a function wrapper that calls the SDL_RWops’s
    • read method appropriately, to simplify application development.
    • \param context a pointer to an SDL_RWops structure
      @@ -390,10 +387,10 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
    • \sa SDL_RWFromConstMem
    • \sa SDL_RWFromFile
    • \sa SDL_RWFromMem
    • \sa SDL_RWseek
    • \sa SDL_RWwrite
    • \sa SDL_SeekRW
    • \sa SDL_WriteRW
      */
      -extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, void *ptr, size_t size);
      +extern DECLSPEC size_t SDLCALL SDL_ReadRW(SDL_RWops *context, void *ptr, size_t size);

/**

  • Write to an SDL_RWops data stream.
    @@ -409,7 +406,7 @@ extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, void *ptr, size_t
  • written because it would require blocking, this function returns -2 to
  • distinguish that this is not an error and the caller can try again later.
    • SDL_RWwrite is actually a function wrapper that calls the SDL_RWops’s
    • SDL_WriteRW is actually a function wrapper that calls the SDL_RWops’s
    • write method appropriately, to simplify application development.
    • It is an error to specify a negative size, but this parameter is signed
      @@ -428,10 +425,10 @@ extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, void *ptr, size_t
    • \sa SDL_RWFromFile
    • \sa SDL_RWFromMem
    • \sa SDL_RWprint
    • \sa SDL_RWread
    • \sa SDL_RWseek
    • \sa SDL_ReadRW
    • \sa SDL_SeekRW
      */
      -extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size);
      +extern DECLSPEC size_t SDLCALL SDL_WriteRW(SDL_RWops *context, const void *ptr, size_t size);

/**

  • Print to an SDL_RWops data stream.
    @@ -450,9 +447,9 @@ extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, const void *ptr,
  • \sa SDL_RWFromConstMem
  • \sa SDL_RWFromFile
  • \sa SDL_RWFromMem
    • \sa SDL_RWread
    • \sa SDL_RWseek
    • \sa SDL_RWwrite
    • \sa SDL_ReadRW
    • \sa SDL_SeekRW
    • \sa SDL_WriteRW
      */
      extern DECLSPEC size_t SDLCALL SDL_RWprintf(SDL_RWops *context, SDL_PRINTF_FORMAT_STRING const char *fmt, …) SDL_PRINTF_VARARG_FUNC(2);

@@ -472,9 +469,9 @@ extern DECLSPEC size_t SDLCALL SDL_RWprintf(SDL_RWops *context, SDL_PRINTF_FORMA

  • \sa SDL_RWFromConstMem
  • \sa SDL_RWFromFile
  • \sa SDL_RWFromMem
    • \sa SDL_RWread
    • \sa SDL_RWseek
    • \sa SDL_RWwrite
    • \sa SDL_ReadRW
    • \sa SDL_SeekRW
    • \sa SDL_WriteRW
      */
      extern DECLSPEC size_t SDLCALL SDL_RWvprintf(SDL_RWops *context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2);

diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index 29f0cfb33d917…1792c91f7fee0 100644
— a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -1520,10 +1520,10 @@ static int WaveNextChunk(SDL_RWops *src, WaveChunk *chunk)
nextposition++;
}

  • if (SDL_RWseek(src, nextposition, SDL_RW_SEEK_SET) != nextposition) {
  • if (SDL_SeekRW(src, nextposition, SDL_RW_SEEK_SET) != nextposition) {
    /* Not sure how we ended up here. Just abort. */
    return -2;
  • } else if (SDL_RWread(src, chunkheader, sizeof(Uint32) * 2) != (sizeof(Uint32) * 2)) {
  • } else if (SDL_ReadRW(src, chunkheader, sizeof(Uint32) * 2) != (sizeof(Uint32) * 2)) {
    return -1;
    }

@@ -1548,12 +1548,12 @@ static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t len
return -1;
}

  •    if (SDL_RWseek(src, chunk->position, SDL_RW_SEEK_SET) != chunk->position) {
    
  •    if (SDL_SeekRW(src, chunk->position, SDL_RW_SEEK_SET) != chunk->position) {
           /* Not sure how we ended up here. Just abort. */
           return -2;
       }
    
  •    chunk->size = SDL_RWread(src, chunk->data, length);
    
  •    chunk->size = SDL_ReadRW(src, chunk->data, length);
       if (chunk->size != length) {
           /* Expected to be handled by the caller. */
       }
    

@@ -1655,7 +1655,7 @@ static int WaveReadFormat(WaveFile *file)

     if (!SDL_ReadU16LE(fmtsrc, &format->validsamplebits) ||
         !SDL_ReadU32LE(fmtsrc, &format->channelmask) ||
  •        SDL_RWread(fmtsrc, format->subformat, 16) != 16) {
    
  •        SDL_ReadRW(fmtsrc, format->subformat, 16) != 16) {
       }
       format->samplesperblock = format->validsamplebits;
       format->encoding = WaveGetFormatGUIDEncoding(format);
    

@@ -1795,7 +1795,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
}
}

  • RIFFstart = SDL_RWtell(src);
  • RIFFstart = SDL_TellRW(src);
    if (RIFFstart < 0) {
    return SDL_SetError(“Could not seek in file”);
    }
    @@ -1897,7 +1897,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec spec, Uint8 *
    file->fact.status = -1;
    } else {
    /
    Let’s use src directly, it’s just too convenient. */
  •                Sint64 position = SDL_RWseek(src, chunk->position, SDL_RW_SEEK_SET);
    
  •                Sint64 position = SDL_SeekRW(src, chunk->position, SDL_RW_SEEK_SET);
                   if (position == chunk->position && SDL_ReadU32LE(src, &file->fact.samplelength)) {
                       file->fact.status = 1;
                   } else {
    

@@ -1940,7 +1940,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
if (chunk->fourcc != DATA && chunk->length > 0) {
Uint8 tmp;
Uint64 position = (Uint64)chunk->position + chunk->length - 1;

  •        if (position > SDL_MAX_SINT64 || SDL_RWseek(src, (Sint64)position, SDL_RW_SEEK_SET) != (Sint64)position) {
    
  •        if (position > SDL_MAX_SINT64 || SDL_SeekRW(src, (Sint64)position, SDL_RW_SEEK_SET) != (Sint64)position) {
               return SDL_SetError("Could not seek to WAVE chunk data");
           } else if (!SDL_ReadU8(src, &tmp)) {
               return SDL_SetError("RIFF size truncates chunk");
    

@@ -2111,7 +2111,7 @@ int SDL_LoadWAV_RW(SDL_RWops *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uint8

 /* Cleanup */
 if (!freesrc) {
  •    SDL_RWseek(src, file.chunk.position, SDL_RW_SEEK_SET);
    
  •    SDL_SeekRW(src, file.chunk.position, SDL_RW_SEEK_SET);
    
    }
    WaveFreeChunkData(&file.chunk);
    SDL_free(file.decoderdata);
    diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c
    index cbd86180a1cd7…e6e9f9cb413dc 100644
    — a/src/audio/disk/SDL_diskaudio.c
    +++ b/src/audio/disk/SDL_diskaudio.c
    @@ -43,7 +43,7 @@ static int DISKAUDIO_WaitDevice(SDL_AudioDevice *device)

static int DISKAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size)
{

  • const int written = (int)SDL_RWwrite(device->hidden->io, buffer, (size_t)buffer_size);
  • const int written = (int)SDL_WriteRW(device->hidden->io, buffer, (size_t)buffer_size);
    if (written != buffer_size) { // If we couldn’t write, assume fatal error for now
    return -1;
    }
    @@ -64,7 +64,7 @@ static int DISKAUDIO_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, in
    const int origbuflen = buflen;

    if (h->io) {

  •    const int br = (int)SDL_RWread(h->io, buffer, (size_t)buflen);
    
  •    const int br = (int)SDL_ReadRW(h->io, buffer, (size_t)buflen);
       buflen -= br;
       buffer = ((Uint8 *)buffer) + br;
       if (buflen > 0) { // EOF (or error, but whatever).
    

diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym
index ae0f3fa573bf9…52c9bf387eeba 100644
— a/src/dynapi/SDL_dynapi.sym
+++ b/src/dynapi/SDL_dynapi.sym
@@ -467,11 +467,11 @@ SDL3_0.0.0 {
SDL_RWFromConstMem;
SDL_RWFromFile;
SDL_RWFromMem;

  • SDL_RWread;
  • SDL_RWseek;
  • SDL_RWsize;
  • SDL_RWtell;
  • SDL_RWwrite;
  • SDL_ReadRW;

  • SDL_SeekRW;

  • SDL_SizeRW;

  • SDL_TellRW;

  • SDL_WriteRW;
    SDL_RaiseWindow;
    SDL_ReadU16BE;
    SDL_ReadU32BE;
    diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
    index bb9d3a0e46f6c…aec8ec7bc660d 100644
    — a/src/dynapi/SDL_dynapi_overrides.h
    +++ b/src/dynapi/SDL_dynapi_overrides.h
    @@ -491,11 +491,11 @@
    #define SDL_RWFromConstMem SDL_RWFromConstMem_REAL
    #define SDL_RWFromFile SDL_RWFromFile_REAL
    #define SDL_RWFromMem SDL_RWFromMem_REAL
    -#define SDL_RWread SDL_RWread_REAL
    -#define SDL_RWseek SDL_RWseek_REAL
    -#define SDL_RWsize SDL_RWsize_REAL
    -#define SDL_RWtell SDL_RWtell_REAL
    -#define SDL_RWwrite SDL_RWwrite_REAL
    +#define SDL_ReadRW SDL_ReadRW_REAL
    +#define SDL_SeekRW SDL_SeekRW_REAL
    +#define SDL_SizeRW SDL_SizeRW_REAL
    +#define SDL_TellRW SDL_TellRW_REAL
    +#define SDL_WriteRW SDL_WriteRW_REAL
    #define SDL_RaiseWindow SDL_RaiseWindow_REAL
    #define SDL_ReadU16BE SDL_ReadU16BE_REAL
    #define SDL_ReadU32BE SDL_ReadU32BE_REAL
    diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
    index 370e9a8321b8c…516bfd291c384 100644
    — a/src/dynapi/SDL_dynapi_procs.h
    +++ b/src/dynapi/SDL_dynapi_procs.h
    @@ -536,11 +536,11 @@ SDL_DYNAPI_PROC(void,SDL_QuitSubSystem,(Uint32 a),(a),)
    SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromConstMem,(const void a, size_t b),(a,b),return)
    SDL_DYNAPI_PROC(SDL_RWops
    ,SDL_RWFromFile,(const char *a, const char b),(a,b),return)
    SDL_DYNAPI_PROC(SDL_RWops
    ,SDL_RWFromMem,(void *a, size_t b),(a,b),return)
    -SDL_DYNAPI_PROC(size_t,SDL_RWread,(SDL_RWops *a, void *b, size_t c),(a,b,c),return)
    -SDL_DYNAPI_PROC(Sint64,SDL_RWseek,(SDL_RWops *a, Sint64 b, int c),(a,b,c),return)
    -SDL_DYNAPI_PROC(Sint64,SDL_RWsize,(SDL_RWops *a),(a),return)
    -SDL_DYNAPI_PROC(Sint64,SDL_RWtell,(SDL_RWops *a),(a),return)
    -SDL_DYNAPI_PROC(size_t,SDL_RWwrite,(SDL_RWops *a, const void *b, size_t c),(a,b,c),return)
    +SDL_DYNAPI_PROC(size_t,SDL_ReadRW,(SDL_RWops *a, void *b, size_t c),(a,b,c),return)
    +SDL_DYNAPI_PROC(Sint64,SDL_SeekRW,(SDL_RWops *a, Sint64 b, int c),(a,b,c),return)
    +SDL_DYNAPI_PROC(Sint64,SDL_SizeRW,(SDL_RWops *a),(a),return)
    +SDL_DYNAPI_PROC(Sint64,SDL_TellRW,(SDL_RWops *a),(a),return)
    +SDL_DYNAPI_PROC(size_t,SDL_WriteRW,(SDL_RWops *a, const void *b, size_t c),(a,b,c),return)
    SDL_DYNAPI_PROC(int,SDL_RaiseWindow,(SDL_Window *a),(a),return)
    SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU16BE,(SDL_RWops *a, Uint16 *b),(a,b),return)
    SDL_DYNAPI_PROC(SDL_bool,SDL_ReadU32BE,(SDL_RWops *a, Uint32 *b),(a,b),return)
    diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
    index d736b3d83b558…5f0fc409cea24 100644
    — a/src/file/SDL_rwops.c
    +++ b/src/file/SDL_rwops.c
    @@ -415,7 +415,7 @@ static SDL_RWops *SDL_RWFromFP(FILE *fp, SDL_bool autoclose)

    SDL_RWopsInterface iface;
    SDL_zero(iface);

  • // There’s no stdio_size because SDL_RWsize emulates it the same way we’d do it for stdio anyhow.
  • // There’s no stdio_size because SDL_SizeRW emulates it the same way we’d do it for stdio anyhow.
    iface.seek = stdio_seek;
    iface.read = stdio_read;
    iface.write = stdio_write;
    @@ -748,7 +748,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
    goto done;
    }
  • size = SDL_RWsize(src);
  • size = SDL_SizeRW(src);
    if (size < 0) {
    size = FILE_CHUNK_SIZE;
    loading_chunks = SDL_TRUE;
    @@ -780,7 +780,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
    }
    }
  •    size_read = SDL_RWread(src, data + size_total, (size_t)(size - size_total));
    
  •    size_read = SDL_ReadRW(src, data + size_total, (size_t)(size - size_total));
       if (size_read > 0) {
           size_total += size_read;
           continue;
    

@@ -820,7 +820,7 @@ SDL_PropertiesID SDL_GetRWProperties(SDL_RWops *context)
return context->props;
}

-Sint64 SDL_RWsize(SDL_RWops *context)
+Sint64 SDL_SizeRW(SDL_RWops *context)
{
if (!context) {
return SDL_InvalidParamError(“context”);
@@ -828,19 +828,19 @@ Sint64 SDL_RWsize(SDL_RWops *context)
if (!context->iface.size) {
Sint64 pos, size;

  •    pos = SDL_RWseek(context, 0, SDL_RW_SEEK_CUR);
    
  •    pos = SDL_SeekRW(context, 0, SDL_RW_SEEK_CUR);
       if (pos < 0) {
           return -1;
       }
    
  •    size = SDL_RWseek(context, 0, SDL_RW_SEEK_END);
    
  •    size = SDL_SeekRW(context, 0, SDL_RW_SEEK_END);
    
  •    SDL_RWseek(context, pos, SDL_RW_SEEK_SET);
    
  •    SDL_SeekRW(context, pos, SDL_RW_SEEK_SET);
       return size;
    
    }
    return context->iface.size(context->userdata);
    }

-Sint64 SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence)
+Sint64 SDL_SeekRW(SDL_RWops *context, Sint64 offset, int whence)
{
if (!context) {
return SDL_InvalidParamError(“context”);
@@ -850,12 +850,12 @@ Sint64 SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence)
return context->iface.seek(context->userdata, offset, whence);
}

-Sint64 SDL_RWtell(SDL_RWops *context)
+Sint64 SDL_TellRW(SDL_RWops *context)
{

  • return SDL_RWseek(context, 0, SDL_RW_SEEK_CUR);
  • return SDL_SeekRW(context, 0, SDL_RW_SEEK_CUR);
    }

-size_t SDL_RWread(SDL_RWops *context, void *ptr, size_t size)
+size_t SDL_ReadRW(SDL_RWops *context, void *ptr, size_t size)
{
size_t bytes;

@@ -886,7 +886,7 @@ size_t SDL_RWread(SDL_RWops *context, void *ptr, size_t size)
return bytes;
}

-size_t SDL_RWwrite(SDL_RWops *context, const void *ptr, size_t size)
+size_t SDL_WriteRW(SDL_RWops *context, const void *ptr, size_t size)
{
size_t bytes;

@@ -927,7 +927,7 @@ size_t SDL_RWprintf(SDL_RWops *context, SDL_PRINTF_FORMAT_STRING const char *fmt
return 0;
}

  • bytes = SDL_RWwrite(context, string, (size_t)size);
  • bytes = SDL_WriteRW(context, string, (size_t)size);
    SDL_free(string);
    return bytes;
    }
    @@ -943,7 +943,7 @@ size_t SDL_RWvprintf(SDL_RWops *context, SDL_PRINTF_FORMAT_STRING const char *fm
    return 0;
    }
  • bytes = SDL_RWwrite(context, string, (size_t)size);
  • bytes = SDL_WriteRW(context, string, (size_t)size);
    SDL_free(string);
    return bytes;
    }
    @@ -955,7 +955,7 @@ SDL_bool SDL_ReadU8(SDL_RWops *src, Uint8 *value)
    Uint8 data = 0;
    SDL_bool result = SDL_FALSE;
  • if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
  • if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
    result = SDL_TRUE;
    }
    if (value) {
    @@ -969,7 +969,7 @@ SDL_bool SDL_ReadU16LE(SDL_RWops *src, Uint16 *value)
    Uint16 data = 0;
    SDL_bool result = SDL_FALSE;
  • if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
  • if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
    result = SDL_TRUE;
    }
    if (value) {
    @@ -988,7 +988,7 @@ SDL_bool SDL_ReadU16BE(SDL_RWops *src, Uint16 *value)
    Uint16 data = 0;
    SDL_bool result = SDL_FALSE;
  • if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
  • if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
    result = SDL_TRUE;
    }
    if (value) {
    @@ -1007,7 +1007,7 @@ SDL_bool SDL_ReadU32LE(SDL_RWops *src, Uint32 *value)
    Uint32 data = 0;
    SDL_bool result = SDL_FALSE;
  • if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
  • if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
    result = SDL_TRUE;
    }
    if (value) {
    @@ -1026,7 +1026,7 @@ SDL_bool SDL_ReadU32BE(SDL_RWops *src, Uint32 *value)
    Uint32 data = 0;
    SDL_bool result = SDL_FALSE;
  • if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
  • if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
    result = SDL_TRUE;
    }
    if (value) {
    @@ -1045,7 +1045,7 @@ SDL_bool SDL_ReadU64LE(SDL_RWops *src, Uint64 *value)
    Uint64 data = 0;
    SDL_bool result = SDL_FALSE;
  • if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
  • if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
    result = SDL_TRUE;
    }
    if (value) {
    @@ -1064,7 +1064,7 @@ SDL_bool SDL_ReadU64BE(SDL_RWops *src, Uint64 *value)
    Uint64 data = 0;
    SDL_bool result = SDL_FALSE;
  • if (SDL_RWread(src, &data, sizeof(data)) == sizeof(data)) {
  • if (SDL_ReadRW(src, &data, sizeof(data)) == sizeof(data)) {
    result = SDL_TRUE;
    }
    if (value) {
    @@ -1080,13 +1080,13 @@ SDL_bool SDL_ReadS64BE(SDL_RWops *src, Sint64 *value)

SDL_bool SDL_WriteU8(SDL_RWops *dst, Uint8 value)
{

  • return (SDL_RWwrite(dst, &value, sizeof(value)) == sizeof(value));
  • return (SDL_WriteRW(dst, &value, sizeof(value)) == sizeof(value));
    }

SDL_bool SDL_WriteU16LE(SDL_RWops *dst, Uint16 value)
{
const Uint16 swapped = SDL_SwapLE16(value);

  • return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
  • return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
    }

SDL_bool SDL_WriteS16LE(SDL_RWops *dst, Sint16 value)
@@ -1097,7 +1097,7 @@ SDL_bool SDL_WriteS16LE(SDL_RWops *dst, Sint16 value)
SDL_bool SDL_WriteU16BE(SDL_RWops *dst, Uint16 value)
{
const Uint16 swapped = SDL_SwapBE16(value);

  • return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
  • return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
    }

SDL_bool SDL_WriteS16BE(SDL_RWops *dst, Sint16 value)
@@ -1108,7 +1108,7 @@ SDL_bool SDL_WriteS16BE(SDL_RWops *dst, Sint16 value)
SDL_bool SDL_WriteU32LE(SDL_RWops *dst, Uint32 value)
{
const Uint32 swapped = SDL_SwapLE32(value);

  • return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
  • return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
    }

SDL_bool SDL_WriteS32LE(SDL_RWops *dst, Sint32 value)
@@ -1119,7 +1119,7 @@ SDL_bool SDL_WriteS32LE(SDL_RWops *dst, Sint32 value)
SDL_bool SDL_WriteU32BE(SDL_RWops *dst, Uint32 value)
{
const Uint32 swapped = SDL_SwapBE32(value);

  • return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
  • return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
    }

SDL_bool SDL_WriteS32BE(SDL_RWops *dst, Sint32 value)
@@ -1130,7 +1130,7 @@ SDL_bool SDL_WriteS32BE(SDL_RWops *dst, Sint32 value)
SDL_bool SDL_WriteU64LE(SDL_RWops *dst, Uint64 value)
{
const Uint64 swapped = SDL_SwapLE64(value);

  • return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
  • return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
    }

SDL_bool SDL_WriteS64LE(SDL_RWops *dst, Sint64 value)
@@ -1141,7 +1141,7 @@ SDL_bool SDL_WriteS64LE(SDL_RWops *dst, Sint64 value)
SDL_bool SDL_WriteU64BE(SDL_RWops *dst, Uint64 value)
{
const Uint64 swapped = SDL_SwapBE64(value);

  • return (SDL_RWwrite(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
  • return (SDL_WriteRW(dst, &swapped, sizeof(swapped)) == sizeof(swapped));
    }

SDL_bool SDL_WriteS64BE(SDL_RWops *dst, Sint64 value)
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 1673fb86d3832…81d0efa807463 100644
— a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1904,10 +1904,10 @@ static const void *SDLTest_ScreenShotClipboardProvider(void *context, const char

     file = SDL_RWFromFile(SCREENSHOT_FILE, "r");
     if (file) {
  •        size_t length = (size_t)SDL_RWsize(file);
    
  •        size_t length = (size_t)SDL_SizeRW(file);
           void *image = SDL_malloc(length);
           if (image) {
    
  •            if (SDL_RWread(file, image, length) != length) {
    
  •            if (SDL_ReadRW(file, image, length) != length) {
                   SDL_Log("Couldn't read %s: %s\n", SCREENSHOT_FILE, SDL_GetError());
                   SDL_free(image);
                   image = NULL;
    

@@ -1983,7 +1983,7 @@ static void SDLTest_PasteScreenShot(void)
file = SDL_RWFromFile(filename, “w”);
if (file) {
SDL_Log(“Writing clipboard image to %s”, filename);

  •            SDL_RWwrite(file, data, size);
    
  •            SDL_WriteRW(file, data, size);
               SDL_CloseRW(file);
           }
           SDL_free(data);
    

diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c
index 9c79092864310…9a80bcf7e61aa 100644
— a/src/video/SDL_bmp.c
+++ b/src/video/SDL_bmp.c
@@ -239,12 +239,12 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc)
}

 /* Read in the BMP file header */
  • fp_offset = SDL_RWtell(src);
  • fp_offset = SDL_TellRW(src);
    if (fp_offset < 0) {
    goto done;
    }
    SDL_ClearError();
  • if (SDL_RWread(src, magic, 2) != 2) {
(Patch may be truncated, please check the link at the top of this post.)