| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/os_compat_android.h" | 5 #include "base/os_compat_android.h" |
| 6 | 6 |
| 7 #include <asm/unistd.h> | 7 #include <asm/unistd.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <math.h> | 9 #include <math.h> |
| 10 #include <sys/stat.h> | 10 #include <sys/stat.h> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // library provided by the NDK for API level 9. When the optimization kicks | 68 // library provided by the NDK for API level 9. When the optimization kicks |
| 69 // in, it makes the final build fail with a puzzling message (puzzling | 69 // in, it makes the final build fail with a puzzling message (puzzling |
| 70 // because 'sincos' doesn't appear anywhere in the sources!). | 70 // because 'sincos' doesn't appear anywhere in the sources!). |
| 71 // | 71 // |
| 72 // To solve this, we provide our own implementation of the sincos() function | 72 // To solve this, we provide our own implementation of the sincos() function |
| 73 // and related friends. Note that we must also explicitely tell GCC to disable | 73 // and related friends. Note that we must also explicitely tell GCC to disable |
| 74 // optimizations when generating these. Otherwise, the generated machine code | 74 // optimizations when generating these. Otherwise, the generated machine code |
| 75 // for each function would simply end up calling itself, resulting in a | 75 // for each function would simply end up calling itself, resulting in a |
| 76 // runtime crash due to stack overflow. | 76 // runtime crash due to stack overflow. |
| 77 // | 77 // |
| 78 #if defined(__GNUC__) && !defined(__clang__) | 78 #if defined(__GNUC__) && !defined(__clang__) && \ |
| 79 !defined(ANDROID_SINCOS_PROVIDED) |
| 79 | 80 |
| 80 // For the record, Clang does not support the 'optimize' attribute. | 81 // For the record, Clang does not support the 'optimize' attribute. |
| 81 // In the unlikely event that it begins performing this optimization too, | 82 // In the unlikely event that it begins performing this optimization too, |
| 82 // we'll have to find a different way to achieve this. NOTE: Tested with O1 | 83 // we'll have to find a different way to achieve this. NOTE: Tested with O1 |
| 83 // which still performs the optimization. | 84 // which still performs the optimization. |
| 84 // | 85 // |
| 85 #define GCC_NO_OPTIMIZE __attribute__((optimize("O0"))) | 86 #define GCC_NO_OPTIMIZE __attribute__((optimize("O0"))) |
| 86 | 87 |
| 87 GCC_NO_OPTIMIZE | 88 GCC_NO_OPTIMIZE |
| 88 void sincos(double angle, double* s, double *c) { | 89 void sincos(double angle, double* s, double *c) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // The directory doesn't exist, but an error occured | 162 // The directory doesn't exist, but an error occured |
| 162 return NULL; | 163 return NULL; |
| 163 } | 164 } |
| 164 } | 165 } |
| 165 | 166 |
| 166 // We reached the max number of tries. | 167 // We reached the max number of tries. |
| 167 return NULL; | 168 return NULL; |
| 168 } | 169 } |
| 169 | 170 |
| 170 } // extern "C" | 171 } // extern "C" |
| OLD | NEW |