summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/common/util/strtol.c71
-rw-r--r--usr/src/common/util/strtolctype.h75
-rw-r--r--usr/src/common/util/strtoll.c (renamed from usr/src/lib/libc/port/gen/strtoll.c)85
-rw-r--r--usr/src/common/util/strtoul.c62
-rw-r--r--usr/src/common/util/strtoull.c (renamed from usr/src/lib/libc/port/gen/strtoull.c)75
-rw-r--r--usr/src/lib/libc/amd64/Makefile6
-rw-r--r--usr/src/lib/libc/i386/Makefile.com6
-rw-r--r--usr/src/lib/libc/sparc/Makefile6
-rw-r--r--usr/src/lib/libc/sparcv9/Makefile6
-rw-r--r--usr/src/uts/common/Makefile.files5
-rw-r--r--usr/src/uts/common/io/comstar/port/iscsit/iscsit_auth.c4
-rw-r--r--usr/src/uts/common/io/idm/idm_text.c113
-rw-r--r--usr/src/uts/common/os/ddi_strtol.c216
-rw-r--r--usr/src/uts/common/sys/ddi_obsolete.h6
-rw-r--r--usr/src/uts/common/sys/idm/idm_text.h6
-rw-r--r--usr/src/uts/common/sys/sunddi.h4
-rw-r--r--usr/src/uts/common/sys/types.h7
17 files changed, 283 insertions, 470 deletions
diff --git a/usr/src/common/util/strtol.c b/usr/src/common/util/strtol.c
index 26614146e9..8a67da740f 100644
--- a/usr/src/common/util/strtol.c
+++ b/usr/src/common/util/strtol.c
@@ -20,54 +20,54 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(_BOOT) && !defined(_KMDB)
+#if defined(_KERNEL) && !defined(_BOOT)
+#include <sys/errno.h>
+#else /* _KERNEL && !_BOOT */
+#if !defined(_BOOT) && !defined(_KMDB)
#include "lint.h"
-#endif /* !_BOOT && !_KMDB */
+#endif /* !_BOOT && !_KMDB */
#include <errno.h>
#include <ctype.h>
#include <limits.h>
-#include <sys/types.h>
#include <stdlib.h>
+#endif /* _KERNEL && !_BOOT */
+#include "strtolctype.h"
+#include <sys/types.h>
-#define DIGIT(x) \
- (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
-
-#define MBASE ('z' - 'a' + 1 + 10)
-
-/*
- * The following macro is a local version of isalnum() which limits
- * alphabetic characters to the ranges a-z and A-Z; locale dependent
- * characters will not return 1. The members of a-z and A-Z are
- * assumed to be in ascending order and contiguous
- */
-#define lisalnum(x) \
- (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
-
+#if defined(_KERNEL) && !defined(_BOOT)
+int
+ddi_strtol(const char *str, char **nptr, int base, long *result)
+#else /* _KERNEL && !_BOOT */
long
strtol(const char *str, char **nptr, int base)
+#endif /* _KERNEL && !_BOOT */
{
long val;
int c;
- int xx, neg = 0;
- long multmin;
- long limit;
+ int xx;
+ int neg = 0;
+ long multmin;
+ long limit;
const char **ptr = (const char **)nptr;
- const unsigned char *ustr = (const unsigned char *)str;
+ const unsigned char *ustr = (const unsigned char *)str;
if (ptr != (const char **)0)
*ptr = (char *)ustr; /* in case no number is formed */
if (base < 0 || base > MBASE || base == 1) {
+ /* base is invalid -- should be a fatal error */
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (EINVAL);
+#else /* _KERNEL && !_BOOT */
errno = EINVAL;
- return (0); /* base is invalid -- should be a fatal error */
+ return (0);
+#endif /* _KERNEL && !_BOOT */
}
if (!isalnum(c = *ustr)) {
while (isspace(c))
@@ -91,8 +91,14 @@ strtol(const char *str, char **nptr, int base)
* for any base > 10, the digits incrementally following
* 9 are assumed to be "abc...z" or "ABC...Z"
*/
- if (!lisalnum(c) || (xx = DIGIT(c)) >= base)
- return (0); /* no number formed */
+ if (!lisalnum(c) || (xx = DIGIT(c)) >= base) {
+ /* no number formed */
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (EINVAL);
+#else /* _KERNEL && !_BOOT */
+ return (0);
+#endif /* _KERNEL && !_BOOT */
+ }
if (base == 16 && c == '0' && (ustr[1] == 'x' || ustr[1] == 'X') &&
isxdigit(ustr[2]))
c = *(ustr += 2); /* skip over leading "0x" or "0X" */
@@ -105,7 +111,7 @@ strtol(const char *str, char **nptr, int base)
multmin = limit / (long)base;
val = -DIGIT(c);
for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; ) {
- /* accumulate neg avoids surprises near MAXLONG */
+ /* accumulate neg avoids surprises near LONG_MAX */
if (val < multmin)
goto overflow;
val *= base;
@@ -116,13 +122,22 @@ strtol(const char *str, char **nptr, int base)
}
if (ptr != (const char **)0)
*ptr = (char *)ustr;
+#if defined(_KERNEL) && !defined(_BOOT)
+ *result = neg ? val : -val;
+ return (0);
+#else /* _KERNEL && !_BOOT */
return (neg ? val : -val);
+#endif /* _KERNEL && !_BOOT */
overflow:
for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; (c = *++ustr))
;
if (ptr != (const char **)0)
*ptr = (char *)ustr;
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (ERANGE);
+#else /* _KERNEL && !_BOOT */
errno = ERANGE;
return (neg ? LONG_MIN : LONG_MAX);
+#endif /* _KERNEL && !_BOOT */
}
diff --git a/usr/src/common/util/strtolctype.h b/usr/src/common/util/strtolctype.h
new file mode 100644
index 0000000000..7b7afc6e30
--- /dev/null
+++ b/usr/src/common/util/strtolctype.h
@@ -0,0 +1,75 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+/* Copyright (c) 1988 AT&T */
+/* All Rights Reserved */
+
+#ifndef _COMMON_UTIL_CTYPE_H
+#define _COMMON_UTIL_CTYPE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * This header file contains a collection of macros that the strtou?ll?
+ * functions in common/util use to test characters. What we need is a kernel
+ * version of ctype.h.
+ */
+
+#if defined(_KERNEL) && !defined(_BOOT)
+
+#define isalnum(ch) (isalpha(ch) || isdigit(ch))
+#define isalpha(ch) (isupper(ch) || islower(ch))
+#define isdigit(ch) ((ch) >= '0' && (ch) <= '9')
+#define islower(ch) ((ch) >= 'a' && (ch) <= 'z')
+#define isspace(ch) (((ch) == ' ') || ((ch) == '\r') || ((ch) == '\n') || \
+ ((ch) == '\t') || ((ch) == '\f'))
+#define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
+#define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \
+ ((ch) >= 'A' && (ch) <= 'F'))
+
+#endif /* _KERNEL && !_BOOT */
+
+#define DIGIT(x) \
+ (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
+
+#define MBASE ('z' - 'a' + 1 + 10)
+
+/*
+ * The following macro is a version of isalnum() that limits alphabetic
+ * characters to the ranges a-z and A-Z; locale dependent characters will not
+ * return 1. The members of a-z and A-Z are assumed to be in ascending order
+ * and contiguous.
+ */
+#define lisalnum(x) \
+ (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _COMMON_UTIL_CTYPE_H */
diff --git a/usr/src/lib/libc/port/gen/strtoll.c b/usr/src/common/util/strtoll.c
index d594cd9053..6e654c9ed5 100644
--- a/usr/src/lib/libc/port/gen/strtoll.c
+++ b/usr/src/common/util/strtoll.c
@@ -20,56 +20,54 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
+#if defined(_KERNEL) && !defined(_BOOT)
+#include <sys/errno.h>
+#else /* _KERNEL && !_BOOT */
+#if !defined(_BOOT) && !defined(_KMDB)
#include "lint.h"
+#endif /* !_BOOT && !_KMDB */
#include <errno.h>
#include <ctype.h>
#include <limits.h>
-#include <sys/types.h>
#include <stdlib.h>
+#endif /* _KERNEL && !_BOOT */
+#include "strtolctype.h"
+#include <sys/types.h>
-#define DIGIT(x) \
- (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
-
-#define MBASE ('z' - 'a' + 1 + 10)
-
-/*
- * The following macro is a local version of isalnum() which limits
- * alphabetic characters to the ranges a-z and A-Z; locale dependent
- * characters will not return 1. The members of a-z and A-Z are
- * assumed to be in ascending order and contiguous
- */
-#define lisalnum(x) \
- (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
-
+#if defined(_KERNEL) && !defined(_BOOT)
+int
+ddi_strtoll(const char *str, char **nptr, int base, longlong_t *result)
+#else /* _KERNEL && !_BOOT */
longlong_t
strtoll(const char *str, char **nptr, int base)
+#endif /* _KERNEL && !_BOOT */
{
longlong_t val;
int c;
- int xx, neg = 0;
- longlong_t multmin;
- longlong_t limit;
- longlong_t llong_min, llong_max;
+ int xx;
+ int neg = 0;
+ longlong_t multmin;
+ longlong_t limit;
const char **ptr = (const char **)nptr;
- const unsigned char *ustr = (const unsigned char *)str;
-
- llong_min = LLONG_MIN; /* from a local version of limits.h */
- llong_max = LLONG_MAX;
+ const unsigned char *ustr = (const unsigned char *)str;
if (ptr != (const char **)0)
*ptr = (char *)ustr; /* in case no number is formed */
if (base < 0 || base > MBASE || base == 1) {
+ /* base is invalid -- should be a fatal error */
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (EINVAL);
+#else /* _KERNEL && !_BOOT */
errno = EINVAL;
- return (0); /* base is invalid -- should be a fatal error */
+ return (0);
+#endif /* _KERNEL && !_BOOT */
}
if (!isalnum(c = *ustr)) {
while (isspace(c))
@@ -93,23 +91,27 @@ strtoll(const char *str, char **nptr, int base)
* for any base > 10, the digits incrementally following
* 9 are assumed to be "abc...z" or "ABC...Z"
*/
- if (!lisalnum(c) || (xx = DIGIT(c)) >= base)
- return (0); /* no number formed */
+ if (!lisalnum(c) || (xx = DIGIT(c)) >= base) {
+ /* no number formed */
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (EINVAL);
+#else /* _KERNEL && !_BOOT */
+ return (0);
+#endif /* _KERNEL && !_BOOT */
+ }
if (base == 16 && c == '0' && (ustr[1] == 'x' || ustr[1] == 'X') &&
isxdigit(ustr[2]))
c = *(ustr += 2); /* skip over leading "0x" or "0X" */
- /* this code assumes that abs(llong_min) >= abs(llong_max) */
+ /* this code assumes that abs(LLONG_MIN) >= abs(LLONG_MAX) */
if (neg)
- limit = llong_min;
+ limit = LLONG_MIN;
else
- limit = -llong_max;
-
- multmin = limit / base;
-
+ limit = -LLONG_MAX;
+ multmin = limit / (longlong_t)base;
val = -DIGIT(c);
for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; ) {
- /* accumulate neg avoids surprises near llong_max */
+ /* accumulate neg avoids surprises near LLONG_MAX */
if (val < multmin)
goto overflow;
val *= base;
@@ -120,13 +122,22 @@ strtoll(const char *str, char **nptr, int base)
}
if (ptr != (const char **)0)
*ptr = (char *)ustr;
+#if defined(_KERNEL) && !defined(_BOOT)
+ *result = neg ? val : -val;
+ return (0);
+#else /* _KERNEL && !_BOOT */
return (neg ? val : -val);
+#endif /* _KERNEL && !_BOOT */
overflow:
for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; (c = *++ustr))
;
if (ptr != (const char **)0)
*ptr = (char *)ustr;
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (ERANGE);
+#else /* _KERNEL && !_BOOT */
errno = ERANGE;
- return (neg ? llong_min : llong_max);
+ return (neg ? LLONG_MIN : LLONG_MAX);
+#endif /* _KERNEL && !_BOOT */
}
diff --git a/usr/src/common/util/strtoul.c b/usr/src/common/util/strtoul.c
index 9d01f2eebf..3b1eff90c1 100644
--- a/usr/src/common/util/strtoul.c
+++ b/usr/src/common/util/strtoul.c
@@ -20,54 +20,53 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(_BOOT) && !defined(_KMDB)
+#if defined(_KERNEL) && !defined(_BOOT)
+#include <sys/errno.h>
+#else /* _KERNEL && !_BOOT */
+#if !defined(_BOOT) && !defined(_KMDB)
#include "lint.h"
-#endif /* !_BOOT && !_KMDB */
+#endif /* !_BOOT && !_KMDB */
#include <errno.h>
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
+#endif /* _KERNEL && !_BOOT */
+#include "strtolctype.h"
#include <sys/types.h>
-#define DIGIT(x) \
- (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
-
-#define MBASE ('z' - 'a' + 1 + 10)
-
-/*
- * The following macro is a local version of isalnum() which limits
- * alphabetic characters to the ranges a-z and A-Z; locale dependent
- * characters will not return 1. The members of a-z and A-Z are
- * assumed to be in ascending order and contiguous
- */
-#define lisalnum(x) \
- (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
-
+#if defined(_KERNEL) && !defined(_BOOT)
+int
+ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result)
+#else /* _KERNEL && !_BOOT */
unsigned long
strtoul(const char *str, char **nptr, int base)
+#endif /* _KERNEL && !_BOOT */
{
unsigned long val;
int c;
int xx;
- unsigned long multmax;
int neg = 0;
+ unsigned long multmax;
const char **ptr = (const char **)nptr;
- const unsigned char *ustr = (const unsigned char *)str;
+ const unsigned char *ustr = (const unsigned char *)str;
if (ptr != (const char **)0)
*ptr = (char *)ustr; /* in case no number is formed */
if (base < 0 || base > MBASE || base == 1) {
+ /* base is invalid -- should be a fatal error */
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (EINVAL);
+#else /* _KERNEL && !_BOOT */
errno = EINVAL;
- return (0); /* base is invalid -- should be a fatal error */
+ return (0);
+#endif /* _KERNEL && !_BOOT */
}
if (!isalnum(c = *ustr)) {
while (isspace(c))
@@ -91,8 +90,14 @@ strtoul(const char *str, char **nptr, int base)
* for any base > 10, the digits incrementally following
* 9 are assumed to be "abc...z" or "ABC...Z"
*/
- if (!lisalnum(c) || (xx = DIGIT(c)) >= base)
- return (0); /* no number formed */
+ if (!lisalnum(c) || (xx = DIGIT(c)) >= base) {
+ /* no number formed */
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (EINVAL);
+#else /* _KERNEL && !_BOOT */
+ return (0);
+#endif /* _KERNEL && !_BOOT */
+ }
if (base == 16 && c == '0' && (ustr[1] == 'x' || ustr[1] == 'X') &&
isxdigit(ustr[2]))
c = *(ustr += 2); /* skip over leading "0x" or "0X" */
@@ -110,13 +115,22 @@ strtoul(const char *str, char **nptr, int base)
}
if (ptr != (const char **)0)
*ptr = (char *)ustr;
+#if defined(_KERNEL) && !defined(_BOOT)
+ *result = neg ? -val : val;
+ return (0);
+#else /* _KERNEL && !_BOOT */
return (neg ? -val : val);
+#endif /* _KERNEL && !_BOOT */
overflow:
for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; (c = *++ustr))
;
if (ptr != (const char **)0)
*ptr = (char *)ustr;
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (ERANGE);
+#else /* _KERNEL && !_BOOT */
errno = ERANGE;
return (ULONG_MAX);
+#endif /* _KERNEL && !_BOOT */
}
diff --git a/usr/src/lib/libc/port/gen/strtoull.c b/usr/src/common/util/strtoull.c
index 6d474eded6..ca7713d524 100644
--- a/usr/src/lib/libc/port/gen/strtoull.c
+++ b/usr/src/common/util/strtoull.c
@@ -20,57 +20,53 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
+#if defined(_KERNEL) && !defined(_BOOT)
+#include <sys/errno.h>
+#else /* _KERNEL && !_BOOT */
+#if !defined(_BOOT) && !defined(_KMDB)
#include "lint.h"
+#endif /* !_BOOT && !_KMDB */
#include <errno.h>
#include <ctype.h>
#include <limits.h>
-#include <sys/types.h>
#include <stdlib.h>
+#endif /* _KERNEL && !_BOOT */
+#include "strtolctype.h"
+#include <sys/types.h>
-#define DIGIT(x) \
- (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
-
-#define MBASE ('z' - 'a' + 1 + 10)
-
-
-/*
- * The following macro is a local version of isalnum() which limits
- * alphabetic characters to the ranges a-z and A-Z; locale dependent
- * characters will not return 1. The members of a-z and A-Z are
- * assumed to be in ascending order and contiguous
- */
-#define lisalnum(x) \
- (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
-
+#if defined(_KERNEL) && !defined(_BOOT)
+int
+ddi_strtoull(const char *str, char **nptr, int base, u_longlong_t *result)
+#else /* _KERNEL && !_BOOT */
u_longlong_t
strtoull(const char *str, char **nptr, int base)
+#endif /* _KERNEL && !_BOOT */
{
u_longlong_t val;
int c;
int xx;
- u_longlong_t multmax;
- u_longlong_t ullong_max;
int neg = 0;
- const char **ptr = (const char **)nptr;
- const unsigned char *ustr = (const unsigned char *)str;
+ u_longlong_t multmax;
+ const char **ptr = (const char **)nptr;
+ const unsigned char *ustr = (const unsigned char *)str;
if (ptr != (const char **)0)
*ptr = (char *)ustr; /* in case no number is formed */
-
- ullong_max = ULLONG_MAX; /* from a local version of limits.h */
-
if (base < 0 || base > MBASE || base == 1) {
+ /* base is invalid -- should be a fatal error */
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (EINVAL);
+#else /* _KERNEL && !_BOOT */
errno = EINVAL;
- return (0); /* base is invalid -- should be a fatal error */
+ return (0);
+#endif /* _KERNEL && !_BOOT */
}
if (!isalnum(c = *ustr)) {
while (isspace(c))
@@ -94,32 +90,47 @@ strtoull(const char *str, char **nptr, int base)
* for any base > 10, the digits incrementally following
* 9 are assumed to be "abc...z" or "ABC...Z"
*/
- if (!lisalnum(c) || (xx = DIGIT(c)) >= base)
- return (0); /* no number formed */
+ if (!lisalnum(c) || (xx = DIGIT(c)) >= base) {
+ /* no number formed */
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (EINVAL);
+#else /* _KERNEL && !_BOOT */
+ return (0);
+#endif /* _KERNEL && !_BOOT */
+ }
if (base == 16 && c == '0' && (ustr[1] == 'x' || ustr[1] == 'X') &&
isxdigit(ustr[2]))
c = *(ustr += 2); /* skip over leading "0x" or "0X" */
- multmax = ullong_max / (u_longlong_t)base;
+ multmax = ULLONG_MAX / (u_longlong_t)base;
val = DIGIT(c);
for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; ) {
if (val > multmax)
goto overflow;
val *= base;
- if (ullong_max - val < xx)
+ if (ULLONG_MAX - val < xx)
goto overflow;
val += xx;
c = *++ustr;
}
if (ptr != (const char **)0)
*ptr = (char *)ustr;
+#if defined(_KERNEL) && !defined(_BOOT)
+ *result = neg ? -val : val;
+ return (0);
+#else /* _KERNEL && !_BOOT */
return (neg ? -val : val);
+#endif /* _KERNEL && !_BOOT */
overflow:
for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; (c = *++ustr))
;
if (ptr != (const char **)0)
*ptr = (char *)ustr;
+#if defined(_KERNEL) && !defined(_BOOT)
+ return (ERANGE);
+#else /* _KERNEL && !_BOOT */
errno = ERANGE;
- return (ullong_max);
+ return (ULLONG_MAX);
+#endif /* _KERNEL && !_BOOT */
}
diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile
index 0d261ea062..5824f3aaa3 100644
--- a/usr/src/lib/libc/amd64/Makefile
+++ b/usr/src/lib/libc/amd64/Makefile
@@ -94,7 +94,9 @@ COMOBJS= \
ffs.o \
qsort.o \
strtol.o \
- strtoul.o
+ strtoul.o \
+ strtoll.o \
+ strtoull.o
GENOBJS= \
_getsp.o \
@@ -547,8 +549,6 @@ PORTGEN= \
strtoimax.o \
strtok.o \
strtok_r.o \
- strtoll.o \
- strtoull.o \
strtoumax.o \
swab.o \
swapctl.o \
diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com
index 27028899d5..1222822d94 100644
--- a/usr/src/lib/libc/i386/Makefile.com
+++ b/usr/src/lib/libc/i386/Makefile.com
@@ -94,7 +94,9 @@ COMOBJS= \
ffs.o \
qsort.o \
strtol.o \
- strtoul.o
+ strtoul.o \
+ strtoll.o \
+ strtoull.o
DTRACEOBJS= \
dtrace_data.o
@@ -577,8 +579,6 @@ PORTGEN= \
strtoimax.o \
strtok.o \
strtok_r.o \
- strtoll.o \
- strtoull.o \
strtoumax.o \
swab.o \
swapctl.o \
diff --git a/usr/src/lib/libc/sparc/Makefile b/usr/src/lib/libc/sparc/Makefile
index cc787fcaf1..5b69107630 100644
--- a/usr/src/lib/libc/sparc/Makefile
+++ b/usr/src/lib/libc/sparc/Makefile
@@ -114,7 +114,9 @@ COMOBJS= \
memccpy.o \
qsort.o \
strtol.o \
- strtoul.o
+ strtoul.o \
+ strtoll.o \
+ strtoull.o
DTRACEOBJS= \
dtrace_data.o
@@ -602,8 +604,6 @@ PORTGEN= \
strtoimax.o \
strtok.o \
strtok_r.o \
- strtoll.o \
- strtoull.o \
strtoumax.o \
swab.o \
swapctl.o \
diff --git a/usr/src/lib/libc/sparcv9/Makefile b/usr/src/lib/libc/sparcv9/Makefile
index af36ea9cdd..ca6763246f 100644
--- a/usr/src/lib/libc/sparcv9/Makefile
+++ b/usr/src/lib/libc/sparcv9/Makefile
@@ -118,7 +118,9 @@ COMOBJS= \
memccpy.o \
qsort.o \
strtol.o \
- strtoul.o
+ strtoul.o \
+ strtoll.o \
+ strtoull.o
GENOBJS= \
_getsp.o \
@@ -562,8 +564,6 @@ PORTGEN= \
strtoimax.o \
strtok.o \
strtok_r.o \
- strtoll.o \
- strtoull.o \
strtoumax.o \
swab.o \
swapctl.o \
diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files
index 371d86c60c..19f0512969 100644
--- a/usr/src/uts/common/Makefile.files
+++ b/usr/src/uts/common/Makefile.files
@@ -64,6 +64,10 @@ COMMON_CORE_OBJS += \
seg_kmem.o \
softint.o \
string.o \
+ strtol.o \
+ strtoul.o \
+ strtoll.o \
+ strtoull.o \
thread_intr.o \
vm_page.o \
vm_pagelist.o \
@@ -121,7 +125,6 @@ GENUNIX_OBJS += \
ddi_intr_impl.o \
ddi_intr_irm.o \
ddi_nodeid.o \
- ddi_strtol.o \
ddi_timer.o \
devcfg.o \
devcache.o \
diff --git a/usr/src/uts/common/io/comstar/port/iscsit/iscsit_auth.c b/usr/src/uts/common/io/comstar/port/iscsit/iscsit_auth.c
index 762081e5b6..ed7ac05ea7 100644
--- a/usr/src/uts/common/io/comstar/port/iscsit/iscsit_auth.c
+++ b/usr/src/uts/common/io/comstar/port/iscsit/iscsit_auth.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -296,7 +296,7 @@ auth_chap_select_alg(iscsit_conn_t *ict, nvpair_t *nvp,
while (alg_choice != NULL) {
nvrc = nvpair_value_string(alg_choice, &alg_string);
ASSERT(nvrc == 0);
- rc = idm_strtoull(alg_string, NULL, 0, (u_longlong_t *)&alg);
+ rc = ddi_strtoull(alg_string, NULL, 0, (u_longlong_t *)&alg);
if (rc == 0 && alg == 5) {
/* only MD5 is supported */
text = alg_string;
diff --git a/usr/src/uts/common/io/idm/idm_text.c b/usr/src/uts/common/io/idm/idm_text.c
index ac3d2617df..1b00333e77 100644
--- a/usr/src/uts/common/io/idm/idm_text.c
+++ b/usr/src/uts/common/io/idm/idm_text.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -541,7 +541,7 @@ idm_nvlist_add_binary(nvlist_t *nvl,
* as a hex or base64 value. Therefore we'll convert it
* to an array of bytes.
*/
- if ((rc = idm_strtoull(value, NULL, 0,
+ if ((rc = ddi_strtoull(value, NULL, 0,
(u_longlong_t *)&uint64_value)) != 0)
return (rc);
@@ -582,7 +582,7 @@ idm_nvlist_add_numerical(nvlist_t *nvl,
* This shouldn't happen with real-world values for the current
* iSCSI parameters of "numerical" type.
*/
- rc = idm_strtoull(value, NULL, 0, (u_longlong_t *)&uint64_value);
+ rc = ddi_strtoull(value, NULL, 0, (u_longlong_t *)&uint64_value);
if (rc == 0) {
rc = nvlist_add_uint64(nvl, ikvx->ik_key_name, uint64_value);
}
@@ -628,7 +628,7 @@ idm_nvlist_add_numeric_range(nvlist_t *nvl,
* Start value
*/
*(val_scan + val_len + 1) = '\0';
- rc = idm_strtoull(val_scan, NULL, 0, (u_longlong_t *)&start_val);
+ rc = ddi_strtoull(val_scan, NULL, 0, (u_longlong_t *)&start_val);
if (rc == 0) {
rc = nvlist_add_uint64(range_nvl, "start", start_val);
}
@@ -641,7 +641,7 @@ idm_nvlist_add_numeric_range(nvlist_t *nvl,
* End value
*/
val_scan += val_len + 1;
- rc = idm_strtoull(val_scan, NULL, 0, (u_longlong_t *)&end_val);
+ rc = ddi_strtoull(val_scan, NULL, 0, (u_longlong_t *)&end_val);
if (rc == 0) {
rc = nvlist_add_uint64(range_nvl, "start", end_val);
}
@@ -1616,106 +1616,3 @@ cleanup:
*/
return (ret);
}
-
-/*
- * idm_strtoull
- *
- * Since the kernel only provides ddi_strtoul (not the ddi_strtoull that we
- * would like to use) we need our own conversion function to convert
- * string integer representations to 64-bit integers. ddi_strtoul doesn't
- * work well for us on 32-bit systems. This code is shamelessly ripped
- * from ddi_strtol.c. Eventually we should push this back into the DDI
- * so that we don't need our own version anymore.
- */
-
-#define isalnum(ch) (isalpha(ch) || isdigit(ch))
-#define isalpha(ch) (isupper(ch) || islower(ch))
-#define isdigit(ch) ((ch) >= '0' && (ch) <= '9')
-#define islower(ch) ((ch) >= 'a' && (ch) <= 'z')
-#define isspace(ch) (((ch) == ' ') || ((ch) == '\r') || ((ch) == '\n') || \
- ((ch) == '\t') || ((ch) == '\f'))
-#define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
-#define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \
- ((ch) >= 'A' && (ch) <= 'F'))
-
-#define DIGIT(x) \
- (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
-
-#define MBASE ('z' - 'a' + 1 + 10)
-
-#define lisalnum(x) \
- (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
-
-#ifndef ULLONG_MAX
-#define ULLONG_MAX 18446744073709551615ULL
-#endif
-
-int
-idm_strtoull(const char *str, char **nptr, int base,
- unsigned long long *result)
-{
- unsigned long long val;
- int c;
- int xx;
- unsigned long long multmax;
- int neg = 0;
- const char **ptr = (const char **)nptr;
- const unsigned char *ustr = (const unsigned char *)str;
-
- if (ptr != (const char **)0)
- *ptr = (char *)ustr; /* in case no number is formed */
- if (base < 0 || base > MBASE || base == 1) {
- /* base is invalid -- should be a fatal error */
- return (EINVAL);
- }
- if (!isalnum(c = *ustr)) {
- while (isspace(c))
- c = *++ustr;
- switch (c) {
- case '-':
- neg++;
- /* FALLTHROUGH */
- case '+':
- c = *++ustr;
- }
- }
- if (base == 0)
- if (c != '0')
- base = 10;
- else if (ustr[1] == 'x' || ustr[1] == 'X')
- base = 16;
- else
- base = 8;
- /*
- * for any base > 10, the digits incrementally following
- * 9 are assumed to be "abc...z" or "ABC...Z"
- */
- if (!lisalnum(c) || (xx = DIGIT(c)) >= base)
- return (EINVAL); /* no number formed */
- if (base == 16 && c == '0' && (ustr[1] == 'x' || ustr[1] == 'X') &&
- isxdigit(ustr[2]))
- c = *(ustr += 2); /* skip over leading "0x" or "0X" */
-
- multmax = ULLONG_MAX / (unsigned long long)base;
- val = DIGIT(c);
- for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; ) {
- if (val > multmax)
- goto overflow;
- val *= base;
- if (ULONG_MAX - val < xx)
- goto overflow;
- val += xx;
- c = *++ustr;
- }
- if (ptr != (const char **)0)
- *ptr = (char *)ustr;
- *result = neg ? -val : val;
- return (0);
-
-overflow:
- for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; )
- c = *++ustr;
- if (ptr != (const char **)0)
- *ptr = (char *)ustr;
- return (ERANGE);
-}
diff --git a/usr/src/uts/common/os/ddi_strtol.c b/usr/src/uts/common/os/ddi_strtol.c
deleted file mode 100644
index b271f3b913..0000000000
--- a/usr/src/uts/common/os/ddi_strtol.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1988 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/ddi.h>
-#include <sys/errno.h>
-
-/*
- * String to integer conversion routines.
- *
- * This file is derived from usr/src/common/util/strtol.c
- *
- * We cannot use the user land versions as there is no errno to report
- * error in kernel. So the return value is used to return an error,
- * and the result is stored in an extra parameter passed by reference.
- * Otherwise, the following functions are identical to the user land
- * versions.
- */
-
-/*
- * We should have a kernel version of ctype.h.
- */
-#define isalnum(ch) (isalpha(ch) || isdigit(ch))
-#define isalpha(ch) (isupper(ch) || islower(ch))
-#define isdigit(ch) ((ch) >= '0' && (ch) <= '9')
-#define islower(ch) ((ch) >= 'a' && (ch) <= 'z')
-#define isspace(ch) (((ch) == ' ') || ((ch) == '\r') || ((ch) == '\n') || \
- ((ch) == '\t') || ((ch) == '\f'))
-#define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
-#define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \
- ((ch) >= 'A' && (ch) <= 'F'))
-
-#define DIGIT(x) \
- (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
-
-#define MBASE ('z' - 'a' + 1 + 10)
-
-/*
- * The following macro is a local version of isalnum() which limits
- * alphabetic characters to the ranges a-z and A-Z; locale dependent
- * characters will not return 1. The members of a-z and A-Z are
- * assumed to be in ascending order and contiguous
- */
-#define lisalnum(x) \
- (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
-
-int
-ddi_strtol(const char *str, char **nptr, int base, long *result)
-{
- long val;
- int c;
- int xx, neg = 0;
- long multmin;
- long limit;
- const char **ptr = (const char **)nptr;
- const unsigned char *ustr = (const unsigned char *)str;
-
- if (ptr != (const char **)0)
- *ptr = (char *)ustr; /* in case no number is formed */
- if (base < 0 || base > MBASE || base == 1) {
- /* base is invalid -- should be a fatal error */
- return (EINVAL);
- }
- if (!isalnum(c = *ustr)) {
- while (isspace(c))
- c = *++ustr;
- switch (c) {
- case '-':
- neg++;
- /* FALLTHROUGH */
- case '+':
- c = *++ustr;
- }
- }
- if (base == 0)
- if (c != '0')
- base = 10;
- else if (ustr[1] == 'x' || ustr[1] == 'X')
- base = 16;
- else
- base = 8;
- /*
- * for any base > 10, the digits incrementally following
- * 9 are assumed to be "abc...z" or "ABC...Z"
- */
- if (!lisalnum(c) || (xx = DIGIT(c)) >= base)
- return (EINVAL); /* no number formed */
- if (base == 16 && c == '0' && (ustr[1] == 'x' || ustr[1] == 'X') &&
- isxdigit(ustr[2]))
- c = *(ustr += 2); /* skip over leading "0x" or "0X" */
-
- /* this code assumes that abs(LONG_MIN) >= abs(LONG_MAX) */
- if (neg)
- limit = LONG_MIN;
- else
- limit = -LONG_MAX;
- multmin = limit / (long)base;
- val = -DIGIT(c);
- for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; ) {
- /* accumulate neg avoids surprises near MAXLONG */
- if (val < multmin)
- goto overflow;
- val *= base;
- if (val < limit + xx)
- goto overflow;
- val -= xx;
- c = *++ustr;
- }
- if (ptr != (const char **)0)
- *ptr = (char *)ustr;
- *result = neg ? val : -val;
- return (0);
-
-overflow:
- for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; (c = *++ustr))
- ;
- if (ptr != (const char **)0)
- *ptr = (char *)ustr;
- return (ERANGE);
-}
-
-int
-ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result)
-{
- unsigned long val;
- int c;
- int xx;
- unsigned long multmax;
- int neg = 0;
- const char **ptr = (const char **)nptr;
- const unsigned char *ustr = (const unsigned char *)str;
-
- if (ptr != (const char **)0)
- *ptr = (char *)ustr; /* in case no number is formed */
- if (base < 0 || base > MBASE || base == 1) {
- /* base is invalid -- should be a fatal error */
- return (EINVAL);
- }
- if (!isalnum(c = *ustr)) {
- while (isspace(c))
- c = *++ustr;
- switch (c) {
- case '-':
- neg++;
- /* FALLTHROUGH */
- case '+':
- c = *++ustr;
- }
- }
- if (base == 0)
- if (c != '0')
- base = 10;
- else if (ustr[1] == 'x' || ustr[1] == 'X')
- base = 16;
- else
- base = 8;
- /*
- * for any base > 10, the digits incrementally following
- * 9 are assumed to be "abc...z" or "ABC...Z"
- */
- if (!lisalnum(c) || (xx = DIGIT(c)) >= base)
- return (EINVAL); /* no number formed */
- if (base == 16 && c == '0' && (ustr[1] == 'x' || ustr[1] == 'X') &&
- isxdigit(ustr[2]))
- c = *(ustr += 2); /* skip over leading "0x" or "0X" */
-
- multmax = ULONG_MAX / (unsigned long)base;
- val = DIGIT(c);
- for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; ) {
- if (val > multmax)
- goto overflow;
- val *= base;
- if (ULONG_MAX - val < xx)
- goto overflow;
- val += xx;
- c = *++ustr;
- }
- if (ptr != (const char **)0)
- *ptr = (char *)ustr;
- *result = neg ? -val : val;
- return (0);
-
-overflow:
- for (c = *++ustr; lisalnum(c) && (xx = DIGIT(c)) < base; (c = *++ustr))
- ;
- if (ptr != (const char **)0)
- *ptr = (char *)ustr;
- return (ERANGE);
-}
diff --git a/usr/src/uts/common/sys/ddi_obsolete.h b/usr/src/uts/common/sys/ddi_obsolete.h
index 84970dbb54..f93d89fb7e 100644
--- a/usr/src/uts/common/sys/ddi_obsolete.h
+++ b/usr/src/uts/common/sys/ddi_obsolete.h
@@ -1,13 +1,11 @@
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_DDI_OBSOLETE_H
#define _SYS_DDI_OBSOLETE_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* Obsoleted DDI Interfaces
*/
@@ -32,6 +30,8 @@ int ddi_iomin(dev_info_t *dip, int initial, int streaming);
#ifndef _DDI_STRICT
+extern long strtol(const char *, char **, int);
+extern unsigned long strtoul(const char *, char **, int);
int ddi_dma_setup(dev_info_t *dip, struct ddi_dma_req *dmareqp,
ddi_dma_handle_t *handlep);
diff --git a/usr/src/uts/common/sys/idm/idm_text.h b/usr/src/uts/common/sys/idm/idm_text.h
index 35649466a7..bbae966371 100644
--- a/usr/src/uts/common/sys/idm/idm_text.h
+++ b/usr/src/uts/common/sys/idm/idm_text.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _IDM_TEXT_H_
@@ -187,10 +187,6 @@ idm_pdu_init_text_data(idm_pdu_t *pdu, void *arg,
void
idm_itextbuf_free(void *arg);
-int
-idm_strtoull(const char *str, char **nptr, int base,
- unsigned long long *result);
-
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/sys/sunddi.h b/usr/src/uts/common/sys/sunddi.h
index 7f619b8da6..619f2a1c07 100644
--- a/usr/src/uts/common/sys/sunddi.h
+++ b/usr/src/uts/common/sys/sunddi.h
@@ -402,8 +402,6 @@ extern int physio(int (*)(struct buf *), struct buf *, dev_t,
int, void (*)(struct buf *), struct uio *);
extern void disksort(struct diskhd *, struct buf *);
-extern long strtol(const char *, char **, int);
-extern unsigned long strtoul(const char *, char **, int);
extern size_t strlen(const char *) __PURE;
extern size_t strnlen(const char *, size_t) __PURE;
extern char *strcpy(char *, const char *);
@@ -456,6 +454,8 @@ extern void *memchr(const void *, int, size_t);
extern int ddi_strtol(const char *, char **, int, long *);
extern int ddi_strtoul(const char *, char **, int, unsigned long *);
+extern int ddi_strtoll(const char *, char **, int, longlong_t *);
+extern int ddi_strtoull(const char *, char **, int, u_longlong_t *);
/*
* kiconv functions and their macros.
diff --git a/usr/src/uts/common/sys/types.h b/usr/src/uts/common/sys/types.h
index 8f133c1056..c926ba7ffc 100644
--- a/usr/src/uts/common/sys/types.h
+++ b/usr/src/uts/common/sys/types.h
@@ -577,6 +577,13 @@ typedef unsigned long ulong;
#define ULONG_MAX 4294967295UL /* max of "unsigned long int" */
#endif
+#define LLONG_MIN (-9223372036854775807LL-1LL)
+ /* min of "long long int" */
+#define LLONG_MAX 9223372036854775807LL
+ /* max of "long long int" */
+#define ULLONG_MAX 18446744073709551615ULL
+ /* max of "unsigned long long int" */
+
#endif /* defined(_KERNEL) */
#define P_MYPID ((pid_t)0)