10ac341f1SConrad Meyer 20ac341f1SConrad Meyer #ifndef sodium_export_H 30ac341f1SConrad Meyer #define sodium_export_H 40ac341f1SConrad Meyer 50ac341f1SConrad Meyer #include <stddef.h> 60ac341f1SConrad Meyer #include <stdint.h> 70ac341f1SConrad Meyer #include <limits.h> 80ac341f1SConrad Meyer 90ac341f1SConrad Meyer #if !defined(__clang__) && !defined(__GNUC__) 100ac341f1SConrad Meyer # ifdef __attribute__ 110ac341f1SConrad Meyer # undef __attribute__ 120ac341f1SConrad Meyer # endif 130ac341f1SConrad Meyer # define __attribute__(a) 140ac341f1SConrad Meyer #endif 150ac341f1SConrad Meyer 160ac341f1SConrad Meyer #ifdef SODIUM_STATIC 170ac341f1SConrad Meyer # define SODIUM_EXPORT 180ac341f1SConrad Meyer # define SODIUM_EXPORT_WEAK 190ac341f1SConrad Meyer #else 200ac341f1SConrad Meyer # if defined(_MSC_VER) 210ac341f1SConrad Meyer # ifdef SODIUM_DLL_EXPORT 220ac341f1SConrad Meyer # define SODIUM_EXPORT __declspec(dllexport) 230ac341f1SConrad Meyer # else 240ac341f1SConrad Meyer # define SODIUM_EXPORT __declspec(dllimport) 250ac341f1SConrad Meyer # endif 260ac341f1SConrad Meyer # else 270ac341f1SConrad Meyer # if defined(__SUNPRO_C) 280ac341f1SConrad Meyer # ifndef __GNU_C__ 290ac341f1SConrad Meyer # define SODIUM_EXPORT __attribute__ (visibility(__global)) 300ac341f1SConrad Meyer # else 310ac341f1SConrad Meyer # define SODIUM_EXPORT __attribute__ __global 320ac341f1SConrad Meyer # endif 330ac341f1SConrad Meyer # elif defined(_MSG_VER) 340ac341f1SConrad Meyer # define SODIUM_EXPORT extern __declspec(dllexport) 350ac341f1SConrad Meyer # else 360ac341f1SConrad Meyer # define SODIUM_EXPORT __attribute__ ((visibility ("default"))) 370ac341f1SConrad Meyer # endif 380ac341f1SConrad Meyer # endif 390ac341f1SConrad Meyer # if defined(__ELF__) && !defined(SODIUM_DISABLE_WEAK_FUNCTIONS) 400ac341f1SConrad Meyer # define SODIUM_EXPORT_WEAK SODIUM_EXPORT __attribute__((weak)) 410ac341f1SConrad Meyer # else 420ac341f1SConrad Meyer # define SODIUM_EXPORT_WEAK SODIUM_EXPORT 430ac341f1SConrad Meyer # endif 440ac341f1SConrad Meyer #endif 450ac341f1SConrad Meyer 460ac341f1SConrad Meyer #ifndef CRYPTO_ALIGN 470ac341f1SConrad Meyer # if defined(__INTEL_COMPILER) || defined(_MSC_VER) 480ac341f1SConrad Meyer # define CRYPTO_ALIGN(x) __declspec(align(x)) 490ac341f1SConrad Meyer # else 500ac341f1SConrad Meyer # define CRYPTO_ALIGN(x) __attribute__ ((aligned(x))) 510ac341f1SConrad Meyer # endif 520ac341f1SConrad Meyer #endif 530ac341f1SConrad Meyer 540ac341f1SConrad Meyer #define SODIUM_MIN(A, B) ((A) < (B) ? (A) : (B)) 550ac341f1SConrad Meyer #define SODIUM_SIZE_MAX SODIUM_MIN(UINT64_MAX, SIZE_MAX) 560ac341f1SConrad Meyer 57*bbb7a2c7SMatt Macy #ifdef _KERNEL 58*bbb7a2c7SMatt Macy #include <sys/param.h> 59*bbb7a2c7SMatt Macy #include <sys/libkern.h> 60*bbb7a2c7SMatt Macy static inline void sodium_misuse(void)61*bbb7a2c7SMatt Macysodium_misuse(void) 62*bbb7a2c7SMatt Macy { 63*bbb7a2c7SMatt Macy panic("bad value passed to sodium"); 64*bbb7a2c7SMatt Macy } 65*bbb7a2c7SMatt Macy #endif 66*bbb7a2c7SMatt Macy 670ac341f1SConrad Meyer #endif 68