blob: 563407e42dc2eb6501c9bc1d713700f1a16a8196 [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
John Bauman89401822014-05-06 15:04:28 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// 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 Bauman89401822014-05-06 15:04:28 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// 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 Bauman89401822014-05-06 15:04:28 -040014
15#ifndef COMPILER_UTIL_H
16#define COMPILER_UTIL_H
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
Alexis Hetu3ef0c0a2015-06-09 11:37:45 -040022// atof_clamp is like atof but
23// 1. it forces C locale, i.e. forcing '.' as decimal point.
Alexis Hetu40f48ab2018-01-24 15:58:05 -050024// 2. it sets the value to FLT_MAX if overflow happens.
Alexis Hetu3ef0c0a2015-06-09 11:37:45 -040025// Return false if overflow happens.
26bool atof_clamp(const char *str, float *value);
27
Alexis Hetu40f48ab2018-01-24 15:58:05 -050028// If overflow happens, value is set to INT_MAX.
Alexis Hetu3ef0c0a2015-06-09 11:37:45 -040029// Return false if overflow happens.
30bool atoi_clamp(const char *str, int *value);
John Bauman89401822014-05-06 15:04:28 -040031
Alexis Hetu40f48ab2018-01-24 15:58:05 -050032// If overflow happens, value is set to UINT_MAX.
33// Return false if overflow happens.
34bool atou_clamp(const char *str, unsigned int *value);
35
John Bauman89401822014-05-06 15:04:28 -040036#ifdef __cplusplus
37} // end extern "C"
38#endif
39
40#endif // COMPILER_UTIL_H