003 File Manager
Current Path:
/usr/src/sys/libkern
usr
/
src
/
sys
/
libkern
/
📁
..
📄
arc4random.c
(6.91 KB)
📄
arc4random_uniform.c
(1.78 KB)
📁
arm
📁
arm64
📄
ashldi3.c
(2.43 KB)
📄
ashrdi3.c
(2.56 KB)
📄
asprintf.c
(2.17 KB)
📄
bcd.c
(1.67 KB)
📄
bcmp.c
(4.2 KB)
📄
bcopy.c
(4.13 KB)
📄
bsearch.c
(3.07 KB)
📄
cmpdi2.c
(2.18 KB)
📄
divdi3.c
(2.2 KB)
📄
explicit_bzero.c
(512 B)
📄
ffs.c
(1.84 KB)
📄
ffsl.c
(1.85 KB)
📄
ffsll.c
(1.82 KB)
📄
fls.c
(1.84 KB)
📄
flsl.c
(1.84 KB)
📄
flsll.c
(1.85 KB)
📄
fnmatch.c
(5.89 KB)
📄
gsb_crc32.c
(42.96 KB)
📄
iconv.c
(13.11 KB)
📄
iconv_converter_if.m
(2.11 KB)
📄
iconv_ucs.c
(12.47 KB)
📄
iconv_xlat.c
(3.39 KB)
📄
iconv_xlat16.c
(8.47 KB)
📄
inet_aton.c
(3.41 KB)
📄
inet_ntoa.c
(1.8 KB)
📄
inet_ntop.c
(4.94 KB)
📄
inet_pton.c
(5.21 KB)
📄
jenkins_hash.c
(16.09 KB)
📄
lshrdi3.c
(2.24 KB)
📄
mcount.c
(8.52 KB)
📄
memcchr.c
(3.27 KB)
📄
memchr.c
(1.99 KB)
📄
memcmp.c
(2 KB)
📄
memmem.c
(2.39 KB)
📄
memset.c
(1.61 KB)
📄
moddi3.c
(2.22 KB)
📄
murmur3_32.c
(3.4 KB)
📄
qdivrem.c
(7.47 KB)
📄
qsort.c
(5.95 KB)
📄
qsort_r.c
(156 B)
📄
quad.h
(4.16 KB)
📄
random.c
(1.92 KB)
📄
scanc.c
(1.93 KB)
📄
strcasecmp.c
(2.52 KB)
📄
strcasestr.c
(2.4 KB)
📄
strcat.c
(1.83 KB)
📄
strchr.c
(1.88 KB)
📄
strchrnul.c
(1.57 KB)
📄
strcmp.c
(1.96 KB)
📄
strcpy.c
(1.82 KB)
📄
strcspn.c
(2.36 KB)
📄
strdup.c
(2.15 KB)
📄
strlcat.c
(2.56 KB)
📄
strlcpy.c
(1.64 KB)
📄
strlen.c
(3.77 KB)
📄
strncat.c
(2.23 KB)
📄
strncmp.c
(1.92 KB)
📄
strncpy.c
(2.15 KB)
📄
strndup.c
(1.98 KB)
📄
strnlen.c
(1.61 KB)
📄
strrchr.c
(1.89 KB)
📄
strsep.c
(2.63 KB)
📄
strspn.c
(2.32 KB)
📄
strstr.c
(2.11 KB)
📄
strtol.c
(4.06 KB)
📄
strtoq.c
(4.09 KB)
📄
strtoul.c
(3.13 KB)
📄
strtouq.c
(3.08 KB)
📄
strvalid.c
(2.04 KB)
📄
timingsafe_bcmp.c
(1.08 KB)
📄
ucmpdi2.c
(2.32 KB)
📄
udivdi3.c
(1.97 KB)
📄
umoddi3.c
(2 KB)
📁
x86
Editing: strtoq.c
/*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/ctype.h> #include <sys/limits.h> /* * Convert a string to a quad integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ quad_t strtoq(const char *nptr, char **endptr, int base) { const char *s; u_quad_t acc; unsigned char c; u_quad_t qbase, cutoff; int neg, any, cutlim; /* * Skip white space and pick up leading +/- sign if any. * If base is 0, allow 0x for hex and 0 for octal, else * assume decimal; if base is already 16, allow 0x. */ s = nptr; do { c = *s++; } while (isspace(c)); if (c == '-') { neg = 1; c = *s++; } else { neg = 0; if (c == '+') c = *s++; } if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { c = s[1]; s += 2; base = 16; } if (base == 0) base = c == '0' ? 8 : 10; /* * Compute the cutoff value between legal numbers and illegal * numbers. That is the largest legal value, divided by the * base. An input number that is greater than this value, if * followed by a legal input character, is too big. One that * is equal to this value may be valid or not; the limit * between valid and invalid numbers is then based on the last * digit. For instance, if the range for quads is * [-9223372036854775808..9223372036854775807] and the input base * is 10, cutoff will be set to 922337203685477580 and cutlim to * either 7 (neg==0) or 8 (neg==1), meaning that if we have * accumulated a value > 922337203685477580, or equal but the * next digit is > 7 (or 8), the number is too big, and we will * return a range error. * * Set any if any `digits' consumed; make it negative to indicate * overflow. */ qbase = (unsigned)base; cutoff = neg ? (u_quad_t)-(QUAD_MIN + QUAD_MAX) + QUAD_MAX : QUAD_MAX; cutlim = cutoff % qbase; cutoff /= qbase; for (acc = 0, any = 0;; c = *s++) { if (!isascii(c)) break; if (isdigit(c)) c -= '0'; else if (isalpha(c)) c -= isupper(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base) break; if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; acc *= qbase; acc += c; } } if (any < 0) { acc = neg ? QUAD_MIN : QUAD_MAX; } else if (neg) acc = -acc; if (endptr != NULL) *endptr = __DECONST(char *, any ? s - 1 : nptr); return (acc); }
Upload File
Create Folder