2 * Copyright 2018 Samy Al Bahra.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: head/sys/contrib/ck/include/ck_md.h 329388 2018-02-16 17:50:06Z cog
31 * This header file is meant for use of Concurrency Kit in the FreeBSD kernel.
37 #include <sys/param.h>
40 #error This header file is meant for the FreeBSD kernel.
43 #ifndef CK_MD_CACHELINE
45 * FreeBSD's CACHE_LINE macro is a compile-time maximum cache-line size for an
46 * architecture, defined to be 128 bytes by default on x86*. Even in presence
47 * of adjacent sector prefetch, this doesn't make sense from a modeling
50 #if defined(__amd64__) || defined(__i386__)
51 #define CK_MD_CACHELINE (64)
53 #define CK_MD_CACHELINE (CACHE_LINE_SIZE)
54 #endif /* !__amd64__ && !__i386__ */
55 #endif /* CK_MD_CACHELINE */
57 #ifndef CK_MD_PAGESIZE
58 #define CK_MD_PAGESIZE (PAGE_SIZE)
62 * Once FreeBSD has a mechanism to detect RTM, this can be enabled and RTM
63 * facilities can be called. These facilities refer to TSX.
65 #ifndef CK_MD_RTM_DISABLE
66 #define CK_MD_RTM_DISABLE
67 #endif /* CK_MD_RTM_DISABLE */
70 * Do not enable pointer-packing-related (VMA) optimizations in kernel-space.
72 #ifndef CK_MD_POINTER_PACK_DISABLE
73 #define CK_MD_POINTER_PACK_DISABLE
74 #endif /* CK_MD_POINTER_PACK_DISABLE */
77 * The following would be used for pointer-packing tricks, disabled for the
80 #ifndef CK_MD_VMA_BITS_UNKNOWN
81 #define CK_MD_VMA_BITS_UNKNOWN
82 #endif /* CK_MD_VMA_BITS_UNKNOWN */
85 * Do not enable double operations in kernel-space.
87 #ifndef CK_PR_DISABLE_DOUBLE
88 #define CK_PR_DISABLE_DOUBLE
89 #endif /* CK_PR_DISABLE_DOUBLE */
92 * If building for a uni-processor target, then enable the uniprocessor
93 * feature flag. This, among other things, will remove the lock prefix.
100 * Disable the use of compiler builtin functions.
102 #define CK_MD_CC_BUILTIN_DISABLE 1
105 * CK expects those, which are normally defined by the build system.
107 #if defined(__i386__) && !defined(__x86__)
110 * If x86 becomes more relevant, we may want to consider importing in
111 * __mbk() to avoid potential issues around false sharing.
114 #define CK_MD_SSE_DISABLE 1
115 #elif defined(__amd64__)
117 #elif defined(__sparc64__) && !defined(__sparcv9__)
120 #elif defined(__powerpc64__) && !defined(__ppc64__)
122 #elif defined(__powerpc__) && !defined(__ppc__)
126 /* If no memory model has been defined, assume RMO. */
127 #if !defined(CK_MD_RMO) && !defined(CK_MD_TSO) && !defined(CK_MD_PSO)
131 #define CK_VERSION "0.7.0"
132 #define CK_GIT_SHA "db5db44"