export.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef sodium_export_H
  2. #define sodium_export_H
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. #include <limits.h>
  6. #if !defined(__clang__) && !defined(__GNUC__)
  7. # ifdef __attribute__
  8. # undef __attribute__
  9. # endif
  10. # define __attribute__(a)
  11. #endif
  12. #ifdef SODIUM_STATIC
  13. # define SODIUM_EXPORT
  14. # define SODIUM_EXPORT_WEAK
  15. #else
  16. # if defined(_MSC_VER)
  17. # ifdef SODIUM_DLL_EXPORT
  18. # define SODIUM_EXPORT __declspec(dllexport)
  19. # else
  20. # define SODIUM_EXPORT __declspec(dllimport)
  21. # endif
  22. # else
  23. # if defined(__SUNPRO_C)
  24. # ifndef __GNU_C__
  25. # define SODIUM_EXPORT __attribute__ (visibility(__global))
  26. # else
  27. # define SODIUM_EXPORT __attribute__ __global
  28. # endif
  29. # elif defined(_MSG_VER)
  30. # define SODIUM_EXPORT extern __declspec(dllexport)
  31. # else
  32. # define SODIUM_EXPORT __attribute__ ((visibility ("default")))
  33. # endif
  34. # endif
  35. # if defined(__ELF__) && !defined(SODIUM_DISABLE_WEAK_FUNCTIONS)
  36. # define SODIUM_EXPORT_WEAK SODIUM_EXPORT __attribute__((weak))
  37. # else
  38. # define SODIUM_EXPORT_WEAK SODIUM_EXPORT
  39. # endif
  40. #endif
  41. #ifndef CRYPTO_ALIGN
  42. # if defined(__INTEL_COMPILER) || defined(_MSC_VER)
  43. # define CRYPTO_ALIGN(x) __declspec(align(x))
  44. # else
  45. # define CRYPTO_ALIGN(x) __attribute__ ((aligned(x)))
  46. # endif
  47. #endif
  48. #define SODIUM_MIN(A, B) ((A) < (B) ? (A) : (B))
  49. #define SODIUM_SIZE_MAX SODIUM_MIN(UINT64_MAX, SIZE_MAX)
  50. #endif