use SDL's functions version inplace of libc version

This commit is contained in:
Sylvain 2021-11-21 22:30:48 +01:00 committed by Sam Lantinga
parent 35b7ce1893
commit d31251b014
46 changed files with 114 additions and 124 deletions

View File

@ -58,7 +58,7 @@ render(SDL_Renderer *renderer, int w, int h, double deltaTime)
ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT * ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
deltaMilliseconds; 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) { if (speed > 0) {
/* compensate for friction */ /* compensate for friction */

View File

@ -109,7 +109,7 @@ stepParticles(double deltaTime)
} }
} else { } else {
float speed = 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, /* if wind resistance is not powerful enough to stop us completely,
then apply winde resistance, otherwise just stop us completely */ then apply winde resistance, otherwise just stop us completely */
if (WIND_RESISTANCE * deltaMilliseconds < speed) { if (WIND_RESISTANCE * deltaMilliseconds < speed) {
@ -194,15 +194,15 @@ explodeEmitter(struct particle *emitter)
/* come up with a random angle and speed for new particle */ /* come up with a random angle and speed for new particle */
float theta = randomFloat(0, 2.0f * 3.141592); float theta = randomFloat(0, 2.0f * 3.141592);
float exponent = 3.0f; float exponent = 3.0f;
float speed = randomFloat(0.00, powf(0.17, exponent)); float speed = randomFloat(0.00, SDL_powf(0.17, exponent));
speed = powf(speed, 1.0f / exponent); speed = SDL_powf(speed, 1.0f / exponent);
/* select the particle at the end of our array */ /* select the particle at the end of our array */
struct particle *p = &particles[num_active_particles]; struct particle *p = &particles[num_active_particles];
/* set the particles properties */ /* set the particles properties */
p->xvel = speed * cos(theta); p->xvel = speed * SDL_cos(theta);
p->yvel = speed * sin(theta); p->yvel = speed * SDL_sin(theta);
p->x = emitter->x + emitter->xvel; p->x = emitter->x + emitter->xvel;
p->y = emitter->y + emitter->yvel; p->y = emitter->y + emitter->yvel;
p->isActive = 1; p->isActive = 1;
@ -297,7 +297,7 @@ spawnEmitterParticle(GLfloat x, GLfloat y)
p->y = screen_h; p->y = screen_h;
/* set velocity so that terminal point is (x,y) */ /* set velocity so that terminal point is (x,y) */
p->xvel = 0; p->xvel = 0;
p->yvel = -sqrt(2 * ACCEL * (screen_h - y)); p->yvel = -SDL_sqrt(2 * ACCEL * (screen_h - y));
/* set other attributes */ /* set other attributes */
p->size = 10 * pointSizeScale; p->size = 10 * pointSizeScale;
p->type = emitter; p->type = emitter;

View File

@ -21,7 +21,7 @@ void
drawLine(SDL_Renderer *renderer, float startx, float starty, float dx, float dy) 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 */ 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 dx_prime = dx / iterations; /* x-shift per iteration */
float dy_prime = dy / iterations; /* y-shift per iteration */ float dy_prime = dy / iterations; /* y-shift per iteration */

View File

@ -1753,7 +1753,7 @@ SDL_SilenceValueForFormat(const SDL_AudioFormat format)
{ {
switch (format) { switch (format) {
/* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a /* !!! 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. */ !!! FIXME: off from silence. Maybe just don't use U16. */
case AUDIO_U16LSB: case AUDIO_U16LSB:
case AUDIO_U16MSB: case AUDIO_U16MSB:

View File

@ -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". /* 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 just chop the extra lines off, this seems to get a reasonable device
name without extra details. */ name without extra details. */
if ((ptr = strchr(desc, '\n')) != NULL) { if ((ptr = SDL_strchr(desc, '\n')) != NULL) {
*ptr = '\0'; *ptr = '\0';
} }

View File

@ -90,7 +90,7 @@ PSPAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
return SDL_SetError("Couldn't reserve hardware channel"); 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++) { for (i = 0; i < NUM_BUFFERS; i++) {
this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size]; this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size];
} }

View File

@ -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); 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++) { for (i = 0; i < NUM_BUFFERS; i++) {
this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size]; this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size];
} }

View File

@ -268,7 +268,7 @@ SDL_EVDEV_kbd_init(void)
kbd->key_map = &keymap_default_us_acc; kbd->key_map = &keymap_default_us_acc;
} }
/* Allow inhibiting keyboard mute with env. variable for debugging etc. */ /* 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. /* Take keyboard from console and open the actual keyboard device.
* Ensures that the keystrokes do not leak through to the console. * Ensures that the keystrokes do not leak through to the console.
*/ */

View File

