| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Platform specific code for POSIX goes here. This is not a platform on its | 28 // Platform specific code for POSIX goes here. This is not a platform on its |
| 29 // own but contains the parts which are the same across POSIX platforms Linux, | 29 // own but contains the parts which are the same across POSIX platforms Linux, |
| 30 // Mac OS, FreeBSD and OpenBSD. | 30 // Mac OS, FreeBSD and OpenBSD. |
| 31 | 31 |
| 32 #include "platform-posix.h" |
| 33 |
| 32 #include <unistd.h> | 34 #include <unistd.h> |
| 33 #include <errno.h> | 35 #include <errno.h> |
| 34 #include <time.h> | 36 #include <time.h> |
| 35 | 37 |
| 36 #include <sys/mman.h> | 38 #include <sys/mman.h> |
| 37 #include <sys/socket.h> | 39 #include <sys/socket.h> |
| 38 #include <sys/resource.h> | 40 #include <sys/resource.h> |
| 39 #include <sys/time.h> | 41 #include <sys/time.h> |
| 40 #include <sys/types.h> | 42 #include <sys/types.h> |
| 41 #include <sys/stat.h> | 43 #include <sys/stat.h> |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // ---------------------------------------------------------------------------- | 124 // ---------------------------------------------------------------------------- |
| 123 // Math functions | 125 // Math functions |
| 124 | 126 |
| 125 double modulo(double x, double y) { | 127 double modulo(double x, double y) { |
| 126 return fmod(x, y); | 128 return fmod(x, y); |
| 127 } | 129 } |
| 128 | 130 |
| 129 | 131 |
| 130 #define UNARY_MATH_FUNCTION(name, generator) \ | 132 #define UNARY_MATH_FUNCTION(name, generator) \ |
| 131 static UnaryMathFunction fast_##name##_function = NULL; \ | 133 static UnaryMathFunction fast_##name##_function = NULL; \ |
| 132 V8_DECLARE_ONCE(fast_##name##_init_once); \ | |
| 133 void init_fast_##name##_function() { \ | 134 void init_fast_##name##_function() { \ |
| 134 fast_##name##_function = generator; \ | 135 fast_##name##_function = generator; \ |
| 135 } \ | 136 } \ |
| 136 double fast_##name(double x) { \ | 137 double fast_##name(double x) { \ |
| 137 CallOnce(&fast_##name##_init_once, \ | |
| 138 &init_fast_##name##_function); \ | |
| 139 return (*fast_##name##_function)(x); \ | 138 return (*fast_##name##_function)(x); \ |
| 140 } | 139 } |
| 141 | 140 |
| 142 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) | 141 UNARY_MATH_FUNCTION(sin, CreateTranscendentalFunction(TranscendentalCache::SIN)) |
| 143 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) | 142 UNARY_MATH_FUNCTION(cos, CreateTranscendentalFunction(TranscendentalCache::COS)) |
| 144 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) | 143 UNARY_MATH_FUNCTION(tan, CreateTranscendentalFunction(TranscendentalCache::TAN)) |
| 145 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) | 144 UNARY_MATH_FUNCTION(log, CreateTranscendentalFunction(TranscendentalCache::LOG)) |
| 146 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | 145 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) |
| 147 | 146 |
| 148 #undef MATH_FUNCTION | 147 #undef MATH_FUNCTION |
| 149 | 148 |
| 150 | 149 |
| 150 void MathSetup() { |
| 151 init_fast_sin_function(); |
| 152 init_fast_cos_function(); |
| 153 init_fast_tan_function(); |
| 154 init_fast_log_function(); |
| 155 init_fast_sqrt_function(); |
| 156 } |
| 157 |
| 158 |
| 151 double OS::nan_value() { | 159 double OS::nan_value() { |
| 152 // NAN from math.h is defined in C99 and not in POSIX. | 160 // NAN from math.h is defined in C99 and not in POSIX. |
| 153 return NAN; | 161 return NAN; |
| 154 } | 162 } |
| 155 | 163 |
| 156 | 164 |
| 157 // ---------------------------------------------------------------------------- | 165 // ---------------------------------------------------------------------------- |
| 158 // POSIX date/time support. | 166 // POSIX date/time support. |
| 159 // | 167 // |
| 160 | 168 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 return ntohl(value); | 521 return ntohl(value); |
| 514 } | 522 } |
| 515 | 523 |
| 516 | 524 |
| 517 Socket* OS::CreateSocket() { | 525 Socket* OS::CreateSocket() { |
| 518 return new POSIXSocket(); | 526 return new POSIXSocket(); |
| 519 } | 527 } |
| 520 | 528 |
| 521 | 529 |
| 522 } } // namespace v8::internal | 530 } } // namespace v8::internal |
| OLD | NEW |