cmd-inet/usr.sbin: remove -Wno-implicit-function-declaration
[unleashed.git] / usr / src / common / util / strtolctype.h
blob5acde13101208bcaf696f9eca61e7fb090daf216
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2016 Gary Mills
24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 /* Copyright (c) 1988 AT&T */
29 /* All Rights Reserved */
31 #ifndef _COMMON_UTIL_STRTOLCTYPE_H
32 #define _COMMON_UTIL_STRTOLCTYPE_H
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
39 * This is a private header file containing a collection of macros that
40 * the strtou?ll? functions in common/util use to test characters. Which
41 * macros are defined depends on which of _KERNEL or _BOOT are defined.
42 * New code should use the kernel version of ctype.h: <sys/ctype.h>.
44 * NOTE: These macros are used within several DTrace probe context functions.
45 * They must not be altered to make function calls or perform actions not
46 * safe in probe context.
50 * Cases that define these macros:
51 * _KERNEL && !_BOOT: Used by kernel functions
52 * !_KERNEL && _BOOT: Used by dboot_startkern.c for x86 boot
53 * Cases that omit these macros:
54 * _KERNEL && _BOOT: Used by common/util/strtol.c for SPARC boot library
55 * !_KERNEL && !_BOOT: Used by strtou?ll? functions in libc
57 #if defined(_KERNEL) ^ defined(_BOOT)
59 #define isalnum(ch) (isalpha(ch) || isdigit(ch))
60 #define isalpha(ch) (isupper(ch) || islower(ch))
61 #define isdigit(ch) ((ch) >= '0' && (ch) <= '9')
62 #define islower(ch) ((ch) >= 'a' && (ch) <= 'z')
63 #define isspace(ch) (((ch) == ' ') || ((ch) == '\r') || ((ch) == '\n') || \
64 ((ch) == '\t') || ((ch) == '\f'))
65 #define isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
66 #define isxdigit(ch) (isdigit(ch) || ((ch) >= 'a' && (ch) <= 'f') || \
67 ((ch) >= 'A' && (ch) <= 'F'))
69 #endif /* _KERNEL ^ _BOOT */
72 * The following macros are defined unconditionally.
75 #define DIGIT(x) \
76 (isdigit(x) ? (x) - '0' : islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
78 #define MBASE ('z' - 'a' + 1 + 10)
81 * The following macro is a version of isalnum() that limits alphabetic
82 * characters to the ranges a-z and A-Z; locale dependent characters will not
83 * return 1. The members of a-z and A-Z are assumed to be in ascending order
84 * and contiguous.
86 #define lisalnum(x) \
87 (isdigit(x) || ((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
89 #ifdef __cplusplus
91 #endif
93 #endif /* _COMMON_UTIL_STRTOLCTYPE_H */