@ -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) static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym)
{ {
if (KS_GROUP(ksym) == KS_GROUP_Keypad) { if (KS_GROUP(ksym) == KS_GROUP_Keypad) {
if (isprint(ksym & 0xFF)) ksym &= 0xFF; if (SDL_isprint(ksym & 0xFF)) ksym &= 0xFF;
} }
switch(ksym) { switch(ksym) {
case KS_Escape: 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) { if (input->text_len > 0) {
input->text[input->text_len] = '\0'; input->text[input->text_len] = '\0';
SDL_SendKeyboardText(input->text); 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_len = 0;
input->text[0] = 0; input->text[0] = 0;
} }

View File

@ -377,8 +377,8 @@ CPU_haveARMSIMD(void)
{ {
const char *plat = (const char *) aux.a_un.a_val; const char *plat = (const char *) aux.a_un.a_val;
if (plat) { if (plat) {
arm_simd = strncmp(plat, "v6l", 3) == 0 || arm_simd = SDL_strncmp(plat, "v6l", 3) == 0 ||
strncmp(plat, "v7l", 3) == 0; SDL_strncmp(plat, "v7l", 3) == 0;
} }
} }
} }

View File

@ -82,7 +82,7 @@ readSymLink(const char *path)
#if defined(__OPENBSD__) #if defined(__OPENBSD__)
static char *search_path_for_binary(const char *bin) static char *search_path_for_binary(const char *bin)
{ {
char *envr = getenv("PATH"); char *envr = SDL_getenv("PATH");
size_t alloc_size; size_t alloc_size;
char *exe = NULL; char *exe = NULL;
char *start = envr; char *start = envr;

View File

@ -35,7 +35,6 @@
#include <fcntl.h> /* O_RDWR */ #include <fcntl.h> /* O_RDWR */
#include <limits.h> /* INT_MAX */ #include <limits.h> /* INT_MAX */
#include <errno.h> /* errno, strerror */ #include <errno.h> /* errno, strerror */
#include <math.h> /* atan2 */
#include <sys/stat.h> /* stat */ #include <sys/stat.h> /* stat */
/* Just in case. */ /* Just in case. */
@ -713,10 +712,10 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src)
else { else {
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */ 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) - Y-axis-value is the second coordinate (from center to SOUTH)
- X-axis-value is the first coordinate (from center to EAST) - 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 have the first spherical value. Therefore we proceed as in case
SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value. SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value.
--> add 45000 in total --> add 45000 in total

View File

@ -53,7 +53,6 @@
#include <pthread.h> #include <pthread.h>
#include <errno.h> // For ETIMEDOUT and ECONNRESET #include <errno.h> // For ETIMEDOUT and ECONNRESET
#include <stdlib.h> // For malloc() and free() #include <stdlib.h> // For malloc() and free()
#include <string.h> // For memcpy()
#define TAG "hidapi" #define TAG "hidapi"
@ -196,7 +195,7 @@ public:
} }
m_nSize = nSize; m_nSize = nSize;
memcpy( m_pData, pData, nSize ); SDL_memcpy( m_pData, pData, nSize );
} }
void clear() void clear()
@ -313,7 +312,7 @@ static jbyteArray NewByteArray( JNIEnv* env, const uint8_t *pData, size_t nDataL
{ {
jbyteArray array = env->NewByteArray( (jsize)nDataLen ); jbyteArray array = env->NewByteArray( (jsize)nDataLen );
jbyte *pBuf = env->GetByteArrayElements( array, NULL ); jbyte *pBuf = env->GetByteArrayElements( array, NULL );
memcpy( pBuf, pData, nDataLen ); SDL_memcpy( pBuf, pData, nDataLen );
env->ReleaseByteArrayElements( array, pBuf, 0 ); env->ReleaseByteArrayElements( array, pBuf, 0 );
return array; return array;
@ -324,7 +323,7 @@ static char *CreateStringFromJString( JNIEnv *env, const jstring &sString )
size_t nLength = env->GetStringUTFLength( sString ); size_t nLength = env->GetStringUTFLength( sString );
const char *pjChars = env->GetStringUTFChars( sString, NULL ); const char *pjChars = env->GetStringUTFChars( sString, NULL );
char *psString = (char*)malloc( nLength + 1 ); char *psString = (char*)malloc( nLength + 1 );
memcpy( psString, pjChars, nLength ); SDL_memcpy( psString, pjChars, nLength );
psString[ nLength ] = '\0'; psString[ nLength ] = '\0';
env->ReleaseStringUTFChars( sString, pjChars ); env->ReleaseStringUTFChars( sString, pjChars );
return psString; return psString;
@ -347,9 +346,9 @@ static wchar_t *CreateWStringFromJString( JNIEnv *env, const jstring &sString )
static wchar_t *CreateWStringFromWString( const wchar_t *pwSrc ) 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 ) ); 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'; pwString[ nLength ] = '\0';
return pwString; return pwString;
} }
@ -358,7 +357,7 @@ static hid_device_info *CopyHIDDeviceInfo( const hid_device_info *pInfo )
{ {
hid_device_info *pCopy = new hid_device_info; hid_device_info *pCopy = new hid_device_info;
*pCopy = *pInfo; *pCopy = *pInfo;
pCopy->path = strdup( pInfo->path ); pCopy->path = SDL_strdup( pInfo->path );
pCopy->product_string = CreateWStringFromWString( pInfo->product_string ); pCopy->product_string = CreateWStringFromWString( pInfo->product_string );
pCopy->manufacturer_string = CreateWStringFromWString( pInfo->manufacturer_string ); pCopy->manufacturer_string = CreateWStringFromWString( pInfo->manufacturer_string );
pCopy->serial_number = CreateWStringFromWString( pInfo->serial_number ); pCopy->serial_number = CreateWStringFromWString( pInfo->serial_number );
@ -579,12 +578,12 @@ public:
if ( m_bIsBLESteamController ) if ( m_bIsBLESteamController )
{ {
data[0] = 0x03; data[0] = 0x03;
memcpy( data + 1, buffer.data(), nDataLen ); SDL_memcpy( data + 1, buffer.data(), nDataLen );
++nDataLen; ++nDataLen;
} }
else else
{ {
memcpy( data, buffer.data(), nDataLen ); SDL_memcpy( data, buffer.data(), nDataLen );
} }
m_vecData.pop_front(); m_vecData.pop_front();
@ -721,7 +720,7 @@ public:
} }
size_t uBytesToCopy = m_featureReport.size() > nDataLen ? nDataLen : m_featureReport.size(); 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(); m_featureReport.clear();
LOGV( "=== Got %u bytes", uBytesToCopy ); 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 ); LOGV( "HIDDeviceConnected() id=%d VID/PID = %.4x/%.4x, interface %d\n", nDeviceID, nVendorId, nProductId, nInterface );
hid_device_info *pInfo = new hid_device_info; 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->path = CreateStringFromJString( env, sIdentifier );
pInfo->vendor_id = nVendorId; pInfo->vendor_id = nVendorId;
pInfo->product_id = nProductId; 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 ); hid_mutex_guard l( &g_DevicesMutex );
for ( hid_device_ref<CHIDDevice> pCurr = g_Devices; pCurr; pCurr = pCurr->next ) for ( hid_device_ref<CHIDDevice> 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(); hid_device *pValue = pCurr->GetDevice();
if ( pValue ) if ( pValue )

View File

@ -220,7 +220,7 @@ static void hexdump( const uint8_t *ptr, int len )
static void ResetSteamControllerPacketAssembler( SteamControllerPacketAssembler *pAssembler ) static void ResetSteamControllerPacketAssembler( SteamControllerPacketAssembler *pAssembler )
{ {
memset( pAssembler->uBuffer, 0, sizeof( pAssembler->uBuffer ) ); SDL_memset( pAssembler->uBuffer, 0, sizeof( pAssembler->uBuffer ) );
pAssembler->nExpectedSegmentNumber = 0; 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 pSegment + 2, // ignore header and report number
MAX_REPORT_SEGMENT_PAYLOAD_SIZE ); MAX_REPORT_SEGMENT_PAYLOAD_SIZE );
@ -294,7 +294,7 @@ static int WriteSegmentToSteamControllerPacketAssembler( SteamControllerPacketAs
else else
{ {
// Just pass through // Just pass through
memcpy( pAssembler->uBuffer, SDL_memcpy( pAssembler->uBuffer,
pSegment, pSegment,
nSegmentLength ); nSegmentLength );
return nSegmentLength; return nSegmentLength;
@ -331,10 +331,10 @@ static int SetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65], int
nActualDataLen -= nBytesInPacket; nActualDataLen -= nBytesInPacket;
// Construct packet // Construct packet
memset( uPacketBuffer, 0, sizeof( uPacketBuffer ) ); SDL_memset( uPacketBuffer, 0, sizeof( uPacketBuffer ) );
uPacketBuffer[ 0 ] = BLE_REPORT_NUMBER; uPacketBuffer[ 0 ] = BLE_REPORT_NUMBER;
uPacketBuffer[ 1 ] = GetSegmentHeader( nSegmentNumber, nActualDataLen == 0 ); uPacketBuffer[ 1 ] = GetSegmentHeader( nSegmentNumber, nActualDataLen == 0 );
memcpy( &uPacketBuffer[ 2 ], pBufferPtr, nBytesInPacket ); SDL_memcpy( &uPacketBuffer[ 2 ], pBufferPtr, nBytesInPacket );
pBufferPtr += nBytesInPacket; pBufferPtr += nBytesInPacket;
nSegmentNumber++; nSegmentNumber++;
@ -364,7 +364,7 @@ static int GetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65] )
while( nRetries < BLE_MAX_READ_RETRIES ) while( nRetries < BLE_MAX_READ_RETRIES )
{ {
memset( uSegmentBuffer, 0, sizeof( uSegmentBuffer ) ); SDL_memset( uSegmentBuffer, 0, sizeof( uSegmentBuffer ) );
uSegmentBuffer[ 0 ] = BLE_REPORT_NUMBER; uSegmentBuffer[ 0 ] = BLE_REPORT_NUMBER;
nRet = SDL_hid_get_feature_report( dev, uSegmentBuffer, sizeof( uSegmentBuffer ) ); nRet = SDL_hid_get_feature_report( dev, uSegmentBuffer, sizeof( uSegmentBuffer ) );
DPRINTF( "GetFeatureReport ble ret=%d\n", nRet ); 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" // Leave space for "report number"
uBuffer[ 0 ] = 0; uBuffer[ 0 ] = 0;
memcpy( uBuffer + 1, assembler.uBuffer, nPacketLength ); SDL_memcpy( uBuffer + 1, assembler.uBuffer, nPacketLength );
return nPacketLength; return nPacketLength;
} }
} }
@ -500,7 +500,7 @@ static bool ResetSteamController( SDL_hid_device *dev, bool bSuppressErrorSpew,
} }
// Reset the default settings // Reset the default settings
memset( buf, 0, 65 ); SDL_memset( buf, 0, 65 );
buf[1] = ID_LOAD_DEFAULT_SETTINGS; buf[1] = ID_LOAD_DEFAULT_SETTINGS;
buf[2] = 0; buf[2] = 0;
res = SetFeatureReport( dev, buf, 3 ); 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; \ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \
++nSettings; ++nSettings;
memset( buf, 0, 65 ); SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_SETTINGS_VALUES; buf[1] = ID_SET_SETTINGS_VALUES;
ADD_SETTING( SETTING_WIRELESS_PACKET_VERSION, 2 ); ADD_SETTING( SETTING_WIRELESS_PACKET_VERSION, 2 );
ADD_SETTING( SETTING_LEFT_TRACKPAD_MODE, TRACKPAD_NONE ); ADD_SETTING( SETTING_LEFT_TRACKPAD_MODE, TRACKPAD_NONE );
@ -547,7 +547,7 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \
int iRetry; int iRetry;
for ( iRetry = 0; iRetry < 2; ++iRetry ) for ( iRetry = 0; iRetry < 2; ++iRetry )
{ {
memset( buf, 0, 65 ); SDL_memset( buf, 0, 65 );
buf[1] = ID_GET_DIGITAL_MAPPINGS; buf[1] = ID_GET_DIGITAL_MAPPINGS;
buf[2] = 1; // one byte - requesting from index 0 buf[2] = 1; // one byte - requesting from index 0
buf[3] = 0; buf[3] = 0;
@ -580,7 +580,7 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \
} }
// Set our new mappings // Set our new mappings
memset( buf, 0, 65 ); SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_DIGITAL_MAPPINGS; buf[1] = ID_SET_DIGITAL_MAPPINGS;
buf[2] = 6; // 2 settings x 3 bytes buf[2] = 6; // 2 settings x 3 bytes
buf[3] = IO_DIGITAL_BUTTON_RIGHT_TRIGGER; 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 ) 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 pData[ 0 ] = BLE_REPORT_NUMBER; // hid_read will also overwrite this with the same value, 0x03
return SDL_hid_read( dev, pData, nDataSize ); return SDL_hid_read( dev, pData, nDataSize );
} }
@ -624,18 +624,18 @@ static void CloseSteamController( SDL_hid_device *dev )
int nSettings = 0; int nSettings = 0;
// Reset digital button mappings // Reset digital button mappings
memset( buf, 0, 65 ); SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_DEFAULT_DIGITAL_MAPPINGS; buf[1] = ID_SET_DEFAULT_DIGITAL_MAPPINGS;
SetFeatureReport( dev, buf, 2 ); SetFeatureReport( dev, buf, 2 );
// Reset the default settings // Reset the default settings
memset( buf, 0, 65 ); SDL_memset( buf, 0, 65 );
buf[1] = ID_LOAD_DEFAULT_SETTINGS; buf[1] = ID_LOAD_DEFAULT_SETTINGS;
buf[2] = 0; buf[2] = 0;
SetFeatureReport( dev, buf, 3 ); SetFeatureReport( dev, buf, 3 );
// Reset mouse mode for lizard mode // Reset mouse mode for lizard mode
memset( buf, 0, 65 ); SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_SETTINGS_VALUES; buf[1] = ID_SET_SETTINGS_VALUES;
ADD_SETTING( SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_ABSOLUTE_MOUSE ); ADD_SETTING( SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_ABSOLUTE_MOUSE );
buf[2] = nSettings*3; buf[2] = nSettings*3;
@ -695,14 +695,14 @@ static void FormatStatePacketUntilGyro( SteamControllerStateInternal_t *pState,
// 15 degrees in rad // 15 degrees in rad
const float flRotationAngle = 0.261799f; 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 = m_eControllerType;
pState->eControllerType = 2; // k_eControllerType_SteamController; pState->eControllerType = 2; // k_eControllerType_SteamController;
pState->unPacketNum = pStatePacket->unPacketNum; pState->unPacketNum = pStatePacket->unPacketNum;
// We have a chunk of trigger data in the packet format here, so zero it out afterwards // 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; pState->ulButtons &= ~0xFFFF000000LL;
// The firmware uses this bit to tell us what kind of data is packed into the left two axises // 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; ucOptionDataMask |= (uint32_t)(*pData++) << 8;
if ( ucOptionDataMask & k_EBLEButtonChunk1 ) if ( ucOptionDataMask & k_EBLEButtonChunk1 )
{ {
memcpy( &pState->ulButtons, pData, 3 ); SDL_memcpy( &pState->ulButtons, pData, 3 );
pData += 3; pData += 3;
} }
if ( ucOptionDataMask & k_EBLEButtonChunk2 ) 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 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 // this protocol yet either
int nLength = sizeof( pState->sLeftStickX ) + sizeof( pState->sLeftStickY ); int nLength = sizeof( pState->sLeftStickX ) + sizeof( pState->sLeftStickY );
memcpy( &pState->sLeftStickX, pData, nLength ); SDL_memcpy( &pState->sLeftStickX, pData, nLength );
pData += nLength; pData += nLength;
} }
if ( ucOptionDataMask & k_EBLELeftTrackpadChunk ) if ( ucOptionDataMask & k_EBLELeftTrackpadChunk )
{ {
int nLength = sizeof( pState->sLeftPadX ) + sizeof( pState->sLeftPadY ); int nLength = sizeof( pState->sLeftPadX ) + sizeof( pState->sLeftPadY );
int nPadOffset; int nPadOffset;
memcpy( &pState->sLeftPadX, pData, nLength ); SDL_memcpy( &pState->sLeftPadX, pData, nLength );
if ( pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK ) if ( pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK )
nPadOffset = 1000; nPadOffset = 1000;
else else
@ -867,7 +867,7 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize,
int nLength = sizeof( pState->sRightPadX ) + sizeof( pState->sRightPadY ); int nLength = sizeof( pState->sRightPadX ) + sizeof( pState->sRightPadY );
int nPadOffset = 0; int nPadOffset = 0;
memcpy( &pState->sRightPadX, pData, nLength ); SDL_memcpy( &pState->sRightPadX, pData, nLength );
if ( pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK ) if ( pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK )
nPadOffset = 1000; nPadOffset = 1000;
@ -882,19 +882,19 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize,
if ( ucOptionDataMask & k_EBLEIMUAccelChunk ) if ( ucOptionDataMask & k_EBLEIMUAccelChunk )
{ {
int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ ); int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ );
memcpy( &pState->sAccelX, pData, nLength ); SDL_memcpy( &pState->sAccelX, pData, nLength );
pData += nLength; pData += nLength;
} }
if ( ucOptionDataMask & k_EBLEIMUGyroChunk ) if ( ucOptionDataMask & k_EBLEIMUGyroChunk )
{ {
int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ ); int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ );
memcpy( &pState->sGyroX, pData, nLength ); SDL_memcpy( &pState->sGyroX, pData, nLength );
pData += nLength; pData += nLength;
} }
if ( ucOptionDataMask & k_EBLEIMUQuatChunk ) if ( ucOptionDataMask & k_EBLEIMUQuatChunk )
{ {
int nLength = sizeof( pState->sGyroQuatW ) + sizeof( pState->sGyroQuatX ) + sizeof( pState->sGyroQuatY ) + sizeof( pState->sGyroQuatZ ); 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; pData += nLength;
} }
return true; return true;
@ -1122,7 +1122,7 @@ HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *jo
unsigned char buf[65]; unsigned char buf[65];
int nSettings = 0; int nSettings = 0;
memset( buf, 0, 65 ); SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_SETTINGS_VALUES; buf[1] = ID_SET_SETTINGS_VALUES;
if (enabled) { if (enabled) {
ADD_SETTING( SETTING_GYRO_MODE, 0x18 /* SETTING_GYRO_SEND_RAW_ACCEL | SETTING_GYRO_MODE_SEND_RAW_GYRO */ ); ADD_SETTING( SETTING_GYRO_MODE, 0x18 /* SETTING_GYRO_SEND_RAW_ACCEL | SETTING_GYRO_MODE_SEND_RAW_GYRO */ );

View File

@ -45,7 +45,7 @@ build_locales_from_csv_string(char *csv)
num_locales++; /* one more for terminator */ 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)); alloclen = slen + (num_locales * sizeof (SDL_Locale));
loc = retval = (SDL_Locale *) SDL_calloc(1, alloclen); loc = retval = (SDL_Locale *) SDL_calloc(1, alloclen);

