From bcf23f43dc1b73080eeded927585ee86feab40a7 Mon Sep 17 00:00:00 2001 From: Gary Mills Date: Fri, 19 Feb 2016 16:34:27 -0600 Subject: [PATCH] 6596 Macro redefined in strtolctype.h Reviewed by: Garrett D'Amore Approved by: Dan McDonald --- usr/src/common/util/strtolctype.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/usr/src/common/util/strtolctype.h b/usr/src/common/util/strtolctype.h index 535c014d1f..5acde13101 100644 --- a/usr/src/common/util/strtolctype.h +++ b/usr/src/common/util/strtolctype.h @@ -20,6 +20,7 @@ */ /* + * Copyright 2016 Gary Mills * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -27,24 +28,33 @@ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ -#ifndef _COMMON_UTIL_CTYPE_H -#define _COMMON_UTIL_CTYPE_H +#ifndef _COMMON_UTIL_STRTOLCTYPE_H +#define _COMMON_UTIL_STRTOLCTYPE_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. + * This is a private header file containing a collection of macros that + * the strtou?ll? functions in common/util use to test characters. Which + * macros are defined depends on which of _KERNEL or _BOOT are defined. + * New code should use the kernel version of ctype.h: . * * NOTE: These macros are used within several DTrace probe context functions. * They must not be altered to make function calls or perform actions not * safe in probe context. */ -#if defined(_KERNEL) || defined(_BOOT) +/* + * Cases that define these macros: + * _KERNEL && !_BOOT: Used by kernel functions + * !_KERNEL && _BOOT: Used by dboot_startkern.c for x86 boot + * Cases that omit these macros: + * _KERNEL && _BOOT: Used by common/util/strtol.c for SPARC boot library + * !_KERNEL && !_BOOT: Used by strtou?ll? functions in libc + */ +#if defined(_KERNEL) ^ defined(_BOOT) #define isalnum(ch) (isalpha(ch) || isdigit(ch)) #define isalpha(ch) (isupper(ch) || islower(ch)) @@ -56,7 +66,11 @@ extern "C" { #define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \ ((ch) >= 'A' && (ch) <= 'F')) -#endif /* _KERNEL || _BOOT */ +#endif /* _KERNEL ^ _BOOT */ + +/* + * The following macros are defined unconditionally. + */ #define DIGIT(x) \ (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A') @@ -76,4 +90,4 @@ extern "C" { } #endif -#endif /* _COMMON_UTIL_CTYPE_H */ +#endif /* _COMMON_UTIL_STRTOLCTYPE_H */ -- 2.11.4.GIT