Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: crypto/openssl_util.cc

Issue 895013002: Revert of Move the call to CRYPTO_set_NEON_capable up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "crypto/openssl_util.h" 5 #include "crypto/openssl_util.h"
6 6
7 #include <openssl/err.h> 7 #include <openssl/err.h>
8 #include <openssl/ssl.h> 8 #include <openssl/ssl.h>
9 #include <openssl/cpu.h> 9 #include <openssl/cpu.h>
10 10
(...skipping 30 matching lines...) Expand all
41 // context) who's cleanup depends on the global environment here, but 41 // context) who's cleanup depends on the global environment here, but
42 // we can't control the order the AtExit handlers will run in so 42 // we can't control the order the AtExit handlers will run in so
43 // allowing the global environment to leak at least ensures it is 43 // allowing the global environment to leak at least ensures it is
44 // available for those other singletons to reliably cleanup. 44 // available for those other singletons to reliably cleanup.
45 return Singleton<OpenSSLInitSingleton, 45 return Singleton<OpenSSLInitSingleton,
46 LeakySingletonTraits<OpenSSLInitSingleton> >::get(); 46 LeakySingletonTraits<OpenSSLInitSingleton> >::get();
47 } 47 }
48 private: 48 private:
49 friend struct DefaultSingletonTraits<OpenSSLInitSingleton>; 49 friend struct DefaultSingletonTraits<OpenSSLInitSingleton>;
50 OpenSSLInitSingleton() { 50 OpenSSLInitSingleton() {
51 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
52 const bool has_neon =
53 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
54 // CRYPTO_set_NEON_capable is called before |SSL_library_init| because this
55 // stops BoringSSL from probing for NEON support via SIGILL in the case
56 // that getauxval isn't present.
57 CRYPTO_set_NEON_capable(has_neon);
58 // See https://code.google.com/p/chromium/issues/detail?id=341598
59 base::CPU cpu;
60 CRYPTO_set_NEON_functional(!cpu.has_broken_neon());
61 #endif
62
63 SSL_load_error_strings(); 51 SSL_load_error_strings();
64 SSL_library_init(); 52 SSL_library_init();
65 int num_locks = CRYPTO_num_locks(); 53 int num_locks = CRYPTO_num_locks();
66 locks_.reserve(num_locks); 54 locks_.reserve(num_locks);
67 for (int i = 0; i < num_locks; ++i) 55 for (int i = 0; i < num_locks; ++i)
68 locks_.push_back(new base::Lock()); 56 locks_.push_back(new base::Lock());
69 CRYPTO_set_locking_callback(LockingCallback); 57 CRYPTO_set_locking_callback(LockingCallback);
70 CRYPTO_THREADID_set_callback(CurrentThreadId); 58 CRYPTO_THREADID_set_callback(CurrentThreadId);
59
60 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
61 const bool has_neon =
62 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
63 if (has_neon)
64 CRYPTO_set_NEON_capable(1);
65 // See https://code.google.com/p/chromium/issues/detail?id=341598
66 base::CPU cpu;
67 CRYPTO_set_NEON_functional(!cpu.has_broken_neon());
68 #endif
71 } 69 }
72 70
73 ~OpenSSLInitSingleton() { 71 ~OpenSSLInitSingleton() {
74 CRYPTO_set_locking_callback(NULL); 72 CRYPTO_set_locking_callback(NULL);
75 EVP_cleanup(); 73 EVP_cleanup();
76 ERR_free_strings(); 74 ERR_free_strings();
77 } 75 }
78 76
79 static void LockingCallback(int mode, int n, const char* file, int line) { 77 static void LockingCallback(int mode, int n, const char* file, int line) {
80 OpenSSLInitSingleton::GetInstance()->OnLockingCallback(mode, n, file, line); 78 OpenSSLInitSingleton::GetInstance()->OnLockingCallback(mode, n, file, line);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 std::string message; 121 std::string message;
124 location.Write(true, true, &message); 122 location.Write(true, true, &message);
125 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message; 123 DVLOG(1) << "OpenSSL ERR_get_error stack from " << message;
126 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL); 124 ERR_print_errors_cb(&OpenSSLErrorCallback, NULL);
127 } else { 125 } else {
128 ERR_clear_error(); 126 ERR_clear_error();
129 } 127 }
130 } 128 }
131 129
132 } // namespace crypto 130 } // namespace crypto
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698