From d31251b0142ae6b275c75a13ce79288b9eb4864d Mon Sep 17 00:00:00 2001 From: Sylvain Date: Sun, 21 Nov 2021 22:30:48 +0100 Subject: [PATCH] use SDL's functions version inplace of libc version --- Xcode-iOS/Demos/src/accelerometer.c | 2 +- Xcode-iOS/Demos/src/fireworks.c | 12 ++--- Xcode-iOS/Demos/src/touch.c | 2 +- src/audio/SDL_audio.c | 2 +- src/audio/alsa/SDL_alsa_audio.c | 2 +- src/audio/psp/SDL_pspaudio.c | 2 +- src/audio/vita/SDL_vitaaudio.c | 2 +- src/core/freebsd/SDL_evdev_kbd_freebsd.c | 2 +- src/core/openbsd/SDL_wscons_kbd.c | 4 +- src/cpuinfo/SDL_cpuinfo.c | 4 +- src/filesystem/unix/SDL_sysfilesystem.c | 2 +- src/haptic/linux/SDL_syshaptic.c | 5 +- src/hidapi/android/hid.cpp | 23 ++++----- src/joystick/hidapi/SDL_hidapi_steam.c | 50 +++++++++---------- src/locale/SDL_locale.c | 2 +- src/misc/vita/SDL_sysurl.c | 2 +- src/power/haiku/SDL_syspower.c | 2 +- src/power/linux/SDL_syspower.c | 2 +- src/render/software/SDL_rotate.c | 4 +- .../vitagxm/SDL_render_vita_gxm_tools.c | 4 +- src/video/directfb/SDL_DirectFB_events.c | 2 +- src/video/directfb/SDL_DirectFB_mouse.c | 2 +- src/video/directfb/SDL_DirectFB_video.c | 2 +- src/video/directfb/SDL_DirectFB_window.c | 2 +- .../emscripten/SDL_emscriptenframebuffer.c | 2 +- src/video/haiku/SDL_BWin.h | 2 +- src/video/vita/SDL_vitaframebuffer.c | 2 +- src/video/vita/SDL_vitatouch.c | 2 +- src/video/wayland/SDL_waylandvideo.c | 2 +- src/video/x11/SDL_x11events.c | 14 +++--- src/video/x11/SDL_x11modes.c | 2 +- src/video/x11/SDL_x11shape.c | 2 +- src/video/x11/SDL_x11window.c | 4 +- src/video/x11/edid-parse.c | 2 +- test/checkkeysthreads.c | 2 +- test/testautomation_sdltest.c | 6 +-- test/testevdev.c | 10 ++-- test/testgl2.c | 4 +- test/testgles2_sdf.c | 4 +- test/testhaptic.c | 16 +++--- test/testime.c | 4 +- test/testloadso.c | 2 +- test/testrumble.c | 8 +-- test/testsem.c | 2 +- test/testtimer.c | 2 +- test/testyuv_cvt.c | 6 +-- 46 files changed, 114 insertions(+), 124 deletions(-) diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c index 2cc0123c2..925aee4e3 100644 --- a/Xcode-iOS/Demos/src/accelerometer.c +++ b/Xcode-iOS/Demos/src/accelerometer.c @@ -58,7 +58,7 @@ render(SDL_Renderer *renderer, int w, int h, double deltaTime) ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT * deltaMilliseconds; - speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy); + speed = SDL_sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy); if (speed > 0) { /* compensate for friction */ diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c index 2c4f621f1..600d20bbb 100644 --- a/Xcode-iOS/Demos/src/fireworks.c +++ b/Xcode-iOS/Demos/src/fireworks.c @@ -109,7 +109,7 @@ stepParticles(double deltaTime) } } else { float speed = - sqrt(curr->xvel * curr->xvel + curr->yvel * curr->yvel); + SDL_sqrt(curr->xvel * curr->xvel + curr->yvel * curr->yvel); /* if wind resistance is not powerful enough to stop us completely, then apply winde resistance, otherwise just stop us completely */ if (WIND_RESISTANCE * deltaMilliseconds < speed) { @@ -194,15 +194,15 @@ explodeEmitter(struct particle *emitter) /* come up with a random angle and speed for new particle */ float theta = randomFloat(0, 2.0f * 3.141592); float exponent = 3.0f; - float speed = randomFloat(0.00, powf(0.17, exponent)); - speed = powf(speed, 1.0f / exponent); + float speed = randomFloat(0.00, SDL_powf(0.17, exponent)); + speed = SDL_powf(speed, 1.0f / exponent); /* select the particle at the end of our array */ struct particle *p = &particles[num_active_particles]; /* set the particles properties */ - p->xvel = speed * cos(theta); - p->yvel = speed * sin(theta); + p->xvel = speed * SDL_cos(theta); + p->yvel = speed * SDL_sin(theta); p->x = emitter->x + emitter->xvel; p->y = emitter->y + emitter->yvel; p->isActive = 1; @@ -297,7 +297,7 @@ spawnEmitterParticle(GLfloat x, GLfloat y) p->y = screen_h; /* set velocity so that terminal point is (x,y) */ p->xvel = 0; - p->yvel = -sqrt(2 * ACCEL * (screen_h - y)); + p->yvel = -SDL_sqrt(2 * ACCEL * (screen_h - y)); /* set other attributes */ p->size = 10 * pointSizeScale; p->type = emitter; diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c index 6f727e435..918240b82 100644 --- a/Xcode-iOS/Demos/src/touch.c +++ b/Xcode-iOS/Demos/src/touch.c @@ -21,7 +21,7 @@ void drawLine(SDL_Renderer *renderer, float startx, float starty, float dx, float dy) { - float distance = sqrt(dx * dx + dy * dy); /* length of line segment (pythagoras) */ + float distance = SDL_sqrt(dx * dx + dy * dy); /* length of line segment (pythagoras) */ int iterations = distance / PIXELS_PER_ITERATION + 1; /* number of brush sprites to draw for the line */ float dx_prime = dx / iterations; /* x-shift per iteration */ float dy_prime = dy / iterations; /* y-shift per iteration */ diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index fd8e6da8b..318644e6f 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -1753,7 +1753,7 @@ SDL_SilenceValueForFormat(const SDL_AudioFormat format) { switch (format) { /* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a - !!! FIXME: byte for memset() use. This is actually 0.1953 percent + !!! FIXME: byte for SDL_memset() use. This is actually 0.1953 percent !!! FIXME: off from silence. Maybe just don't use U16. */ case AUDIO_U16LSB: case AUDIO_U16MSB: diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 79c879fb6..2c6974324 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -779,7 +779,7 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee /* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output". just chop the extra lines off, this seems to get a reasonable device name without extra details. */ - if ((ptr = strchr(desc, '\n')) != NULL) { + if ((ptr = SDL_strchr(desc, '\n')) != NULL) { *ptr = '\0'; } diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index 5eeb0da5a..e98604c6c 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -90,7 +90,7 @@ PSPAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) return SDL_SetError("Couldn't reserve hardware channel"); } - memset(this->hidden->rawbuf, 0, mixlen); + SDL_memset(this->hidden->rawbuf, 0, mixlen); for (i = 0; i < NUM_BUFFERS; i++) { this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size]; } diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c index b69aed8d2..72929eb1c 100644 --- a/src/audio/vita/SDL_vitaaudio.c +++ b/src/audio/vita/SDL_vitaaudio.c @@ -100,7 +100,7 @@ VITAAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) sceAudioOutSetVolume(this->hidden->channel, SCE_AUDIO_VOLUME_FLAG_L_CH|SCE_AUDIO_VOLUME_FLAG_R_CH, vols); - memset(this->hidden->rawbuf, 0, mixlen); + SDL_memset(this->hidden->rawbuf, 0, mixlen); for (i = 0; i < NUM_BUFFERS; i++) { this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size]; } diff --git a/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/src/core/freebsd/SDL_evdev_kbd_freebsd.c index 06642b507..c74b1b894 100644 --- a/src/core/freebsd/SDL_evdev_kbd_freebsd.c +++ b/src/core/freebsd/SDL_evdev_kbd_freebsd.c @@ -268,7 +268,7 @@ SDL_EVDEV_kbd_init(void) kbd->key_map = &keymap_default_us_acc; } /* Allow inhibiting keyboard mute with env. variable for debugging etc. */ - if (getenv("SDL_INPUT_FREEBSD_KEEP_KBD") == NULL) { + if (SDL_getenv("SDL_INPUT_FREEBSD_KEEP_KBD") == NULL) { /* Take keyboard from console and open the actual keyboard device. * Ensures that the keystrokes do not leak through to the console. */ diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index a507b6faf..b59df0fc2 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -509,7 +509,7 @@ static void put_utf8(SDL_WSCONS_input_data* input, uint c) static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym) { if (KS_GROUP(ksym) == KS_GROUP_Keypad) { - if (isprint(ksym & 0xFF)) ksym &= 0xFF; + if (SDL_isprint(ksym & 0xFF)) ksym &= 0xFF; } switch(ksym) { case KS_Escape: @@ -526,7 +526,7 @@ static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym) if (input->text_len > 0) { input->text[input->text_len] = '\0'; SDL_SendKeyboardText(input->text); - /*memset(input->text, 0, sizeof(input->text));*/ + /*SDL_memset(input->text, 0, sizeof(input->text));*/ input->text_len = 0; input->text[0] = 0; } diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 77495562f..a26b89214 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -377,8 +377,8 @@ CPU_haveARMSIMD(void) { const char *plat = (const char *) aux.a_un.a_val; if (plat) { - arm_simd = strncmp(plat, "v6l", 3) == 0 || - strncmp(plat, "v7l", 3) == 0; + arm_simd = SDL_strncmp(plat, "v6l", 3) == 0 || + SDL_strncmp(plat, "v7l", 3) == 0; } } } diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index c39c07a08..83321b85b 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -82,7 +82,7 @@ readSymLink(const char *path) #if defined(__OPENBSD__) static char *search_path_for_binary(const char *bin) { - char *envr = getenv("PATH"); + char *envr = SDL_getenv("PATH"); size_t alloc_size; char *exe = NULL; char *start = envr; diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 555fd836e..744a54e67 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -35,7 +35,6 @@ #include /* O_RDWR */ #include /* INT_MAX */ #include /* errno, strerror */ -#include /* atan2 */ #include /* stat */ /* Just in case. */ @@ -713,10 +712,10 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) else { float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */ /* - atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) + SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) - Y-axis-value is the second coordinate (from center to SOUTH) - X-axis-value is the first coordinate (from center to EAST) - We add 36000, because atan2 also returns negative values. Then we practically + We add 36000, because SDL_atan2 also returns negative values. Then we practically have the first spherical value. Therefore we proceed as in case SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value. --> add 45000 in total diff --git a/src/hidapi/android/hid.cpp b/src/hidapi/android/hid.cpp index bac7bc499..0984f47eb 100644 --- a/src/hidapi/android/hid.cpp +++ b/src/hidapi/android/hid.cpp @@ -53,7 +53,6 @@ #include #include // For ETIMEDOUT and ECONNRESET #include // For malloc() and free() -#include // For memcpy() #define TAG "hidapi" @@ -196,7 +195,7 @@ public: } m_nSize = nSize; - memcpy( m_pData, pData, nSize ); + SDL_memcpy( m_pData, pData, nSize ); } void clear() @@ -313,7 +312,7 @@ static jbyteArray NewByteArray( JNIEnv* env, const uint8_t *pData, size_t nDataL { jbyteArray array = env->NewByteArray( (jsize)nDataLen ); jbyte *pBuf = env->GetByteArrayElements( array, NULL ); - memcpy( pBuf, pData, nDataLen ); + SDL_memcpy( pBuf, pData, nDataLen ); env->ReleaseByteArrayElements( array, pBuf, 0 ); return array; @@ -324,7 +323,7 @@ static char *CreateStringFromJString( JNIEnv *env, const jstring &sString ) size_t nLength = env->GetStringUTFLength( sString ); const char *pjChars = env->GetStringUTFChars( sString, NULL ); char *psString = (char*)malloc( nLength + 1 ); - memcpy( psString, pjChars, nLength ); + SDL_memcpy( psString, pjChars, nLength ); psString[ nLength ] = '\0'; env->ReleaseStringUTFChars( sString, pjChars ); return psString; @@ -347,9 +346,9 @@ static wchar_t *CreateWStringFromJString( JNIEnv *env, const jstring &sString ) static wchar_t *CreateWStringFromWString( const wchar_t *pwSrc ) { - size_t nLength = wcslen( pwSrc ); + size_t nLength = SDL_wcslen( pwSrc ); wchar_t *pwString = (wchar_t*)malloc( ( nLength + 1 ) * sizeof( wchar_t ) ); - memcpy( pwString, pwSrc, nLength * sizeof( wchar_t ) ); + SDL_memcpy( pwString, pwSrc, nLength * sizeof( wchar_t ) ); pwString[ nLength ] = '\0'; return pwString; } @@ -358,7 +357,7 @@ static hid_device_info *CopyHIDDeviceInfo( const hid_device_info *pInfo ) { hid_device_info *pCopy = new hid_device_info; *pCopy = *pInfo; - pCopy->path = strdup( pInfo->path ); + pCopy->path = SDL_strdup( pInfo->path ); pCopy->product_string = CreateWStringFromWString( pInfo->product_string ); pCopy->manufacturer_string = CreateWStringFromWString( pInfo->manufacturer_string ); pCopy->serial_number = CreateWStringFromWString( pInfo->serial_number ); @@ -579,12 +578,12 @@ public: if ( m_bIsBLESteamController ) { data[0] = 0x03; - memcpy( data + 1, buffer.data(), nDataLen ); + SDL_memcpy( data + 1, buffer.data(), nDataLen ); ++nDataLen; } else { - memcpy( data, buffer.data(), nDataLen ); + SDL_memcpy( data, buffer.data(), nDataLen ); } m_vecData.pop_front(); @@ -721,7 +720,7 @@ public: } size_t uBytesToCopy = m_featureReport.size() > nDataLen ? nDataLen : m_featureReport.size(); - memcpy( pData, m_featureReport.data(), uBytesToCopy ); + SDL_memcpy( pData, m_featureReport.data(), uBytesToCopy ); m_featureReport.clear(); LOGV( "=== Got %u bytes", uBytesToCopy ); @@ -921,7 +920,7 @@ JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceConnected)(JNI LOGV( "HIDDeviceConnected() id=%d VID/PID = %.4x/%.4x, interface %d\n", nDeviceID, nVendorId, nProductId, nInterface ); hid_device_info *pInfo = new hid_device_info; - memset( pInfo, 0, sizeof( *pInfo ) ); + SDL_memset( pInfo, 0, sizeof( *pInfo ) ); pInfo->path = CreateStringFromJString( env, sIdentifier ); pInfo->vendor_id = nVendorId; pInfo->product_id = nProductId; @@ -1120,7 +1119,7 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bEx hid_mutex_guard l( &g_DevicesMutex ); for ( hid_device_ref pCurr = g_Devices; pCurr; pCurr = pCurr->next ) { - if ( strcmp( pCurr->GetDeviceInfo()->path, path ) == 0 ) + if ( SDL_strcmp( pCurr->GetDeviceInfo()->path, path ) == 0 ) { hid_device *pValue = pCurr->GetDevice(); if ( pValue ) diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index d89bd0834..5cbf3391b 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -220,7 +220,7 @@ static void hexdump( const uint8_t *ptr, int len ) static void ResetSteamControllerPacketAssembler( SteamControllerPacketAssembler *pAssembler ) { - memset( pAssembler->uBuffer, 0, sizeof( pAssembler->uBuffer ) ); + SDL_memset( pAssembler->uBuffer, 0, sizeof( pAssembler->uBuffer ) ); pAssembler->nExpectedSegmentNumber = 0; } @@ -279,7 +279,7 @@ static int WriteSegmentToSteamControllerPacketAssembler( SteamControllerPacketAs } } - memcpy( pAssembler->uBuffer + nSegmentNumber * MAX_REPORT_SEGMENT_PAYLOAD_SIZE, + SDL_memcpy( pAssembler->uBuffer + nSegmentNumber * MAX_REPORT_SEGMENT_PAYLOAD_SIZE, pSegment + 2, // ignore header and report number MAX_REPORT_SEGMENT_PAYLOAD_SIZE ); @@ -294,7 +294,7 @@ static int WriteSegmentToSteamControllerPacketAssembler( SteamControllerPacketAs else { // Just pass through - memcpy( pAssembler->uBuffer, + SDL_memcpy( pAssembler->uBuffer, pSegment, nSegmentLength ); return nSegmentLength; @@ -331,10 +331,10 @@ static int SetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65], int nActualDataLen -= nBytesInPacket; // Construct packet - memset( uPacketBuffer, 0, sizeof( uPacketBuffer ) ); + SDL_memset( uPacketBuffer, 0, sizeof( uPacketBuffer ) ); uPacketBuffer[ 0 ] = BLE_REPORT_NUMBER; uPacketBuffer[ 1 ] = GetSegmentHeader( nSegmentNumber, nActualDataLen == 0 ); - memcpy( &uPacketBuffer[ 2 ], pBufferPtr, nBytesInPacket ); + SDL_memcpy( &uPacketBuffer[ 2 ], pBufferPtr, nBytesInPacket ); pBufferPtr += nBytesInPacket; nSegmentNumber++; @@ -364,7 +364,7 @@ static int GetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65] ) while( nRetries < BLE_MAX_READ_RETRIES ) { - memset( uSegmentBuffer, 0, sizeof( uSegmentBuffer ) ); + SDL_memset( uSegmentBuffer, 0, sizeof( uSegmentBuffer ) ); uSegmentBuffer[ 0 ] = BLE_REPORT_NUMBER; nRet = SDL_hid_get_feature_report( dev, uSegmentBuffer, sizeof( uSegmentBuffer ) ); DPRINTF( "GetFeatureReport ble ret=%d\n", nRet ); @@ -386,7 +386,7 @@ static int GetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65] ) { // Leave space for "report number" uBuffer[ 0 ] = 0; - memcpy( uBuffer + 1, assembler.uBuffer, nPacketLength ); + SDL_memcpy( uBuffer + 1, assembler.uBuffer, nPacketLength ); return nPacketLength; } } @@ -500,7 +500,7 @@ static bool ResetSteamController( SDL_hid_device *dev, bool bSuppressErrorSpew, } // Reset the default settings - memset( buf, 0, 65 ); + SDL_memset( buf, 0, 65 ); buf[1] = ID_LOAD_DEFAULT_SETTINGS; buf[2] = 0; res = SetFeatureReport( dev, buf, 3 ); @@ -518,7 +518,7 @@ buf[3+nSettings*3+1] = ((uint16_t)VALUE)&0xFF; \ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \ ++nSettings; - memset( buf, 0, 65 ); + SDL_memset( buf, 0, 65 ); buf[1] = ID_SET_SETTINGS_VALUES; ADD_SETTING( SETTING_WIRELESS_PACKET_VERSION, 2 ); ADD_SETTING( SETTING_LEFT_TRACKPAD_MODE, TRACKPAD_NONE ); @@ -547,7 +547,7 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \ int iRetry; for ( iRetry = 0; iRetry < 2; ++iRetry ) { - memset( buf, 0, 65 ); + SDL_memset( buf, 0, 65 ); buf[1] = ID_GET_DIGITAL_MAPPINGS; buf[2] = 1; // one byte - requesting from index 0 buf[3] = 0; @@ -580,7 +580,7 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \ } // Set our new mappings - memset( buf, 0, 65 ); + SDL_memset( buf, 0, 65 ); buf[1] = ID_SET_DIGITAL_MAPPINGS; buf[2] = 6; // 2 settings x 3 bytes buf[3] = IO_DIGITAL_BUTTON_RIGHT_TRIGGER; @@ -608,7 +608,7 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \ //--------------------------------------------------------------------------- static int ReadSteamController( SDL_hid_device *dev, uint8_t *pData, int nDataSize ) { - memset( pData, 0, nDataSize ); + SDL_memset( pData, 0, nDataSize ); pData[ 0 ] = BLE_REPORT_NUMBER; // hid_read will also overwrite this with the same value, 0x03 return SDL_hid_read( dev, pData, nDataSize ); } @@ -624,18 +624,18 @@ static void CloseSteamController( SDL_hid_device *dev ) int nSettings = 0; // Reset digital button mappings - memset( buf, 0, 65 ); + SDL_memset( buf, 0, 65 ); buf[1] = ID_SET_DEFAULT_DIGITAL_MAPPINGS; SetFeatureReport( dev, buf, 2 ); // Reset the default settings - memset( buf, 0, 65 ); + SDL_memset( buf, 0, 65 ); buf[1] = ID_LOAD_DEFAULT_SETTINGS; buf[2] = 0; SetFeatureReport( dev, buf, 3 ); // Reset mouse mode for lizard mode - memset( buf, 0, 65 ); + SDL_memset( buf, 0, 65 ); buf[1] = ID_SET_SETTINGS_VALUES; ADD_SETTING( SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_ABSOLUTE_MOUSE ); buf[2] = nSettings*3; @@ -695,14 +695,14 @@ static void FormatStatePacketUntilGyro( SteamControllerStateInternal_t *pState, // 15 degrees in rad const float flRotationAngle = 0.261799f; - memset(pState, 0, offsetof(SteamControllerStateInternal_t, sBatteryLevel)); + SDL_memset(pState, 0, offsetof(SteamControllerStateInternal_t, sBatteryLevel)); //pState->eControllerType = m_eControllerType; pState->eControllerType = 2; // k_eControllerType_SteamController; pState->unPacketNum = pStatePacket->unPacketNum; // We have a chunk of trigger data in the packet format here, so zero it out afterwards - memcpy(&pState->ulButtons, &pStatePacket->ButtonTriggerData.ulButtons, 8); + SDL_memcpy(&pState->ulButtons, &pStatePacket->ButtonTriggerData.ulButtons, 8); pState->ulButtons &= ~0xFFFF000000LL; // The firmware uses this bit to tell us what kind of data is packed into the left two axises @@ -822,7 +822,7 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize, ucOptionDataMask |= (uint32_t)(*pData++) << 8; if ( ucOptionDataMask & k_EBLEButtonChunk1 ) { - memcpy( &pState->ulButtons, pData, 3 ); + SDL_memcpy( &pState->ulButtons, pData, 3 ); pData += 3; } if ( ucOptionDataMask & k_EBLEButtonChunk2 ) @@ -844,14 +844,14 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize, // This doesn't handle any of the special headcrab stuff for raw joystick which is OK for now since that FW doesn't support // this protocol yet either int nLength = sizeof( pState->sLeftStickX ) + sizeof( pState->sLeftStickY ); - memcpy( &pState->sLeftStickX, pData, nLength ); + SDL_memcpy( &pState->sLeftStickX, pData, nLength ); pData += nLength; } if ( ucOptionDataMask & k_EBLELeftTrackpadChunk ) { int nLength = sizeof( pState->sLeftPadX ) + sizeof( pState->sLeftPadY ); int nPadOffset; - memcpy( &pState->sLeftPadX, pData, nLength ); + SDL_memcpy( &pState->sLeftPadX, pData, nLength ); if ( pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK ) nPadOffset = 1000; else @@ -867,7 +867,7 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize, int nLength = sizeof( pState->sRightPadX ) + sizeof( pState->sRightPadY ); int nPadOffset = 0; - memcpy( &pState->sRightPadX, pData, nLength ); + SDL_memcpy( &pState->sRightPadX, pData, nLength ); if ( pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK ) nPadOffset = 1000; @@ -882,19 +882,19 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize, if ( ucOptionDataMask & k_EBLEIMUAccelChunk ) { int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ ); - memcpy( &pState->sAccelX, pData, nLength ); + SDL_memcpy( &pState->sAccelX, pData, nLength ); pData += nLength; } if ( ucOptionDataMask & k_EBLEIMUGyroChunk ) { int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ ); - memcpy( &pState->sGyroX, pData, nLength ); + SDL_memcpy( &pState->sGyroX, pData, nLength ); pData += nLength; } if ( ucOptionDataMask & k_EBLEIMUQuatChunk ) { int nLength = sizeof( pState->sGyroQuatW ) + sizeof( pState->sGyroQuatX ) + sizeof( pState->sGyroQuatY ) + sizeof( pState->sGyroQuatZ ); - memcpy( &pState->sGyroQuatW, pData, nLength ); + SDL_memcpy( &pState->sGyroQuatW, pData, nLength ); pData += nLength; } return true; @@ -1122,7 +1122,7 @@ HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *jo unsigned char buf[65]; int nSettings = 0; - memset( buf, 0, 65 ); + SDL_memset( buf, 0, 65 ); buf[1] = ID_SET_SETTINGS_VALUES; if (enabled) { ADD_SETTING( SETTING_GYRO_MODE, 0x18 /* SETTING_GYRO_SEND_RAW_ACCEL | SETTING_GYRO_MODE_SEND_RAW_GYRO */ ); diff --git a/src/locale/SDL_locale.c b/src/locale/SDL_locale.c index 59f3e7fe5..e475b0755 100644 --- a/src/locale/SDL_locale.c +++ b/src/locale/SDL_locale.c @@ -45,7 +45,7 @@ build_locales_from_csv_string(char *csv) num_locales++; /* one more for terminator */ - slen = ((size_t) (ptr - csv)) + 1; /* strlen(csv) + 1 */ + slen = ((size_t) (ptr - csv)) + 1; /* SDL_strlen(csv) + 1 */ alloclen = slen + (num_locales * sizeof (SDL_Locale)); loc = retval = (SDL_Locale *) SDL_calloc(1, alloclen); diff --git a/src/misc/vita/SDL_sysurl.c b/src/misc/vita/SDL_sysurl.c index 42f6c456e..68f399776 100644 --- a/src/misc/vita/SDL_sysurl.c +++ b/src/misc/vita/SDL_sysurl.c @@ -35,7 +35,7 @@ SDL_SYS_OpenURL(const char *url) sceAppUtilInit(&init_param, &boot_param); SDL_zero(browser_param); browser_param.str = url; - browser_param.strlen = strlen(url); + browser_param.strlen = SDL_strlen(url); sceAppUtilLaunchWebBrowser(&browser_param); return 0; } diff --git a/src/power/haiku/SDL_syspower.c b/src/power/haiku/SDL_syspower.c index 87167b91c..4ae965706 100644 --- a/src/power/haiku/SDL_syspower.c +++ b/src/power/haiku/SDL_syspower.c @@ -59,7 +59,7 @@ SDL_GetPowerInfo_Haiku(SDL_PowerState * state, int *seconds, int *percent) return SDL_FALSE; /* maybe some other method will work? */ } - memset(regs, '\0', sizeof(regs)); + SDL_memset(regs, '\0', sizeof(regs)); regs[0] = APM_FUNC_OFFSET + APM_FUNC_GET_POWER_STATUS; regs[1] = APM_DEVICE_ALL; rc = ioctl(fd, APM_BIOS_CALL, regs); diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index f91100543..c02ef0db5 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -51,7 +51,7 @@ open_power_file(const char *base, const char *node, const char *key) return -1; /* oh well. */ } - snprintf(path, pathlen, "%s/%s/%s", base, node, key); + SDL_snprintf(path, pathlen, "%s/%s/%s", base, node, key); fd = open(path, O_RDONLY | O_CLOEXEC); SDL_stack_free(path); return fd; diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index a903d1db2..b5ac715e8 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -184,7 +184,7 @@ computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int if (signy < 0) sp += (src->h-1)*src->pitch; \ \ for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \ - if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use memcpy */ \ + if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use SDL_memcpy */ \ SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \ sp += dst->w*sizeof(pixelType); \ dp += dst->w*sizeof(pixelType); \ @@ -439,7 +439,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, if (!(is8bit || (src->format->BitsPerPixel == 32 && src->format->Amask))) return NULL; - /* Calculate target factors from sin/cos and zoom */ + /* Calculate target factors from sine/cosine and zoom */ sangleinv = sangle*65536.0; cangleinv = cangle*65536.0; diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c index 08c361106..6d0a4b9cc 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c @@ -475,7 +475,7 @@ gxm_init(SDL_Renderer *renderer) SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, &data->displayBufferUid[i]); - // memset the buffer to black + // SDL_memset the buffer to black for (y = 0; y < VITA_GXM_SCREEN_HEIGHT; y++) { unsigned int *row = (unsigned int *)data->displayBufferData[i] + y * VITA_GXM_SCREEN_STRIDE; for (x = 0; x < VITA_GXM_SCREEN_WIDTH; x++) { @@ -1104,7 +1104,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc // set up parameters SceGxmRenderTargetParams renderTargetParams; - memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams)); + SDL_memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams)); renderTargetParams.flags = 0; renderTargetParams.width = w; renderTargetParams.height = h; diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index c8c3368a8..7e19bbee7 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -683,7 +683,7 @@ EnumKeyboards(DFBInputDeviceID device_id, #endif devdata->keyboard[devdata->num_keyboard].id = device_id; devdata->keyboard[devdata->num_keyboard].is_generic = 0; - if (!strncmp("X11", desc.name, 3)) + if (!SDL_strncmp("X11", desc.name, 3)) { devdata->keyboard[devdata->num_keyboard].map = xfree86_scancode_table2; devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(xfree86_scancode_table2); diff --git a/src/video/directfb/SDL_DirectFB_mouse.c b/src/video/directfb/SDL_DirectFB_mouse.c index 967462561..597fc3aa8 100644 --- a/src/video/directfb/SDL_DirectFB_mouse.c +++ b/src/video/directfb/SDL_DirectFB_mouse.c @@ -164,7 +164,7 @@ DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) p = surface->pixels; for (i = 0; i < surface->h; i++) - memcpy((char *) dest + i * pitch, + SDL_memcpy((char *) dest + i * pitch, (char *) p + i * surface->pitch, 4 * surface->w); curdata->surf->Unlock(curdata->surf); diff --git a/src/video/directfb/SDL_DirectFB_video.c b/src/video/directfb/SDL_DirectFB_video.c index cca2fd7e2..25529716c 100644 --- a/src/video/directfb/SDL_DirectFB_video.c +++ b/src/video/directfb/SDL_DirectFB_video.c @@ -201,7 +201,7 @@ static int readBoolEnv(const char *env_name, int def_val) stemp = SDL_getenv(env_name); if (stemp) - return atoi(stemp); + return SDL_atoi(stemp); else return def_val; } diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c index b8c78fed8..48e68755f 100644 --- a/src/video/directfb/SDL_DirectFB_window.c +++ b/src/video/directfb/SDL_DirectFB_window.c @@ -227,7 +227,7 @@ DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) p = surface->pixels; for (i = 0; i < surface->h; i++) - memcpy((char *) dest + i * pitch, + SDL_memcpy((char *) dest + i * pitch, (char *) p + i * surface->pitch, 4 * surface->w); SDL_DFB_CHECK(windata->icon->Unlock(windata->icon)); diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.c b/src/video/emscripten/SDL_emscriptenframebuffer.c index 95087dab1..db2f74a50 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -119,7 +119,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec // } // the following code is faster though, because // .set() is almost free - easily 10x faster due to - // native memcpy efficiencies, and the remaining loop + // native SDL_memcpy efficiencies, and the remaining loop // just stores, not load + store, so it is faster data32.set(HEAP32.subarray(src, src + num)); var data8 = SDL2.data8; diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h index bfd2014d5..11061e5e0 100644 --- a/src/video/haiku/SDL_BWin.h +++ b/src/video/haiku/SDL_BWin.h @@ -193,7 +193,7 @@ class SDL_BWin:public BDirectWindow if (_clips == NULL) _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect)); if(_clips) { - memcpy(_clips, info->clip_list, + SDL_memcpy(_clips, info->clip_list, _num_clips*sizeof(clipping_rect)); _bits = (uint8*) info->bits; diff --git a/src/video/vita/SDL_vitaframebuffer.c b/src/video/vita/SDL_vitaframebuffer.c index a8b901426..af055b1b4 100644 --- a/src/video/vita/SDL_vitaframebuffer.c +++ b/src/video/vita/SDL_vitaframebuffer.c @@ -74,7 +74,7 @@ int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, vo &data->buffer_uid ); - // memset the buffer to black + // SDL_memset the buffer to black SDL_memset(data->buffer, 0x0, SCREEN_W*SCREEN_H*4); SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c index 51684f593..8e0878462 100644 --- a/src/video/vita/SDL_vitatouch.c +++ b/src/video/vita/SDL_vitatouch.c @@ -90,7 +90,7 @@ VITA_PollTouch(void) if (Vita_Window == NULL) return; - memcpy(touch_old, touch, sizeof(touch_old)); + SDL_memcpy(touch_old, touch, sizeof(touch_old)); for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) { /** Skip polling of Touch Device if environment variable is set **/ diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index c9d28129b..1938cd6c8 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -601,7 +601,7 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id, d->idle_inhibit_manager = wl_registry_bind(d->registry, id, &zwp_idle_inhibit_manager_v1_interface, 1); } else if (SDL_strcmp(interface, "xdg_activation_v1") == 0) { d->activation_manager = wl_registry_bind(d->registry, id, &xdg_activation_v1_interface, 1); - } else if (strcmp(interface, "zwp_text_input_manager_v3") == 0) { + } else if (SDL_strcmp(interface, "zwp_text_input_manager_v3") == 0) { Wayland_add_text_input_manager(d, id, version); } else if (SDL_strcmp(interface, "wl_data_device_manager") == 0) { Wayland_add_data_device_manager(d, id, version); diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 5d0517e21..1d0bd7987 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -270,19 +270,19 @@ static char* X11_URIToLocal(char* uri) { char *file = NULL; SDL_bool local; - if (memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */ - else if (strstr(uri,":/") != NULL) return file; /* wrong scheme */ + if (SDL_memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */ + else if (SDL_strstr(uri,":/") != NULL) return file; /* wrong scheme */ local = uri[0] != '/' || (uri[0] != '\0' && uri[1] == '/'); /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { - char* hostname_end = strchr(uri+1, '/'); + char* hostname_end = SDL_strchr(uri+1, '/'); if (hostname_end != NULL) { char hostname[ 257 ]; if (gethostname(hostname, 255) == 0) { hostname[ 256 ] = '\0'; - if (memcmp(uri+1, hostname, hostname_end - (uri+1)) == 0) { + if (SDL_memcmp(uri+1, hostname, hostname_end - (uri+1)) == 0) { uri = hostname_end + 1; local = SDL_TRUE; } @@ -1186,7 +1186,7 @@ X11_DispatchEvent(_THIS, XEvent *xevent) /* reply with status */ - memset(&m, 0, sizeof(XClientMessageEvent)); + SDL_memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent->xclient.display; m.window = xevent->xclient.data.l[0]; @@ -1204,7 +1204,7 @@ X11_DispatchEvent(_THIS, XEvent *xevent) else if(xevent->xclient.message_type == videodata->XdndDrop) { if (data->xdnd_req == None) { /* say again - not interested! */ - memset(&m, 0, sizeof(XClientMessageEvent)); + SDL_memset(&m, 0, sizeof(XClientMessageEvent)); m.type = ClientMessage; m.display = xevent->xclient.display; m.window = xevent->xclient.data.l[0]; @@ -1583,7 +1583,7 @@ X11_SendWakeupEvent(_THIS, SDL_Window *window) Window xwindow = ((SDL_WindowData *) window->driverdata)->xwindow; XClientMessageEvent event; - memset(&event, 0, sizeof(XClientMessageEvent)); + SDL_memset(&event, 0, sizeof(XClientMessageEvent)); event.type = ClientMessage; event.display = req_display; event.send_event = True; diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index c0a5b5f27..cbc3242be 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -358,7 +358,7 @@ GetXftDPI(Display* dpy) } /* - * It's possible for SDL_atoi to call strtol, if it fails due to a + * It's possible for SDL_atoi to call SDL_strtol, if it fails due to a * overflow or an underflow, it will return LONG_MAX or LONG_MIN and set * errno to ERANGE. So we need to check for this so we dont get crazy dpi * values diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index d3d45ec7d..372db60f3 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -71,7 +71,7 @@ X11_ResizeWindowShape(SDL_Window* window) { return SDL_SetError("Could not allocate memory for shaped-window bitmap."); } } - memset(data->bitmap,0,data->bitmapsize); + SDL_memset(data->bitmap,0,data->bitmapsize); window->shaper->userx = window->x; window->shaper->usery = window->y; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index def7ae9b1..1b3e693ad 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -737,9 +737,9 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME; Atom WM_NAME = data->videodata->WM_NAME; - X11_XChangeProperty(display, data->xwindow, WM_NAME, UTF8_STRING, 8, 0, (const unsigned char *) title, strlen(title)); + X11_XChangeProperty(display, data->xwindow, WM_NAME, UTF8_STRING, 8, 0, (const unsigned char *) title, SDL_strlen(title)); - status = X11_XChangeProperty(display, data->xwindow, _NET_WM_NAME, UTF8_STRING, 8, 0, (const unsigned char *) title, strlen(title)); + status = X11_XChangeProperty(display, data->xwindow, _NET_WM_NAME, UTF8_STRING, 8, 0, (const unsigned char *) title, SDL_strlen(title)); if (status != 1) { char *x11_error = NULL; diff --git a/src/video/x11/edid-parse.c b/src/video/x11/edid-parse.c index e22324f2c..f1ef08965 100644 --- a/src/video/x11/edid-parse.c +++ b/src/video/x11/edid-parse.c @@ -50,7 +50,7 @@ get_bits (int in, int begin, int end) static int decode_header (const uchar *edid) { - if (memcmp (edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0) + if (SDL_memcmp (edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0) return TRUE; return FALSE; } diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c index e636b7182..360e7f5d3 100644 --- a/test/checkkeysthreads.c +++ b/test/checkkeysthreads.c @@ -210,7 +210,7 @@ static int SDLCALL ping_thread(void *ptr) { int cnt; SDL_Event sdlevent; - memset(&sdlevent, 0 , sizeof(SDL_Event)); + SDL_memset(&sdlevent, 0 , sizeof(SDL_Event)); for (cnt = 0; cnt < 10; ++cnt) { fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10); fflush(stderr); sdlevent.type = SDL_KEYDOWN; diff --git a/test/testautomation_sdltest.c b/test/testautomation_sdltest.c index 1790194f4..809664dc3 100644 --- a/test/testautomation_sdltest.c +++ b/test/testautomation_sdltest.c @@ -1131,7 +1131,7 @@ sdltest_randomAsciiString(void *arg) SDLTest_AssertCheck(len >= 1 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", (int) len); nonAsciiCharacters = 0; for (i=0; i= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int) targetLen, (int) len); nonAsciiCharacters = 0; for (i=0; iname); - memset(&caps, '\0', sizeof(caps)); - memcpy(caps.ev, t->ev, sizeof(t->ev)); - memcpy(caps.keys, t->keys, sizeof(t->keys)); - memcpy(caps.abs, t->abs, sizeof(t->abs)); - memcpy(caps.rel, t->rel, sizeof(t->rel)); + SDL_memset(&caps, '\0', sizeof(caps)); + SDL_memcpy(caps.ev, t->ev, sizeof(t->ev)); + SDL_memcpy(caps.keys, t->keys, sizeof(t->keys)); + SDL_memcpy(caps.abs, t->abs, sizeof(t->abs)); + SDL_memcpy(caps.rel, t->rel, sizeof(t->rel)); for (j = 0; j < SDL_arraysize(caps.ev); j++) { caps.ev[j] = SwapLongLE(caps.ev[j]); diff --git a/test/testgl2.c b/test/testgl2.c index 50561049b..94c21c5b9 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -238,10 +238,10 @@ main(int argc, char *argv[]) consumed = SDLTest_CommonArg(state, i); if (consumed == 0) { if (SDL_strcasecmp(argv[i], "--fsaa") == 0 && i+1 < argc) { - fsaa = atoi(argv[i+1]); + fsaa = SDL_atoi(argv[i+1]); consumed = 2; } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) { - accel = atoi(argv[i+1]); + accel = SDL_atoi(argv[i+1]); consumed = 2; } else { consumed = -1; diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c index 31436267b..4a63863a5 100644 --- a/test/testgles2_sdf.c +++ b/test/testgles2_sdf.c @@ -163,8 +163,8 @@ process_shader(GLuint *shader, const char * source, GLint shader_type) } /* Notes on a_angle: - * It is a vector containing sin and cos for rotation matrix - * To get correct rotation for most cases when a_angle is disabled cos + * It is a vector containing sine and cosine for rotation matrix + * To get correct rotation for most cases when a_angle is disabled SDL_cos value is decremented by 1.0 to get proper output with 0.0 which is default value */ diff --git a/test/testhaptic.c b/test/testhaptic.c index 9613629e2..74be9e0c3 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -14,10 +14,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND /* * includes */ -#include -#include /* strstr */ -#include /* isdigit */ - #include "SDL.h" #ifndef SDL_HAPTIC_DISABLED @@ -55,7 +51,7 @@ main(int argc, char **argv) index = -1; if (argc > 1) { name = argv[1]; - if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { + if ((SDL_strcmp(name, "--help") == 0) || (SDL_strcmp(name, "-h") == 0)) { SDL_Log("USAGE: %s [device]\n" "If device is a two-digit number it'll use it as an index, otherwise\n" "it'll use it as if it were part of the device's name.\n", @@ -63,9 +59,9 @@ main(int argc, char **argv) return 0; } - i = strlen(name); - if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) { - index = atoi(name); + i = SDL_strlen(name); + if ((i < 3) && SDL_isdigit(name[0]) && ((i == 1) || SDL_isdigit(name[1]))) { + index = SDL_atoi(name); name = NULL; } } @@ -82,7 +78,7 @@ main(int argc, char **argv) /* Try to find matching device */ else { for (i = 0; i < SDL_NumHaptics(); i++) { - if (strstr(SDL_HapticName(i), name) != NULL) + if (SDL_strstr(SDL_HapticName(i), name) != NULL) break; } @@ -110,7 +106,7 @@ main(int argc, char **argv) SDL_ClearError(); /* Create effects. */ - memset(&efx, 0, sizeof(efx)); + SDL_memset(&efx, 0, sizeof(efx)); nefx = 0; supported = SDL_HapticQuery(haptic); diff --git a/test/testime.c b/test/testime.c index 125bedc33..73fc81787 100644 --- a/test/testime.c +++ b/test/testime.c @@ -648,12 +648,12 @@ int main(int argc, char *argv[]) } for (argc--, argv++; argc > 0; argc--, argv++) { - if (strcmp(argv[0], "--help") == 0) { + if (SDL_strcmp(argv[0], "--help") == 0) { usage(); return 0; } - else if (strcmp(argv[0], "--font") == 0) + else if (SDL_strcmp(argv[0], "--font") == 0) { argc--; argv++; diff --git a/test/testloadso.c b/test/testloadso.c index 5e138c6dd..5b51c47d3 100644 --- a/test/testloadso.c +++ b/test/testloadso.c @@ -44,7 +44,7 @@ main(int argc, char *argv[]) return 2; } - if (strcmp(argv[1], "--hello") == 0) { + if (SDL_strcmp(argv[1], "--hello") == 0) { hello = 1; libname = argv[2]; symname = "puts"; diff --git a/test/testrumble.c b/test/testrumble.c index 1dfcbe5c4..868e95e36 100644 --- a/test/testrumble.c +++ b/test/testrumble.c @@ -25,10 +25,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND /* * includes */ -#include -#include /* strstr */ -#include /* isdigit */ - #include "SDL.h" #ifndef SDL_HAPTIC_DISABLED @@ -56,7 +52,7 @@ main(int argc, char **argv) if (argc > 1) { size_t l; name = argv[1]; - if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) { + if ((SDL_strcmp(name, "--help") == 0) || (SDL_strcmp(name, "-h") == 0)) { SDL_Log("USAGE: %s [device]\n" "If device is a two-digit number it'll use it as an index, otherwise\n" "it'll use it as if it were part of the device's name.\n", @@ -83,7 +79,7 @@ main(int argc, char **argv) /* Try to find matching device */ else { for (i = 0; i < SDL_NumHaptics(); i++) { - if (strstr(SDL_HapticName(i), name) != NULL) + if (SDL_strstr(SDL_HapticName(i), name) != NULL) break; } diff --git a/test/testsem.c b/test/testsem.c index 6a76280c2..e8721dcea 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -262,7 +262,7 @@ main(int argc, char **argv) signal(SIGTERM, killed); signal(SIGINT, killed); - init_sem = atoi(argv[1]); + init_sem = SDL_atoi(argv[1]); if (init_sem > 0) { TestRealWorld(init_sem); } diff --git a/test/testtimer.c b/test/testtimer.c index fe30ab54f..fbf3f66c0 100644 --- a/test/testtimer.c +++ b/test/testtimer.c @@ -72,7 +72,7 @@ main(int argc, char *argv[]) /* Start the timer */ desired = 0; if (argv[1]) { - desired = atoi(argv[1]); + desired = SDL_atoi(argv[1]); } if (desired == 0) { desired = DEFAULT_RESOLUTION; diff --git a/test/testyuv_cvt.c b/test/testyuv_cvt.c index 3dc18b758..31844c232 100644 --- a/test/testyuv_cvt.c +++ b/test/testyuv_cvt.c @@ -31,9 +31,9 @@ static void RGBtoYUV(Uint8 * rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int mo // This formula is from Microsoft's documentation: // https://msdn.microsoft.com/en-us/library/windows/desktop/dd206750(v=vs.85).aspx // L = Kr * R + Kb * B + (1 - Kr - Kb) * G - // Y = floor(2^(M-8) * (219*(L-Z)/S + 16) + 0.5); - // U = clip3(0, (2^M)-1, floor(2^(M-8) * (112*(B-L) / ((1-Kb)*S) + 128) + 0.5)); - // V = clip3(0, (2^M)-1, floor(2^(M-8) * (112*(R-L) / ((1-Kr)*S) + 128) + 0.5)); + // Y = SDL_floor(2^(M-8) * (219*(L-Z)/S + 16) + 0.5); + // U = clip3(0, (2^M)-1, SDL_floor(2^(M-8) * (112*(B-L) / ((1-Kb)*S) + 128) + 0.5)); + // V = clip3(0, (2^M)-1, SDL_floor(2^(M-8) * (112*(R-L) / ((1-Kr)*S) + 128) + 0.5)); float S, Z, R, G, B, L, Kr, Kb, Y, U, V; if (mode == SDL_YUV_CONVERSION_BT709) {