Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

intutils.c File Reference

#include <assert.h>
#include "base/intutils.h"
#include "debug/macros.h"

Defines

#define SWAP(PTR1, PTR2)

Functions

void base_copySmall (void *vdst, const void *vsrc, size_t n)
 Best compromise for copy:
  • for Intel, it is better to define our own copy function for small copies memcpy is better for sizes over 120-150
  • for Sun, memcpy is always worse.

void base_fill (void *mem, size_t n, uint32_t value)
 Fill memory with a given value.
uint32_t base_diff (const void *data, size_t n, uint32_t value)
 Check if memory differs with a given value.
BOOL base_areEqual (const void *data1, const void *data2, size_t n)
 Test equality.
static void intutils_quicksort (uint32_t *min, uint32_t *max)
void base_sort (uint32_t *values, size_t n)
 Quick sort: from lower to higher ints.

Define Documentation

#define SWAP PTR1,
PTR2   ) 
 

Value:

do { \
  uint32_t _tmp = *(PTR1);   \
  *(PTR1) = *(PTR2);         \
  *(PTR2) = _tmp;            \
} while(0)


Function Documentation

BOOL base_areEqual const void *  data1,
const void *  data2,
size_t  intSize
 

Test equality.

(optimistic implementation)

Parameters:
data1,data2,: data to be compared.
intSize,: size in int to compare.
Returns:
TRUE if the contents are the same.
Precondition:
data1 and data2 are of size int32_t[intSize] null pointers are accepted as argument

void base_copySmall void *  dst,
const void *  src,
size_t  intSize
 

Best compromise for copy:

  • for Intel, it is better to define our own copy function for small copies memcpy is better for sizes over 120-150
  • for Sun, memcpy is always worse.

As the cost of a function call is negligible we prefer to reduce code size by not inlining the code.

Parameters:
src,: source
dst,: destination
intSize,: size in int to copy
Precondition:
src and dst are int32_t[intsize].

uint32_t base_diff const void *  mem,
size_t  intSize,
uint32_t  intValue
 

Check if memory differs with a given value.

Parameters:
mem,: memory to check
intSize,: size in int to fill
intValue,: value to check
Returns:
0 if mem[0..intSize-1] == intValue, or !=0 otherwise.

void base_fill void *  mem,
size_t  intSize,
uint32_t  intValue
 

Fill memory with a given value.

Parameters:
mem,: memory to fill
intSize,: size in int to fill
intValue,: value to use to fill
Postcondition:
int[0..intSize-1] at mem is filled with intValue

void base_sort uint32_t *  values,
size_t  n
 

Quick sort: from lower to higher ints.

Parameters:
values,: values to sort
n,: number of values
Precondition:
values is a uint32_t[n]

static void intutils_quicksort uint32_t *  min,
uint32_t *  max
[static]
 


Generated on Fri Jun 30 00:02:30 2006 for Module base by  doxygen 1.4.2