summaryrefslogtreecommitdiff
path: root/numpy/core/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/src/common')
-rw-r--r--numpy/core/src/common/convert.c30
-rw-r--r--numpy/core/src/common/convert.h13
2 files changed, 43 insertions, 0 deletions
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 <numpy/ndarraytypes.h>
+#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