4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _RTE_ACL_OSDEP_ALONE_H_
35 #define _RTE_ACL_OSDEP_ALONE_H_
40 * RTE ACL OS dependent file.
41 * An example how to build/use ACL library standalone
42 * (without rest of DPDK).
43 * Don't include that file on it's own, use <rte_acl_osdep.h>.
46 #if (defined(__ICC) || (__GNUC__ == 4 && __GNUC_MINOR__ < 4))
49 #include <xmmintrin.h>
53 #include <emmintrin.h>
56 #if defined(__SSE4_2__) || defined(__SSE4_1__)
57 #include <smmintrin.h>
62 #include <x86intrin.h>
70 #define DUMMY_MACRO do {} while (0)
75 #define __rte_unused __attribute__((__unused__))
77 #define RTE_PTR_ADD(ptr, x) ((typeof(ptr))((uintptr_t)(ptr) + (x)))
79 #define RTE_PTR_ALIGN_FLOOR(ptr, align) \
80 (typeof(ptr))((uintptr_t)(ptr) & ~((uintptr_t)(align) - 1))
82 #define RTE_PTR_ALIGN_CEIL(ptr, align) \
83 RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(ptr, (align) - 1), align)
85 #define RTE_PTR_ALIGN(ptr, align) RTE_PTR_ALIGN_CEIL(ptr, align)
87 #define RTE_ALIGN_FLOOR(val, align) \
88 (typeof(val))((val) & (~((typeof(val))((align) - 1))))
90 #define RTE_ALIGN_CEIL(val, align) \
91 RTE_ALIGN_FLOOR(((val) + ((typeof(val))(align) - 1)), align)
93 #define RTE_ALIGN(ptr, align) RTE_ALIGN_CEIL(ptr, align)
95 #define RTE_MIN(a, b) ({ \
101 #define RTE_DIM(a) (sizeof(a) / sizeof((a)[0]))
104 * Searches the input parameter for the least significant set bit
105 * (starting from zero).
106 * If a least significant 1 bit is found, its bit index is returned.
107 * If the content of the input paramer is zero, then the content of the return
108 * value is undefined.
110 * input parameter, should not be zero.
112 * least significant set bit in the input parameter.
114 static inline uint32_t
115 rte_bsf32(uint32_t v)
124 * rte_common_vect related.
126 typedef __m128i xmm_t;
128 #define XMM_SIZE (sizeof(xmm_t))
129 #define XMM_MASK (XMM_SIZE - 1)
131 typedef union rte_mmsse {
133 uint8_t u8[XMM_SIZE / sizeof(uint8_t)];
134 uint16_t u16[XMM_SIZE / sizeof(uint16_t)];
135 uint32_t u32[XMM_SIZE / sizeof(uint32_t)];
136 uint64_t u64[XMM_SIZE / sizeof(uint64_t)];
137 double pd[XMM_SIZE / sizeof(double)];
141 * rte_cycles related.
143 static inline uint64_t
154 asm volatile("rdtsc" :
163 #define rte_lcore_id() (0)
168 #define rte_errno errno
169 #define E_RTE_NO_TAILQ (-1)
172 * rte_rwlock related.
174 #define rte_rwlock_read_lock(x) DUMMY_MACRO
175 #define rte_rwlock_read_unlock(x) DUMMY_MACRO
176 #define rte_rwlock_write_lock(x) DUMMY_MACRO
177 #define rte_rwlock_write_unlock(x) DUMMY_MACRO
180 * rte_memory related.
182 #define SOCKET_ID_ANY -1 /**< Any NUMA socket. */
183 #define CACHE_LINE_SIZE 64 /**< Cache line size. */
184 #define CACHE_LINE_MASK (CACHE_LINE_SIZE-1) /**< Cache line mask. */
187 * Force alignment to cache line.
189 #define __rte_cache_aligned __attribute__((__aligned__(CACHE_LINE_SIZE)))
193 * rte_byteorder related.
195 #define rte_le_to_cpu_16(x) (x)
196 #define rte_le_to_cpu_32(x) (x)
198 #define rte_cpu_to_be_16(x) \
199 (((x) & UINT8_MAX) << CHAR_BIT | ((x) >> CHAR_BIT & UINT8_MAX))
200 #define rte_cpu_to_be_32(x) __builtin_bswap32(x)
203 * rte_branch_prediction related.
206 #define likely(x) __builtin_expect((x), 1)
210 #define unlikely(x) __builtin_expect((x), 0)
211 #endif /* unlikely */
218 rte_dummy_tailq(void)
220 static __thread TAILQ_HEAD(rte_dummy_head, rte_dummy) dummy_head;
221 TAILQ_INIT(&dummy_head);
225 #define RTE_TAILQ_LOOKUP_BY_IDX(idx, struct_name) rte_dummy_tailq()
227 #define RTE_EAL_TAILQ_REMOVE(idx, type, elm) DUMMY_MACRO
232 #define snprintf(str, len, frmt, args...) snprintf(str, len, frmt, ##args)
237 #define RTE_LOG(l, t, fmt, args...) printf(fmt, ##args)
242 #define rte_free(x) free(x)
245 rte_zmalloc_socket(__rte_unused const char *type, size_t size, unsigned align,
246 __rte_unused int socket)
251 rc = posix_memalign(&ptr, align, size);
257 memset(ptr, 0, size);
264 #define rte_panic(fmt, args...) do { \
265 RTE_LOG(CRIT, EAL, fmt, ##args); \
269 #define rte_exit(err, fmt, args...) do { \
270 RTE_LOG(CRIT, EAL, fmt, ##args); \
278 #endif /* _RTE_ACL_OSDEP_ALONE_H_ */