View File

@ -35,7 +35,7 @@ SDL_SYS_OpenURL(const char *url)
sceAppUtilInit(&init_param, &boot_param); sceAppUtilInit(&init_param, &boot_param);
SDL_zero(browser_param); SDL_zero(browser_param);
browser_param.str = url; browser_param.str = url;
browser_param.strlen = strlen(url); browser_param.strlen = SDL_strlen(url);
sceAppUtilLaunchWebBrowser(&browser_param); sceAppUtilLaunchWebBrowser(&browser_param);
return 0; return 0;
} }

View File

@ -59,7 +59,7 @@ SDL_GetPowerInfo_Haiku(SDL_PowerState * state, int *seconds, int *percent)
return SDL_FALSE; /* maybe some other method will work? */ 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[0] = APM_FUNC_OFFSET + APM_FUNC_GET_POWER_STATUS;
regs[1] = APM_DEVICE_ALL; regs[1] = APM_DEVICE_ALL;
rc = ioctl(fd, APM_BIOS_CALL, regs); rc = ioctl(fd, APM_BIOS_CALL, regs);

View File

@ -51,7 +51,7 @@ open_power_file(const char *base, const char *node, const char *key)
return -1; /* oh well. */ 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); fd = open(path, O_RDONLY | O_CLOEXEC);
SDL_stack_free(path); SDL_stack_free(path);
return fd; return fd;

