summaryrefslogtreecommitdiff
path: root/src/libunixonacid/kolbak_enqueue.c
blob: 0838e992d33d7dcf887cdd9053886b8c76cb7dc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* ISC license. */

#include <sys/types.h>
#include <errno.h>
#include <skalibs/kolbak.h>
#include <skalibs/unixmessage.h>

int kolbak_enqueue (kolbak_queue_t *q, unixmessage_handler_func_t *f, void *data)
{
  size_t newtail = (q->tail + 1) % q->n ;
  if (newtail == q->head) return (errno = ENOBUFS, 0) ;
  q->x[q->tail].f = f ;
  q->x[q->tail].data = data ;
  q->tail = newtail ;
  return 1 ;
}