src/buffer.c

Thu, 19 Dec 2024 21:33:45 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 19 Dec 2024 21:33:45 +0100
changeset 1028
3e4905241838
parent 1024
8f99f6c28bd3
child 1030
06091e067bee
permissions
-rw-r--r--

add copy-on-extend feature to UCX buffer - fixes #533

483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2021 Mike Becker, Olaf Wintermann All rights reserved.
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 */
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 #include "cx/buffer.h"
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30
530
e866516cac17 #170 first buffer tests
Mike Becker <universe@uap-core.de>
parents: 529
diff changeset
31 #include <stdio.h>
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 #include <string.h>
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33
1028
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
34 static int buffer_copy_on_write(CxBuffer* buffer) {
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
35 if (0 == (buffer->flags & CX_BUFFER_COPY_ON_WRITE)) return 0;
1028
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
36 void *newspace = cxMalloc(buffer->allocator, buffer->capacity);
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
37 if (NULL == newspace) return -1;
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
38 memcpy(newspace, buffer->space, buffer->size);
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
39 buffer->space = newspace;
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
40 buffer->flags &= ~CX_BUFFER_COPY_ON_WRITE;
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
41 buffer->flags |= CX_BUFFER_FREE_CONTENTS;
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
42 return 0;
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
43 }
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
44
501
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
45 int cxBufferInit(
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
46 CxBuffer *buffer,
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 void *space,
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 size_t capacity,
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 761
diff changeset
49 const CxAllocator *allocator,
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 int flags
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 ) {
989
8aa57a7fecc4 improve consistency for allocator arguments - fixes #485
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
52 if (allocator == NULL) {
8aa57a7fecc4 improve consistency for allocator arguments - fixes #485
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
53 allocator = cxDefaultAllocator;
8aa57a7fecc4 improve consistency for allocator arguments - fixes #485
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
54 }
1028
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
55 if (flags & CX_BUFFER_COPY_ON_EXTEND) {
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
56 flags |= CX_BUFFER_AUTO_EXTEND;
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
57 }
501
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
58 buffer->allocator = allocator;
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
59 buffer->flags = flags;
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
60 if (!space) {
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
61 buffer->bytes = cxMalloc(allocator, capacity);
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
62 if (buffer->bytes == NULL) {
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
63 return -1;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 }
501
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
65 buffer->flags |= CX_BUFFER_FREE_CONTENTS;
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
66 } else {
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
67 buffer->bytes = space;
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
68 }
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
69 buffer->capacity = capacity;
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
70 buffer->size = 0;
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
71 buffer->pos = 0;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
73 buffer->flush_func = NULL;
541
67e078518935 #170 complete write tests for status quo
Mike Becker <universe@uap-core.de>
parents: 540
diff changeset
74 buffer->flush_target = NULL;
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
75 buffer->flush_blkmax = 0;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
76 buffer->flush_blksize = 4096;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
77 buffer->flush_threshold = SIZE_MAX;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
78
501
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
79 return 0;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
80 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
81
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
82 void cxBufferDestroy(CxBuffer *buffer) {
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
83 if (buffer->flags & CX_BUFFER_FREE_CONTENTS) {
501
9a08f5e515cc add allocator support to CxBuffer
Mike Becker <universe@uap-core.de>
parents: 500
diff changeset
84 cxFree(buffer->allocator, buffer->bytes);
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
85 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
86 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
87
683
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
88 CxBuffer *cxBufferCreate(
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
89 void *space,
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
90 size_t capacity,
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 761
diff changeset
91 const CxAllocator *allocator,
683
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
92 int flags
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
93 ) {
989
8aa57a7fecc4 improve consistency for allocator arguments - fixes #485
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
94 if (allocator == NULL) {
8aa57a7fecc4 improve consistency for allocator arguments - fixes #485
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
95 allocator = cxDefaultAllocator;
8aa57a7fecc4 improve consistency for allocator arguments - fixes #485
Mike Becker <universe@uap-core.de>
parents: 985
diff changeset
96 }
683
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
97 CxBuffer *buf = cxMalloc(allocator, sizeof(CxBuffer));
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
98 if (buf == NULL) return NULL;
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
99 if (0 == cxBufferInit(buf, space, capacity, allocator, flags)) {
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
100 return buf;
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
101 } else {
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
102 cxFree(allocator, buf);
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
103 return NULL;
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
104 }
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
105 }
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
106
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
107 void cxBufferFree(CxBuffer *buffer) {
985
68754c7de906 major refactoring of attributes
Mike Becker <universe@uap-core.de>
parents: 970
diff changeset
108 if (buffer == NULL) return;
991
ec49db06dae0 cxBufferFree() now calls cxBufferDestroy()
Mike Becker <universe@uap-core.de>
parents: 989
diff changeset
109 cxBufferDestroy(buffer);
683
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
110 cxFree(buffer->allocator, buffer);
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
111 }
aa0d09f2d81c add convenience functions for allocating a buffer on the heap
Mike Becker <universe@uap-core.de>
parents: 673
diff changeset
112
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
113 int cxBufferSeek(
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
114 CxBuffer *buffer,
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
115 off_t offset,
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
116 int whence
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
117 ) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
118 size_t npos;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
119 switch (whence) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
120 case SEEK_CUR:
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
121 npos = buffer->pos;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
122 break;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
123 case SEEK_END:
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
124 npos = buffer->size;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
125 break;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
126 case SEEK_SET:
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
127 npos = 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
128 break;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
129 default:
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
130 return -1;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
131 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
132
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
133 size_t opos = npos;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
134 npos += offset;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
135
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
136 if ((offset > 0 && npos < opos) || (offset < 0 && npos > opos)) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
137 return -1;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
138 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
139
1007
81b2986d2b04 fix that cxBufferSeek() cannot move pos past the end - fixes #523
Mike Becker <universe@uap-core.de>
parents: 1005
diff changeset
140 if (npos > buffer->size) {
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
141 return -1;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
142 } else {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
143 buffer->pos = npos;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
144 return 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
145 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
146
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
147 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
148
529
814d51173f20 #171 const qualifier and nonnull attributes
Mike Becker <universe@uap-core.de>
parents: 501
diff changeset
149 void cxBufferClear(CxBuffer *buffer) {
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
150 if (0 == (buffer->flags & CX_BUFFER_COPY_ON_WRITE)) {
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
151 memset(buffer->bytes, 0, buffer->size);
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
152 }
529
814d51173f20 #171 const qualifier and nonnull attributes
Mike Becker <universe@uap-core.de>
parents: 501
diff changeset
153 buffer->size = 0;
814d51173f20 #171 const qualifier and nonnull attributes
Mike Becker <universe@uap-core.de>
parents: 501
diff changeset
154 buffer->pos = 0;
814d51173f20 #171 const qualifier and nonnull attributes
Mike Becker <universe@uap-core.de>
parents: 501
diff changeset
155 }
814d51173f20 #171 const qualifier and nonnull attributes
Mike Becker <universe@uap-core.de>
parents: 501
diff changeset
156
761
61d5197d612b add cxBufferReset() - resolves #338
Mike Becker <universe@uap-core.de>
parents: 683
diff changeset
157 void cxBufferReset(CxBuffer *buffer) {
61d5197d612b add cxBufferReset() - resolves #338
Mike Becker <universe@uap-core.de>
parents: 683
diff changeset
158 buffer->size = 0;
61d5197d612b add cxBufferReset() - resolves #338
Mike Becker <universe@uap-core.de>
parents: 683
diff changeset
159 buffer->pos = 0;
61d5197d612b add cxBufferReset() - resolves #338
Mike Becker <universe@uap-core.de>
parents: 683
diff changeset
160 }
61d5197d612b add cxBufferReset() - resolves #338
Mike Becker <universe@uap-core.de>
parents: 683
diff changeset
161
1004
d8044fd5005c make cxBufferEof() return a bool
Mike Becker <universe@uap-core.de>
parents: 991
diff changeset
162 bool cxBufferEof(const CxBuffer *buffer) {
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
163 return buffer->pos >= buffer->size;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
164 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
165
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
166 int cxBufferMinimumCapacity(
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
167 CxBuffer *buffer,
532
080c304ec176 fix cxBufferMinimumCapacity implementation still using additional_bytes
Mike Becker <universe@uap-core.de>
parents: 530
diff changeset
168 size_t newcap
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
169 ) {
532
080c304ec176 fix cxBufferMinimumCapacity implementation still using additional_bytes
Mike Becker <universe@uap-core.de>
parents: 530
diff changeset
170 if (newcap <= buffer->capacity) {
080c304ec176 fix cxBufferMinimumCapacity implementation still using additional_bytes
Mike Becker <universe@uap-core.de>
parents: 530
diff changeset
171 return 0;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
172 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
173
1028
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
174 const int force_copy_flags = CX_BUFFER_COPY_ON_WRITE | CX_BUFFER_COPY_ON_EXTEND;
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
175 if (buffer->flags & force_copy_flags) {
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
176 void *newspace = cxMalloc(buffer->allocator, newcap);
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
177 if (NULL == newspace) return -1;
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
178 memcpy(newspace, buffer->space, buffer->size);
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
179 buffer->space = newspace;
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
180 buffer->capacity = newcap;
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
181 buffer->flags &= ~force_copy_flags;
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
182 buffer->flags |= CX_BUFFER_FREE_CONTENTS;
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
183 return 0;
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
184 } else if (cxReallocate(buffer->allocator,
536
cb9b9739055e #170 add cxBufferClear test
Mike Becker <universe@uap-core.de>
parents: 534
diff changeset
185 (void **) &buffer->bytes, newcap) == 0) {
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
186 buffer->capacity = newcap;
533
8d70ad8da899 do not implicitly zero freshly allocated memory
Mike Becker <universe@uap-core.de>
parents: 532
diff changeset
187 return 0;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
188 } else {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
189 return -1;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
190 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
191 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
192
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
193 /**
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
194 * Helps flushing data to the flush target of a buffer.
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
195 *
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
196 * @param buffer the buffer containing the config
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
197 * @param space the data to flush
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
198 * @param size the element size
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
199 * @param nitems the number of items
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
200 * @return the number of items flushed
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
201 */
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
202 static size_t cx_buffer_write_flush_helper(
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
203 CxBuffer *buffer,
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 761
diff changeset
204 const unsigned char *space,
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
205 size_t size,
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
206 size_t nitems
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
207 ) {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
208 size_t pos = 0;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
209 size_t remaining = nitems;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
210 size_t max_items = buffer->flush_blksize / size;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
211 while (remaining > 0) {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
212 size_t items = remaining > max_items ? max_items : remaining;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
213 size_t flushed = buffer->flush_func(
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
214 space + pos,
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
215 size, items,
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
216 buffer->flush_target);
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
217 if (flushed > 0) {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
218 pos += (flushed * size);
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
219 remaining -= flushed;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
220 } else {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
221 // if no bytes can be flushed out anymore, we give up
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
222 break;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
223 }
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
224 }
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
225 return nitems - remaining;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
226 }
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
227
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
228 size_t cxBufferWrite(
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 761
diff changeset
229 const void *ptr,
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
230 size_t size,
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
231 size_t nitems,
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
232 CxBuffer *buffer
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
233 ) {
543
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
234 // optimize for easy case
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
235 if (size == 1 && (buffer->capacity - buffer->pos) >= nitems) {
1028
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
236 if (buffer_copy_on_write(buffer)) return 0;
543
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
237 memcpy(buffer->bytes + buffer->pos, ptr, nitems);
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
238 buffer->pos += nitems;
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
239 if (buffer->pos > buffer->size) {
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
240 buffer->size = buffer->pos;
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
241 }
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
242 return nitems;
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
243 }
7b9114030ca4 optimization for buffer write easy cases
Mike Becker <universe@uap-core.de>
parents: 542
diff changeset
244
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
245 size_t len;
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
246 size_t nitems_out = nitems;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
247 if (cx_szmul(size, nitems, &len)) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
248 return 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
249 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
250 size_t required = buffer->pos + len;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
251 if (buffer->pos > required) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
252 return 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
253 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
254
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
255 bool perform_flush = false;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
256 if (required > buffer->capacity) {
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
257 if (buffer->flags & CX_BUFFER_AUTO_EXTEND) {
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
258 if (buffer->flush_blkmax > 0 && required > buffer->flush_threshold) {
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
259 perform_flush = true;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
260 } else {
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
261 if (cxBufferMinimumCapacity(buffer, required)) {
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
262 return 0;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
263 }
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
264 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
265 } else {
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
266 if (buffer->flush_blkmax > 0) {
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
267 perform_flush = true;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
268 } else {
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
269 // truncate data to be written, if we can neither extend nor flush
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
270 len = buffer->capacity - buffer->pos;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
271 if (size > 1) {
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
272 len -= len % size;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
273 }
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
274 nitems_out = len / size;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
275 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
276 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
277 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
278
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
279 if (len == 0) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
280 return len;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
281 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
282
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
283 if (perform_flush) {
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
284 size_t flush_max;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
285 if (cx_szmul(buffer->flush_blkmax, buffer->flush_blksize, &flush_max)) {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
286 return 0;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
287 }
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
288 size_t flush_pos = buffer->flush_func == NULL || buffer->flush_target == NULL
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
289 ? buffer->pos
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
290 : cx_buffer_write_flush_helper(buffer, buffer->bytes, 1, buffer->pos);
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
291 if (flush_pos == buffer->pos) {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
292 // entire buffer has been flushed, we can reset
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
293 buffer->size = buffer->pos = 0;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
294
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
295 size_t items_flush; // how many items can also be directly flushed
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
296 size_t items_keep; // how many items have to be written to the buffer
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
297
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
298 items_flush = flush_max >= required ? nitems : (flush_max - flush_pos) / size;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
299 if (items_flush > 0) {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
300 items_flush = cx_buffer_write_flush_helper(buffer, ptr, size, items_flush / size);
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
301 // in case we could not flush everything, keep the rest
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
302 }
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
303 items_keep = nitems - items_flush;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
304 if (items_keep > 0) {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
305 // try again with the remaining stuff
890
54565fd74e74 move all const keywords to the west - fixes #426
Mike Becker <universe@uap-core.de>
parents: 761
diff changeset
306 const unsigned char *new_ptr = ptr;
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
307 new_ptr += items_flush * size;
567
f90a7cfe2480 #184 #170 more thorough flush testing
Mike Becker <universe@uap-core.de>
parents: 544
diff changeset
308 // report the directly flushed items as written plus the remaining stuff
f90a7cfe2480 #184 #170 more thorough flush testing
Mike Becker <universe@uap-core.de>
parents: 544
diff changeset
309 return items_flush + cxBufferWrite(new_ptr, size, items_keep, buffer);
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
310 } else {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
311 // all items have been flushed - report them as written
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
312 return nitems;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
313 }
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
314 } else if (flush_pos == 0) {
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
315 // nothing could be flushed at all, we immediately give up without writing any data
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
316 return 0;
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
317 } else {
567
f90a7cfe2480 #184 #170 more thorough flush testing
Mike Becker <universe@uap-core.de>
parents: 544
diff changeset
318 // we were partially successful, we shift left and try again
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
319 cxBufferShiftLeft(buffer, flush_pos);
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
320 return cxBufferWrite(ptr, size, nitems, buffer);
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
321 }
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
322 } else {
1028
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
323 if (buffer_copy_on_write(buffer)) return 0;
539
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
324 memcpy(buffer->bytes + buffer->pos, ptr, len);
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
325 buffer->pos += len;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
326 if (buffer->pos > buffer->size) {
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
327 buffer->size = buffer->pos;
9cd98da9ee17 #184 start implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 538
diff changeset
328 }
544
2e73456e5f84 #184 untested implementation of the flush feature
Mike Becker <universe@uap-core.de>
parents: 543
diff changeset
329 return nitems_out;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
330 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
331
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
332 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
333
538
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
334 int cxBufferPut(
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
335 CxBuffer *buffer,
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
336 int c
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
337 ) {
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
338 c &= 0xFF;
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
339 unsigned char const ch = c;
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
340 if (cxBufferWrite(&ch, 1, 1, buffer) == 1) {
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
341 return c;
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
342 } else {
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
343 return EOF;
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
344 }
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
345 }
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
346
1005
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
347 int cxBufferTerminate(CxBuffer *buffer) {
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
348 bool success = 0 == cxBufferPut(buffer, 0);
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
349 if (success) {
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
350 buffer->pos--;
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
351 buffer->size--;
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
352 return 0;
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
353 } else {
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
354 return -1;
1005
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
355 }
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
356 }
67fa386ce600 add cxBufferTerminate()
Mike Becker <universe@uap-core.de>
parents: 1004
diff changeset
357
538
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
358 size_t cxBufferPutString(
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
359 CxBuffer *buffer,
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
360 const char *str
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
361 ) {
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
362 return cxBufferWrite(str, 1, strlen(str), buffer);
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
363 }
2cfbcbe86a7c #170 first basic write tests
Mike Becker <universe@uap-core.de>
parents: 536
diff changeset
364
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
365 size_t cxBufferRead(
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
366 void *ptr,
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
367 size_t size,
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
368 size_t nitems,
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
369 CxBuffer *buffer
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
370 ) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
371 size_t len;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
372 if (cx_szmul(size, nitems, &len)) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
373 return 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
374 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
375 if (buffer->pos + len > buffer->size) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
376 len = buffer->size - buffer->pos;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
377 if (size > 1) len -= len % size;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
378 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
379
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
380 if (len <= 0) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
381 return len;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
382 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
383
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
384 memcpy(ptr, buffer->bytes + buffer->pos, len);
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
385 buffer->pos += len;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
386
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
387 return len / size;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
388 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
389
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
390 int cxBufferGet(CxBuffer *buffer) {
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
391 if (cxBufferEof(buffer)) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
392 return EOF;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
393 } else {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
394 int c = buffer->bytes[buffer->pos];
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
395 buffer->pos++;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
396 return c;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
397 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
398 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
399
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
400 int cxBufferShiftLeft(
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
401 CxBuffer *buffer,
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
402 size_t shift
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
403 ) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
404 if (shift >= buffer->size) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
405 buffer->pos = buffer->size = 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
406 } else {
1028
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
407 if (buffer_copy_on_write(buffer)) return -1;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
408 memmove(buffer->bytes, buffer->bytes + shift, buffer->size - shift);
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
409 buffer->size -= shift;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
410
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
411 if (buffer->pos >= shift) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
412 buffer->pos -= shift;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
413 } else {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
414 buffer->pos = 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
415 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
416 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
417 return 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
418 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
419
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
420 int cxBufferShiftRight(
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
421 CxBuffer *buffer,
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
422 size_t shift
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
423 ) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
424 size_t req_capacity = buffer->size + shift;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
425 size_t movebytes;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
426
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
427 // auto extend buffer, if required and enabled
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
428 if (buffer->capacity < req_capacity) {
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
429 if (buffer->flags & CX_BUFFER_AUTO_EXTEND) {
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
430 if (cxBufferMinimumCapacity(buffer, req_capacity)) {
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
431 return -1;
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
432 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
433 movebytes = buffer->size;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
434 } else {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
435 movebytes = buffer->capacity - shift;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
436 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
437 } else {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
438 movebytes = buffer->size;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
439 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
440
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
441 if (movebytes > 0) {
1028
3e4905241838 add copy-on-extend feature to UCX buffer - fixes #533
Mike Becker <universe@uap-core.de>
parents: 1024
diff changeset
442 if (buffer_copy_on_write(buffer)) return -1;
1024
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
443 memmove(buffer->bytes + shift, buffer->bytes, movebytes);
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
444 buffer->size = shift + movebytes;
8f99f6c28bd3 add copy-on-write feature to UCX buffer - fixes #531
Mike Becker <universe@uap-core.de>
parents: 1007
diff changeset
445 }
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
446
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
447 buffer->pos += shift;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
448 if (buffer->pos > buffer->size) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
449 buffer->pos = buffer->size;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
450 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
451
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
452 return 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
453 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
454
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
455 int cxBufferShift(
500
eb9e7bd40a8e do not hide pointers behind typedefs
Mike Becker <universe@uap-core.de>
parents: 489
diff changeset
456 CxBuffer *buffer,
483
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
457 off_t shift
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
458 ) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
459 if (shift < 0) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
460 return cxBufferShiftLeft(buffer, (size_t) (-shift));
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
461 } else if (shift > 0) {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
462 return cxBufferShiftRight(buffer, (size_t) shift);
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
463 } else {
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
464 return 0;
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
465 }
929016224c3c add ported UCX buffer implementation
Mike Becker <universe@uap-core.de>
parents:
diff changeset
466 }

mercurial