public: add Q_memor routine that binary OR's data from src to dst
Supposed to be compiled with optimizations enabled.
This commit is contained in:
parent
0848f28d83
commit
2ad6511c31
3 changed files with 20 additions and 0 deletions
|
@ -128,6 +128,14 @@ typedef uint64_t longtime_t;
|
|||
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
|
||||
#endif
|
||||
|
||||
#if !defined( __cplusplus ) && __STDC_VERSION__ >= 199101L // not C++ and C99 or newer
|
||||
#define XASH_RESTRICT restrict
|
||||
#elif _MSC_VER || __GNUC__ || __clang__ // compiler-specific extensions
|
||||
#define XASH_RESTRICT __restrict
|
||||
#else
|
||||
#define XASH_RESTRICT // nothing
|
||||
#endif
|
||||
|
||||
#ifdef XASH_BIG_ENDIAN
|
||||
#define LittleLong(x) (((int)(((x)&255)<<24)) + ((int)((((x)>>8)&255)<<16)) + ((int)(((x)>>16)&255)<<8) + (((x) >> 24)&255))
|
||||
#define LittleLongSW(x) (x = LittleLong(x) )
|
||||
|
|
|
@ -274,6 +274,13 @@ const byte *Q_memmem( const byte *haystack, size_t haystacklen, const byte *need
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void Q_memor( byte *XASH_RESTRICT dst, const byte *XASH_RESTRICT src, size_t len )
|
||||
{
|
||||
size_t i;
|
||||
for( i = 0; i < len; i++ ) // msvc likes to optimize this loop form
|
||||
dst[i] |= src[i];
|
||||
}
|
||||
|
||||
const char* Q_timestamp( int format )
|
||||
{
|
||||
static string timestamp;
|
||||
|
|
|
@ -45,6 +45,10 @@ enum
|
|||
#define PFILE_TOKEN_MAX_LENGTH 1024
|
||||
#define PFILE_FS_TOKEN_MAX_LENGTH 512
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define restrict
|
||||
#endif // __cplusplus
|
||||
|
||||
//
|
||||
// build.c
|
||||
//
|
||||
|
@ -72,6 +76,7 @@ void Q_atov( float *vec, const char *str, size_t siz );
|
|||
qboolean Q_stricmpext( const char *pattern, const char *text );
|
||||
qboolean Q_strnicmpext( const char *pattern, const char *text, size_t minimumlen );
|
||||
const byte *Q_memmem( const byte *haystack, size_t haystacklen, const byte *needle, size_t needlelen );
|
||||
void Q_memor( byte *XASH_RESTRICT dst, const byte *XASH_RESTRICT src, size_t len );
|
||||
const char *Q_timestamp( int format );
|
||||
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args );
|
||||
int Q_snprintf( char *buffer, size_t buffersize, const char *format, ... ) _format( 3 );
|
||||
|
|
Loading…
Add table
Reference in a new issue