Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

69 righe
2.3 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. /* x86 and x86_64 need to record the result of a cpuid call for the asm to work
  19. * correctly, unless compiled without asm code. */
  20. #define NEED_CPUID
  21. #else
  22. /* Otherwise, don't emit a static initialiser. */
  23. #if !defined(BORINGSSL_NO_STATIC_INITIALIZER)
  24. #define BORINGSSL_NO_STATIC_INITIALIZER
  25. #endif
  26. #endif /* !OPENSSL_NO_ASM && (OPENSSL_X86 || OPENSSL_X86_64) */
  27. #if defined(OPENSSL_WINDOWS)
  28. #define OPENSSL_CDECL __cdecl
  29. #else
  30. #define OPENSSL_CDECL
  31. #endif
  32. #if !defined(BORINGSSL_NO_STATIC_INITIALIZER)
  33. #if !defined(OPENSSL_WINDOWS)
  34. static void do_library_init(void) __attribute__ ((constructor));
  35. #else
  36. #pragma section(".CRT$XCU", read)
  37. static void __cdecl do_library_init(void);
  38. __declspec(allocate(".CRT$XCU")) void(*library_init_constructor)(void) =
  39. do_library_init;
  40. #endif
  41. #endif /* !BORINGSSL_NO_STATIC_INITIALIZER */
  42. /* do_library_init is the actual initialization function. If
  43. * BORINGSSL_NO_STATIC_INITIALIZER isn't defined, this is set as a static
  44. * initializer. Otherwise, it is called by CRYPTO_library_init. */
  45. static void OPENSSL_CDECL do_library_init(void) {
  46. #if defined(NEED_CPUID)
  47. OPENSSL_cpuid_setup();
  48. #endif
  49. }
  50. void CRYPTO_library_init(void) {
  51. /* TODO(davidben): It would be tidier if this build knob could be replaced
  52. * with an internal lazy-init mechanism that would handle things correctly
  53. * in-library. */
  54. #if defined(BORINGSSL_NO_STATIC_INITIALIZER)
  55. do_library_init();
  56. #endif
  57. }