From ea4c8a1ca7bc69873d20340073fb54fb2f2eca2a Mon Sep 17 00:00:00 2001 From: mattip Date: Thu, 13 Sep 2018 18:09:03 +0300 Subject: MAINT: refactor to share npy_strto{u}ll --- numpy/core/src/common/convert.c | 30 ++++++++++++++++++++++++++++++ numpy/core/src/common/convert.h | 13 +++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 numpy/core/src/common/convert.c create mode 100644 numpy/core/src/common/convert.h (limited to 'numpy/core/src/common') diff --git a/numpy/core/src/common/convert.c b/numpy/core/src/common/convert.c new file mode 100644 index 000000000..aec925ae2 --- /dev/null +++ b/numpy/core/src/common/convert.c @@ -0,0 +1,30 @@ +#include +#include "convert.h" + +NPY_NO_EXPORT npy_longlong +npy_strtoll(const char *str, char **endptr, int base) +{ +#if defined HAVE_STRTOLL + return strtoll(str, endptr, base); +#elif defined _MSC_VER + return _strtoi64(str, endptr, base); +#else + /* ok on 64 bit posix */ + return PyOS_strtol(str, endptr, base); +#endif +} + +NPY_NO_EXPORT npy_ulonglong +npy_strtoull(const char *str, char **endptr, int base) +{ +#if defined HAVE_STRTOULL + return strtoull(str, endptr, base); +#elif defined _MSC_VER + return _strtoui64(str, endptr, base); +#else + /* ok on 64 bit posix */ + return PyOS_strtoul(str, endptr, base); +#endif +} + + diff --git a/numpy/core/src/common/convert.h b/numpy/core/src/common/convert.h new file mode 100644 index 000000000..6106b1d13 --- /dev/null +++ b/numpy/core/src/common/convert.h @@ -0,0 +1,13 @@ +#ifndef _COMMON_CONVERT_H +#define _COMMON_CONVERT_H + + +/* Convert a string to an int in an arbitrary base */ +NPY_NO_EXPORT npy_longlong +npy_strtoll(const char *str, char **endptr, int base); + +/* Convert a string to an int in an arbitrary base */ +NPY_NO_EXPORT npy_ulonglong +npy_strtoull(const char *str, char **endptr, int base); + +#endif -- cgit v1.2.1