├── .gitignore ├── Bridge_HPTS_2019.pdf ├── DirectMappedFile ├── .cproject ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.cdt.codan.core.prefs │ └── org.eclipse.linuxtools.tools.launch.core.prefs ├── LICENSE ├── bin │ └── usid_build ├── dmf.c └── dmf.h ├── LICENSE ├── NVM_Direct_API.doc ├── NVM_Direct_API.pdf ├── NVM_Direct_Notes.pdf ├── NVM_Direct_Presentation.pdf ├── README.html ├── README.md ├── README.pdf ├── RemoteSystemsTempFiles └── .project ├── bin ├── .project └── gccX ├── libpmem ├── .cproject ├── .gitignore ├── .project ├── libpmem.c ├── libpmem.h ├── libpmem.manpage ├── out.c ├── out.h ├── pmem.c ├── pmem.h ├── util.c ├── util.h └── valgrind_internal.h ├── nvmd ├── .cproject ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.cdt.codan.core.prefs ├── LICENSE ├── bin │ └── usid_build ├── nvm.h ├── nvm_data0.h ├── nvm_heap.c ├── nvm_heap.h ├── nvm_heap0.h ├── nvm_locks.c ├── nvm_locks.h ├── nvm_locks0.h ├── nvm_misc.c ├── nvm_misc.h ├── nvm_region.c ├── nvm_region.h ├── nvm_region0.h ├── nvm_transaction.c ├── nvm_transaction.h ├── nvm_transaction0.h ├── nvm_usid.c ├── nvm_usid.h ├── nvm_usid0.h └── nvm_usidmap.c ├── nvmds ├── .cproject ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.cdt.codan.core.prefs ├── LICENSE ├── nvms_locking.c ├── nvms_locking.h ├── nvms_memory.c ├── nvms_memory.h ├── nvms_misc.c ├── nvms_misc.h ├── nvms_region.c ├── nvms_region.h ├── nvms_sleeping.c └── nvms_sleeping.h ├── test_dmf ├── .cproject ├── .gitignore ├── .project ├── .settings │ └── org.eclipse.cdt.codan.core.prefs ├── project.gdbinit └── test.c └── test_nvmd ├── .cproject ├── .gitignore ├── .project ├── .settings ├── org.eclipse.cdt.codan.core.prefs ├── org.eclipse.cdt.core.prefs ├── org.eclipse.cdt.ui.prefs └── org.eclipse.linuxtools.tools.launch.core.prefs ├── LICENSE ├── bin └── usid_build ├── main.c └── project.gdbinit /.gitignore: -------------------------------------------------------------------------------- 1 | /readonly/ 2 | /.metadata/ 3 | /DirectMappedFileTx/ -------------------------------------------------------------------------------- /Bridge_HPTS_2019.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/nvm-direct/51f347cdb5f4ad401a75abca8eb28b2d129e3141/Bridge_HPTS_2019.pdf -------------------------------------------------------------------------------- /DirectMappedFile/.gitignore: -------------------------------------------------------------------------------- 1 | /DebugX/ 2 | /ReleaseX/ 3 | -------------------------------------------------------------------------------- /DirectMappedFile/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | DirectMappedFile 4 | 5 | 6 | nvmd 7 | 8 | 9 | 10 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 11 | clean,full,incremental, 12 | 13 | 14 | 15 | 16 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 17 | full,incremental, 18 | 19 | 20 | 21 | 22 | 23 | org.eclipse.cdt.core.cnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /DirectMappedFile/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning 3 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 4 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error 5 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 6 | org.eclipse.cdt.codan.checkers.noreturn=Error 7 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 8 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error 9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 10 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error 11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 12 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning 13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 14 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error 15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 16 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning 17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} 18 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning 19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} 20 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error 21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 22 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning 23 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} 24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error 25 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error 27 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error 29 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error 31 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error 33 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error 35 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error 37 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info 39 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} 40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning 41 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error 43 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error 45 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error 47 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning 49 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning 51 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning 53 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} 54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning 55 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} 56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning 57 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} 58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error 59 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning 61 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning 63 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning 65 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} 66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error 67 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 68 | -------------------------------------------------------------------------------- /DirectMappedFile/.settings/org.eclipse.linuxtools.tools.launch.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.linuxtools.tools.launch.core.LinuxtoolsPath="${workspace_loc\:/bin}" 3 | org.eclipse.linuxtools.tools.launch.core.LinuxtoolsPathCombo="${workspace_loc\:/bin}" 4 | org.eclipse.linuxtools.tools.launch.core.LinuxtoolsSystemEnvPath=false 5 | -------------------------------------------------------------------------------- /DirectMappedFile/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 2 | 3 | The Universal Permissive License (UPL), Version 1.0 4 | 5 | Subject to the condition set forth below, permission is hereby granted to any 6 | person obtaining a copy of this software, associated documentation and/or data 7 | (collectively the "Software"), free of charge and under any and all copyright 8 | rights in the Software, and any and all patent rights owned or freely 9 | licensable by each licensor hereunder covering either (i) the unmodified 10 | Software as contributed to or provided by such licensor, or (ii) the Larger 11 | Works (as defined below), to deal in both 12 | 13 | (a) the Software, and 14 | 15 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | one is included with the Software (each a "Larger Work" to which the Software 17 | is contributed by such licensors), 18 | 19 | without restriction, including without limitation the rights to copy, create 20 | derivative works of, display, perform, and distribute the Software and make, 21 | use, sell, offer for sale, import, export, have made, and have sold the 22 | Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | either these or other terms. 24 | 25 | This license is subject to the following condition: 26 | 27 | The above copyright notice and either this complete permission notice or at a 28 | minimum a reference to the UPL must be included in all copies or substantial 29 | portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | -------------------------------------------------------------------------------- /DirectMappedFile/bin/usid_build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script should be run just before running the linker 3 | # It creates the nvm_type and nvm_extern definitions. 4 | 5 | # Cleanup last build 6 | echo dmf/bin/usid_build called 7 | rm -f usid.c usid.json usid.o 8 | 9 | # construct usid.c from the .usd files 10 | CMD="usidmap -r=dmf_usid_init -c=./usid.c -d=./usid.json ./*.usd" 11 | echo " $CMD" 12 | $CMD 13 | X=$? 14 | if [ $X -ne 0 ] 15 | then 16 | echo " Status $X from usidmap" 17 | exit $X 18 | fi 19 | 20 | # remove the things defined by libnvm until a better usidmap is available 21 | sed -i "/__nvm_type_nvm_.* =/,/};/d" ./usid.c 22 | sed -i "/^ (const nvm_type.)&__nvm_type_nvm_/d" ./usid.c 23 | 24 | # compile usid.c 25 | CMD="gcc -O0 -g3 -c -I../../nvmd -I../../nvmds -fPIC -o ./usid.o ./usid.c" 26 | echo " $CMD" 27 | $CMD 28 | X=$? 29 | if [ $X -ne 0 ] 30 | then 31 | echo " Status $X from gcc usid.c" 32 | exit $X 33 | fi 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 2 | 3 | The Universal Permissive License (UPL), Version 1.0 4 | 5 | Subject to the condition set forth below, permission is hereby granted to any 6 | person obtaining a copy of this software, associated documentation and/or data 7 | (collectively the "Software"), free of charge and under any and all copyright 8 | rights in the Software, and any and all patent rights owned or freely 9 | licensable by each licensor hereunder covering either (i) the unmodified 10 | Software as contributed to or provided by such licensor, or (ii) the Larger 11 | Works (as defined below), to deal in both 12 | 13 | (a) the Software, and 14 | 15 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 16 | one is included with the Software (each a "Larger Work" to which the Software 17 | is contributed by such licensors), 18 | 19 | without restriction, including without limitation the rights to copy, create 20 | derivative works of, display, perform, and distribute the Software and make, 21 | use, sell, offer for sale, import, export, have made, and have sold the 22 | Software and the Larger Work(s), and to sublicense the foregoing rights on 23 | either these or other terms. 24 | 25 | This license is subject to the following condition: 26 | 27 | The above copyright notice and either this complete permission notice or at a 28 | minimum a reference to the UPL must be included in all copies or substantial 29 | portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | -------------------------------------------------------------------------------- /NVM_Direct_API.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/nvm-direct/51f347cdb5f4ad401a75abca8eb28b2d129e3141/NVM_Direct_API.doc -------------------------------------------------------------------------------- /NVM_Direct_API.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/nvm-direct/51f347cdb5f4ad401a75abca8eb28b2d129e3141/NVM_Direct_API.pdf -------------------------------------------------------------------------------- /NVM_Direct_Notes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/nvm-direct/51f347cdb5f4ad401a75abca8eb28b2d129e3141/NVM_Direct_Notes.pdf -------------------------------------------------------------------------------- /NVM_Direct_Presentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/nvm-direct/51f347cdb5f4ad401a75abca8eb28b2d129e3141/NVM_Direct_Presentation.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NVM Direct # 2 | ## Version 0.3 ## 3 | The advent of persistent memory in enterprise computing introduces new 4 | problems related to managing consistent application state. To solve 5 | these problems Oracle is developing NVM Direct, an open source C library and a set of C language extensions 6 | for applications utilizing NVM. This library and the extensions 7 | implement an application interface (API) that is applicable to a wide 8 | range of applications. 9 | 10 | This repository contains the shared library portion of the API and an example application. It is mostly complete, but there are a few pieces missing. It has not been rigorously tested yet. This preliminary version is being released so people can understand the intent of the API, and get a feel for what it can do. This is not production quality. 11 | 12 | There will be a GitHub repository containing the C extensions precompiler source 13 | code when it is completed. For now the Linux executables for the precompiler can be 14 | downloaded from the Oracle Technology Network at the [NVM Direct](http://www.oracle.com/technetwork/oracle-labs/open-nvm-download-2440119.html "NVM Direct") page. The precompiler consists of two executables: clang and usidmap. The precompiler itself is a modified version of clang which takes the preprocessed version of code using the C extensions, and produces C source which gcc can compile. The precompiler also produces a JSON file describing all the persistent structs and callback functions. The JSON file is processed by usidmap to generate the code to register all the USID's for an application. The makefiles to use these executables are included in the eclipse DebugX build configurations for all projects. Extract the two executables and ensure they are available through your $PATH as clang and usidmap. This should work on any modern x64 Linux distribution. 15 | 16 | The library is coded both with and without the 17 | C extensions. If `NVM_EXT` is defined then the version with extensions 18 | will be compiled. This will be set if the DebugX build configuration is used. The two versions provide a comparison of how the extensions will look when used in a real application. 19 | 20 | The library has been developed using Eclipse Luna. There are three Eclipse projects in the repository for the NVM Direct code. There are two build configurations for each project. The configurations ending in X compile the code with the C 21 | extensions. Of course that will not work without the precompiler. 22 | 23 | There are two Eclipse projects for an example application. They are written with the C extensions and require the precompiler. 24 | 25 | The bin project just contains a shell script to compile a C file that uses the NVM Direct C extensions. It is only intended to work with the makefiles generated by Eclipse Luna for gcc. However it should be easy to modify for other environments. 26 | 27 | Note that most of the DebugX build configurations use a custom shell script to run usidmap and to post process its output. This is necessary because of some problems with usidmap. A future version will not require the post processing. The test_dmf project does not run usidmap because it does not define any USID's. 28 | 29 | ### Eclipse Projects: ### 30 | 31 | - **`test_nvmd`:** This is a silly NVM application that tries to get most 32 | of the library code called. It forks itself and kills its child to 33 | exercise recovery. 34 | - **`nvmd`:** This is the portable shared library. It contains the bulk of 35 | the code. 36 | - **`nvmds`:** This is a service layer that allows the library to be customized for different environments. The current service layer is for testing the library on Linux. It does not actually work with persistent memory. It needs to integrate with Intel's libpmem to actually work with NVM. 37 | - **`DirectMappedFile`:** This is an example shared library written with the NVM Direct API. It uses NVM Direct to create a region file that supports atomic 38 | block I/O to NVM using memcpy. It supports an arbitrary number of threads 39 | simultaneously doing reads and writes. The size of the file can be changed 40 | concurrently with I/O. This is similar to the functionality provided by [Block Translation Table](http://pmem.io/2014/09/23/btt.html). See dmf.h and dmf.c for more information. 41 | - **`test_dmf`:** This is an application to test DirectMappedFile. It gets multiple threads simultaneously reading/writing/resizing a file. 42 | - **`bin`:** This just contains a shell script for compiling sources that use the C extensions for NVM Direct. 43 | 44 | ### Documents: ### 45 | There is some documentation in the root of the repository. This is intended 46 | to aid in understanding the code. 47 | 48 | - **`LICENSE`:** This contains the Universal Permissive License that 49 | this code is released under. 50 | - **`NVM_Direct_API.pdf`:** This is an 100 page document describing the API and 51 | the reasoning behind the design. 52 | It includes the extended C syntax and all the publicly available library 53 | entry points. It is not as detailed as man pages, but it is a start. 54 | - **`NVM_Direct_Presentation.pdf`:** This is a slide deck that has been used for presentations on the API. It is pretty basic. 55 | - **`NVM_Direct_Notes.pdf`:** This is the same presentation, but with 56 | the notes for each slide. The notes give information which could not be 57 | presented due to time constraints. 58 | 59 | ### To Do: ### 60 | The API is not yet an industrial strength software package ready for use in production code. This alpha release has all the software interfaces that a production quality release will have, but lacks some of the external support that is really required. Some of the algorithms can also be improved. 61 | 62 | - The error reporting is inadequate. Real developers will need much more information about asserts caused by improper library calls and NVM corruptions found by the library. An error reporting system needs to be developed. 63 | 64 | - The documentation does not go down to the level of detail a developer expects in a man page. The .h files are the best documentation. The man pages need to be written. 65 | 66 | - There are Doxygen annotated comments throughout the code, but there is no overall Doxygen documentation. Doxygen documentation needs to be generated and made complete. 67 | 68 | - There is a small test program used for initial debugging. However it is far from an adequate test of the entire API in all its corner cases. A full test suite needs to be developed. 69 | 70 | - The code contains a few TODO comments that create Eclipse tasks. These still need to be addressed. They do not significantly impact functionality. 71 | 72 | - The library does not actually work with persistent memory. The service layer uses a disk file system and does not actually do the necessary processor cache flushing and persistent memory barriers needed for real NVM. The service layer needs to be integrated with libpmem. 73 | 74 | - The precompiler that implements the language extensions is not complete yet, and will not be open sourced until it is in a better state. The library cannot be compiled with `NVM_EXT` defined without the precompiler. Development versions of the precompiler have successfully compiled the code with extensions, but not all of the extended features are available. The most significant issue is the automatic construction of the initialized nvm_type structs that describe the persistent structs. They have been hand crafted in usidmap.c. It is difficult to keep the C declarations and usidmap.c in sync. 75 | 76 | - Debugger support is needed for the language extensions. Following self-relative pointers in gdb is cumbersome at best. The debugger should be able to recognize USID's and report structs properly formatted. Getting formatted dumps of transaction undo could be very useful for resolving recovery problems. 77 | 78 | - Eclipse and other IDE's contain C parsers that do not recognize the NVM extensions for C. This makes some Eclipse features unusable with code that contains extensions. 79 | 80 | - There are some configuration parameters that the service layer passes to the generic layer of the library. Currently these are hard wired as numeric values in the service layer code. There needs to be a mechanism to allow per application configuration of the parameters. 81 | 82 | - Since the code has never been run on real NVM there are no performance numbers. Benchmarks need to be developed and run on real hardware to evaluate the library. 83 | 84 | - The code has not been instrumented to report performance statistics. This is needed for application tuning, and bottleneck discovery. -------------------------------------------------------------------------------- /README.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oracle/nvm-direct/51f347cdb5f4ad401a75abca8eb28b2d129e3141/README.pdf -------------------------------------------------------------------------------- /RemoteSystemsTempFiles/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RemoteSystemsTempFiles 4 | 5 | 6 | 7 | 8 | 9 | 10 | org.eclipse.rse.ui.remoteSystemsTempNature 11 | 12 | 13 | -------------------------------------------------------------------------------- /bin/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | bin 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /bin/gccX: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #echo using gccX 3 | 4 | # This script is used as the compiler for the DebugX configurations. It must be 5 | # in the path when building those configurations. The precompiler clang must 6 | # also be in the path. They are both in the NVM_Direct.git/bin directory. 7 | 8 | # define the path name of the compiler to use 9 | CC=gcc 10 | #ICC=/usr/local/packages/icc_remote/12.0.5.226/bin/icc 11 | 12 | #define the path name of the NVM extension precompiler 13 | CX=clang 14 | 15 | # scan the arguments finding the object and source files. The rest of the 16 | # arguments are saved for calling the compiler. 17 | OBJ=0 # set when -o encountered meaning the next arg is the output file 18 | PPARGS= # arguments for the preprocessor 19 | CARGS= # arguments for the C compiler 20 | ONAME= # output files base name - adds extension to get the file 21 | SRC= # C source file containing NVM extensions 22 | 23 | for ARG in "$@" ; do 24 | # echo next arg: $ARG 25 | 26 | if [ "$ARG" == '-c' ] 27 | then 28 | # discard the -c 29 | # echo -c found 30 | continue 31 | fi 32 | 33 | if [ "$ARG" == '-o' ] 34 | then 35 | # echo -o found 36 | OBJ=1 37 | continue 38 | fi 39 | 40 | if [ $OBJ = 1 ] 41 | then 42 | ONAME=${ARG%.o} 43 | OBJ=2 44 | # echo output saved as ${ONAME}.o 45 | continue 46 | fi 47 | 48 | if [[ "$ARG" = -M* ]] 49 | then 50 | PPARGS="$PPARGS $ARG" 51 | # echo ppargs now $PPARGS 52 | continue 53 | fi 54 | 55 | if [[ "$ARG" = -I* ]] 56 | then 57 | PPARGS="$PPARGS $ARG" 58 | # echo ppargs now $PPARGS 59 | continue 60 | fi 61 | 62 | if [[ "$ARG" = -D* ]] 63 | then 64 | PPARGS="$PPARGS $ARG" 65 | # echo ppargs now $PPARGS 66 | continue 67 | fi 68 | 69 | if [[ "$ARG" = *.c ]]; then 70 | SRC=$ARG 71 | # echo source file is $SRC 72 | continue 73 | fi 74 | 75 | CARGS="$CARGS $ARG" 76 | # echo cargs now $CARGS 77 | 78 | done 79 | 80 | 81 | # Remove old output file versions to ensure they are not used if this fails 82 | rm -f ${ONAME}.ix ${ONAME}.i ${ONAME}.o 83 | 84 | # Run the standard preprocessor to get the input for the precompiler 85 | CMD="$CC -E $PPARGS $CARGS -o ${ONAME}.ix $SRC" 86 | echo " $CMD" 87 | $CMD 88 | X=$? 89 | if [ $X -ne 0 ] 90 | then 91 | echo " Status $X from $CC" 92 | exit $X 93 | fi 94 | 95 | # Run the NVM extensions precompiler for a standard C preprocessor outputfile 96 | CMD="$CX -n -Wno-invalid-preprocessed-input -xc ${ONAME}.ix -o ${ONAME}.i" 97 | #CMD="$CX -n -xc ${ONAME}.ix -o ${ONAME}.i" 98 | echo " $CMD" 99 | $CMD 100 | X=$? 101 | if [ $X -ne 0 ] 102 | then 103 | echo " Status $X from $CX" 104 | exit $X 105 | fi 106 | 107 | # Work around some clang9 bugs 108 | #sed -i "s/typedef typedef/typedef/" ${ONAME}.i 109 | #sed -i "/enum __nvm_assert/d" ${ONAME}.i 110 | 111 | # until I get usidmap working remove __ from __nvm_type* 112 | #sed -i "s/__nvm_type/nvm_type/g" ${ONAME}.i 113 | 114 | # gcc complains when an initializer of a single scalar union misses {} 115 | CARGS="$CARGS -Wno-missing-braces" 116 | 117 | # Run the C compiler phase to generate the desired .o 118 | CMD="$CC -c -o ${ONAME}.o $CARGS ${ONAME}.i" 119 | echo " $CMD" 120 | $CMD 121 | X=$? 122 | if [ $X -ne 0 ] 123 | then 124 | echo " Status $X from $CC" 125 | exit $X 126 | fi 127 | 128 | -------------------------------------------------------------------------------- /libpmem/.cproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 35 | 41 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 86 | 87 | 93 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /libpmem/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | -------------------------------------------------------------------------------- /libpmem/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | libpmem 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 25 | 26 | 27 | -------------------------------------------------------------------------------- /libpmem/libpmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * * Neither the name of Intel Corporation nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | * libpmem.c -- pmem entry points for libpmem 35 | */ 36 | 37 | #include 38 | #include 39 | 40 | #include "libpmem.h" 41 | 42 | #include "pmem.h" 43 | #include "util.h" 44 | #include "out.h" 45 | 46 | /* 47 | * libpmem_init -- load-time initialization for libpmem 48 | * 49 | * Called automatically by the run-time loader. 50 | */ 51 | __attribute__((constructor)) 52 | static void 53 | libpmem_init(void) 54 | { 55 | out_init(PMEM_LOG_PREFIX, PMEM_LOG_LEVEL_VAR, PMEM_LOG_FILE_VAR, 56 | PMEM_MAJOR_VERSION, PMEM_MINOR_VERSION); 57 | LOG(3, NULL); 58 | util_init(); 59 | } 60 | 61 | /* 62 | * libpmem_fini -- libpmem cleanup routine 63 | * 64 | * Called automatically when the process terminates. 65 | */ 66 | __attribute__((destructor)) 67 | static void 68 | libpmem_fini(void) 69 | { 70 | LOG(3, NULL); 71 | out_fini(); 72 | } 73 | 74 | /* 75 | * pmem_check_version -- see if library meets application version requirements 76 | */ 77 | const char * 78 | pmem_check_version(unsigned major_required, unsigned minor_required) 79 | { 80 | LOG(3, "major_required %u minor_required %u", 81 | major_required, minor_required); 82 | 83 | if (major_required != PMEM_MAJOR_VERSION) { 84 | ERR("libpmem major version mismatch (need %u, found %u)", 85 | major_required, PMEM_MAJOR_VERSION); 86 | return out_get_errormsg(); 87 | } 88 | 89 | if (minor_required > PMEM_MINOR_VERSION) { 90 | ERR("libpmem minor version mismatch (need %u, found %u)", 91 | minor_required, PMEM_MINOR_VERSION); 92 | return out_get_errormsg(); 93 | } 94 | 95 | return NULL; 96 | } 97 | 98 | /* 99 | * pmem_errormsg -- return last error message 100 | */ 101 | const char * 102 | pmem_errormsg(void) 103 | { 104 | return out_get_errormsg(); 105 | } 106 | -------------------------------------------------------------------------------- /libpmem/libpmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * * Neither the name of Intel Corporation nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | * libpmem.h -- definitions of libpmem entry points 35 | * 36 | * This library provides support for programming with persistent memory (pmem). 37 | * 38 | * libpmem provides support for using raw pmem directly. 39 | * 40 | * See libpmem(3) for details. 41 | */ 42 | 43 | #ifndef LIBPMEM_H 44 | #define LIBPMEM_H 1 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | #include 51 | 52 | void *pmem_map(int fd); 53 | int pmem_unmap(void *addr, size_t len); 54 | int pmem_is_pmem(void *addr, size_t len); 55 | void pmem_persist(void *addr, size_t len); 56 | int pmem_msync(void *addr, size_t len); 57 | void pmem_flush(void *addr, size_t len); 58 | void pmem_drain(void); 59 | int pmem_has_hw_drain(void); 60 | void *pmem_memmove_persist(void *pmemdest, const void *src, size_t len); 61 | void *pmem_memcpy_persist(void *pmemdest, const void *src, size_t len); 62 | void *pmem_memset_persist(void *pmemdest, int c, size_t len); 63 | void *pmem_memmove_nodrain(void *pmemdest, const void *src, size_t len); 64 | void *pmem_memcpy_nodrain(void *pmemdest, const void *src, size_t len); 65 | void *pmem_memset_nodrain(void *pmemdest, int c, size_t len); 66 | 67 | /* 68 | * PMEM_MAJOR_VERSION and PMEM_MINOR_VERSION provide the current version of the 69 | * libpmem API as provided by this header file. Applications can verify that 70 | * the version available at run-time is compatible with the version used at 71 | * compile-time by passing these defines to pmem_check_version(). 72 | */ 73 | #define PMEM_MAJOR_VERSION 1 74 | #define PMEM_MINOR_VERSION 0 75 | const char *pmem_check_version( 76 | unsigned major_required, 77 | unsigned minor_required); 78 | 79 | const char *pmem_errormsg(void); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | #endif /* libpmem.h */ 85 | -------------------------------------------------------------------------------- /libpmem/out.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * * Neither the name of Intel Corporation nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | * out.h -- definitions for "out" module 35 | */ 36 | 37 | #include 38 | #include 39 | 40 | #ifdef DEBUG 41 | 42 | #define OUT_LOG out_log 43 | #define OUT_NONL out_nonl 44 | #define OUT_FATAL out_fatal 45 | #define OUT_FATAL_ABORT out_fatal 46 | 47 | #else 48 | 49 | static __attribute__((always_inline)) inline void 50 | out_log_discard(const char *file, int line, const char *func, int level, 51 | const char *fmt, ...) 52 | { 53 | (void) file; 54 | (void) line; 55 | (void) func; 56 | (void) level; 57 | (void) fmt; 58 | } 59 | 60 | static __attribute__((always_inline)) inline void 61 | out_nonl_discard(int level, const char *fmt, ...) 62 | { 63 | (void) level; 64 | (void) fmt; 65 | } 66 | 67 | static __attribute__((always_inline)) inline void 68 | out_fatal_discard(const char *file, int line, const char *func, 69 | const char *fmt, ...) 70 | { 71 | (void) file; 72 | (void) line; 73 | (void) func; 74 | (void) fmt; 75 | } 76 | 77 | static __attribute__((always_inline)) __attribute__((noreturn)) inline void 78 | out_fatal_abort(const char *file, int line, const char *func, 79 | const char *fmt, ...) 80 | { 81 | (void) file; 82 | (void) line; 83 | (void) func; 84 | (void) fmt; 85 | 86 | abort(); 87 | } 88 | 89 | #define OUT_LOG out_log_discard 90 | #define OUT_NONL out_nonl_discard 91 | #define OUT_FATAL out_fatal_discard 92 | #define OUT_FATAL_ABORT out_fatal_abort 93 | 94 | #endif 95 | 96 | /* produce debug/trace output */ 97 | #define LOG(level, ...)\ 98 | OUT_LOG(__FILE__, __LINE__, __func__, level, __VA_ARGS__) 99 | 100 | /* produce debug/trace output without prefix and new line */ 101 | #define LOG_NONL(level, ...)\ 102 | OUT_NONL(level, __VA_ARGS__) 103 | 104 | /* produce output and exit */ 105 | #define FATAL(...)\ 106 | OUT_FATAL_ABORT(__FILE__, __LINE__, __func__, __VA_ARGS__) 107 | 108 | /* assert a condition is true at runtime */ 109 | #define ASSERT_rt(cnd)\ 110 | ((void)((cnd) || (OUT_FATAL(__FILE__, __LINE__, __func__,\ 111 | "assertion failure: %s", #cnd), 0))) 112 | 113 | /* assertion with extra info printed if assertion fails at runtime */ 114 | #define ASSERTinfo_rt(cnd, info)\ 115 | ((void)((cnd) || (OUT_FATAL(__FILE__, __LINE__, __func__,\ 116 | "assertion failure: %s (%s = %s)", #cnd, #info, info), 0))) 117 | 118 | /* assert two integer values are equal at runtime */ 119 | #define ASSERTeq_rt(lhs, rhs)\ 120 | ((void)(((lhs) == (rhs)) || (OUT_FATAL(__FILE__, __LINE__, __func__,\ 121 | "assertion failure: %s (0x%llx) == %s (0x%llx)", #lhs,\ 122 | (unsigned long long)(lhs), #rhs, (unsigned long long)(rhs)), 0))) 123 | 124 | /* assert two integer values are not equal at runtime */ 125 | #define ASSERTne_rt(lhs, rhs)\ 126 | ((void)(((lhs) != (rhs)) || (OUT_FATAL(__FILE__, __LINE__, __func__,\ 127 | "assertion failure: %s (0x%llx) != %s (0x%llx)", #lhs,\ 128 | (unsigned long long)(lhs), #rhs, (unsigned long long)(rhs)), 0))) 129 | 130 | /* assert a condition is true */ 131 | #define ASSERT(cnd)\ 132 | do {\ 133 | /*\ 134 | * Detect useless asserts on always true expression. Please use\ 135 | * COMPILE_ERROR_ON(!cnd) or ASSERT_rt(cnd) in such cases.\ 136 | */\ 137 | if (__builtin_constant_p(cnd))\ 138 | COMPILE_ERROR_ON(cnd);\ 139 | ASSERT_rt(cnd);\ 140 | } while (0) 141 | 142 | /* assertion with extra info printed if assertion fails */ 143 | #define ASSERTinfo(cnd, info)\ 144 | do {\ 145 | /* See comment in ASSERT. */\ 146 | if (__builtin_constant_p(cnd))\ 147 | COMPILE_ERROR_ON(cnd);\ 148 | ASSERTinfo_rt(cnd);\ 149 | } while (0) 150 | 151 | /* assert two integer values are equal */ 152 | #define ASSERTeq(lhs, rhs)\ 153 | do {\ 154 | /* See comment in ASSERT. */\ 155 | if (__builtin_constant_p(lhs) && __builtin_constant_p(rhs))\ 156 | COMPILE_ERROR_ON((lhs) == (rhs));\ 157 | ASSERTeq_rt(lhs, rhs);\ 158 | } while (0) 159 | 160 | /* assert two integer values are not equal */ 161 | #define ASSERTne(lhs, rhs)\ 162 | do {\ 163 | /* See comment in ASSERT. */\ 164 | if (__builtin_constant_p(lhs) && __builtin_constant_p(rhs))\ 165 | COMPILE_ERROR_ON((lhs) != (rhs));\ 166 | ASSERTne_rt(lhs, rhs);\ 167 | } while (0) 168 | 169 | #define ERR(...)\ 170 | out_err(__FILE__, __LINE__, __func__, __VA_ARGS__) 171 | 172 | void out_init(const char *log_prefix, const char *log_level_var, 173 | const char *log_file_var, int major_version, 174 | int minor_version); 175 | void out_fini(void); 176 | void out(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 177 | void out_nonl(int level, const char *fmt, 178 | ...) __attribute__((format(printf, 2, 3))); 179 | void out_log(const char *file, int line, const char *func, int level, 180 | const char *fmt, ...) 181 | __attribute__((format(printf, 5, 6))); 182 | void out_err(const char *file, int line, const char *func, 183 | const char *fmt, ...) 184 | __attribute__((format(printf, 4, 5))); 185 | void out_fatal(const char *file, int line, const char *func, 186 | const char *fmt, ...) 187 | __attribute__((format(printf, 4, 5))) 188 | __attribute__((noreturn)); 189 | void out_set_print_func(void (*print_func)(const char *s)); 190 | void out_set_vsnprintf_func(int (*vsnprintf_func)(char *str, size_t size, 191 | const char *format, va_list ap)); 192 | const char *out_get_errormsg(void); 193 | -------------------------------------------------------------------------------- /libpmem/pmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * * Neither the name of Intel Corporation nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | * pmem.h -- internal definitions for libpmem 35 | */ 36 | 37 | #define PMEM_LOG_PREFIX "libpmem" 38 | #define PMEM_LOG_LEVEL_VAR "PMEM_LOG_LEVEL" 39 | #define PMEM_LOG_FILE_VAR "PMEM_LOG_FILE" 40 | 41 | extern unsigned long Pagesize; 42 | -------------------------------------------------------------------------------- /libpmem/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * * Neither the name of Intel Corporation nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | * util.h -- internal definitions for util module 35 | */ 36 | 37 | extern unsigned long Pagesize; 38 | 39 | 40 | /* 41 | * overridable names for malloc & friends used by this library 42 | */ 43 | typedef void *(*Malloc_func)(size_t size); 44 | typedef void (*Free_func)(void *ptr); 45 | typedef void *(*Realloc_func)(void *ptr, size_t size); 46 | typedef char *(*Strdup_func)(const char *s); 47 | 48 | extern Malloc_func Malloc; 49 | extern Free_func Free; 50 | extern Realloc_func Realloc; 51 | extern Strdup_func Strdup; 52 | 53 | void util_set_alloc_funcs( 54 | void *(*malloc_func)(size_t size), 55 | void (*free_func)(void *ptr), 56 | void *(*realloc_func)(void *ptr, size_t size), 57 | char *(*strdup_func)(const char *s)); 58 | void *util_map(int fd, size_t len, int cow, size_t req_align); 59 | int util_unmap(void *addr, size_t len); 60 | 61 | int util_tmpfile(const char *dir, size_t size); 62 | void *util_map_tmpfile(const char *dir, size_t size, size_t req_align); 63 | 64 | /* 65 | * Number of bits per type in alignment descriptor 66 | */ 67 | #define ALIGNMENT_DESC_BITS 4 68 | 69 | /* 70 | * architecture identification flags 71 | * 72 | * These flags allow to unambiguously determine the architecture 73 | * on which the pool was created. 74 | * 75 | * The alignment_desc field contains information about alignment 76 | * of the following basic types: 77 | * - char 78 | * - short 79 | * - int 80 | * - long 81 | * - long long 82 | * - size_t 83 | * - off_t 84 | * - float 85 | * - double 86 | * - long double 87 | * - void * 88 | * 89 | * The alignment of each type is computer as an offset of field 90 | * of specific type in the following structure: 91 | * struct { 92 | * char byte; 93 | * type field; 94 | * }; 95 | * 96 | * The value is decremented by 1 and masked by 4 bits. 97 | * Multiple alignment are stored on consecutive 4 bits of each 98 | * type in order specified above. 99 | */ 100 | struct arch_flags { 101 | uint64_t alignment_desc; /* alignment descriptor */ 102 | uint8_t ei_class; /* ELF format file class */ 103 | uint8_t ei_data; /* ELF format data encoding */ 104 | uint8_t reserved[4]; 105 | uint16_t e_machine; /* required architecture */ 106 | }; 107 | 108 | /* 109 | * header used at the beginning of all types of memory pools 110 | * 111 | * for pools build on persistent memory, the integer types 112 | * below are stored in little-endian byte order. 113 | */ 114 | #define POOL_HDR_SIG_LEN 8 115 | #define POOL_HDR_UUID_LEN 16 /* uuid byte length */ 116 | #define POOL_HDR_UUID_STR_LEN 37 /* uuid string length */ 117 | #define POOL_HDR_UUID_GEN_FILE "/proc/sys/kernel/random/uuid" 118 | 119 | typedef unsigned char uuid_t[POOL_HDR_UUID_LEN]; /* 16 byte binary uuid value */ 120 | 121 | struct pool_hdr { 122 | char signature[POOL_HDR_SIG_LEN]; 123 | uint32_t major; /* format major version number */ 124 | uint32_t compat_features; /* mask: compatible "may" features */ 125 | uint32_t incompat_features; /* mask: "must support" features */ 126 | uint32_t ro_compat_features; /* mask: force RO if unsupported */ 127 | uuid_t poolset_uuid; /* pool set UUID */ 128 | uuid_t uuid; /* UUID of this file */ 129 | uuid_t prev_part_uuid; /* prev part */ 130 | uuid_t next_part_uuid; /* next part */ 131 | uuid_t prev_repl_uuid; /* prev replica */ 132 | uuid_t next_repl_uuid; /* next replica */ 133 | uint64_t crtime; /* when created (seconds since epoch) */ 134 | struct arch_flags arch_flags; /* architecture identification flags */ 135 | unsigned char unused[3944]; /* must be zero */ 136 | uint64_t checksum; /* checksum of above fields */ 137 | }; 138 | 139 | int util_checksum(void *addr, size_t len, uint64_t *csump, int insert); 140 | int util_convert_hdr(struct pool_hdr *hdrp); 141 | int util_get_arch_flags(struct arch_flags *arch_flags); 142 | int util_check_arch_flags(const struct arch_flags *arch_flags); 143 | 144 | /* 145 | * macros for micromanaging range protections for the debug version 146 | */ 147 | #ifdef DEBUG 148 | 149 | #define RANGE_RO(addr, len) ASSERT(util_range_ro(addr, len) >= 0) 150 | #define RANGE_RW(addr, len) ASSERT(util_range_rw(addr, len) >= 0) 151 | 152 | #else 153 | 154 | /* nondebug version */ 155 | #define RANGE_RO(addr, len) 156 | #define RANGE_RW(addr, len) 157 | 158 | #endif /* DEBUG */ 159 | 160 | /* 161 | * pool sets & replicas 162 | */ 163 | #define POOLSET_HDR_SIG "PMEMPOOLSET" 164 | #define POOLSET_HDR_SIG_LEN 11 /* does NOT include '\0' */ 165 | 166 | #define POOLSET_REPLICA_SIG "REPLICA" 167 | #define POOLSET_REPLICA_SIG_LEN 7 /* does NOT include '\0' */ 168 | 169 | struct pool_set_part { 170 | /* populated by a pool set file parser */ 171 | const char *path; 172 | size_t filesize; /* aligned to page size */ 173 | int fd; 174 | int created; /* indicates newly created (zeroed) file */ 175 | 176 | /* util_poolset_open/create */ 177 | void *hdr; /* base address of header */ 178 | size_t hdrsize; /* size of the header mapping */ 179 | void *addr; /* base address of the mapping */ 180 | size_t size; /* size of the mapping - page aligned */ 181 | int rdonly; 182 | uuid_t uuid; 183 | }; 184 | 185 | struct pool_replica { 186 | unsigned nparts; 187 | size_t repsize; /* total size of all the parts (mappings) */ 188 | int is_pmem; /* true if all the parts are in PMEM */ 189 | struct pool_set_part part[]; 190 | }; 191 | 192 | struct pool_set { 193 | unsigned nreplicas; 194 | uuid_t uuid; 195 | int rdonly; 196 | int zeroed; /* true if all the parts are new files */ 197 | size_t poolsize; /* the smallest replica size */ 198 | struct pool_replica *replica[]; 199 | }; 200 | 201 | /* 202 | * Structure for binary version of uuid. From RFC4122, 203 | * https://tools.ietf.org/html/rfc4122 204 | */ 205 | struct uuid { 206 | uint32_t time_low; 207 | uint16_t time_mid; 208 | uint16_t time_hi_and_ver; 209 | uint8_t clock_seq_hi; 210 | uint8_t clock_seq_low; 211 | uint8_t node[6]; 212 | }; 213 | 214 | void util_init(void); 215 | 216 | int util_range_ro(void *addr, size_t len); 217 | int util_range_rw(void *addr, size_t len); 218 | int util_range_none(void *addr, size_t len); 219 | 220 | int util_is_zeroed(const void *addr, size_t len); 221 | 222 | int util_feature_check(struct pool_hdr *hdrp, uint32_t incompat, 223 | uint32_t ro_compat, uint32_t compat); 224 | 225 | char *util_map_hint_unused(void *addr, size_t len, size_t align); 226 | char *util_map_hint(size_t len, size_t req_align); 227 | 228 | int util_poolset_parse(const char *path, int fd, struct pool_set **setp); 229 | void util_poolset_close(struct pool_set *set, int del); 230 | void util_poolset_free(struct pool_set *set); 231 | int util_poolset_chmod(struct pool_set *set, mode_t mode); 232 | void util_poolset_fdclose(struct pool_set *set); 233 | 234 | int util_file_create(const char *path, size_t size, size_t minsize); 235 | int util_file_open(const char *path, size_t *size, size_t minsize, int flags); 236 | int util_uuid_to_string(uuid_t u, char *buf); 237 | int util_uuid_from_string(const char uuid[POOL_HDR_UUID_STR_LEN], 238 | struct uuid *ud); 239 | int util_uuid_generate(uuid_t uuid); 240 | 241 | int util_pool_create(struct pool_set **setp, const char *path, size_t poolsize, 242 | size_t minsize, size_t hdrsize, const char *sig, 243 | uint32_t major, uint32_t compat, uint32_t incompat, uint32_t ro_compat); 244 | int util_pool_open_nocheck(struct pool_set **setp, const char *path, int rdonly, 245 | size_t hdrsize); 246 | int util_pool_open(struct pool_set **setp, const char *path, int rdonly, 247 | size_t minsize, size_t hdrsize, const char *sig, 248 | uint32_t major, uint32_t compat, uint32_t incompat, uint32_t ro_compat); 249 | 250 | 251 | #define COMPILE_ERROR_ON(cond) ((void)sizeof (char[(cond) ? -1 : 1])) 252 | 253 | /* setbit macro substitution which properly deals with types */ 254 | static inline void util_setbit(uint8_t *b, uint32_t i) 255 | { 256 | b[i / 8] = (uint8_t)(b[i / 8] | (uint8_t)(1 << (i % 8))); 257 | } 258 | #define util_isset(a, i) isset(a, i) 259 | #define util_isclr(a, i) isclr(a, i) 260 | 261 | #if !defined(likely) 262 | #if defined(__GNUC__) 263 | #define likely(x) __builtin_expect(!!(x), 1) 264 | #define unlikely(x) __builtin_expect(!!(x), 0) 265 | #else 266 | #define likely(x) (!!(x)) 267 | #define unlikely(x) (!!(x)) 268 | #endif 269 | #endif 270 | -------------------------------------------------------------------------------- /libpmem/valgrind_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Intel Corporation 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * * Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * * Neither the name of Intel Corporation nor the names of its 17 | * contributors may be used to endorse or promote products derived 18 | * from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* 34 | * valgrind_internal.h -- internal definitions for valgrind macros 35 | */ 36 | 37 | #ifdef USE_VALGRIND 38 | #define USE_VG_PMEMCHECK 39 | #define USE_VG_HELGRIND 40 | #define USE_VG_MEMCHECK 41 | #endif 42 | 43 | #if defined(USE_VG_PMEMCHECK) || defined(USE_VG_HELGRIND) ||\ 44 | defined(USE_VG_MEMCHECK) 45 | extern unsigned _On_valgrind; 46 | #define On_valgrind __builtin_expect(_On_valgrind, 0) 47 | #include 48 | #else 49 | #define On_valgrind (0) 50 | #endif 51 | 52 | #ifdef USE_VG_HELGRIND 53 | #include 54 | 55 | #define VALGRIND_ANNOTATE_HAPPENS_BEFORE(obj) do {\ 56 | if (On_valgrind) \ 57 | ANNOTATE_HAPPENS_BEFORE((obj));\ 58 | } while (0) 59 | 60 | #define VALGRIND_ANNOTATE_HAPPENS_AFTER(obj) do {\ 61 | if (On_valgrind) \ 62 | ANNOTATE_HAPPENS_AFTER((obj));\ 63 | } while (0) 64 | 65 | #else 66 | 67 | #define VALGRIND_ANNOTATE_HAPPENS_BEFORE(obj) do { (void)(obj); } while (0) 68 | 69 | #define VALGRIND_ANNOTATE_HAPPENS_AFTER(obj) do { (void)(obj); } while (0) 70 | 71 | #endif 72 | 73 | #ifdef USE_VG_PMEMCHECK 74 | 75 | #include 76 | 77 | #define VALGRIND_REGISTER_PMEM_MAPPING(addr, len) do {\ 78 | if (On_valgrind)\ 79 | VALGRIND_PMC_REGISTER_PMEM_MAPPING((addr), (len));\ 80 | } while (0) 81 | 82 | #define VALGRIND_REGISTER_PMEM_FILE(desc, base_addr, size, offset) do {\ 83 | if (On_valgrind)\ 84 | VALGRIND_PMC_REGISTER_PMEM_FILE((desc), (base_addr), (size), \ 85 | (offset));\ 86 | } while (0) 87 | 88 | #define VALGRIND_REMOVE_PMEM_MAPPING(addr, len) do {\ 89 | if (On_valgrind)\ 90 | VALGRIND_PMC_REMOVE_PMEM_MAPPING((addr), (len));\ 91 | } while (0) 92 | 93 | #define VALGRIND_CHECK_IS_PMEM_MAPPING(addr, len) do {\ 94 | if (On_valgrind)\ 95 | VALGRIND_PMC_CHECK_IS_PMEM_MAPPING((addr), (len));\ 96 | } while (0) 97 | 98 | #define VALGRIND_PRINT_PMEM_MAPPINGS do {\ 99 | if (On_valgrind)\ 100 | VALGRIND_PMC_PRINT_PMEM_MAPPINGS;\ 101 | } while (0) 102 | 103 | #define VALGRIND_DO_FLUSH(addr, len) do {\ 104 | if (On_valgrind)\ 105 | VALGRIND_PMC_DO_FLUSH((addr), (len));\ 106 | } while (0) 107 | 108 | #define VALGRIND_DO_FENCE do {\ 109 | if (On_valgrind)\ 110 | VALGRIND_PMC_DO_FENCE;\ 111 | } while (0) 112 | 113 | #define VALGRIND_DO_COMMIT do {\ 114 | if (On_valgrind)\ 115 | VALGRIND_PMC_DO_COMMIT;\ 116 | } while (0) 117 | 118 | #define VALGRIND_DO_PERSIST(addr, len) do {\ 119 | if (On_valgrind) {\ 120 | VALGRIND_PMC_DO_FLUSH((addr), (len));\ 121 | VALGRIND_PMC_DO_FENCE;\ 122 | VALGRIND_PMC_DO_COMMIT;\ 123 | VALGRIND_PMC_DO_FENCE;\ 124 | }\ 125 | } while (0) 126 | 127 | #define VALGRIND_SET_CLEAN(addr, len) do {\ 128 | if (On_valgrind)\ 129 | VALGRIND_PMC_SET_CLEAN(addr, len);\ 130 | } while (0) 131 | 132 | #define VALGRIND_WRITE_STATS do {\ 133 | if (On_valgrind)\ 134 | VALGRIND_PMC_WRITE_STATS;\ 135 | } while (0) 136 | 137 | #define VALGRIND_LOG_STORES do {\ 138 | if (On_valgrind)\ 139 | VALGRIND_PMC_LOG_STORES;\ 140 | } while (0) 141 | 142 | #define VALGRIND_NO_LOG_STORES do {\ 143 | if (On_valgrind)\ 144 | VALGRIND_PMC_NO_LOG_STORES;\ 145 | } while (0) 146 | 147 | #define VALGRIND_ADD_LOG_REGION(addr, len) do {\ 148 | if (On_valgrind)\ 149 | VALGRIND_PMC_ADD_LOG_REGION((addr), (len));\ 150 | } while (0) 151 | 152 | #define VALGRIND_REMOVE_LOG_REGION(addr, len) do {\ 153 | if (On_valgrind)\ \ 154 | VALGRIND_PMC_REMOVE_LOG_REGION((addr), (len));\ 155 | } while (0) 156 | 157 | #define VALGRIND_FULL_REORDER do {\ 158 | if (On_valgrind)\ 159 | VALGRIND_PMC_FULL_REORDER;\ 160 | } while (0) 161 | 162 | #define VALGRIND_PARTIAL_REORDER do {\ 163 | if (On_valgrind)\ 164 | VALGRIND_PMC_PARTIAL_REORDER;\ 165 | } while (0) 166 | 167 | #define VALGRIND_ONLY_FAULT do {\ 168 | if (On_valgrind)\ 169 | VALGRIND_PMC_ONLY_FAULT;\ 170 | } while (0) 171 | 172 | #define VALGRIND_STOP_REORDER_FAULT do {\ 173 | if (On_valgrind)\ 174 | VALGRIND_PMC_STOP_REORDER_FAULT;\ 175 | } while (0) 176 | 177 | #define VALGRIND_START_TX do {\ 178 | if (On_valgrind)\ 179 | VALGRIND_PMC_START_TX;\ 180 | } while (0) 181 | 182 | #define VALGRIND_START_TX_N(txn) do {\ 183 | if (On_valgrind)\ 184 | VALGRIND_PMC_START_TX_N(txn);\ 185 | } while (0) 186 | 187 | #define VALGRIND_END_TX do {\ 188 | if (On_valgrind)\ 189 | VALGRIND_PMC_END_TX;\ 190 | } while (0) 191 | 192 | #define VALGRIND_END_TX_N(txn) do {\ 193 | if (On_valgrind)\ 194 | VALGRIND_PMC_END_TX_N(txn);\ 195 | } while (0) 196 | 197 | #define VALGRIND_ADD_TO_TX(addr, len) do {\ 198 | if (On_valgrind)\ 199 | VALGRIND_PMC_ADD_TO_TX(addr, len);\ 200 | } while (0) 201 | 202 | #define VALGRIND_ADD_TO_TX_N(txn, addr, len) do {\ 203 | if (On_valgrind)\ 204 | VALGRIND_PMC_ADD_TO_TX_N(txn, addr, len);\ 205 | } while (0) 206 | 207 | #define VALGRIND_REMOVE_FROM_TX(addr, len) do {\ 208 | if (On_valgrind)\ 209 | VALGRIND_PMC_REMOVE_FROM_TX(addr, len);\ 210 | } while (0) 211 | 212 | #define VALGRIND_REMOVE_FROM_TX_N(txn, addr, len) do {\ 213 | if (On_valgrind)\ 214 | VALGRIND_PMC_REMOVE_FROM_TX_N(txn, addr, len);\ 215 | } while (0) 216 | 217 | #define VALGRIND_ADD_TO_GLOBAL_TX_IGNORE(addr, len) do {\ 218 | if (On_valgrind)\ 219 | VALGRIND_PMC_ADD_TO_GLOBAL_TX_IGNORE(addr, len);\ 220 | } while (0) 221 | 222 | #else 223 | 224 | #define VALGRIND_REGISTER_PMEM_MAPPING(addr, len) do {\ 225 | (void) (addr);\ 226 | (void) (len);\ 227 | } while (0) 228 | 229 | #define VALGRIND_REGISTER_PMEM_FILE(desc, base_addr, size, offset) do {\ 230 | (void) (desc);\ 231 | (void) (base_addr);\ 232 | (void) (size);\ 233 | (void) (offset);\ 234 | } while (0) 235 | 236 | #define VALGRIND_REMOVE_PMEM_MAPPING(addr, len) do {\ 237 | (void) (addr);\ 238 | (void) (len);\ 239 | } while (0) 240 | 241 | #define VALGRIND_CHECK_IS_PMEM_MAPPING(addr, len) do {\ 242 | (void) (addr);\ 243 | (void) (len);\ 244 | } while (0) 245 | 246 | #define VALGRIND_PRINT_PMEM_MAPPINGS do {} while (0) 247 | 248 | #define VALGRIND_DO_FLUSH(addr, len) do {\ 249 | (void) (addr);\ 250 | (void) (len);\ 251 | } while (0) 252 | 253 | #define VALGRIND_DO_FENCE do {} while (0) 254 | 255 | #define VALGRIND_DO_COMMIT do {} while (0) 256 | 257 | #define VALGRIND_DO_PERSIST(addr, len) do {\ 258 | (void) (addr);\ 259 | (void) (len);\ 260 | } while (0) 261 | 262 | #define VALGRIND_SET_CLEAN(addr, len) do {\ 263 | (void) (addr);\ 264 | (void) (len);\ 265 | } while (0) 266 | 267 | #define VALGRIND_WRITE_STATS do {} while (0) 268 | 269 | #define VALGRIND_LOG_STORES do {} while (0) 270 | 271 | #define VALGRIND_NO_LOG_STORES do {} while (0) 272 | 273 | #define VALGRIND_ADD_LOG_REGION(addr, len) do {\ 274 | (void) (addr);\ 275 | (void) (len);\ 276 | } while (0) 277 | 278 | #define VALGRIND_REMOVE_LOG_REGION(addr, len) do {\ 279 | (void) (addr);\ 280 | (void) (len);\ 281 | } while (0) 282 | 283 | #define VALGRIND_FULL_REORDER do {} while (0) 284 | 285 | #define VALGRIND_PARTIAL_REORDER do {} while (0) 286 | 287 | #define VALGRIND_ONLY_FAULT do {} while (0) 288 | 289 | #define VALGRIND_STOP_REORDER_FAULT do {} while (0) 290 | 291 | #define VALGRIND_START_TX do {} while (0) 292 | 293 | #define VALGRIND_START_TX_N(txn) do { (void) (txn); } while (0) 294 | 295 | #define VALGRIND_END_TX do {} while (0) 296 | 297 | #define VALGRIND_END_TX_N(txn) do {\ 298 | (void) (txn);\ 299 | } while (0) 300 | 301 | #define VALGRIND_ADD_TO_TX(addr, len) do {\ 302 | (void) (addr);\ 303 | (void) (len);\ 304 | } while (0) 305 | 306 | #define VALGRIND_ADD_TO_TX_N(txn, addr, len) do {\ 307 | (void) (txn);\ 308 | (void) (addr);\ 309 | (void) (len);\ 310 | } while (0) 311 | 312 | #define VALGRIND_REMOVE_FROM_TX(addr, len) do {\ 313 | (void) (addr);\ 314 | (void) (len);\ 315 | } while (0) 316 | 317 | #define VALGRIND_REMOVE_FROM_TX_N(txn, addr, len) do {\ 318 | (void) (txn);\ 319 | (void) (addr);\ 320 | (void) (len);\ 321 | } while (0) 322 | 323 | #define VALGRIND_ADD_TO_GLOBAL_TX_IGNORE(addr, len) do {\ 324 | (void) (addr);\ 325 | (void) (len);\ 326 | } while (0) 327 | 328 | #endif 329 | 330 | #ifdef USE_VG_MEMCHECK 331 | 332 | #include 333 | 334 | #define VALGRIND_DO_DISABLE_ERROR_REPORTING do {\ 335 | if (On_valgrind)\ 336 | VALGRIND_DISABLE_ERROR_REPORTING;\ 337 | } while (0) 338 | 339 | #define VALGRIND_DO_ENABLE_ERROR_REPORTING do {\ 340 | if (On_valgrind)\ 341 | VALGRIND_ENABLE_ERROR_REPORTING;\ 342 | } while (0) 343 | 344 | #define VALGRIND_DO_CREATE_MEMPOOL(pool, rzB, is_zeroed) do {\ 345 | if (On_valgrind)\ 346 | VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed);\ 347 | } while (0) 348 | 349 | #define VALGRIND_DO_DESTROY_MEMPOOL(pool) do {\ 350 | if (On_valgrind)\ 351 | VALGRIND_DESTROY_MEMPOOL(pool);\ 352 | } while (0) 353 | 354 | #define VALGRIND_DO_MEMPOOL_ALLOC(pool, addr, size) do {\ 355 | if (On_valgrind && pool->is_master_replica)\ 356 | VALGRIND_MEMPOOL_ALLOC(pool, addr, size);\ 357 | } while (0) 358 | 359 | #define VALGRIND_DO_MEMPOOL_FREE(pool, addr) do {\ 360 | if (On_valgrind && pool->is_master_replica)\ 361 | VALGRIND_MEMPOOL_FREE(pool, addr);\ 362 | } while (0) 363 | 364 | #define VALGRIND_DO_MEMPOOL_CHANGE(pool, addrA, addrB, size) do {\ 365 | if (On_valgrind && pool->is_master_replica)\ 366 | VALGRIND_MEMPOOL_CHANGE(pool, addrA, addrB, size);\ 367 | } while (0) 368 | 369 | #define VALGRIND_DO_MAKE_MEM_DEFINED(pool, addr, len) do {\ 370 | if (On_valgrind && pool->is_master_replica)\ 371 | VALGRIND_MAKE_MEM_DEFINED(addr, len);\ 372 | } while (0) 373 | 374 | #define VALGRIND_DO_MAKE_MEM_UNDEFINED(pool, addr, len) do {\ 375 | if (On_valgrind && pool->is_master_replica)\ 376 | VALGRIND_MAKE_MEM_UNDEFINED(addr, len);\ 377 | } while (0) 378 | 379 | #define VALGRIND_DO_MAKE_MEM_NOACCESS(pool, addr, len) do {\ 380 | if (On_valgrind && pool->is_master_replica)\ 381 | VALGRIND_MAKE_MEM_NOACCESS(addr, len);\ 382 | } while (0) 383 | 384 | #define VALGRIND_DO_CHECK_MEM_IS_ADDRESSABLE(addr, len) do {\ 385 | if (On_valgrind)\ 386 | VALGRIND_CHECK_MEM_IS_ADDRESSABLE(addr, len);\ 387 | } while (0) 388 | 389 | #else 390 | 391 | #define VALGRIND_DO_DISABLE_ERROR_REPORTING do {} while (0) 392 | 393 | #define VALGRIND_DO_ENABLE_ERROR_REPORTING do {} while (0) 394 | 395 | #define VALGRIND_DO_CREATE_MEMPOOL(pool, rzB, is_zeroed)\ 396 | do { (void) (pool); (void) (rzB); (void) (is_zeroed); } while (0) 397 | 398 | #define VALGRIND_DO_DESTROY_MEMPOOL(pool)\ 399 | do { (void) (pool); } while (0) 400 | 401 | #define VALGRIND_DO_MEMPOOL_ALLOC(pool, addr, size)\ 402 | do { (void) (pool); (void) (addr); (void) (size); } while (0) 403 | 404 | #define VALGRIND_DO_MEMPOOL_FREE(pool, addr)\ 405 | do { (void) (pool); (void) (addr); } while (0) 406 | 407 | #define VALGRIND_DO_MEMPOOL_CHANGE(pool, addrA, addrB, size)\ 408 | do {\ 409 | (void) (pool); (void) (addrA); (void) (addrB); (void) (size);\ 410 | } while (0) 411 | 412 | #define VALGRIND_DO_MAKE_MEM_DEFINED(pool, addr, len)\ 413 | do { (void) (pool); (void) (addr); (void) (len); } while (0) 414 | 415 | #define VALGRIND_DO_MAKE_MEM_UNDEFINED(pool, addr, len)\ 416 | do { (void) (pool); (void) (addr); (void) (len); } while (0) 417 | 418 | #define VALGRIND_DO_MAKE_MEM_NOACCESS(pool, addr, len)\ 419 | do { (void) (pool); (void) (addr); (void) (len); } while (0) 420 | 421 | #define VALGRIND_DO_CHECK_MEM_IS_ADDRESSABLE(addr, len)\ 422 | do { (void) (addr); (void) (len); } while (0) 423 | 424 | #endif 425 | -------------------------------------------------------------------------------- /nvmd/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /DebugX/ 3 | /ReleaseX/ 4 | /Release/ 5 | -------------------------------------------------------------------------------- /nvmd/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | nvmd 4 | 5 | 6 | nvmds 7 | libpmem 8 | 9 | 10 | 11 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 12 | clean,full,incremental, 13 | 14 | 15 | 16 | 17 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 18 | full,incremental, 19 | 20 | 21 | 22 | 23 | 24 | org.eclipse.cdt.core.cnature 25 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 26 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /nvmd/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning 3 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 4 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error 5 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 6 | org.eclipse.cdt.codan.checkers.noreturn=Error 7 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 8 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error 9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 10 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error 11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 12 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning 13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 14 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error 15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 16 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning 17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} 18 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning 19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} 20 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error 21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 22 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning 23 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} 24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error 25 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error 27 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error 29 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error 31 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error 33 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error 35 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error 37 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info 39 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} 40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning 41 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error 43 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error 45 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error 47 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning 49 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning 51 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning 53 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} 54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning 55 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} 56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning 57 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} 58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error 59 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning 61 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning 63 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning 65 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} 66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error 67 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 68 | -------------------------------------------------------------------------------- /nvmd/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | -------------------------------------------------------------------------------- /nvmd/bin/usid_build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script should be run just before running the linker 3 | # It creates the nvm_type and nvm_extern definitions. 4 | 5 | # Cleanup last build 6 | echo usid_build called 7 | rm -f usid.c usid.json usid.o 8 | 9 | # construct usid.c from the .usd files 10 | CMD="usidmap -r=nvm_usid_register -c=./usid.c -d=./usid.json ./*.usd" 11 | echo " $CMD" 12 | $CMD 13 | X=$? 14 | if [ $X -ne 0 ] 15 | then 16 | echo " Status $X from usidmap" 17 | exit $X 18 | fi 19 | 20 | # compile usid.c 21 | CMD="gcc -O0 -g3 -c -I../../nvmd -I../../nvmds -fPIC -o ./usid.o ./usid.c" 22 | echo " $CMD" 23 | $CMD 24 | X=$? 25 | if [ $X -ne 0 ] 26 | then 27 | echo " Status $X from usidmap" 28 | exit $X 29 | fi 30 | -------------------------------------------------------------------------------- /nvmd/nvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvm.h - All Non-Volatile Memory includes for an application 43 | 44 | DESCRIPTION\n 45 | Including nvm.h will include all the .h files an application needs to 46 | use the NVM library and NVM extensions to C. 47 | 48 | */ 49 | 50 | #ifndef NVM_H 51 | #define NVM_H 52 | 53 | #include 54 | #include 55 | #include 56 | 57 | /** 58 | * A pointer to an nvm_heap is use as an opaque handle to a heap 59 | */ 60 | #ifdef NVM_EXT 61 | typedef persistent struct nvm_heap nvm_heap; 62 | #else 63 | typedef struct nvm_heap nvm_heap; 64 | #endif //NVM_EXT 65 | 66 | /** 67 | * A pointer to an nvm_mutex_array is use as an opaque handle to a 68 | * mutex array 69 | */ 70 | #ifdef NVM_EXT 71 | typedef persistent struct nvm_mutex_array nvm_mutex_array; 72 | #else 73 | typedef struct nvm_mutex_array nvm_mutex_array; 74 | #endif //NVM_EXT 75 | 76 | #ifndef NVM_USID_H 77 | #include "nvm_usid.h" 78 | #endif 79 | 80 | #ifndef NVM_MISC_H 81 | #include "nvm_misc.h" 82 | #endif 83 | 84 | #ifndef NVM_REGION_H 85 | #include "nvm_region.h" 86 | #endif 87 | 88 | #ifndef NVM_LOCKS_H 89 | #include "nvm_locks.h" 90 | #endif 91 | 92 | #ifndef NVM_HEAP_H 93 | #include "nvm_heap.h" 94 | #endif 95 | 96 | #ifndef NVM_TRANSACTION_H 97 | #include "nvm_transaction.h" 98 | #endif 99 | 100 | #endif /* NVM_H */ 101 | 102 | -------------------------------------------------------------------------------- /nvmd/nvm_data0.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvm_data0.h - NVM library private volatile data 43 | 44 | DESCRIPTION\n 45 | This file defines the application global and thread local data 46 | structures used by the library. All the volatile data used by the 47 | library can be navigated to through these structures. 48 | 49 | Theses declarations are private to the NVM library. 50 | */ 51 | 52 | 53 | #ifndef NVM_DATA0_H 54 | #define NVM_DATA0_H 55 | 56 | #ifndef NVMS_MISC_H 57 | #include "nvms_misc.h" 58 | #endif 59 | 60 | #ifndef NVMS_LOCKING_H 61 | #include "nvms_locking.h" 62 | #endif 63 | 64 | #ifndef NVMS_SLEEPING_H 65 | #include "nvms_sleeping.h" 66 | #endif 67 | 68 | #ifndef NVMS_MEMORY_H 69 | #include "nvms_memory.h" 70 | #endif 71 | 72 | #ifdef __cplusplus 73 | extern "C" 74 | { 75 | #endif 76 | typedef struct nvm_proc_data nvm_proc_data; 77 | typedef struct nvm_app_data nvm_app_data; 78 | typedef struct nvm_region_data nvm_region_data; 79 | typedef struct nvm_mapped_region nvm_mapped_region; 80 | typedef struct nvm_usid_map nvm_usid_map; 81 | typedef struct nvm_trans_table_data nvm_trans_table_data; 82 | typedef struct nvm_wait nvm_wait; 83 | typedef struct nvm_wait_list nvm_wait_list; 84 | 85 | #ifdef NVM_EXT 86 | /* Persistent struct types */ 87 | typedef persistent struct nvm_transaction nvm_transaction; 88 | typedef persistent struct nvm_region nvm_region; 89 | typedef persistent struct nvm_undo_blk nvm_undo_blk; 90 | #else 91 | /* Persistent struct types */ 92 | typedef struct nvm_transaction nvm_transaction; 93 | typedef struct nvm_region nvm_region; 94 | typedef struct nvm_undo_blk nvm_undo_blk; 95 | 96 | /* Self relative pointers for persistent types. */ 97 | NVM_SRP(nvm_transaction) 98 | NVM_SRP(nvm_region) 99 | NVM_SRP(nvm_undo_blk) 100 | #endif //NVM_EXT 101 | 102 | /* 103 | * These are the forward incomplete type definitions for all the undo 104 | * record types 105 | */ 106 | #ifdef NVM_EXT 107 | typedef persistent struct nvm_restore nvm_restore; 108 | typedef persistent struct nvm_lkrec nvm_lkrec; 109 | typedef persistent struct nvm_on_unlock nvm_on_unlock; 110 | typedef persistent struct nvm_savepnt nvm_savepnt; 111 | typedef persistent struct nvm_nested nvm_nested; 112 | typedef persistent struct nvm_on_abort nvm_on_abort; 113 | typedef persistent struct nvm_on_commit nvm_on_commit; 114 | #else 115 | typedef struct nvm_restore nvm_restore; 116 | typedef struct nvm_lkrec nvm_lkrec; 117 | typedef struct nvm_on_unlock nvm_on_unlock; 118 | typedef struct nvm_savepnt nvm_savepnt; 119 | typedef struct nvm_nested nvm_nested; 120 | typedef struct nvm_on_abort nvm_on_abort; 121 | typedef struct nvm_on_commit nvm_on_commit; 122 | NVM_SRP(nvm_restore) 123 | NVM_SRP(nvm_lkrec) 124 | NVM_SRP(nvm_on_unlock) 125 | NVM_SRP(nvm_savepnt) 126 | NVM_SRP(nvm_nested) 127 | NVM_SRP(nvm_on_abort) 128 | NVM_SRP(nvm_on_commit) 129 | #endif //NVM_EXT 130 | 131 | /** 132 | * This contains the thread private data. There is one copy of this struct 133 | * for each thread. The owning thread is the only thread that touches any 134 | * data in this struct. Thus there are no locks to cover the contents. The 135 | * thread root pointer points at an instance of this struct. 136 | */ 137 | struct nvm_thread_data 138 | { 139 | 140 | /** 141 | * If this thread is in the middle of upgrading a persistent struct 142 | * to a new type, then this points to the struct being upgraded. 143 | */ 144 | #ifdef NVM_EXT 145 | void ^upgrade_ptr; 146 | #else 147 | void *upgrade_ptr; 148 | #endif //NVM_EXT 149 | 150 | /** 151 | * If this thread is in the middle of upgrading a persistent struct 152 | * to a new type, then this points to the old type definition. 153 | */ 154 | const nvm_type *upgrade_type; 155 | 156 | /** 157 | * If this thread has an active transaction, then this points to 158 | * the NVM structure that manages the transaction. If there is 159 | * no current transaction then this is a null pointer. 160 | */ 161 | #ifdef NVM_EXT 162 | nvm_transaction ^transaction; 163 | #else 164 | nvm_transaction *transaction; 165 | #endif //NVM_EXT 166 | 167 | /** 168 | * If this thread has an active transaction, then this points to 169 | * the NVM region that the transaction operates on. 170 | */ 171 | #ifdef NVM_EXT 172 | nvm_region ^region; 173 | #else 174 | nvm_region *region; 175 | #endif //NVM_EXT 176 | 177 | /** 178 | * This is the current transaction nesting depth. It is maintained 179 | * here rather than calculating on every request to improve performance 180 | */ 181 | int txdepth; 182 | 183 | /** 184 | * If this platform requires flushing of each NVM cache line that is 185 | * modified, then this points to an array of addresses that need 186 | * flushing. This is used to reduce multiple flushes of the same 187 | * cache line by postponing the flush with a cache of pending flushes. 188 | * If this platform does not need flushes then this will be null. 189 | */ 190 | uint64_t *flush_cache; 191 | 192 | /** 193 | * If there is a flush cache then this is the right shift count to 194 | * convert an NVM address into an index into the flush cache. 195 | */ 196 | unsigned flush_cache_shift; 197 | 198 | /** 199 | * If there is a flush cache then this is a mask to extract the index 200 | * after the right shift. 201 | */ 202 | unsigned flush_cache_mask; 203 | 204 | /** 205 | * If there is a flush cache then this can be XOR'ed with an index to 206 | * get the alternate cache entry. This gets a 2 way associative cache. 207 | */ 208 | unsigned flush_cache_xor; 209 | 210 | /** 211 | * This is the number of base transactions executed by this thread. 212 | */ 213 | uint64_t trans_cnt; 214 | 215 | /** 216 | * This is the number of cache line flushes. 217 | */ 218 | uint64_t flush_cnt; 219 | 220 | /** 221 | * This is the number of persists done by this thread. 222 | */ 223 | uint64_t persist_cnt; 224 | 225 | /** 226 | * This is the number of persists done by this thread which only 227 | * persist a single store. 228 | */ 229 | uint64_t persist1_cnt; 230 | 231 | /** 232 | * This is the number of persists done for the purpose of generating 233 | * undo. 234 | */ 235 | uint64_t persist_undo; 236 | 237 | /** 238 | * This is the number of persists done for NVM mutex lock/unlock. 239 | */ 240 | uint64_t persist_lock; 241 | 242 | /** 243 | * This is the number of perisists done for tx begin/end, including 244 | * nested transaction begin/end. 245 | */ 246 | uint64_t persist_tx; 247 | 248 | /** 249 | * This is the number of persists for transaction commit excluding 250 | * any on commit call backs. 251 | */ 252 | uint64_t persist_commit; 253 | 254 | /** 255 | * This is the number of persists for transaction abort excluding 256 | * any on abort call backs. 257 | */ 258 | uint64_t persist_abort; 259 | 260 | /** 261 | * This is a local copy of the parameters from the service library to 262 | * speed up access. 263 | */ 264 | nvms_parameters params; 265 | }; 266 | typedef struct nvm_thread_data nvm_thread_data; 267 | 268 | /** 269 | * Return a pointer to the current thread data 270 | */ 271 | static inline nvm_thread_data * 272 | nvm_get_thread_data() 273 | { 274 | return(nvm_thread_data *)nvms_thread_get_ptr(); 275 | } 276 | 277 | /** 278 | * This contains the application global data. There is exactly one copy 279 | * of this struct shared by all threads. All application global data 280 | * can be reached from this struct except for the thread context created 281 | * by nvm_thread_init. The application root pointer points at this struct. 282 | */ 283 | struct nvm_app_data 284 | { 285 | /** 286 | * This is the mutex used to protect the app root struct, and 287 | * coordinate allocation of process root structs. 288 | */ 289 | nvms_mutex mutex; 290 | 291 | /** 292 | * This is the parameter data for this application returned by the 293 | * service library. This also appears in nvm_thread_data for access 294 | * when it is easier to find. 295 | */ 296 | nvms_parameters params; 297 | 298 | /** 299 | * This is the hash map used for looking up USID to global symbol 300 | * mappings. 301 | */ 302 | nvm_usid_map *usid_map; 303 | 304 | /** 305 | * The app_data ends with an array of pointers to region data. This 306 | * array is indexed by the nvm_desc descriptor return when a region 307 | * is attached to an application. Zero entries are available 308 | * descriptors. The actual size of the array is determined by the 309 | * max_regions parameter. 310 | */ 311 | nvm_region_data *regions[1]; 312 | 313 | }; 314 | 315 | /** 316 | * This is called when the shared library is loaded before main is 317 | * called. It does the one time initializations needed by the library. 318 | */ 319 | void nvm_init(void); 320 | 321 | /** 322 | * Return a pointer to the current application root struct 323 | */ 324 | static inline nvm_app_data * 325 | nvm_get_app_data() 326 | { 327 | return *(nvm_app_data**)nvms_app_ptr_addr(); 328 | } 329 | 330 | /* This is the array of pointers to nvm_types defined for this library. */ 331 | extern const nvm_type *nvm_usid_types[]; 332 | 333 | /* This is the array of pointers to nvm_externs defined for this library. */ 334 | extern const nvm_extern *nvm_usid_externs[]; 335 | 336 | /* These are the nvm_extern declarations for this library */ 337 | extern const nvm_extern nvm_extern_nvm_free_callback; 338 | 339 | #ifdef __cplusplus 340 | } 341 | #endif 342 | 343 | #endif /* NVM_DATA0_H */ 344 | 345 | -------------------------------------------------------------------------------- /nvmd/nvm_locks0.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvm_locks0.h - private declarations for NVM locking 43 | 44 | DESCRIPTION\n 45 | This contains the declarations for NVM locking that are 46 | private to the NVM library 47 | 48 | */ 49 | #ifndef NVMS_LOCKING_H 50 | #include "nvms_locking.h" 51 | #endif 52 | 53 | #ifndef NVMS_SLEEPING_H 54 | #include "nvms_sleeping.h" 55 | #endif 56 | 57 | #ifndef NVM_DATA0_H 58 | #include "nvm_data0.h" 59 | #endif 60 | 61 | #ifndef NVM_REGION0_H 62 | #include "nvm_region0.h" 63 | #endif 64 | 65 | 66 | #ifndef NVM_LOCKS0_H 67 | #define NVM_LOCKS0_H 68 | 69 | #ifdef __cplusplus 70 | extern "C" 71 | { 72 | #endif 73 | /** 74 | * This is the actual struct for an NVM mutex. The opaque type nvm_mutex in 75 | * nvm_locks.h is what applications use to declare mutexes in persistent 76 | * structs. 77 | */ 78 | #ifdef NVM_EXT 79 | persistent struct nvm_amutex 80 | tag("Mutex to lock NVM data structures for a transaction") 81 | alignas(8) 82 | size(8) 83 | { 84 | /** Force 8 byte alignment without precompiler support. */ 85 | uint64_t _align[0]; 86 | 87 | /** 88 | * This describes how the mutex is currently locked. If it is zero, 89 | * then there is no lock. If it is positive, then it holds the 90 | * transaction slot number of the exclusive holder. If it is negative, 91 | * then it is the count of share lock holders. 92 | */ 93 | int16_t owners; 94 | 95 | /** 96 | * This is the number of threads that are blocked waiting to acquire 97 | * an exclusive lock on this nvm_amutex. 98 | */ 99 | transient 100 | uint16_t x_waiters; 101 | 102 | /** 103 | * This is the number of threads that are blocked waiting to acquire 104 | * a share lock on this nvm_amutex. 105 | */ 106 | transient 107 | uint16_t s_waiters; 108 | 109 | /** 110 | * This is the lock level that the nvm_amutex was initialized with. It 111 | * never changes after initialization. A level of zero means only 112 | * no-wait locking is allowed. Otherwise it is an error to do a wait 113 | * lock if another lock is held on an nvm_amutex with a greater than or 114 | * equal level. 115 | */ 116 | uint8_t level; 117 | 118 | /** 119 | * This is 0 if nvm_mutex_init has not been called to initialize this 120 | * mutex. Attempting to lock an uninitialized mutex will fire an 121 | * assert. 122 | */ 123 | uint8_t initialized; 124 | }; 125 | typedef persistent struct nvm_amutex nvm_amutex; 126 | #else 127 | struct nvm_amutex 128 | { 129 | /** Force 8 byte alignment without precompiler support. */ 130 | uint64_t _align[0]; 131 | 132 | /** 133 | * This describes how the mutex is currently locked. If it is zero, 134 | * then there is no lock. If it is positive, then it holds the 135 | * transaction slot number of the exclusive holder. If it is negative, 136 | * then it is the count of share lock holders. 137 | */ 138 | int16_t owners; 139 | 140 | /** 141 | * This is the number of threads that are blocked waiting to acquire 142 | * an exclusive lock on this nvm_amutex. 143 | */ 144 | uint16_t x_waiters; 145 | 146 | /** 147 | * This is the number of threads that are blocked waiting to acquire 148 | * a share lock on this nvm_amutex. 149 | */ 150 | uint16_t s_waiters; 151 | 152 | /** 153 | * This is the lock level that the nvm_amutex was initialized with. It 154 | * never changes after initialization. A level of zero means only 155 | * no-wait locking is allowed. Otherwise it is an error to do a wait 156 | * lock if another lock is held on an nvm_amutex with a greater than or 157 | * equal level. 158 | */ 159 | uint8_t level; 160 | 161 | /** 162 | * This is 0 if nvm_mutex_init has not been called to initialize this 163 | * mutex. Attempting to lock an uninitialized mutex will fire an 164 | * assert. 165 | */ 166 | uint8_t initialized; 167 | }; 168 | typedef struct nvm_amutex nvm_amutex; 169 | NVM_SRP(nvm_amutex) 170 | #endif //NVM_EXT 171 | 172 | /** 173 | * This is an array of NVM mutexes that can cover a large number of 174 | * persistent structs. The address of a struct is hashed to pick one 175 | * mutex from the array. The size of the array is specified when it 176 | * is created. The larger the array the fewer false collisions there 177 | * will be. 178 | */ 179 | #ifdef NVM_EXT 180 | persistent struct nvm_mutex_array 181 | USID("334f c14d 262d a28c e5e0 4e9e 3750 9c23") 182 | tag("Array of mutexes to lock objects by their address") 183 | alignas(8) 184 | size(24) 185 | { 186 | /** 187 | * This is the number of mutexes in the array. 188 | */ 189 | uint32_t count; 190 | 191 | /** 192 | * This is used to track the number of destroyed mutexes in 193 | * nvm_destroy_mutex_array so that rollback can reinitialize them 194 | */ 195 | uint32_t destroyed; 196 | 197 | /** 198 | * This is the extensible array of the actual mutexes 199 | */ 200 | nvm_amutex mutexes[]; 201 | }; 202 | #else 203 | struct nvm_mutex_array 204 | { 205 | /** 206 | * The USID that maps to the nvm_type for nvm_mutex_array 207 | */ 208 | nvm_usid type_usid; 209 | 210 | /** 211 | * This is the number of mutexes in the array. 212 | */ 213 | uint32_t count; 214 | 215 | /** 216 | * This is used to track the number of destroyed mutexes in 217 | * nvm_destroy_mutex_array so that rollback can reinitialize them 218 | */ 219 | uint32_t destroyed; 220 | 221 | /** 222 | * This is the extensible array of the actual mutexes 223 | */ 224 | nvm_amutex mutexes[]; 225 | }; 226 | NVM_SRP(nvm_mutex_array); 227 | #endif //NVM_EXT 228 | 229 | /* Internal version of nvm_create_mutex_array that allows levels over 200 */ 230 | #ifdef NVM_EXT 231 | nvm_mutex_array ^nvm_create_mutex_array1@( 232 | nvm_heap ^heap, 233 | uint32_t count, 234 | uint8_t level 235 | ); 236 | #else 237 | nvm_mutex_array *nvm_create_mutex_array1( 238 | nvm_heap *heap, 239 | uint32_t count, 240 | uint8_t level 241 | ); 242 | #endif 243 | 244 | /** 245 | * There is an nvm_wait struct for every NVM mutex that has a waiter or 246 | * recently had waiters. 247 | */ 248 | #ifdef NVM_EXT 249 | struct nvm_wait 250 | { 251 | struct nvm_wait *link; 252 | nvms_cond cond; 253 | nvm_amutex ^nvmx; 254 | }; 255 | #else 256 | struct nvm_wait 257 | { 258 | struct nvm_wait *link; 259 | nvms_cond cond; 260 | nvm_amutex *nvmx; 261 | }; 262 | #endif //NVM_EXT 263 | 264 | /** 265 | * The nvm_wait structures are distributed into hash buckets based on the 266 | * address of the nvm_amutex. An nvm_wait_list struct is one bucket in the 267 | * hash table. 268 | */ 269 | struct nvm_wait_list 270 | { 271 | nvms_mutex mutex; 272 | nvm_wait *head; 273 | }; 274 | 275 | /** 276 | * This defines the hash table used to wait for an nvm_amutex to be available 277 | * for locking. There is one of these in application global memory for 278 | * each region. 279 | */ 280 | struct nvm_wait_table 281 | { 282 | uint32_t buckets; // the number of buckets in the hash table 283 | nvm_wait_list table[]; 284 | }; 285 | typedef struct nvm_wait_table nvm_wait_table; 286 | 287 | /** 288 | * Allocate a wait table for threads that need to block on NVM mutexes in 289 | * this region. It is allocated in volatile application global memory. The 290 | * volatile mutex in each bucket is initialized. When this returns success, 291 | * the region data will point at the allocated waiter table. 292 | * 293 | * @param[in] rd 294 | * Pointer to the region data for the region containing the NVM mutexes 295 | * 296 | * @param[in] sz 297 | * The number of buckets to allocate for the wait table. 298 | * 299 | * @return 300 | * Returns 1 on success and 0 if allocation or service mutex creation fails 301 | */ 302 | int nvm_wait_table_create(nvm_region_data *rd, unsigned sz); 303 | 304 | /** 305 | * This is called to cleanup the waiter table when detaching a region or 306 | * cleaning up after a failed attach. An assert fires if there are any 307 | * threads waiting on any mutexes in this region when this is called. The 308 | * easiest way to ensure this is to verify there are no active transactions. 309 | * 310 | * This has no effect on any persistent data so there is no need to call 311 | * this if the entire application is terminating. 312 | * 313 | * On return the pointer to the waiter table in the region data will be 314 | * cleared. If it is already cleared then this will return without doing 315 | * anything. 316 | * 317 | * @param[in] rd 318 | * Pointer to the region data for the region containing the waiter table 319 | * 320 | * @return 321 | * 1 if successful and 0 if we had to give up because we could not wait 322 | */ 323 | int nvm_wait_table_destroy(nvm_region_data *rd); 324 | 325 | /** 326 | * Internal version of nvm_mutex_init that allows levels over 200 327 | */ 328 | #ifdef NVM_EXT 329 | void nvm_mutex_init1( 330 | nvm_amutex ^mutex, 331 | uint8_t level 332 | ); 333 | #else 334 | void nvm_mutex_init1( 335 | nvm_amutex *mutex, 336 | uint8_t level 337 | ); 338 | #endif //NVM_EXT 339 | 340 | /** 341 | * This is called to unlock an NVM mutex when a transaction commits or an 342 | * NVM lock undo record is applied for rollback or commit. It is given the 343 | * undo record that was constructed when the lock was acquired. 344 | * 345 | * @param tx[in] 346 | * The transaction that owns the lock. 347 | * 348 | * @param td[in] 349 | * The thread private data for the thread owning the transaction. 350 | * 351 | * @param lk[in] 352 | * The lock undo record created by nvm_lock. 353 | */ 354 | #ifdef NVM_EXT 355 | void nvm_unlock@( 356 | nvm_transaction ^tx, 357 | nvm_thread_data *td, 358 | nvm_lkrec ^lk 359 | ); 360 | #else 361 | void nvm_unlock( 362 | nvm_transaction *tx, 363 | nvm_thread_data *td, 364 | nvm_lkrec *lk 365 | ); 366 | #endif //NVM_EXT 367 | 368 | /** 369 | * After recovery discovers all the transactions threads and before doing 370 | * recovery, it needs to resolve the state of any NVM locks that were in 371 | * flux when the NVM region was last detached. For every dead transaction 372 | * that had a lock in the middle of acquisition or release, this routine 373 | * is called to resolve its state. 374 | * 375 | * @param ttd[in] 376 | * Transaction table volatile data for the region being recovered. 377 | * 378 | * @param lk[in] 379 | * Address of a lock that might need its state repaired. 380 | */ 381 | #ifdef NVM_EXT 382 | void nvm_recover_lock(nvm_trans_table_data *ttd, nvm_lkrec ^lk); 383 | #else 384 | void nvm_recover_lock(nvm_trans_table_data *ttd, nvm_lkrec *lk); 385 | #endif //NVM_EXT 386 | #ifdef __cplusplus 387 | } 388 | #endif 389 | 390 | #endif /* NVM_LOCKS0_H */ 391 | 392 | -------------------------------------------------------------------------------- /nvmd/nvm_usid0.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvm_usid0.h - private usid management declarations 43 | 44 | DESCRIPTION\n 45 | This contains the declarations for NVM usid management that are private 46 | to the NVM library. 47 | 48 | */ 49 | 50 | #ifndef NVM_USID0_H 51 | #define NVM_USID0_H 52 | 53 | #ifdef __cplusplus 54 | extern "C" 55 | { 56 | #endif 57 | /** 58 | * This is the struct that maps USID's to globals in the executable. 59 | * 60 | * There is no mutex to protect this struct since it is constructed by 61 | * the first thread at process initialization and is read only from then 62 | * on. 63 | */ 64 | struct nvm_usid_map 65 | { 66 | /** 67 | * This is the number of entries in the table. It is always a power of 68 | * 2. About half of the entries should be unused for efficient 69 | * operation. 70 | * 71 | * In the current implementation the size is a configuration constant 72 | * that must be specified for the application. It would be possible to 73 | * recode this to grow the map as needed. 74 | */ 75 | size_t size; 76 | 77 | /** 78 | * This is the number of entries that are actually in use. If it gets 79 | * too large, symbol lookup will become slow because there will be 80 | * many collisions. 81 | */ 82 | size_t used; 83 | 84 | /** 85 | * This is the actual hash map itself. This must be the last field 86 | * because it is sized based on the application. 87 | */ 88 | nvm_extern map[]; 89 | }; 90 | 91 | /* 92 | * function to register USID mappings for the NVM library 93 | * 94 | * @return 1 if all mappings saved, 0 if there are redundant mappings that 95 | * are ignored. 96 | */ 97 | #ifdef NVM_EXT 98 | int nvm_usid_register(void); 99 | #else 100 | int nvm_usidmap_register(void); 101 | #endif //NVM_EXT 102 | 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* NVM_USID0_H */ 109 | 110 | -------------------------------------------------------------------------------- /nvmds/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /DebugX/ 3 | /Release/ 4 | /ReleaseX/ 5 | -------------------------------------------------------------------------------- /nvmds/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | nvmds 4 | 5 | 6 | libpmem 7 | 8 | 9 | 10 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 11 | clean,full,incremental, 12 | 13 | 14 | 15 | 16 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 17 | full,incremental, 18 | 19 | 20 | 21 | 22 | 23 | org.eclipse.cdt.core.cnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /nvmds/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning 3 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 4 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error 5 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 6 | org.eclipse.cdt.codan.checkers.noreturn=Error 7 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 8 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error 9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 10 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error 11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 12 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning 13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 14 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error 15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 16 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning 17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} 18 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning 19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} 20 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error 21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 22 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning 23 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} 24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error 25 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error 27 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error 29 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error 31 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error 33 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error 35 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error 37 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info 39 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} 40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning 41 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error 43 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error 45 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error 47 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning 49 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning 51 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning 53 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} 54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning 55 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} 56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning 57 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} 58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error 59 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning 61 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning 63 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning 65 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} 66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error 67 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 68 | -------------------------------------------------------------------------------- /nvmds/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | -------------------------------------------------------------------------------- /nvmds/nvms_locking.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 4 | 5 | The Universal Permissive License (UPL), Version 1.0 6 | 7 | Subject to the condition set forth below, permission is hereby granted to any 8 | person obtaining a copy of this software, associated documentation and/or data 9 | (collectively the "Software"), free of charge and under any and all copyright 10 | rights in the Software, and any and all patent rights owned or freely 11 | licensable by each licensor hereunder covering either (i) the unmodified 12 | Software as contributed to or provided by such licensor, or (ii) the Larger 13 | Works (as defined below), to deal in both 14 | 15 | (a) the Software, and 16 | 17 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 18 | one is included with the Software (each a "Larger Work" to which the Software 19 | is contributed by such licensors), 20 | 21 | without restriction, including without limitation the rights to copy, create 22 | derivative works of, display, perform, and distribute the Software and make, 23 | use, sell, offer for sale, import, export, have made, and have sold the 24 | Software and the Larger Work(s), and to sublicense the foregoing rights on 25 | either these or other terms. 26 | 27 | This license is subject to the following condition: 28 | 29 | The above copyright notice and either this complete permission notice or at a 30 | minimum a reference to the UPL must be included in all copies or substantial 31 | portions of the Software. 32 | 33 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 34 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 35 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 36 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 37 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 38 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 39 | SOFTWARE. 40 | */ 41 | /**\file 42 | NAME\n 43 | nvms_locking.c - NVM services for volatile memory locking 44 | 45 | DESCRIPTION\n 46 | The NVM library needs mutexes for coordinating access to volatile memory 47 | between threads. This file provides an implementation of these mutexes 48 | based on pthread mutexes. 49 | 50 | */ 51 | #define _XOPEN_SOURCE 700 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | #include "nvms_locking.h" 60 | #include "nvms_sleeping.h" 61 | #include "nvms_misc.h" 62 | /** 63 | * This allocates and initializes an application global mutex. 64 | * 65 | * If there are any errors then errno is set and the return value is zero. 66 | * 67 | * @return 68 | * An opaque handle to the mutex, or zero if there is an error. 69 | */ 70 | nvms_mutex nvms_create_mutex(void) 71 | { 72 | /* Create a mutex attribute and set the type to do error checking */ 73 | pthread_mutexattr_t attr; 74 | pthread_mutexattr_init(&attr); 75 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); 76 | 77 | /* allocate and initialize a mutex */ 78 | pthread_mutex_t *mx = malloc(sizeof(pthread_mutex_t)); 79 | if (!mx) 80 | { 81 | return NULL; 82 | } 83 | int ret = pthread_mutex_init(mx, &attr); 84 | if (ret != 0) 85 | { 86 | errno = ret; 87 | return NULL; 88 | } 89 | return mx; 90 | } 91 | /** 92 | * This destroys an application global mutex freeing the memory it consumed. 93 | * The mutex must not be locked when destroyed. 94 | * 95 | * @param[in] mutex 96 | * Handle to the mutex to destroy. 97 | */ 98 | void nvms_destroy_mutex(nvms_mutex mutex) 99 | { 100 | pthread_mutex_t *mx = mutex; 101 | int ret = pthread_mutex_destroy(mx); 102 | if (ret != 0) 103 | nvms_assert_fail("Invalid nvms_mutex on destroy"); 104 | free(mx); 105 | } 106 | /** 107 | * When this returns 1 the calling thread has an exclusive lock on the 108 | * indicated mutex. If the wait parameter is true then the thread might 109 | * sleep waiting for another thread to release its lock. If wait is false 110 | * then 0 is returned rather than wait for the holder to release its lock. 111 | * 112 | * @param[in] mutex 113 | * Handle to the mutex to lock. 114 | * 115 | * @param[in] wait 116 | * If 0 thread returns 0 rather than wait for a conflicting lock to be 117 | * released. 118 | * 119 | * @return 120 | * 1 if lock acquired, 0 if not acquired due to conflicting lock. 121 | */ 122 | int nvms_lock_mutex( 123 | nvms_mutex mutex, 124 | int wait 125 | ) 126 | { 127 | pthread_mutex_t *mx = mutex; 128 | int ret; 129 | if (wait) 130 | ret = pthread_mutex_lock(mx); 131 | else 132 | ret = pthread_mutex_trylock(mx); 133 | if (ret && ret != EBUSY) 134 | nvms_assert_fail("Invalid nvms_mutex on lock"); 135 | if (ret) 136 | { 137 | errno = ret; 138 | return 0; 139 | } 140 | return 1; 141 | } 142 | /** 143 | * When this returns the calling thread no longer has a lock on the 144 | * indicated mutex. This might wakeup another thread waiting for a lock. 145 | * The calling thread must have locked the mutex via nvms_lock_mutex. 146 | * If the caller previously registered a recovery operation, the opcode is 147 | * cleared to zero before the mutex is unlocked. 148 | * 149 | * @param[in] mutex 150 | * Handle to the mutex to unlock. 151 | */ 152 | void nvms_unlock_mutex( 153 | nvms_mutex mutex 154 | ) 155 | { 156 | pthread_mutex_t *mx = mutex; 157 | int ret = pthread_mutex_unlock(mx); 158 | if (ret) 159 | nvms_assert_fail("Invalid or not locked nvms_mutex on unlock"); 160 | } 161 | 162 | 163 | /** 164 | * This does a 2 byte compare and swap of a location in NVM or volatile 165 | * memory. The return value is the value of the location when the CAS 166 | * executed. If it is equal to the old value then the swap succeeded. 167 | * 168 | * @param[in] ptr 169 | * The address of location to modify 170 | * 171 | * @param[in] oldval 172 | * The expected value to change 173 | * 174 | * @param[in] newval 175 | * The new value to store if compare is successful 176 | * 177 | * @return 178 | * The value that was in memory when the CAS fetched the location 179 | */ 180 | uint16_t nvms_cas2( 181 | volatile uint16_t *ptr, // 182 | uint16_t oldval, // 183 | uint16_t newval // new value to store if compare is successful 184 | ) 185 | { 186 | return __sync_val_compare_and_swap(ptr, oldval, newval); 187 | } 188 | /** 189 | * This does a 4 byte compare and swap of a location in NVM or volatile 190 | * memory. The return value is the value of the location when the CAS 191 | * executed. If it is equal to the old value then the swap succeeded. 192 | * 193 | * @param[in] ptr 194 | * The address of location to modify 195 | * 196 | * @param[in] oldval 197 | * The expected value to change 198 | * 199 | * @param[in] newval 200 | * The new value to store if compare is successful 201 | * 202 | * @return 203 | * The value that was in memory when the CAS fetched the location 204 | */ 205 | uint32_t nvms_cas4( 206 | volatile uint32_t *ptr, // 207 | uint32_t oldval, // 208 | uint32_t newval // new value to store if compare is successful 209 | ) 210 | { 211 | return __sync_val_compare_and_swap(ptr, oldval, newval); 212 | } 213 | /** 214 | * This does an 8 byte compare and swap of a location in NVM or volatile 215 | * memory. The return value is the value of the location when the CAS 216 | * executed. If it is equal to the old value then the swap succeeded. 217 | * 218 | * @param[in] ptr 219 | * The address of location to modify 220 | * 221 | * @param[in] oldval 222 | * The expected value to change 223 | * 224 | * @param[in] newval 225 | * The new value to store if compare is successful 226 | * 227 | * @return 228 | * The value that was in memory when the CAS fetched the location 229 | */ 230 | uint64_t nvms_cas8( 231 | volatile uint64_t *ptr, // 232 | uint64_t oldval, // 233 | uint64_t newval // new value to store if compare is successful 234 | ) 235 | { 236 | return __sync_val_compare_and_swap(ptr, oldval, newval); 237 | } 238 | -------------------------------------------------------------------------------- /nvmds/nvms_locking.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvms_locking.h - NVM services for volatile memory locking 43 | 44 | DESCRIPTION\n 45 | The NVM library needs mutexes for coordinating access to volatile memory 46 | between threads. This header defines the interface that the NVM library 47 | needs implemented. 48 | 49 | */ 50 | 51 | #ifndef NVMS_LOCKING_H 52 | #define NVMS_LOCKING_H 53 | #include 54 | #include 55 | 56 | #ifdef __cplusplus 57 | extern "C" 58 | { 59 | #endif 60 | 61 | /** 62 | * This defines an opaque type used as a handle to an application global 63 | * mutex that can be used to coordinate between threads within the same 64 | * application. 65 | */ 66 | typedef void *nvms_mutex; 67 | 68 | /** 69 | * This allocates and initializes an application global mutex. 70 | * 71 | * If there are any errors then errno is set and the return value is zero. 72 | * 73 | * @return 74 | * An opaque handle to the mutex, or zero if there is an error. 75 | */ 76 | nvms_mutex nvms_create_mutex(void); 77 | 78 | /** 79 | * This destroys an application global mutex freeing the memory it consumed. 80 | * The mutex must not be locked when destroyed. 81 | * 82 | * @param[in] mutex 83 | * Handle to the mutex to destroy. 84 | */ 85 | void nvms_destroy_mutex(nvms_mutex mutex); 86 | 87 | /** 88 | * When this returns 1 the calling thread has an exclusive lock on the 89 | * indicated mutex. If the wait parameter is true then the thread might 90 | * sleep waiting for another thread to release its lock. If wait is false 91 | * then 0 is returned rather than wait for the holder to release its lock. 92 | * 93 | * @param[in] mutex 94 | * Handle to the mutex to lock. 95 | * 96 | * @param[in] wait 97 | * If 0 thread returns 0 rather than wait for a conflicting lock to be 98 | * released. 99 | * 100 | * @return 101 | * 1 if lock acquired, 0 if not acquired due to conflicting lock. 102 | */ 103 | int nvms_lock_mutex( 104 | nvms_mutex mutex, 105 | int wait 106 | ); 107 | 108 | /** 109 | * When this returns the calling thread no longer has a lock on the 110 | * indicated mutex. This might wakeup another thread waiting for a lock. 111 | * The calling thread must have locked the mutex via nvms_lock_mutex. 112 | * If the caller previously registered a recovery operation, the opcode is 113 | * cleared to zero before the mutex is unlocked. 114 | * 115 | * @param[in] mutex 116 | * Handle to the mutex to unlock. 117 | */ 118 | void nvms_unlock_mutex( 119 | nvms_mutex mutex 120 | ); 121 | 122 | 123 | /** 124 | * This does a 2 byte compare and swap of a location in NVM or volatile 125 | * memory. The return value is the value of the location when the CAS 126 | * executed. If it is equal to the old value then the swap succeeded. 127 | * 128 | * @param[in] ptr 129 | * The address of location to modify 130 | * 131 | * @param[in] oldval 132 | * The expected value to change 133 | * 134 | * @param[in] newval 135 | * The new value to store if compare is successful 136 | * 137 | * @return 138 | * The value that was in memory when the CAS fetched the location 139 | */ 140 | uint16_t nvms_cas2( 141 | volatile uint16_t *ptr, // 142 | uint16_t oldval, // 143 | uint16_t newval // new value to store if compare is successful 144 | ); 145 | 146 | /** 147 | * This does a 4 byte compare and swap of a location in NVM or volatile 148 | * memory. The return value is the value of the location when the CAS 149 | * executed. If it is equal to the old value then the swap succeeded. 150 | * 151 | * @param[in] ptr 152 | * The address of location to modify 153 | * 154 | * @param[in] oldval 155 | * The expected value to change 156 | * 157 | * @param[in] newval 158 | * The new value to store if compare is successful 159 | * 160 | * @return 161 | * The value that was in memory when the CAS fetched the location 162 | */ 163 | uint32_t nvms_cas4( 164 | volatile uint32_t *ptr, // 165 | uint32_t oldval, // 166 | uint32_t newval // new value to store if compare is successful 167 | ); 168 | 169 | /** 170 | * This does an 8 byte compare and swap of a location in NVM or volatile 171 | * memory. The return value is the value of the location when the CAS 172 | * executed. If it is equal to the old value then the swap succeeded. 173 | * 174 | * @param[in] ptr 175 | * The address of location to modify 176 | * 177 | * @param[in] oldval 178 | * The expected value to change 179 | * 180 | * @param[in] newval 181 | * The new value to store if compare is successful 182 | * 183 | * @return 184 | * The value that was in memory when the CAS fetched the location 185 | */ 186 | uint64_t nvms_cas8( 187 | volatile uint64_t *ptr, // 188 | uint64_t oldval, // 189 | uint64_t newval // new value to store if compare is successful 190 | ); 191 | 192 | #ifdef __cplusplus 193 | } 194 | #endif 195 | 196 | #endif /* NVMS_MUTEX_H */ 197 | 198 | -------------------------------------------------------------------------------- /nvmds/nvms_memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvms_memory.c - NVM services for volatile memory management 43 | 44 | DESCRIPTION\n 45 | This implements volatile memory services for the NVM library. 46 | 47 | NOTES| 48 | Memory management services provide 2 classes of volatile memory based on 49 | the visibility to different threads of execution: 50 | 51 | 1. Thread local memory is only accessed by a single thread of execution. 52 | It may be accessible to other threads, but the NVM library does not do 53 | that. If the owning thread exits the memory is automatically released 54 | by the services layer. 55 | 56 | 2. Application global memory can be accessed by any thread via the same 57 | virtual address. 58 | 59 | For each class of memory, there is an allocate and a free service. Since 60 | the service library only supports a single process, this could be 61 | malloc/free for both classes. 62 | 63 | All volatile memory used by the NVM library is dynamically allocated from 64 | one of the two classes. The library does not declare any global or static 65 | variables other than those that are const. In order to maintain its 66 | state, it needs the services library to maintain root pointers. The NVM 67 | library allocates a root struct and stores a pointer to it in a root 68 | pointer. There are two kinds of root pointers : 69 | 70 | 1. Application root pointer: There is only one application root pointer 71 | in an application. Every thread sees the same value. It is in application 72 | global memory. 73 | 74 | 3. Thread root pointer: Each thread has its own private thread root 75 | pointer. It is in thread local memory so that it disappears if the thread 76 | calls nvm_fini. 77 | 78 | EXPORT FUNCTION(S)\n 79 | nvms_thread_set_ptr - set the thread local root pointer\n 80 | nvms_thread_get_ptr - get the thread local root pointer\n 81 | nvms_thread_alloc - allocate thread local memory\n 82 | nvms_thread_free - free thread local memory\n 83 | nvms_app_ptr_addr - get the application root pointer address\n 84 | nvms_app_set_ptr - set the application global root pointer\n 85 | nvms_app_alloc - allocate application global memory\n 86 | nvms_app_free - free application global memory\n 87 | 88 | INTERNAL FUNCTION(S)\n 89 | 90 | STATIC FUNCTION(S)\n 91 | 92 | NOTES\n 93 | 94 | MODIFIED (MM/DD/YY) 95 | bbridge 05/06/14 - Creation\n 96 | */ 97 | #include 98 | #include 99 | #include 100 | #include 101 | #include 102 | #include 103 | #include 104 | #include 105 | #include 106 | #include 107 | #include "errno.h" 108 | #include "error.h" 109 | #include "nvms_misc.h" 110 | #include "nvms_memory.h" 111 | #include "libpmem.h" 112 | 113 | /* The key for getting the per thread pointer */ 114 | static pthread_key_t nvms_ptr_key; 115 | 116 | /* The key for getting the per thread allocations */ 117 | static pthread_key_t nvms_alloc_key; 118 | 119 | /* the one and only app pointer */ 120 | void *nvms_app_ptr; 121 | 122 | /** 123 | * This is called once before any other calls to the service library. It 124 | * provides the library a means of doing any one time initialization such 125 | * as creating a pthread key. 126 | */ 127 | void nvms_init() 128 | { 129 | #ifdef LIBPMEM_H 130 | /* Ensure we have a viable pmem library */ 131 | if (pmem_check_version(PMEM_MAJOR_VERSION, PMEM_MINOR_VERSION)) 132 | error(1, 0, "libpmem incompatible: %s", pmem_errormsg()); 133 | #endif 134 | 135 | pthread_key_create(&nvms_ptr_key, NULL); 136 | pthread_key_create(&nvms_alloc_key, NULL); 137 | } 138 | /** 139 | * This is called at the beginning of thread initialization of the NVM 140 | * library. It provides the service layer an opportunity to do per thread 141 | * initialization. 142 | */ 143 | void nvms_thread_init() { } 144 | 145 | /** 146 | * This is called once after all other calls to the service library. It 147 | * provides the library a means of doing any cleanup such as deleting a 148 | * pthread key. This does not terminate the thread. It could be followed by 149 | * another call to nvms_thread_init() in the same thread. 150 | */ 151 | void nvms_thread_fini() 152 | { 153 | /* Release all the per thread allocations */ 154 | void **cur = pthread_getspecific(nvms_alloc_key); 155 | void **nxt; 156 | while (cur) 157 | { 158 | nxt = *cur; 159 | free(cur); 160 | cur = nxt; 161 | pthread_setspecific(nvms_alloc_key, cur); 162 | } 163 | } 164 | /** 165 | * This saves a root pointer for this thread. Subsequent calls made from 166 | * this thread to get the thread root pointer will return this value. The 167 | * root pointer must be a value returned by nvms_thread_alloc. 168 | * 169 | * @param[in] ptr 170 | * The root pointer to save. 171 | */ 172 | void nvms_thread_set_ptr( 173 | void *ptr 174 | ) 175 | { 176 | int ret = pthread_setspecific(nvms_ptr_key, ptr); 177 | if (ret) 178 | nvms_assert_fail("Error setting per thread pointer"); 179 | } 180 | /** 181 | * This returns the root pointer for this thread. If nvms_thread_set_ptr 182 | * was never called in this thread, then zero is returned. 183 | * 184 | * @return 185 | * The root pointer or zero if there is none. 186 | */ 187 | void *nvms_thread_get_ptr() 188 | { 189 | void *ptr = pthread_getspecific(nvms_ptr_key); 190 | return ptr; 191 | } 192 | /** 193 | * This allocates size bytes of zeroed memory that is visible to the 194 | * calling thread. If the thread exits the memory will be automatically 195 | * released as if it was passed to nvms_thread_free. 196 | * 197 | * If there are any errors then errno is set and the return value is zero. 198 | * 199 | * @param[in] size 200 | * amount of memory to allocate in bytes 201 | * 202 | * @return 203 | * A pointer to the newly allocated memory or zero 204 | */ 205 | void *nvms_thread_alloc( 206 | size_t size 207 | ) 208 | { 209 | /* malloc the memory and put it on the list of chunks allocated to this 210 | * thread. */ 211 | void **ret = malloc(size + sizeof(void*)); 212 | memset(ret+1, 0, size); 213 | *ret = pthread_getspecific(nvms_alloc_key); 214 | pthread_setspecific(nvms_alloc_key, ret); 215 | return ret + 1; 216 | } 217 | /** 218 | * This releases memory that was previously allocated to the calling thread. 219 | * 220 | * @param[in] ptr 221 | * pointer previously returned by nvms_thread_alloc 222 | */ 223 | void nvms_thread_free( 224 | void *ptr 225 | ) 226 | { 227 | /* Find the address on the list of allocations to this thread */ 228 | void **prev = NULL; 229 | void **cur = pthread_getspecific(nvms_alloc_key); 230 | while ((cur + 1) != ptr) 231 | { 232 | prev = cur; 233 | cur = *cur; 234 | if (!cur) 235 | nvms_assert_fail("Freeing thread memory that was not allocated"); 236 | } 237 | 238 | /* remove from allocated list */ 239 | if (prev) 240 | *prev = *cur; 241 | else 242 | pthread_setspecific(nvms_alloc_key, *cur); 243 | 244 | free(cur); 245 | } 246 | 247 | /** 248 | * This allocates size bytes of zeroed memory that is visible to the 249 | * calling application. 250 | * 251 | * If there are any errors then an assert fires. 252 | * 253 | * @param[in] size 254 | * amount of memory to allocate in bytes 255 | * 256 | * @return 257 | * A pointer to the newly allocated memory 258 | */ 259 | void *nvms_app_alloc(size_t size) 260 | { 261 | void *mem = malloc(size); 262 | if (mem == 0) 263 | nvms_assert_fail("Failure in malloc"); 264 | memset(mem, 0, size); 265 | return mem; 266 | } 267 | /** 268 | * This releases memory that was previously allocated to the calling 269 | * application. 270 | * 271 | * @param[in] ptr 272 | * pointer previously returned by nvms_app_alloc 273 | * 274 | * @return 275 | * 1 if successfully freed, and 0 if not freed because some lock could not 276 | * be acquired. 277 | */ 278 | int nvms_app_free(void *ptr) 279 | { 280 | free(ptr); 281 | return 1; 282 | } 283 | -------------------------------------------------------------------------------- /nvmds/nvms_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvms_memory.h - NVM services for volatile memory management 43 | 44 | DESCRIPTION\n 45 | This defines the interface required by the NVM library for allocating 46 | and freeing volatile memory. 47 | 48 | NOTES\n 49 | Memory management services provide 2 classes of volatile memory based on 50 | the visibility to different threads of execution: 51 | 52 | 1. Thread local memory is only accessed by a single thread of execution. 53 | It may be accessible to other threads, but the NVM library does not do 54 | that. If the owning thread exits the memory is automatically released 55 | by the services layer. 56 | 57 | 2. Application global memory can be accessed by any thread via the same 58 | virtual address. 59 | 60 | For each class of memory, there is an allocate and a free service. Since 61 | the service library only supports a single process, this could be 62 | malloc/free for both classes. 63 | 64 | All volatile memory used by the NVM library is dynamically allocated from 65 | one of the two classes. The library does not declare any global or static 66 | variables other than those that are const. In order to maintain its 67 | state, it needs the services library to maintain root pointers. The NVM 68 | library allocates a root struct and stores a pointer to it in a root 69 | pointer. There are two kinds of root pointers : 70 | 71 | 1. Application root pointer: There is only one application root pointer 72 | in an application. Every thread sees the same value. It is in application 73 | global memory. 74 | 75 | 3. Thread root pointer: Each thread has its own private thread root 76 | pointer. It is in thread local memory so that it disappears if the thread 77 | calls nvm_fini. 78 | 79 | */ 80 | 81 | #ifndef NVMS_MEMORY_H 82 | #define NVMS_MEMORY_H 83 | #include 84 | #include 85 | 86 | #ifdef __cplusplus 87 | extern "C" 88 | { 89 | #endif 90 | /** 91 | * This is called once before any other calls to the service library. It 92 | * provides the library a means of doing any one time initialization such 93 | * as creating a pthread key. It is called from nvm_init when the library 94 | * is loaded. 95 | */ 96 | void nvms_init(); 97 | 98 | /** 99 | * This is called at the beginning of thread initialization of the NVM 100 | * library. It provides the service layer an opportunity to do per thread 101 | * initialization. 102 | */ 103 | void nvms_thread_init(); 104 | 105 | /** 106 | * This is called once after all other calls to the service library. It 107 | * provides the library a means of doing any cleanup such as deleting a 108 | * pthread key. This does not terminate the thread. It could be followed by 109 | * another call to nvms_thread_init() in the same thread. 110 | */ 111 | void nvms_thread_fini(); 112 | 113 | /** 114 | * This saves a root pointer for this thread. Subsequent calls made from 115 | * this thread to get the thread root pointer will return this value. The 116 | * root pointer must be a value returned by nvms_thread_alloc. 117 | * 118 | * @param[in] ptr 119 | * The root pointer to save. 120 | */ 121 | void nvms_thread_set_ptr( 122 | void *ptr 123 | ); 124 | 125 | /** 126 | * This returns the root pointer for this thread. If nvms_thread_set_ptr 127 | * was never called in this thread, then zero is returned. 128 | * 129 | * @return 130 | * The root pointer or zero if there is none. 131 | */ 132 | void *nvms_thread_get_ptr(); 133 | 134 | /** 135 | * This allocates size bytes of uninitialized memory that is visible to the 136 | * calling thread. 137 | 138 | * If there are any errors then errno is set and the return value is zero. 139 | 140 | * @param[in] size 141 | * amount of memory to allocate in bytes 142 | * 143 | * @return 144 | * A pointer to the newly allocated memory or zero 145 | */ 146 | void *nvms_thread_alloc( 147 | size_t size 148 | ); 149 | 150 | /** 151 | * This releases memory that was previously allocated to the calling thread. 152 | * 153 | * @param[in] ptr 154 | * pointer previously returned by nvms_thread_alloc 155 | */ 156 | void nvms_thread_free( 157 | void *ptr 158 | ); 159 | 160 | /** 161 | * This returns the address of the application root pointer for the current 162 | * application. The application root pointer itself must be zero when the 163 | * application is started. It is in application global memory so that it is 164 | * automatically released when all threads in an application exit. 165 | * 166 | * This routine is used both to get and set the application root pointer. 167 | * It is only called once per thread in nvm_thread_init. 168 | * 169 | * @return 170 | * Address in application global memory of the application root pointer. 171 | */ 172 | static inline void **nvms_app_ptr_addr() 173 | { 174 | extern void *nvms_app_ptr; 175 | return &nvms_app_ptr; 176 | } 177 | 178 | 179 | /** 180 | * This allocates size bytes of zeroed memory that is visible to the 181 | * calling application. 182 | * 183 | * If there are any errors then an assert fires. 184 | * 185 | * @param[in] size 186 | * amount of memory to allocate in bytes 187 | * 188 | * @return 189 | * A pointer to the newly allocated memory 190 | */ 191 | void *nvms_app_alloc(size_t size); 192 | 193 | /** 194 | * This releases memory that was previously allocated to the calling 195 | * application. 196 | * 197 | * @param[in] ptr 198 | * pointer previously returned by nvms_app_alloc 199 | * 200 | * @return 201 | * 1 if successfully freed, and 0 if not freed because some lock could not 202 | * be acquired. 203 | */ 204 | int nvms_app_free(void *ptr); 205 | 206 | 207 | #ifdef __cplusplus 208 | } 209 | #endif 210 | 211 | #endif /* NVMS_MEMORY_H */ 212 | 213 | -------------------------------------------------------------------------------- /nvmds/nvms_sleeping.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvms_sleeping.c - NVM services for sleeping and waking up threads. 43 | 44 | DESCRIPTION\n 45 | The NVM library needs a mechanism similar to pthread condition variables 46 | for blocking a thread when it needs to sleep until another thread releases 47 | a resource. Condition variables must be allocated in application global 48 | memory so that they are available to all threads in an application. 49 | 50 | */ 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include "nvms_locking.h" 59 | #include "nvms_sleeping.h" 60 | #include "nvms_misc.h" 61 | /** 62 | * This function allocates and initializes one condition variable in 63 | * application global memory and returns a handle to it. 64 | * 65 | * If there are any errors then errno is set and the return value is zero. 66 | * 67 | * @return 68 | * An opaque handle to the condition variable, or zero if there is an error. 69 | */ 70 | nvms_cond nvms_create_cond(void) 71 | { 72 | pthread_cond_t *cv = malloc(sizeof(pthread_cond_t)); 73 | int ret = pthread_cond_init(cv, NULL); 74 | if (ret != 0) 75 | { 76 | errno = ret; 77 | return NULL; 78 | } 79 | return cv; 80 | } 81 | /** 82 | * This destroys one condition variable making its handle no longer usable 83 | * and releasing any memory associated with it. There must not be any 84 | * threads waiting on the condition variable when it is destroyed. 85 | * 86 | * @param[in] cond 87 | * Handle for the condition variable to destroy 88 | */ 89 | void nvms_destroy_cond(nvms_cond cond) 90 | { 91 | pthread_cond_t *cv = cond; 92 | int ret = pthread_cond_destroy(cv); 93 | if (ret != 0) 94 | nvms_assert_fail("Invalid nvms_cond on destroy"); 95 | free(cv); 96 | } 97 | /** 98 | * The calling thread will block until the condition variable is posted to 99 | * wake it up. The application global mutex passed in must be locked by the 100 | * calling thread. It will be unlocked while the thread is blocked and 101 | * locked when this returns. The same mutex must be held by all waiters and 102 | * posters of the same condition variable. Passing a zero stop time blocks 103 | * until posted or a signal is received. 104 | * 105 | * @param[in] cond 106 | * Handle for the condition variable to wait on. 107 | * 108 | * @param[in] mutex 109 | * The mutex to hold while checking the condition and release while 110 | * sleeping. 111 | * 112 | * @param[in] stop 113 | * This is the absolute time to wakeup if not posted. It is in microseconds 114 | * since the beginning of the epoch (usually 1970). A stop time of zero 115 | * means there is no timeout. 116 | */ 117 | void nvms_cond_wait( 118 | nvms_cond cond, 119 | nvms_mutex mutex, 120 | uint64_t stop 121 | ) 122 | { 123 | pthread_cond_t *cv = cond; 124 | 125 | if (stop == 0) 126 | { 127 | /* infinite timeout */ 128 | int ret = pthread_cond_wait(cv, (pthread_mutex_t*)mutex); 129 | if (ret != 0) 130 | nvms_assert_fail("Invalid nvms_cond or nvms_mutex on wait"); 131 | } 132 | else 133 | { 134 | struct timespec when; 135 | when.tv_sec = stop / 1000000; 136 | when.tv_nsec = (stop % 1000000)*1000; 137 | int ret = pthread_cond_timedwait(cv, (pthread_mutex_t*)mutex, &when); 138 | if (ret && ret != ETIMEDOUT) 139 | nvms_assert_fail("Invalid nvms_cond or nvms_mutex on timed wait"); 140 | errno = ret; 141 | } 142 | } 143 | /** 144 | * This function will wake up one thread waiting on the condition variable 145 | * or all threads waiting on the condition variable. If there are no 146 | * threads waiting then nothing happens. To avoid starvation, the thread 147 | * waiting the longest should be posted first. The caller must hold the 148 | * same mutex that the waiters held when calling nvms_cond_wait. 149 | * 150 | * @param[in] cond 151 | * Handle for the condition variable to wait on. 152 | * 153 | * @param[in] all 154 | * True to post all threads rather than one 155 | */ 156 | void nvms_cond_post( 157 | nvms_cond cond, // condition variable to post 158 | int all // true to post all threads rather than one 159 | ) 160 | { 161 | pthread_cond_t *cv = cond; 162 | if (all) 163 | pthread_cond_broadcast(cv); 164 | else 165 | pthread_cond_signal(cv); 166 | } 167 | -------------------------------------------------------------------------------- /nvmds/nvms_sleeping.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | /**\file 41 | NAME\n 42 | nvms_sleeping.h - NVM services for sleeping and waking up threads. 43 | 44 | DESCRIPTION\n 45 | The NVM library needs a mechanism similar to pthread condition variables 46 | for blocking a thread when it needs to sleep until another thread releases 47 | a resource. Condition variables must be allocated in application global 48 | memory so that they are available to all threads in an application. 49 | 50 | */ 51 | 52 | #ifndef NVMS_SLEEPING_H 53 | #define NVMS_SLEEPING_H 54 | 55 | #ifdef __cplusplus 56 | extern "C" 57 | { 58 | #endif 59 | 60 | /** 61 | * This type represents a opaque handle to a condition variable provided by 62 | * the services library. The handle must be usable by any thread in the 63 | * application. Thus it is a pointer to application global memory. 64 | */ 65 | typedef void *nvms_cond; 66 | 67 | /** 68 | * This function allocates and initializes one condition variable in 69 | * application global memory and returns a handle to it. 70 | * 71 | * If there are any errors then errno is set and the return value is zero. 72 | * 73 | * @param[out] destroy 74 | * This points to a null handle that is set to the return value atomically 75 | * with allocation of the conditiona variable. 76 | * 77 | * @return 78 | * An opaque handle to the condition variable, or zero if there is an error. 79 | */ 80 | nvms_cond nvms_create_cond(void); 81 | 82 | /** 83 | * This destroys one condition variable making its handle no longer usable 84 | * and releasing any memory associated with it. There must not be any 85 | * threads waiting on the condition variable when it is destroyed. 86 | * 87 | * @param[in] cond 88 | * Handle for the condition variable to destroy 89 | */ 90 | void nvms_destroy_cond(nvms_cond cond); 91 | 92 | /** 93 | * The calling thread will block until the condition variable is posted to 94 | * wake it up. The application global mutex passed in must be locked by the 95 | * calling thread. It will be unlocked while the thread is blocked and 96 | * locked when this returns. The same mutex must be held by all waiters and 97 | * posters of the same condition variable. Passing a zero stop time blocks 98 | * until posted or a signal is received. A non-zero stop time will stop 99 | * waiting when that time arrives. The current time can be acquired through 100 | * nvms_utime(). Using an absolute stop time allows multiple waits to be 101 | * aggregated into one stop time. 102 | * 103 | * @param[in] cond 104 | * Handle for the condition variable to wait on. 105 | * 106 | * @param[in] mutex 107 | * The mutex to hold while checking the condition and release while 108 | * sleeping. 109 | * 110 | * @param[in] stop 111 | * This is the absolute time to wakeup if not posted. It is in microseconds 112 | * since the beginning of the epoch (usually 1970). A stop time of zero 113 | * means there is no timeout. 114 | */ 115 | void nvms_cond_wait( 116 | nvms_cond cond, 117 | nvms_mutex mutex, 118 | uint64_t stop 119 | ); 120 | 121 | /** 122 | * This function will wake up one thread waiting on the condition variable 123 | * or all threads waiting on the condition variable. If there are no 124 | * threads waiting then nothing happens. To avoid starvation, the thread 125 | * waiting the longest should be posted first. The caller must hold the 126 | * same mutex that the waiters held when calling nvms_cond_wait. 127 | * 128 | * @param[in] cond 129 | * Handle for the condition variable to wait on. 130 | * 131 | * @param[in] all 132 | * True to post all threads rather than one 133 | */ 134 | void nvms_cond_post( 135 | nvms_cond cond, // condition variable to post 136 | int all // true to post all threads rather than one 137 | ); 138 | 139 | #ifdef __cplusplus 140 | } 141 | #endif 142 | 143 | #endif /* NVMS_SLEEPING_H */ 144 | 145 | -------------------------------------------------------------------------------- /test_dmf/.gitignore: -------------------------------------------------------------------------------- 1 | /DebugX/ 2 | /ReleaseX/ 3 | -------------------------------------------------------------------------------- /test_dmf/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | test_dmf 4 | 5 | 6 | DirectMappedFile 7 | nvmd 8 | nvmds 9 | 10 | 11 | 12 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 13 | clean,full,incremental, 14 | 15 | 16 | 17 | 18 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 19 | full,incremental, 20 | 21 | 22 | 23 | 24 | 25 | org.eclipse.cdt.core.cnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /test_dmf/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning 3 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 4 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error 5 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 6 | org.eclipse.cdt.codan.checkers.noreturn=Error 7 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 8 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error 9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 10 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error 11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 12 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning 13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 14 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error 15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 16 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning 17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} 18 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning 19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} 20 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error 21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 22 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning 23 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} 24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error 25 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error 27 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error 29 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error 31 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error 33 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error 35 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error 37 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info 39 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} 40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning 41 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error 43 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error 45 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error 47 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning 49 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning 51 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning 53 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} 54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning 55 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} 56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning 57 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} 58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error 59 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning 61 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning 63 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning 65 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} 66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error 67 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 68 | -------------------------------------------------------------------------------- /test_dmf/project.gdbinit: -------------------------------------------------------------------------------- 1 | b nvms_assert_fail 2 | b nvms_corruption 3 | b nvms_fatal 4 | 5 | -------------------------------------------------------------------------------- /test_nvmd/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /DebugX/ 3 | /Release/ 4 | /ReleaseX/ 5 | -------------------------------------------------------------------------------- /test_nvmd/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | test_nvmd 4 | 5 | 6 | nvmd 7 | nvmds 8 | 9 | 10 | 11 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 12 | clean,full,incremental, 13 | 14 | 15 | 16 | 17 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 18 | full,incremental, 19 | 20 | 21 | 22 | 23 | 24 | org.eclipse.cdt.core.cnature 25 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 26 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /test_nvmd/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.codan.checkers.errnoreturn=Warning 3 | org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 4 | org.eclipse.cdt.codan.checkers.errreturnvalue=Error 5 | org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 6 | org.eclipse.cdt.codan.checkers.noreturn=Error 7 | org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} 8 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error 9 | org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 10 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error 11 | org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 12 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning 13 | org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 14 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error 15 | org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 16 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning 17 | org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false} 18 | org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning 19 | org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} 20 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error 21 | org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 22 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning 23 | org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} 24 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error 25 | org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 26 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error 27 | org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 28 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error 29 | org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 30 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error 31 | org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 32 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error 33 | org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 34 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error 35 | org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 36 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error 37 | org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 38 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info 39 | org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} 40 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning 41 | org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 42 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error 43 | org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 44 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error 45 | org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 46 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error 47 | org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 48 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning 49 | org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 50 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning 51 | org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 52 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning 53 | org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} 54 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning 55 | org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} 56 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning 57 | org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} 58 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error 59 | org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 60 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning 61 | org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 62 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning 63 | org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} 64 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning 65 | org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} 66 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error 67 | org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} 68 | -------------------------------------------------------------------------------- /test_nvmd/.settings/org.eclipse.cdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/project/cdt.managedbuild.config.gnu.exe.debug.395346795/CWD/delimiter=\: 3 | environment/project/cdt.managedbuild.config.gnu.exe.debug.395346795/CWD/operation=replace 4 | environment/project/cdt.managedbuild.config.gnu.exe.debug.395346795/CWD/value=/scratch/eclipse/NVM_Direct.git/test_nvmd/Debug 5 | environment/project/cdt.managedbuild.config.gnu.exe.debug.395346795/append=true 6 | environment/project/cdt.managedbuild.config.gnu.exe.debug.395346795/appendContributed=true 7 | -------------------------------------------------------------------------------- /test_nvmd/.settings/org.eclipse.cdt.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | formatter_settings_version=1 3 | -------------------------------------------------------------------------------- /test_nvmd/.settings/org.eclipse.linuxtools.tools.launch.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.linuxtools.tools.launch.core.LinuxtoolsPath=../../bin 3 | -------------------------------------------------------------------------------- /test_nvmd/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 3 | 4 | The Universal Permissive License (UPL), Version 1.0 5 | 6 | Subject to the condition set forth below, permission is hereby granted to any 7 | person obtaining a copy of this software, associated documentation and/or data 8 | (collectively the "Software"), free of charge and under any and all copyright 9 | rights in the Software, and any and all patent rights owned or freely 10 | licensable by each licensor hereunder covering either (i) the unmodified 11 | Software as contributed to or provided by such licensor, or (ii) the Larger 12 | Works (as defined below), to deal in both 13 | 14 | (a) the Software, and 15 | 16 | (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if 17 | one is included with the Software (each a "Larger Work" to which the Software 18 | is contributed by such licensors), 19 | 20 | without restriction, including without limitation the rights to copy, create 21 | derivative works of, display, perform, and distribute the Software and make, 22 | use, sell, offer for sale, import, export, have made, and have sold the 23 | Software and the Larger Work(s), and to sublicense the foregoing rights on 24 | either these or other terms. 25 | 26 | This license is subject to the following condition: 27 | 28 | The above copyright notice and either this complete permission notice or at a 29 | minimum a reference to the UPL must be included in all copies or substantial 30 | portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38 | SOFTWARE. 39 | */ 40 | -------------------------------------------------------------------------------- /test_nvmd/bin/usid_build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script should be run just before running the linker 3 | # It creates the nvm_type and nvm_extern definitions. 4 | 5 | # Cleanup last build 6 | echo test_nvm/bin/usid_build called 7 | rm -f usid.c usid.json usid.o 8 | 9 | # construct usid.c from the .usd files 10 | CMD="usidmap -r=usid_register -c=./usid.c -d=./usid.json ./*.usd" 11 | echo " $CMD" 12 | $CMD 13 | X=$? 14 | if [ $X -ne 0 ] 15 | then 16 | echo " Status $X from usidmap" 17 | exit $X 18 | fi 19 | 20 | # remove the things defined by libnvm until a better usidmap is available 21 | sed -i "/__nvm_type_nvm_.* =/,/};/d" ./usid.c 22 | sed -i "/^ (const nvm_type.)&__nvm_type_nvm_/d" ./usid.c 23 | 24 | # compile usid.c 25 | CMD="gcc -O0 -g3 -c -I../../nvmd -I../../nvmds -o ./usid.o ./usid.c" 26 | echo " $CMD" 27 | $CMD 28 | X=$? 29 | if [ $X -ne 0 ] 30 | then 31 | echo " Status $X from gcc usid.c" 32 | exit $X 33 | fi 34 | -------------------------------------------------------------------------------- /test_nvmd/project.gdbinit: -------------------------------------------------------------------------------- 1 | b nvms_assert_fail 2 | b nvms_corruption 3 | b nvms_fatal 4 | --------------------------------------------------------------------------------