Changeset 2156


Ignore:
Timestamp:
May 24, 2012, 7:37:13 PM (7 years ago)
Author:
ksherdy
Message:

Added size parameter to macros.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/buffer.hpp

    r2151 r2156  
    1010//              BLOCK_SIZE defined as a number of bytes.
    1111//
    12 #define PADDING_BLOCKS 0
     12#define PADDING_BLOCKS 1
    1313#define PADDING_SIZE (BLOCK_SIZE * PADDING_BLOCKS)
    14 #define COPYBACK_BLOCKS 2
     14#define COPYBACK_BLOCKS 0
    1515#define COPYBACK_SIZE (BLOCK_SIZE * COPYBACK_BLOCKS)
    16 #define SEGMENT_BLOCKS  2
     16#define SEGMENT_BLOCKS  12
    1717#define SEGMENT_SIZE (BLOCK_SIZE * SEGMENT_BLOCKS)
    1818#define BUFFER_SIZE (COPYBACK_SIZE + SEGMENT_SIZE + PADDING_SIZE)
     
    2929//
    3030///////////////////////////////////////////////////////////////////////////
    31 #define ALLOC_STATIC_ALIGNED_BYTE_BUFFER(base_ptr) \
    32     ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[BUFFER_SIZE/sizeof(BitBlock)]; \
     31
     32#define ALLOC_STATIC_ALIGNED_BYTE_BUFFER(base_ptr, buffer_size) \
     33    ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[buffer_size/sizeof(BitBlock)]; \
     34    assert_bitblock_align((void*)aligned_##base_ptr);\
     35    base_ptr = (uint8_t *)&aligned_##base_ptr[0];\
     36
     37#define ALLOC_STATIC_ALIGNED_BITBLOCK_BUFFER(base_ptr, buffer_size) \
     38    ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[buffer_size/sizeof(BitBlock)/8]; \
    3339    assert_bitblock_align((void*)aligned_##base_ptr);\
    3440    base_ptr = &aligned_##base_ptr[0];\
    3541
    36 #define ALLOC_STATIC_ALIGNED_BITBLOCK_BUFFER(base_ptr) \
    37     ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[BUFFER_SIZE/sizeof(BitBlock)/8]; \
    38     assert_bitblock_align((void*)aligned_##base_ptr);\
    39     base_ptr = &aligned_##base_ptr[0];\
    40 
    41 #define ALLOC_STATIC_ALIGNED_BYTE_BUFFER_WITH_COPYBACK(copyback_ptr, base_ptr) \
    42     ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[BUFFER_SIZE/sizeof(BitBlock)]; \
     42#define ALLOC_STATIC_ALIGNED_BYTE_BUFFER_WITH_COPYBACK(copyback_ptr, base_ptr, buffer_size) \
     43    ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[buffer_size/sizeof(BitBlock)]; \
    4344    assert_bitblock_align((void*)aligned_##base_ptr);\
    4445    copyback_ptr = (uint8_t *)aligned_##base_ptr; \
    4546    memset(copyback_ptr,0,COPYBACK_SIZE); \
    46     base_ptr = &copyback_ptr[COPYBACK_SIZE]; \
     47    base_ptr = (uint8_t *)&copyback_ptr[COPYBACK_SIZE]; \
    4748
    48 #define ALLOC_STATIC_ALIGNED_BITBLOCK_BUFFER_WITH_COPYBACK(copyback_ptr, base_ptr) \
    49     ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[BUFFER_SIZE/sizeof(BitBlock)/8]; \
     49#define ALLOC_STATIC_ALIGNED_BITBLOCK_BUFFER_WITH_COPYBACK(copyback_ptr, base_ptr, buffer_size) \
     50    ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[buffer_size/sizeof(BitBlock)/8]; \
    5051    assert_bitblock_align((void*)aligned_##base_ptr);\
    5152    copyback_ptr = (BitBlock *) aligned_##base_ptr; \
     
    5354    base_ptr = &copyback_ptr[COPYBACK_BLOCKS]; \
    5455
    55 #define COPY_BACK_BYTE_BUFFER(copyback_ptr, base_ptr) \
     56#define COPY_BACK_BYTE_BUFFER(copyback_ptr, base_ptr, copyback_size, segment_size) \
    5657do {    void * dest = copyback_ptr;\
    57     void * src = (uint8_t *)base_ptr + (SEGMENT_SIZE - COPYBACK_SIZE);\
     58    void * src = (uint8_t *)base_ptr + (segment_size - copyback_size);\
    5859        assert_bitblock_align(src);\
    5960        assert_bitblock_align(dest);\
    60         memmove(dest, src, COPYBACK_SIZE);\
     61    memmove(dest, src, copyback_size);\
    6162} while(0)
    6263
    63 #define COPY_BACK_BITBLOCK_BUFFER(copyback_ptr, base_ptr) \
     64#define COPY_BACK_BITBLOCK_BUFFER(copyback_ptr, base_ptr, copyback_size, segment_size) \
    6465do {    void * dest = copyback_ptr;\
    65     void * src = (uint8_t *)base_ptr + ((SEGMENT_SIZE - COPYBACK_SIZE)/8);\
     66    void * src = (uint8_t *)base_ptr + ((segment_size - copyback_size)/8);\
    6667        assert_bitblock_align(src);\
    6768        assert_bitblock_align(dest);\
    68         memmove(dest, src, COPYBACK_SIZE/8);\
     69    memmove(dest, src, copyback_size/8);\
    6970} while(0)
    7071
Note: See TracChangeset for help on using the changeset viewer.