1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
5 #ifndef RTE_PMD_MLX5_COMMON_OS_H_
6 #define RTE_PMD_MLX5_COMMON_OS_H_
10 #include "mlx5_autoconf.h"
11 #include "mlx5_glue.h"
12 #include "mlx5_malloc.h"
15 * This API allocates aligned or non-aligned memory. The free can be on either
16 * aligned or nonaligned memory. To be protected - even though there may be no
17 * alignment - in Windows this API will unconditioanlly call _aligned_malloc()
18 * with at least a minimal alignment size.
21 * The alignment value, which must be an integer power of 2 (or 0 for
24 * Size in bytes to allocate
27 * Valid pointer to allocated memory, NULL in case of failure
30 mlx5_os_malloc(size_t align, size_t size)
32 if (align < MLX5_MALLOC_ALIGNMENT)
33 align = MLX5_MALLOC_ALIGNMENT;
34 return _aligned_malloc(size, align);
38 * This API de-allocates a memory that originally could have been allocated
39 * aligned or non-aligned. In Windows since the allocation was with
40 * _aligned_malloc() - it is safe to always call _aligned_free().
43 * Pointer to address to free
47 mlx5_os_free(void *addr)
51 #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */