Remove bb.c.

This commit is contained in:
NIIBE Yutaka
2017-12-15 15:07:48 +09:00
parent b58dd05c9d
commit f3cc662548
3 changed files with 0 additions and 105 deletions

89
bb.c
View File

@@ -1,89 +0,0 @@
/*
* bb.c - Bounded Buffer
*
* Copyright (C) 2017 Flying Stone Technology
* Author: NIIBE Yutaka <gniibe@fsij.org>
*
* This file is a part of Chopstx, a thread library for embedded.
*
* Chopstx is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Chopstx is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* As additional permission under GNU GPL version 3 section 7, you may
* distribute non-source form of the Program without the copy of the
* GNU GPL normally required by section 4, provided you inform the
* receipents of GNU GPL by a written offer.
*
*/
#include <stdint.h>
#include <stdlib.h>
#include <chopstx.h>
#include <bb.h>
void
bb_init (struct bb *bb, uint32_t max_item)
{
bb->items = 0;
bb->max_items = max_item;
chopstx_cond_init (&bb->cond);
chopstx_mutex_init (&bb->mutex);
}
void
bb_get (struct bb *bb)
{
chopstx_mutex_lock (&bb->mutex);
while (bb->items == 0)
chopstx_cond_wait (&bb->cond, &bb->mutex);
bb->items--;
chopstx_mutex_unlock (&bb->mutex);
}
void
bb_put (struct bb *bb)
{
chopstx_mutex_lock (&bb->mutex);
while (bb->items == bb->max_item)
chopstx_cond_wait (&bb->cond, &bb->mutex);
bb->items++;
chopstx_cond_signal (&bb->cond);
chopstx_mutex_unlock (&bb->mutex);
}
static int
bb_check_empty (void *arg)
{
struct bb *bb = arg;
return bb->items != 0;
}
static int
bb_check_full (void *arg)
{
struct bb *bb = arg;
return bb->items != bb->max_item;
}
void
bb_prepare_poll (struct bb *bb, chopstx_poll_cond_t *p, int full)
{
poll_desc->type = CHOPSTX_POLL_COND;
poll_desc->ready = 0;
poll_desc->cond = &bb->cond;
poll_desc->mutex = &bb->mutex;
poll_desc->check = full? bb_check_full: bb_check_empty;
poll_desc->arg = bb;
}

12
bb.h
View File

@@ -1,12 +0,0 @@
struct bb {
chopstx_mutex_t mutex;
chopstx_cond_t cond;
uint32_t items;
uint32_t max_item;
};
void bb_init (struct bb *bb, uint32_t max_item);
void bb_get (struct bb *bb);
void bb_put (struct bb *bb);
void bb_prepare_poll (struct bb *bb, chopstx_poll_cond_t *p, int full);

View File

@@ -2,10 +2,6 @@
CSRC += $(CHOPSTX)/entry.c $(CHOPSTX)/chopstx.c CSRC += $(CHOPSTX)/entry.c $(CHOPSTX)/chopstx.c
ifneq ($(USE_BB),)
CSRC += $(CHOPSTX)/bb.c
endif
ifneq ($(USE_EVENTFLAG),) ifneq ($(USE_EVENTFLAG),)
CSRC += $(CHOPSTX)/eventflag.c CSRC += $(CHOPSTX)/eventflag.c
endif endif