1*5c591343SA. Cody Schuffelen /* Microsoft Reference Implementation for TPM 2.0 2*5c591343SA. Cody Schuffelen * 3*5c591343SA. Cody Schuffelen * The copyright in this software is being made available under the BSD License, 4*5c591343SA. Cody Schuffelen * included below. This software may be subject to other third party and 5*5c591343SA. Cody Schuffelen * contributor rights, including patent rights, and no such rights are granted 6*5c591343SA. Cody Schuffelen * under this license. 7*5c591343SA. Cody Schuffelen * 8*5c591343SA. Cody Schuffelen * Copyright (c) Microsoft Corporation 9*5c591343SA. Cody Schuffelen * 10*5c591343SA. Cody Schuffelen * All rights reserved. 11*5c591343SA. Cody Schuffelen * 12*5c591343SA. Cody Schuffelen * BSD License 13*5c591343SA. Cody Schuffelen * 14*5c591343SA. Cody Schuffelen * Redistribution and use in source and binary forms, with or without modification, 15*5c591343SA. Cody Schuffelen * are permitted provided that the following conditions are met: 16*5c591343SA. Cody Schuffelen * 17*5c591343SA. Cody Schuffelen * Redistributions of source code must retain the above copyright notice, this list 18*5c591343SA. Cody Schuffelen * of conditions and the following disclaimer. 19*5c591343SA. Cody Schuffelen * 20*5c591343SA. Cody Schuffelen * Redistributions in binary form must reproduce the above copyright notice, this 21*5c591343SA. Cody Schuffelen * list of conditions and the following disclaimer in the documentation and/or 22*5c591343SA. Cody Schuffelen * other materials provided with the distribution. 23*5c591343SA. Cody Schuffelen * 24*5c591343SA. Cody Schuffelen * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" 25*5c591343SA. Cody Schuffelen * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26*5c591343SA. Cody Schuffelen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27*5c591343SA. Cody Schuffelen * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28*5c591343SA. Cody Schuffelen * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29*5c591343SA. Cody Schuffelen * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30*5c591343SA. Cody Schuffelen * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31*5c591343SA. Cody Schuffelen * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32*5c591343SA. Cody Schuffelen * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33*5c591343SA. Cody Schuffelen * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34*5c591343SA. Cody Schuffelen */ 35*5c591343SA. Cody Schuffelen // This file contains the build switches. This contains switches for multiple 36*5c591343SA. Cody Schuffelen // versions of the crypto-library so some may not apply to your environment. 37*5c591343SA. Cody Schuffelen // 38*5c591343SA. Cody Schuffelen 39*5c591343SA. Cody Schuffelen #ifndef _COMPILER_DEPENDENCIES_H_ 40*5c591343SA. Cody Schuffelen #define _COMPILER_DEPENDENCIES_H_ 41*5c591343SA. Cody Schuffelen 42*5c591343SA. Cody Schuffelen #ifdef GCC 43*5c591343SA. Cody Schuffelen # undef _MSC_VER 44*5c591343SA. Cody Schuffelen # undef WIN32 45*5c591343SA. Cody Schuffelen #endif 46*5c591343SA. Cody Schuffelen 47*5c591343SA. Cody Schuffelen #ifdef _MSC_VER 48*5c591343SA. Cody Schuffelen // These definitions are for the Microsoft compiler 49*5c591343SA. Cody Schuffelen 50*5c591343SA. Cody Schuffelen // Endian conversion for aligned structures 51*5c591343SA. Cody Schuffelen # define REVERSE_ENDIAN_16(_Number) _byteswap_ushort(_Number) 52*5c591343SA. Cody Schuffelen # define REVERSE_ENDIAN_32(_Number) _byteswap_ulong(_Number) 53*5c591343SA. Cody Schuffelen # define REVERSE_ENDIAN_64(_Number) _byteswap_uint64(_Number) 54*5c591343SA. Cody Schuffelen 55*5c591343SA. Cody Schuffelen // Avoid compiler warning for in line of stdio (or not) 56*5c591343SA. Cody Schuffelen //#define _NO_CRT_STDIO_INLINE 57*5c591343SA. Cody Schuffelen 58*5c591343SA. Cody Schuffelen // This macro is used to handle LIB_EXPORT of function and variable names in lieu 59*5c591343SA. Cody Schuffelen // of a .def file. Visual Studio requires that functions be explicitly exported and 60*5c591343SA. Cody Schuffelen // imported. 61*5c591343SA. Cody Schuffelen # define LIB_EXPORT __declspec(dllexport) // VS compatible version 62*5c591343SA. Cody Schuffelen # define LIB_IMPORT __declspec(dllimport) 63*5c591343SA. Cody Schuffelen 64*5c591343SA. Cody Schuffelen // This is defined to indicate a function that does not return. Microsoft compilers 65*5c591343SA. Cody Schuffelen // do not support the _Noretrun function parameter. 66*5c591343SA. Cody Schuffelen # define NORETURN __declspec(noreturn) 67*5c591343SA. Cody Schuffelen # if _MSC_VER >= 1400 // SAL processing when needed 68*5c591343SA. Cody Schuffelen # include <sal.h> 69*5c591343SA. Cody Schuffelen # endif 70*5c591343SA. Cody Schuffelen 71*5c591343SA. Cody Schuffelen # ifdef _WIN64 72*5c591343SA. Cody Schuffelen # define _INTPTR 2 73*5c591343SA. Cody Schuffelen # else 74*5c591343SA. Cody Schuffelen # define _INTPTR 1 75*5c591343SA. Cody Schuffelen # endif 76*5c591343SA. Cody Schuffelen 77*5c591343SA. Cody Schuffelen 78*5c591343SA. Cody Schuffelen #define NOT_REFERENCED(x) (x) 79*5c591343SA. Cody Schuffelen 80*5c591343SA. Cody Schuffelen // Lower the compiler error warning for system include 81*5c591343SA. Cody Schuffelen // files. They tend not to be that clean and there is no 82*5c591343SA. Cody Schuffelen // reason to sort through all the spurious errors that they 83*5c591343SA. Cody Schuffelen // generate when the normal error level is set to /Wall 84*5c591343SA. Cody Schuffelen # define _REDUCE_WARNING_LEVEL_(n) \ 85*5c591343SA. Cody Schuffelen __pragma(warning(push, n)) 86*5c591343SA. Cody Schuffelen // Restore the compiler warning level 87*5c591343SA. Cody Schuffelen # define _NORMAL_WARNING_LEVEL_ \ 88*5c591343SA. Cody Schuffelen __pragma(warning(pop)) 89*5c591343SA. Cody Schuffelen # include <stdint.h> 90*5c591343SA. Cody Schuffelen #endif 91*5c591343SA. Cody Schuffelen 92*5c591343SA. Cody Schuffelen #ifndef _MSC_VER 93*5c591343SA. Cody Schuffelen #ifndef WINAPI 94*5c591343SA. Cody Schuffelen # define WINAPI 95*5c591343SA. Cody Schuffelen #endif 96*5c591343SA. Cody Schuffelen # define __pragma(x) 97*5c591343SA. Cody Schuffelen # define REVERSE_ENDIAN_16(_Number) __builtin_bswap16(_Number) 98*5c591343SA. Cody Schuffelen # define REVERSE_ENDIAN_32(_Number) __builtin_bswap32(_Number) 99*5c591343SA. Cody Schuffelen # define REVERSE_ENDIAN_64(_Number) __builtin_bswap64(_Number) 100*5c591343SA. Cody Schuffelen #endif 101*5c591343SA. Cody Schuffelen 102*5c591343SA. Cody Schuffelen #if defined(__GNUC__) 103*5c591343SA. Cody Schuffelen # define NORETURN __attribute__((noreturn)) 104*5c591343SA. Cody Schuffelen # include <stdint.h> 105*5c591343SA. Cody Schuffelen #endif 106*5c591343SA. Cody Schuffelen 107*5c591343SA. Cody Schuffelen // Things that are not defined should be defined as NULL 108*5c591343SA. Cody Schuffelen #ifndef NORETURN 109*5c591343SA. Cody Schuffelen # define NORETURN 110*5c591343SA. Cody Schuffelen #endif 111*5c591343SA. Cody Schuffelen #ifndef LIB_EXPORT 112*5c591343SA. Cody Schuffelen # define LIB_EXPORT 113*5c591343SA. Cody Schuffelen #endif 114*5c591343SA. Cody Schuffelen #ifndef LIB_IMPORT 115*5c591343SA. Cody Schuffelen # define LIB_IMPORT 116*5c591343SA. Cody Schuffelen #endif 117*5c591343SA. Cody Schuffelen #ifndef _REDUCE_WARNING_LEVEL_ 118*5c591343SA. Cody Schuffelen # define _REDUCE_WARNING_LEVEL_(n) 119*5c591343SA. Cody Schuffelen #endif 120*5c591343SA. Cody Schuffelen #ifndef _NORMAL_WARNING_LEVEL_ 121*5c591343SA. Cody Schuffelen # define _NORMAL_WARNING_LEVEL_ 122*5c591343SA. Cody Schuffelen #endif 123*5c591343SA. Cody Schuffelen #ifndef NOT_REFERENCED 124*5c591343SA. Cody Schuffelen # define NOT_REFERENCED(x) (x = x) 125*5c591343SA. Cody Schuffelen #endif 126*5c591343SA. Cody Schuffelen 127*5c591343SA. Cody Schuffelen #ifdef _POSIX_ 128*5c591343SA. Cody Schuffelen typedef int SOCKET; 129*5c591343SA. Cody Schuffelen #endif 130*5c591343SA. Cody Schuffelen 131*5c591343SA. Cody Schuffelen 132*5c591343SA. Cody Schuffelen #endif // _COMPILER_DEPENDENCIES_H_