| 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$ |
| 27 |
*/ |
| 28 |
|
| 29 |
/* |
| 30 |
* This header file is meant for use of Concurrency Kit in the FreeBSD kernel. |
| 31 |
*/ |
| 32 |
|
| 33 |
#ifndef CK_MD_H |
| 34 |
#define CK_MD_H |
| 35 |
|
| 36 |
#include <sys/param.h> |
| 37 |
|
| 38 |
#ifndef _KERNEL |
| 39 |
#error This header file is meant for the FreeBSD kernel. |
| 40 |
#endif /* _KERNEL */ |
| 41 |
|
| 42 |
#ifndef CK_MD_CACHELINE |
| 43 |
/* |
| 44 |
* FreeBSD's CACHE_LINE macro is a compile-time maximum cache-line size for an |
| 45 |
* architecture, defined to be 128 bytes by default on x86*. Even in presence |
| 46 |
* of adjacent sector prefetch, this doesn't make sense from a modeling |
| 47 |
* perspective. |
| 48 |
*/ |
| 49 |
#if defined(__amd64__) || defined(__i386__) |
| 50 |
#define CK_MD_CACHELINE (64) |
| 51 |
#else |
| 52 |
#define CK_MD_CACHELINE (CACHE_LINE_SIZE) |
| 53 |
#endif /* !__amd64__ && !__i386__ */ |
| 54 |
#endif /* CK_MD_CACHELINE */ |
| 55 |
|
| 56 |
#ifndef CK_MD_PAGESIZE |
| 57 |
#define CK_MD_PAGESIZE (PAGE_SIZE) |
| 58 |
#endif |
| 59 |
|
| 60 |
/* |
| 61 |
* Once FreeBSD has a mechanism to detect RTM, this can be enabled and RTM |
| 62 |
* facilities can be called. These facilities refer to TSX. |
| 63 |
*/ |
| 64 |
#ifndef CK_MD_RTM_DISABLE |
| 65 |
#define CK_MD_RTM_DISABLE |
| 66 |
#endif /* CK_MD_RTM_DISABLE */ |
| 67 |
|
| 68 |
/* |
| 69 |
* Do not enable pointer-packing-related (VMA) optimizations in kernel-space. |
| 70 |
*/ |
| 71 |
#ifndef CK_MD_POINTER_PACK_DISABLE |
| 72 |
#define CK_MD_POINTER_PACK_DISABLE |
| 73 |
#endif /* CK_MD_POINTER_PACK_DISABLE */ |
| 74 |
|
| 75 |
/* |
| 76 |
* The following would be used for pointer-packing tricks, disabled for the |
| 77 |
* kernel. |
| 78 |
*/ |
| 79 |
#ifndef CK_MD_VMA_BITS_UNKNOWN |
| 80 |
#define CK_MD_VMA_BITS_UNKNOWN |
| 81 |
#endif /* CK_MD_VMA_BITS_UNKNOWN */ |
| 82 |
|
| 83 |
/* |
| 84 |
* Do not enable double operations in kernel-space. |
| 85 |
*/ |
| 86 |
#ifndef CK_PR_DISABLE_DOUBLE |
| 87 |
#define CK_PR_DISABLE_DOUBLE |
| 88 |
#endif /* CK_PR_DISABLE_DOUBLE */ |
| 89 |
|
| 90 |
/* |
| 91 |
* If building for a uni-processor target, then enable the uniprocessor |
| 92 |
* feature flag. This, among other things, will remove the lock prefix. |
| 93 |
*/ |
| 94 |
#ifndef SMP |
| 95 |
#define CK_MD_UMP |
| 96 |
#endif /* SMP */ |
| 97 |
|
| 98 |
/* |
| 99 |
* Disable the use of compiler builtin functions. |
| 100 |
*/ |
| 101 |
#define CK_MD_CC_BUILTIN_DISABLE 1 |
| 102 |
|
| 103 |
/* |
| 104 |
* CK expects those, which are normally defined by the build system. |
| 105 |
*/ |
| 106 |
#if defined(__i386__) && !defined(__x86__) |
| 107 |
#define __x86__ |
| 108 |
/* |
| 109 |
* If x86 becomes more relevant, we may want to consider importing in |
| 110 |
* __mbk() to avoid potential issues around false sharing. |
| 111 |
*/ |
| 112 |
#define CK_MD_TSO |
| 113 |
#define CK_MD_SSE_DISABLE 1 |
| 114 |
#elif defined(__amd64__) |
| 115 |
#define CK_MD_TSO |
| 116 |
#elif defined(__sparc64__) && !defined(__sparcv9__) |
| 117 |
#define __sparcv9__ |
| 118 |
#define CK_MD_TSO |
| 119 |
#elif defined(__powerpc64__) && !defined(__ppc64__) |
| 120 |
#define __ppc64__ |
| 121 |
#elif defined(__powerpc__) && !defined(__ppc__) |
| 122 |
#define __ppc__ |
| 123 |
#endif |
| 124 |
|
| 125 |
/* If no memory model has been defined, assume RMO. */ |
| 126 |
#if !defined(CK_MD_RMO) && !defined(CK_MD_TSO) && !defined(CK_MD_PSO) |
| 127 |
#define CK_MD_RMO |
| 128 |
#endif |
| 129 |
|
| 130 |
#define CK_VERSION "@VERSION@" |
| 131 |
#define CK_GIT_SHA "@GIT_SHA@" |
| 132 |
|
| 133 |
#endif /* CK_MD_H */ |