本文整理汇总了C++中CIRC_SPACE函数的典型用法代码示例。如果您正苦于以下问题:C++ CIRC_SPACE函数的具体用法?C++ CIRC_SPACE怎么用?C++ CIRC_SPACE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CIRC_SPACE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rxrpc_wait_for_tx_window
/*
* wait for space to appear in the transmit/ACK window
* - caller holds the socket locked
*/
static int rxrpc_wait_for_tx_window(struct rxrpc_sock *rx,
struct rxrpc_call *call,
long *timeo)
{
DECLARE_WAITQUEUE(myself, current);
int ret;
_enter(",{%d},%ld",
CIRC_SPACE(call->acks_head, call->acks_tail, call->acks_winsz),
*timeo);
add_wait_queue(&call->tx_waitq, &myself);
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
ret = 0;
if (CIRC_SPACE(call->acks_head, call->acks_tail,
call->acks_winsz) > 0)
break;
if (signal_pending(current)) {
ret = sock_intr_errno(*timeo);
break;
}
release_sock(&rx->sk);
*timeo = schedule_timeout(*timeo);
lock_sock(&rx->sk);
}
remove_wait_queue(&call->tx_waitq, &myself);
set_current_state(TASK_RUNNING);
_leave(" = %d", ret);
return ret;
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:38,代码来源:ar-output.c
示例2: rs_put_char
static int rs_put_char(struct tty_struct *tty, unsigned char ch)
{
struct serial_state *info;
unsigned long flags;
info = tty->driver_data;
if (serial_paranoia_check(info, tty->name, "rs_put_char"))
return 0;
if (!info->xmit.buf)
return 0;
local_irq_save(flags);
if (CIRC_SPACE(info->xmit.head,
info->xmit.tail,
SERIAL_XMIT_SIZE) == 0) {
local_irq_restore(flags);
return 0;
}
info->xmit.buf[info->xmit.head++] = ch;
info->xmit.head &= SERIAL_XMIT_SIZE-1;
local_irq_restore(flags);
return 1;
}
开发者ID:kprog,项目名称:linux,代码行数:26,代码来源:amiserial.c
示例3: ev3_uart_receive_buf
static void ev3_uart_receive_buf(struct tty_struct *tty,
const unsigned char *cp, char *fp, int count)
{
struct ev3_uart_port_data *port = tty->disc_data;
struct circ_buf *cb = &port->circ_buf;
int size;
if (port->closing)
return;
if (count > CIRC_SPACE(cb->head, cb->tail, EV3_UART_BUFFER_SIZE))
return;
size = CIRC_SPACE_TO_END(cb->head, cb->tail, EV3_UART_BUFFER_SIZE);
if (count > size) {
memcpy(cb->buf + cb->head, cp, size);
memcpy(cb->buf, cp + size, count - size);
cb->head = count - size;
} else {
memcpy(cb->buf + cb->head, cp, count);
cb->head += count;
}
schedule_work(&port->rx_data_work);
}
开发者ID:JorgePe,项目名称:lego-linux-drivers,代码行数:25,代码来源:ev3_uart_sensor_ld.c
示例4: main
/********************************************************************************
* Description:
* Input Args:
* Output Args:
* Return Value:
********************************************************************************/
int main (int argc, char **argv)
{
int i, len;
struct circ_buf tx_ring;
char data[LEN];
char buf[LEN];
memset(&tx_ring, 0, sizeof(struct circ_buf));
tx_ring.buf = malloc(CIRC_BUF_SIZE);
if( NULL == tx_ring.buf )
{
printf("Allocate Ring buffer failure.\n");
return -1;
}
memset(data, 0, sizeof(data));
/* Prepare for the data */
for(i=0; i<sizeof(data); i++)
{
data[i] = 30+i;
}
printf("CIRC_SPACE: %d\n", CIRC_SPACE(tx_ring.head, tx_ring.tail, CIRC_BUF_SIZE));
printf("CIRC_SPACE_TO_END: %d\n", CIRC_SPACE_TO_END(tx_ring.head, tx_ring.tail, CIRC_BUF_SIZE));
printf("CIRC_CNT: %d\n", CIRC_CNT(tx_ring.head, tx_ring.tail, CIRC_BUF_SIZE));
printf("CIRC_CNT_TO_END: %d\n", CIRC_CNT_TO_END(tx_ring.head, tx_ring.tail, CIRC_BUF_SIZE));
while(1)
{
produce_item(&tx_ring, data, sizeof(data));
len = consume_item(&tx_ring, buf, sizeof(buf) );
sleep(1);
}
return 0;
} /* ----- End of main() ----- */
开发者ID:jhbsz,项目名称:embedded_project,代码行数:41,代码来源:circ_buf.c
示例5: jr_enqueue
/* -1 --- error, can't enqueue -- no space available */
static int jr_enqueue(uint32_t *desc_addr,
void (*callback)(uint32_t desc, uint32_t status, void *arg),
void *arg)
{
struct jr_regs *regs = (struct jr_regs *)CONFIG_SYS_FSL_JR0_ADDR;
int head = jr.head;
dma_addr_t desc_phys_addr = virt_to_phys(desc_addr);
if (sec_in32(®s->irsa) == 0 ||
CIRC_SPACE(jr.head, jr.tail, jr.size) <= 0)
return -1;
jr.input_ring[head] = desc_phys_addr;
jr.info[head].desc_phys_addr = desc_phys_addr;
jr.info[head].desc_addr = (uint32_t)desc_addr;
jr.info[head].callback = (void *)callback;
jr.info[head].arg = arg;
jr.info[head].op_done = 0;
jr.head = (head + 1) & (jr.size - 1);
sec_out32(®s->irja, 1);
return 0;
}
开发者ID:CDACBANG,项目名称:u-boot-wingz,代码行数:26,代码来源:jr.c
示例6: qtnf_tx_queue_ready
static int qtnf_tx_queue_ready(struct qtnf_pcie_bus_priv *priv)
{
if (!CIRC_SPACE(priv->tx_bd_w_index, priv->tx_bd_r_index,
priv->tx_bd_num)) {
qtnf_pcie_data_tx_reclaim(priv);
if (!CIRC_SPACE(priv->tx_bd_w_index, priv->tx_bd_r_index,
priv->tx_bd_num)) {
pr_warn_ratelimited("reclaim full Tx queue\n");
priv->tx_full_count++;
return 0;
}
}
return 1;
}
开发者ID:Lyude,项目名称:linux,代码行数:16,代码来源:pcie.c
示例7: qtnf_dbg_hdp_stats
static int qtnf_dbg_hdp_stats(struct seq_file *s, void *data)
{
struct qtnf_bus *bus = dev_get_drvdata(s->private);
struct qtnf_pcie_pearl_state *ps = get_bus_priv(bus);
struct qtnf_pcie_bus_priv *priv = &ps->base;
seq_printf(s, "tx_full_count(%u)\n", priv->tx_full_count);
seq_printf(s, "tx_done_count(%u)\n", priv->tx_done_count);
seq_printf(s, "tx_reclaim_done(%u)\n", priv->tx_reclaim_done);
seq_printf(s, "tx_reclaim_req(%u)\n", priv->tx_reclaim_req);
seq_printf(s, "tx_bd_r_index(%u)\n", priv->tx_bd_r_index);
seq_printf(s, "tx_bd_p_index(%u)\n",
readl(PCIE_HDP_RX0DMA_CNT(ps->pcie_reg_base))
& (priv->tx_bd_num - 1));
seq_printf(s, "tx_bd_w_index(%u)\n", priv->tx_bd_w_index);
seq_printf(s, "tx queue len(%u)\n",
CIRC_CNT(priv->tx_bd_w_index, priv->tx_bd_r_index,
priv->tx_bd_num));
seq_printf(s, "rx_bd_r_index(%u)\n", priv->rx_bd_r_index);
seq_printf(s, "rx_bd_p_index(%u)\n",
readl(PCIE_HDP_TX0DMA_CNT(ps->pcie_reg_base))
& (priv->rx_bd_num - 1));
seq_printf(s, "rx_bd_w_index(%u)\n", priv->rx_bd_w_index);
seq_printf(s, "rx alloc queue len(%u)\n",
CIRC_SPACE(priv->rx_bd_w_index, priv->rx_bd_r_index,
priv->rx_bd_num));
return 0;
}
开发者ID:avagin,项目名称:linux,代码行数:31,代码来源:pearl_pcie.c
示例8: hisi_femac_rx_refill
static void hisi_femac_rx_refill(struct hisi_femac_priv *priv)
{
struct hisi_femac_queue *rxq = &priv->rxq;
struct sk_buff *skb;
u32 pos;
u32 len = MAX_FRAME_SIZE;
dma_addr_t addr;
pos = rxq->head;
while (readl(priv->port_base + ADDRQ_STAT) & BIT_RX_READY) {
if (!CIRC_SPACE(pos, rxq->tail, rxq->num))
break;
if (unlikely(rxq->skb[pos])) {
netdev_err(priv->ndev, "err skb[%d]=%p\n",
pos, rxq->skb[pos]);
break;
}
skb = netdev_alloc_skb_ip_align(priv->ndev, len);
if (unlikely(!skb))
break;
addr = dma_map_single(priv->dev, skb->data, len,
DMA_FROM_DEVICE);
if (dma_mapping_error(priv->dev, addr)) {
dev_kfree_skb_any(skb);
break;
}
rxq->dma_phys[pos] = addr;
rxq->skb[pos] = skb;
writel(addr, priv->port_base + IQ_ADDR);
pos = (pos + 1) % rxq->num;
}
rxq->head = pos;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:34,代码来源:hisi_femac.c
示例9: rs_write_room
static int rs_write_room(struct tty_struct *tty)
{
struct serial_state *info = tty->driver_data;
if (serial_paranoia_check(info, tty->name, "rs_write_room"))
return 0;
return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
}
开发者ID:kprog,项目名称:linux,代码行数:8,代码来源:amiserial.c
示例10: EMAC_TxLoad
//-----------------------------------------------------------------------------
/// Return current load of TX.
//-----------------------------------------------------------------------------
unsigned int EMAC_TxLoad(void)
{
unsigned short head = txTd.head;
unsigned short tail = txTd.tail;
#if 1
return CIRC_CNT(head, tail, TX_BUFFERS);
#else
return (TX_BUFFERS - CIRC_SPACE(head, tail, TX_BUFFERS));
#endif
}
开发者ID:Flyagin,项目名称:BS-MRZV,代码行数:13,代码来源:emac.c
示例11: kick_start_rx
//////////////////////////////////////////////////////////////////////////////
// ASYNCHRONOUS
//////////////////////////////////////////////////////////////////////////////
static void kick_start_rx( void )
{
if ( usb_ref_count ) {
int total_space = CIRC_SPACE( rx_ring.in, rx_ring.out, RBUF_SIZE );
if ( total_space >= RX_PACKET_SIZE ) {
pxa_usb_recv( packet_buffer,
RX_PACKET_SIZE,
rx_done_callback_packet_buffer
);
}
}
}
开发者ID:bticino,项目名称:linux-2.4.19-rmk7-pxa2-btweb,代码行数:15,代码来源:usb-char.c
示例12: ehv_bc_tty_write_room
/*
* Return the amount of space in the output buffer
*
* This is actually a contract between the driver and the tty layer outlining
* how much write room the driver can guarantee will be sent OR BUFFERED. This
* driver MUST honor the return value.
*/
static int ehv_bc_tty_write_room(struct tty_struct *ttys)
{
struct ehv_bc_data *bc = ttys->driver_data;
unsigned long flags;
int count;
spin_lock_irqsave(&bc->lock, flags);
count = CIRC_SPACE(bc->head, bc->tail, BUF_SIZE);
spin_unlock_irqrestore(&bc->lock, flags);
return count;
}
开发者ID:realmz,项目名称:blackfin-linux,代码行数:19,代码来源:ehv_bytechan.c
示例13: user_notify_callback
static void user_notify_callback(void *event)
{
down(&event_mutex);
if (CIRC_SPACE(pmic_events.head, pmic_events.tail, CIRC_BUF_MAX)) {
pmic_events.buf[pmic_events.head] = (int)event;
pmic_events.head = (pmic_events.head + 1) & (CIRC_BUF_MAX - 1);
} else {
pr_info("Failed to notify event to the user\n");
}
up(&event_mutex);
kill_fasync(&pmic_dev_queue, SIGIO, POLL_IN);
}
开发者ID:AvalueAES,项目名称:rev-sa01,代码行数:13,代码来源:pmic-dev.c
示例14: put_to_in
void put_to_in(forth_context_type *fc, char c)
{
set_current_state(TASK_INTERRUPTIBLE);
while (CIRC_SPACE(fc->in.head,fc->in.tail,TIB_SIZE)==0)
{
schedule_timeout(1);
set_current_state(TASK_INTERRUPTIBLE);
if(fc->stop) return;
}
set_current_state(TASK_RUNNING);
fc->in.buf[fc->in.head]=c;
fc->in.head=(fc->in.head+1) & (TIB_SIZE-1);
}
开发者ID:y-salnikov,项目名称:kforth,代码行数:13,代码来源:forth.c
示例15: hisi_femac_net_xmit
static netdev_tx_t hisi_femac_net_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct hisi_femac_priv *priv = netdev_priv(dev);
struct hisi_femac_queue *txq = &priv->txq;
dma_addr_t addr;
u32 val;
val = readl(priv->port_base + ADDRQ_STAT);
val &= BIT_TX_READY;
if (!val) {
hisi_femac_irq_enable(priv, IRQ_INT_TX_PER_PACKET);
dev->stats.tx_dropped++;
dev->stats.tx_fifo_errors++;
netif_stop_queue(dev);
return NETDEV_TX_BUSY;
}
if (unlikely(!CIRC_SPACE(txq->head, txq->tail,
txq->num))) {
hisi_femac_irq_enable(priv, IRQ_INT_TX_PER_PACKET);
dev->stats.tx_dropped++;
dev->stats.tx_fifo_errors++;
netif_stop_queue(dev);
return NETDEV_TX_BUSY;
}
addr = dma_map_single(priv->dev, skb->data,
skb->len, DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(priv->dev, addr))) {
dev_kfree_skb_any(skb);
dev->stats.tx_dropped++;
return NETDEV_TX_OK;
}
txq->dma_phys[txq->head] = addr;
txq->skb[txq->head] = skb;
txq->head = (txq->head + 1) % txq->num;
writel(addr, priv->port_base + EQ_ADDR);
writel(skb->len + ETH_FCS_LEN, priv->port_base + EQFRM_LEN);
priv->tx_fifo_used_cnt++;
dev->stats.tx_packets++;
dev->stats.tx_bytes += skb->len;
netdev_sent_queue(dev, skb->len);
return NETDEV_TX_OK;
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:50,代码来源:hisi_femac.c
示例16: caam_jr_enqueue
/**
* caam_jr_enqueue() - Enqueue a job descriptor head. Returns 0 if OK,
* -EBUSY if the queue is full, -EIO if it cannot map the caller's
* descriptor.
* @dev: device of the job ring to be used. This device should have
* been assigned prior by caam_jr_register().
* @desc: points to a job descriptor that execute our request. All
* descriptors (and all referenced data) must be in a DMAable
* region, and all data references must be physical addresses
* accessible to CAAM (i.e. within a PAMU window granted
* to it).
* @cbk: pointer to a callback function to be invoked upon completion
* of this request. This has the form:
* callback(struct device *dev, u32 *desc, u32 stat, void *arg)
* where:
* @dev: contains the job ring device that processed this
* response.
* @desc: descriptor that initiated the request, same as
* "desc" being argued to caam_jr_enqueue().
* @status: untranslated status received from CAAM. See the
* reference manual for a detailed description of
* error meaning, or see the JRSTA definitions in the
* register header file
* @areq: optional pointer to an argument passed with the
* original request
* @areq: optional pointer to a user argument for use at callback
* time.
**/
int caam_jr_enqueue(struct device *dev, u32 *desc,
void (*cbk)(struct device *dev, u32 *desc,
u32 status, void *areq),
void *areq)
{
struct caam_drv_private_jr *jrp = dev_get_drvdata(dev);
struct caam_jrentry_info *head_entry;
int head, tail, desc_size;
dma_addr_t desc_dma;
desc_size = (*desc & HDR_JD_LENGTH_MASK) * sizeof(u32);
desc_dma = dma_map_single(dev, desc, desc_size, DMA_TO_DEVICE);
if (dma_mapping_error(dev, desc_dma)) {
dev_err(dev, "caam_jr_enqueue(): can't map jobdesc\n");
return -EIO;
}
spin_lock_bh(&jrp->inplock);
head = jrp->head;
tail = ACCESS_ONCE(jrp->tail);
if (!rd_reg32(&jrp->rregs->inpring_avail) ||
CIRC_SPACE(head, tail, JOBR_DEPTH) <= 0) {
spin_unlock_bh(&jrp->inplock);
dma_unmap_single(dev, desc_dma, desc_size, DMA_TO_DEVICE);
return -EBUSY;
}
head_entry = &jrp->entinfo[head];
head_entry->desc_addr_virt = desc;
head_entry->desc_size = desc_size;
head_entry->callbk = (void *)cbk;
head_entry->cbkarg = areq;
head_entry->desc_addr_dma = desc_dma;
jrp->inpring[jrp->inp_ring_write_index] = desc_dma;
smp_wmb();
jrp->inp_ring_write_index = (jrp->inp_ring_write_index + 1) &
(JOBR_DEPTH - 1);
jrp->head = (head + 1) & (JOBR_DEPTH - 1);
wr_reg32(&jrp->rregs->inpring_jobadd, 1);
spin_unlock_bh(&jrp->inplock);
return 0;
}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:78,代码来源:jr.c
示例17: rs_put_char
static void rs_put_char(struct tty_struct *tty, unsigned char ch)
{
struct async_struct *info = (struct async_struct *)tty->driver_data;
unsigned long flags;
if (!tty || !info->xmit.buf) return;
local_irq_save(flags);
if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) == 0) {
local_irq_restore(flags);
return;
}
info->xmit.buf[info->xmit.head] = ch;
info->xmit.head = (info->xmit.head + 1) & (SERIAL_XMIT_SIZE-1);
local_irq_restore(flags);
}
开发者ID:BackupTheBerlios,项目名称:tuxap,代码行数:16,代码来源:simserial.c
示例18:
uint8_t *gmac_dev_get_tx_buffer(gmac_device_t* p_gmac_dev, gmac_quelist_t queue_idx)
{
volatile gmac_tx_descriptor_t *p_tx_td;
gmac_queue_t* p_gmac_queue = &p_gmac_dev->gmac_queue_list[queue_idx];
/* Pointers to the current transmit descriptor */
p_tx_td = &p_gmac_queue->p_tx_dscr[p_gmac_queue->us_tx_head];
/* If no free TxTd, forget it */
if (CIRC_SPACE(p_gmac_queue->us_tx_head, p_gmac_queue->us_tx_tail,
p_gmac_queue->us_tx_list_size) == 0) {
if (p_tx_td[p_gmac_queue->us_tx_head].status.val & GMAC_TXD_USED)
return 0;
}
return (uint8_t *)p_tx_td->addr;
}
开发者ID:thegeek82000,项目名称:asf,代码行数:17,代码来源:gmac_raw_2.c
示例19: nfp_release_mask_id
static int nfp_release_mask_id(struct nfp_app *app, u8 mask_id)
{
struct nfp_flower_priv *priv = app->priv;
struct circ_buf *ring;
ring = &priv->mask_ids.mask_id_free_list;
/* Checking if buffer is full. */
if (CIRC_SPACE(ring->head, ring->tail, NFP_FLOWER_MASK_ENTRY_RS) == 0)
return -ENOBUFS;
memcpy(&ring->buf[ring->head], &mask_id, NFP_FLOWER_MASK_ELEMENT_RS);
ring->head = (ring->head + NFP_FLOWER_MASK_ELEMENT_RS) %
(NFP_FLOWER_MASK_ENTRY_RS * NFP_FLOWER_MASK_ELEMENT_RS);
priv->mask_ids.last_used[mask_id] = ktime_get();
return 0;
}
开发者ID:Anjali05,项目名称:linux,代码行数:18,代码来源:metadata.c
示例20: nu__AsyncIO__tx_enqueue
size_t
nu__AsyncIO__tx_enqueue(struct nu__AsyncIO *a, const void *src, size_t n, bool overrun)
{
struct circ_buf *tx_buf = &(a->tx_buf);
size_t ui;
producer_enter(a, tx_buf);
for (ui = 0; ui < n; ++ui) {
tx_buf->buf[tx_buf->head] = *((const char *)src + ui);
tx_buf->head = (tx_buf->head + 1) & (a->tx_buf_size - 1);
if (CIRC_SPACE(tx_buf->head, tx_buf->tail, a->tx_buf_size) < 1) {
if (!overrun)
break;
tx_buf->tail = (tx_buf->head - 1) & (a->tx_buf_size - 1);
}
}
producer_exit(a, tx_buf);
return ui;
}
开发者ID:DIYzzuzpb,项目名称:sc6-pic32-code,代码行数:18,代码来源:async_io.c
注:本文中的CIRC_SPACE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论