xref: /aosp_15_r20/art/runtime/entrypoints/math_entrypoints.cc (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "entrypoint_utils-inl.h"
18 
19 namespace art HIDDEN {
20 
art_l2d(int64_t l)21 extern "C" double art_l2d(int64_t l) {
22   return static_cast<double>(l);
23 }
24 
art_l2f(int64_t l)25 extern "C" float art_l2f(int64_t l) {
26   return static_cast<float>(l);
27 }
28 
29 /*
30  * Float/double conversion requires clamping to min and max of integer form.  If
31  * target doesn't support this normally, use these.
32  */
art_d2l(double d)33 extern "C" int64_t art_d2l(double d) {
34   return art_float_to_integral<int64_t, double>(d);
35 }
36 
art_f2l(float f)37 extern "C" int64_t art_f2l(float f) {
38   return art_float_to_integral<int64_t, float>(f);
39 }
40 
art_d2i(double d)41 extern "C" int32_t art_d2i(double d) {
42   return art_float_to_integral<int32_t, double>(d);
43 }
44 
art_f2i(float f)45 extern "C" int32_t art_f2i(float f) {
46   return art_float_to_integral<int32_t, float>(f);
47 }
48 
49 }  // namespace art
50