13 #define sarray_transfer_many PREFIXED_NAME(sarray_transfer_many)
14 #define sarray_transfer_ PREFIXED_NAME(sarray_transfer_ )
15 #define sarray_transfer_ext_ PREFIXED_NAME(sarray_transfer_ext_)
18 buffer *
const data,
const unsigned row_size,
const uint id,
22 const unsigned after = p_off +
sizeof(
uint), after_len = size-after;
24 #define GET_P() memcpy(&p,row+p_off,sizeof(uint))
25 #define COPY_ROW() memcpy(out,row,p_off), \
26 memcpy((char*)out + p_off,row+after,after_len)
28 #define PACK_BODY() do { \
29 uint dummy, *len_ptr=&dummy; \
30 uint i, p,lp = -(uint)1, len=0; \
31 uint *restrict out = buffer_reserve(data, n*(row_size+3)*sizeof(uint)); \
33 const char *row = input + size*perm[i]; \
40 len_ptr=out++; len=0; \
43 out += row_size, len += row_size; \
46 data->n = out - (uint*)data->ptr; \
54 buffer *
const data,
const unsigned row_size,
const uint id,
56 const uint *
const restrict proc,
const unsigned proc_stride,
59 #define GET_P() p=*(const uint*)((const char*)proc+proc_stride*perm[i])
60 #define COPY_ROW() memcpy(out,row,size)
68 buffer *
const data,
const unsigned off,
const unsigned row_size,
74 uint *msg_end = buf+3+buf[2]; buf+=3;
76 memcpy((
char*)buf+off, input+size*(*perm++), size), buf+=row_size;
82 const buffer *
const data,
const unsigned off,
const unsigned row_size)
86 const uint *msg_end = buf+3+buf[2]; buf+=3;
88 memcpy(out, (
char*)buf+off, size), out+=size, buf+=row_size;
93 char *
restrict out,
const unsigned size,
const unsigned p_off,
94 const buffer *
const data,
const unsigned row_size,
int set_src)
96 const unsigned after = p_off +
sizeof(
uint), after_len = size-after;
98 const unsigned pi = set_src ? 1:0;
100 const uint p=buf[pi], *msg_end = buf+3+buf[2]; buf+=3;
101 while(buf!=msg_end) {
102 memcpy(out,buf,p_off);
103 memcpy(out+p_off,&p,
sizeof(
uint));
104 memcpy(out+after,(
const char *)buf+p_off,after_len);
105 out+=size, buf+=row_size;
112 const uint *buf = data->
ptr, *buf_end = buf + data->
n;
114 while(buf!=buf_end) {
uint len=buf[2]; n+=len, buf+=len+3; }
120 uint *buf = data->
ptr, *buf_end = buf + data->
n;
121 const uint maxn = max*row_size;
123 while(buf!=buf_end) {
124 uint len=buf[2]; n+=len;
125 if(n<maxn) buf+=len+3;
127 buf[2]-=(maxn-
n); data->
n = (buf-(
uint*)data->
ptr)+3+buf[2];
129 while(buf!=buf_end) {
uint len=buf[2]; n+=len, buf+=len+3; }
138 struct array *
const *
const A,
const unsigned *
const size,
const unsigned An,
139 const int fixed,
const int ext,
const int set_src,
const unsigned p_off,
140 const uint *
const restrict proc,
const unsigned proc_stride,
144 unsigned i,row_size,off,off1;
147 if(!ext) off1 -=
sizeof(
uint);
148 row_size=off1;
for(i=1;i<An;++
i) row_size += size[i];
149 row_size = (row_size+
sizeof(
uint)-1)/
sizeof(
uint);
151 perm =
sortp(&cr->
work,0, proc,A[0]->
n,proc_stride);
156 proc,proc_stride, perm);
157 for(off=off1,i=1;i<An;++
i)
if(size[i])
168 for(i=1;i<An;++
i)
if(A[i]->max<max) max=A[
i]->
max;
171 for(i=0;i<An;++
i) A[i]->n=an;
174 if(!ext)
unpack_int (A[0]->ptr,size[0],p_off, &cr->
data, row_size, set_src);
176 for(off=off1,i=1;i<An;++
i)
if(size[i])
184 const unsigned p_off,
const int set_src,
188 (
uint*)((
char*)A->
ptr+p_off),size, cr);
192 const uint *
const proc,
const unsigned proc_stride,
static void * array_reserve_(struct array *a, size_t min, size_t size, const char *file, unsigned line)
static uint cap_rows(buffer *const data, const unsigned row_size, const uint max)
static void pack_int(buffer *const data, const unsigned row_size, const uint id, const char *const restrict input, const uint n, const unsigned size, const unsigned p_off, const uint *const restrict perm)
static void pack_ext(buffer *const data, const unsigned row_size, const uint id, const char *const restrict input, const uint n, const unsigned size, const uint *const restrict proc, const unsigned proc_stride, const uint *const restrict perm)
static uint num_rows(const buffer *const data, const unsigned row_size)
#define sarray_transfer_many
uint * sortp(buffer *restrict buf, int start_perm, const T *restrict A, uint n, unsigned stride)
static void unpack_more(char *restrict out, const unsigned size, const buffer *const data, const unsigned off, const unsigned row_size)
static void unpack_int(char *restrict out, const unsigned size, const unsigned p_off, const buffer *const data, const unsigned row_size, int set_src)
establishes some macros to establish naming conventions
#define sarray_transfer_ext_
static void pack_more(buffer *const data, const unsigned off, const unsigned row_size, const char *const restrict input, const unsigned size, const uint *restrict perm)