Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

113 rindas
3.8 KiB

  1. /* Copyright (c) 2014, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #include <openssl/crypto.h>
  15. #include "internal.h"
  16. #if !defined(OPENSSL_NO_ASM) && \
  17. (defined(OPENSSL_X86) || defined(OPENSSL_X86_64) || \
  18. defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64))
  19. /* x86, x86_64 and the ARMs need to record the result of a cpuid call for the
  20. * asm to work correctly, unless compiled without asm code. */
  21. #define NEED_CPUID
  22. #else
  23. /* Otherwise, don't emit a static initialiser. */
  24. #if !defined(BORINGSSL_NO_STATIC_INITIALIZER)
  25. #define BORINGSSL_NO_STATIC_INITIALIZER
  26. #endif
  27. #endif /* !OPENSSL_NO_ASM && (OPENSSL_X86 || OPENSSL_X86_64 ||
  28. OPENSSL_ARM || OPENSSL_AARCH64) */
  29. /* The capability variables are defined in this file in order to work around a
  30. * linker bug. When linking with a .a, if no symbols in a .o are referenced
  31. * then the .o is discarded, even if it has constructor functions.
  32. *
  33. * This still means that any binaries that don't include some functionality
  34. * that tests the capability values will still skip the constructor but, so
  35. * far, the init constructor function only sets the capability variables. */
  36. #if defined(OPENSSL_X86) || defined(OPENSSL_X86_64)
  37. /* This value must be explicitly initialised to zero in order to work around a
  38. * bug in libtool or the linker on OS X.
  39. *
  40. * If not initialised then it becomes a "common symbol". When put into an
  41. * archive, linking on OS X will fail to resolve common symbols. By
  42. * initialising it to zero, it becomes a "data symbol", which isn't so
  43. * affected. */
  44. uint32_t OPENSSL_ia32cap_P[4] = {0};
  45. #elif defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64)
  46. #include "arm_arch.h"
  47. #if defined(__ARM_NEON__)
  48. uint32_t OPENSSL_armcap_P = ARMV7_NEON | ARMV7_NEON_FUNCTIONAL;
  49. #else
  50. uint32_t OPENSSL_armcap_P = ARMV7_NEON_FUNCTIONAL;
  51. #endif
  52. #endif
  53. #if defined(OPENSSL_WINDOWS)
  54. #define OPENSSL_CDECL __cdecl
  55. #else
  56. #define OPENSSL_CDECL
  57. #endif
  58. #if !defined(BORINGSSL_NO_STATIC_INITIALIZER)
  59. #if !defined(OPENSSL_WINDOWS)
  60. static void do_library_init(void) __attribute__ ((constructor));
  61. #else
  62. #pragma section(".CRT$XCU", read)
  63. static void __cdecl do_library_init(void);
  64. __declspec(allocate(".CRT$XCU")) void(*library_init_constructor)(void) =
  65. do_library_init;
  66. #endif
  67. #endif /* !BORINGSSL_NO_STATIC_INITIALIZER */
  68. /* do_library_init is the actual initialization function. If
  69. * BORINGSSL_NO_STATIC_INITIALIZER isn't defined, this is set as a static
  70. * initializer. Otherwise, it is called by CRYPTO_library_init. */
  71. static void OPENSSL_CDECL do_library_init(void) {
  72. /* WARNING: this function may only configure the capability variables. See the
  73. * note above about the linker bug. */
  74. #if defined(NEED_CPUID)
  75. OPENSSL_cpuid_setup();
  76. #endif
  77. }
  78. void CRYPTO_library_init(void) {
  79. /* TODO(davidben): It would be tidier if this build knob could be replaced
  80. * with an internal lazy-init mechanism that would handle things correctly
  81. * in-library. */
  82. #if defined(BORINGSSL_NO_STATIC_INITIALIZER)
  83. do_library_init();
  84. #endif
  85. }
  86. const char *SSLeay_version(int unused) {
  87. return SSLeay();
  88. }
  89. const char *SSLeay(void) {
  90. return "BoringSSL";
  91. }