Endianness check
Altlinux build / build-alt (push) Failing after 2m3s
Archlinux build / build-arch (push) Successful in 2m58s
Debian build / build-ubuntu (push) Has been cancelled
Archlinux build / make-test (push) Has been cancelled

This commit is contained in:
zx
2025-05-01 18:10:15 +03:00
parent 144eacc0d6
commit 5eb6ddc45b
4 changed files with 31 additions and 16 deletions
+21 -12
View File
@@ -253,10 +253,10 @@ int checkmasks(const char *masks, const char *str)
*/
char *buffer_putlong(char *buffer, long val)
{
buffer[0] = ( ((unsigned long) val) ) & 0xff;
buffer[1] = ( ((unsigned long) val) >> 8 ) & 0xff;
buffer[2] = ( ((unsigned long) val) >> 16 ) & 0xff;
buffer[3] = ( ((unsigned long) val) >> 24 ) & 0xff;
buffer[0] = ( ((uint_least32_t) val) ) & 0xff;
buffer[1] = ( ((uint_least32_t) val) >> 8 ) & 0xff;
buffer[2] = ( ((uint_least32_t) val) >> 16 ) & 0xff;
buffer[3] = ( ((uint_least32_t) val) >> 24 ) & 0xff;
return buffer;
}
@@ -273,8 +273,8 @@ char *buffer_putlong(char *buffer, long val)
*/
char *buffer_putint(char *buffer, int val)
{
buffer[0] = ( ((unsigned int) val) ) & 0xff;
buffer[1] = ( ((unsigned int) val) >> 8 ) & 0xff;
buffer[0] = ( ((uint_least16_t) val) ) & 0xff;
buffer[1] = ( ((uint_least16_t) val) >> 8 ) & 0xff;
return buffer;
}
@@ -290,10 +290,10 @@ char *buffer_putint(char *buffer, int val)
*/
long buffer_getlong(const char *buffer)
{
return ( (unsigned long) ((unsigned char) buffer[0]) )
| ( (unsigned long) ((unsigned char) buffer[1]) << 8 )
| ( (unsigned long) ((unsigned char) buffer[2]) << 16 )
| ( (unsigned long) ((unsigned char) buffer[3]) << 24 );
return (long)( (uint_least32_t) ((unsigned char) buffer[0]) )
| ( (uint_least32_t) ((unsigned char) buffer[1]) << 8 )
| ( (uint_least32_t) ((unsigned char) buffer[2]) << 16 )
| ( (uint_least32_t) ((unsigned char) buffer[3]) << 24 );
}
/*****************************************************************************
@@ -307,8 +307,17 @@ long buffer_getlong(const char *buffer)
*/
int buffer_getint(const char *buffer)
{
return ( (unsigned int) ((unsigned char) buffer[0]) )
| ( (unsigned int) ((unsigned char) buffer[1]) << 8 );
return (int)( (uint_least16_t) ((unsigned char) buffer[0]) )
| ( (uint_least16_t) ((unsigned char) buffer[1]) << 8 );
}
void swap_long(char *buffer){
char *temp = xmemcpy(buffer, sizeof(uint32_t));
temp[0] = buffer[2];
temp[1] = buffer[3];
temp[2] = buffer[0];
temp[3] = buffer[1];
memcpy(buffer,temp,sizeof(uint32_t));
}
void printf_usage(const char *ident, const char *fmt, ...)