Harlequin RIP SDK
Harlequin standard memory set, copy, move, and compare functions

Files

file  hqmemcmp.h
 Interface to memory compare utility.
 
file  hqmemcpy.h
 Two entry points for copying blocks of memory, closely shadowing the ANSI functions memcpy and memmove.
 
file  hqmemset.h
 Functions for setting a blocks of memory to a fixed value, providing a uniform alternative to the C functions memset/memfill/bzero.
 

Macros

#define SIMPLEST_MEMSET   0
 
#define HqMemSet8(_p, _v, _c)
 
#define HqMemSet16(_p, _v, _c)
 
#define HqMemSet32(_p, _v, _c)
 
#define HqMemSet64(_p, _v, _c)
 
#define HqMemSetPtr(_p, _v, _c)   HqMemSet64((uint64 *)(char *)(_p), (uint64)(uintptr_t)(_v), (_c))
 
#define HqMemNullPtr(_p, _c)   HqMemSet64((uint64 *)(char *)(_p), (uint64)(uintptr_t)(NULL), (_c))
 
#define HqMemZero(_p, _c)   HqMemSet8_f((uint8 *)(_p), (uint8)0, (size_t)(_c))
 

Functions

int32 HqMemCmp (const void *s1, size_t ln1, const void *s2, size_t ln2)
 Compare two blocks of memory, returning a total order comparising indicator over the contents of the memory. More...
 
HqBool HqMemEqual (const void *s1, size_t ln1, const void *s2, size_t ln2)
 Compare two blocks of memory, returning a boolean indicating whether the blocks of memory are equal or not. More...
 
void HqMemCpy (void *dest, const void *src, size_t count)
 Copy a number of bytes from one location in memory to another. More...
 
void HqMemMove (void *dest, const void *src, size_t count)
 Copy a number of bytes from one location in memory to another, coping with overlapping blocks. More...
 
void HqMemSet8_f (uint8 *ptr, uint8 val, size_t count)
 
void HqMemSet16_f (uint16 *ptr, uint16 val, size_t count)
 
void HqMemSet32_f (uint32 *ptr, uint32 val, size_t count)
 
void HqMemSet64_f (uint64 *ptr, uint64 val, size_t count)
 

Detailed Description

The standard memory functions should be used by SDK and core functions for all block move, copy, set, and compare operations where possible. Platform specific optimisations applied to the definitions of these operations will affect all of the RIP code.

Macro Definition Documentation

◆ HqMemNullPtr

#define HqMemNullPtr (   _p,
  _c 
)    HqMemSet64((uint64 *)(char *)(_p), (uint64)(uintptr_t)(NULL), (_c))

Set a block of memory to a pointer value NULL. This may be implemented as a macro.

Parameters
[out]_pThe address of the memory block to set.
_cThe number of values to set.

◆ HqMemSet16

#define HqMemSet16 (   _p,
  _v,
  _c 
)

Set a block of memory to a 16-bit value. This may be implemented as a macro.

Parameters
[out]_pThe address of the memory block to set.
_vThe value to set each memory unit to.
_cThe number of values to set.

◆ HqMemSet32

#define HqMemSet32 (   _p,
  _v,
  _c 
)

Set a block of memory to a 32-bit value. This may be implemented as a macro.

Parameters
[out]_pThe address of the memory block to set.
_vThe value to set each memory unit to.
_cThe number of values to set.

◆ HqMemSet64

#define HqMemSet64 (   _p,
  _v,
  _c 
)

Set a block of memory to a 64-bit value. This may be implemented as a macro.

Parameters
[out]_pThe address of the memory block to set.
_vThe value to set each memory unit to.
_cThe number of values to set.

◆ HqMemSet8

#define HqMemSet8 (   _p,
  _v,
  _c 
)

Set a block of memory to a byte value. This may be implemented as a macro.

Parameters
[out]_pThe address of the memory block to set.
_vThe value to set each memory unit to.
_cThe number of values to set.

◆ HqMemSetPtr

#define HqMemSetPtr (   _p,
  _v,
  _c 
)    HqMemSet64((uint64 *)(char *)(_p), (uint64)(uintptr_t)(_v), (_c))

Set a block of memory to a pointer value. This may be implemented as a macro.

Parameters
[out]_pThe address of the memory block to set.
_vThe value to set each memory unit to.
_cThe number of values to set.

◆ HqMemZero

