Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 14 | |
| 15 | #ifndef COMPILER_UTIL_H |
| 16 | #define COMPILER_UTIL_H |
| 17 | |
| 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | |
Alexis Hetu | 3ef0c0a | 2015-06-09 11:37:45 -0400 | [diff] [blame] | 22 | // atof_clamp is like atof but |
| 23 | // 1. it forces C locale, i.e. forcing '.' as decimal point. |
Alexis Hetu | 40f48ab | 2018-01-24 15:58:05 -0500 | [diff] [blame] | 24 | // 2. it sets the value to FLT_MAX if overflow happens. |
Alexis Hetu | 3ef0c0a | 2015-06-09 11:37:45 -0400 | [diff] [blame] | 25 | // Return false if overflow happens. |
| 26 | bool atof_clamp(const char *str, float *value); |
| 27 | |
Alexis Hetu | 40f48ab | 2018-01-24 15:58:05 -0500 | [diff] [blame] | 28 | // If overflow happens, value is set to INT_MAX. |
Alexis Hetu | 3ef0c0a | 2015-06-09 11:37:45 -0400 | [diff] [blame] | 29 | // Return false if overflow happens. |
| 30 | bool atoi_clamp(const char *str, int *value); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 31 | |
Alexis Hetu | 40f48ab | 2018-01-24 15:58:05 -0500 | [diff] [blame] | 32 | // If overflow happens, value is set to UINT_MAX. |
| 33 | // Return false if overflow happens. |
| 34 | bool atou_clamp(const char *str, unsigned int *value); |
| 35 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 36 | #ifdef __cplusplus |
| 37 | } // end extern "C" |
| 38 | #endif |
| 39 | |
| 40 | #endif // COMPILER_UTIL_H |