summaryrefslogtreecommitdiffstats
path: root/baseline/source/susan/wccmalloc.c
blob: edf01cc47c9183b65d60d24decdb24867c6c12f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
File: huff_dec.c
Original provenience: David Bourgin (David.Bourgin@ufrima.imag.fr)

2016-03-23:
- Replaced dynamic memory allocation by a fixed array with 514 entries
- Replaced memset() with loops
- Replaced file I/O by reading and writing to char arrays
- Added huff_dec_main(), huff_dec_init() and huff_dec_return()
- Added huff_dec_ prefix to all functions, types and global variables
- Changed function arguments to ANSI style
- Replaced macro definitions
- Added generic TACLeBench header replacing previous header
- Included license from compress.txt
- Corrected loop bounds in huff_dec_read_header()

2016-05-24:
- static removed and huff_dec prefix added

2016-05-25:
- added const to void g++ warning
50 51
#include "wccmalloc.h"

// This must be redefined for each new benchmark
#define HEAP_SIZE 30000

char susan_simulated_heap[HEAP_SIZE];
unsigned int susan_freeHeapPos;

void* susan_wccmalloc( unsigned int numberOfBytes )
{
  // Get a 4-byte adress for alignment purposes
  unsigned int offset = ( (unsigned long)susan_simulated_heap + susan_freeHeapPos ) % 4;
  if ( offset ) {
    susan_freeHeapPos += 4 - offset;
  }
  void* currentPos = (void*)&susan_simulated_heap[susan_freeHeapPos];
  susan_freeHeapPos += numberOfBytes;
  return currentPos;
}
void susan_wccfreeall( void ) 
{
  susan_freeHeapPos = 0;
}

void* susan_wccmemcpy(void* dstpp, const void* srcpp, unsigned int len)
{
  unsigned long int dstp = (long int) dstpp;
  unsigned long int srcp = (long int) srcpp;

  _Pragma("loopbound min 76 max 76")
  while (len > 0) {
    char __x = ((char *) srcp)[0];
    srcp += 1;
    len -= 1;
    ((char *) dstp)[0] = __x;
    dstp += 1;
  }

  return dstpp;
}

void susan_wccmemset( void *p, int value, unsigned int num )
{
  unsigned long i;
  char *char_ptr = (char*)p;

  _Pragma( "loopbound min 7220 max 28880" )
  for ( i = 0; i < num; ++i ) {
    *char_ptr++ = (unsigned char)value;
  }
}