f-stack/dpdk/lib/eal/freebsd/include/rte_os.h

113 lines
2.4 KiB
C
Raw Normal View History

2020-06-18 16:55:50 +00:00
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2019 Intel Corporation
*/
#ifndef _RTE_OS_H_
#define _RTE_OS_H_
2022-09-02 07:34:10 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2020-06-18 16:55:50 +00:00
/**
2022-09-02 07:34:10 +00:00
* This header should contain any definition
* which is not supported natively or named differently in FreeBSD.
2020-06-18 16:55:50 +00:00
*/
#include <pthread_np.h>
2022-09-06 04:00:10 +00:00
#include <sys/queue.h>
/* These macros are compatible with system's sys/queue.h. */
#define RTE_TAILQ_HEAD(name, type) TAILQ_HEAD(name, type)
#define RTE_TAILQ_ENTRY(type) TAILQ_ENTRY(type)
#define RTE_TAILQ_FOREACH(var, head, field) TAILQ_FOREACH(var, head, field)
#define RTE_TAILQ_FIRST(head) TAILQ_FIRST(head)
#define RTE_TAILQ_NEXT(elem, field) TAILQ_NEXT(elem, field)
#define RTE_STAILQ_HEAD(name, type) STAILQ_HEAD(name, type)
#define RTE_STAILQ_ENTRY(type) STAILQ_ENTRY(type)
2020-06-18 16:55:50 +00:00
typedef cpuset_t rte_cpuset_t;
2022-09-02 04:40:05 +00:00
#define RTE_HAS_CPUSET
2022-09-02 07:34:10 +00:00
#ifdef RTE_EAL_FREEBSD_CPUSET_LEGACY
#if __FreeBSD_version >= 1301000
#define RTE_CPU_AND(dst, src1, src2) do \
{ \
cpuset_t tmp; \
CPU_COPY(src1, &tmp); \
CPU_AND(&tmp, &tmp, src2); \
CPU_COPY(&tmp, dst); \
} while (0)
#define RTE_CPU_OR(dst, src1, src2) do \
{ \
cpuset_t tmp; \
CPU_COPY(src1, &tmp); \
CPU_OR(&tmp, &tmp, src2); \
CPU_COPY(&tmp, dst); \
} while (0)
#else
2020-06-18 16:55:50 +00:00
#define RTE_CPU_AND(dst, src1, src2) do \
{ \
cpuset_t tmp; \
CPU_COPY(src1, &tmp); \
CPU_AND(&tmp, src2); \
CPU_COPY(&tmp, dst); \
} while (0)
#define RTE_CPU_OR(dst, src1, src2) do \
{ \
cpuset_t tmp; \
CPU_COPY(src1, &tmp); \
CPU_OR(&tmp, src2); \
CPU_COPY(&tmp, dst); \
} while (0)
#endif
2020-06-18 16:55:50 +00:00
#define RTE_CPU_FILL(set) CPU_FILL(set)
2022-09-02 07:34:10 +00:00
/* In FreeBSD 13 CPU_NAND macro is CPU_ANDNOT */
#ifdef CPU_NAND
2020-06-18 16:55:50 +00:00
#define RTE_CPU_NOT(dst, src) do \
{ \
cpuset_t tmp; \
CPU_FILL(&tmp); \
CPU_NAND(&tmp, src); \
CPU_COPY(&tmp, dst); \
} while (0)
2022-09-02 07:34:10 +00:00
#else
#if __FreeBSD_version >= 1301000
#define RTE_CPU_NOT(dst, src) do \
{ \
cpuset_t tmp; \
CPU_FILL(&tmp); \
CPU_ANDNOT(&tmp, &tmp, src); \
CPU_COPY(&tmp, dst); \
} while (0)
#else
2022-09-02 07:34:10 +00:00
#define RTE_CPU_NOT(dst, src) do \
{ \
cpuset_t tmp; \
CPU_FILL(&tmp); \
CPU_ANDNOT(&tmp, src); \
CPU_COPY(&tmp, dst); \
} while (0)
#endif
2022-09-02 07:34:10 +00:00
#endif /* CPU_NAND */
#else /* RTE_EAL_FREEBSD_CPUSET_LEGACY */
#define RTE_CPU_AND CPU_AND
#define RTE_CPU_OR CPU_OR
#define RTE_CPU_FILL CPU_FILL
#define RTE_CPU_NOT(dst, src) do { \
cpu_set_t tmp; \
CPU_FILL(&tmp); \
CPU_XOR(dst, src, &tmp); \
} while (0)
#endif /* RTE_EAL_FREEBSD_CPUSET_LEGACY */
#ifdef __cplusplus
}
#endif
2020-06-18 16:55:50 +00:00
#endif /* _RTE_OS_H_ */