View File

@ -184,7 +184,7 @@ computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int
if (signy < 0) sp += (src->h-1)*src->pitch; \ if (signy < 0) sp += (src->h-1)*src->pitch; \
\ \
for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \ 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)); \ SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
sp += dst->w*sizeof(pixelType); \ sp += dst->w*sizeof(pixelType); \
dp += 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))) if (!(is8bit || (src->format->BitsPerPixel == 32 && src->format->Amask)))
return NULL; return NULL;
/* Calculate target factors from sin/cos and zoom */ /* Calculate target factors from sine/cosine and zoom */
sangleinv = sangle*65536.0; sangleinv = sangle*65536.0;
cangleinv = cangle*65536.0; cangleinv = cangle*65536.0;

View File

@ -475,7 +475,7 @@ gxm_init(SDL_Renderer *renderer)
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
&data->displayBufferUid[i]); &data->displayBufferUid[i]);
// memset the buffer to black // SDL_memset the buffer to black
for (y = 0; y < VITA_GXM_SCREEN_HEIGHT; y++) { for (y = 0; y < VITA_GXM_SCREEN_HEIGHT; y++) {
unsigned int *row = (unsigned int *)data->displayBufferData[i] + y * VITA_GXM_SCREEN_STRIDE; unsigned int *row = (unsigned int *)data->displayBufferData[i] + y * VITA_GXM_SCREEN_STRIDE;
for (x = 0; x < VITA_GXM_SCREEN_WIDTH; x++) { 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 // set up parameters
SceGxmRenderTargetParams renderTargetParams; SceGxmRenderTargetParams renderTargetParams;
memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams)); SDL_memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams));
renderTargetParams.flags = 0; renderTargetParams.flags = 0;
renderTargetParams.width = w; renderTargetParams.width = w;
renderTargetParams.height = h; renderTargetParams.height = h;

