source: trunk/lib_c/buffer.h @ 3478

Last change on this file since 3478 was 3391, checked in by linmengl, 6 years ago

check in IDISA C library and other support libraries. Some template features still remain.

File size: 2.4 KB
Line 
1/* Generated by cpp2c.rb from ./buffer.hpp
2 * Use IDISA C support
3*/
4
5#ifndef BUFFER_H
6#define BUFFER_H
7#include "bitblock.h"
8
9///////////////////////////////////////////////////////////////////////////
10//
11// Statically Allocated Parallel Data Buffer Management
12//
13// Parallel data buffers with optional copyback/padding segments.
14//
15// |COPYBACK BLOCKS|WORKING SEGMENT BLOCKS|PADDING BLOCKS|
16//
17// WARNING: Statically allocated bitblock arrays must remain in scope.
18//
19///////////////////////////////////////////////////////////////////////////
20
21#define ALLOC_STATIC_ALIGNED_BYTE_BUFFER(base_ptr, buffer_size) \
22    ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[buffer_size/sizeof(BitBlock)]; \
23    assert_bitblock_align((void*)aligned_##base_ptr);\
24    base_ptr = (char *)&aligned_##base_ptr[0];\
25
26#define ALLOC_STATIC_ALIGNED_BITBLOCK_BUFFER(base_ptr, buffer_size) \
27    ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[buffer_size/sizeof(BitBlock)/8]; \
28    assert_bitblock_align((void*)aligned_##base_ptr);\
29    base_ptr = &aligned_##base_ptr[0];\
30
31// TODO - Unbake macro buffer constants. - BUFFER_SIZE
32
33#define ALLOC_STATIC_ALIGNED_BYTE_BUFFER_WITH_COPYBACK(copyback_ptr, base_ptr) \
34    ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[BUFFER_SIZE/sizeof(BitBlock)]; \
35    assert_bitblock_align((void*)aligned_##base_ptr);\
36    copyback_ptr = (char *)aligned_##base_ptr; \
37    memset(copyback_ptr,0,COPYBACK_SIZE); \
38    base_ptr = &copyback_ptr[COPYBACK_SIZE]; \
39
40#define ALLOC_STATIC_ALIGNED_BITBLOCK_BUFFER_WITH_COPYBACK(copyback_ptr, base_ptr) \
41    ATTRIBUTE_SIMD_ALIGN BitBlock aligned_##base_ptr[BUFFER_SIZE/sizeof(BitBlock)/8]; \
42    assert_bitblock_align((void*)aligned_##base_ptr);\
43    copyback_ptr = (BitBlock *) aligned_##base_ptr; \
44    memset(copyback_ptr,0,COPYBACK_SIZE/8); \
45    base_ptr = &copyback_ptr[COPYBACK_BLOCKS]; \
46
47#define COPY_BACK_BYTE_BUFFER(copyback_ptr, base_ptr) \
48do {    void * dest = copyback_ptr;\
49    void * src = (char *)base_ptr + (SEGMENT_SIZE - COPYBACK_SIZE);\
50    assert_bitblock_align(src);\
51    assert_bitblock_align(dest);\
52    memmove(dest, src, COPYBACK_SIZE);\
53} while(0)
54
55#define COPY_BACK_BITBLOCK_BUFFER(copyback_ptr, base_ptr) \
56do {    void * dest = copyback_ptr;\
57    void * src = (char *)base_ptr + ((SEGMENT_SIZE - COPYBACK_SIZE)/8);\
58    assert_bitblock_align(src);\
59    assert_bitblock_align(dest);\
60    memmove(dest, src, COPYBACK_SIZE/8);\
61} while(0)
62
63#endif // BUFFER_H
64
Note: See TracBrowser for help on using the repository browser.