DPDK
25.11.0
Toggle main menu visibility
Loading...
Searching...
No Matches
rte_stack_std.h
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright(c) 2019 Intel Corporation
3
*/
4
5
#ifndef _RTE_STACK_STD_H_
6
#define _RTE_STACK_STD_H_
7
8
#include <
rte_branch_prediction.h
>
9
22
static
__rte_always_inline
unsigned
int
23
__rte_stack_std_push(
struct
rte_stack *s,
void
*
const
*obj_table,
24
unsigned
int
n)
25
{
26
struct
rte_stack_std *stack = &s->stack_std;
27
unsigned
int
index;
28
void
**cache_objs;
29
30
rte_spinlock_lock
(&stack->lock);
31
cache_objs = &stack->objs[stack->len];
32
33
/* Is there sufficient space in the stack? */
34
if
((stack->len + n) > s->capacity) {
35
rte_spinlock_unlock
(&stack->lock);
36
return
0;
37
}
38
39
/* Add elements back into the cache */
40
for
(index = 0; index < n; ++index, obj_table++)
41
cache_objs[index] = *obj_table;
42
43
stack->len += n;
44
45
rte_spinlock_unlock
(&stack->lock);
46
return
n;
47
}
48
61
static
__rte_always_inline
unsigned
int
62
__rte_stack_std_pop(
struct
rte_stack *s,
void
**obj_table,
unsigned
int
n)
63
{
64
struct
rte_stack_std *stack = &s->stack_std;
65
unsigned
int
index, len;
66
void
**cache_objs;
67
68
rte_spinlock_lock
(&stack->lock);
69
70
if
(
unlikely
(n > stack->len)) {
71
rte_spinlock_unlock
(&stack->lock);
72
return
0;
73
}
74
75
cache_objs = stack->objs;
76
77
for
(index = 0, len = stack->len - 1; index < n;
78
++index, len--, obj_table++)
79
*obj_table = cache_objs[len];
80
81
stack->len -= n;
82
rte_spinlock_unlock
(&stack->lock);
83
84
return
n;
85
}
86
95
static
__rte_always_inline
unsigned
int
96
__rte_stack_std_count(
struct
rte_stack *s)
97
{
98
return
(
unsigned
int
)s->stack_std.len;
99
}
100
107
void
108
rte_stack_std_init(
struct
rte_stack *s);
109
118
ssize_t
119
rte_stack_std_get_memsize(
unsigned
int
count);
120
121
#endif
/* _RTE_STACK_STD_H_ */
rte_branch_prediction.h
unlikely
#define unlikely(x)
Definition
rte_branch_prediction.h:43
__rte_always_inline
#define __rte_always_inline
Definition
rte_common.h:490
rte_spinlock_unlock
static void rte_spinlock_unlock(rte_spinlock_t *sl)
rte_spinlock_lock
static void rte_spinlock_lock(rte_spinlock_t *sl)
lib
stack
rte_stack_std.h
Generated by
1.17.0