View File

@ -683,7 +683,7 @@ EnumKeyboards(DFBInputDeviceID device_id,
#endif #endif
devdata->keyboard[devdata->num_keyboard].id = device_id; devdata->keyboard[devdata->num_keyboard].id = device_id;
devdata->keyboard[devdata->num_keyboard].is_generic = 0; 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 = xfree86_scancode_table2;
devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(xfree86_scancode_table2); devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(xfree86_scancode_table2);

View File

@ -164,7 +164,7 @@ DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
p = surface->pixels; p = surface->pixels;
for (i = 0; i < surface->h; i++) 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); (char *) p + i * surface->pitch, 4 * surface->w);
curdata->surf->Unlock(curdata->surf); curdata->surf->Unlock(curdata->surf);

View File

@ -201,7 +201,7 @@ static int readBoolEnv(const char *env_name, int def_val)
stemp = SDL_getenv(env_name); stemp = SDL_getenv(env_name);
if (stemp) if (stemp)
return atoi(stemp); return SDL_atoi(stemp);
else else
return def_val; return def_val;
} }

View File

@ -227,7 +227,7 @@ DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
p = surface->pixels; p = surface->pixels;
for (i = 0; i < surface->h; i++) 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); (char *) p + i * surface->pitch, 4 * surface->w);
SDL_DFB_CHECK(windata->icon->Unlock(windata->icon)); SDL_DFB_CHECK(windata->icon->Unlock(windata->icon));

