xref: /spdk/mk/spdk.mock.unittest.mk (revision 7b8c7efe8fe5cbfb09d5ebff2fbad7ce49c7504d)
1#  SPDX-License-Identifier: BSD-3-Clause
2#  Copyright (C) 2015 Intel Corporation.
3#  All rights reserved.
4#
5
6SPDK_MOCK_SYMBOLS += \
7	calloc \
8	pthread_mutexattr_init \
9	pthread_mutex_init \
10	recvmsg \
11	sendmsg \
12	writev
13
14define add_wrap_with_prefix
15$(2:%=-Wl,--wrap,$(1)%)
16endef
17
18ifeq ($(OS),Windows)
19# Windows needs a thin layer above the system calls to provide POSIX
20# functionality. For GCC, use the prefix wpdk_ to ensure that the layer
21# is called. For other compilers, --wrap is not supported so the layer
22# implements an alternative mechanism to enable mocking.
23ifeq ($(CC_TYPE),gcc)
24LDFLAGS += $(call add_wrap_with_prefix,wpdk_,$(SPDK_MOCK_SYMBOLS))
25endif
26else
27LDFLAGS += $(call add_wrap_with_prefix,,$(SPDK_MOCK_SYMBOLS))
28endif
29