本文整理汇总了C++中CIRC_SPACE函数的典型用法代码示例。如果您正苦于以下问题:C++ CIRC_SPACE函数的具体用法?C++ CIRC_SPACE怎么用?C++ CIRC_SPACE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CIRC_SPACE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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() ----- */
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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
}
示例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
);
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}