#define HqMemZero (   _p,
  _c 
)    HqMemSet8_f((uint8 *)(_p), (uint8)0, (size_t)(_c))

Set a block of memory to zero. This may be implemented as a macro. This macro should be used in preference to the explicitly sized memory setting functions, because the platform may provide optimisations specifically for zeroing memory.

Parameters
[out]_pThe address of the memory block to set to zero.
_cThe number of bytes to set to zero.

◆ SIMPLEST_MEMSET

#define SIMPLEST_MEMSET   0

For ease of profiling and performance testing it is often the case that having all memsets as a very simple implementation in their own function (and not inline) is useful. If this is required, set the following define to 1.

Function Documentation

◆ HqMemCmp()

int32 HqMemCmp ( const void *  s1,
size_t  ln1,
const void *  s2,
size_t  ln2 
)

Compare two blocks of memory, returning a total order comparising indicator over the contents of the memory.

Parameters
[in]s1A pointer to a block of memory. This may be NULL if ln1 is zero, otherwise it must point at a valid memory block of length ln1.
ln1The length in bytes of the memory block pointed to by s1. This must be greater than or equal to zero.
[in]s2A pointer to a block of memory. This may be NULL if ln2 is zero, otherwise it must point at a valid memory block of length ln2.
ln2The length in bytes of the memory block pointed to by s2. This must be greater than or equal to zero.
Returns
0 if the contents and lengths of the memory blocks are identical. A negative value is returned if the contents of s1 are ordered before s2. A positive value is returned if the contents of s1 are ordered after s2.

◆ HqMemCpy()

void HqMemCpy ( void *  dest,
const void *  src,
size_t  count 
)

Copy a number of bytes from one location in memory to another.

Parameters
[out]destThe location to copy the source memory to.
[in]srcThe location to copy memory from.
countThe number of bytes to copy. This must be greater than or equal to zero.

This function should not be called with overlapping memory blocks. Use HqMemMove() instead.

◆ HqMemEqual()

HqBool HqMemEqual ( const void *  s1,
size_t  ln1,
const void *  s2,
size_t  ln2 
)

Compare two blocks of memory, returning a boolean indicating whether the blocks of memory are equal or not.

Parameters
[in]s1A pointer to a block of memory. This may be NULL if ln1 is zero, otherwise it must point at a valid memory block of length ln1.
ln1The length in bytes of the memory block pointed to by s1. This must be greater than or equal to zero.
[in]s2A pointer to a block of memory. This may be NULL if ln2 is zero, otherwise it must point at a valid memory block of length ln2.
ln2The length in bytes of the memory block pointed to by s2. This must be greater than or equal to zero.
Return values
TRUEif the contents and lengths of the memory blocks are identical.
FALSEif the contents and lengths of the memory blocks are not identical.

◆ HqMemMove()

void HqMemMove ( void *  dest,
const void *  src,
size_t  count 
)

Copy a number of bytes from one location in memory to another, coping with overlapping blocks.

Parameters
[out]destThe location to copy the source memory to.
[in]srcThe location to copy memory from.
countThe number of bytes to copy. This must be greater than or equal to zero.

This function is safe to use when the blocks of memory overlap.

◆ HqMemSet16_f()

void HqMemSet16_f ( uint16 ptr,
uint16  val,
size_t  count 
)

Set a block of memory to a 16-bit value, using a function.

Parameters
[out]ptrThe address of the memory block to set.
valThe value to set each memory unit to.
countThe number of values to set.

◆ HqMemSet32_f()

void HqMemSet32_f ( uint32 ptr,
uint32  val,
size_t  count 
)

Set a block of memory to a 32-bit value, using a function.

Parameters
[out]ptrThe address of the memory block to set.
valThe value to set each memory unit to.
countThe number of values to set.

◆ HqMemSet64_f()

void HqMemSet64_f ( uint64 ptr,
uint64  val,
size_t  count 
)

Set a block of memory to a 64-bit value, using a function.

Parameters
[out]ptrThe address of the memory block to set.
valThe value to set each memory unit to.
countThe number of values to set.

◆ HqMemSet8_f()

void HqMemSet8_f ( uint8 ptr,
uint8  val,
size_t  count 
)

Set a block of memory to a byte value, using a function.

Parameters
[out]ptrThe address of the memory block to set.
valThe value to set each memory unit to.
countThe number of values to set.