1766 rb_head->put_idx = 0;
1767 rb_head->get_idx = 0;
1768 rb_head->size = 0;
1769 rb_head->state = SGHSC_RB_EMPTY;
1770 }
1771 }
1772
1773 /*
1774 * sghsc_rb_put()
1775 * Insert an event info into the event ring buffer.
1776 * Returns DDI_FAILURE if the buffer is full, DDI_SUCCESS otherwise
1777 */
1778 static int
1779 sghsc_rb_put(sghsc_rb_head_t *rb_head, sghsc_event_t *event)
1780 {
1781 if (rb_head->state == SGHSC_RB_FULL)
1782 return (DDI_FAILURE);
1783
1784 rb_head->buf[rb_head->put_idx] = *event;
1785
1786 rb_head->put_idx = ++rb_head->put_idx & (rb_head->size - 1);
1787
1788 if (rb_head->put_idx == rb_head->get_idx)
1789 rb_head->state = SGHSC_RB_FULL;
1790 else
1791 rb_head->state = SGHSC_RB_FLOAT;
1792
1793 return (DDI_SUCCESS);
1794 }
1795 /*
1796 * sghsc_rb_get()
1797 * Remove an event info from the event ring buffer.
1798 * Returns DDI_FAILURE if the buffer is empty, DDI_SUCCESS otherwise.
1799 */
1800 static int
1801 sghsc_rb_get(sghsc_rb_head_t *rb_head, sghsc_event_t *event)
1802 {
1803
1804 if (rb_head->state == SGHSC_RB_EMPTY)
1805 return (DDI_FAILURE);
1806
1807 *event = rb_head->buf[rb_head->get_idx];
1808
1809 rb_head->get_idx = ++rb_head->get_idx & (rb_head->size - 1);
1810
1811 if (rb_head->get_idx == rb_head->put_idx)
1812 rb_head->state = SGHSC_RB_EMPTY;
1813 else
1814 rb_head->state = SGHSC_RB_FLOAT;
1815
1816 return (DDI_SUCCESS);
1817 }
|
1766 rb_head->put_idx = 0;
1767 rb_head->get_idx = 0;
1768 rb_head->size = 0;
1769 rb_head->state = SGHSC_RB_EMPTY;
1770 }
1771 }
1772
1773 /*
1774 * sghsc_rb_put()
1775 * Insert an event info into the event ring buffer.
1776 * Returns DDI_FAILURE if the buffer is full, DDI_SUCCESS otherwise
1777 */
1778 static int
1779 sghsc_rb_put(sghsc_rb_head_t *rb_head, sghsc_event_t *event)
1780 {
1781 if (rb_head->state == SGHSC_RB_FULL)
1782 return (DDI_FAILURE);
1783
1784 rb_head->buf[rb_head->put_idx] = *event;
1785
1786 rb_head->put_idx = (rb_head->put_idx + 1) & (rb_head->size - 1);
1787
1788 if (rb_head->put_idx == rb_head->get_idx)
1789 rb_head->state = SGHSC_RB_FULL;
1790 else
1791 rb_head->state = SGHSC_RB_FLOAT;
1792
1793 return (DDI_SUCCESS);
1794 }
1795 /*
1796 * sghsc_rb_get()
1797 * Remove an event info from the event ring buffer.
1798 * Returns DDI_FAILURE if the buffer is empty, DDI_SUCCESS otherwise.
1799 */
1800 static int
1801 sghsc_rb_get(sghsc_rb_head_t *rb_head, sghsc_event_t *event)
1802 {
1803
1804 if (rb_head->state == SGHSC_RB_EMPTY)
1805 return (DDI_FAILURE);
1806
1807 *event = rb_head->buf[rb_head->get_idx];
1808
1809 rb_head->get_idx = (rb_head->get_idx + 1) & (rb_head->size - 1);
1810
1811 if (rb_head->get_idx == rb_head->put_idx)
1812 rb_head->state = SGHSC_RB_EMPTY;
1813 else
1814 rb_head->state = SGHSC_RB_FLOAT;
1815
1816 return (DDI_SUCCESS);
1817 }
|