1 /* 2 * Copyright 2018 Samy Al Bahra. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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. 13 * 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 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: head/sys/contrib/ck/include/ck_md.h 329388 2018-02-16 17:50:06Z cog 27 net $ 28 */ 29 30 /* 31 * This header file is meant for use of Concurrency Kit in the FreeBSD kernel. 32 */ 33 34 #ifndef CK_MD_H 35 #define CK_MD_H 36 37 #include <sys/param.h> 38 39 #ifndef _KERNEL 40 #error This header file is meant for the FreeBSD kernel. 41 #endif /* _KERNEL */ 42 43 #ifndef CK_MD_CACHELINE 44 /* 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 48 * perspective. 49 */ 50 #if defined(__amd64__) || defined(__i386__) 51 #define CK_MD_CACHELINE (64) 52 #else 53 #define CK_MD_CACHELINE (CACHE_LINE_SIZE) 54 #endif /* !__amd64__ && !__i386__ */ 55 #endif /* CK_MD_CACHELINE */ 56 57 #ifndef CK_MD_PAGESIZE 58 #define CK_MD_PAGESIZE (PAGE_SIZE) 59 #endif 60 61 /* 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. 64 */ 65 #ifndef CK_MD_RTM_DISABLE 66 #define CK_MD_RTM_DISABLE 67 #endif /* CK_MD_RTM_DISABLE */ 68 69 /* 70 * Do not enable pointer-packing-related (VMA) optimizations in kernel-space. 71 */ 72 #ifndef CK_MD_POINTER_PACK_DISABLE 73 #define CK_MD_POINTER_PACK_DISABLE 74 #endif /* CK_MD_POINTER_PACK_DISABLE */ 75 76 /* 77 * The following would be used for pointer-packing tricks, disabled for the 78 * kernel. 79 */ 80 #ifndef CK_MD_VMA_BITS_UNKNOWN 81 #define CK_MD_VMA_BITS_UNKNOWN 82 #endif /* CK_MD_VMA_BITS_UNKNOWN */ 83 84 /* 85 * Do not enable double operations in kernel-space. 86 */ 87 #ifndef CK_PR_DISABLE_DOUBLE 88 #define CK_PR_DISABLE_DOUBLE 89 #endif /* CK_PR_DISABLE_DOUBLE */ 90 91 /* 92 * If building for a uni-processor target, then enable the uniprocessor 93 * feature flag. This, among other things, will remove the lock prefix. 94 */ 95 #ifndef SMP 96 #define CK_MD_UMP 97 #endif /* SMP */ 98 99 /* 100 * Disable the use of compiler builtin functions. 101 */ 102 #define CK_MD_CC_BUILTIN_DISABLE 1 103 104 /* 105 * CK expects those, which are normally defined by the build system. 106 */ 107 #if defined(__i386__) && !defined(__x86__) 108 #define __x86__ 109 /* 110 * If x86 becomes more relevant, we may want to consider importing in 111 * __mbk() to avoid potential issues around false sharing. 112 */ 113 #define CK_MD_TSO 114 #define CK_MD_SSE_DISABLE 1 115 #elif defined(__amd64__) 116 #define CK_MD_TSO 117 #elif defined(__sparc64__) && !defined(__sparcv9__) 118 #define __sparcv9__ 119 #define CK_MD_TSO 120 #elif defined(__powerpc64__) && !defined(__ppc64__) 121 #define __ppc64__ 122 #elif defined(__powerpc__) && !defined(__ppc__) 123 #define __ppc__ 124 #endif 125 126 /* If no memory model has been defined, assume RMO. */ 127 #if !defined(CK_MD_RMO) && !defined(CK_MD_TSO) && !defined(CK_MD_PSO) 128 #define CK_MD_RMO 129 #endif 130 131 #define CK_VERSION "0.7.0" 132 #define CK_GIT_SHA "db5db44" 133 134 #endif /* CK_MD_H */ 135