« third_party/modest/source/mycore/mythread.c
↑ Summary
third_party/modest/source/mycore/utils/avl_tree.c »
| 1 | /* | ||||||||||||||
| 2 | Copyright (C) 2015-2017 Alexander Borisov | ||||||||||||||
| 3 | |||||||||||||||
| 4 | This library is free software; you can redistribute it and/or | ||||||||||||||
| 5 | modify it under the terms of the GNU Lesser General Public | ||||||||||||||
| 6 | License as published by the Free Software Foundation; either | ||||||||||||||
| 7 | version 2.1 of the License, or (at your option) any later version. | ||||||||||||||
| 8 | |||||||||||||||
| 9 | This library is distributed in the hope that it will be useful, | ||||||||||||||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||
| 12 | Lesser General Public License for more details. | ||||||||||||||
| 13 | |||||||||||||||
| 14 | You should have received a copy of the GNU Lesser General Public | ||||||||||||||
| 15 | License along with this library; if not, write to the Free Software | ||||||||||||||
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||||||||||||
| 17 | |||||||||||||||
| 18 | Author: lex.borisov@gmail.com (Alexander Borisov) | ||||||||||||||
| 19 | */ | ||||||||||||||
| 20 | |||||||||||||||
| 21 | #include "mycore/thread_queue.h" | ||||||||||||||
| 22 | |||||||||||||||
| 23 | 0 | mythread_queue_t * mythread_queue_create(void) | |||||||||||||
| 24 | { | ||||||||||||||
| 25 | 0 | return mycore_calloc(1, sizeof(mythread_queue_t)); | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | |||||||||||||||
| 28 | 0 | mystatus_t mythread_queue_init(mythread_queue_t* queue, size_t size) | |||||||||||||
| 29 | { | ||||||||||||||
| 30 | 0 | ▶ | if(size < 32) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 31 | 0 | size = 32; | |||||||||||||
| 32 | |||||||||||||||
| 33 | 0 | queue->nodes_pos_size = 512; | |||||||||||||
| 34 | 0 | queue->nodes_size = size; | |||||||||||||
| 35 | 0 | queue->nodes = (mythread_queue_node_t**)mycore_calloc(queue->nodes_pos_size, sizeof(mythread_queue_node_t*)); | |||||||||||||
| 36 | |||||||||||||||
| 37 | 0 | ▶ | if(queue->nodes == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 38 | 0 | return MyCORE_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC; | |||||||||||||
| 39 | |||||||||||||||
| 40 | 0 | queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)mycore_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size); | |||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | ▶ | if(queue->nodes[queue->nodes_pos] == NULL) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 0 | queue->nodes = mycore_free(queue->nodes); | |||||||||||||
| 44 | 0 | return MyCORE_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC; | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | 0 | return MyCORE_STATUS_OK; | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | |||||||||||||||
| 50 | 0 | void mythread_queue_clean(mythread_queue_t* queue) | |||||||||||||
| 51 | { | ||||||||||||||
| 52 | 0 | queue->nodes_length = 0; | |||||||||||||
| 53 | 0 | queue->nodes_pos = 0; | |||||||||||||
| 54 | 0 | queue->nodes_root = 0; | |||||||||||||
| 55 | 0 | queue->nodes_uses = 0; | |||||||||||||
| 56 | 0 | } | |||||||||||||
| 57 | |||||||||||||||
| 58 | 0 | mythread_queue_t * mythread_queue_destroy(mythread_queue_t* queue) | |||||||||||||
| 59 | { | ||||||||||||||
| 60 | 0 | ▶ | if(queue == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 61 | 0 | return NULL; | |||||||||||||
| 62 | |||||||||||||||
| 63 | 0 | ▶ | if(queue->nodes) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 64 | /* '<=' it is normal */ | ||||||||||||||
| 65 | 0 | ▶ | for (size_t i = 0; i <= queue->nodes_pos; i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 66 | 0 | mycore_free(queue->nodes[i]); | |||||||||||||
| 67 | } | ||||||||||||||
| 68 | |||||||||||||||
| 69 | 0 | mycore_free(queue->nodes); | |||||||||||||
| 70 | } | ||||||||||||||
| 71 | |||||||||||||||
| 72 | 0 | mycore_free(queue); | |||||||||||||
| 73 | |||||||||||||||
| 74 | 0 | return NULL; | |||||||||||||
| 75 | } | ||||||||||||||
| 76 | |||||||||||||||
| 77 | 0 | void mythread_queue_node_clean(mythread_queue_node_t* qnode) | |||||||||||||
| 78 | { | ||||||||||||||
| 79 | 0 | memset(qnode, 0, sizeof(mythread_queue_node_t)); | |||||||||||||
| 80 | 0 | } | |||||||||||||
| 81 | |||||||||||||||
| 82 | 0 | mythread_queue_node_t * mythread_queue_get_prev_node(mythread_queue_node_t* qnode) | |||||||||||||
| 83 | { | ||||||||||||||
| 84 | 0 | return qnode->prev; | |||||||||||||
| 85 | } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | 0 | mythread_queue_node_t * mythread_queue_get_current_node(mythread_queue_t* queue) | |||||||||||||
| 88 | { | ||||||||||||||
| 89 | 0 | return &queue->nodes[queue->nodes_pos][queue->nodes_length]; | |||||||||||||
| 90 | } | ||||||||||||||
| 91 | |||||||||||||||
| 92 | 0 | mythread_queue_node_t * mythread_queue_get_first_node(mythread_queue_t* queue) | |||||||||||||
| 93 | { | ||||||||||||||
| 94 | 0 | return &queue->nodes[0][0]; | |||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | 0 | size_t mythread_queue_count_used_node(mythread_queue_t* queue) | |||||||||||||
| 98 | { | ||||||||||||||
| 99 | 0 | return queue->nodes_uses; | |||||||||||||
| 100 | } | ||||||||||||||
| 101 | |||||||||||||||
| 102 | 0 | mythread_queue_node_t * mythread_queue_node_malloc(mythread_t *mythread, mythread_queue_t* queue, mystatus_t *status) | |||||||||||||
| 103 | { | ||||||||||||||
| 104 | 0 | queue->nodes_length++; | |||||||||||||
| 105 | |||||||||||||||
| 106 | 0 | ▶ | if(queue->nodes_length >= queue->nodes_size) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 107 | { | ||||||||||||||
| 108 | 0 | queue->nodes_pos++; | |||||||||||||
| 109 | |||||||||||||||
| 110 | 0 | ▶ | if(queue->nodes_pos >= queue->nodes_pos_size) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 111 | { | ||||||||||||||
| 112 | #ifndef MyCORE_BUILD_WITHOUT_THREADS | ||||||||||||||
| 113 | 0 | ▶ | if(mythread) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 114 | 0 | mythread_queue_list_wait_for_done(mythread, mythread->context); | |||||||||||||
| 115 | #endif | ||||||||||||||
| 116 | 0 | size_t new_size = queue->nodes_pos_size + 512; | |||||||||||||
| 117 | 0 | mythread_queue_node_t** tmp = mycore_realloc(queue->nodes, sizeof(mythread_queue_node_t*) * new_size); | |||||||||||||
| 118 | |||||||||||||||
| 119 | 0 | ▶ | if(tmp) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 120 | 0 | memset(&tmp[queue->nodes_pos], 0, sizeof(mythread_queue_node_t*) * (new_size - queue->nodes_pos)); | |||||||||||||
| 121 | |||||||||||||||
| 122 | 0 | queue->nodes = tmp; | |||||||||||||
| 123 | 0 | queue->nodes_pos_size = new_size; | |||||||||||||
| 124 | } | ||||||||||||||
| 125 | else { | ||||||||||||||
| 126 | 0 | ▶ | if(status) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 127 | 0 | *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC; | |||||||||||||
| 128 | |||||||||||||||
| 129 | 0 | return NULL; | |||||||||||||
| 130 | } | ||||||||||||||
| 131 | } | ||||||||||||||
| 132 | |||||||||||||||
| 133 | 0 | ▶ | if(queue->nodes[queue->nodes_pos] == NULL) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 134 | 0 | queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)mycore_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size); | |||||||||||||
| 135 | |||||||||||||||
| 136 | 0 | ▶ | if(queue->nodes[queue->nodes_pos] == NULL) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 137 | 0 | ▶ | if(status) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 138 | 0 | *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC; | |||||||||||||
| 139 | |||||||||||||||
| 140 | 0 | return NULL; | |||||||||||||
| 141 | } | ||||||||||||||
| 142 | } | ||||||||||||||
| 143 | |||||||||||||||
| 144 | 0 | queue->nodes_length = 0; | |||||||||||||
| 145 | } | ||||||||||||||
| 146 | |||||||||||||||
| 147 | 0 | queue->nodes_uses++; | |||||||||||||
| 148 | |||||||||||||||
| 149 | 0 | return &queue->nodes[queue->nodes_pos][queue->nodes_length]; | |||||||||||||
| 150 | } | ||||||||||||||
| 151 | |||||||||||||||
| 152 | 0 | mythread_queue_node_t * mythread_queue_node_malloc_limit(mythread_t *mythread, mythread_queue_t* queue, size_t limit, mystatus_t *status) | |||||||||||||
| 153 | { | ||||||||||||||
| 154 | 0 | queue->nodes_length++; | |||||||||||||
| 155 | |||||||||||||||
| 156 | 0 | ▶ | if(queue->nodes_uses >= limit) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 157 | 0 | queue->nodes_uses++; | |||||||||||||
| 158 | |||||||||||||||
| 159 | #ifndef MyCORE_BUILD_WITHOUT_THREADS | ||||||||||||||
| 160 | 0 | ▶ | if(mythread) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 161 | 0 | mythread_queue_list_wait_for_done(mythread, mythread->context); | |||||||||||||
| 162 | #endif | ||||||||||||||
| 163 | 0 | queue->nodes_length = 0; | |||||||||||||
| 164 | 0 | queue->nodes_pos = 0; | |||||||||||||
| 165 | 0 | queue->nodes_root = 0; | |||||||||||||
| 166 | 0 | queue->nodes_uses = 0; | |||||||||||||
| 167 | } | ||||||||||||||
| 168 | 0 | ▶ | else if(queue->nodes_length >= queue->nodes_size) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 169 | { | ||||||||||||||
| 170 | 0 | queue->nodes_pos++; | |||||||||||||
| 171 | |||||||||||||||
| 172 | 0 | ▶ | if(queue->nodes_pos >= queue->nodes_pos_size) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 173 | { | ||||||||||||||
| 174 | #ifndef MyCORE_BUILD_WITHOUT_THREADS | ||||||||||||||
| 175 | 0 | ▶ | if(mythread) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 176 | 0 | mythread_queue_list_wait_for_done(mythread, mythread->context); | |||||||||||||
| 177 | #endif | ||||||||||||||
| 178 | 0 | size_t new_size = queue->nodes_pos_size + 512; | |||||||||||||
| 179 | 0 | mythread_queue_node_t** tmp = mycore_realloc(queue->nodes, sizeof(mythread_queue_node_t*) * new_size); | |||||||||||||
| 180 | |||||||||||||||
| 181 | 0 | ▶ | if(tmp) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 182 | 0 | memset(&tmp[queue->nodes_pos], 0, sizeof(mythread_queue_node_t*) * (new_size - queue->nodes_pos)); | |||||||||||||
| 183 | |||||||||||||||
| 184 | 0 | queue->nodes = tmp; | |||||||||||||
| 185 | 0 | queue->nodes_pos_size = new_size; | |||||||||||||
| 186 | } | ||||||||||||||
| 187 | else { | ||||||||||||||
| 188 | 0 | ▶ | if(status) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 189 | 0 | *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_NODES_MALLOC; | |||||||||||||
| 190 | |||||||||||||||
| 191 | 0 | return NULL; | |||||||||||||
| 192 | } | ||||||||||||||
| 193 | } | ||||||||||||||
| 194 | |||||||||||||||
| 195 | 0 | ▶ | if(queue->nodes[queue->nodes_pos] == NULL) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 196 | 0 | queue->nodes[queue->nodes_pos] = (mythread_queue_node_t*)mycore_malloc(sizeof(mythread_queue_node_t) * queue->nodes_size); | |||||||||||||
| 197 | |||||||||||||||
| 198 | 0 | ▶ | if(queue->nodes[queue->nodes_pos] == NULL) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 199 | 0 | ▶ | if(status) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 200 | 0 | *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_NODE_MALLOC; | |||||||||||||
| 201 | |||||||||||||||
| 202 | 0 | return NULL; | |||||||||||||
| 203 | } | ||||||||||||||
| 204 | } | ||||||||||||||
| 205 | |||||||||||||||
| 206 | 0 | queue->nodes_length = 0; | |||||||||||||
| 207 | } | ||||||||||||||
| 208 | |||||||||||||||
| 209 | 0 | queue->nodes_uses++; | |||||||||||||
| 210 | |||||||||||||||
| 211 | 0 | return &queue->nodes[queue->nodes_pos][queue->nodes_length]; | |||||||||||||
| 212 | } | ||||||||||||||
| 213 | |||||||||||||||
| 214 | #ifndef MyCORE_BUILD_WITHOUT_THREADS | ||||||||||||||
| 215 | 0 | mythread_queue_node_t * mythread_queue_node_malloc_round(mythread_t *mythread, mythread_queue_list_entry_t *entry) | |||||||||||||
| 216 | { | ||||||||||||||
| 217 | 0 | mythread_queue_t* queue = entry->queue; | |||||||||||||
| 218 | |||||||||||||||
| 219 | 0 | queue->nodes_length++; | |||||||||||||
| 220 | |||||||||||||||
| 221 | 0 | ▶ | if(queue->nodes_length >= queue->nodes_size) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 222 | 0 | queue->nodes_uses++; | |||||||||||||
| 223 | |||||||||||||||
| 224 | #ifndef MyCORE_BUILD_WITHOUT_THREADS | ||||||||||||||
| 225 | 0 | ▶ | if(mythread) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 226 | 0 | mythread_queue_list_entry_wait_for_done(mythread, entry); | |||||||||||||
| 227 | #endif | ||||||||||||||
| 228 | |||||||||||||||
| 229 | 0 | mythread_queue_list_entry_clean(entry); | |||||||||||||
| 230 | } | ||||||||||||||
| 231 | else | ||||||||||||||
| 232 | 0 | queue->nodes_uses++; | |||||||||||||
| 233 | |||||||||||||||
| 234 | 0 | return &queue->nodes[queue->nodes_pos][queue->nodes_length]; | |||||||||||||
| 235 | } | ||||||||||||||
| 236 | #endif | ||||||||||||||
| 237 | |||||||||||||||
| 238 | #ifndef MyCORE_BUILD_WITHOUT_THREADS | ||||||||||||||
| 239 | /* | ||||||||||||||
| 240 | * Queue List | ||||||||||||||
| 241 | */ | ||||||||||||||
| 242 | 0 | mythread_queue_list_t * mythread_queue_list_create(mystatus_t *status) | |||||||||||||
| 243 | { | ||||||||||||||
| 244 | 0 | return (mythread_queue_list_t*)mycore_calloc(1, sizeof(mythread_queue_list_t)); | |||||||||||||
| 245 | } | ||||||||||||||
| 246 | |||||||||||||||
| 247 | 0 | void mythread_queue_list_destroy(mythread_queue_list_t* queue_list) | |||||||||||||
| 248 | { | ||||||||||||||
| 249 | 0 | ▶ | if(queue_list == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 250 | 0 | return; | |||||||||||||
| 251 | |||||||||||||||
| 252 | 0 | mycore_free(queue_list); | |||||||||||||
| 253 | } | ||||||||||||||
| 254 | |||||||||||||||
| 255 | 0 | size_t mythread_queue_list_get_count(mythread_queue_list_t* queue_list) | |||||||||||||
| 256 | { | ||||||||||||||
| 257 | 0 | return queue_list->count; | |||||||||||||
| 258 | } | ||||||||||||||
| 259 | |||||||||||||||
| 260 | 0 | void mythread_queue_list_wait_for_done(mythread_t* mythread, mythread_queue_list_t* queue_list) | |||||||||||||
| 261 | { | ||||||||||||||
| 262 | 0 | ▶ | if(queue_list == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 263 | 0 | return; | |||||||||||||
| 264 | |||||||||||||||
| 265 | 0 | mythread_queue_list_entry_t *entry = queue_list->first; | |||||||||||||
| 266 | |||||||||||||||
| 267 | 0 | ▶ | while(entry) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 268 | { | ||||||||||||||
| 269 | 0 | ▶ | for (size_t i = 0; i < mythread->entries_length; i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 270 | 0 | ▶ | while(entry->thread_param[i].use < entry->queue->nodes_uses) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 271 | 0 | mythread_nanosleep_sleep(mythread->timespec); | |||||||||||||
| 272 | } | ||||||||||||||
| 273 | |||||||||||||||
| 274 | 0 | entry = entry->next; | |||||||||||||
| 275 | } | ||||||||||||||
| 276 | } | ||||||||||||||
| 277 | |||||||||||||||
| 278 | 0 | bool mythread_queue_list_see_for_done(mythread_t* mythread, mythread_queue_list_t* queue_list) | |||||||||||||
| 279 | { | ||||||||||||||
| 280 | 0 | ▶ | if(queue_list == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 281 | 0 | return true; | |||||||||||||
| 282 | |||||||||||||||
| 283 | 0 | mythread_queue_list_entry_t *entry = queue_list->first; | |||||||||||||
| 284 | |||||||||||||||
| 285 | 0 | ▶ | while(entry) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 286 | { | ||||||||||||||
| 287 | 0 | ▶ | for (size_t i = 0; i < mythread->entries_length; i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 288 | 0 | ▶ | if(entry->thread_param[i].use < entry->queue->nodes_uses) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 289 | 0 | return false; | |||||||||||||
| 290 | } | ||||||||||||||
| 291 | |||||||||||||||
| 292 | 0 | entry = entry->next; | |||||||||||||
| 293 | } | ||||||||||||||
| 294 | |||||||||||||||
| 295 | 0 | return true; | |||||||||||||
| 296 | } | ||||||||||||||
| 297 | |||||||||||||||
| 298 | 0 | bool mythread_queue_list_see_for_done_by_thread(mythread_t* mythread, mythread_queue_list_t* queue_list, mythread_id_t thread_id) | |||||||||||||
| 299 | { | ||||||||||||||
| 300 | 0 | ▶ | if(queue_list == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 301 | 0 | return true; | |||||||||||||
| 302 | |||||||||||||||
| 303 | 0 | mythread_queue_list_entry_t *entry = queue_list->first; | |||||||||||||
| 304 | |||||||||||||||
| 305 | 0 | ▶ | while(entry) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 306 | { | ||||||||||||||
| 307 | 0 | ▶ | if(entry->thread_param[thread_id].use < entry->queue->nodes_uses) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 308 | 0 | return false; | |||||||||||||
| 309 | |||||||||||||||
| 310 | 0 | entry = entry->next; | |||||||||||||
| 311 | } | ||||||||||||||
| 312 | |||||||||||||||
| 313 | 0 | return true; | |||||||||||||
| 314 | } | ||||||||||||||
| 315 | |||||||||||||||
| 316 | /* | ||||||||||||||
| 317 | * Queue List Entry | ||||||||||||||
| 318 | */ | ||||||||||||||
| 319 | 0 | mythread_queue_list_entry_t * mythread_queue_list_entry_push(mythread_t** mythread_list, size_t list_size, mythread_queue_list_t* queue_list, | |||||||||||||
| 320 | mythread_queue_t* queue, size_t thread_param_size, mystatus_t* status) | ||||||||||||||
| 321 | { | ||||||||||||||
| 322 | 0 | ▶ | if(status) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 323 | 0 | *status = MyCORE_STATUS_OK; | |||||||||||||
| 324 | |||||||||||||||
| 325 | /* create new entry */ | ||||||||||||||
| 326 | 0 | mythread_queue_list_entry_t* entry = (mythread_queue_list_entry_t*)mycore_calloc(1, sizeof(mythread_queue_list_entry_t)); | |||||||||||||
| 327 | 0 | ▶ | if(entry == NULL) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 328 | 0 | ▶ | if(status) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 329 | 0 | *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_MALLOC; | |||||||||||||
| 330 | |||||||||||||||
| 331 | 0 | return NULL; | |||||||||||||
| 332 | } | ||||||||||||||
| 333 | |||||||||||||||
| 334 | /* create thread params */ | ||||||||||||||
| 335 | 0 | entry->thread_param_size = thread_param_size; | |||||||||||||
| 336 | |||||||||||||||
| 337 | 0 | ▶ | if(thread_param_size) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 338 | 0 | entry->thread_param = (mythread_queue_thread_param_t*)mycore_calloc(thread_param_size, sizeof(mythread_queue_thread_param_t)); | |||||||||||||
| 339 | |||||||||||||||
| 340 | 0 | ▶ | if(entry->thread_param == NULL) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 341 | 0 | mycore_free(entry); | |||||||||||||
| 342 | |||||||||||||||
| 343 | 0 | ▶ | if(status) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 344 | 0 | *status = MyCORE_STATUS_THREAD_ERROR_QUEUE_MALLOC; | |||||||||||||
| 345 | |||||||||||||||
| 346 | 0 | return NULL; | |||||||||||||
| 347 | } | ||||||||||||||
| 348 | } | ||||||||||||||
| 349 | else | ||||||||||||||
| 350 | 0 | entry->thread_param = NULL; | |||||||||||||
| 351 | |||||||||||||||
| 352 | 0 | entry->queue = queue; | |||||||||||||
| 353 | |||||||||||||||
| 354 | 0 | ▶ | for(size_t i = 0; i < list_size; i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 355 | 0 | ▶ | if(mythread_list[i]) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 356 | 0 | ▶ | if(mythread_list[i]->type == MyTHREAD_TYPE_BATCH) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 357 | 0 | mythread_queue_list_entry_make_batch(mythread_list[i], entry); | |||||||||||||
| 358 | else | ||||||||||||||
| 359 | 0 | mythread_queue_list_entry_make_stream(mythread_list[i], entry); | |||||||||||||
| 360 | |||||||||||||||
| 361 | 0 | mythread_suspend(mythread_list[i]); | |||||||||||||
| 362 | } | ||||||||||||||
| 363 | } | ||||||||||||||
| 364 | |||||||||||||||
| 365 | 0 | ▶ | if(queue_list->first) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 366 | 0 | queue_list->last->next = entry; | |||||||||||||
| 367 | 0 | entry->prev = queue_list->last; | |||||||||||||
| 368 | |||||||||||||||
| 369 | 0 | queue_list->last = entry; | |||||||||||||
| 370 | } | ||||||||||||||
| 371 | else { | ||||||||||||||
| 372 | 0 | queue_list->first = entry; | |||||||||||||
| 373 | 0 | queue_list->last = entry; | |||||||||||||
| 374 | } | ||||||||||||||
| 375 | |||||||||||||||
| 376 | 0 | queue_list->count++; | |||||||||||||
| 377 | |||||||||||||||
| 378 | 0 | ▶ | for(size_t i = 0; i < list_size; i++) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 379 | 0 | ▶ | if(mythread_list[i]) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 380 | 0 | mythread_resume(mythread_list[i], MyTHREAD_OPT_UNDEF); | |||||||||||||
| 381 | |||||||||||||||
| 382 | 0 | return entry; | |||||||||||||
| 383 | } | ||||||||||||||
| 384 | |||||||||||||||
| 385 | 0 | mythread_queue_list_entry_t * mythread_queue_list_entry_delete(mythread_t** mythread_list, size_t list_size, mythread_queue_list_t *queue_list, mythread_queue_list_entry_t *entry, bool destroy_queue) | |||||||||||||
| 386 | { | ||||||||||||||
| 387 | 0 | ▶ | for(size_t i = 0; i < list_size; i++) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 388 | 0 | ▶ | if(mythread_list[i]) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 389 | 0 | mythread_suspend(mythread_list[i]); | |||||||||||||
| 390 | |||||||||||||||
| 391 | 0 | mythread_queue_list_entry_t *next = entry->next; | |||||||||||||
| 392 | 0 | mythread_queue_list_entry_t *prev = entry->prev; | |||||||||||||
| 393 | |||||||||||||||
| 394 | 0 | ▶ | if(prev) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 395 | 0 | prev->next = next; | |||||||||||||
| 396 | |||||||||||||||
| 397 | 0 | ▶ | if(next) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 398 | 0 | next->prev = prev; | |||||||||||||
| 399 | |||||||||||||||
| 400 | 0 | ▶ | if(queue_list->first == entry) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 401 | 0 | queue_list->first = next; | |||||||||||||
| 402 | |||||||||||||||
| 403 | 0 | ▶ | if(queue_list->last == entry) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 404 | 0 | queue_list->last = prev; | |||||||||||||
| 405 | |||||||||||||||
| 406 | 0 | queue_list->count--; | |||||||||||||
| 407 | |||||||||||||||
| 408 | 0 | ▶ | for(size_t i = 0; i < list_size; i++) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 409 | 0 | ▶ | if(mythread_list[i]) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 410 | 0 | mythread_resume(mythread_list[i], MyTHREAD_OPT_UNDEF); | |||||||||||||
| 411 | |||||||||||||||
| 412 | 0 | ▶ | if(destroy_queue && entry->queue) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 413 | 0 | mythread_queue_destroy(entry->queue); | |||||||||||||
| 414 | |||||||||||||||
| 415 | 0 | ▶ | if(entry->thread_param) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 416 | 0 | mycore_free(entry->thread_param); | |||||||||||||
| 417 | |||||||||||||||
| 418 | 0 | mycore_free(entry); | |||||||||||||
| 419 | |||||||||||||||
| 420 | 0 | return NULL; | |||||||||||||
| 421 | } | ||||||||||||||
| 422 | |||||||||||||||
| 423 | 0 | void mythread_queue_list_entry_clean(mythread_queue_list_entry_t *entry) | |||||||||||||
| 424 | { | ||||||||||||||
| 425 | 0 | ▶ | if(entry == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 426 | 0 | return; | |||||||||||||
| 427 | |||||||||||||||
| 428 | 0 | mythread_queue_clean(entry->queue); | |||||||||||||
| 429 | } | ||||||||||||||
| 430 | |||||||||||||||
| 431 | 0 | void mythread_queue_list_entry_wait_for_done(mythread_t* mythread, mythread_queue_list_entry_t *entry) | |||||||||||||
| 432 | { | ||||||||||||||
| 433 | 0 | ▶ | if(entry == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 434 | 0 | return; | |||||||||||||
| 435 | |||||||||||||||
| 436 | 0 | ▶ | for(size_t i = 0; i < entry->thread_param_size; i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 437 | 0 | ▶ | while(entry->thread_param[i].use < entry->queue->nodes_uses) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 438 | 0 | mythread_nanosleep_sleep(mythread->timespec); | |||||||||||||
| 439 | } | ||||||||||||||
| 440 | } | ||||||||||||||
| 441 | |||||||||||||||
| 442 | 0 | bool mythread_queue_list_entry_see_for_done(mythread_queue_list_entry_t *entry) | |||||||||||||
| 443 | { | ||||||||||||||
| 444 | 0 | ▶ | if(entry == NULL) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 445 | 0 | return true; | |||||||||||||
| 446 | |||||||||||||||
| 447 | 0 | ▶ | for(size_t i = 0; i < entry->thread_param_size; i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 448 | 0 | ▶ | if(entry->thread_param[i].use < entry->queue->nodes_uses) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 449 | 0 | return false; | |||||||||||||
| 450 | } | ||||||||||||||
| 451 | |||||||||||||||
| 452 | 0 | return true; | |||||||||||||
| 453 | } | ||||||||||||||
| 454 | |||||||||||||||
| 455 | 0 | void mythread_queue_list_entry_make_batch(mythread_t* mythread, mythread_queue_list_entry_t* entry) | |||||||||||||
| 456 | { | ||||||||||||||
| 457 | 0 | ▶ | if(entry == NULL || mythread == NULL) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 458 | 0 | return; | |||||||||||||
| 459 | |||||||||||||||
| 460 | 0 | size_t i = 0; | |||||||||||||
| 461 | 0 | ▶ | for(size_t from = mythread->id_increase; from <= mythread->entries_length; from++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 462 | 0 | entry->thread_param[from].use = i; | |||||||||||||
| 463 | 0 | i++; | |||||||||||||
| 464 | } | ||||||||||||||
| 465 | } | ||||||||||||||
| 466 | |||||||||||||||
| 467 | 0 | void mythread_queue_list_entry_make_stream(mythread_t* mythread, mythread_queue_list_entry_t* entry) | |||||||||||||
| 468 | { | ||||||||||||||
| 469 | 0 | ▶ | if(entry == NULL || mythread == NULL) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 470 | 0 | return; | |||||||||||||
| 471 | |||||||||||||||
| 472 | 0 | ▶ | for(size_t from = mythread->id_increase; from <= mythread->entries_length; from++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 473 | 0 | ▶ | if (from < entry->thread_param_size) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 474 | 0 | entry->thread_param[from].use = 0; | |||||||||||||
| 475 | } | ||||||||||||||
| 476 | } | ||||||||||||||
| 477 | |||||||||||||||
| 478 | /* | ||||||||||||||
| 479 | * Thread Process Functions | ||||||||||||||
| 480 | */ | ||||||||||||||
| 481 | 0 | bool mythread_function_see_opt(mythread_context_t *ctx, volatile mythread_thread_opt_t opt, mythread_id_t thread_id, size_t done_count, void* timeout) | |||||||||||||
| 482 | { | ||||||||||||||
| 483 | 0 | mythread_t *mythread = ctx->mythread; | |||||||||||||
| 484 | 0 | mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context; | |||||||||||||
| 485 | |||||||||||||||
| 486 | 0 | ▶ | if(done_count != queue_list->count) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 487 | 0 | return false; | |||||||||||||
| 488 | |||||||||||||||
| 489 | 0 | ▶ | if(opt & MyTHREAD_OPT_STOP) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 490 | { | ||||||||||||||
| 491 | 0 | ▶ | if(mythread_queue_list_see_for_done_by_thread(mythread, queue_list, thread_id)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 492 | { | ||||||||||||||
| 493 | 0 | ctx->opt = MyTHREAD_OPT_STOP; | |||||||||||||
| 494 | 0 | mythread_mutex_wait(mythread, ctx->mutex); | |||||||||||||
| 495 | 0 | ctx->opt = MyTHREAD_OPT_UNDEF; | |||||||||||||
| 496 | |||||||||||||||
| 497 | 0 | return false; | |||||||||||||
| 498 | } | ||||||||||||||
| 499 | } | ||||||||||||||
| 500 | 0 | ▶ | else if(opt & MyTHREAD_OPT_QUIT) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 501 | { | ||||||||||||||
| 502 | 0 | ▶ | if(mythread_queue_list_see_for_done_by_thread(mythread, queue_list, thread_id)) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 503 | { | ||||||||||||||
| 504 | 0 | mythread_mutex_close(mythread, ctx->mutex); | |||||||||||||
| 505 | 0 | mythread_nanosleep_destroy(ctx->timespec); | |||||||||||||
| 506 | |||||||||||||||
| 507 | 0 | ctx->opt = MyTHREAD_OPT_QUIT; | |||||||||||||
| 508 | 0 | return true; | |||||||||||||
| 509 | } | ||||||||||||||
| 510 | } | ||||||||||||||
| 511 | |||||||||||||||
| 512 | 0 | mythread_nanosleep_sleep(timeout); | |||||||||||||
| 513 | |||||||||||||||
| 514 | 0 | return false; | |||||||||||||
| 515 | } | ||||||||||||||
| 516 | |||||||||||||||
| 517 | 0 | void * mythread_function_queue_batch(void *arg) | |||||||||||||
| 518 | { | ||||||||||||||
| 519 | 0 | mythread_context_t *ctx = (mythread_context_t*)arg; | |||||||||||||
| 520 | 0 | mythread_t *mythread = ctx->mythread; | |||||||||||||
| 521 | 0 | mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context; | |||||||||||||
| 522 | 0 | mythread_id_t thread_id = myhread_increase_id_by_entry_id(mythread, ctx->id); | |||||||||||||
| 523 | |||||||||||||||
| 524 | 0 | mythread_mutex_wait(mythread, ctx->mutex); | |||||||||||||
| 525 | |||||||||||||||
| 526 | 0 | do { | |||||||||||||
| 527 | 0 | ▶ | if(mythread->opt & MyTHREAD_OPT_WAIT) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 528 | 0 | ctx->opt = MyTHREAD_OPT_WAIT; | |||||||||||||
| 529 | |||||||||||||||
| 530 | 0 | ▶ | while (mythread->opt & MyTHREAD_OPT_WAIT) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 531 | 0 | mythread_nanosleep_sleep(ctx->timespec); | |||||||||||||
| 532 | |||||||||||||||
| 533 | 0 | ctx->opt = MyTHREAD_OPT_UNDEF; | |||||||||||||
| 534 | } | ||||||||||||||
| 535 | |||||||||||||||
| 536 | 0 | mythread_queue_list_entry_t *entry = queue_list->first; | |||||||||||||
| 537 | 0 | size_t done_count = 0; | |||||||||||||
| 538 | |||||||||||||||
| 539 | 0 | ▶ | while(entry) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 540 | { | ||||||||||||||
| 541 | 0 | mythread_queue_thread_param_t *thread_param = &entry->thread_param[ thread_id ]; | |||||||||||||
| 542 | |||||||||||||||
| 543 | 0 | ▶ | if(thread_param->use < entry->queue->nodes_uses) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 544 | { | ||||||||||||||
| 545 | 0 | size_t pos = thread_param->use / entry->queue->nodes_size; | |||||||||||||
| 546 | 0 | size_t len = thread_param->use % entry->queue->nodes_size; | |||||||||||||
| 547 | |||||||||||||||
| 548 | 0 | mythread_queue_node_t *qnode = &entry->queue->nodes[pos][len]; | |||||||||||||
| 549 | |||||||||||||||
| 550 | //if((qnode->tree->flags & MyCORE_TREE_FLAGS_SINGLE_MODE) == 0) | ||||||||||||||
| 551 | 0 | ctx->func(ctx->id, (void*)qnode); | |||||||||||||
| 552 | |||||||||||||||
| 553 | 0 | thread_param->use += mythread->entries_length; | |||||||||||||
| 554 | } | ||||||||||||||
| 555 | else | ||||||||||||||
| 556 | 0 | done_count++; | |||||||||||||
| 557 | |||||||||||||||
| 558 | 0 | entry = entry->next; | |||||||||||||
| 559 | } | ||||||||||||||
| 560 | |||||||||||||||
| 561 | 0 | if(done_count == queue_list->count && | |||||||||||||
| 562 | 0 | mythread_function_see_opt(ctx, mythread->opt, thread_id, done_count, ctx->timespec)) | |||||||||||||
| 563 | { | ||||||||||||||
| 564 | 0 | break; | |||||||||||||
| 565 | } | ||||||||||||||
| 566 | } | ||||||||||||||
| 567 | while (1); | ||||||||||||||
| 568 | |||||||||||||||
| 569 | 0 | return NULL; | |||||||||||||
| 570 | } | ||||||||||||||
| 571 | |||||||||||||||
| 572 | 0 | void * mythread_function_queue_stream(void *arg) | |||||||||||||
| 573 | { | ||||||||||||||
| 574 | 0 | mythread_context_t *ctx = (mythread_context_t*)arg; | |||||||||||||
| 575 | 0 | mythread_t * mythread = ctx->mythread; | |||||||||||||
| 576 | 0 | mythread_queue_list_t *queue_list = (mythread_queue_list_t*)mythread->context; | |||||||||||||
| 577 | 0 | mythread_id_t thread_id = myhread_increase_id_by_entry_id(mythread, ctx->id); | |||||||||||||
| 578 | |||||||||||||||
| 579 | 0 | mythread_mutex_wait(mythread, ctx->mutex); | |||||||||||||
| 580 | |||||||||||||||
| 581 | 0 | do { | |||||||||||||
| 582 | 0 | ▶ | if(mythread->opt & MyTHREAD_OPT_WAIT) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 583 | 0 | ctx->opt = MyTHREAD_OPT_WAIT; | |||||||||||||
| 584 | |||||||||||||||
| 585 | 0 | ▶ | while (mythread->opt & MyTHREAD_OPT_WAIT) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 586 | 0 | mythread_nanosleep_sleep(ctx->timespec); | |||||||||||||
| 587 | } | ||||||||||||||
| 588 | |||||||||||||||
| 589 | 0 | ctx->opt = MyTHREAD_OPT_UNDEF; | |||||||||||||
| 590 | } | ||||||||||||||
| 591 | |||||||||||||||
| 592 | 0 | mythread_queue_list_entry_t *entry = queue_list->first; | |||||||||||||
| 593 | 0 | size_t done_count = 0; | |||||||||||||
| 594 | |||||||||||||||
| 595 | 0 | ▶ | while(entry) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 596 | { | ||||||||||||||
| 597 | 0 | mythread_queue_thread_param_t *thread_param = &entry->thread_param[ thread_id ]; | |||||||||||||
| 598 | |||||||||||||||
| 599 | 0 | ▶ | if(thread_param->use < entry->queue->nodes_uses) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 600 | { | ||||||||||||||
| 601 | 0 | size_t pos = thread_param->use / entry->queue->nodes_size; | |||||||||||||
| 602 | 0 | size_t len = thread_param->use % entry->queue->nodes_size; | |||||||||||||
| 603 | |||||||||||||||
| 604 | 0 | mythread_queue_node_t *qnode = &entry->queue->nodes[pos][len]; | |||||||||||||
| 605 | |||||||||||||||
| 606 | //if((qnode->tree->flags & MyCORE_TREE_FLAGS_SINGLE_MODE) == 0) | ||||||||||||||
| 607 | 0 | ctx->func(ctx->id, (void*)qnode); | |||||||||||||
| 608 | |||||||||||||||
| 609 | 0 | thread_param->use++; | |||||||||||||
| 610 | } | ||||||||||||||
| 611 | else | ||||||||||||||
| 612 | 0 | done_count++; | |||||||||||||
| 613 | |||||||||||||||
| 614 | 0 | entry = entry->next; | |||||||||||||
| 615 | } | ||||||||||||||
| 616 | |||||||||||||||
| 617 | 0 | if(done_count == queue_list->count && | |||||||||||||
| 618 | 0 | mythread_function_see_opt(ctx, mythread->opt, thread_id, done_count, ctx->timespec)) | |||||||||||||
| 619 | { | ||||||||||||||
| 620 | 0 | break; | |||||||||||||
| 621 | } | ||||||||||||||
| 622 | } | ||||||||||||||
| 623 | while(1); | ||||||||||||||
| 624 | |||||||||||||||
| 625 | 0 | return NULL; | |||||||||||||
| 626 | } | ||||||||||||||
| 627 | |||||||||||||||
| 628 | 0 | void * mythread_function(void *arg) | |||||||||||||
| 629 | { | ||||||||||||||
| 630 | 0 | mythread_context_t *ctx = (mythread_context_t*)arg; | |||||||||||||
| 631 | 0 | mythread_t * mythread = ctx->mythread; | |||||||||||||
| 632 | |||||||||||||||
| 633 | 0 | mythread_mutex_wait(mythread, ctx->mutex); | |||||||||||||
| 634 | |||||||||||||||
| 635 | do { | ||||||||||||||
| 636 | 0 | ctx->func(ctx->id, ctx); | |||||||||||||
| 637 | |||||||||||||||
| 638 | 0 | ctx->opt |= MyTHREAD_OPT_DONE; | |||||||||||||
| 639 | |||||||||||||||
| 640 | 0 | ▶ | if(ctx->opt & MyTHREAD_OPT_WAIT) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 641 | 0 | ▶ | while (ctx->opt & MyTHREAD_OPT_WAIT) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 642 | 0 | mythread_nanosleep_sleep(ctx->timespec); | |||||||||||||
| 643 | } | ||||||||||||||
| 644 | } | ||||||||||||||
| 645 | else { | ||||||||||||||
| 646 | 0 | ctx->opt |= MyTHREAD_OPT_STOP; | |||||||||||||
| 647 | 0 | mythread_mutex_wait(mythread, ctx->mutex); | |||||||||||||
| 648 | } | ||||||||||||||
| 649 | |||||||||||||||
| 650 | 0 | ▶ | if(mythread->opt & MyTHREAD_OPT_QUIT || ctx->opt & MyTHREAD_OPT_QUIT) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 651 | { | ||||||||||||||
| 652 | 0 | mythread_mutex_close(mythread, ctx->mutex); | |||||||||||||
| 653 | 0 | mythread_nanosleep_destroy(ctx->timespec); | |||||||||||||
| 654 | |||||||||||||||
| 655 | 0 | ctx->opt = MyTHREAD_OPT_QUIT; | |||||||||||||
| 656 | 0 | break; | |||||||||||||
| 657 | } | ||||||||||||||
| 658 | |||||||||||||||
| 659 | 0 | ctx->opt = MyTHREAD_OPT_UNDEF; | |||||||||||||
| 660 | } | ||||||||||||||
| 661 | while(1); | ||||||||||||||
| 662 | |||||||||||||||
| 663 | 0 | return NULL; | |||||||||||||
| 664 | } | ||||||||||||||
| 665 | |||||||||||||||
| 666 | #endif | ||||||||||||||