XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
xwcq.c
浏览该文件的文档.
1
13#include <string.h>
14#include <xwos/standard.h>
15#include <xwos/lib/object.h>
16#include <xwos/lib/bclst.h>
18#include <xwos/osal/sync/sem.h>
19#include <xwmd/isc/xwcq/mif.h>
20
26static __xwmd_code
27void xwcq_construct(struct xwcq * cq, xwu8_t * mem)
28{
30 cq->slotsize = 0;
31 cq->slotnum = 0;
32 cq->rear = 0;
33 cq->front = 0;
34 cq->q = mem;
35}
36
41static __xwmd_code
42void xwcq_destruct(struct xwcq * cq)
43{
45}
46
52static __xwmd_code
54{
55 struct xwcq * cq;
56
57 cq = xwcc_derof(obj, struct xwcq, xwobj);
58 xwos_sem_fini(&cq->sem);
59 xwcq_destruct(cq);
60 return XWOK;
61}
62
71static __xwmd_code
73 xwobj_gc_f gcfunc)
74{
75 xwer_t rc;
76
77 rc = xwos_object_activate(&cq->xwobj, gcfunc);
78 if (rc < 0) {
79 goto err_xwobj_activate;
80 }
81 xwos_splk_init(&cq->lock);
83 cq->slotsize = slotsize;
84 cq->slotnum = slotnum;
85 cq->rear = 0;
86 cq->front = 0;
87 return XWOK;
88
89err_xwobj_activate:
90 return rc;
91}
92
95{
96 XWOS_VALIDATE((cq), "nullptr", -EFAULT);
97 XWOS_VALIDATE((mem), "nullptr", -EFAULT);
98 XWOS_VALIDATE((slotsize > 0), "zero-size", -ESIZE);
99 XWOS_VALIDATE((slotnum > 0), "zero-num", -ESIZE);
100 XWOS_VALIDATE(!(slotsize & XWMM_UNALIGNED_MASK), "size-not-aligned", -EALIGN);
101
102 xwcq_construct(cq, mem);
104}
105
108{
109 XWOS_VALIDATE((cq), "nullptr", -EFAULT);
110
111 return xwcq_put(cq);
112}
113
115{
116 xwsq_t tik;
117
118 if (NULL != cq) {
119 tik = cq->xwobj.tik;
120 } else {
121 tik = 0;
122 }
123 return tik;
124}
125
128{
129 return xwos_object_acquire(&cqd.cq->xwobj, cqd.tik);
130}
131
134{
135 return xwos_object_release(&cqd.cq->xwobj, cqd.tik);
136}
137
140{
141 XWOS_VALIDATE((cq), "nullptr", -EFAULT);
142 return xwos_object_grab(&cq->xwobj);
143}
144
146xwer_t xwcq_put(struct xwcq * cq)
147{
148 XWOS_VALIDATE((cq), "nullptr", -EFAULT);
149 return xwos_object_put(&cq->xwobj);
150}
151
153xwer_t xwcq_eq(struct xwcq * cq, const xwu8_t * data, xwsz_t * size)
154{
155 xwreg_t cpuirq;
156 xwsz_t eqsize;
157
158 XWOS_VALIDATE((cq), "nullptr", -EFAULT);
159 XWOS_VALIDATE((data), "nullptr", -EFAULT);
160 XWOS_VALIDATE((size), "nullptr", -EFAULT);
161
162 eqsize = *size;
163 eqsize = (eqsize > cq->slotsize) ? cq->slotsize : eqsize;
164 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
165 // cppcheck-suppress [misra-c2012-17.7]
166 memcpy(&cq->q[(xwsz_t)cq->rear * cq->slotsize], data, eqsize);
167 cq->rear++;
168 if (cq->rear >= (xwssq_t)cq->slotnum) {
169 cq->rear = 0;
170 }
171 if (cq->rear == cq->front) {
172 /* Queue is overflow. Discard the oldest data */
173 cq->front++;
174 if (cq->front >= (xwssq_t)cq->slotnum) {
175 cq->front = 0;
176 }
177 }
178 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
179 xwos_sem_post(&cq->sem);
180 *size = eqsize;
181 return XWOK;
182}
183
185xwer_t xwcq_jq(struct xwcq * cq, const xwu8_t * data, xwsz_t * size)
186{
187 xwreg_t cpuirq;
188 xwsz_t eqsize;
189
190 XWOS_VALIDATE((cq), "nullptr", -EFAULT);
191 XWOS_VALIDATE((data), "nullptr", -EFAULT);
192 XWOS_VALIDATE((size), "nullptr", -EFAULT);
193
194 eqsize = *size;
195 eqsize = (eqsize > cq->slotsize) ? cq->slotsize : eqsize;
196 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
197 cq->front--;
198 if (cq->front < 0) {
199 cq->front = (xwssz_t)cq->slotnum - 1;
200 }
201 if (cq->front == cq->rear) {
202 /* Queue is overflow. Discard the newest data */
203 cq->rear--;
204 if (cq->rear < 0) {
205 cq->rear = (xwssz_t)cq->slotnum;
206 }
207 }
208 // cppcheck-suppress [misra-c2012-17.7]
209 memcpy(&cq->q[(xwsz_t)cq->front * cq->slotsize], data, eqsize);
210 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
211 xwos_sem_post(&cq->sem);
212 *size = eqsize;
213 return XWOK;
214}
215
217xwer_t xwcq_dq(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
218{
219 return xwcq_dq_to(cq, buf, size, XWTM_MAX);
220}
221
223xwer_t xwcq_dq_to(struct xwcq * cq, xwu8_t * buf, xwsz_t * size, xwtm_t to)
224{
225 xwreg_t cpuirq;
226 xwsz_t bufsz;
227 xwsz_t cpsz;
228 xwer_t rc;
229
230 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
231 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
232 XWOS_VALIDATE(size, "nullptr", -EFAULT);
233
234 bufsz = *size;
235 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
236 rc = xwos_sem_wait_to(&cq->sem, to);
237 if (rc < 0) {
238 goto err_sem_wait_to;
239 }
240 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
241 // cppcheck-suppress [misra-c2012-17.7]
242 memcpy(buf, &cq->q[(xwsz_t)cq->front * cq->slotsize], cpsz);
243 cq->front++;
244 if (cq->front >= (xwssz_t)cq->slotnum) {
245 cq->front = 0;
246 }
247 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
248 *size = cpsz;
249 return XWOK;
250
251err_sem_wait_to:
252 return rc;
253}
254
256xwer_t xwcq_dq_unintr(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
257{
258 xwsz_t bufsz;
259 xwsz_t cpsz;
260 xwreg_t cpuirq;
261 xwer_t rc;
262
263 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
264 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
265 XWOS_VALIDATE(size, "nullptr", -EFAULT);
266
267 bufsz = *size;
268 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
269 rc = xwos_sem_wait_unintr(&cq->sem);
270 if (rc < 0) {
271 goto err_sem_wait_unintr;
272 }
273 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
274 // cppcheck-suppress [misra-c2012-17.7]
275 memcpy(buf, &cq->q[(xwsz_t)cq->front * cq->slotsize], cpsz);
276 cq->front++;
277 if (cq->front >= (xwssz_t)cq->slotnum) {
278 cq->front = 0;
279 }
280 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
281 *size = cpsz;
282 return XWOK;
283
284err_sem_wait_unintr:
285 return rc;
286}
287
289xwer_t xwcq_trydq(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
290{
291 xwsz_t bufsz;
292 xwsz_t cpsz;
293 xwreg_t cpuirq;
294 xwer_t rc;
295
296 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
297 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
298 XWOS_VALIDATE(size, "nullptr", -EFAULT);
299
300 bufsz = *size;
301 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
302 rc = xwos_sem_trywait(&cq->sem);
303 if (rc < 0) {
304 goto err_sem_trywait;
305 }
306 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
307 // cppcheck-suppress [misra-c2012-17.7]
308 memcpy(buf, &cq->q[(xwsz_t)cq->front * cq->slotsize], cpsz);
309 cq->front++;
310 if (cq->front >= (xwssz_t)cq->slotnum) {
311 cq->front = 0;
312 }
313 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
314 *size = cpsz;
315 return XWOK;
316
317err_sem_trywait:
318 return rc;
319}
320
322xwer_t xwcq_rq(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
323{
324 return xwcq_rq_to(cq, buf, size, XWTM_MAX);
325}
326
328xwer_t xwcq_rq_to(struct xwcq * cq, xwu8_t * buf, xwsz_t * size, xwtm_t to)
329{
330 xwreg_t cpuirq;
331 xwsz_t bufsz;
332 xwsz_t cpsz;
333 xwer_t rc;
334
335 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
336 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
337 XWOS_VALIDATE(size, "nullptr", -EFAULT);
338
339 bufsz = *size;
340 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
341 rc = xwos_sem_wait_to(&cq->sem, to);
342 if (rc < 0) {
343 goto err_sem_wait_to;
344 }
345 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
346 cq->rear--;
347 if (cq->rear < 0) {
348 cq->rear = (xwssz_t)cq->slotnum - 1;
349 }
350 // cppcheck-suppress [misra-c2012-17.7]
351 memcpy(buf, &cq->q[(xwsz_t)cq->rear * cq->slotsize], cpsz);
352 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
353 *size = cpsz;
354 return XWOK;
355
356err_sem_wait_to:
357 return rc;
358}
359
361xwer_t xwcq_rq_unintr(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
362{
363 xwreg_t cpuirq;
364 xwsz_t bufsz;
365 xwsz_t cpsz;
366 xwer_t rc;
367
368 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
369 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
370 XWOS_VALIDATE(size, "nullptr", -EFAULT);
371
372 bufsz = *size;
373 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
374 rc = xwos_sem_wait_unintr(&cq->sem);
375 if (rc < 0) {
376 goto err_sem_wait_unintr;
377 }
378 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
379 cq->rear--;
380 if (cq->rear < 0) {
381 cq->rear = (xwssz_t)cq->slotnum - 1;
382 }
383 // cppcheck-suppress [misra-c2012-17.7]
384 memcpy(buf, &cq->q[(xwsz_t)cq->rear * cq->slotsize], cpsz);
385 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
386 *size = cpsz;
387 return XWOK;
388
389err_sem_wait_unintr:
390 return rc;
391}
392
394xwer_t xwcq_tryrq(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
395{
396 xwreg_t cpuirq;
397 xwsz_t bufsz;
398 xwsz_t cpsz;
399 xwer_t rc;
400
401 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
402 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
403 XWOS_VALIDATE(size, "nullptr", -EFAULT);
404
405 bufsz = *size;
406 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
407 rc = xwos_sem_trywait(&cq->sem);
408 if (rc < 0) {
409 goto err_sem_trywait;
410 }
411 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
412 cq->rear--;
413 if (cq->rear < 0) {
414 cq->rear = (xwssz_t)cq->slotnum - 1;
415 }
416 // cppcheck-suppress [misra-c2012-17.7]
417 memcpy(buf, &cq->q[(xwsz_t)cq->rear * cq->slotsize], cpsz);
418 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
419 *size = cpsz;
420 return XWOK;
421
422err_sem_trywait:
423 return rc;
424}
425
427xwer_t xwcq_pfq(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
428{
429 return xwcq_pfq_to(cq, buf, size, XWTM_MAX);
430}
431
433xwer_t xwcq_pfq_to(struct xwcq * cq, xwu8_t * buf, xwsz_t * size, xwtm_t to)
434{
435 xwreg_t cpuirq;
436 xwsz_t bufsz;
437 xwsz_t cpsz;
438 xwer_t rc;
439
440 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
441 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
442 XWOS_VALIDATE(size, "nullptr", -EFAULT);
443
444 bufsz = *size;
445 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
446 rc = xwos_sem_wait_to(&cq->sem, to);
447 if (rc < 0) {
448 goto err_sem_wait_to;
449 }
450 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
451 // cppcheck-suppress [misra-c2012-17.7]
452 memcpy(buf, &cq->q[(xwsz_t)cq->front * cq->slotsize], cpsz);
453 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
454 xwos_sem_post(&cq->sem);
455 *size = cpsz;
456 return XWOK;
457
458err_sem_wait_to:
459 return rc;
460}
461
463xwer_t xwcq_pfq_unintr(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
464{
465 xwreg_t cpuirq;
466 xwsz_t bufsz;
467 xwsz_t cpsz;
468 xwer_t rc;
469
470 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
471 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
472 XWOS_VALIDATE(size, "nullptr", -EFAULT);
473
474 bufsz = *size;
475 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
476 rc = xwos_sem_wait_unintr(&cq->sem);
477 if (rc < 0) {
478 goto err_sem_wait_unintr;
479 }
480 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
481 // cppcheck-suppress [misra-c2012-17.7]
482 memcpy(buf, &cq->q[(xwsz_t)cq->front * cq->slotsize], cpsz);
483 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
484 xwos_sem_post(&cq->sem);
485 *size = cpsz;
486 return XWOK;
487
488err_sem_wait_unintr:
489 return rc;
490}
491
493xwer_t xwcq_trypfq(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
494{
495 xwreg_t cpuirq;
496 xwsz_t bufsz;
497 xwsz_t cpsz;
498 xwer_t rc;
499
500 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
501 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
502 XWOS_VALIDATE(size, "nullptr", -EFAULT);
503
504 bufsz = *size;
505 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
506 rc = xwos_sem_trywait(&cq->sem);
507 if (rc < 0) {
508 goto err_sem_trywait;
509 }
510 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
511 // cppcheck-suppress [misra-c2012-17.7]
512 memcpy(buf, &cq->q[(xwsz_t)cq->front * cq->slotsize], cpsz);
513 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
514 xwos_sem_post(&cq->sem);
515 *size = cpsz;
516 return XWOK;
517
518err_sem_trywait:
519 return rc;
520}
521
523xwer_t xwcq_prq(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
524{
525 return xwcq_prq_to(cq, buf, size, XWTM_MAX);
526}
527
529xwer_t xwcq_prq_to(struct xwcq * cq, xwu8_t * buf, xwsz_t * size, xwtm_t to)
530{
531 xwreg_t cpuirq;
533 xwsz_t bufsz;
534 xwsz_t cpsz;
535 xwer_t rc;
536
537 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
538 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
539 XWOS_VALIDATE(size, "nullptr", -EFAULT);
540
541 bufsz = *size;
542 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
543 rc = xwos_sem_wait_to(&cq->sem, to);
544 if (rc < 0) {
545 goto err_sem_wait_to;
546 }
547 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
548 rear = cq->rear - 1;
549 if (rear < 0) {
550 rear = (xwssz_t)cq->slotnum - 1;
551 }
552 // cppcheck-suppress [misra-c2012-17.7]
553 memcpy(buf, &cq->q[(xwsz_t)rear * cq->slotsize], cpsz);
554 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
555 xwos_sem_post(&cq->sem);
556 *size = cpsz;
557 return XWOK;
558
559err_sem_wait_to:
560 return rc;
561}
562
564xwer_t xwcq_prq_unintr(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
565{
566 xwreg_t cpuirq;
568 xwsz_t bufsz;
569 xwsz_t cpsz;
570 xwer_t rc;
571
572 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
573 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
574 XWOS_VALIDATE(size, "nullptr", -EFAULT);
575
576 bufsz = *size;
577 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
578 rc = xwos_sem_wait_unintr(&cq->sem);
579 if (rc < 0) {
580 goto err_sem_wait_unintr;
581 }
582 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
583 rear = cq->rear - 1;
584 if (rear < 0) {
585 rear = (xwssz_t)cq->slotnum - 1;
586 }
587 // cppcheck-suppress [misra-c2012-17.7]
588 memcpy(buf, &cq->q[(xwsz_t)rear * cq->slotsize], cpsz);
589 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
590 xwos_sem_post(&cq->sem);
591 *size = cpsz;
592 return XWOK;
593
594err_sem_wait_unintr:
595 return rc;
596}
597
599xwer_t xwcq_tryprq(struct xwcq * cq, xwu8_t * buf, xwsz_t * size)
600{
601 xwreg_t cpuirq;
603 xwsz_t bufsz;
604 xwsz_t cpsz;
605 xwer_t rc;
606
607 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
608 XWOS_VALIDATE(buf, "nullptr", -EFAULT);
609 XWOS_VALIDATE(size, "nullptr", -EFAULT);
610
611 bufsz = *size;
612 cpsz = (bufsz > cq->slotsize) ? cq->slotsize : bufsz;
613 rc = xwos_sem_trywait(&cq->sem);
614 if (rc < 0) {
615 goto err_sem_trywait;
616 }
617 xwos_splk_lock_cpuirqsv(&cq->lock, &cpuirq);
618 rear = cq->rear - 1;
619 if (rear < 0) {
620 rear = (xwssz_t)cq->slotnum - 1;
621 }
622 // cppcheck-suppress [misra-c2012-17.7]
623 memcpy(buf, &cq->q[(xwsz_t)rear * cq->slotsize], cpsz);
624 xwos_splk_unlock_cpuirqrs(&cq->lock, cpuirq);
625 xwos_sem_post(&cq->sem);
626 *size = cpsz;
627 return XWOK;
628
629err_sem_trywait:
630 return rc;
631}
632
634{
635 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
636
637 xwos_sem_freeze(&cq->sem);
638 cq->rear = 0;
639 cq->front = 0;
640 xwos_sem_thaw(&cq->sem);
641 return XWOK;
642}
643
644xwer_t xwcq_get_capacity(struct xwcq * cq, xwsz_t * capbuf)
645{
646 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
647 XWOS_VALIDATE(capbuf, "nullptr", -EFAULT);
648
649 *capbuf = cq->slotnum;
650 return XWOK;
651}
652
653xwer_t xwcq_get_size(struct xwcq * cq, xwsz_t * szbuf)
654{
655 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
656 XWOS_VALIDATE(szbuf, "nullptr", -EFAULT);
657
658 *szbuf = cq->slotsize;
659 return XWOK;
660}
661
663{
664 XWOS_VALIDATE(cq, "nullptr", -EFAULT);
665 XWOS_VALIDATE(avbbuf, "nullptr", -EFAULT);
666
667 if (cq->rear >= cq->front) {
668 *avbbuf = (xwsz_t)cq->rear - (xwsz_t)cq->front;
669 } else {
670 *avbbuf = cq->slotnum - (xwsz_t)cq->front + (xwsz_t)cq->rear;
671 }
672 return XWOK;
673}
674
675xwer_t xwcq_bind(struct xwcq * cq, struct xwos_sel * sel, xwsq_t pos)
676{
677 xwer_t rc;
678
679 rc = xwcq_grab(cq);
680 if (rc < 0) {
681 goto err_cq_grab;
682 }
683 rc = xwos_sem_bind(&cq->sem, sel, pos);
684
685err_cq_grab:
686 return rc;
687}
688
689xwer_t xwcq_unbind(struct xwcq * cq, struct xwos_sel * sel)
690{
691 xwer_t rc;
692
693 rc = xwos_sem_unbind(&cq->sem, sel);
694 if (rc < 0) {
695 goto err_unbind;
696 }
697 rc = xwcq_put(cq);
698 XWOS_BUG_ON(rc < 0);
699 return XWOK;
700
701err_unbind:
702 return rc;
703}
XWOS通用库:双循环链表
xwer_t xwcq_get_availability(struct xwcq *cq, xwsz_t *avbbuf)
XWCQ API: 获取循环队列中有效数据槽的数量
Definition xwcq.c:662
xwer_t xwcq_init(struct xwcq *cq, xwsz_t slotsize, xwsz_t slotnum, xwu8_t *mem)
XWCQ API:初始化循环队列
Definition xwcq.c:94
xwer_t xwcq_dq_to(struct xwcq *cq, xwu8_t *buf, xwsz_t *size, xwtm_t to)
XWCQ API: 限时等待从循环队列的 首端 接收数据 (离队,DeQueue)
Definition xwcq.c:223
xwer_t xwcq_get_capacity(struct xwcq *cq, xwsz_t *capbuf)
XWCQ API: 获取循环队列的容量
Definition xwcq.c:644
xwer_t xwcq_bind(struct xwcq *cq, struct xwos_sel *sel, xwsq_t pos)
XWOS API:绑定循环队列对象到信号选择器
Definition xwcq.c:675
xwsq_t xwcq_get_tik(struct xwcq *cq)
XWCQ API:获取循环队列对象的标签
Definition xwcq.c:114
xwer_t xwcq_prq(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 等待从循环队列 尾端 拷贝数据 (Peek at the Rear of Queue)
Definition xwcq.c:523
xwer_t xwcq_pfq_unintr(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 等待从循环队列 头端 拷贝数据 (Peek at the Front of Queue), 并且等待不可被中断
Definition xwcq.c:463
xwer_t xwcq_tryrq(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 尝试从循环队列的 尾端 接收数据 (反向离队,Reversely deQueue)
Definition xwcq.c:394
xwer_t xwcq_release(xwcq_d cqd)
XWCQ API:检查循环队列对象的标签并增加引用计数
Definition xwcq.c:133
xwer_t xwcq_trydq(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 尝试从循环队列的 首端 接收数据 (离队,DeQueue)
Definition xwcq.c:289
xwer_t xwcq_put(struct xwcq *cq)
XWCQ API:减少循环队列对象的引用计数
Definition xwcq.c:146
xwer_t xwcq_pfq_to(struct xwcq *cq, xwu8_t *buf, xwsz_t *size, xwtm_t to)
XWCQ API: 限时等待从循环队列 头端 拷贝数据 (Peek at the Front of Queue)
Definition xwcq.c:433
xwer_t xwcq_dq_unintr(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 等待从循环队列的 首端 接收数据 (离队,DeQueue), 并且等待不可被中断
Definition xwcq.c:256
xwer_t xwcq_prq_to(struct xwcq *cq, xwu8_t *buf, xwsz_t *size, xwtm_t to)
XWCQ API: 限时等待从循环队列 尾端 拷贝数据 (Peek at the Rear of Queue)
Definition xwcq.c:529
xwer_t xwcq_jq(struct xwcq *cq, const xwu8_t *data, xwsz_t *size)
XWCQ API:将数据发送循环队列的 首端 (插队,Jump the Queue)
Definition xwcq.c:185
xwer_t xwcq_rq(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 等待从循环队列的 尾端 接收数据 (反向离队,Reversely deQueue)
Definition xwcq.c:322
xwer_t xwcq_tryprq(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 尝试从循环队列 尾端 拷贝数据 (Peek at the Rear of Queue)
Definition xwcq.c:599
xwer_t xwcq_get_size(struct xwcq *cq, xwsz_t *szbuf)
XWCQ API: 获取循环队列的单个数据槽的大小
Definition xwcq.c:653
xwer_t xwcq_unbind(struct xwcq *cq, struct xwos_sel *sel)
XWOS API:从信号选择器上解绑循环队列对象
Definition xwcq.c:689
xwer_t xwcq_prq_unintr(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 等待从循环队列 尾端 拷贝数据 (Peek at the Rear of Queue), 并且等待不可被中断
Definition xwcq.c:564
xwer_t xwcq_dq(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 等待从循环队列的 首端 接收数据 (离队,DeQueue)
Definition xwcq.c:217
xwer_t xwcq_eq(struct xwcq *cq, const xwu8_t *data, xwsz_t *size)
XWCQ API:将数据发送到循环队列的 尾端 (入队,EnQueue)
Definition xwcq.c:153
xwer_t xwcq_fini(struct xwcq *cq)
XWCQ API:销毁循环队列对象
Definition xwcq.c:107
xwer_t xwcq_grab(struct xwcq *cq)
XWCQ API:增加循环队列对象的引用计数
Definition xwcq.c:139
xwer_t xwcq_rq_unintr(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 等待从循环队列的 尾端 接收数据 (反向离队,Reversely deQueue), 并且等待不可被中断
Definition xwcq.c:361
xwer_t xwcq_flush(struct xwcq *cq)
XWCQ API: 清空循环队列
Definition xwcq.c:633
xwer_t xwcq_acquire(xwcq_d cqd)
XWCQ API:检查循环队列对象的标签并增加引用计数
Definition xwcq.c:127
xwer_t xwcq_rq_to(struct xwcq *cq, xwu8_t *buf, xwsz_t *size, xwtm_t to)
XWCQ API: 限时等待从循环队列的 尾端 接收数据 (反向离队,Reversely deQueue)
Definition xwcq.c:328
xwer_t xwcq_trypfq(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 尝试从循环队列 头端 拷贝数据 (Peek at the Front of Queue)
Definition xwcq.c:493
xwer_t xwcq_pfq(struct xwcq *cq, xwu8_t *buf, xwsz_t *size)
XWCQ API: 等待从循环队列 头端 拷贝数据 (Peek at the Front of Queue)
Definition xwcq.c:427
#define XWMM_UNALIGNED_MASK
Definition common.h:30
#define __xwmd_api
Definition compiler.h:363
#define xwcc_derof(baseptr, derclass, member)
将基类结构体指针转换为派生类结构体指针
Definition compiler.h:501
#define __xwmd_code
Definition compiler.h:359
#define EFAULT
Bad address
Definition errno.h:44
#define EALIGN
Not aligned
Definition errno.h:201
#define XWOK
No error
Definition errno.h:182
#define ESIZE
Size error
Definition errno.h:199
xws64_t xwtm_t
XWOS系统时间 (有符号)
Definition type.h:742
#define XWTM_MAX
xwtm_t 的最大值
Definition type.h:755
signed long xwer_t
Definition type.h:554
#define NULL
Definition type.h:28
unsigned long xwsz_t
Definition type.h:339
uint8_t xwu8_t
Definition type.h:194
unsigned long xwsq_t
Definition type.h:445
signed long xwssq_t
Definition type.h:461
signed long xwssz_t
Definition type.h:355
xwptr_t xwreg_t
Definition type.h:409
xwer_t(* xwobj_gc_f)(struct xwos_object *)
垃圾回收函数指针类型
Definition object.h:42
xwer_t xwos_object_grab(struct xwos_object *obj)
增加对象的引用计数
Definition object.c:297
xwer_t xwos_object_activate(struct xwos_object *obj, xwobj_gc_f gcfunc)
激活一个XWOS对象(将其引用计数初始化位1)
Definition object.c:135
void xwos_object_construct(struct xwos_object *obj)
XWOS对象的构造函数
Definition object.c:107
void xwos_object_destruct(struct xwos_object *obj)
XWOS对象的析构函数
Definition object.c:119
xwer_t xwos_object_release(struct xwos_object *obj, xwsq_t tik)
检查对象的标签并减少引用计数
Definition object.c:265
xwer_t xwos_object_acquire(struct xwos_object *obj, xwsq_t tik)
检查对象的标签并增加引用计数
Definition object.c:206
xwer_t xwos_object_put(struct xwos_object *obj)
减少对象的引用计数
Definition object.c:316
static void xwos_splk_unlock_cpuirqrs(struct xwos_splk *spl, xwreg_t cpuirq)
XWOS API:解锁自旋锁,并恢复本地CPU的中断标志
Definition spinlock.h:224
static void xwos_splk_init(struct xwos_splk *spl)
XWOS API:初始化自旋锁
Definition spinlock.h:89
static void xwos_splk_lock_cpuirqsv(struct xwos_splk *spl, xwreg_t *cpuirq)
XWOS API:上锁自旋锁,保存本地CPU的中断标志并关闭
Definition spinlock.h:192
#define XWOS_VALIDATE(exp, errstr,...)
检查函数参数是否有效
Definition standard.h:76
#define XWOS_BUG_ON(x)
Definition standard.h:57
static xwer_t xwos_sem_trywait(struct xwos_sem *sem)
XWOS API:尝试获取信号量
Definition sem.h:454
static xwer_t xwos_sem_bind(struct xwos_sem *sem, struct xwos_sel *sel, xwsq_t pos)
XWOS API:绑定信号量对象到信号选择器
Definition sem.h:297
static xwer_t xwos_sem_unbind(struct xwos_sem *sem, struct xwos_sel *sel)
XWOS API:从信号选择器上解绑信号量对象
Definition sem.h:314
static xwer_t xwos_sem_wait_unintr(struct xwos_sem *sem)
XWOS API:等待并获取信号量,且等待不可被中断
Definition sem.h:436
static xwer_t xwos_sem_fini(struct xwos_sem *sem)
XWOS API:销毁静态方式初始化的信号量对象
Definition sem.h:140
static xwer_t xwos_sem_freeze(struct xwos_sem *sem)
XWOS API:冻结信号量对象
Definition sem.h:335
static xwer_t xwos_sem_wait_to(struct xwos_sem *sem, xwtm_t to)
XWOS API:限时等待并获取信号量
Definition sem.h:418
static xwer_t xwos_sem_thaw(struct xwos_sem *sem)
XWOS API:解冻信号量对象
Definition sem.h:354
static xwer_t xwos_sem_init(struct xwos_sem *sem, xwssq_t val, xwssq_t max)
XWOS API:静态方式初始化信号量对象
Definition sem.h:125
static xwer_t xwos_sem_post(struct xwos_sem *sem)
XWOS API:发布信号量
Definition sem.h:373
操作系统抽象层:自旋锁
循环队列对象描述符
Definition mif.h:138
struct xwcq * cq
Definition mif.h:139
xwsq_t tik
Definition mif.h:140
循环队列对象
Definition mif.h:124
struct xwos_sem sem
Definition mif.h:128
struct xwos_splk lock
Definition mif.h:129
struct xwos_object xwobj
Definition mif.h:125
xwsz_t slotnum
Definition mif.h:127
xwssz_t front
Definition mif.h:131
xwssz_t rear
Definition mif.h:130
xwu8_t * q
Definition mif.h:132
xwsz_t slotsize
Definition mif.h:126
XWOS对象
Definition object.h:53
xwsq_t tik
Definition object.h:54
XWOS API:信号选择器对象
Definition sel.h:81
操作系统抽象层:信号量
循环队列:模块接口
static xwer_t xwcq_gc(struct xwos_object *obj)
循环队列对象的垃圾回收函数
Definition xwcq.c:53
static void xwcq_destruct(struct xwcq *cq)
循环队列对象的析构函数
Definition xwcq.c:42
static xwer_t xwcq_activate(struct xwcq *cq, xwsz_t slotsize, xwsz_t slotnum, xwobj_gc_f gcfunc)
激活循环队列对象
Definition xwcq.c:72
static void xwcq_construct(struct xwcq *cq, xwu8_t *mem)
循环队列对象的构造函数
Definition xwcq.c:27
XWOS通用库:XWOS的对象
XWOS的标准头文件