View File

@ -119,7 +119,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rec
// } // }
// the following code is faster though, because // the following code is faster though, because
// .set() is almost free - easily 10x faster due to // .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 // just stores, not load + store, so it is faster
data32.set(HEAP32.subarray(src, src + num)); data32.set(HEAP32.subarray(src, src + num));
var data8 = SDL2.data8; var data8 = SDL2.data8;

View File

@ -193,7 +193,7 @@ class SDL_BWin:public BDirectWindow
if (_clips == NULL) if (_clips == NULL)
_clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect)); _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
if(_clips) { if(_clips) {
memcpy(_clips, info->clip_list, SDL_memcpy(_clips, info->clip_list,
_num_clips*sizeof(clipping_rect)); _num_clips*sizeof(clipping_rect));
_bits = (uint8*) info->bits; _bits = (uint8*) info->bits;

View File

@ -74,7 +74,7 @@ int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, vo
&data->buffer_uid &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(data->buffer, 0x0, SCREEN_W*SCREEN_H*4);
SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf));

View File

@ -90,7 +90,7 @@ VITA_PollTouch(void)
if (Vita_Window == NULL) if (Vita_Window == NULL)
return; 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++) { for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
/** Skip polling of Touch Device if environment variable is set **/ /** Skip polling of Touch Device if environment variable is set **/

View File

@ -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); 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) { } else if (SDL_strcmp(interface, "xdg_activation_v1") == 0) {
d->activation_manager = wl_registry_bind(d->registry, id, &xdg_activation_v1_interface, 1); 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); Wayland_add_text_input_manager(d, id, version);
} else if (SDL_strcmp(interface, "wl_data_device_manager") == 0) { } else if (SDL_strcmp(interface, "wl_data_device_manager") == 0) {
Wayland_add_data_device_manager(d, id, version); Wayland_add_data_device_manager(d, id, version);

View File

@ -270,19 +270,19 @@ static char* X11_URIToLocal(char* uri) {
char *file = NULL; char *file = NULL;
SDL_bool local; SDL_bool local;
if (memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */ if (SDL_memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */
else if (strstr(uri,":/") != NULL) return file; /* wrong scheme */ else if (SDL_strstr(uri,":/") != NULL) return file; /* wrong scheme */
local = uri[0] != '/' || (uri[0] != '\0' && uri[1] == '/'); local = uri[0] != '/' || (uri[0] != '\0' && uri[1] == '/');
/* got a hostname? */ /* got a hostname? */
if (!local && uri[0] == '/' && uri[2] != '/') { if (!local && uri[0] == '/' && uri[2] != '/') {
char* hostname_end = strchr(uri+1, '/'); char* hostname_end = SDL_strchr(uri+1, '/');
if (hostname_end != NULL) { if (hostname_end != NULL) {
char hostname[ 257 ]; char hostname[ 257 ];
if (gethostname(hostname, 255) == 0) { if (gethostname(hostname, 255) == 0) {
hostname[ 256 ] = '\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; uri = hostname_end + 1;
local = SDL_TRUE; local = SDL_TRUE;
} }
@ -1186,7 +1186,7 @@ X11_DispatchEvent(_THIS, XEvent *xevent)
/* reply with status */ /* reply with status */
memset(&m, 0, sizeof(XClientMessageEvent)); SDL_memset(&m, 0, sizeof(XClientMessageEvent));
m.type = ClientMessage; m.type = ClientMessage;
m.display = xevent->xclient.display; m.display = xevent->xclient.display;
m.window = xevent->xclient.data.l[0]; m.window = xevent->xclient.data.l[0];
@ -1204,7 +1204,7 @@ X11_DispatchEvent(_THIS, XEvent *xevent)
else if(xevent->xclient.message_type == videodata->XdndDrop) { else if(xevent->xclient.message_type == videodata->XdndDrop) {
if (data->xdnd_req == None) { if (data->xdnd_req == None) {
/* say again - not interested! */ /* say again - not interested! */
memset(&m, 0, sizeof(XClientMessageEvent)); SDL_memset(&m, 0, sizeof(XClientMessageEvent));
m.type = ClientMessage; m.type = ClientMessage;
m.display = xevent->xclient.display; m.display = xevent->xclient.display;
m.window = xevent->xclient.data.l[0]; m.window = xevent->xclient.data.l[0];
@ -1583,7 +1583,7 @@ X11_SendWakeupEvent(_THIS, SDL_Window *window)
Window xwindow = ((SDL_WindowData *) window->driverdata)->xwindow; Window xwindow = ((SDL_WindowData *) window->driverdata)->xwindow;
XClientMessageEvent event; XClientMessageEvent event;
memset(&event, 0, sizeof(XClientMessageEvent)); SDL_memset(&event, 0, sizeof(XClientMessageEvent));
event.type = ClientMessage; event.type = ClientMessage;
event.display = req_display; event.display = req_display;
event.send_event = True; event.send_event = True;

View File

@ -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 * 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 * errno to ERANGE. So we need to check for this so we dont get crazy dpi
* values * values

View File

@ -71,7 +71,7 @@ X11_ResizeWindowShape(SDL_Window* window) {
return SDL_SetError("Could not allocate memory for shaped-window bitmap."); 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->userx = window->x;
window->shaper->usery = window->y; window->shaper->usery = window->y;

View File

@ -737,9 +737,9 @@ X11_SetWindowTitle(_THIS, SDL_Window * window)
Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME; Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
Atom WM_NAME = data->videodata->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) { if (status != 1) {
char *x11_error = NULL; char *x11_error = NULL;

View File

@ -50,7 +50,7 @@ get_bits (int in, int begin, int end)
static int static int
decode_header (const uchar *edid) 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 TRUE;
return FALSE; return FALSE;
} }

View File

@ -210,7 +210,7 @@ static int SDLCALL ping_thread(void *ptr)
{ {
int cnt; int cnt;
SDL_Event sdlevent; SDL_Event sdlevent;
memset(&sdlevent, 0 , sizeof(SDL_Event)); SDL_memset(&sdlevent, 0 , sizeof(SDL_Event));
for (cnt = 0; cnt < 10; ++cnt) { for (cnt = 0; cnt < 10; ++cnt) {
fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10); fflush(stderr); fprintf(stderr, "sending event (%d/%d) from thread.\n", cnt + 1, 10); fflush(stderr);
sdlevent.type = SDL_KEYDOWN; sdlevent.type = SDL_KEYDOWN;

View File

@ -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); SDLTest_AssertCheck(len >= 1 && len <= 255, "Validate that result length; expected: len=[1,255], got: %d", (int) len);
nonAsciiCharacters = 0; nonAsciiCharacters = 0;
for (i=0; i<len; i++) { for (i=0; i<len; i++) {
if (iscntrl(result[i])) { if (SDL_iscntrl(result[i])) {
nonAsciiCharacters++; nonAsciiCharacters++;
} }
} }
@ -1169,7 +1169,7 @@ sdltest_randomAsciiStringWithMaximumLength(void *arg)
SDLTest_AssertCheck(len >= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int) targetLen, (int) len); SDLTest_AssertCheck(len >= 1 && len <= targetLen, "Validate that result length; expected: len=[1,%d], got: %d", (int) targetLen, (int) len);
nonAsciiCharacters = 0; nonAsciiCharacters = 0;
for (i=0; i<len; i++) { for (i=0; i<len; i++) {
if (iscntrl(result[i])) { if (SDL_iscntrl(result[i])) {
nonAsciiCharacters++; nonAsciiCharacters++;
} }
} }
@ -1223,7 +1223,7 @@ sdltest_randomAsciiStringOfSize(void *arg)
SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", (int) targetLen, (int) len); SDLTest_AssertCheck(len == targetLen, "Validate that result length; expected: len=%d, got: %d", (int) targetLen, (int) len);
nonAsciiCharacters = 0; nonAsciiCharacters = 0;
for (i=0; i<len; i++) { for (i=0; i<len; i++) {
if (iscntrl(result[i])) { if (SDL_iscntrl(result[i])) {
nonAsciiCharacters++; nonAsciiCharacters++;
} }
} }

View File

@ -961,11 +961,11 @@ run_test(void)
printf("%s...\n", t->name); printf("%s...\n", t->name);
memset(&caps, '\0', sizeof(caps)); SDL_memset(&caps, '\0', sizeof(caps));
memcpy(caps.ev, t->ev, sizeof(t->ev)); SDL_memcpy(caps.ev, t->ev, sizeof(t->ev));
memcpy(caps.keys, t->keys, sizeof(t->keys)); SDL_memcpy(caps.keys, t->keys, sizeof(t->keys));
memcpy(caps.abs, t->abs, sizeof(t->abs)); SDL_memcpy(caps.abs, t->abs, sizeof(t->abs));
memcpy(caps.rel, t->rel, sizeof(t->rel)); SDL_memcpy(caps.rel, t->rel, sizeof(t->rel));
for (j = 0; j < SDL_arraysize(caps.ev); j++) { for (j = 0; j < SDL_arraysize(caps.ev); j++) {
caps.ev[j] = SwapLongLE(caps.ev[j]); caps.ev[j] = SwapLongLE(caps.ev[j]);

View File

@ -238,10 +238,10 @@ main(int argc, char *argv[])
consumed = SDLTest_CommonArg(state, i); consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) { if (consumed == 0) {
if (SDL_strcasecmp(argv[i], "--fsaa") == 0 && i+1 < argc) { if (SDL_strcasecmp(argv[i], "--fsaa") == 0 && i+1 < argc) {
fsaa = atoi(argv[i+1]); fsaa = SDL_atoi(argv[i+1]);
consumed = 2; consumed = 2;
} else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) { } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) {
accel = atoi(argv[i+1]); accel = SDL_atoi(argv[i+1]);
consumed = 2; consumed = 2;
} else { } else {
consumed = -1; consumed = -1;

View File

@ -163,8 +163,8 @@ process_shader(GLuint *shader, const char * source, GLint shader_type)
} }
/* Notes on a_angle: /* Notes on a_angle:
* It is a vector containing sin and cos for rotation matrix * It is a vector containing sine and cosine for rotation matrix
* To get correct rotation for most cases when a_angle is disabled cos * 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 value is decremented by 1.0 to get proper output with 0.0 which is
default value default value
*/ */

View File

@ -14,10 +14,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
/* /*
* includes * includes
*/ */
#include <stdlib.h>
#include <string.h> /* strstr */
#include <ctype.h> /* isdigit */
#include "SDL.h" #include "SDL.h"
#ifndef SDL_HAPTIC_DISABLED #ifndef SDL_HAPTIC_DISABLED
@ -55,7 +51,7 @@ main(int argc, char **argv)
index = -1; index = -1;
if (argc > 1) { if (argc > 1) {
name = argv[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" SDL_Log("USAGE: %s [device]\n"
"If device is a two-digit number it'll use it as an index, otherwise\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", "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; return 0;
} }
i = strlen(name); i = SDL_strlen(name);
if ((i < 3) && isdigit(name[0]) && ((i == 1) || isdigit(name[1]))) { if ((i < 3) && SDL_isdigit(name[0]) && ((i == 1) || SDL_isdigit(name[1]))) {
index = atoi(name); index = SDL_atoi(name);
name = NULL; name = NULL;
} }
} }
@ -82,7 +78,7 @@ main(int argc, char **argv)
/* Try to find matching device */ /* Try to find matching device */
else { else {
for (i = 0; i < SDL_NumHaptics(); i++) { for (i = 0; i < SDL_NumHaptics(); i++) {
if (strstr(SDL_HapticName(i), name) != NULL) if (SDL_strstr(SDL_HapticName(i), name) != NULL)
break; break;
} }
@ -110,7 +106,7 @@ main(int argc, char **argv)
SDL_ClearError(); SDL_ClearError();
/* Create effects. */ /* Create effects. */
memset(&efx, 0, sizeof(efx)); SDL_memset(&efx, 0, sizeof(efx));
nefx = 0; nefx = 0;
supported = SDL_HapticQuery(haptic); supported = SDL_HapticQuery(haptic);

View File

@ -648,12 +648,12 @@ int main(int argc, char *argv[])
} }
for (argc--, argv++; argc > 0; argc--, argv++) for (argc--, argv++; argc > 0; argc--, argv++)
{ {
if (strcmp(argv[0], "--help") == 0) { if (SDL_strcmp(argv[0], "--help") == 0) {
usage(); usage();
return 0; return 0;
} }
else if (strcmp(argv[0], "--font") == 0) else if (SDL_strcmp(argv[0], "--font") == 0)
{ {
argc--; argc--;
argv++; argv++;

View File

@ -44,7 +44,7 @@ main(int argc, char *argv[])
return 2; return 2;
} }
if (strcmp(argv[1], "--hello") == 0) { if (SDL_strcmp(argv[1], "--hello") == 0) {
hello = 1; hello = 1;
libname = argv[2]; libname = argv[2];
symname = "puts"; symname = "puts";

View File

@ -25,10 +25,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
/* /*
* includes * includes
*/ */
#include <stdlib.h>
#include <string.h> /* strstr */
#include <ctype.h> /* isdigit */
#include "SDL.h" #include "SDL.h"
#ifndef SDL_HAPTIC_DISABLED #ifndef SDL_HAPTIC_DISABLED
@ -56,7 +52,7 @@ main(int argc, char **argv)
if (argc > 1) { if (argc > 1) {
size_t l; size_t l;
name = argv[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" SDL_Log("USAGE: %s [device]\n"
"If device is a two-digit number it'll use it as an index, otherwise\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", "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 */ /* Try to find matching device */
else { else {
for (i = 0; i < SDL_NumHaptics(); i++) { for (i = 0; i < SDL_NumHaptics(); i++) {
if (strstr(SDL_HapticName(i), name) != NULL) if (SDL_strstr(SDL_HapticName(i), name) != NULL)
break; break;
} }

View File

@ -262,7 +262,7 @@ main(int argc, char **argv)
signal(SIGTERM, killed); signal(SIGTERM, killed);
signal(SIGINT, killed); signal(SIGINT, killed);
init_sem = atoi(argv[1]); init_sem = SDL_atoi(argv[1]);
if (init_sem > 0) { if (init_sem > 0) {
TestRealWorld(init_sem); TestRealWorld(init_sem);
} }

View File

@ -72,7 +72,7 @@ main(int argc, char *argv[])
/* Start the timer */ /* Start the timer */
desired = 0; desired = 0;
if (argv[1]) { if (argv[1]) {
desired = atoi(argv[1]); desired = SDL_atoi(argv[1]);
} }
if (desired == 0) { if (desired == 0) {
desired = DEFAULT_RESOLUTION; desired = DEFAULT_RESOLUTION;

View File

@ -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: // This formula is from Microsoft's documentation:
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd206750(v=vs.85).aspx // https://msdn.microsoft.com/en-us/library/windows/desktop/dd206750(v=vs.85).aspx
// L = Kr * R + Kb * B + (1 - Kr - Kb) * G // L = Kr * R + Kb * B + (1 - Kr - Kb) * G
// Y = floor(2^(M-8) * (219*(L-Z)/S + 16) + 0.5); // Y = SDL_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)); // 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, floor(2^(M-8) * (112*(R-L) / ((1-Kr)*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; float S, Z, R, G, B, L, Kr, Kb, Y, U, V;
if (mode == SDL_YUV_CONVERSION_BT709) { if (mode == SDL_YUV_CONVERSION_BT709) {