Home | History | Annotate | Download | only in lib
      1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
      2 
      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
      6 
      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.
     14 ==============================================================================*/
     15 
     16 #include "tensorflow/stream_executor/lib/numbers.h"
     17 
     18 #include <stdlib.h>
     19 
     20 namespace perftools {
     21 namespace gputools {
     22 namespace port {
     23 
     24 bool safe_strto32(const char* str, int32* value) {
     25   char* endptr;
     26   *value = strtol(str, &endptr, 10);  // NOLINT
     27   if (endptr != str) {
     28     while (isspace(*endptr)) ++endptr;
     29   }
     30   return *str != '\0' && *endptr == '\0';
     31 }
     32 
     33 // Convert strings to floating point values.
     34 // Leading and trailing spaces are allowed.
     35 // Values may be rounded on over- and underflow.
     36 bool safe_strto32(const string& str, int32* value) {
     37   return port::safe_strto32(str.c_str(), value);
     38 }
     39 
     40 }  // namespace port
     41 }  // namespace gputools
     42 }  // namespace perftools
     43