mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-18 02:24:18 +00:00
Merge changes from topic "db/deps" into integration
* changes: feat(compiler-rt): update compiler-rt source files fix(deps): add missing aeabi_memcpy.S feat(zlib): update zlib source files docs(changelog): add zlib and compiler-rt scope feat(libfdt): upgrade libfdt source files docs(prerequisites): upgrade to Mbed TLS 2.28.1
This commit is contained in:
commit
9900d4eb06
44 changed files with 12955 additions and 1671 deletions
1
Makefile
1
Makefile
|
@ -59,6 +59,7 @@ LIB_DIRS_TO_CHECK := $(sort $(filter-out \
|
||||||
lib/compiler-rt \
|
lib/compiler-rt \
|
||||||
lib/libfdt% \
|
lib/libfdt% \
|
||||||
lib/libc, \
|
lib/libc, \
|
||||||
|
lib/zlib \
|
||||||
$(wildcard lib/*)))
|
$(wildcard lib/*)))
|
||||||
ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
|
ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
|
||||||
lib \
|
lib \
|
||||||
|
|
|
@ -1181,8 +1181,15 @@ subsections:
|
||||||
- title: commitlint
|
- title: commitlint
|
||||||
scope: commitlint
|
scope: commitlint
|
||||||
|
|
||||||
|
- title: Compiler runtime libraries
|
||||||
|
scope: compiler-rt
|
||||||
|
|
||||||
- title: libfdt
|
- title: libfdt
|
||||||
scope: libfdt
|
scope: libfdt
|
||||||
|
|
||||||
- title: Node Package Manager (NPM)
|
- title: Node Package Manager (NPM)
|
||||||
scope: npm
|
scope: npm
|
||||||
|
|
||||||
|
- title: zlib
|
||||||
|
scope: zlib
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ supporting tools:
|
||||||
The following libraries are required for Trusted Board Boot and Measured Boot
|
The following libraries are required for Trusted Board Boot and Measured Boot
|
||||||
support:
|
support:
|
||||||
|
|
||||||
- mbed TLS == 2.28.0 (tag: ``mbedtls-2.28.0``)
|
- mbed TLS == 2.28.1 (tag: ``mbedtls-2.28.1``)
|
||||||
|
|
||||||
These tools are optional:
|
These tools are optional:
|
||||||
|
|
||||||
|
|
100
include/lib/libc/aarch32/float.h
Normal file
100
include/lib/libc/aarch32/float.h
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
/*-
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*
|
||||||
|
* Copyright (c) 1989 Regents of the University of California.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* from: @(#)float.h 7.1 (Berkeley) 5/8/90
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MACHINE_FLOAT_H_
|
||||||
|
#define _MACHINE_FLOAT_H_ 1
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
extern int __flt_rounds(void);
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#define FLT_RADIX 2 /* b */
|
||||||
|
#ifndef _ARM_HARD_FLOAT
|
||||||
|
#define FLT_ROUNDS __flt_rounds()
|
||||||
|
#else
|
||||||
|
#define FLT_ROUNDS (-1)
|
||||||
|
#endif
|
||||||
|
#if __ISO_C_VISIBLE >= 1999
|
||||||
|
#define FLT_EVAL_METHOD 0
|
||||||
|
#define DECIMAL_DIG 17 /* max precision in decimal digits */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FLT_MANT_DIG 24 /* p */
|
||||||
|
#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
|
||||||
|
#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
|
||||||
|
#define FLT_MIN_EXP (-125) /* emin */
|
||||||
|
#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
|
||||||
|
#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
|
||||||
|
#define FLT_MAX_EXP 128 /* emax */
|
||||||
|
#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
|
||||||
|
#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
|
||||||
|
#if __ISO_C_VISIBLE >= 2011
|
||||||
|
#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */
|
||||||
|
#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */
|
||||||
|
#define FLT_HAS_SUBNORM 1
|
||||||
|
#endif /* __ISO_C_VISIBLE >= 2011 */
|
||||||
|
|
||||||
|
#define DBL_MANT_DIG 53
|
||||||
|
#define DBL_EPSILON 2.2204460492503131E-16
|
||||||
|
#define DBL_DIG 15
|
||||||
|
#define DBL_MIN_EXP (-1021)
|
||||||
|
#define DBL_MIN 2.2250738585072014E-308
|
||||||
|
#define DBL_MIN_10_EXP (-307)
|
||||||
|
#define DBL_MAX_EXP 1024
|
||||||
|
#define DBL_MAX 1.7976931348623157E+308
|
||||||
|
#define DBL_MAX_10_EXP 308
|
||||||
|
#if __ISO_C_VISIBLE >= 2011
|
||||||
|
#define DBL_TRUE_MIN 4.9406564584124654E-324
|
||||||
|
#define DBL_DECIMAL_DIG 17
|
||||||
|
#define DBL_HAS_SUBNORM 1
|
||||||
|
#endif /* __ISO_C_VISIBLE >= 2011 */
|
||||||
|
|
||||||
|
#define LDBL_MANT_DIG DBL_MANT_DIG
|
||||||
|
#define LDBL_EPSILON ((long double)DBL_EPSILON)
|
||||||
|
#define LDBL_DIG DBL_DIG
|
||||||
|
#define LDBL_MIN_EXP DBL_MIN_EXP
|
||||||
|
#define LDBL_MIN ((long double)DBL_MIN)
|
||||||
|
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||||||
|
#define LDBL_MAX_EXP DBL_MAX_EXP
|
||||||
|
#define LDBL_MAX ((long double)DBL_MAX)
|
||||||
|
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||||||
|
#if __ISO_C_VISIBLE >= 2011
|
||||||
|
#define LDBL_TRUE_MIN ((long double)DBL_TRUE_MIN)
|
||||||
|
#define LDBL_DECIMAL_DIG DBL_DECIMAL_DIG
|
||||||
|
#define LDBL_HAS_SUBNORM DBL_HAS_SUBNORM
|
||||||
|
#endif /* __ISO_C_VISIBLE >= 2011 */
|
||||||
|
|
||||||
|
#endif /* _MACHINE_FLOAT_H_ */
|
94
include/lib/libc/aarch64/float.h
Normal file
94
include/lib/libc/aarch64/float.h
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1989 Regents of the University of California.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* from: @(#)float.h 7.1 (Berkeley) 5/8/90
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MACHINE_FLOAT_H_
|
||||||
|
#define _MACHINE_FLOAT_H_
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
extern int __flt_rounds(void);
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#define FLT_RADIX 2 /* b */
|
||||||
|
#define FLT_ROUNDS __flt_rounds()
|
||||||
|
#if __ISO_C_VISIBLE >= 1999
|
||||||
|
#define FLT_EVAL_METHOD 0
|
||||||
|
#define DECIMAL_DIG 17 /* max precision in decimal digits */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FLT_MANT_DIG 24 /* p */
|
||||||
|
#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
|
||||||
|
#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
|
||||||
|
#define FLT_MIN_EXP (-125) /* emin */
|
||||||
|
#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
|
||||||
|
#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
|
||||||
|
#define FLT_MAX_EXP 128 /* emax */
|
||||||
|
#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
|
||||||
|
#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
|
||||||
|
#if __ISO_C_VISIBLE >= 2011
|
||||||
|
#define FLT_TRUE_MIN 1.40129846E-45F /* b**(emin-p) */
|
||||||
|
#define FLT_DECIMAL_DIG 9 /* ceil(1+p*log10(b)) */
|
||||||
|
#define FLT_HAS_SUBNORM 1
|
||||||
|
#endif /* __ISO_C_VISIBLE >= 2011 */
|
||||||
|
|
||||||
|
#define DBL_MANT_DIG 53
|
||||||
|
#define DBL_EPSILON 2.2204460492503131E-16
|
||||||
|
#define DBL_DIG 15
|
||||||
|
#define DBL_MIN_EXP (-1021)
|
||||||
|
#define DBL_MIN 2.2250738585072014E-308
|
||||||
|
#define DBL_MIN_10_EXP (-307)
|
||||||
|
#define DBL_MAX_EXP 1024
|
||||||
|
#define DBL_MAX 1.7976931348623157E+308
|
||||||
|
#define DBL_MAX_10_EXP 308
|
||||||
|
#if __ISO_C_VISIBLE >= 2011
|
||||||
|
#define DBL_TRUE_MIN 4.9406564584124654E-324
|
||||||
|
#define DBL_DECIMAL_DIG 17
|
||||||
|
#define DBL_HAS_SUBNORM 1
|
||||||
|
#endif /* __ISO_C_VISIBLE >= 2011 */
|
||||||
|
|
||||||
|
#define LDBL_MANT_DIG 113
|
||||||
|
#define LDBL_EPSILON 1.925929944387235853055977942584927319E-34L
|
||||||
|
#define LDBL_DIG 33
|
||||||
|
#define LDBL_MIN_EXP (-16381)
|
||||||
|
#define LDBL_MIN 3.362103143112093506262677817321752603E-4932L
|
||||||
|
#define LDBL_MIN_10_EXP (-4931)
|
||||||
|
#define LDBL_MAX_EXP (+16384)
|
||||||
|
#define LDBL_MAX 1.189731495357231765085759326628007016E+4932L
|
||||||
|
#define LDBL_MAX_10_EXP (+4932)
|
||||||
|
#if __ISO_C_VISIBLE >= 2011
|
||||||
|
#define LDBL_TRUE_MIN 6.475175119438025110924438958227646552E-4966L
|
||||||
|
#define LDBL_DECIMAL_DIG 36
|
||||||
|
#define LDBL_HAS_SUBNORM 1
|
||||||
|
#endif /* __ISO_C_VISIBLE >= 2011 */
|
||||||
|
|
||||||
|
#endif /* _MACHINE_FLOAT_H_ */
|
922
include/lib/libc/sys/cdefs.h
Normal file
922
include/lib/libc/sys/cdefs.h
Normal file
|
@ -0,0 +1,922 @@
|
||||||
|
/*-
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*
|
||||||
|
* Copyright (c) 1991, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to Berkeley by
|
||||||
|
* Berkeley Software Design, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @(#)cdefs.h 8.8 (Berkeley) 1/9/95
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SYS_CDEFS_H_
|
||||||
|
#define _SYS_CDEFS_H_
|
||||||
|
|
||||||
|
#if defined(_KERNEL) && defined(_STANDALONE)
|
||||||
|
#error "_KERNEL and _STANDALONE are mutually exclusive"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Testing against Clang-specific extensions.
|
||||||
|
*/
|
||||||
|
#ifndef __has_attribute
|
||||||
|
#define __has_attribute(x) 0
|
||||||
|
#endif
|
||||||
|
#ifndef __has_extension
|
||||||
|
#define __has_extension __has_feature
|
||||||
|
#endif
|
||||||
|
#ifndef __has_feature
|
||||||
|
#define __has_feature(x) 0
|
||||||
|
#endif
|
||||||
|
#ifndef __has_include
|
||||||
|
#define __has_include(x) 0
|
||||||
|
#endif
|
||||||
|
#ifndef __has_builtin
|
||||||
|
#define __has_builtin(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define __BEGIN_DECLS extern "C" {
|
||||||
|
#define __END_DECLS }
|
||||||
|
#else
|
||||||
|
#define __BEGIN_DECLS
|
||||||
|
#define __END_DECLS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This code has been put in place to help reduce the addition of
|
||||||
|
* compiler specific defines in FreeBSD code. It helps to aid in
|
||||||
|
* having a compiler-agnostic source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
|
||||||
|
#if __GNUC__ >= 3
|
||||||
|
#define __GNUCLIKE_ASM 3
|
||||||
|
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
|
||||||
|
#else
|
||||||
|
#define __GNUCLIKE_ASM 2
|
||||||
|
#endif
|
||||||
|
#define __GNUCLIKE___TYPEOF 1
|
||||||
|
#define __GNUCLIKE___SECTION 1
|
||||||
|
|
||||||
|
#define __GNUCLIKE_CTOR_SECTION_HANDLING 1
|
||||||
|
|
||||||
|
#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
|
||||||
|
|
||||||
|
#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
|
||||||
|
#define __GNUCLIKE_BUILTIN_VARARGS 1
|
||||||
|
#define __GNUCLIKE_BUILTIN_STDARG 1
|
||||||
|
#define __GNUCLIKE_BUILTIN_VAALIST 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __GNUC_VA_LIST_COMPATIBILITY 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compiler memory barriers, specific to gcc and clang.
|
||||||
|
*/
|
||||||
|
#define __compiler_membar() __asm __volatile(" " : : : "memory")
|
||||||
|
|
||||||
|
#define __GNUCLIKE_BUILTIN_NEXT_ARG 1
|
||||||
|
#define __GNUCLIKE_MATH_BUILTIN_RELOPS
|
||||||
|
|
||||||
|
#define __GNUCLIKE_BUILTIN_MEMCPY 1
|
||||||
|
|
||||||
|
/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
|
||||||
|
#define __CC_SUPPORTS_INLINE 1
|
||||||
|
#define __CC_SUPPORTS___INLINE 1
|
||||||
|
#define __CC_SUPPORTS___INLINE__ 1
|
||||||
|
|
||||||
|
#define __CC_SUPPORTS___FUNC__ 1
|
||||||
|
#define __CC_SUPPORTS_WARNING 1
|
||||||
|
|
||||||
|
#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
|
||||||
|
|
||||||
|
#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
|
||||||
|
|
||||||
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macro to test if we're using a specific version of gcc or later.
|
||||||
|
*/
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define __GNUC_PREREQ__(ma, mi) \
|
||||||
|
(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
|
||||||
|
#else
|
||||||
|
#define __GNUC_PREREQ__(ma, mi) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The __CONCAT macro is used to concatenate parts of symbol names, e.g.
|
||||||
|
* with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
|
||||||
|
* The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
|
||||||
|
* mode -- there must be no spaces between its arguments, and for nested
|
||||||
|
* __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
|
||||||
|
* concatenate double-quoted strings produced by the __STRING macro, but
|
||||||
|
* this only works with ANSI C.
|
||||||
|
*
|
||||||
|
* __XSTRING is like __STRING, but it expands any macros in its argument
|
||||||
|
* first. It is only available with ANSI C.
|
||||||
|
*/
|
||||||
|
#if defined(__STDC__) || defined(__cplusplus)
|
||||||
|
#define __P(protos) protos /* full-blown ANSI C */
|
||||||
|
#define __CONCAT1(x,y) x ## y
|
||||||
|
#define __CONCAT(x,y) __CONCAT1(x,y)
|
||||||
|
#define __STRING(x) #x /* stringify without expanding x */
|
||||||
|
#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
|
||||||
|
|
||||||
|
#define __const const /* define reserved names to standard */
|
||||||
|
#define __signed signed
|
||||||
|
#define __volatile volatile
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define __inline inline /* convert to C++ keyword */
|
||||||
|
#else
|
||||||
|
#if !(defined(__CC_SUPPORTS___INLINE))
|
||||||
|
#define __inline /* delete GCC keyword */
|
||||||
|
#endif /* ! __CC_SUPPORTS___INLINE */
|
||||||
|
#endif /* !__cplusplus */
|
||||||
|
|
||||||
|
#else /* !(__STDC__ || __cplusplus) */
|
||||||
|
#define __P(protos) () /* traditional C preprocessor */
|
||||||
|
#define __CONCAT(x,y) x/**/y
|
||||||
|
#define __STRING(x) "x"
|
||||||
|
|
||||||
|
#if !defined(__CC_SUPPORTS___INLINE)
|
||||||
|
#define __const /* delete pseudo-ANSI C keywords */
|
||||||
|
#define __inline
|
||||||
|
#define __signed
|
||||||
|
#define __volatile
|
||||||
|
/*
|
||||||
|
* In non-ANSI C environments, new programs will want ANSI-only C keywords
|
||||||
|
* deleted from the program and old programs will want them left alone.
|
||||||
|
* When using a compiler other than gcc, programs using the ANSI C keywords
|
||||||
|
* const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
|
||||||
|
* When using "gcc -traditional", we assume that this is the intent; if
|
||||||
|
* __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
|
||||||
|
*/
|
||||||
|
#ifndef NO_ANSI_KEYWORDS
|
||||||
|
#define const /* delete ANSI C keywords */
|
||||||
|
#define inline
|
||||||
|
#define signed
|
||||||
|
#define volatile
|
||||||
|
#endif /* !NO_ANSI_KEYWORDS */
|
||||||
|
#endif /* !__CC_SUPPORTS___INLINE */
|
||||||
|
#endif /* !(__STDC__ || __cplusplus) */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compiler-dependent macros to help declare dead (non-returning) and
|
||||||
|
* pure (no side effects) functions, and unused variables. They are
|
||||||
|
* null except for versions of gcc that are known to support the features
|
||||||
|
* properly (old versions of gcc-2 supported the dead and pure features
|
||||||
|
* in a different (wrong) way). If we do not provide an implementation
|
||||||
|
* for a given compiler, let the compile fail if it is told to use
|
||||||
|
* a feature that we cannot live without.
|
||||||
|
*/
|
||||||
|
#define __weak_symbol __attribute__((__weak__))
|
||||||
|
#if !__GNUC_PREREQ__(2, 5)
|
||||||
|
#define __dead2
|
||||||
|
#define __pure2
|
||||||
|
#define __unused
|
||||||
|
#endif
|
||||||
|
#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
|
||||||
|
#define __dead2 __attribute__((__noreturn__))
|
||||||
|
#define __pure2 __attribute__((__const__))
|
||||||
|
#define __unused
|
||||||
|
/* XXX Find out what to do for __packed, __aligned and __section */
|
||||||
|
#endif
|
||||||
|
#if __GNUC_PREREQ__(2, 7)
|
||||||
|
#define __dead2 __attribute__((__noreturn__))
|
||||||
|
#define __pure2 __attribute__((__const__))
|
||||||
|
#define __unused __attribute__((__unused__))
|
||||||
|
#define __used __attribute__((__used__))
|
||||||
|
#define __packed __attribute__((__packed__))
|
||||||
|
#define __aligned(x) __attribute__((__aligned__(x)))
|
||||||
|
#define __section(x) __attribute__((__section__(x)))
|
||||||
|
#endif
|
||||||
|
#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
|
||||||
|
#define __alloc_size(x) __attribute__((__alloc_size__(x)))
|
||||||
|
#define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x)))
|
||||||
|
#else
|
||||||
|
#define __alloc_size(x)
|
||||||
|
#define __alloc_size2(n, x)
|
||||||
|
#endif
|
||||||
|
#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
|
||||||
|
#define __alloc_align(x) __attribute__((__alloc_align__(x)))
|
||||||
|
#else
|
||||||
|
#define __alloc_align(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !__GNUC_PREREQ__(2, 95)
|
||||||
|
#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keywords added in C11.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
|
||||||
|
|
||||||
|
#if !__has_extension(c_alignas)
|
||||||
|
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||||
|
__has_extension(cxx_alignas)
|
||||||
|
#define _Alignas(x) alignas(x)
|
||||||
|
#else
|
||||||
|
/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
|
||||||
|
#define _Alignas(x) __aligned(x)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
|
#define _Alignof(x) alignof(x)
|
||||||
|
#else
|
||||||
|
#define _Alignof(x) __alignof(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__cplusplus) && !__has_extension(c_atomic) && \
|
||||||
|
!__has_extension(cxx_atomic) && !__GNUC_PREREQ__(4, 7)
|
||||||
|
/*
|
||||||
|
* No native support for _Atomic(). Place object in structure to prevent
|
||||||
|
* most forms of direct non-atomic access.
|
||||||
|
*/
|
||||||
|
#define _Atomic(T) struct { T volatile __val; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
|
#define _Noreturn [[noreturn]]
|
||||||
|
#else
|
||||||
|
#define _Noreturn __dead2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !__has_extension(c_static_assert)
|
||||||
|
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||||
|
__has_extension(cxx_static_assert)
|
||||||
|
#define _Static_assert(x, y) static_assert(x, y)
|
||||||
|
#elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus)
|
||||||
|
/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
|
||||||
|
#elif defined(__COUNTER__)
|
||||||
|
#define _Static_assert(x, y) __Static_assert(x, __COUNTER__)
|
||||||
|
#define __Static_assert(x, y) ___Static_assert(x, y)
|
||||||
|
#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \
|
||||||
|
__unused
|
||||||
|
#else
|
||||||
|
#define _Static_assert(x, y) struct __hack
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !__has_extension(c_thread_local)
|
||||||
|
/*
|
||||||
|
* XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
|
||||||
|
* without actually supporting the thread_local keyword. Don't check for
|
||||||
|
* the presence of C++11 when defining _Thread_local.
|
||||||
|
*/
|
||||||
|
#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
|
||||||
|
__has_extension(cxx_thread_local)
|
||||||
|
#define _Thread_local thread_local
|
||||||
|
#else
|
||||||
|
#define _Thread_local __thread
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Emulation of C11 _Generic(). Unlike the previously defined C11
|
||||||
|
* keywords, it is not possible to implement this using exactly the same
|
||||||
|
* syntax. Therefore implement something similar under the name
|
||||||
|
* __generic(). Unlike _Generic(), this macro can only distinguish
|
||||||
|
* between a single type, so it requires nested invocations to
|
||||||
|
* distinguish multiple cases.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
|
||||||
|
__has_extension(c_generic_selections)
|
||||||
|
#define __generic(expr, t, yes, no) \
|
||||||
|
_Generic(expr, t: yes, default: no)
|
||||||
|
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
|
||||||
|
#define __generic(expr, t, yes, no) \
|
||||||
|
__builtin_choose_expr( \
|
||||||
|
__builtin_types_compatible_p(__typeof(expr), t), yes, no)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* C99 Static array indices in function parameter declarations. Syntax such as:
|
||||||
|
* void bar(int myArray[static 10]);
|
||||||
|
* is allowed in C99 but not in C++. Define __min_size appropriately so
|
||||||
|
* headers using it can be compiled in either language. Use like this:
|
||||||
|
* void bar(int myArray[__min_size(10)]);
|
||||||
|
*/
|
||||||
|
#if !defined(__cplusplus) && \
|
||||||
|
(defined(__clang__) || __GNUC_PREREQ__(4, 6)) && \
|
||||||
|
(!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
|
||||||
|
#define __min_size(x) static (x)
|
||||||
|
#else
|
||||||
|
#define __min_size(x) (x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ__(2, 96)
|
||||||
|
#define __malloc_like __attribute__((__malloc__))
|
||||||
|
#define __pure __attribute__((__pure__))
|
||||||
|
#else
|
||||||
|
#define __malloc_like
|
||||||
|
#define __pure
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ__(3, 1)
|
||||||
|
#define __always_inline __attribute__((__always_inline__))
|
||||||
|
#else
|
||||||
|
#define __always_inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ__(3, 1)
|
||||||
|
#define __noinline __attribute__ ((__noinline__))
|
||||||
|
#else
|
||||||
|
#define __noinline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ__(3, 4)
|
||||||
|
#define __fastcall __attribute__((__fastcall__))
|
||||||
|
#define __result_use_check __attribute__((__warn_unused_result__))
|
||||||
|
#else
|
||||||
|
#define __fastcall
|
||||||
|
#define __result_use_check
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ__(4, 1)
|
||||||
|
#define __returns_twice __attribute__((__returns_twice__))
|
||||||
|
#else
|
||||||
|
#define __returns_twice
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
|
||||||
|
#define __unreachable() __builtin_unreachable()
|
||||||
|
#else
|
||||||
|
#define __unreachable() ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
|
||||||
|
#if !__GNUC_PREREQ__(2, 7)
|
||||||
|
#define __func__ NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__GNUC__) && __GNUC__ >= 2) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
|
||||||
|
#define __LONG_LONG_SUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* C++11 exposes a load of C99 stuff */
|
||||||
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
|
#define __LONG_LONG_SUPPORTED
|
||||||
|
#ifndef __STDC_LIMIT_MACROS
|
||||||
|
#define __STDC_LIMIT_MACROS
|
||||||
|
#endif
|
||||||
|
#ifndef __STDC_CONSTANT_MACROS
|
||||||
|
#define __STDC_CONSTANT_MACROS
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GCC 2.95 provides `__restrict' as an extension to C90 to support the
|
||||||
|
* C99-specific `restrict' type qualifier. We happen to use `__restrict' as
|
||||||
|
* a way to define the `restrict' type qualifier without disturbing older
|
||||||
|
* software that is unaware of C99 keywords.
|
||||||
|
*/
|
||||||
|
#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
|
||||||
|
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
|
||||||
|
#define __restrict
|
||||||
|
#else
|
||||||
|
#define __restrict restrict
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GNU C version 2.96 adds explicit branch prediction so that
|
||||||
|
* the CPU back-end can hint the processor and also so that
|
||||||
|
* code blocks can be reordered such that the predicted path
|
||||||
|
* sees a more linear flow, thus improving cache behavior, etc.
|
||||||
|
*
|
||||||
|
* The following two macros provide us with a way to utilize this
|
||||||
|
* compiler feature. Use __predict_true() if you expect the expression
|
||||||
|
* to evaluate to true, and __predict_false() if you expect the
|
||||||
|
* expression to evaluate to false.
|
||||||
|
*
|
||||||
|
* A few notes about usage:
|
||||||
|
*
|
||||||
|
* * Generally, __predict_false() error condition checks (unless
|
||||||
|
* you have some _strong_ reason to do otherwise, in which case
|
||||||
|
* document it), and/or __predict_true() `no-error' condition
|
||||||
|
* checks, assuming you want to optimize for the no-error case.
|
||||||
|
*
|
||||||
|
* * Other than that, if you don't know the likelihood of a test
|
||||||
|
* succeeding from empirical or other `hard' evidence, don't
|
||||||
|
* make predictions.
|
||||||
|
*
|
||||||
|
* * These are meant to be used in places that are run `a lot'.
|
||||||
|
* It is wasteful to make predictions in code that is run
|
||||||
|
* seldomly (e.g. at subsystem initialization time) as the
|
||||||
|
* basic block reordering that this affects can often generate
|
||||||
|
* larger code.
|
||||||
|
*/
|
||||||
|
#if __GNUC_PREREQ__(2, 96)
|
||||||
|
#define __predict_true(exp) __builtin_expect((exp), 1)
|
||||||
|
#define __predict_false(exp) __builtin_expect((exp), 0)
|
||||||
|
#else
|
||||||
|
#define __predict_true(exp) (exp)
|
||||||
|
#define __predict_false(exp) (exp)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ__(4, 0)
|
||||||
|
#define __null_sentinel __attribute__((__sentinel__))
|
||||||
|
#define __exported __attribute__((__visibility__("default")))
|
||||||
|
#define __hidden __attribute__((__visibility__("hidden")))
|
||||||
|
#else
|
||||||
|
#define __null_sentinel
|
||||||
|
#define __exported
|
||||||
|
#define __hidden
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
|
||||||
|
* require it.
|
||||||
|
*/
|
||||||
|
#if __GNUC_PREREQ__(4, 1)
|
||||||
|
#define __offsetof(type, field) __builtin_offsetof(type, field)
|
||||||
|
#else
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#define __offsetof(type, field) \
|
||||||
|
((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
|
||||||
|
#else
|
||||||
|
#define __offsetof(type, field) \
|
||||||
|
(__offsetof__ (reinterpret_cast <__size_t> \
|
||||||
|
(&reinterpret_cast <const volatile char &> \
|
||||||
|
(static_cast<type *> (0)->field))))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#define __rangeof(type, start, end) \
|
||||||
|
(__offsetof(type, end) - __offsetof(type, start))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Given the pointer x to the member m of the struct s, return
|
||||||
|
* a pointer to the containing structure. When using GCC, we first
|
||||||
|
* assign pointer x to a local variable, to check that its type is
|
||||||
|
* compatible with member m.
|
||||||
|
*/
|
||||||
|
#if __GNUC_PREREQ__(3, 1)
|
||||||
|
#define __containerof(x, s, m) ({ \
|
||||||
|
const volatile __typeof(((s *)0)->m) *__x = (x); \
|
||||||
|
__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
|
||||||
|
})
|
||||||
|
#else
|
||||||
|
#define __containerof(x, s, m) \
|
||||||
|
__DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compiler-dependent macros to declare that functions take printf-like
|
||||||
|
* or scanf-like arguments. They are null except for versions of gcc
|
||||||
|
* that are known to support the features properly (old versions of gcc-2
|
||||||
|
* didn't permit keeping the keywords out of the application namespace).
|
||||||
|
*/
|
||||||
|
#if !__GNUC_PREREQ__(2, 7)
|
||||||
|
#define __printflike(fmtarg, firstvararg)
|
||||||
|
#define __scanflike(fmtarg, firstvararg)
|
||||||
|
#define __format_arg(fmtarg)
|
||||||
|
#define __strfmonlike(fmtarg, firstvararg)
|
||||||
|
#define __strftimelike(fmtarg, firstvararg)
|
||||||
|
#else
|
||||||
|
#define __printflike(fmtarg, firstvararg) \
|
||||||
|
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
|
||||||
|
#define __scanflike(fmtarg, firstvararg) \
|
||||||
|
__attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
|
||||||
|
#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
|
||||||
|
#define __strfmonlike(fmtarg, firstvararg) \
|
||||||
|
__attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
|
||||||
|
#define __strftimelike(fmtarg, firstvararg) \
|
||||||
|
__attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
|
||||||
|
#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
|
||||||
|
defined(__GNUC__)
|
||||||
|
#define __printf0like(fmtarg, firstvararg) \
|
||||||
|
__attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
|
||||||
|
#else
|
||||||
|
#define __printf0like(fmtarg, firstvararg)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define __strong_reference(sym,aliassym) \
|
||||||
|
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
|
||||||
|
#ifdef __STDC__
|
||||||
|
#define __weak_reference(sym,alias) \
|
||||||
|
__asm__(".weak " #alias); \
|
||||||
|
__asm__(".equ " #alias ", " #sym)
|
||||||
|
#define __warn_references(sym,msg) \
|
||||||
|
__asm__(".section .gnu.warning." #sym); \
|
||||||
|
__asm__(".asciz \"" msg "\""); \
|
||||||
|
__asm__(".previous")
|
||||||
|
#define __sym_compat(sym,impl,verid) \
|
||||||
|
__asm__(".symver " #impl ", " #sym "@" #verid)
|
||||||
|
#define __sym_default(sym,impl,verid) \
|
||||||
|
__asm__(".symver " #impl ", " #sym "@@@" #verid)
|
||||||
|
#else
|
||||||
|
#define __weak_reference(sym,alias) \
|
||||||
|
__asm__(".weak alias"); \
|
||||||
|
__asm__(".equ alias, sym")
|
||||||
|
#define __warn_references(sym,msg) \
|
||||||
|
__asm__(".section .gnu.warning.sym"); \
|
||||||
|
__asm__(".asciz \"msg\""); \
|
||||||
|
__asm__(".previous")
|
||||||
|
#define __sym_compat(sym,impl,verid) \
|
||||||
|
__asm__(".symver impl, sym@verid")
|
||||||
|
#define __sym_default(impl,sym,verid) \
|
||||||
|
__asm__(".symver impl, sym@@@verid")
|
||||||
|
#endif /* __STDC__ */
|
||||||
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
|
#define __GLOBL(sym) __asm__(".globl " __XSTRING(sym))
|
||||||
|
#define __WEAK(sym) __asm__(".weak " __XSTRING(sym))
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
|
||||||
|
#else
|
||||||
|
/*
|
||||||
|
* The following definition might not work well if used in header files,
|
||||||
|
* but it should be better than nothing. If you want a "do nothing"
|
||||||
|
* version, then it should generate some harmless declaration, such as:
|
||||||
|
* #define __IDSTRING(name,string) struct __hack
|
||||||
|
*/
|
||||||
|
#define __IDSTRING(name,string) static const char name[] __unused = string
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Embed the rcs id of a source file in the resulting library. Note that in
|
||||||
|
* more recent ELF binutils, we use .ident allowing the ID to be stripped.
|
||||||
|
* Usage:
|
||||||
|
* __FBSDID("$FreeBSD$");
|
||||||
|
*/
|
||||||
|
#ifndef __FBSDID
|
||||||
|
#if !defined(STRIP_FBSDID)
|
||||||
|
#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
|
||||||
|
#else
|
||||||
|
#define __FBSDID(s) struct __hack
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __RCSID
|
||||||
|
#ifndef NO__RCSID
|
||||||
|
#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
|
||||||
|
#else
|
||||||
|
#define __RCSID(s) struct __hack
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __RCSID_SOURCE
|
||||||
|
#ifndef NO__RCSID_SOURCE
|
||||||
|
#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
|
||||||
|
#else
|
||||||
|
#define __RCSID_SOURCE(s) struct __hack
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SCCSID
|
||||||
|
#ifndef NO__SCCSID
|
||||||
|
#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
|
||||||
|
#else
|
||||||
|
#define __SCCSID(s) struct __hack
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __COPYRIGHT
|
||||||
|
#ifndef NO__COPYRIGHT
|
||||||
|
#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
|
||||||
|
#else
|
||||||
|
#define __COPYRIGHT(s) struct __hack
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __DECONST
|
||||||
|
#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __DEVOLATILE
|
||||||
|
#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __DEQUALIFY
|
||||||
|
#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* The following definitions are an extension of the behavior originally
|
||||||
|
* implemented in <sys/_posix.h>, but with a different level of granularity.
|
||||||
|
* POSIX.1 requires that the macros we test be defined before any standard
|
||||||
|
* header file is included.
|
||||||
|
*
|
||||||
|
* Here's a quick run-down of the versions (and some informal names)
|
||||||
|
* defined(_POSIX_SOURCE) 1003.1-1988
|
||||||
|
* encoded as 198808 below
|
||||||
|
* _POSIX_C_SOURCE == 1 1003.1-1990
|
||||||
|
* encoded as 199009 below
|
||||||
|
* _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
|
||||||
|
* encoded as 199209 below
|
||||||
|
* _POSIX_C_SOURCE == 199309 1003.1b-1993
|
||||||
|
* (1003.1 Issue 4, Single Unix Spec v1, Unix 93)
|
||||||
|
* _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
|
||||||
|
* and the omnibus ISO/IEC 9945-1: 1996
|
||||||
|
* (1003.1 Issue 5, Single Unix Spec v2, Unix 95)
|
||||||
|
* _POSIX_C_SOURCE == 200112 1003.1-2001 (1003.1 Issue 6, Unix 03)
|
||||||
|
* _POSIX_C_SOURCE == 200809 1003.1-2008 (1003.1 Issue 7)
|
||||||
|
* IEEE Std 1003.1-2017 (Rev of 1003.1-2008) is
|
||||||
|
* 1003.1-2008 with two TCs applied with
|
||||||
|
* _POSIX_C_SOURCE=200809 and _XOPEN_SOURCE=700
|
||||||
|
*
|
||||||
|
* In addition, the X/Open Portability Guide, which is now the Single UNIX
|
||||||
|
* Specification, defines a feature-test macro which indicates the version of
|
||||||
|
* that specification, and which subsumes _POSIX_C_SOURCE.
|
||||||
|
*
|
||||||
|
* Our macros begin with two underscores to avoid namespace screwage.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
|
||||||
|
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
|
||||||
|
#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
|
||||||
|
#define _POSIX_C_SOURCE 199009
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
|
||||||
|
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
|
||||||
|
#undef _POSIX_C_SOURCE
|
||||||
|
#define _POSIX_C_SOURCE 199209
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
|
||||||
|
#ifdef _XOPEN_SOURCE
|
||||||
|
#if _XOPEN_SOURCE - 0 >= 700
|
||||||
|
#define __XSI_VISIBLE 700
|
||||||
|
#undef _POSIX_C_SOURCE
|
||||||
|
#define _POSIX_C_SOURCE 200809
|
||||||
|
#elif _XOPEN_SOURCE - 0 >= 600
|
||||||
|
#define __XSI_VISIBLE 600
|
||||||
|
#undef _POSIX_C_SOURCE
|
||||||
|
#define _POSIX_C_SOURCE 200112
|
||||||
|
#elif _XOPEN_SOURCE - 0 >= 500
|
||||||
|
#define __XSI_VISIBLE 500
|
||||||
|
#undef _POSIX_C_SOURCE
|
||||||
|
#define _POSIX_C_SOURCE 199506
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deal with all versions of POSIX. The ordering relative to the tests above is
|
||||||
|
* important.
|
||||||
|
*/
|
||||||
|
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
|
||||||
|
#define _POSIX_C_SOURCE 198808
|
||||||
|
#endif
|
||||||
|
#ifdef _POSIX_C_SOURCE
|
||||||
|
#if _POSIX_C_SOURCE >= 200809
|
||||||
|
#define __POSIX_VISIBLE 200809
|
||||||
|
#define __ISO_C_VISIBLE 1999
|
||||||
|
#elif _POSIX_C_SOURCE >= 200112
|
||||||
|
#define __POSIX_VISIBLE 200112
|
||||||
|
#define __ISO_C_VISIBLE 1999
|
||||||
|
#elif _POSIX_C_SOURCE >= 199506
|
||||||
|
#define __POSIX_VISIBLE 199506
|
||||||
|
#define __ISO_C_VISIBLE 1990
|
||||||
|
#elif _POSIX_C_SOURCE >= 199309
|
||||||
|
#define __POSIX_VISIBLE 199309
|
||||||
|
#define __ISO_C_VISIBLE 1990
|
||||||
|
#elif _POSIX_C_SOURCE >= 199209
|
||||||
|
#define __POSIX_VISIBLE 199209
|
||||||
|
#define __ISO_C_VISIBLE 1990
|
||||||
|
#elif _POSIX_C_SOURCE >= 199009
|
||||||
|
#define __POSIX_VISIBLE 199009
|
||||||
|
#define __ISO_C_VISIBLE 1990
|
||||||
|
#else
|
||||||
|
#define __POSIX_VISIBLE 198808
|
||||||
|
#define __ISO_C_VISIBLE 0
|
||||||
|
#endif /* _POSIX_C_SOURCE */
|
||||||
|
/*
|
||||||
|
* Both glibc and OpenBSD enable c11 features when _ISOC11_SOURCE is defined, or
|
||||||
|
* when compiling with -stdc=c11. A strict reading of the standard would suggest
|
||||||
|
* doing it only for the former. However, a strict reading also requires C99
|
||||||
|
* mode only, so building with C11 is already undefined. Follow glibc's and
|
||||||
|
* OpenBSD's lead for this non-standard configuration for maximum compatibility.
|
||||||
|
*/
|
||||||
|
#if _ISOC11_SOURCE || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
||||||
|
#undef __ISO_C_VISIBLE
|
||||||
|
#define __ISO_C_VISIBLE 2011
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
/*-
|
||||||
|
* Deal with _ANSI_SOURCE:
|
||||||
|
* If it is defined, and no other compilation environment is explicitly
|
||||||
|
* requested, then define our internal feature-test macros to zero. This
|
||||||
|
* makes no difference to the preprocessor (undefined symbols in preprocessing
|
||||||
|
* expressions are defined to have value zero), but makes it more convenient for
|
||||||
|
* a test program to print out the values.
|
||||||
|
*
|
||||||
|
* If a program mistakenly defines _ANSI_SOURCE and some other macro such as
|
||||||
|
* _POSIX_C_SOURCE, we will assume that it wants the broader compilation
|
||||||
|
* environment (and in fact we will never get here).
|
||||||
|
*/
|
||||||
|
#if defined(_ANSI_SOURCE) /* Hide almost everything. */
|
||||||
|
#define __POSIX_VISIBLE 0
|
||||||
|
#define __XSI_VISIBLE 0
|
||||||
|
#define __BSD_VISIBLE 0
|
||||||
|
#define __ISO_C_VISIBLE 1990
|
||||||
|
#define __EXT1_VISIBLE 0
|
||||||
|
#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
|
||||||
|
#define __POSIX_VISIBLE 0
|
||||||
|
#define __XSI_VISIBLE 0
|
||||||
|
#define __BSD_VISIBLE 0
|
||||||
|
#define __ISO_C_VISIBLE 1999
|
||||||
|
#define __EXT1_VISIBLE 0
|
||||||
|
#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */
|
||||||
|
#define __POSIX_VISIBLE 0
|
||||||
|
#define __XSI_VISIBLE 0
|
||||||
|
#define __BSD_VISIBLE 0
|
||||||
|
#define __ISO_C_VISIBLE 2011
|
||||||
|
#define __EXT1_VISIBLE 0
|
||||||
|
#else /* Default environment: show everything. */
|
||||||
|
#define __POSIX_VISIBLE 200809
|
||||||
|
#define __XSI_VISIBLE 700
|
||||||
|
#define __BSD_VISIBLE 1
|
||||||
|
#define __ISO_C_VISIBLE 2011
|
||||||
|
#define __EXT1_VISIBLE 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* User override __EXT1_VISIBLE */
|
||||||
|
#if defined(__STDC_WANT_LIB_EXT1__)
|
||||||
|
#undef __EXT1_VISIBLE
|
||||||
|
#if __STDC_WANT_LIB_EXT1__
|
||||||
|
#define __EXT1_VISIBLE 1
|
||||||
|
#else
|
||||||
|
#define __EXT1_VISIBLE 0
|
||||||
|
#endif
|
||||||
|
#endif /* __STDC_WANT_LIB_EXT1__ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Old versions of GCC use non-standard ARM arch symbols; acle-compat.h
|
||||||
|
* translates them to __ARM_ARCH and the modern feature symbols defined by ARM.
|
||||||
|
*/
|
||||||
|
#if defined(__arm__) && !defined(__ARM_ARCH)
|
||||||
|
#include <machine/acle-compat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Nullability qualifiers: currently only supported by Clang.
|
||||||
|
*/
|
||||||
|
#if !(defined(__clang__) && __has_feature(nullability))
|
||||||
|
#define _Nonnull
|
||||||
|
#define _Nullable
|
||||||
|
#define _Null_unspecified
|
||||||
|
#define __NULLABILITY_PRAGMA_PUSH
|
||||||
|
#define __NULLABILITY_PRAGMA_POP
|
||||||
|
#else
|
||||||
|
#define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wnullability-completeness\"")
|
||||||
|
#define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Type Safety Checking
|
||||||
|
*
|
||||||
|
* Clang provides additional attributes to enable checking type safety
|
||||||
|
* properties that cannot be enforced by the C type system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __has_attribute(__argument_with_type_tag__) && \
|
||||||
|
__has_attribute(__type_tag_for_datatype__)
|
||||||
|
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
|
||||||
|
__attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
|
||||||
|
#define __datatype_type_tag(kind, type) \
|
||||||
|
__attribute__((__type_tag_for_datatype__(kind, type)))
|
||||||
|
#else
|
||||||
|
#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx)
|
||||||
|
#define __datatype_type_tag(kind, type)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lock annotations.
|
||||||
|
*
|
||||||
|
* Clang provides support for doing basic thread-safety tests at
|
||||||
|
* compile-time, by marking which locks will/should be held when
|
||||||
|
* entering/leaving a functions.
|
||||||
|
*
|
||||||
|
* Furthermore, it is also possible to annotate variables and structure
|
||||||
|
* members to enforce that they are only accessed when certain locks are
|
||||||
|
* held.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if __has_extension(c_thread_safety_attributes)
|
||||||
|
#define __lock_annotate(x) __attribute__((x))
|
||||||
|
#else
|
||||||
|
#define __lock_annotate(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Structure implements a lock. */
|
||||||
|
#define __lockable __lock_annotate(lockable)
|
||||||
|
|
||||||
|
/* Function acquires an exclusive or shared lock. */
|
||||||
|
#define __locks_exclusive(...) \
|
||||||
|
__lock_annotate(exclusive_lock_function(__VA_ARGS__))
|
||||||
|
#define __locks_shared(...) \
|
||||||
|
__lock_annotate(shared_lock_function(__VA_ARGS__))
|
||||||
|
|
||||||
|
/* Function attempts to acquire an exclusive or shared lock. */
|
||||||
|
#define __trylocks_exclusive(...) \
|
||||||
|
__lock_annotate(exclusive_trylock_function(__VA_ARGS__))
|
||||||
|
#define __trylocks_shared(...) \
|
||||||
|
__lock_annotate(shared_trylock_function(__VA_ARGS__))
|
||||||
|
|
||||||
|
/* Function releases a lock. */
|
||||||
|
#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
|
||||||
|
|
||||||
|
/* Function asserts that an exclusive or shared lock is held. */
|
||||||
|
#define __asserts_exclusive(...) \
|
||||||
|
__lock_annotate(assert_exclusive_lock(__VA_ARGS__))
|
||||||
|
#define __asserts_shared(...) \
|
||||||
|
__lock_annotate(assert_shared_lock(__VA_ARGS__))
|
||||||
|
|
||||||
|
/* Function requires that an exclusive or shared lock is or is not held. */
|
||||||
|
#define __requires_exclusive(...) \
|
||||||
|
__lock_annotate(exclusive_locks_required(__VA_ARGS__))
|
||||||
|
#define __requires_shared(...) \
|
||||||
|
__lock_annotate(shared_locks_required(__VA_ARGS__))
|
||||||
|
#define __requires_unlocked(...) \
|
||||||
|
__lock_annotate(locks_excluded(__VA_ARGS__))
|
||||||
|
|
||||||
|
/* Function should not be analyzed. */
|
||||||
|
#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function or variable should not be sanitized, e.g., by AddressSanitizer.
|
||||||
|
* GCC has the nosanitize attribute, but as a function attribute only, and
|
||||||
|
* warns on use as a variable attribute.
|
||||||
|
*/
|
||||||
|
#if __has_attribute(no_sanitize) && defined(__clang__)
|
||||||
|
#ifdef _KERNEL
|
||||||
|
#define __nosanitizeaddress __attribute__((no_sanitize("kernel-address")))
|
||||||
|
#define __nosanitizememory __attribute__((no_sanitize("kernel-memory")))
|
||||||
|
#else
|
||||||
|
#define __nosanitizeaddress __attribute__((no_sanitize("address")))
|
||||||
|
#define __nosanitizememory __attribute__((no_sanitize("memory")))
|
||||||
|
#endif
|
||||||
|
#define __nosanitizethread __attribute__((no_sanitize("thread")))
|
||||||
|
#else
|
||||||
|
#define __nosanitizeaddress
|
||||||
|
#define __nosanitizememory
|
||||||
|
#define __nosanitizethread
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Guard variables and structure members by lock. */
|
||||||
|
#define __guarded_by(x) __lock_annotate(guarded_by(x))
|
||||||
|
#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
|
||||||
|
|
||||||
|
/* Alignment builtins for better type checking and improved code generation. */
|
||||||
|
/* Provide fallback versions for other compilers (GCC/Clang < 10): */
|
||||||
|
#if !__has_builtin(__builtin_is_aligned)
|
||||||
|
#define __builtin_is_aligned(x, align) \
|
||||||
|
(((__uintptr_t)x & ((align) - 1)) == 0)
|
||||||
|
#endif
|
||||||
|
#if !__has_builtin(__builtin_align_up)
|
||||||
|
#define __builtin_align_up(x, align) \
|
||||||
|
((__typeof__(x))(((__uintptr_t)(x)+((align)-1))&(~((align)-1))))
|
||||||
|
#endif
|
||||||
|
#if !__has_builtin(__builtin_align_down)
|
||||||
|
#define __builtin_align_down(x, align) \
|
||||||
|
((__typeof__(x))((x)&(~((align)-1))))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __align_up(x, y) __builtin_align_up(x, y)
|
||||||
|
#define __align_down(x, y) __builtin_align_down(x, y)
|
||||||
|
#define __is_aligned(x, y) __builtin_is_aligned(x, y)
|
||||||
|
|
||||||
|
#endif /* !_SYS_CDEFS_H_ */
|
|
@ -14,6 +14,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FDT_FIRST_SUPPORTED_VERSION 0x02
|
#define FDT_FIRST_SUPPORTED_VERSION 0x02
|
||||||
|
#define FDT_LAST_COMPATIBLE_VERSION 0x10
|
||||||
#define FDT_LAST_SUPPORTED_VERSION 0x11
|
#define FDT_LAST_SUPPORTED_VERSION 0x11
|
||||||
|
|
||||||
/* Error codes: informative error codes */
|
/* Error codes: informative error codes */
|
||||||
|
@ -101,7 +102,11 @@ extern "C" {
|
||||||
/* FDT_ERR_BADFLAGS: The function was passed a flags field that
|
/* FDT_ERR_BADFLAGS: The function was passed a flags field that
|
||||||
* contains invalid flags or an invalid combination of flags. */
|
* contains invalid flags or an invalid combination of flags. */
|
||||||
|
|
||||||
#define FDT_ERR_MAX 18
|
#define FDT_ERR_ALIGNMENT 19
|
||||||
|
/* FDT_ERR_ALIGNMENT: The device tree base address is not 8-byte
|
||||||
|
* aligned. */
|
||||||
|
|
||||||
|
#define FDT_ERR_MAX 19
|
||||||
|
|
||||||
/* constants */
|
/* constants */
|
||||||
#define FDT_MAX_PHANDLE 0xfffffffe
|
#define FDT_MAX_PHANDLE 0xfffffffe
|
||||||
|
@ -122,11 +127,16 @@ static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
|
||||||
uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
|
uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Alignment helpers:
|
* External helpers to access words from a device tree blob. They're built
|
||||||
* These helpers access words from a device tree blob. They're
|
* to work even with unaligned pointers on platforms (such as ARMv5) that don't
|
||||||
* built to work even with unaligned pointers on platforms (ike
|
* like unaligned loads and stores.
|
||||||
* ARM) that don't like unaligned loads and stores
|
|
||||||
*/
|
*/
|
||||||
|
static inline uint16_t fdt16_ld(const fdt16_t *p)
|
||||||
|
{
|
||||||
|
const uint8_t *bp = (const uint8_t *)p;
|
||||||
|
|
||||||
|
return ((uint16_t)bp[0] << 8) | bp[1];
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint32_t fdt32_ld(const fdt32_t *p)
|
static inline uint32_t fdt32_ld(const fdt32_t *p)
|
||||||
{
|
{
|
||||||
|
@ -184,23 +194,23 @@ int fdt_next_node(const void *fdt, int offset, int *depth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_first_subnode() - get offset of first direct subnode
|
* fdt_first_subnode() - get offset of first direct subnode
|
||||||
*
|
|
||||||
* @fdt: FDT blob
|
* @fdt: FDT blob
|
||||||
* @offset: Offset of node to check
|
* @offset: Offset of node to check
|
||||||
* @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none
|
*
|
||||||
|
* Return: offset of first subnode, or -FDT_ERR_NOTFOUND if there is none
|
||||||
*/
|
*/
|
||||||
int fdt_first_subnode(const void *fdt, int offset);
|
int fdt_first_subnode(const void *fdt, int offset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_next_subnode() - get offset of next direct subnode
|
* fdt_next_subnode() - get offset of next direct subnode
|
||||||
|
* @fdt: FDT blob
|
||||||
|
* @offset: Offset of previous subnode
|
||||||
*
|
*
|
||||||
* After first calling fdt_first_subnode(), call this function repeatedly to
|
* After first calling fdt_first_subnode(), call this function repeatedly to
|
||||||
* get direct subnodes of a parent node.
|
* get direct subnodes of a parent node.
|
||||||
*
|
*
|
||||||
* @fdt: FDT blob
|
* Return: offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
|
||||||
* @offset: Offset of previous subnode
|
* subnodes
|
||||||
* @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more
|
|
||||||
* subnodes
|
|
||||||
*/
|
*/
|
||||||
int fdt_next_subnode(const void *fdt, int offset);
|
int fdt_next_subnode(const void *fdt, int offset);
|
||||||
|
|
||||||
|
@ -225,7 +235,6 @@ int fdt_next_subnode(const void *fdt, int offset);
|
||||||
* Note that this is implemented as a macro and @node is used as
|
* Note that this is implemented as a macro and @node is used as
|
||||||
* iterator in the loop. The parent variable be constant or even a
|
* iterator in the loop. The parent variable be constant or even a
|
||||||
* literal.
|
* literal.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
#define fdt_for_each_subnode(node, fdt, parent) \
|
#define fdt_for_each_subnode(node, fdt, parent) \
|
||||||
for (node = fdt_first_subnode(fdt, parent); \
|
for (node = fdt_first_subnode(fdt, parent); \
|
||||||
|
@ -269,17 +278,21 @@ fdt_set_hdr_(size_dt_struct);
|
||||||
/**
|
/**
|
||||||
* fdt_header_size - return the size of the tree's header
|
* fdt_header_size - return the size of the tree's header
|
||||||
* @fdt: pointer to a flattened device tree
|
* @fdt: pointer to a flattened device tree
|
||||||
|
*
|
||||||
|
* Return: size of DTB header in bytes
|
||||||
*/
|
*/
|
||||||
size_t fdt_header_size(const void *fdt);
|
size_t fdt_header_size(const void *fdt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_header_size_ - internal function which takes a version number
|
* fdt_header_size_ - internal function to get header size from a version number
|
||||||
|
* @version: devicetree version number
|
||||||
|
*
|
||||||
|
* Return: size of DTB header in bytes
|
||||||
*/
|
*/
|
||||||
size_t fdt_header_size_(uint32_t version);
|
size_t fdt_header_size_(uint32_t version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_check_header - sanity check a device tree header
|
* fdt_check_header - sanity check a device tree header
|
||||||
|
|
||||||
* @fdt: pointer to data which might be a flattened device tree
|
* @fdt: pointer to data which might be a flattened device tree
|
||||||
*
|
*
|
||||||
* fdt_check_header() checks that the given buffer contains what
|
* fdt_check_header() checks that the given buffer contains what
|
||||||
|
@ -404,8 +417,7 @@ static inline uint32_t fdt_get_max_phandle(const void *fdt)
|
||||||
* highest phandle value in the device tree blob) will be returned in the
|
* highest phandle value in the device tree blob) will be returned in the
|
||||||
* @phandle parameter.
|
* @phandle parameter.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Return: 0 on success or a negative error-code on failure
|
||||||
* 0 on success or a negative error-code on failure
|
|
||||||
*/
|
*/
|
||||||
int fdt_generate_phandle(const void *fdt, uint32_t *phandle);
|
int fdt_generate_phandle(const void *fdt, uint32_t *phandle);
|
||||||
|
|
||||||
|
@ -425,9 +437,11 @@ int fdt_num_mem_rsv(const void *fdt);
|
||||||
/**
|
/**
|
||||||
* fdt_get_mem_rsv - retrieve one memory reserve map entry
|
* fdt_get_mem_rsv - retrieve one memory reserve map entry
|
||||||
* @fdt: pointer to the device tree blob
|
* @fdt: pointer to the device tree blob
|
||||||
* @address, @size: pointers to 64-bit variables
|
* @n: index of reserve map entry
|
||||||
|
* @address: pointer to 64-bit variable to hold the start address
|
||||||
|
* @size: pointer to 64-bit variable to hold the size of the entry
|
||||||
*
|
*
|
||||||
* On success, *address and *size will contain the address and size of
|
* On success, @address and @size will contain the address and size of
|
||||||
* the n-th reserve map entry from the device tree blob, in
|
* the n-th reserve map entry from the device tree blob, in
|
||||||
* native-endian format.
|
* native-endian format.
|
||||||
*
|
*
|
||||||
|
@ -450,6 +464,8 @@ int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
|
||||||
* namelen characters of name for matching the subnode name. This is
|
* namelen characters of name for matching the subnode name. This is
|
||||||
* useful for finding subnodes based on a portion of a larger string,
|
* useful for finding subnodes based on a portion of a larger string,
|
||||||
* such as a full path.
|
* such as a full path.
|
||||||
|
*
|
||||||
|
* Return: offset of the subnode or -FDT_ERR_NOTFOUND if name not found.
|
||||||
*/
|
*/
|
||||||
#ifndef SWIG /* Not available in Python */
|
#ifndef SWIG /* Not available in Python */
|
||||||
int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
|
int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
|
||||||
|
@ -489,6 +505,8 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
|
||||||
*
|
*
|
||||||
* Identical to fdt_path_offset(), but only consider the first namelen
|
* Identical to fdt_path_offset(), but only consider the first namelen
|
||||||
* characters of path as the path name.
|
* characters of path as the path name.
|
||||||
|
*
|
||||||
|
* Return: offset of the node or negative libfdt error value otherwise
|
||||||
*/
|
*/
|
||||||
#ifndef SWIG /* Not available in Python */
|
#ifndef SWIG /* Not available in Python */
|
||||||
int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
|
int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
|
||||||
|
@ -588,9 +606,9 @@ int fdt_next_property_offset(const void *fdt, int offset);
|
||||||
/**
|
/**
|
||||||
* fdt_for_each_property_offset - iterate over all properties of a node
|
* fdt_for_each_property_offset - iterate over all properties of a node
|
||||||
*
|
*
|
||||||
* @property_offset: property offset (int, lvalue)
|
* @property: property offset (int, lvalue)
|
||||||
* @fdt: FDT blob (const void *)
|
* @fdt: FDT blob (const void *)
|
||||||
* @node: node offset (int)
|
* @node: node offset (int)
|
||||||
*
|
*
|
||||||
* This is actually a wrapper around a for loop and would be used like so:
|
* This is actually a wrapper around a for loop and would be used like so:
|
||||||
*
|
*
|
||||||
|
@ -653,6 +671,9 @@ const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
|
||||||
*
|
*
|
||||||
* Identical to fdt_get_property(), but only examine the first namelen
|
* Identical to fdt_get_property(), but only examine the first namelen
|
||||||
* characters of name for matching the property name.
|
* characters of name for matching the property name.
|
||||||
|
*
|
||||||
|
* Return: pointer to the structure representing the property, or NULL
|
||||||
|
* if not found
|
||||||
*/
|
*/
|
||||||
#ifndef SWIG /* Not available in Python */
|
#ifndef SWIG /* Not available in Python */
|
||||||
const struct fdt_property *fdt_get_property_namelen(const void *fdt,
|
const struct fdt_property *fdt_get_property_namelen(const void *fdt,
|
||||||
|
@ -745,6 +766,8 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
|
||||||
*
|
*
|
||||||
* Identical to fdt_getprop(), but only examine the first namelen
|
* Identical to fdt_getprop(), but only examine the first namelen
|
||||||
* characters of name for matching the property name.
|
* characters of name for matching the property name.
|
||||||
|
*
|
||||||
|
* Return: pointer to the property's value or NULL on error
|
||||||
*/
|
*/
|
||||||
#ifndef SWIG /* Not available in Python */
|
#ifndef SWIG /* Not available in Python */
|
||||||
const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
|
const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
|
||||||
|
@ -766,10 +789,10 @@ static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
|
||||||
* @lenp: pointer to an integer variable (will be overwritten) or NULL
|
* @lenp: pointer to an integer variable (will be overwritten) or NULL
|
||||||
*
|
*
|
||||||
* fdt_getprop() retrieves a pointer to the value of the property
|
* fdt_getprop() retrieves a pointer to the value of the property
|
||||||
* named 'name' of the node at offset nodeoffset (this will be a
|
* named @name of the node at offset @nodeoffset (this will be a
|
||||||
* pointer to within the device blob itself, not a copy of the value).
|
* pointer to within the device blob itself, not a copy of the value).
|
||||||
* If lenp is non-NULL, the length of the property value is also
|
* If @lenp is non-NULL, the length of the property value is also
|
||||||
* returned, in the integer pointed to by lenp.
|
* returned, in the integer pointed to by @lenp.
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* pointer to the property's value
|
* pointer to the property's value
|
||||||
|
@ -814,8 +837,11 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
|
||||||
* @name: name of the alias th look up
|
* @name: name of the alias th look up
|
||||||
* @namelen: number of characters of name to consider
|
* @namelen: number of characters of name to consider
|
||||||
*
|
*
|
||||||
* Identical to fdt_get_alias(), but only examine the first namelen
|
* Identical to fdt_get_alias(), but only examine the first @namelen
|
||||||
* characters of name for matching the alias name.
|
* characters of @name for matching the alias name.
|
||||||
|
*
|
||||||
|
* Return: a pointer to the expansion of the alias named @name, if it exists,
|
||||||
|
* NULL otherwise
|
||||||
*/
|
*/
|
||||||
#ifndef SWIG /* Not available in Python */
|
#ifndef SWIG /* Not available in Python */
|
||||||
const char *fdt_get_alias_namelen(const void *fdt,
|
const char *fdt_get_alias_namelen(const void *fdt,
|
||||||
|
@ -828,7 +854,7 @@ const char *fdt_get_alias_namelen(const void *fdt,
|
||||||
* @name: name of the alias th look up
|
* @name: name of the alias th look up
|
||||||
*
|
*
|
||||||
* fdt_get_alias() retrieves the value of a given alias. That is, the
|
* fdt_get_alias() retrieves the value of a given alias. That is, the
|
||||||
* value of the property named 'name' in the node /aliases.
|
* value of the property named @name in the node /aliases.
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* a pointer to the expansion of the alias named 'name', if it exists
|
* a pointer to the expansion of the alias named 'name', if it exists
|
||||||
|
@ -1004,14 +1030,13 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
|
||||||
int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
|
int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_node_check_compatible: check a node's compatible property
|
* fdt_node_check_compatible - check a node's compatible property
|
||||||
* @fdt: pointer to the device tree blob
|
* @fdt: pointer to the device tree blob
|
||||||
* @nodeoffset: offset of a tree node
|
* @nodeoffset: offset of a tree node
|
||||||
* @compatible: string to match against
|
* @compatible: string to match against
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* fdt_node_check_compatible() returns 0 if the given node contains a
|
* fdt_node_check_compatible() returns 0 if the given node contains a
|
||||||
* 'compatible' property with the given string as one of its elements,
|
* @compatible property with the given string as one of its elements,
|
||||||
* it returns non-zero otherwise, or on error.
|
* it returns non-zero otherwise, or on error.
|
||||||
*
|
*
|
||||||
* returns:
|
* returns:
|
||||||
|
@ -1075,7 +1100,7 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
|
||||||
* one or more strings, each terminated by \0, as is found in a device tree
|
* one or more strings, each terminated by \0, as is found in a device tree
|
||||||
* "compatible" property.
|
* "compatible" property.
|
||||||
*
|
*
|
||||||
* @return: 1 if the string is found in the list, 0 not found, or invalid list
|
* Return: 1 if the string is found in the list, 0 not found, or invalid list
|
||||||
*/
|
*/
|
||||||
int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
|
int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
|
||||||
|
|
||||||
|
@ -1084,7 +1109,8 @@ int fdt_stringlist_contains(const char *strlist, int listlen, const char *str);
|
||||||
* @fdt: pointer to the device tree blob
|
* @fdt: pointer to the device tree blob
|
||||||
* @nodeoffset: offset of a tree node
|
* @nodeoffset: offset of a tree node
|
||||||
* @property: name of the property containing the string list
|
* @property: name of the property containing the string list
|
||||||
* @return:
|
*
|
||||||
|
* Return:
|
||||||
* the number of strings in the given property
|
* the number of strings in the given property
|
||||||
* -FDT_ERR_BADVALUE if the property value is not NUL-terminated
|
* -FDT_ERR_BADVALUE if the property value is not NUL-terminated
|
||||||
* -FDT_ERR_NOTFOUND if the property does not exist
|
* -FDT_ERR_NOTFOUND if the property does not exist
|
||||||
|
@ -1104,7 +1130,7 @@ int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property);
|
||||||
* small-valued cell properties, such as #address-cells, when searching for
|
* small-valued cell properties, such as #address-cells, when searching for
|
||||||
* the empty string.
|
* the empty string.
|
||||||
*
|
*
|
||||||
* @return:
|
* return:
|
||||||
* the index of the string in the list of strings
|
* the index of the string in the list of strings
|
||||||
* -FDT_ERR_BADVALUE if the property value is not NUL-terminated
|
* -FDT_ERR_BADVALUE if the property value is not NUL-terminated
|
||||||
* -FDT_ERR_NOTFOUND if the property does not exist or does not contain
|
* -FDT_ERR_NOTFOUND if the property does not exist or does not contain
|
||||||
|
@ -1128,7 +1154,7 @@ int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property,
|
||||||
* If non-NULL, the length of the string (on success) or a negative error-code
|
* If non-NULL, the length of the string (on success) or a negative error-code
|
||||||
* (on failure) will be stored in the integer pointer to by lenp.
|
* (on failure) will be stored in the integer pointer to by lenp.
|
||||||
*
|
*
|
||||||
* @return:
|
* Return:
|
||||||
* A pointer to the string at the given index in the string list or NULL on
|
* A pointer to the string at the given index in the string list or NULL on
|
||||||
* failure. On success the length of the string will be stored in the memory
|
* failure. On success the length of the string will be stored in the memory
|
||||||
* location pointed to by the lenp parameter, if non-NULL. On failure one of
|
* location pointed to by the lenp parameter, if non-NULL. On failure one of
|
||||||
|
@ -1217,6 +1243,8 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
|
||||||
* starting from the given index, and using only the first characters
|
* starting from the given index, and using only the first characters
|
||||||
* of the name. It is useful when you want to manipulate only one value of
|
* of the name. It is useful when you want to manipulate only one value of
|
||||||
* an array and you have a string that doesn't end with \0.
|
* an array and you have a string that doesn't end with \0.
|
||||||
|
*
|
||||||
|
* Return: 0 on success, negative libfdt error value otherwise
|
||||||
*/
|
*/
|
||||||
#ifndef SWIG /* Not available in Python */
|
#ifndef SWIG /* Not available in Python */
|
||||||
int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
|
int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
|
||||||
|
@ -1330,8 +1358,13 @@ static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_setprop_inplace_cell - change the value of a single-cell property
|
* fdt_setprop_inplace_cell - change the value of a single-cell property
|
||||||
|
* @fdt: pointer to the device tree blob
|
||||||
|
* @nodeoffset: offset of the node containing the property
|
||||||
|
* @name: name of the property to change the value of
|
||||||
|
* @val: new value of the 32-bit cell
|
||||||
*
|
*
|
||||||
* This is an alternative name for fdt_setprop_inplace_u32()
|
* This is an alternative name for fdt_setprop_inplace_u32()
|
||||||
|
* Return: 0 on success, negative libfdt error number otherwise.
|
||||||
*/
|
*/
|
||||||
static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
|
static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset,
|
||||||
const char *name, uint32_t val)
|
const char *name, uint32_t val)
|
||||||
|
@ -1403,7 +1436,7 @@ int fdt_nop_node(void *fdt, int nodeoffset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_create_with_flags - begin creation of a new fdt
|
* fdt_create_with_flags - begin creation of a new fdt
|
||||||
* @fdt: pointer to memory allocated where fdt will be created
|
* @buf: pointer to memory allocated where fdt will be created
|
||||||
* @bufsize: size of the memory space at fdt
|
* @bufsize: size of the memory space at fdt
|
||||||
* @flags: a valid combination of FDT_CREATE_FLAG_ flags, or 0.
|
* @flags: a valid combination of FDT_CREATE_FLAG_ flags, or 0.
|
||||||
*
|
*
|
||||||
|
@ -1421,7 +1454,7 @@ int fdt_create_with_flags(void *buf, int bufsize, uint32_t flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_create - begin creation of a new fdt
|
* fdt_create - begin creation of a new fdt
|
||||||
* @fdt: pointer to memory allocated where fdt will be created
|
* @buf: pointer to memory allocated where fdt will be created
|
||||||
* @bufsize: size of the memory space at fdt
|
* @bufsize: size of the memory space at fdt
|
||||||
*
|
*
|
||||||
* fdt_create() is equivalent to fdt_create_with_flags() with flags=0.
|
* fdt_create() is equivalent to fdt_create_with_flags() with flags=0.
|
||||||
|
@ -1486,7 +1519,8 @@ int fdt_pack(void *fdt);
|
||||||
/**
|
/**
|
||||||
* fdt_add_mem_rsv - add one memory reserve map entry
|
* fdt_add_mem_rsv - add one memory reserve map entry
|
||||||
* @fdt: pointer to the device tree blob
|
* @fdt: pointer to the device tree blob
|
||||||
* @address, @size: 64-bit values (native endian)
|
* @address: 64-bit start address of the reserve map entry
|
||||||
|
* @size: 64-bit size of the reserved region
|
||||||
*
|
*
|
||||||
* Adds a reserve map entry to the given blob reserving a region at
|
* Adds a reserve map entry to the given blob reserving a region at
|
||||||
* address address of length size.
|
* address address of length size.
|
||||||
|
@ -1691,8 +1725,14 @@ static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_setprop_cell - set a property to a single cell value
|
* fdt_setprop_cell - set a property to a single cell value
|
||||||
|
* @fdt: pointer to the device tree blob
|
||||||
|
* @nodeoffset: offset of the node whose property to change
|
||||||
|
* @name: name of the property to change
|
||||||
|
* @val: 32-bit integer value for the property (native endian)
|
||||||
*
|
*
|
||||||
* This is an alternative name for fdt_setprop_u32()
|
* This is an alternative name for fdt_setprop_u32()
|
||||||
|
*
|
||||||
|
* Return: 0 on success, negative libfdt error value otherwise.
|
||||||
*/
|
*/
|
||||||
static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
|
static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
|
||||||
uint32_t val)
|
uint32_t val)
|
||||||
|
@ -1863,8 +1903,14 @@ static inline int fdt_appendprop_u64(void *fdt, int nodeoffset,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fdt_appendprop_cell - append a single cell value to a property
|
* fdt_appendprop_cell - append a single cell value to a property
|
||||||
|
* @fdt: pointer to the device tree blob
|
||||||
|
* @nodeoffset: offset of the node whose property to change
|
||||||
|
* @name: name of the property to change
|
||||||
|
* @val: 32-bit integer value to append to the property (native endian)
|
||||||
*
|
*
|
||||||
* This is an alternative name for fdt_appendprop_u32()
|
* This is an alternative name for fdt_appendprop_u32()
|
||||||
|
*
|
||||||
|
* Return: 0 on success, negative libfdt error value otherwise.
|
||||||
*/
|
*/
|
||||||
static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
|
static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
|
||||||
const char *name, uint32_t val)
|
const char *name, uint32_t val)
|
||||||
|
@ -1967,13 +2013,16 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name);
|
||||||
* fdt_add_subnode_namelen - creates a new node based on substring
|
* fdt_add_subnode_namelen - creates a new node based on substring
|
||||||
* @fdt: pointer to the device tree blob
|
* @fdt: pointer to the device tree blob
|
||||||
* @parentoffset: structure block offset of a node
|
* @parentoffset: structure block offset of a node
|
||||||
* @name: name of the subnode to locate
|
* @name: name of the subnode to create
|
||||||
* @namelen: number of characters of name to consider
|
* @namelen: number of characters of name to consider
|
||||||
*
|
*
|
||||||
* Identical to fdt_add_subnode(), but use only the first namelen
|
* Identical to fdt_add_subnode(), but use only the first @namelen
|
||||||
* characters of name as the name of the new node. This is useful for
|
* characters of @name as the name of the new node. This is useful for
|
||||||
* creating subnodes based on a portion of a larger string, such as a
|
* creating subnodes based on a portion of a larger string, such as a
|
||||||
* full path.
|
* full path.
|
||||||
|
*
|
||||||
|
* Return: structure block offset of the created subnode (>=0),
|
||||||
|
* negative libfdt error value otherwise
|
||||||
*/
|
*/
|
||||||
#ifndef SWIG /* Not available in Python */
|
#ifndef SWIG /* Not available in Python */
|
||||||
int fdt_add_subnode_namelen(void *fdt, int parentoffset,
|
int fdt_add_subnode_namelen(void *fdt, int parentoffset,
|
||||||
|
@ -1992,7 +2041,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
|
||||||
*
|
*
|
||||||
* This function will insert data into the blob, and will therefore
|
* This function will insert data into the blob, and will therefore
|
||||||
* change the offsets of some existing nodes.
|
* change the offsets of some existing nodes.
|
||||||
|
*
|
||||||
* returns:
|
* returns:
|
||||||
* structure block offset of the created nodeequested subnode (>=0), on
|
* structure block offset of the created nodeequested subnode (>=0), on
|
||||||
* success
|
* success
|
||||||
|
@ -2067,6 +2116,24 @@ int fdt_del_node(void *fdt, int nodeoffset);
|
||||||
*/
|
*/
|
||||||
int fdt_overlay_apply(void *fdt, void *fdto);
|
int fdt_overlay_apply(void *fdt, void *fdto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fdt_overlay_target_offset - retrieves the offset of a fragment's target
|
||||||
|
* @fdt: Base device tree blob
|
||||||
|
* @fdto: Device tree overlay blob
|
||||||
|
* @fragment_offset: node offset of the fragment in the overlay
|
||||||
|
* @pathp: pointer which receives the path of the target (or NULL)
|
||||||
|
*
|
||||||
|
* fdt_overlay_target_offset() retrieves the target offset in the base
|
||||||
|
* device tree of a fragment, no matter how the actual targeting is
|
||||||
|
* done (through a phandle or a path)
|
||||||
|
*
|
||||||
|
* returns:
|
||||||
|
* the targeted node offset in the base device tree
|
||||||
|
* Negative error code on error
|
||||||
|
*/
|
||||||
|
int fdt_overlay_target_offset(const void *fdt, const void *fdto,
|
||||||
|
int fragment_offset, char const **pathp);
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* Debugging / informational functions */
|
/* Debugging / informational functions */
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
//===-- aeabi_ldivmod.S - EABI ldivmod implementation ---------------------===//
|
//===-- aeabi_ldivmod.S - EABI ldivmod implementation ---------------------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
//
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
29
lib/compiler-rt/builtins/arm/aeabi_memcpy.S
Normal file
29
lib/compiler-rt/builtins/arm/aeabi_memcpy.S
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//===-- aeabi_memcpy.S - EABI memcpy implementation -----------------------===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "../assembly.h"
|
||||||
|
|
||||||
|
// void __aeabi_memcpy(void *dest, void *src, size_t n) { memcpy(dest, src, n); }
|
||||||
|
|
||||||
|
.syntax unified
|
||||||
|
.p2align 2
|
||||||
|
DEFINE_COMPILERRT_FUNCTION(__aeabi_memcpy)
|
||||||
|
#ifdef USE_THUMB_1
|
||||||
|
push {r7, lr}
|
||||||
|
bl memcpy
|
||||||
|
pop {r7, pc}
|
||||||
|
#else
|
||||||
|
b memcpy
|
||||||
|
#endif
|
||||||
|
END_COMPILERRT_FUNCTION(__aeabi_memcpy)
|
||||||
|
|
||||||
|
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcpy4, __aeabi_memcpy)
|
||||||
|
DEFINE_AEABI_FUNCTION_ALIAS(__aeabi_memcpy8, __aeabi_memcpy)
|
||||||
|
|
||||||
|
NO_EXEC_STACK_DIRECTIVE
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
//===-- aeabi_uldivmod.S - EABI uldivmod implementation -------------------===//
|
//===-- aeabi_uldivmod.S - EABI uldivmod implementation -------------------===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
//
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,27 @@
|
||||||
/* ===-- assembly.h - compiler-rt assembler support macros -----------------===
|
//===-- assembly.h - compiler-rt assembler support macros -----------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file defines macros for use in compiler-rt assembler source.
|
||||||
* This file defines macros for use in compiler-rt assembler source.
|
// This file is not part of the interface of this library.
|
||||||
* This file is not part of the interface of this library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMPILERRT_ASSEMBLY_H
|
#ifndef COMPILERRT_ASSEMBLY_H
|
||||||
#define COMPILERRT_ASSEMBLY_H
|
#define COMPILERRT_ASSEMBLY_H
|
||||||
|
|
||||||
#if defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
|
#if defined(__linux__) && defined(__CET__)
|
||||||
#define SEPARATOR @
|
#if __has_include(<cet.h>)
|
||||||
|
#include <cet.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && defined(__aarch64__)
|
||||||
|
#define SEPARATOR %%
|
||||||
#else
|
#else
|
||||||
#define SEPARATOR ;
|
#define SEPARATOR ;
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,14 +41,15 @@
|
||||||
#define HIDDEN(name) .hidden name
|
#define HIDDEN(name) .hidden name
|
||||||
#define LOCAL_LABEL(name) .L_##name
|
#define LOCAL_LABEL(name) .L_##name
|
||||||
#define FILE_LEVEL_DIRECTIVE
|
#define FILE_LEVEL_DIRECTIVE
|
||||||
#if defined(__arm__)
|
#if defined(__arm__) || defined(__aarch64__)
|
||||||
#define SYMBOL_IS_FUNC(name) .type name,%function
|
#define SYMBOL_IS_FUNC(name) .type name,%function
|
||||||
#else
|
#else
|
||||||
#define SYMBOL_IS_FUNC(name) .type name,@function
|
#define SYMBOL_IS_FUNC(name) .type name,@function
|
||||||
#endif
|
#endif
|
||||||
#define CONST_SECTION .section .rodata
|
#define CONST_SECTION .section .rodata
|
||||||
|
|
||||||
#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__)
|
#if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
|
||||||
|
defined(__linux__)
|
||||||
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
|
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
|
||||||
#else
|
#else
|
||||||
#define NO_EXEC_STACK_DIRECTIVE
|
#define NO_EXEC_STACK_DIRECTIVE
|
||||||
|
@ -66,11 +71,103 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__arm__) || defined(__aarch64__)
|
||||||
|
#define FUNC_ALIGN \
|
||||||
|
.text SEPARATOR \
|
||||||
|
.balign 16 SEPARATOR
|
||||||
|
#else
|
||||||
|
#define FUNC_ALIGN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// BTI and PAC gnu property note
|
||||||
|
#define NT_GNU_PROPERTY_TYPE_0 5
|
||||||
|
#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
|
||||||
|
#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI 1
|
||||||
|
#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC 2
|
||||||
|
|
||||||
|
#if defined(__ARM_FEATURE_BTI_DEFAULT)
|
||||||
|
#define BTI_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_BTI
|
||||||
|
#else
|
||||||
|
#define BTI_FLAG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __ARM_FEATURE_PAC_DEFAULT & 3
|
||||||
|
#define PAC_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_PAC
|
||||||
|
#else
|
||||||
|
#define PAC_FLAG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GNU_PROPERTY(type, value) \
|
||||||
|
.pushsection .note.gnu.property, "a" SEPARATOR \
|
||||||
|
.p2align 3 SEPARATOR \
|
||||||
|
.word 4 SEPARATOR \
|
||||||
|
.word 16 SEPARATOR \
|
||||||
|
.word NT_GNU_PROPERTY_TYPE_0 SEPARATOR \
|
||||||
|
.asciz "GNU" SEPARATOR \
|
||||||
|
.word type SEPARATOR \
|
||||||
|
.word 4 SEPARATOR \
|
||||||
|
.word value SEPARATOR \
|
||||||
|
.word 0 SEPARATOR \
|
||||||
|
.popsection
|
||||||
|
|
||||||
|
#if BTI_FLAG != 0
|
||||||
|
#define BTI_C hint #34
|
||||||
|
#define BTI_J hint #36
|
||||||
|
#else
|
||||||
|
#define BTI_C
|
||||||
|
#define BTI_J
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (BTI_FLAG | PAC_FLAG) != 0
|
||||||
|
#define GNU_PROPERTY_BTI_PAC \
|
||||||
|
GNU_PROPERTY(GNU_PROPERTY_AARCH64_FEATURE_1_AND, BTI_FLAG | PAC_FLAG)
|
||||||
|
#else
|
||||||
|
#define GNU_PROPERTY_BTI_PAC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__) || defined(__GCC_HAVE_DWARF2_CFI_ASM)
|
||||||
|
#define CFI_START .cfi_startproc
|
||||||
|
#define CFI_END .cfi_endproc
|
||||||
|
#else
|
||||||
|
#define CFI_START
|
||||||
|
#define CFI_END
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__arm__)
|
#if defined(__arm__)
|
||||||
|
|
||||||
|
// Determine actual [ARM][THUMB[1][2]] ISA using compiler predefined macros:
|
||||||
|
// - for '-mthumb -march=armv6' compiler defines '__thumb__'
|
||||||
|
// - for '-mthumb -march=armv7' compiler defines '__thumb__' and '__thumb2__'
|
||||||
|
#if defined(__thumb2__) || defined(__thumb__)
|
||||||
|
#define DEFINE_CODE_STATE .thumb SEPARATOR
|
||||||
|
#define DECLARE_FUNC_ENCODING .thumb_func SEPARATOR
|
||||||
|
#if defined(__thumb2__)
|
||||||
|
#define USE_THUMB_2
|
||||||
|
#define IT(cond) it cond
|
||||||
|
#define ITT(cond) itt cond
|
||||||
|
#define ITE(cond) ite cond
|
||||||
|
#else
|
||||||
|
#define USE_THUMB_1
|
||||||
|
#define IT(cond)
|
||||||
|
#define ITT(cond)
|
||||||
|
#define ITE(cond)
|
||||||
|
#endif // defined(__thumb__2)
|
||||||
|
#else // !defined(__thumb2__) && !defined(__thumb__)
|
||||||
|
#define DEFINE_CODE_STATE .arm SEPARATOR
|
||||||
|
#define DECLARE_FUNC_ENCODING
|
||||||
|
#define IT(cond)
|
||||||
|
#define ITT(cond)
|
||||||
|
#define ITE(cond)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_THUMB_1) && defined(USE_THUMB_2)
|
||||||
|
#error "USE_THUMB_1 and USE_THUMB_2 can't be defined together."
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__ARM_ARCH_4T__) || __ARM_ARCH >= 5
|
#if defined(__ARM_ARCH_4T__) || __ARM_ARCH >= 5
|
||||||
#define ARM_HAS_BX
|
#define ARM_HAS_BX
|
||||||
#endif
|
#endif
|
||||||
#if !defined(__ARM_FEATURE_CLZ) && __ARM_ARCH_ISA_THUMB != 1 && \
|
#if !defined(__ARM_FEATURE_CLZ) && !defined(USE_THUMB_1) && \
|
||||||
(__ARM_ARCH >= 6 || (__ARM_ARCH == 5 && !defined(__ARM_ARCH_5__)))
|
(__ARM_ARCH >= 6 || (__ARM_ARCH == 5 && !defined(__ARM_ARCH_5__)))
|
||||||
#define __ARM_FEATURE_CLZ
|
#define __ARM_FEATURE_CLZ
|
||||||
#endif
|
#endif
|
||||||
|
@ -92,40 +189,47 @@
|
||||||
JMP(ip)
|
JMP(ip)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __ARM_ARCH_ISA_THUMB == 2
|
#if defined(USE_THUMB_2)
|
||||||
#define IT(cond) it cond
|
|
||||||
#define ITT(cond) itt cond
|
|
||||||
#else
|
|
||||||
#define IT(cond)
|
|
||||||
#define ITT(cond)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if __ARM_ARCH_ISA_THUMB == 2
|
|
||||||
#define WIDE(op) op.w
|
#define WIDE(op) op.w
|
||||||
#else
|
#else
|
||||||
#define WIDE(op) op
|
#define WIDE(op) op
|
||||||
#endif
|
#endif
|
||||||
|
#else // !defined(__arm)
|
||||||
|
#define DECLARE_FUNC_ENCODING
|
||||||
|
#define DEFINE_CODE_STATE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GLUE2(a, b) a##b
|
#define GLUE2_(a, b) a##b
|
||||||
#define GLUE(a, b) GLUE2(a, b)
|
#define GLUE(a, b) GLUE2_(a, b)
|
||||||
|
#define GLUE2(a, b) GLUE2_(a, b)
|
||||||
|
#define GLUE3_(a, b, c) a##b##c
|
||||||
|
#define GLUE3(a, b, c) GLUE3_(a, b, c)
|
||||||
|
#define GLUE4_(a, b, c, d) a##b##c##d
|
||||||
|
#define GLUE4(a, b, c, d) GLUE4_(a, b, c, d)
|
||||||
|
|
||||||
#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
|
#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
|
||||||
|
|
||||||
#ifdef VISIBILITY_HIDDEN
|
#ifdef VISIBILITY_HIDDEN
|
||||||
#define DECLARE_SYMBOL_VISIBILITY(name) \
|
#define DECLARE_SYMBOL_VISIBILITY(name) \
|
||||||
HIDDEN(SYMBOL_NAME(name)) SEPARATOR
|
HIDDEN(SYMBOL_NAME(name)) SEPARATOR
|
||||||
|
#define DECLARE_SYMBOL_VISIBILITY_UNMANGLED(name) \
|
||||||
|
HIDDEN(name) SEPARATOR
|
||||||
#else
|
#else
|
||||||
#define DECLARE_SYMBOL_VISIBILITY(name)
|
#define DECLARE_SYMBOL_VISIBILITY(name)
|
||||||
|
#define DECLARE_SYMBOL_VISIBILITY_UNMANGLED(name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFINE_COMPILERRT_FUNCTION(name) \
|
#define DEFINE_COMPILERRT_FUNCTION(name) \
|
||||||
|
DEFINE_CODE_STATE \
|
||||||
FILE_LEVEL_DIRECTIVE SEPARATOR \
|
FILE_LEVEL_DIRECTIVE SEPARATOR \
|
||||||
.globl SYMBOL_NAME(name) SEPARATOR \
|
.globl SYMBOL_NAME(name) SEPARATOR \
|
||||||
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
||||||
DECLARE_SYMBOL_VISIBILITY(name) \
|
DECLARE_SYMBOL_VISIBILITY(name) \
|
||||||
|
DECLARE_FUNC_ENCODING \
|
||||||
SYMBOL_NAME(name):
|
SYMBOL_NAME(name):
|
||||||
|
|
||||||
#define DEFINE_COMPILERRT_THUMB_FUNCTION(name) \
|
#define DEFINE_COMPILERRT_THUMB_FUNCTION(name) \
|
||||||
|
DEFINE_CODE_STATE \
|
||||||
FILE_LEVEL_DIRECTIVE SEPARATOR \
|
FILE_LEVEL_DIRECTIVE SEPARATOR \
|
||||||
.globl SYMBOL_NAME(name) SEPARATOR \
|
.globl SYMBOL_NAME(name) SEPARATOR \
|
||||||
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
||||||
|
@ -134,18 +238,32 @@
|
||||||
SYMBOL_NAME(name):
|
SYMBOL_NAME(name):
|
||||||
|
|
||||||
#define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name) \
|
#define DEFINE_COMPILERRT_PRIVATE_FUNCTION(name) \
|
||||||
|
DEFINE_CODE_STATE \
|
||||||
FILE_LEVEL_DIRECTIVE SEPARATOR \
|
FILE_LEVEL_DIRECTIVE SEPARATOR \
|
||||||
.globl SYMBOL_NAME(name) SEPARATOR \
|
.globl SYMBOL_NAME(name) SEPARATOR \
|
||||||
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
||||||
HIDDEN(SYMBOL_NAME(name)) SEPARATOR \
|
HIDDEN(SYMBOL_NAME(name)) SEPARATOR \
|
||||||
|
DECLARE_FUNC_ENCODING \
|
||||||
SYMBOL_NAME(name):
|
SYMBOL_NAME(name):
|
||||||
|
|
||||||
#define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name) \
|
#define DEFINE_COMPILERRT_PRIVATE_FUNCTION_UNMANGLED(name) \
|
||||||
|
DEFINE_CODE_STATE \
|
||||||
.globl name SEPARATOR \
|
.globl name SEPARATOR \
|
||||||
SYMBOL_IS_FUNC(name) SEPARATOR \
|
SYMBOL_IS_FUNC(name) SEPARATOR \
|
||||||
HIDDEN(name) SEPARATOR \
|
HIDDEN(name) SEPARATOR \
|
||||||
|
DECLARE_FUNC_ENCODING \
|
||||||
name:
|
name:
|
||||||
|
|
||||||
|
#define DEFINE_COMPILERRT_OUTLINE_FUNCTION_UNMANGLED(name) \
|
||||||
|
DEFINE_CODE_STATE \
|
||||||
|
FUNC_ALIGN \
|
||||||
|
.globl name SEPARATOR \
|
||||||
|
SYMBOL_IS_FUNC(name) SEPARATOR \
|
||||||
|
DECLARE_SYMBOL_VISIBILITY_UNMANGLED(name) SEPARATOR \
|
||||||
|
CFI_START SEPARATOR \
|
||||||
|
DECLARE_FUNC_ENCODING \
|
||||||
|
name: SEPARATOR BTI_C
|
||||||
|
|
||||||
#define DEFINE_COMPILERRT_FUNCTION_ALIAS(name, target) \
|
#define DEFINE_COMPILERRT_FUNCTION_ALIAS(name, target) \
|
||||||
.globl SYMBOL_NAME(name) SEPARATOR \
|
.globl SYMBOL_NAME(name) SEPARATOR \
|
||||||
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \
|
||||||
|
@ -162,8 +280,13 @@
|
||||||
#ifdef __ELF__
|
#ifdef __ELF__
|
||||||
#define END_COMPILERRT_FUNCTION(name) \
|
#define END_COMPILERRT_FUNCTION(name) \
|
||||||
.size SYMBOL_NAME(name), . - SYMBOL_NAME(name)
|
.size SYMBOL_NAME(name), . - SYMBOL_NAME(name)
|
||||||
|
#define END_COMPILERRT_OUTLINE_FUNCTION(name) \
|
||||||
|
CFI_END SEPARATOR \
|
||||||
|
.size SYMBOL_NAME(name), . - SYMBOL_NAME(name)
|
||||||
#else
|
#else
|
||||||
#define END_COMPILERRT_FUNCTION(name)
|
#define END_COMPILERRT_FUNCTION(name)
|
||||||
|
#define END_COMPILERRT_OUTLINE_FUNCTION(name) \
|
||||||
|
CFI_END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* COMPILERRT_ASSEMBLY_H */
|
#endif // COMPILERRT_ASSEMBLY_H
|
||||||
|
|
|
@ -1,29 +1,35 @@
|
||||||
/* ===-- ctzdi2.c - Implement __ctzdi2 -------------------------------------===
|
//===-- ctzdi2.c - Implement __ctzdi2 -------------------------------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file implements __ctzdi2 for the compiler_rt library.
|
||||||
* This file implements __ctzdi2 for the compiler_rt library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "int_lib.h"
|
#include "int_lib.h"
|
||||||
|
|
||||||
/* Returns: the number of trailing 0-bits */
|
// Returns: the number of trailing 0-bits
|
||||||
|
|
||||||
/* Precondition: a != 0 */
|
#if !defined(__clang__) && \
|
||||||
|
((defined(__sparc__) && defined(__arch64__)) || defined(__mips64) || \
|
||||||
|
(defined(__riscv) && __SIZEOF_POINTER__ >= 8))
|
||||||
|
// On 64-bit architectures with neither a native clz instruction nor a native
|
||||||
|
// ctz instruction, gcc resolves __builtin_ctz to __ctzdi2 rather than
|
||||||
|
// __ctzsi2, leading to infinite recursion.
|
||||||
|
#define __builtin_ctz(a) __ctzsi2(a)
|
||||||
|
extern int __ctzsi2(si_int);
|
||||||
|
#endif
|
||||||
|
|
||||||
COMPILER_RT_ABI si_int
|
// Precondition: a != 0
|
||||||
__ctzdi2(di_int a)
|
|
||||||
{
|
COMPILER_RT_ABI int __ctzdi2(di_int a) {
|
||||||
dwords x;
|
dwords x;
|
||||||
x.all = a;
|
x.all = a;
|
||||||
const si_int f = -(x.s.low == 0);
|
const si_int f = -(x.s.low == 0);
|
||||||
return __builtin_ctz((x.s.high & f) | (x.s.low & ~f)) +
|
return ctzsi((x.s.high & f) | (x.s.low & ~f)) +
|
||||||
(f & ((si_int)(sizeof(si_int) * CHAR_BIT)));
|
(f & ((si_int)(sizeof(si_int) * CHAR_BIT)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,22 @@
|
||||||
/* ===-- divdi3.c - Implement __divdi3 -------------------------------------===
|
//===-- divdi3.c - Implement __divdi3 -------------------------------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file implements __divdi3 for the compiler_rt library.
|
||||||
* This file implements __divdi3 for the compiler_rt library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "int_lib.h"
|
#include "int_lib.h"
|
||||||
|
|
||||||
/* Returns: a / b */
|
// Returns: a / b
|
||||||
|
|
||||||
COMPILER_RT_ABI di_int
|
#define fixint_t di_int
|
||||||
__divdi3(di_int a, di_int b)
|
#define fixuint_t du_int
|
||||||
{
|
#define COMPUTE_UDIV(a, b) __udivmoddi4((a), (b), (du_int *)0)
|
||||||
const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1;
|
#include "int_div_impl.inc"
|
||||||
di_int s_a = a >> bits_in_dword_m1; /* s_a = a < 0 ? -1 : 0 */
|
|
||||||
di_int s_b = b >> bits_in_dword_m1; /* s_b = b < 0 ? -1 : 0 */
|
COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b) { return __divXi3(a, b); }
|
||||||
a = (a ^ s_a) - s_a; /* negate if s_a == -1 */
|
|
||||||
b = (b ^ s_b) - s_b; /* negate if s_b == -1 */
|
|
||||||
s_a ^= s_b; /*sign of quotient */
|
|
||||||
return (__udivmoddi4(a, b, (du_int*)0) ^ s_a) - s_a; /* negate if s_a == -1 */
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +1,28 @@
|
||||||
/*===-- divmoddi4.c - Implement __divmoddi4 --------------------------------===
|
//===-- divmoddi4.c - Implement __divmoddi4 -------------------------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file implements __divmoddi4 for the compiler_rt library.
|
||||||
* This file implements __divmoddi4 for the compiler_rt library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "int_lib.h"
|
#include "int_lib.h"
|
||||||
|
|
||||||
/* Returns: a / b, *rem = a % b */
|
// Returns: a / b, *rem = a % b
|
||||||
|
|
||||||
COMPILER_RT_ABI di_int
|
COMPILER_RT_ABI di_int __divmoddi4(di_int a, di_int b, di_int *rem) {
|
||||||
__divmoddi4(di_int a, di_int b, di_int* rem)
|
const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1;
|
||||||
{
|
di_int s_a = a >> bits_in_dword_m1; // s_a = a < 0 ? -1 : 0
|
||||||
di_int d = __divdi3(a,b);
|
di_int s_b = b >> bits_in_dword_m1; // s_b = b < 0 ? -1 : 0
|
||||||
*rem = a - (d*b);
|
a = (a ^ s_a) - s_a; // negate if s_a == -1
|
||||||
return d;
|
b = (b ^ s_b) - s_b; // negate if s_b == -1
|
||||||
|
s_b ^= s_a; // sign of quotient
|
||||||
|
du_int r;
|
||||||
|
di_int q = (__udivmoddi4(a, b, &r) ^ s_b) - s_b; // negate if s_b == -1
|
||||||
|
*rem = (r ^ s_a) - s_a; // negate if s_a == -1
|
||||||
|
return q;
|
||||||
}
|
}
|
||||||
|
|
95
lib/compiler-rt/builtins/int_div_impl.inc
Normal file
95
lib/compiler-rt/builtins/int_div_impl.inc
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
//===-- int_div_impl.inc - Integer division ---------------------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Helpers used by __udivsi3, __umodsi3, __udivdi3, and __umodsi3.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#define clz(a) (sizeof(a) == sizeof(unsigned long long) ? __builtin_clzll(a) : clzsi(a))
|
||||||
|
|
||||||
|
// Adapted from Figure 3-40 of The PowerPC Compiler Writer's Guide
|
||||||
|
static __inline fixuint_t __udivXi3(fixuint_t n, fixuint_t d) {
|
||||||
|
const unsigned N = sizeof(fixuint_t) * CHAR_BIT;
|
||||||
|
// d == 0 cases are unspecified.
|
||||||
|
unsigned sr = (d ? clz(d) : N) - (n ? clz(n) : N);
|
||||||
|
// 0 <= sr <= N - 1 or sr is very large.
|
||||||
|
if (sr > N - 1) // n < d
|
||||||
|
return 0;
|
||||||
|
if (sr == N - 1) // d == 1
|
||||||
|
return n;
|
||||||
|
++sr;
|
||||||
|
// 1 <= sr <= N - 1. Shifts do not trigger UB.
|
||||||
|
fixuint_t r = n >> sr;
|
||||||
|
n <<= N - sr;
|
||||||
|
fixuint_t carry = 0;
|
||||||
|
for (; sr > 0; --sr) {
|
||||||
|
r = (r << 1) | (n >> (N - 1));
|
||||||
|
n = (n << 1) | carry;
|
||||||
|
// Branch-less version of:
|
||||||
|
// carry = 0;
|
||||||
|
// if (r >= d) r -= d, carry = 1;
|
||||||
|
const fixint_t s = (fixint_t)(d - r - 1) >> (N - 1);
|
||||||
|
carry = s & 1;
|
||||||
|
r -= d & s;
|
||||||
|
}
|
||||||
|
n = (n << 1) | carry;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mostly identical to __udivXi3 but the return values are different.
|
||||||
|
static __inline fixuint_t __umodXi3(fixuint_t n, fixuint_t d) {
|
||||||
|
const unsigned N = sizeof(fixuint_t) * CHAR_BIT;
|
||||||
|
// d == 0 cases are unspecified.
|
||||||
|
unsigned sr = (d ? clz(d) : N) - (n ? clz(n) : N);
|
||||||
|
// 0 <= sr <= N - 1 or sr is very large.
|
||||||
|
if (sr > N - 1) // n < d
|
||||||
|
return n;
|
||||||
|
if (sr == N - 1) // d == 1
|
||||||
|
return 0;
|
||||||
|
++sr;
|
||||||
|
// 1 <= sr <= N - 1. Shifts do not trigger UB.
|
||||||
|
fixuint_t r = n >> sr;
|
||||||
|
n <<= N - sr;
|
||||||
|
fixuint_t carry = 0;
|
||||||
|
for (; sr > 0; --sr) {
|
||||||
|
r = (r << 1) | (n >> (N - 1));
|
||||||
|
n = (n << 1) | carry;
|
||||||
|
// Branch-less version of:
|
||||||
|
// carry = 0;
|
||||||
|
// if (r >= d) r -= d, carry = 1;
|
||||||
|
const fixint_t s = (fixint_t)(d - r - 1) >> (N - 1);
|
||||||
|
carry = s & 1;
|
||||||
|
r -= d & s;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef COMPUTE_UDIV
|
||||||
|
static __inline fixint_t __divXi3(fixint_t a, fixint_t b) {
|
||||||
|
const int N = (int)(sizeof(fixint_t) * CHAR_BIT) - 1;
|
||||||
|
fixint_t s_a = a >> N; // s_a = a < 0 ? -1 : 0
|
||||||
|
fixint_t s_b = b >> N; // s_b = b < 0 ? -1 : 0
|
||||||
|
fixuint_t a_u = (fixuint_t)(a ^ s_a) + (-s_a); // negate if s_a == -1
|
||||||
|
fixuint_t b_u = (fixuint_t)(b ^ s_b) + (-s_b); // negate if s_b == -1
|
||||||
|
s_a ^= s_b; // sign of quotient
|
||||||
|
return (COMPUTE_UDIV(a_u, b_u) ^ s_a) + (-s_a); // negate if s_a == -1
|
||||||
|
}
|
||||||
|
#endif // COMPUTE_UDIV
|
||||||
|
|
||||||
|
#ifdef ASSIGN_UMOD
|
||||||
|
static __inline fixint_t __modXi3(fixint_t a, fixint_t b) {
|
||||||
|
const int N = (int)(sizeof(fixint_t) * CHAR_BIT) - 1;
|
||||||
|
fixint_t s = b >> N; // s = b < 0 ? -1 : 0
|
||||||
|
fixuint_t b_u = (fixuint_t)(b ^ s) + (-s); // negate if s == -1
|
||||||
|
s = a >> N; // s = a < 0 ? -1 : 0
|
||||||
|
fixuint_t a_u = (fixuint_t)(a ^ s) + (-s); // negate if s == -1
|
||||||
|
fixuint_t res;
|
||||||
|
ASSIGN_UMOD(res, a_u, b_u);
|
||||||
|
return (res ^ s) + (-s); // negate if s == -1
|
||||||
|
}
|
||||||
|
#endif // ASSIGN_UMOD
|
|
@ -1,51 +1,49 @@
|
||||||
/* ===-- int_endianness.h - configuration header for compiler-rt ------------===
|
//===-- int_endianness.h - configuration header for compiler-rt -----------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file is a configuration header for compiler-rt.
|
||||||
* This file is a configuration header for compiler-rt.
|
// This file is not part of the interface of this library.
|
||||||
* This file is not part of the interface of this library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INT_ENDIANNESS_H
|
#ifndef INT_ENDIANNESS_H
|
||||||
#define INT_ENDIANNESS_H
|
#define INT_ENDIANNESS_H
|
||||||
|
|
||||||
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
|
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
|
||||||
defined(__ORDER_LITTLE_ENDIAN__)
|
defined(__ORDER_LITTLE_ENDIAN__)
|
||||||
|
|
||||||
/* Clang and GCC provide built-in endianness definitions. */
|
// Clang and GCC provide built-in endianness definitions.
|
||||||
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
#define _YUGA_LITTLE_ENDIAN 0
|
#define _YUGA_LITTLE_ENDIAN 0
|
||||||
#define _YUGA_BIG_ENDIAN 1
|
#define _YUGA_BIG_ENDIAN 1
|
||||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
#define _YUGA_LITTLE_ENDIAN 1
|
#define _YUGA_LITTLE_ENDIAN 1
|
||||||
#define _YUGA_BIG_ENDIAN 0
|
#define _YUGA_BIG_ENDIAN 0
|
||||||
#endif /* __BYTE_ORDER__ */
|
#endif // __BYTE_ORDER__
|
||||||
|
|
||||||
#else /* Compilers other than Clang or GCC. */
|
#else // Compilers other than Clang or GCC.
|
||||||
|
|
||||||
#if defined(__SVR4) && defined(__sun)
|
#if defined(__SVR4) && defined(__sun)
|
||||||
#include <sys/byteorder.h>
|
#include <sys/byteorder.h>
|
||||||
|
|
||||||
#if defined(_BIG_ENDIAN)
|
#if defined(_BIG_ENDIAN)
|
||||||
#define _YUGA_LITTLE_ENDIAN 0
|
#define _YUGA_LITTLE_ENDIAN 0
|
||||||
#define _YUGA_BIG_ENDIAN 1
|
#define _YUGA_BIG_ENDIAN 1
|
||||||
#elif defined(_LITTLE_ENDIAN)
|
#elif defined(_LITTLE_ENDIAN)
|
||||||
#define _YUGA_LITTLE_ENDIAN 1
|
#define _YUGA_LITTLE_ENDIAN 1
|
||||||
#define _YUGA_BIG_ENDIAN 0
|
#define _YUGA_BIG_ENDIAN 0
|
||||||
#else /* !_LITTLE_ENDIAN */
|
#else // !_LITTLE_ENDIAN
|
||||||
#error "unknown endianness"
|
#error "unknown endianness"
|
||||||
#endif /* !_LITTLE_ENDIAN */
|
#endif // !_LITTLE_ENDIAN
|
||||||
|
|
||||||
#endif /* Solaris and AuroraUX. */
|
#endif // Solaris
|
||||||
|
|
||||||
/* .. */
|
// ..
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
|
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
|
||||||
defined(__minix)
|
defined(__minix)
|
||||||
|
@ -53,64 +51,64 @@
|
||||||
|
|
||||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||||
#define _YUGA_LITTLE_ENDIAN 0
|
#define _YUGA_LITTLE_ENDIAN 0
|
||||||
#define _YUGA_BIG_ENDIAN 1
|
#define _YUGA_BIG_ENDIAN 1
|
||||||
#elif _BYTE_ORDER == _LITTLE_ENDIAN
|
#elif _BYTE_ORDER == _LITTLE_ENDIAN
|
||||||
#define _YUGA_LITTLE_ENDIAN 1
|
#define _YUGA_LITTLE_ENDIAN 1
|
||||||
#define _YUGA_BIG_ENDIAN 0
|
#define _YUGA_BIG_ENDIAN 0
|
||||||
#endif /* _BYTE_ORDER */
|
#endif // _BYTE_ORDER
|
||||||
|
|
||||||
#endif /* *BSD */
|
#endif // *BSD
|
||||||
|
|
||||||
#if defined(__OpenBSD__) || defined(__Bitrig__)
|
#if defined(__OpenBSD__)
|
||||||
#include <machine/endian.h>
|
#include <machine/endian.h>
|
||||||
|
|
||||||
#if _BYTE_ORDER == _BIG_ENDIAN
|
#if _BYTE_ORDER == _BIG_ENDIAN
|
||||||
#define _YUGA_LITTLE_ENDIAN 0
|
#define _YUGA_LITTLE_ENDIAN 0
|
||||||
#define _YUGA_BIG_ENDIAN 1
|
#define _YUGA_BIG_ENDIAN 1
|
||||||
#elif _BYTE_ORDER == _LITTLE_ENDIAN
|
#elif _BYTE_ORDER == _LITTLE_ENDIAN
|
||||||
#define _YUGA_LITTLE_ENDIAN 1
|
#define _YUGA_LITTLE_ENDIAN 1
|
||||||
#define _YUGA_BIG_ENDIAN 0
|
#define _YUGA_BIG_ENDIAN 0
|
||||||
#endif /* _BYTE_ORDER */
|
#endif // _BYTE_ORDER
|
||||||
|
|
||||||
#endif /* OpenBSD and Bitrig. */
|
#endif // OpenBSD
|
||||||
|
|
||||||
/* .. */
|
// ..
|
||||||
|
|
||||||
/* Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the
|
// Mac OSX has __BIG_ENDIAN__ or __LITTLE_ENDIAN__ automatically set by the
|
||||||
* compiler (at least with GCC) */
|
// compiler (at least with GCC)
|
||||||
#if defined(__APPLE__) || defined(__ellcc__ )
|
#if defined(__APPLE__) || defined(__ellcc__)
|
||||||
|
|
||||||
#ifdef __BIG_ENDIAN__
|
#ifdef __BIG_ENDIAN__
|
||||||
#if __BIG_ENDIAN__
|
#if __BIG_ENDIAN__
|
||||||
#define _YUGA_LITTLE_ENDIAN 0
|
#define _YUGA_LITTLE_ENDIAN 0
|
||||||
#define _YUGA_BIG_ENDIAN 1
|
#define _YUGA_BIG_ENDIAN 1
|
||||||
#endif
|
#endif
|
||||||
#endif /* __BIG_ENDIAN__ */
|
#endif // __BIG_ENDIAN__
|
||||||
|
|
||||||
#ifdef __LITTLE_ENDIAN__
|
#ifdef __LITTLE_ENDIAN__
|
||||||
#if __LITTLE_ENDIAN__
|
#if __LITTLE_ENDIAN__
|
||||||
#define _YUGA_LITTLE_ENDIAN 1
|
#define _YUGA_LITTLE_ENDIAN 1
|
||||||
#define _YUGA_BIG_ENDIAN 0
|
#define _YUGA_BIG_ENDIAN 0
|
||||||
#endif
|
#endif
|
||||||
#endif /* __LITTLE_ENDIAN__ */
|
#endif // __LITTLE_ENDIAN__
|
||||||
|
|
||||||
#endif /* Mac OSX */
|
#endif // Mac OSX
|
||||||
|
|
||||||
/* .. */
|
// ..
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
#define _YUGA_LITTLE_ENDIAN 1
|
#define _YUGA_LITTLE_ENDIAN 1
|
||||||
#define _YUGA_BIG_ENDIAN 0
|
#define _YUGA_BIG_ENDIAN 0
|
||||||
|
|
||||||
#endif /* Windows */
|
#endif // Windows
|
||||||
|
|
||||||
#endif /* Clang or GCC. */
|
#endif // Clang or GCC.
|
||||||
|
|
||||||
/* . */
|
// .
|
||||||
|
|
||||||
#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
|
#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
|
||||||
#error Unable to determine endian
|
#error Unable to determine endian
|
||||||
#endif /* Check we found an endianness correctly. */
|
#endif // Check we found an endianness correctly.
|
||||||
|
|
||||||
#endif /* INT_ENDIANNESS_H */
|
#endif // INT_ENDIANNESS_H
|
||||||
|
|
|
@ -1,49 +1,33 @@
|
||||||
/* ===-- int_lib.h - configuration header for compiler-rt -----------------===
|
//===-- int_lib.h - configuration header for compiler-rt -----------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file is a configuration header for compiler-rt.
|
||||||
* This file is a configuration header for compiler-rt.
|
// This file is not part of the interface of this library.
|
||||||
* This file is not part of the interface of this library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Portions copyright (c) 2017-2018, ARM Limited and Contributors.
|
|
||||||
* All rights reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INT_LIB_H
|
#ifndef INT_LIB_H
|
||||||
#define INT_LIB_H
|
#define INT_LIB_H
|
||||||
|
|
||||||
/* Assumption: Signed integral is 2's complement. */
|
// Assumption: Signed integral is 2's complement.
|
||||||
/* Assumption: Right shift of signed negative is arithmetic shift. */
|
// Assumption: Right shift of signed negative is arithmetic shift.
|
||||||
/* Assumption: Endianness is little or big (not mixed). */
|
// Assumption: Endianness is little or big (not mixed).
|
||||||
|
|
||||||
#if defined(__ELF__)
|
// ABI macro definitions
|
||||||
#define FNALIAS(alias_name, original_name) \
|
|
||||||
void alias_name() __attribute__((__alias__(#original_name)))
|
|
||||||
#define COMPILER_RT_ALIAS(aliasee) __attribute__((__alias__(#aliasee)))
|
|
||||||
#else
|
|
||||||
#define FNALIAS(alias, name) _Pragma("GCC error(\"alias unsupported on this file format\")")
|
|
||||||
#define COMPILER_RT_ALIAS(aliasee) _Pragma("GCC error(\"alias unsupported on this file format\")")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ABI macro definitions */
|
|
||||||
|
|
||||||
#if __ARM_EABI__
|
#if __ARM_EABI__
|
||||||
# ifdef COMPILER_RT_ARMHF_TARGET
|
#ifdef COMPILER_RT_ARMHF_TARGET
|
||||||
# define COMPILER_RT_ABI
|
#define COMPILER_RT_ABI
|
||||||
# else
|
|
||||||
# define COMPILER_RT_ABI __attribute__((__pcs__("aapcs")))
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# define COMPILER_RT_ABI
|
#define COMPILER_RT_ABI __attribute__((__pcs__("aapcs")))
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define COMPILER_RT_ABI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AEABI_RTABI __attribute__((__pcs__("aapcs")))
|
#define AEABI_RTABI __attribute__((__pcs__("aapcs")))
|
||||||
|
@ -60,42 +44,89 @@
|
||||||
#define UNUSED __attribute__((unused))
|
#define UNUSED __attribute__((unused))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
#define STR(a) #a
|
||||||
* Kernel and boot environment can't use normal headers,
|
#define XSTR(a) STR(a)
|
||||||
* so use the equivalent system headers.
|
#define SYMBOL_NAME(name) XSTR(__USER_LABEL_PREFIX__) #name
|
||||||
*/
|
|
||||||
# include <limits.h>
|
|
||||||
# include <stdint.h>
|
|
||||||
|
|
||||||
/* Include the commonly used internal type definitions. */
|
#if defined(__ELF__) || defined(__MINGW32__) || defined(__wasm__) || \
|
||||||
|
defined(_AIX)
|
||||||
|
#define COMPILER_RT_ALIAS(name, aliasname) \
|
||||||
|
COMPILER_RT_ABI __typeof(name) aliasname __attribute__((__alias__(#name)));
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#if defined(VISIBILITY_HIDDEN)
|
||||||
|
#define COMPILER_RT_ALIAS_VISIBILITY(name) \
|
||||||
|
__asm__(".private_extern " SYMBOL_NAME(name));
|
||||||
|
#else
|
||||||
|
#define COMPILER_RT_ALIAS_VISIBILITY(name)
|
||||||
|
#endif
|
||||||
|
#define COMPILER_RT_ALIAS(name, aliasname) \
|
||||||
|
__asm__(".globl " SYMBOL_NAME(aliasname)); \
|
||||||
|
COMPILER_RT_ALIAS_VISIBILITY(aliasname) \
|
||||||
|
__asm__(SYMBOL_NAME(aliasname) " = " SYMBOL_NAME(name)); \
|
||||||
|
COMPILER_RT_ABI __typeof(name) aliasname;
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
#define COMPILER_RT_ALIAS(name, aliasname)
|
||||||
|
#else
|
||||||
|
#error Unsupported target
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__FreeBSD__) || defined(__NetBSD__)) && \
|
||||||
|
(defined(_KERNEL) || defined(_STANDALONE))
|
||||||
|
//
|
||||||
|
// Kernel and boot environment can't use normal headers,
|
||||||
|
// so use the equivalent system headers.
|
||||||
|
// NB: FreeBSD (and OpenBSD) deprecate machine/limits.h in
|
||||||
|
// favour of sys/limits.h, so prefer the former, but fall
|
||||||
|
// back on the latter if not available since NetBSD only has
|
||||||
|
// the latter.
|
||||||
|
//
|
||||||
|
#if defined(__has_include) && __has_include(<sys/limits.h>)
|
||||||
|
#include <sys/limits.h>
|
||||||
|
#else
|
||||||
|
#include <machine/limits.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/stdint.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#else
|
||||||
|
// Include the standard compiler builtin headers we use functionality from.
|
||||||
|
#include <float.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Include the commonly used internal type definitions.
|
||||||
#include "int_types.h"
|
#include "int_types.h"
|
||||||
|
|
||||||
COMPILER_RT_ABI si_int __paritysi2(si_int a);
|
// Include internal utility function declarations.
|
||||||
COMPILER_RT_ABI si_int __paritydi2(di_int a);
|
#include "int_util.h"
|
||||||
|
|
||||||
|
COMPILER_RT_ABI int __paritysi2(si_int a);
|
||||||
|
COMPILER_RT_ABI int __paritydi2(di_int a);
|
||||||
|
|
||||||
COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b);
|
COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b);
|
||||||
COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
|
COMPILER_RT_ABI si_int __divsi3(si_int a, si_int b);
|
||||||
COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d);
|
COMPILER_RT_ABI su_int __udivsi3(su_int n, su_int d);
|
||||||
|
|
||||||
COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem);
|
COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int *rem);
|
||||||
COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int* rem);
|
COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int *rem);
|
||||||
#ifdef CRT_HAS_128BIT
|
#ifdef CRT_HAS_128BIT
|
||||||
COMPILER_RT_ABI si_int __clzti2(ti_int a);
|
COMPILER_RT_ABI int __clzti2(ti_int a);
|
||||||
COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int* rem);
|
COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int *rem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Definitions for builtins unavailable on MSVC */
|
// Definitions for builtins unavailable on MSVC
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
|
||||||
uint32_t __inline __builtin_ctz(uint32_t value) {
|
int __inline __builtin_ctz(uint32_t value) {
|
||||||
unsigned long trailing_zero = 0;
|
unsigned long trailing_zero = 0;
|
||||||
if (_BitScanForward(&trailing_zero, value))
|
if (_BitScanForward(&trailing_zero, value))
|
||||||
return trailing_zero;
|
return trailing_zero;
|
||||||
return 32;
|
return 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t __inline __builtin_clz(uint32_t value) {
|
int __inline __builtin_clz(uint32_t value) {
|
||||||
unsigned long leading_zero = 0;
|
unsigned long leading_zero = 0;
|
||||||
if (_BitScanReverse(&leading_zero, value))
|
if (_BitScanReverse(&leading_zero, value))
|
||||||
return 31 - leading_zero;
|
return 31 - leading_zero;
|
||||||
|
@ -103,14 +134,14 @@ uint32_t __inline __builtin_clz(uint32_t value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_M_ARM) || defined(_M_X64)
|
#if defined(_M_ARM) || defined(_M_X64)
|
||||||
uint32_t __inline __builtin_clzll(uint64_t value) {
|
int __inline __builtin_clzll(uint64_t value) {
|
||||||
unsigned long leading_zero = 0;
|
unsigned long leading_zero = 0;
|
||||||
if (_BitScanReverse64(&leading_zero, value))
|
if (_BitScanReverse64(&leading_zero, value))
|
||||||
return 63 - leading_zero;
|
return 63 - leading_zero;
|
||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
uint32_t __inline __builtin_clzll(uint64_t value) {
|
int __inline __builtin_clzll(uint64_t value) {
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
return 64;
|
return 64;
|
||||||
uint32_t msh = (uint32_t)(value >> 32);
|
uint32_t msh = (uint32_t)(value >> 32);
|
||||||
|
@ -122,6 +153,19 @@ uint32_t __inline __builtin_clzll(uint64_t value) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define __builtin_clzl __builtin_clzll
|
#define __builtin_clzl __builtin_clzll
|
||||||
#endif /* defined(_MSC_VER) && !defined(__clang__) */
|
|
||||||
|
|
||||||
#endif /* INT_LIB_H */
|
bool __inline __builtin_sadd_overflow(int x, int y, int *result) {
|
||||||
|
if ((x < 0) != (y < 0)) {
|
||||||
|
*result = x + y;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int tmp = (unsigned int)x + (unsigned int)y;
|
||||||
|
if ((tmp < 0) != (x < 0))
|
||||||
|
return true;
|
||||||
|
*result = tmp;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(_MSC_VER) && !defined(__clang__)
|
||||||
|
|
||||||
|
#endif // INT_LIB_H
|
||||||
|
|
|
@ -1,34 +1,31 @@
|
||||||
/* ===-- int_math.h - internal math inlines ---------------------------------===
|
//===-- int_math.h - internal math inlines --------------------------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===-----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file is not part of the interface of this library.
|
||||||
* This file is not part of the interface of this library.
|
//
|
||||||
*
|
// This file defines substitutes for the libm functions used in some of the
|
||||||
* This file defines substitutes for the libm functions used in some of the
|
// compiler-rt implementations, defined in such a way that there is not a direct
|
||||||
* compiler-rt implementations, defined in such a way that there is not a direct
|
// dependency on libm or math.h. Instead, we use the compiler builtin versions
|
||||||
* dependency on libm or math.h. Instead, we use the compiler builtin versions
|
// where available. This reduces our dependencies on the system SDK by foisting
|
||||||
* where available. This reduces our dependencies on the system SDK by foisting
|
// the responsibility onto the compiler.
|
||||||
* the responsibility onto the compiler.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===-----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INT_MATH_H
|
#ifndef INT_MATH_H
|
||||||
#define INT_MATH_H
|
#define INT_MATH_H
|
||||||
|
|
||||||
#ifndef __has_builtin
|
#ifndef __has_builtin
|
||||||
# define __has_builtin(x) 0
|
#define __has_builtin(x) 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ymath.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
|
@ -42,24 +39,23 @@
|
||||||
#define crt_isinf(x) !_finite((x))
|
#define crt_isinf(x) !_finite((x))
|
||||||
#define crt_isnan(x) _isnan((x))
|
#define crt_isnan(x) _isnan((x))
|
||||||
#else
|
#else
|
||||||
/* Define crt_isfinite in terms of the builtin if available, otherwise provide
|
// Define crt_isfinite in terms of the builtin if available, otherwise provide
|
||||||
* an alternate version in terms of our other functions. This supports some
|
// an alternate version in terms of our other functions. This supports some
|
||||||
* versions of GCC which didn't have __builtin_isfinite.
|
// versions of GCC which didn't have __builtin_isfinite.
|
||||||
*/
|
|
||||||
#if __has_builtin(__builtin_isfinite)
|
#if __has_builtin(__builtin_isfinite)
|
||||||
# define crt_isfinite(x) __builtin_isfinite((x))
|
#define crt_isfinite(x) __builtin_isfinite((x))
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
# define crt_isfinite(x) \
|
#define crt_isfinite(x) \
|
||||||
__extension__(({ \
|
__extension__(({ \
|
||||||
__typeof((x)) x_ = (x); \
|
__typeof((x)) x_ = (x); \
|
||||||
!crt_isinf(x_) && !crt_isnan(x_); \
|
!crt_isinf(x_) && !crt_isnan(x_); \
|
||||||
}))
|
}))
|
||||||
#else
|
#else
|
||||||
# error "Do not know how to check for infinity"
|
#error "Do not know how to check for infinity"
|
||||||
#endif /* __has_builtin(__builtin_isfinite) */
|
#endif // __has_builtin(__builtin_isfinite)
|
||||||
#define crt_isinf(x) __builtin_isinf((x))
|
#define crt_isinf(x) __builtin_isinf((x))
|
||||||
#define crt_isnan(x) __builtin_isnan((x))
|
#define crt_isnan(x) __builtin_isnan((x))
|
||||||
#endif /* _MSC_VER */
|
#endif // _MSC_VER
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#define crt_copysign(x, y) copysign((x), (y))
|
#define crt_copysign(x, y) copysign((x), (y))
|
||||||
|
@ -82,33 +78,21 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#define crt_fmax(x, y) __max((x), (y))
|
|
||||||
#define crt_fmaxf(x, y) __max((x), (y))
|
|
||||||
#define crt_fmaxl(x, y) __max((x), (y))
|
#define crt_fmaxl(x, y) __max((x), (y))
|
||||||
#else
|
#else
|
||||||
#define crt_fmax(x, y) __builtin_fmax((x), (y))
|
|
||||||
#define crt_fmaxf(x, y) __builtin_fmaxf((x), (y))
|
|
||||||
#define crt_fmaxl(x, y) __builtin_fmaxl((x), (y))
|
#define crt_fmaxl(x, y) __builtin_fmaxl((x), (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#define crt_logb(x) logb((x))
|
|
||||||
#define crt_logbf(x) logbf((x))
|
|
||||||
#define crt_logbl(x) logbl((x))
|
#define crt_logbl(x) logbl((x))
|
||||||
#else
|
#else
|
||||||
#define crt_logb(x) __builtin_logb((x))
|
|
||||||
#define crt_logbf(x) __builtin_logbf((x))
|
|
||||||
#define crt_logbl(x) __builtin_logbl((x))
|
#define crt_logbl(x) __builtin_logbl((x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(__clang__)
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
#define crt_scalbn(x, y) scalbn((x), (y))
|
|
||||||
#define crt_scalbnf(x, y) scalbnf((x), (y))
|
|
||||||
#define crt_scalbnl(x, y) scalbnl((x), (y))
|
#define crt_scalbnl(x, y) scalbnl((x), (y))
|
||||||
#else
|
#else
|
||||||
#define crt_scalbn(x, y) __builtin_scalbn((x), (y))
|
|
||||||
#define crt_scalbnf(x, y) __builtin_scalbnf((x), (y))
|
|
||||||
#define crt_scalbnl(x, y) __builtin_scalbnl((x), (y))
|
#define crt_scalbnl(x, y) __builtin_scalbnl((x), (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* INT_MATH_H */
|
#endif // INT_MATH_H
|
||||||
|
|
|
@ -1,148 +1,174 @@
|
||||||
/* ===-- int_lib.h - configuration header for compiler-rt -----------------===
|
//===-- int_lib.h - configuration header for compiler-rt -----------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file is not part of the interface of this library.
|
||||||
* This file is not part of the interface of this library.
|
//
|
||||||
*
|
// This file defines various standard types, most importantly a number of unions
|
||||||
* This file defines various standard types, most importantly a number of unions
|
// used to access parts of larger types.
|
||||||
* used to access parts of larger types.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INT_TYPES_H
|
#ifndef INT_TYPES_H
|
||||||
#define INT_TYPES_H
|
#define INT_TYPES_H
|
||||||
|
|
||||||
#include "int_endianness.h"
|
#include "int_endianness.h"
|
||||||
|
|
||||||
/* si_int is defined in Linux sysroot's asm-generic/siginfo.h */
|
// si_int is defined in Linux sysroot's asm-generic/siginfo.h
|
||||||
#ifdef si_int
|
#ifdef si_int
|
||||||
#undef si_int
|
#undef si_int
|
||||||
#endif
|
#endif
|
||||||
typedef int si_int;
|
typedef int32_t si_int;
|
||||||
typedef unsigned su_int;
|
typedef uint32_t su_int;
|
||||||
|
#if UINT_MAX == 0xFFFFFFFF
|
||||||
typedef long long di_int;
|
#define clzsi __builtin_clz
|
||||||
typedef unsigned long long du_int;
|
#define ctzsi __builtin_ctz
|
||||||
|
#elif ULONG_MAX == 0xFFFFFFFF
|
||||||
typedef union
|
#define clzsi __builtin_clzl
|
||||||
{
|
#define ctzsi __builtin_ctzl
|
||||||
di_int all;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
#if _YUGA_LITTLE_ENDIAN
|
|
||||||
su_int low;
|
|
||||||
si_int high;
|
|
||||||
#else
|
#else
|
||||||
si_int high;
|
#error could not determine appropriate clzsi macro for this system
|
||||||
su_int low;
|
#endif
|
||||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
|
||||||
}s;
|
typedef int64_t di_int;
|
||||||
|
typedef uint64_t du_int;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
di_int all;
|
||||||
|
struct {
|
||||||
|
#if _YUGA_LITTLE_ENDIAN
|
||||||
|
su_int low;
|
||||||
|
si_int high;
|
||||||
|
#else
|
||||||
|
si_int high;
|
||||||
|
su_int low;
|
||||||
|
#endif // _YUGA_LITTLE_ENDIAN
|
||||||
|
} s;
|
||||||
} dwords;
|
} dwords;
|
||||||
|
|
||||||
typedef union
|
typedef union {
|
||||||
{
|
du_int all;
|
||||||
du_int all;
|
struct {
|
||||||
struct
|
|
||||||
{
|
|
||||||
#if _YUGA_LITTLE_ENDIAN
|
#if _YUGA_LITTLE_ENDIAN
|
||||||
su_int low;
|
su_int low;
|
||||||
su_int high;
|
su_int high;
|
||||||
#else
|
#else
|
||||||
su_int high;
|
su_int high;
|
||||||
su_int low;
|
su_int low;
|
||||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
#endif // _YUGA_LITTLE_ENDIAN
|
||||||
}s;
|
} s;
|
||||||
} udwords;
|
} udwords;
|
||||||
|
|
||||||
/* MIPS64 issue: PR 20098 */
|
#if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \
|
||||||
#if (defined(__LP64__) || defined(__wasm__)) && \
|
defined(__riscv) || defined(_WIN64)
|
||||||
!(defined(__mips__) && defined(__clang__))
|
|
||||||
#define CRT_HAS_128BIT
|
#define CRT_HAS_128BIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CRT_HAS_128BIT
|
// MSVC doesn't have a working 128bit integer type. Users should really compile
|
||||||
typedef int ti_int __attribute__ ((mode (TI)));
|
// compiler-rt with clang, but if they happen to be doing a standalone build for
|
||||||
typedef unsigned tu_int __attribute__ ((mode (TI)));
|
// asan or something else, disable the 128 bit parts so things sort of work.
|
||||||
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
|
#undef CRT_HAS_128BIT
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef union
|
#ifdef CRT_HAS_128BIT
|
||||||
{
|
typedef int ti_int __attribute__((mode(TI)));
|
||||||
ti_int all;
|
typedef unsigned tu_int __attribute__((mode(TI)));
|
||||||
struct
|
|
||||||
{
|
typedef union {
|
||||||
|
ti_int all;
|
||||||
|
struct {
|
||||||
#if _YUGA_LITTLE_ENDIAN
|
#if _YUGA_LITTLE_ENDIAN
|
||||||
du_int low;
|
du_int low;
|
||||||
di_int high;
|
di_int high;
|
||||||
#else
|
#else
|
||||||
di_int high;
|
di_int high;
|
||||||
du_int low;
|
du_int low;
|
||||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
#endif // _YUGA_LITTLE_ENDIAN
|
||||||
}s;
|
} s;
|
||||||
} twords;
|
} twords;
|
||||||
|
|
||||||
typedef union
|
typedef union {
|
||||||
{
|
tu_int all;
|
||||||
tu_int all;
|
struct {
|
||||||
struct
|
|
||||||
{
|
|
||||||
#if _YUGA_LITTLE_ENDIAN
|
#if _YUGA_LITTLE_ENDIAN
|
||||||
du_int low;
|
du_int low;
|
||||||
du_int high;
|
du_int high;
|
||||||
#else
|
#else
|
||||||
du_int high;
|
du_int high;
|
||||||
du_int low;
|
du_int low;
|
||||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
#endif // _YUGA_LITTLE_ENDIAN
|
||||||
}s;
|
} s;
|
||||||
} utwords;
|
} utwords;
|
||||||
|
|
||||||
static __inline ti_int make_ti(di_int h, di_int l) {
|
static __inline ti_int make_ti(di_int h, di_int l) {
|
||||||
twords r;
|
twords r;
|
||||||
r.s.high = h;
|
r.s.high = h;
|
||||||
r.s.low = l;
|
r.s.low = l;
|
||||||
return r.all;
|
return r.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline tu_int make_tu(du_int h, du_int l) {
|
static __inline tu_int make_tu(du_int h, du_int l) {
|
||||||
utwords r;
|
utwords r;
|
||||||
r.s.high = h;
|
r.s.high = h;
|
||||||
r.s.low = l;
|
r.s.low = l;
|
||||||
return r.all;
|
return r.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CRT_HAS_128BIT */
|
#endif // CRT_HAS_128BIT
|
||||||
|
|
||||||
typedef union
|
// FreeBSD's boot environment does not support using floating-point and poisons
|
||||||
{
|
// the float and double keywords.
|
||||||
su_int u;
|
#if defined(__FreeBSD__) && defined(_STANDALONE)
|
||||||
float f;
|
#define CRT_HAS_FLOATING_POINT 0
|
||||||
|
#else
|
||||||
|
#define CRT_HAS_FLOATING_POINT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CRT_HAS_FLOATING_POINT
|
||||||
|
typedef union {
|
||||||
|
su_int u;
|
||||||
|
float f;
|
||||||
} float_bits;
|
} float_bits;
|
||||||
|
|
||||||
typedef union
|
typedef union {
|
||||||
{
|
udwords u;
|
||||||
udwords u;
|
double f;
|
||||||
double f;
|
|
||||||
} double_bits;
|
} double_bits;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
#if _YUGA_LITTLE_ENDIAN
|
#if _YUGA_LITTLE_ENDIAN
|
||||||
udwords low;
|
udwords low;
|
||||||
udwords high;
|
udwords high;
|
||||||
#else
|
#else
|
||||||
udwords high;
|
udwords high;
|
||||||
udwords low;
|
udwords low;
|
||||||
#endif /* _YUGA_LITTLE_ENDIAN */
|
#endif // _YUGA_LITTLE_ENDIAN
|
||||||
} uqwords;
|
} uqwords;
|
||||||
|
|
||||||
typedef union
|
// Check if the target supports 80 bit extended precision long doubles.
|
||||||
{
|
// Notably, on x86 Windows, MSVC only provides a 64-bit long double, but GCC
|
||||||
uqwords u;
|
// still makes it 80 bits. Clang will match whatever compiler it is trying to
|
||||||
long double f;
|
// be compatible with. On 32-bit x86 Android, long double is 64 bits, while on
|
||||||
|
// x86_64 Android, long double is 128 bits.
|
||||||
|
#if (defined(__i386__) || defined(__x86_64__)) && \
|
||||||
|
!(defined(_MSC_VER) || defined(__ANDROID__))
|
||||||
|
#define HAS_80_BIT_LONG_DOUBLE 1
|
||||||
|
#elif defined(__m68k__) || defined(__ia64__)
|
||||||
|
#define HAS_80_BIT_LONG_DOUBLE 1
|
||||||
|
#else
|
||||||
|
#define HAS_80_BIT_LONG_DOUBLE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CRT_HAS_FLOATING_POINT
|
||||||
|
typedef union {
|
||||||
|
uqwords u;
|
||||||
|
long double f;
|
||||||
} long_double_bits;
|
} long_double_bits;
|
||||||
|
|
||||||
#if __STDC_VERSION__ >= 199901L
|
#if __STDC_VERSION__ >= 199901L
|
||||||
|
@ -153,14 +179,20 @@ typedef long double _Complex Lcomplex;
|
||||||
#define COMPLEX_REAL(x) __real__(x)
|
#define COMPLEX_REAL(x) __real__(x)
|
||||||
#define COMPLEX_IMAGINARY(x) __imag__(x)
|
#define COMPLEX_IMAGINARY(x) __imag__(x)
|
||||||
#else
|
#else
|
||||||
typedef struct { float real, imaginary; } Fcomplex;
|
typedef struct {
|
||||||
|
float real, imaginary;
|
||||||
|
} Fcomplex;
|
||||||
|
|
||||||
typedef struct { double real, imaginary; } Dcomplex;
|
typedef struct {
|
||||||
|
double real, imaginary;
|
||||||
|
} Dcomplex;
|
||||||
|
|
||||||
typedef struct { long double real, imaginary; } Lcomplex;
|
typedef struct {
|
||||||
|
long double real, imaginary;
|
||||||
|
} Lcomplex;
|
||||||
|
|
||||||
#define COMPLEX_REAL(x) (x).real
|
#define COMPLEX_REAL(x) (x).real
|
||||||
#define COMPLEX_IMAGINARY(x) (x).imaginary
|
#define COMPLEX_IMAGINARY(x) (x).imaginary
|
||||||
#endif
|
#endif
|
||||||
#endif /* INT_TYPES_H */
|
#endif
|
||||||
|
#endif // INT_TYPES_H
|
||||||
|
|
47
lib/compiler-rt/builtins/int_util.h
Normal file
47
lib/compiler-rt/builtins/int_util.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
//===-- int_util.h - internal utility functions ---------------------------===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file is not part of the interface of this library.
|
||||||
|
//
|
||||||
|
// This file defines non-inline utilities which are available for use in the
|
||||||
|
// library. The function definitions themselves are all contained in int_util.c
|
||||||
|
// which will always be compiled into any compiler-rt library.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef INT_UTIL_H
|
||||||
|
#define INT_UTIL_H
|
||||||
|
|
||||||
|
/// \brief Trigger a program abort (or panic for kernel code).
|
||||||
|
#define compilerrt_abort() __compilerrt_abort_impl(__FILE__, __LINE__, __func__)
|
||||||
|
|
||||||
|
NORETURN void __compilerrt_abort_impl(const char *file, int line,
|
||||||
|
const char *function);
|
||||||
|
|
||||||
|
#define COMPILE_TIME_ASSERT(expr) COMPILE_TIME_ASSERT1(expr, __COUNTER__)
|
||||||
|
#define COMPILE_TIME_ASSERT1(expr, cnt) COMPILE_TIME_ASSERT2(expr, cnt)
|
||||||
|
#define COMPILE_TIME_ASSERT2(expr, cnt) \
|
||||||
|
typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
|
||||||
|
|
||||||
|
// Force unrolling the code specified to be repeated N times.
|
||||||
|
#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
|
||||||
|
#define REPEAT_1_TIMES(code_to_repeat) code_to_repeat
|
||||||
|
#define REPEAT_2_TIMES(code_to_repeat) \
|
||||||
|
REPEAT_1_TIMES(code_to_repeat) \
|
||||||
|
code_to_repeat
|
||||||
|
#define REPEAT_3_TIMES(code_to_repeat) \
|
||||||
|
REPEAT_2_TIMES(code_to_repeat) \
|
||||||
|
code_to_repeat
|
||||||
|
#define REPEAT_4_TIMES(code_to_repeat) \
|
||||||
|
REPEAT_3_TIMES(code_to_repeat) \
|
||||||
|
code_to_repeat
|
||||||
|
|
||||||
|
#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
|
||||||
|
#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
|
||||||
|
|
||||||
|
#endif // INT_UTIL_H
|
|
@ -1,45 +1,38 @@
|
||||||
/* ===-- lshrdi3.c - Implement __lshrdi3 -----------------------------------===
|
//===-- lshrdi3.c - Implement __lshrdi3 -----------------------------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file implements __lshrdi3 for the compiler_rt library.
|
||||||
* This file implements __lshrdi3 for the compiler_rt library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "int_lib.h"
|
#include "int_lib.h"
|
||||||
|
|
||||||
/* Returns: logical a >> b */
|
// Returns: logical a >> b
|
||||||
|
|
||||||
/* Precondition: 0 <= b < bits_in_dword */
|
// Precondition: 0 <= b < bits_in_dword
|
||||||
|
|
||||||
COMPILER_RT_ABI di_int
|
COMPILER_RT_ABI di_int __lshrdi3(di_int a, int b) {
|
||||||
__lshrdi3(di_int a, si_int b)
|
const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
|
||||||
{
|
udwords input;
|
||||||
const int bits_in_word = (int)(sizeof(si_int) * CHAR_BIT);
|
udwords result;
|
||||||
udwords input;
|
input.all = a;
|
||||||
udwords result;
|
if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ {
|
||||||
input.all = a;
|
result.s.high = 0;
|
||||||
if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */
|
result.s.low = input.s.high >> (b - bits_in_word);
|
||||||
{
|
} else /* 0 <= b < bits_in_word */ {
|
||||||
result.s.high = 0;
|
if (b == 0)
|
||||||
result.s.low = input.s.high >> (b - bits_in_word);
|
return a;
|
||||||
}
|
result.s.high = input.s.high >> b;
|
||||||
else /* 0 <= b < bits_in_word */
|
result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b);
|
||||||
{
|
}
|
||||||
if (b == 0)
|
return result.all;
|
||||||
return a;
|
|
||||||
result.s.high = input.s.high >> b;
|
|
||||||
result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b);
|
|
||||||
}
|
|
||||||
return result.all;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__ARM_EABI__)
|
#if defined(__ARM_EABI__)
|
||||||
AEABI_RTABI di_int __aeabi_llsr(di_int a, si_int b) COMPILER_RT_ALIAS(__lshrdi3);
|
COMPILER_RT_ALIAS(__lshrdi3, __aeabi_llsr)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,36 +1,32 @@
|
||||||
/* ===-- popcountdi2.c - Implement __popcountdi2 ----------------------------===
|
//===-- popcountdi2.c - Implement __popcountdi2 ---------------------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file implements __popcountdi2 for the compiler_rt library.
|
||||||
* This file implements __popcountdi2 for the compiler_rt library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "int_lib.h"
|
#include "int_lib.h"
|
||||||
|
|
||||||
/* Returns: count of 1 bits */
|
// Returns: count of 1 bits
|
||||||
|
|
||||||
COMPILER_RT_ABI si_int
|
COMPILER_RT_ABI int __popcountdi2(di_int a) {
|
||||||
__popcountdi2(di_int a)
|
du_int x2 = (du_int)a;
|
||||||
{
|
x2 = x2 - ((x2 >> 1) & 0x5555555555555555uLL);
|
||||||
du_int x2 = (du_int)a;
|
// Every 2 bits holds the sum of every pair of bits (32)
|
||||||
x2 = x2 - ((x2 >> 1) & 0x5555555555555555uLL);
|
x2 = ((x2 >> 2) & 0x3333333333333333uLL) + (x2 & 0x3333333333333333uLL);
|
||||||
/* Every 2 bits holds the sum of every pair of bits (32) */
|
// Every 4 bits holds the sum of every 4-set of bits (3 significant bits) (16)
|
||||||
x2 = ((x2 >> 2) & 0x3333333333333333uLL) + (x2 & 0x3333333333333333uLL);
|
x2 = (x2 + (x2 >> 4)) & 0x0F0F0F0F0F0F0F0FuLL;
|
||||||
/* Every 4 bits holds the sum of every 4-set of bits (3 significant bits) (16) */
|
// Every 8 bits holds the sum of every 8-set of bits (4 significant bits) (8)
|
||||||
x2 = (x2 + (x2 >> 4)) & 0x0F0F0F0F0F0F0F0FuLL;
|
su_int x = (su_int)(x2 + (x2 >> 32));
|
||||||
/* Every 8 bits holds the sum of every 8-set of bits (4 significant bits) (8) */
|
// The lower 32 bits hold four 16 bit sums (5 significant bits).
|
||||||
su_int x = (su_int)(x2 + (x2 >> 32));
|
// Upper 32 bits are garbage
|
||||||
/* The lower 32 bits hold four 16 bit sums (5 significant bits). */
|
x = x + (x >> 16);
|
||||||
/* Upper 32 bits are garbage */
|
// The lower 16 bits hold two 32 bit sums (6 significant bits).
|
||||||
x = x + (x >> 16);
|
// Upper 16 bits are garbage
|
||||||
/* The lower 16 bits hold two 32 bit sums (6 significant bits). */
|
return (x + (x >> 8)) & 0x0000007F; // (7 significant bits)
|
||||||
/* Upper 16 bits are garbage */
|
|
||||||
return (x + (x >> 8)) & 0x0000007F; /* (7 significant bits) */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,29 @@
|
||||||
/* ===-- popcountsi2.c - Implement __popcountsi2 ---------------------------===
|
//===-- popcountsi2.c - Implement __popcountsi2 ---------------------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file implements __popcountsi2 for the compiler_rt library.
|
||||||
* This file implements __popcountsi2 for the compiler_rt library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "int_lib.h"
|
#include "int_lib.h"
|
||||||
|
|
||||||
/* Returns: count of 1 bits */
|
// Returns: count of 1 bits
|
||||||
|
|
||||||
COMPILER_RT_ABI si_int
|
COMPILER_RT_ABI int __popcountsi2(si_int a) {
|
||||||
__popcountsi2(si_int a)
|
su_int x = (su_int)a;
|
||||||
{
|
x = x - ((x >> 1) & 0x55555555);
|
||||||
su_int x = (su_int)a;
|
// Every 2 bits holds the sum of every pair of bits
|
||||||
x = x - ((x >> 1) & 0x55555555);
|
x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
|
||||||
/* Every 2 bits holds the sum of every pair of bits */
|
// Every 4 bits holds the sum of every 4-set of bits (3 significant bits)
|
||||||
x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
|
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||||
/* Every 4 bits holds the sum of every 4-set of bits (3 significant bits) */
|
// Every 8 bits holds the sum of every 8-set of bits (4 significant bits)
|
||||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
x = (x + (x >> 16));
|
||||||
/* Every 8 bits holds the sum of every 8-set of bits (4 significant bits) */
|
// The lower 16 bits hold two 8 bit sums (5 significant bits).
|
||||||
x = (x + (x >> 16));
|
// Upper 16 bits are garbage
|
||||||
/* The lower 16 bits hold two 8 bit sums (5 significant bits).*/
|
return (x + (x >> 8)) & 0x0000003F; // (6 significant bits)
|
||||||
/* Upper 16 bits are garbage */
|
|
||||||
return (x + (x >> 8)) & 0x0000003F; /* (6 significant bits) */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,231 +1,200 @@
|
||||||
/* ===-- udivmoddi4.c - Implement __udivmoddi4 -----------------------------===
|
//===-- udivmoddi4.c - Implement __udivmoddi4 -----------------------------===//
|
||||||
*
|
//
|
||||||
* The LLVM Compiler Infrastructure
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
*
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
* This file is dual licensed under the MIT and the University of Illinois Open
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
* Source Licenses. See LICENSE.TXT for details.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
//
|
||||||
*
|
// This file implements __udivmoddi4 for the compiler_rt library.
|
||||||
* This file implements __udivmoddi4 for the compiler_rt library.
|
//
|
||||||
*
|
//===----------------------------------------------------------------------===//
|
||||||
* ===----------------------------------------------------------------------===
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "int_lib.h"
|
#include "int_lib.h"
|
||||||
|
|
||||||
/* Effects: if rem != 0, *rem = a % b
|
// Effects: if rem != 0, *rem = a % b
|
||||||
* Returns: a / b
|
// Returns: a / b
|
||||||
*/
|
|
||||||
|
|
||||||
/* Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide */
|
// Translated from Figure 3-40 of The PowerPC Compiler Writer's Guide
|
||||||
|
|
||||||
COMPILER_RT_ABI du_int
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
__udivmoddi4(du_int a, du_int b, du_int* rem)
|
// MSVC throws a warning about mod 0 here, disable it for builds that
|
||||||
{
|
// warn-as-error
|
||||||
const unsigned n_uword_bits = sizeof(su_int) * CHAR_BIT;
|
#pragma warning(push)
|
||||||
const unsigned n_udword_bits = sizeof(du_int) * CHAR_BIT;
|
#pragma warning(disable : 4723 4724)
|
||||||
udwords n;
|
#endif
|
||||||
n.all = a;
|
|
||||||
udwords d;
|
COMPILER_RT_ABI du_int __udivmoddi4(du_int a, du_int b, du_int *rem) {
|
||||||
d.all = b;
|
const unsigned n_uword_bits = sizeof(su_int) * CHAR_BIT;
|
||||||
udwords q;
|
const unsigned n_udword_bits = sizeof(du_int) * CHAR_BIT;
|
||||||
udwords r;
|
udwords n;
|
||||||
unsigned sr;
|
n.all = a;
|
||||||
/* special cases, X is unknown, K != 0 */
|
udwords d;
|
||||||
if (n.s.high == 0)
|
d.all = b;
|
||||||
{
|
udwords q;
|
||||||
if (d.s.high == 0)
|
udwords r;
|
||||||
{
|
unsigned sr;
|
||||||
/* 0 X
|
// special cases, X is unknown, K != 0
|
||||||
* ---
|
if (n.s.high == 0) {
|
||||||
* 0 X
|
if (d.s.high == 0) {
|
||||||
*/
|
// 0 X
|
||||||
if (rem)
|
// ---
|
||||||
*rem = n.s.low % d.s.low;
|
// 0 X
|
||||||
return n.s.low / d.s.low;
|
if (rem)
|
||||||
}
|
*rem = n.s.low % d.s.low;
|
||||||
/* 0 X
|
return n.s.low / d.s.low;
|
||||||
* ---
|
|
||||||
* K X
|
|
||||||
*/
|
|
||||||
if (rem)
|
|
||||||
*rem = n.s.low;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
/* n.s.high != 0 */
|
// 0 X
|
||||||
if (d.s.low == 0)
|
// ---
|
||||||
{
|
// K X
|
||||||
if (d.s.high == 0)
|
if (rem)
|
||||||
{
|
*rem = n.s.low;
|
||||||
/* K X
|
return 0;
|
||||||
* ---
|
}
|
||||||
* 0 0
|
// n.s.high != 0
|
||||||
*/
|
if (d.s.low == 0) {
|
||||||
if (rem)
|
if (d.s.high == 0) {
|
||||||
*rem = n.s.high % d.s.low;
|
// K X
|
||||||
return n.s.high / d.s.low;
|
// ---
|
||||||
}
|
// 0 0
|
||||||
/* d.s.high != 0 */
|
if (rem)
|
||||||
if (n.s.low == 0)
|
*rem = n.s.high % d.s.low;
|
||||||
{
|
return n.s.high / d.s.low;
|
||||||
/* K 0
|
}
|
||||||
* ---
|
// d.s.high != 0
|
||||||
* K 0
|
if (n.s.low == 0) {
|
||||||
*/
|
// K 0
|
||||||
if (rem)
|
// ---
|
||||||
{
|
// K 0
|
||||||
r.s.high = n.s.high % d.s.high;
|
if (rem) {
|
||||||
r.s.low = 0;
|
r.s.high = n.s.high % d.s.high;
|
||||||
*rem = r.all;
|
r.s.low = 0;
|
||||||
}
|
*rem = r.all;
|
||||||
return n.s.high / d.s.high;
|
}
|
||||||
}
|
return n.s.high / d.s.high;
|
||||||
/* K K
|
}
|
||||||
* ---
|
// K K
|
||||||
* K 0
|
// ---
|
||||||
*/
|
// K 0
|
||||||
if ((d.s.high & (d.s.high - 1)) == 0) /* if d is a power of 2 */
|
if ((d.s.high & (d.s.high - 1)) == 0) /* if d is a power of 2 */ {
|
||||||
{
|
if (rem) {
|
||||||
if (rem)
|
r.s.low = n.s.low;
|
||||||
{
|
r.s.high = n.s.high & (d.s.high - 1);
|
||||||
r.s.low = n.s.low;
|
*rem = r.all;
|
||||||
r.s.high = n.s.high & (d.s.high - 1);
|
}
|
||||||
*rem = r.all;
|
return n.s.high >> ctzsi(d.s.high);
|
||||||
}
|
}
|
||||||
return n.s.high >> __builtin_ctz(d.s.high);
|
// K K
|
||||||
}
|
// ---
|
||||||
/* K K
|
// K 0
|
||||||
* ---
|
sr = clzsi(d.s.high) - clzsi(n.s.high);
|
||||||
* K 0
|
// 0 <= sr <= n_uword_bits - 2 or sr large
|
||||||
*/
|
if (sr > n_uword_bits - 2) {
|
||||||
sr = __builtin_clz(d.s.high) - __builtin_clz(n.s.high);
|
if (rem)
|
||||||
/* 0 <= sr <= n_uword_bits - 2 or sr large */
|
*rem = n.all;
|
||||||
if (sr > n_uword_bits - 2)
|
return 0;
|
||||||
{
|
}
|
||||||
if (rem)
|
++sr;
|
||||||
*rem = n.all;
|
// 1 <= sr <= n_uword_bits - 1
|
||||||
return 0;
|
// q.all = n.all << (n_udword_bits - sr);
|
||||||
}
|
q.s.low = 0;
|
||||||
++sr;
|
q.s.high = n.s.low << (n_uword_bits - sr);
|
||||||
/* 1 <= sr <= n_uword_bits - 1 */
|
// r.all = n.all >> sr;
|
||||||
/* q.all = n.all << (n_udword_bits - sr); */
|
r.s.high = n.s.high >> sr;
|
||||||
|
r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
|
||||||
|
} else /* d.s.low != 0 */ {
|
||||||
|
if (d.s.high == 0) {
|
||||||
|
// K X
|
||||||
|
// ---
|
||||||
|
// 0 K
|
||||||
|
if ((d.s.low & (d.s.low - 1)) == 0) /* if d is a power of 2 */ {
|
||||||
|
if (rem)
|
||||||
|
*rem = n.s.low & (d.s.low - 1);
|
||||||
|
if (d.s.low == 1)
|
||||||
|
return n.all;
|
||||||
|
sr = ctzsi(d.s.low);
|
||||||
|
q.s.high = n.s.high >> sr;
|
||||||
|
q.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
|
||||||
|
return q.all;
|
||||||
|
}
|
||||||
|
// K X
|
||||||
|
// ---
|
||||||
|
// 0 K
|
||||||
|
sr = 1 + n_uword_bits + clzsi(d.s.low) - clzsi(n.s.high);
|
||||||
|
// 2 <= sr <= n_udword_bits - 1
|
||||||
|
// q.all = n.all << (n_udword_bits - sr);
|
||||||
|
// r.all = n.all >> sr;
|
||||||
|
if (sr == n_uword_bits) {
|
||||||
|
q.s.low = 0;
|
||||||
|
q.s.high = n.s.low;
|
||||||
|
r.s.high = 0;
|
||||||
|
r.s.low = n.s.high;
|
||||||
|
} else if (sr < n_uword_bits) /* 2 <= sr <= n_uword_bits - 1 */ {
|
||||||
q.s.low = 0;
|
q.s.low = 0;
|
||||||
q.s.high = n.s.low << (n_uword_bits - sr);
|
q.s.high = n.s.low << (n_uword_bits - sr);
|
||||||
/* r.all = n.all >> sr; */
|
|
||||||
r.s.high = n.s.high >> sr;
|
r.s.high = n.s.high >> sr;
|
||||||
r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
|
r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
|
||||||
|
} else /* n_uword_bits + 1 <= sr <= n_udword_bits - 1 */ {
|
||||||
|
q.s.low = n.s.low << (n_udword_bits - sr);
|
||||||
|
q.s.high = (n.s.high << (n_udword_bits - sr)) |
|
||||||
|
(n.s.low >> (sr - n_uword_bits));
|
||||||
|
r.s.high = 0;
|
||||||
|
r.s.low = n.s.high >> (sr - n_uword_bits);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// K X
|
||||||
|
// ---
|
||||||
|
// K K
|
||||||
|
sr = clzsi(d.s.high) - clzsi(n.s.high);
|
||||||
|
// 0 <= sr <= n_uword_bits - 1 or sr large
|
||||||
|
if (sr > n_uword_bits - 1) {
|
||||||
|
if (rem)
|
||||||
|
*rem = n.all;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
++sr;
|
||||||
|
// 1 <= sr <= n_uword_bits
|
||||||
|
// q.all = n.all << (n_udword_bits - sr);
|
||||||
|
q.s.low = 0;
|
||||||
|
if (sr == n_uword_bits) {
|
||||||
|
q.s.high = n.s.low;
|
||||||
|
r.s.high = 0;
|
||||||
|
r.s.low = n.s.high;
|
||||||
|
} else {
|
||||||
|
q.s.high = n.s.low << (n_uword_bits - sr);
|
||||||
|
r.s.high = n.s.high >> sr;
|
||||||
|
r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else /* d.s.low != 0 */
|
}
|
||||||
{
|
// Not a special case
|
||||||
if (d.s.high == 0)
|
// q and r are initialized with:
|
||||||
{
|
// q.all = n.all << (n_udword_bits - sr);
|
||||||
/* K X
|
// r.all = n.all >> sr;
|
||||||
* ---
|
// 1 <= sr <= n_udword_bits - 1
|
||||||
* 0 K
|
su_int carry = 0;
|
||||||
*/
|
for (; sr > 0; --sr) {
|
||||||
if ((d.s.low & (d.s.low - 1)) == 0) /* if d is a power of 2 */
|
// r:q = ((r:q) << 1) | carry
|
||||||
{
|
r.s.high = (r.s.high << 1) | (r.s.low >> (n_uword_bits - 1));
|
||||||
if (rem)
|
r.s.low = (r.s.low << 1) | (q.s.high >> (n_uword_bits - 1));
|
||||||
*rem = n.s.low & (d.s.low - 1);
|
q.s.high = (q.s.high << 1) | (q.s.low >> (n_uword_bits - 1));
|
||||||
if (d.s.low == 1)
|
q.s.low = (q.s.low << 1) | carry;
|
||||||
return n.all;
|
// carry = 0;
|
||||||
sr = __builtin_ctz(d.s.low);
|
// if (r.all >= d.all)
|
||||||
q.s.high = n.s.high >> sr;
|
// {
|
||||||
q.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
|
// r.all -= d.all;
|
||||||
return q.all;
|
// carry = 1;
|
||||||
}
|
// }
|
||||||
/* K X
|
const di_int s = (di_int)(d.all - r.all - 1) >> (n_udword_bits - 1);
|
||||||
* ---
|
carry = s & 1;
|
||||||
* 0 K
|
r.all -= d.all & s;
|
||||||
*/
|
}
|
||||||
sr = 1 + n_uword_bits + __builtin_clz(d.s.low) - __builtin_clz(n.s.high);
|
q.all = (q.all << 1) | carry;
|
||||||
/* 2 <= sr <= n_udword_bits - 1
|
if (rem)
|
||||||
* q.all = n.all << (n_udword_bits - sr);
|
*rem = r.all;
|
||||||
* r.all = n.all >> sr;
|
return q.all;
|
||||||
*/
|
|
||||||
if (sr == n_uword_bits)
|
|
||||||
{
|
|
||||||
q.s.low = 0;
|
|
||||||
q.s.high = n.s.low;
|
|
||||||
r.s.high = 0;
|
|
||||||
r.s.low = n.s.high;
|
|
||||||
}
|
|
||||||
else if (sr < n_uword_bits) // 2 <= sr <= n_uword_bits - 1
|
|
||||||
{
|
|
||||||
q.s.low = 0;
|
|
||||||
q.s.high = n.s.low << (n_uword_bits - sr);
|
|
||||||
r.s.high = n.s.high >> sr;
|
|
||||||
r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
|
|
||||||
}
|
|
||||||
else // n_uword_bits + 1 <= sr <= n_udword_bits - 1
|
|
||||||
{
|
|
||||||
q.s.low = n.s.low << (n_udword_bits - sr);
|
|
||||||
q.s.high = (n.s.high << (n_udword_bits - sr)) |
|
|
||||||
(n.s.low >> (sr - n_uword_bits));
|
|
||||||
r.s.high = 0;
|
|
||||||
r.s.low = n.s.high >> (sr - n_uword_bits);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* K X
|
|
||||||
* ---
|
|
||||||
* K K
|
|
||||||
*/
|
|
||||||
sr = __builtin_clz(d.s.high) - __builtin_clz(n.s.high);
|
|
||||||
/* 0 <= sr <= n_uword_bits - 1 or sr large */
|
|
||||||
if (sr > n_uword_bits - 1)
|
|
||||||
{
|
|
||||||
if (rem)
|
|
||||||
*rem = n.all;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
++sr;
|
|
||||||
/* 1 <= sr <= n_uword_bits */
|
|
||||||
/* q.all = n.all << (n_udword_bits - sr); */
|
|
||||||
q.s.low = 0;
|
|
||||||
if (sr == n_uword_bits)
|
|
||||||
{
|
|
||||||
q.s.high = n.s.low;
|
|
||||||
r.s.high = 0;
|
|
||||||
r.s.low = n.s.high;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
q.s.high = n.s.low << (n_uword_bits - sr);
|
|
||||||
r.s.high = n.s.high >> sr;
|
|
||||||
r.s.low = (n.s.high << (n_uword_bits - sr)) | (n.s.low >> sr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Not a special case
|
|
||||||
* q and r are initialized with:
|
|
||||||
* q.all = n.all << (n_udword_bits - sr);
|
|
||||||
* r.all = n.all >> sr;
|
|
||||||
* 1 <= sr <= n_udword_bits - 1
|
|
||||||
*/
|
|
||||||
su_int carry = 0;
|
|
||||||
for (; sr > 0; --sr)
|
|
||||||
{
|
|
||||||
/* r:q = ((r:q) << 1) | carry */
|
|
||||||
r.s.high = (r.s.high << 1) | (r.s.low >> (n_uword_bits - 1));
|
|
||||||
r.s.low = (r.s.low << 1) | (q.s.high >> (n_uword_bits - 1));
|
|
||||||
q.s.high = (q.s.high << 1) | (q.s.low >> (n_uword_bits - 1));
|
|
||||||
q.s.low = (q.s.low << 1) | carry;
|
|
||||||
/* carry = 0;
|
|
||||||
* if (r.all >= d.all)
|
|
||||||
* {
|
|
||||||
* r.all -= d.all;
|
|
||||||
* carry = 1;
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
const di_int s = (di_int)(d.all - r.all - 1) >> (n_udword_bits - 1);
|
|
||||||
carry = s & 1;
|
|
||||||
r.all -= d.all & s;
|
|
||||||
}
|
|
||||||
q.all = (q.all << 1) | carry;
|
|
||||||
if (rem)
|
|
||||||
*rem = r.all;
|
|
||||||
return q.all;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && !defined(__clang__)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
|
@ -34,6 +34,7 @@ COMPILER_RT_SRCS := lib/compiler-rt/builtins/popcountdi2.c \
|
||||||
ifeq (${ARCH},aarch32)
|
ifeq (${ARCH},aarch32)
|
||||||
COMPILER_RT_SRCS += lib/compiler-rt/builtins/arm/aeabi_ldivmod.S \
|
COMPILER_RT_SRCS += lib/compiler-rt/builtins/arm/aeabi_ldivmod.S \
|
||||||
lib/compiler-rt/builtins/arm/aeabi_uldivmod.S \
|
lib/compiler-rt/builtins/arm/aeabi_uldivmod.S \
|
||||||
|
lib/compiler-rt/builtins/arm/aeabi_memcpy.S \
|
||||||
lib/compiler-rt/builtins/ctzdi2.c \
|
lib/compiler-rt/builtins/ctzdi2.c \
|
||||||
lib/compiler-rt/builtins/divdi3.c \
|
lib/compiler-rt/builtins/divdi3.c \
|
||||||
lib/compiler-rt/builtins/divmoddi4.c \
|
lib/compiler-rt/builtins/divmoddi4.c \
|
||||||
|
|
|
@ -22,6 +22,10 @@ int32_t fdt_ro_probe_(const void *fdt)
|
||||||
if (can_assume(VALID_DTB))
|
if (can_assume(VALID_DTB))
|
||||||
return totalsize;
|
return totalsize;
|
||||||
|
|
||||||
|
/* The device tree must be at an 8-byte aligned address */
|
||||||
|
if ((uintptr_t)fdt & 7)
|
||||||
|
return -FDT_ERR_ALIGNMENT;
|
||||||
|
|
||||||
if (fdt_magic(fdt) == FDT_MAGIC) {
|
if (fdt_magic(fdt) == FDT_MAGIC) {
|
||||||
/* Complete tree */
|
/* Complete tree */
|
||||||
if (!can_assume(LATEST)) {
|
if (!can_assume(LATEST)) {
|
||||||
|
@ -86,6 +90,10 @@ int fdt_check_header(const void *fdt)
|
||||||
{
|
{
|
||||||
size_t hdrsize;
|
size_t hdrsize;
|
||||||
|
|
||||||
|
/* The device tree must be at an 8-byte aligned address */
|
||||||
|
if ((uintptr_t)fdt & 7)
|
||||||
|
return -FDT_ERR_ALIGNMENT;
|
||||||
|
|
||||||
if (fdt_magic(fdt) != FDT_MAGIC)
|
if (fdt_magic(fdt) != FDT_MAGIC)
|
||||||
return -FDT_ERR_BADMAGIC;
|
return -FDT_ERR_BADMAGIC;
|
||||||
if (!can_assume(LATEST)) {
|
if (!can_assume(LATEST)) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset,
|
||||||
/* check validity of address */
|
/* check validity of address */
|
||||||
prop = data;
|
prop = data;
|
||||||
if (addr_cells == 1) {
|
if (addr_cells == 1) {
|
||||||
if ((addr > UINT32_MAX) || ((UINT32_MAX + 1 - addr) < size))
|
if ((addr > UINT32_MAX) || (((uint64_t) UINT32_MAX + 1 - addr) < size))
|
||||||
return -FDT_ERR_BADVALUE;
|
return -FDT_ERR_BADVALUE;
|
||||||
|
|
||||||
fdt32_st(prop, (uint32_t)addr);
|
fdt32_st(prop, (uint32_t)addr);
|
||||||
|
|
|
@ -40,37 +40,22 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
|
||||||
return fdt32_to_cpu(*val);
|
return fdt32_to_cpu(*val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
int fdt_overlay_target_offset(const void *fdt, const void *fdto,
|
||||||
* overlay_get_target - retrieves the offset of a fragment's target
|
int fragment_offset, char const **pathp)
|
||||||
* @fdt: Base device tree blob
|
|
||||||
* @fdto: Device tree overlay blob
|
|
||||||
* @fragment: node offset of the fragment in the overlay
|
|
||||||
* @pathp: pointer which receives the path of the target (or NULL)
|
|
||||||
*
|
|
||||||
* overlay_get_target() retrieves the target offset in the base
|
|
||||||
* device tree of a fragment, no matter how the actual targeting is
|
|
||||||
* done (through a phandle or a path)
|
|
||||||
*
|
|
||||||
* returns:
|
|
||||||
* the targeted node offset in the base device tree
|
|
||||||
* Negative error code on error
|
|
||||||
*/
|
|
||||||
static int overlay_get_target(const void *fdt, const void *fdto,
|
|
||||||
int fragment, char const **pathp)
|
|
||||||
{
|
{
|
||||||
uint32_t phandle;
|
uint32_t phandle;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
int path_len = 0, ret;
|
int path_len = 0, ret;
|
||||||
|
|
||||||
/* Try first to do a phandle based lookup */
|
/* Try first to do a phandle based lookup */
|
||||||
phandle = overlay_get_target_phandle(fdto, fragment);
|
phandle = overlay_get_target_phandle(fdto, fragment_offset);
|
||||||
if (phandle == (uint32_t)-1)
|
if (phandle == (uint32_t)-1)
|
||||||
return -FDT_ERR_BADPHANDLE;
|
return -FDT_ERR_BADPHANDLE;
|
||||||
|
|
||||||
/* no phandle, try path */
|
/* no phandle, try path */
|
||||||
if (!phandle) {
|
if (!phandle) {
|
||||||
/* And then a path based lookup */
|
/* And then a path based lookup */
|
||||||
path = fdt_getprop(fdto, fragment, "target-path", &path_len);
|
path = fdt_getprop(fdto, fragment_offset, "target-path", &path_len);
|
||||||
if (path)
|
if (path)
|
||||||
ret = fdt_path_offset(fdt, path);
|
ret = fdt_path_offset(fdt, path);
|
||||||
else
|
else
|
||||||
|
@ -636,7 +621,7 @@ static int overlay_merge(void *fdt, void *fdto)
|
||||||
if (overlay < 0)
|
if (overlay < 0)
|
||||||
return overlay;
|
return overlay;
|
||||||
|
|
||||||
target = overlay_get_target(fdt, fdto, fragment, NULL);
|
target = fdt_overlay_target_offset(fdt, fdto, fragment, NULL);
|
||||||
if (target < 0)
|
if (target < 0)
|
||||||
return target;
|
return target;
|
||||||
|
|
||||||
|
@ -779,7 +764,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)
|
||||||
return -FDT_ERR_BADOVERLAY;
|
return -FDT_ERR_BADOVERLAY;
|
||||||
|
|
||||||
/* get the target of the fragment */
|
/* get the target of the fragment */
|
||||||
ret = overlay_get_target(fdt, fdto, fragment, &target_path);
|
ret = fdt_overlay_target_offset(fdt, fdto, fragment, &target_path);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
target = ret;
|
target = ret;
|
||||||
|
@ -801,7 +786,7 @@ static int overlay_symbol_update(void *fdt, void *fdto)
|
||||||
|
|
||||||
if (!target_path) {
|
if (!target_path) {
|
||||||
/* again in case setprop_placeholder changed it */
|
/* again in case setprop_placeholder changed it */
|
||||||
ret = overlay_get_target(fdt, fdto, fragment, &target_path);
|
ret = fdt_overlay_target_offset(fdt, fdto, fragment, &target_path);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
target = ret;
|
target = ret;
|
||||||
|
|
|
@ -181,8 +181,8 @@ int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
|
||||||
if (!can_assume(VALID_INPUT) && !re)
|
if (!can_assume(VALID_INPUT) && !re)
|
||||||
return -FDT_ERR_BADOFFSET;
|
return -FDT_ERR_BADOFFSET;
|
||||||
|
|
||||||
*address = fdt64_ld(&re->address);
|
*address = fdt64_ld_(&re->address);
|
||||||
*size = fdt64_ld(&re->size);
|
*size = fdt64_ld_(&re->size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ int fdt_num_mem_rsv(const void *fdt)
|
||||||
const struct fdt_reserve_entry *re;
|
const struct fdt_reserve_entry *re;
|
||||||
|
|
||||||
for (i = 0; (re = fdt_mem_rsv(fdt, i)) != NULL; i++) {
|
for (i = 0; (re = fdt_mem_rsv(fdt, i)) != NULL; i++) {
|
||||||
if (fdt64_ld(&re->size) == 0)
|
if (fdt64_ld_(&re->size) == 0)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -FDT_ERR_TRUNCATED;
|
return -FDT_ERR_TRUNCATED;
|
||||||
|
@ -370,7 +370,7 @@ static const struct fdt_property *fdt_get_property_by_offset_(const void *fdt,
|
||||||
prop = fdt_offset_ptr_(fdt, offset);
|
prop = fdt_offset_ptr_(fdt, offset);
|
||||||
|
|
||||||
if (lenp)
|
if (lenp)
|
||||||
*lenp = fdt32_ld(&prop->len);
|
*lenp = fdt32_ld_(&prop->len);
|
||||||
|
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ static const struct fdt_property *fdt_get_property_namelen_(const void *fdt,
|
||||||
offset = -FDT_ERR_INTERNAL;
|
offset = -FDT_ERR_INTERNAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fdt_string_eq_(fdt, fdt32_ld(&prop->nameoff),
|
if (fdt_string_eq_(fdt, fdt32_ld_(&prop->nameoff),
|
||||||
name, namelen)) {
|
name, namelen)) {
|
||||||
if (poffset)
|
if (poffset)
|
||||||
*poffset = offset;
|
*poffset = offset;
|
||||||
|
@ -461,7 +461,7 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
|
||||||
|
|
||||||
/* Handle realignment */
|
/* Handle realignment */
|
||||||
if (!can_assume(LATEST) && fdt_version(fdt) < 0x10 &&
|
if (!can_assume(LATEST) && fdt_version(fdt) < 0x10 &&
|
||||||
(poffset + sizeof(*prop)) % 8 && fdt32_ld(&prop->len) >= 8)
|
(poffset + sizeof(*prop)) % 8 && fdt32_ld_(&prop->len) >= 8)
|
||||||
return prop->data + 4;
|
return prop->data + 4;
|
||||||
return prop->data;
|
return prop->data;
|
||||||
}
|
}
|
||||||
|
@ -479,22 +479,22 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
|
||||||
int namelen;
|
int namelen;
|
||||||
|
|
||||||
if (!can_assume(VALID_INPUT)) {
|
if (!can_assume(VALID_INPUT)) {
|
||||||
name = fdt_get_string(fdt, fdt32_ld(&prop->nameoff),
|
name = fdt_get_string(fdt, fdt32_ld_(&prop->nameoff),
|
||||||
&namelen);
|
&namelen);
|
||||||
|
*namep = name;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
if (lenp)
|
if (lenp)
|
||||||
*lenp = namelen;
|
*lenp = namelen;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*namep = name;
|
|
||||||
} else {
|
} else {
|
||||||
*namep = fdt_string(fdt, fdt32_ld(&prop->nameoff));
|
*namep = fdt_string(fdt, fdt32_ld_(&prop->nameoff));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle realignment */
|
/* Handle realignment */
|
||||||
if (!can_assume(LATEST) && fdt_version(fdt) < 0x10 &&
|
if (!can_assume(LATEST) && fdt_version(fdt) < 0x10 &&
|
||||||
(offset + sizeof(*prop)) % 8 && fdt32_ld(&prop->len) >= 8)
|
(offset + sizeof(*prop)) % 8 && fdt32_ld_(&prop->len) >= 8)
|
||||||
return prop->data + 4;
|
return prop->data + 4;
|
||||||
return prop->data;
|
return prop->data;
|
||||||
}
|
}
|
||||||
|
@ -519,7 +519,7 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fdt32_ld(php);
|
return fdt32_ld_(php);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *fdt_get_alias_namelen(const void *fdt,
|
const char *fdt_get_alias_namelen(const void *fdt,
|
||||||
|
|
|
@ -349,7 +349,10 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
/* Try to place the new node after the parent's properties */
|
/* Try to place the new node after the parent's properties */
|
||||||
fdt_next_tag(fdt, parentoffset, &nextoffset); /* skip the BEGIN_NODE */
|
tag = fdt_next_tag(fdt, parentoffset, &nextoffset);
|
||||||
|
/* the fdt_subnode_offset_namelen() should ensure this never hits */
|
||||||
|
if (!can_assume(LIBFDT_FLAWLESS) && (tag != FDT_BEGIN_NODE))
|
||||||
|
return -FDT_ERR_INTERNAL;
|
||||||
do {
|
do {
|
||||||
offset = nextoffset;
|
offset = nextoffset;
|
||||||
tag = fdt_next_tag(fdt, offset, &nextoffset);
|
tag = fdt_next_tag(fdt, offset, &nextoffset);
|
||||||
|
@ -391,7 +394,9 @@ int fdt_del_node(void *fdt, int nodeoffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fdt_packblocks_(const char *old, char *new,
|
static void fdt_packblocks_(const char *old, char *new,
|
||||||
int mem_rsv_size, int struct_size)
|
int mem_rsv_size,
|
||||||
|
int struct_size,
|
||||||
|
int strings_size)
|
||||||
{
|
{
|
||||||
int mem_rsv_off, struct_off, strings_off;
|
int mem_rsv_off, struct_off, strings_off;
|
||||||
|
|
||||||
|
@ -406,8 +411,7 @@ static void fdt_packblocks_(const char *old, char *new,
|
||||||
fdt_set_off_dt_struct(new, struct_off);
|
fdt_set_off_dt_struct(new, struct_off);
|
||||||
fdt_set_size_dt_struct(new, struct_size);
|
fdt_set_size_dt_struct(new, struct_size);
|
||||||
|
|
||||||
memmove(new + strings_off, old + fdt_off_dt_strings(old),
|
memmove(new + strings_off, old + fdt_off_dt_strings(old), strings_size);
|
||||||
fdt_size_dt_strings(old));
|
|
||||||
fdt_set_off_dt_strings(new, strings_off);
|
fdt_set_off_dt_strings(new, strings_off);
|
||||||
fdt_set_size_dt_strings(new, fdt_size_dt_strings(old));
|
fdt_set_size_dt_strings(new, fdt_size_dt_strings(old));
|
||||||
}
|
}
|
||||||
|
@ -428,12 +432,14 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
|
||||||
|
|
||||||
if (can_assume(LATEST) || fdt_version(fdt) >= 17) {
|
if (can_assume(LATEST) || fdt_version(fdt) >= 17) {
|
||||||
struct_size = fdt_size_dt_struct(fdt);
|
struct_size = fdt_size_dt_struct(fdt);
|
||||||
} else {
|
} else if (fdt_version(fdt) == 16) {
|
||||||
struct_size = 0;
|
struct_size = 0;
|
||||||
while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END)
|
while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END)
|
||||||
;
|
;
|
||||||
if (struct_size < 0)
|
if (struct_size < 0)
|
||||||
return struct_size;
|
return struct_size;
|
||||||
|
} else {
|
||||||
|
return -FDT_ERR_BADVERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can_assume(LIBFDT_ORDER) ||
|
if (can_assume(LIBFDT_ORDER) ||
|
||||||
|
@ -465,7 +471,8 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
|
||||||
return -FDT_ERR_NOSPACE;
|
return -FDT_ERR_NOSPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdt_packblocks_(fdt, tmp, mem_rsv_size, struct_size);
|
fdt_packblocks_(fdt, tmp, mem_rsv_size, struct_size,
|
||||||
|
fdt_size_dt_strings(fdt));
|
||||||
memmove(buf, tmp, newsize);
|
memmove(buf, tmp, newsize);
|
||||||
|
|
||||||
fdt_set_magic(buf, FDT_MAGIC);
|
fdt_set_magic(buf, FDT_MAGIC);
|
||||||
|
@ -485,7 +492,8 @@ int fdt_pack(void *fdt)
|
||||||
|
|
||||||
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
|
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
|
||||||
* sizeof(struct fdt_reserve_entry);
|
* sizeof(struct fdt_reserve_entry);
|
||||||
fdt_packblocks_(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
|
fdt_packblocks_(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt),
|
||||||
|
fdt_size_dt_strings(fdt));
|
||||||
fdt_set_totalsize(fdt, fdt_data_size_(fdt));
|
fdt_set_totalsize(fdt, fdt_data_size_(fdt));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -39,6 +39,7 @@ static struct fdt_errtabent fdt_errtable[] = {
|
||||||
FDT_ERRTABENT(FDT_ERR_BADOVERLAY),
|
FDT_ERRTABENT(FDT_ERR_BADOVERLAY),
|
||||||
FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
|
FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
|
||||||
FDT_ERRTABENT(FDT_ERR_BADFLAGS),
|
FDT_ERRTABENT(FDT_ERR_BADFLAGS),
|
||||||
|
FDT_ERRTABENT(FDT_ERR_ALIGNMENT),
|
||||||
};
|
};
|
||||||
#define FDT_ERRTABSIZE ((int)(sizeof(fdt_errtable) / sizeof(fdt_errtable[0])))
|
#define FDT_ERRTABSIZE ((int)(sizeof(fdt_errtable) / sizeof(fdt_errtable[0])))
|
||||||
|
|
||||||
|
|
|
@ -377,7 +377,7 @@ int fdt_finish(void *fdt)
|
||||||
fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));
|
fdt_set_totalsize(fdt, newstroffset + fdt_size_dt_strings(fdt));
|
||||||
|
|
||||||
/* And fix up fields that were keeping intermediate state. */
|
/* And fix up fields that were keeping intermediate state. */
|
||||||
fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
|
fdt_set_last_comp_version(fdt, FDT_LAST_COMPATIBLE_VERSION);
|
||||||
fdt_set_magic(fdt, FDT_MAGIC);
|
fdt_set_magic(fdt, FDT_MAGIC);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -46,6 +46,25 @@ static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n)
|
||||||
return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n);
|
return (void *)(uintptr_t)fdt_mem_rsv_(fdt, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal helpers to access tructural elements of the device tree
|
||||||
|
* blob (rather than for exaple reading integers from within property
|
||||||
|
* values). We assume that we are either given a naturally aligned
|
||||||
|
* address for the platform or if we are not, we are on a platform
|
||||||
|
* where unaligned memory reads will be handled in a graceful manner.
|
||||||
|
* If not the external helpers fdtXX_ld() from libfdt.h can be used
|
||||||
|
* instead.
|
||||||
|
*/
|
||||||
|
static inline uint32_t fdt32_ld_(const fdt32_t *p)
|
||||||
|
{
|
||||||
|
return fdt32_to_cpu(*p);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t fdt64_ld_(const fdt64_t *p)
|
||||||
|
{
|
||||||
|
return fdt64_to_cpu(*p);
|
||||||
|
}
|
||||||
|
|
||||||
#define FDT_SW_MAGIC (~FDT_MAGIC)
|
#define FDT_SW_MAGIC (~FDT_MAGIC)
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
1303
lib/zlib/crc32.c
1303
lib/zlib/crc32.c
File diff suppressed because it is too large
Load diff
9877
lib/zlib/crc32.h
9877
lib/zlib/crc32.h
File diff suppressed because it is too large
Load diff
|
@ -70,7 +70,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
code const FAR *dcode; /* local strm->distcode */
|
code const FAR *dcode; /* local strm->distcode */
|
||||||
unsigned lmask; /* mask for first level of length codes */
|
unsigned lmask; /* mask for first level of length codes */
|
||||||
unsigned dmask; /* mask for first level of distance codes */
|
unsigned dmask; /* mask for first level of distance codes */
|
||||||
code here; /* retrieved table entry */
|
code const *here; /* retrieved table entry */
|
||||||
unsigned op; /* code bits, operation, extra bits, or */
|
unsigned op; /* code bits, operation, extra bits, or */
|
||||||
/* window position, window bytes to copy */
|
/* window position, window bytes to copy */
|
||||||
unsigned len; /* match length, unused bytes */
|
unsigned len; /* match length, unused bytes */
|
||||||
|
@ -107,20 +107,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
hold += (unsigned long)(*in++) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
here = lcode[hold & lmask];
|
here = lcode + (hold & lmask);
|
||||||
dolen:
|
dolen:
|
||||||
op = (unsigned)(here.bits);
|
op = (unsigned)(here->bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(here.op);
|
op = (unsigned)(here->op);
|
||||||
if (op == 0) { /* literal */
|
if (op == 0) { /* literal */
|
||||||
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", here.val));
|
"inflate: literal 0x%02x\n", here->val));
|
||||||
*out++ = (unsigned char)(here.val);
|
*out++ = (unsigned char)(here->val);
|
||||||
}
|
}
|
||||||
else if (op & 16) { /* length base */
|
else if (op & 16) { /* length base */
|
||||||
len = (unsigned)(here.val);
|
len = (unsigned)(here->val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (op) {
|
if (op) {
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
|
@ -138,14 +138,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
hold += (unsigned long)(*in++) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
here = dcode[hold & dmask];
|
here = dcode + (hold & dmask);
|
||||||
dodist:
|
dodist:
|
||||||
op = (unsigned)(here.bits);
|
op = (unsigned)(here->bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(here.op);
|
op = (unsigned)(here->op);
|
||||||
if (op & 16) { /* distance base */
|
if (op & 16) { /* distance base */
|
||||||
dist = (unsigned)(here.val);
|
dist = (unsigned)(here->val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
hold += (unsigned long)(*in++) << bits;
|
hold += (unsigned long)(*in++) << bits;
|
||||||
|
@ -264,7 +264,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level distance code */
|
else if ((op & 64) == 0) { /* 2nd level distance code */
|
||||||
here = dcode[here.val + (hold & ((1U << op) - 1))];
|
here = dcode + here->val + (hold & ((1U << op) - 1));
|
||||||
goto dodist;
|
goto dodist;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -274,7 +274,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level length code */
|
else if ((op & 64) == 0) { /* 2nd level length code */
|
||||||
here = lcode[here.val + (hold & ((1U << op) - 1))];
|
here = lcode + here->val + (hold & ((1U << op) - 1));
|
||||||
goto dolen;
|
goto dolen;
|
||||||
}
|
}
|
||||||
else if (op & 32) { /* end-of-block */
|
else if (op & 32) { /* end-of-block */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.c -- zlib decompression
|
/* inflate.c -- zlib decompression
|
||||||
* Copyright (C) 1995-2016 Mark Adler
|
* Copyright (C) 1995-2022 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ z_streamp strm;
|
||||||
state->mode = HEAD;
|
state->mode = HEAD;
|
||||||
state->last = 0;
|
state->last = 0;
|
||||||
state->havedict = 0;
|
state->havedict = 0;
|
||||||
|
state->flags = -1;
|
||||||
state->dmax = 32768U;
|
state->dmax = 32768U;
|
||||||
state->head = Z_NULL;
|
state->head = Z_NULL;
|
||||||
state->hold = 0;
|
state->hold = 0;
|
||||||
|
@ -167,6 +168,8 @@ int windowBits;
|
||||||
|
|
||||||
/* extract wrap request from windowBits parameter */
|
/* extract wrap request from windowBits parameter */
|
||||||
if (windowBits < 0) {
|
if (windowBits < 0) {
|
||||||
|
if (windowBits < -15)
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
wrap = 0;
|
wrap = 0;
|
||||||
windowBits = -windowBits;
|
windowBits = -windowBits;
|
||||||
}
|
}
|
||||||
|
@ -447,10 +450,10 @@ unsigned copy;
|
||||||
|
|
||||||
/* check function to use adler32() for zlib or crc32() for gzip */
|
/* check function to use adler32() for zlib or crc32() for gzip */
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
# define UPDATE(check, buf, len) \
|
# define UPDATE_CHECK(check, buf, len) \
|
||||||
(state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
|
(state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
|
||||||
#else
|
#else
|
||||||
# define UPDATE(check, buf, len) adler32(check, buf, len)
|
# define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check macros for header crc */
|
/* check macros for header crc */
|
||||||
|
@ -670,7 +673,6 @@ int flush;
|
||||||
state->mode = FLAGS;
|
state->mode = FLAGS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->flags = 0; /* expect zlib header */
|
|
||||||
if (state->head != Z_NULL)
|
if (state->head != Z_NULL)
|
||||||
state->head->done = -1;
|
state->head->done = -1;
|
||||||
if (!(state->wrap & 1) || /* check if zlib header allowed */
|
if (!(state->wrap & 1) || /* check if zlib header allowed */
|
||||||
|
@ -697,6 +699,7 @@ int flush;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->dmax = 1U << len;
|
state->dmax = 1U << len;
|
||||||
|
state->flags = 0; /* indicate zlib header */
|
||||||
Tracev((stderr, "inflate: zlib header ok\n"));
|
Tracev((stderr, "inflate: zlib header ok\n"));
|
||||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||||
state->mode = hold & 0x200 ? DICTID : TYPE;
|
state->mode = hold & 0x200 ? DICTID : TYPE;
|
||||||
|
@ -722,6 +725,7 @@ int flush;
|
||||||
CRC2(state->check, hold);
|
CRC2(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = TIME;
|
state->mode = TIME;
|
||||||
|
/* fallthrough */
|
||||||
case TIME:
|
case TIME:
|
||||||
NEEDBITS(32);
|
NEEDBITS(32);
|
||||||
if (state->head != Z_NULL)
|
if (state->head != Z_NULL)
|
||||||
|
@ -730,6 +734,7 @@ int flush;
|
||||||
CRC4(state->check, hold);
|
CRC4(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = OS;
|
state->mode = OS;
|
||||||
|
/* fallthrough */
|
||||||
case OS:
|
case OS:
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
if (state->head != Z_NULL) {
|
if (state->head != Z_NULL) {
|
||||||
|
@ -740,6 +745,7 @@ int flush;
|
||||||
CRC2(state->check, hold);
|
CRC2(state->check, hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = EXLEN;
|
state->mode = EXLEN;
|
||||||
|
/* fallthrough */
|
||||||
case EXLEN:
|
case EXLEN:
|
||||||
if (state->flags & 0x0400) {
|
if (state->flags & 0x0400) {
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
|
@ -753,14 +759,16 @@ int flush;
|
||||||
else if (state->head != Z_NULL)
|
else if (state->head != Z_NULL)
|
||||||
state->head->extra = Z_NULL;
|
state->head->extra = Z_NULL;
|
||||||
state->mode = EXTRA;
|
state->mode = EXTRA;
|
||||||
|
/* fallthrough */
|
||||||
case EXTRA:
|
case EXTRA:
|
||||||
if (state->flags & 0x0400) {
|
if (state->flags & 0x0400) {
|
||||||
copy = state->length;
|
copy = state->length;
|
||||||
if (copy > have) copy = have;
|
if (copy > have) copy = have;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
if (state->head != Z_NULL &&
|
if (state->head != Z_NULL &&
|
||||||
state->head->extra != Z_NULL) {
|
state->head->extra != Z_NULL &&
|
||||||
len = state->head->extra_len - state->length;
|
(len = state->head->extra_len - state->length) <
|
||||||
|
state->head->extra_max) {
|
||||||
zmemcpy(state->head->extra + len, next,
|
zmemcpy(state->head->extra + len, next,
|
||||||
len + copy > state->head->extra_max ?
|
len + copy > state->head->extra_max ?
|
||||||
state->head->extra_max - len : copy);
|
state->head->extra_max - len : copy);
|
||||||
|
@ -775,6 +783,7 @@ int flush;
|
||||||
}
|
}
|
||||||
state->length = 0;
|
state->length = 0;
|
||||||
state->mode = NAME;
|
state->mode = NAME;
|
||||||
|
/* fallthrough */
|
||||||
case NAME:
|
case NAME:
|
||||||
if (state->flags & 0x0800) {
|
if (state->flags & 0x0800) {
|
||||||
if (have == 0) goto inf_leave;
|
if (have == 0) goto inf_leave;
|
||||||
|
@ -796,6 +805,7 @@ int flush;
|
||||||
state->head->name = Z_NULL;
|
state->head->name = Z_NULL;
|
||||||
state->length = 0;
|
state->length = 0;
|
||||||
state->mode = COMMENT;
|
state->mode = COMMENT;
|
||||||
|
/* fallthrough */
|
||||||
case COMMENT:
|
case COMMENT:
|
||||||
if (state->flags & 0x1000) {
|
if (state->flags & 0x1000) {
|
||||||
if (have == 0) goto inf_leave;
|
if (have == 0) goto inf_leave;
|
||||||
|
@ -816,6 +826,7 @@ int flush;
|
||||||
else if (state->head != Z_NULL)
|
else if (state->head != Z_NULL)
|
||||||
state->head->comment = Z_NULL;
|
state->head->comment = Z_NULL;
|
||||||
state->mode = HCRC;
|
state->mode = HCRC;
|
||||||
|
/* fallthrough */
|
||||||
case HCRC:
|
case HCRC:
|
||||||
if (state->flags & 0x0200) {
|
if (state->flags & 0x0200) {
|
||||||
NEEDBITS(16);
|
NEEDBITS(16);
|
||||||
|
@ -839,6 +850,7 @@ int flush;
|
||||||
strm->adler = state->check = ZSWAP32(hold);
|
strm->adler = state->check = ZSWAP32(hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = DICT;
|
state->mode = DICT;
|
||||||
|
/* fallthrough */
|
||||||
case DICT:
|
case DICT:
|
||||||
if (state->havedict == 0) {
|
if (state->havedict == 0) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
|
@ -846,8 +858,10 @@ int flush;
|
||||||
}
|
}
|
||||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
|
/* fallthrough */
|
||||||
case TYPE:
|
case TYPE:
|
||||||
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
|
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
|
||||||
|
/* fallthrough */
|
||||||
case TYPEDO:
|
case TYPEDO:
|
||||||
if (state->last) {
|
if (state->last) {
|
||||||
BYTEBITS();
|
BYTEBITS();
|
||||||
|
@ -898,8 +912,10 @@ int flush;
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = COPY_;
|
state->mode = COPY_;
|
||||||
if (flush == Z_TREES) goto inf_leave;
|
if (flush == Z_TREES) goto inf_leave;
|
||||||
|
/* fallthrough */
|
||||||
case COPY_:
|
case COPY_:
|
||||||
state->mode = COPY;
|
state->mode = COPY;
|
||||||
|
/* fallthrough */
|
||||||
case COPY:
|
case COPY:
|
||||||
copy = state->length;
|
copy = state->length;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
|
@ -935,6 +951,7 @@ int flush;
|
||||||
Tracev((stderr, "inflate: table sizes ok\n"));
|
Tracev((stderr, "inflate: table sizes ok\n"));
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
state->mode = LENLENS;
|
state->mode = LENLENS;
|
||||||
|
/* fallthrough */
|
||||||
case LENLENS:
|
case LENLENS:
|
||||||
while (state->have < state->ncode) {
|
while (state->have < state->ncode) {
|
||||||
NEEDBITS(3);
|
NEEDBITS(3);
|
||||||
|
@ -956,6 +973,7 @@ int flush;
|
||||||
Tracev((stderr, "inflate: code lengths ok\n"));
|
Tracev((stderr, "inflate: code lengths ok\n"));
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
state->mode = CODELENS;
|
state->mode = CODELENS;
|
||||||
|
/* fallthrough */
|
||||||
case CODELENS:
|
case CODELENS:
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -1039,8 +1057,10 @@ int flush;
|
||||||
Tracev((stderr, "inflate: codes ok\n"));
|
Tracev((stderr, "inflate: codes ok\n"));
|
||||||
state->mode = LEN_;
|
state->mode = LEN_;
|
||||||
if (flush == Z_TREES) goto inf_leave;
|
if (flush == Z_TREES) goto inf_leave;
|
||||||
|
/* fallthrough */
|
||||||
case LEN_:
|
case LEN_:
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
|
/* fallthrough */
|
||||||
case LEN:
|
case LEN:
|
||||||
if (have >= 6 && left >= 258) {
|
if (have >= 6 && left >= 258) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
|
@ -1090,6 +1110,7 @@ int flush;
|
||||||
}
|
}
|
||||||
state->extra = (unsigned)(here.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = LENEXT;
|
state->mode = LENEXT;
|
||||||
|
/* fallthrough */
|
||||||
case LENEXT:
|
case LENEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
|
@ -1100,6 +1121,7 @@ int flush;
|
||||||
Tracevv((stderr, "inflate: length %u\n", state->length));
|
Tracevv((stderr, "inflate: length %u\n", state->length));
|
||||||
state->was = state->length;
|
state->was = state->length;
|
||||||
state->mode = DIST;
|
state->mode = DIST;
|
||||||
|
/* fallthrough */
|
||||||
case DIST:
|
case DIST:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
here = state->distcode[BITS(state->distbits)];
|
here = state->distcode[BITS(state->distbits)];
|
||||||
|
@ -1127,6 +1149,7 @@ int flush;
|
||||||
state->offset = (unsigned)here.val;
|
state->offset = (unsigned)here.val;
|
||||||
state->extra = (unsigned)(here.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = DISTEXT;
|
state->mode = DISTEXT;
|
||||||
|
/* fallthrough */
|
||||||
case DISTEXT:
|
case DISTEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
|
@ -1143,6 +1166,7 @@ int flush;
|
||||||
#endif
|
#endif
|
||||||
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
||||||
state->mode = MATCH;
|
state->mode = MATCH;
|
||||||
|
/* fallthrough */
|
||||||
case MATCH:
|
case MATCH:
|
||||||
if (left == 0) goto inf_leave;
|
if (left == 0) goto inf_leave;
|
||||||
copy = out - left;
|
copy = out - left;
|
||||||
|
@ -1202,7 +1226,7 @@ int flush;
|
||||||
state->total += out;
|
state->total += out;
|
||||||
if ((state->wrap & 4) && out)
|
if ((state->wrap & 4) && out)
|
||||||
strm->adler = state->check =
|
strm->adler = state->check =
|
||||||
UPDATE(state->check, put - out, out);
|
UPDATE_CHECK(state->check, put - out, out);
|
||||||
out = left;
|
out = left;
|
||||||
if ((state->wrap & 4) && (
|
if ((state->wrap & 4) && (
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
|
@ -1218,10 +1242,11 @@ int flush;
|
||||||
}
|
}
|
||||||
#ifdef GUNZIP
|
#ifdef GUNZIP
|
||||||
state->mode = LENGTH;
|
state->mode = LENGTH;
|
||||||
|
/* fallthrough */
|
||||||
case LENGTH:
|
case LENGTH:
|
||||||
if (state->wrap && state->flags) {
|
if (state->wrap && state->flags) {
|
||||||
NEEDBITS(32);
|
NEEDBITS(32);
|
||||||
if (hold != (state->total & 0xffffffffUL)) {
|
if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
|
||||||
strm->msg = (char *)"incorrect length check";
|
strm->msg = (char *)"incorrect length check";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
|
@ -1231,6 +1256,7 @@ int flush;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
state->mode = DONE;
|
state->mode = DONE;
|
||||||
|
/* fallthrough */
|
||||||
case DONE:
|
case DONE:
|
||||||
ret = Z_STREAM_END;
|
ret = Z_STREAM_END;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
@ -1240,6 +1266,7 @@ int flush;
|
||||||
case MEM:
|
case MEM:
|
||||||
return Z_MEM_ERROR;
|
return Z_MEM_ERROR;
|
||||||
case SYNC:
|
case SYNC:
|
||||||
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1265,7 +1292,7 @@ int flush;
|
||||||
state->total += out;
|
state->total += out;
|
||||||
if ((state->wrap & 4) && out)
|
if ((state->wrap & 4) && out)
|
||||||
strm->adler = state->check =
|
strm->adler = state->check =
|
||||||
UPDATE(state->check, strm->next_out - out, out);
|
UPDATE_CHECK(state->check, strm->next_out - out, out);
|
||||||
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
|
strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
|
||||||
(state->mode == TYPE ? 128 : 0) +
|
(state->mode == TYPE ? 128 : 0) +
|
||||||
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
||||||
|
@ -1401,6 +1428,7 @@ int ZEXPORT inflateSync(strm)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
{
|
{
|
||||||
unsigned len; /* number of bytes to look at or looked at */
|
unsigned len; /* number of bytes to look at or looked at */
|
||||||
|
int flags; /* temporary to save header status */
|
||||||
unsigned long in, out; /* temporary to save total_in and total_out */
|
unsigned long in, out; /* temporary to save total_in and total_out */
|
||||||
unsigned char buf[4]; /* to restore bit buffer to byte string */
|
unsigned char buf[4]; /* to restore bit buffer to byte string */
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
@ -1433,9 +1461,15 @@ z_streamp strm;
|
||||||
|
|
||||||
/* return no joy or set up to restart inflate() on a new block */
|
/* return no joy or set up to restart inflate() on a new block */
|
||||||
if (state->have != 4) return Z_DATA_ERROR;
|
if (state->have != 4) return Z_DATA_ERROR;
|
||||||
|
if (state->flags == -1)
|
||||||
|
state->wrap = 0; /* if no header yet, treat as raw */
|
||||||
|
else
|
||||||
|
state->wrap &= ~4; /* no point in computing a check value now */
|
||||||
|
flags = state->flags;
|
||||||
in = strm->total_in; out = strm->total_out;
|
in = strm->total_in; out = strm->total_out;
|
||||||
inflateReset(strm);
|
inflateReset(strm);
|
||||||
strm->total_in = in; strm->total_out = out;
|
strm->total_in = in; strm->total_out = out;
|
||||||
|
state->flags = flags;
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
@ -1531,7 +1565,7 @@ int check;
|
||||||
|
|
||||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
if (check)
|
if (check && state->wrap)
|
||||||
state->wrap |= 4;
|
state->wrap |= 4;
|
||||||
else
|
else
|
||||||
state->wrap &= ~4;
|
state->wrap &= ~4;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.h -- internal inflate state definition
|
/* inflate.h -- internal inflate state definition
|
||||||
* Copyright (C) 1995-2016 Mark Adler
|
* Copyright (C) 1995-2019 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -86,7 +86,8 @@ struct inflate_state {
|
||||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
|
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
|
||||||
bit 2 true to validate check value */
|
bit 2 true to validate check value */
|
||||||
int havedict; /* true if dictionary provided */
|
int havedict; /* true if dictionary provided */
|
||||||
int flags; /* gzip header method and flags (0 if zlib) */
|
int flags; /* gzip header method and flags, 0 if zlib, or
|
||||||
|
-1 if raw or no header yet */
|
||||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
||||||
unsigned long check; /* protected copy of check value */
|
unsigned long check; /* protected copy of check value */
|
||||||
unsigned long total; /* protected copy of output count */
|
unsigned long total; /* protected copy of output count */
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2017 Mark Adler
|
* Copyright (C) 1995-2022 Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
|
" inflate 1.2.13 Copyright 1995-2022 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
@ -62,7 +62,7 @@ unsigned short FAR *work;
|
||||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 194, 65};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||||
|
|
|
@ -38,7 +38,7 @@ typedef struct {
|
||||||
/* Maximum size of the dynamic table. The maximum number of code structures is
|
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||||
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
||||||
codes. These values were found by exhaustive searches using the program
|
codes. These values were found by exhaustive searches using the program
|
||||||
examples/enough.c found in the zlib distribtution. The arguments to that
|
examples/enough.c found in the zlib distribution. The arguments to that
|
||||||
program are the number of symbols, the initial root table size, and the
|
program are the number of symbols, the initial root table size, and the
|
||||||
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||||
returns returns 852, and "enough 30 6 15" for distance codes returns 592.
|
returns returns 852, and "enough 30 6 15" for distance codes returns 592.
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
# define crc32 z_crc32
|
# define crc32 z_crc32
|
||||||
# define crc32_combine z_crc32_combine
|
# define crc32_combine z_crc32_combine
|
||||||
# define crc32_combine64 z_crc32_combine64
|
# define crc32_combine64 z_crc32_combine64
|
||||||
|
# define crc32_combine_gen z_crc32_combine_gen
|
||||||
|
# define crc32_combine_gen64 z_crc32_combine_gen64
|
||||||
|
# define crc32_combine_op z_crc32_combine_op
|
||||||
# define crc32_z z_crc32_z
|
# define crc32_z z_crc32_z
|
||||||
# define deflate z_deflate
|
# define deflate z_deflate
|
||||||
# define deflateBound z_deflateBound
|
# define deflateBound z_deflateBound
|
||||||
|
@ -349,6 +352,9 @@
|
||||||
# ifdef FAR
|
# ifdef FAR
|
||||||
# undef FAR
|
# undef FAR
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# endif
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
/* No need for _export, use ZLIB.DEF instead. */
|
/* No need for _export, use ZLIB.DEF instead. */
|
||||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||||
|
@ -467,11 +473,18 @@ typedef uLong FAR uLongf;
|
||||||
# undef _LARGEFILE64_SOURCE
|
# undef _LARGEFILE64_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
|
#ifndef Z_HAVE_UNISTD_H
|
||||||
# define Z_HAVE_UNISTD_H
|
# ifdef __WATCOMC__
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef Z_HAVE_UNISTD_H
|
||||||
|
# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
|
||||||
|
# define Z_HAVE_UNISTD_H
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef Z_SOLO
|
#ifndef Z_SOLO
|
||||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
# if defined(Z_HAVE_UNISTD_H)
|
||||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||||
# ifdef VMS
|
# ifdef VMS
|
||||||
# include <unixio.h> /* for off_t */
|
# include <unixio.h> /* for off_t */
|
||||||
|
|
235
lib/zlib/zlib.h
235
lib/zlib/zlib.h
|
@ -1,7 +1,7 @@
|
||||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||||
version 1.2.11, January 15th, 2017
|
version 1.2.13, October 13th, 2022
|
||||||
|
|
||||||
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
|
Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
@ -37,11 +37,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZLIB_VERSION "1.2.11"
|
#define ZLIB_VERSION "1.2.13"
|
||||||
#define ZLIB_VERNUM 0x12b0
|
#define ZLIB_VERNUM 0x12d0
|
||||||
#define ZLIB_VER_MAJOR 1
|
#define ZLIB_VER_MAJOR 1
|
||||||
#define ZLIB_VER_MINOR 2
|
#define ZLIB_VER_MINOR 2
|
||||||
#define ZLIB_VER_REVISION 11
|
#define ZLIB_VER_REVISION 13
|
||||||
#define ZLIB_VER_SUBREVISION 0
|
#define ZLIB_VER_SUBREVISION 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -276,7 +276,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
||||||
== 0), or after each call of deflate(). If deflate returns Z_OK and with
|
== 0), or after each call of deflate(). If deflate returns Z_OK and with
|
||||||
zero avail_out, it must be called again after making room in the output
|
zero avail_out, it must be called again after making room in the output
|
||||||
buffer because there might be more output pending. See deflatePending(),
|
buffer because there might be more output pending. See deflatePending(),
|
||||||
which can be used if desired to determine whether or not there is more ouput
|
which can be used if desired to determine whether or not there is more output
|
||||||
in that case.
|
in that case.
|
||||||
|
|
||||||
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
|
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
|
||||||
|
@ -543,8 +543,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
||||||
int strategy));
|
int strategy));
|
||||||
|
|
||||||
This is another version of deflateInit with more compression options. The
|
This is another version of deflateInit with more compression options. The
|
||||||
fields next_in, zalloc, zfree and opaque must be initialized before by the
|
fields zalloc, zfree and opaque must be initialized before by the caller.
|
||||||
caller.
|
|
||||||
|
|
||||||
The method parameter is the compression method. It must be Z_DEFLATED in
|
The method parameter is the compression method. It must be Z_DEFLATED in
|
||||||
this version of the library.
|
this version of the library.
|
||||||
|
@ -661,7 +660,7 @@ ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
|
||||||
to dictionary. dictionary must have enough space, where 32768 bytes is
|
to dictionary. dictionary must have enough space, where 32768 bytes is
|
||||||
always enough. If deflateGetDictionary() is called with dictionary equal to
|
always enough. If deflateGetDictionary() is called with dictionary equal to
|
||||||
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
||||||
Similary, if dictLength is Z_NULL, then it is not set.
|
Similarly, if dictLength is Z_NULL, then it is not set.
|
||||||
|
|
||||||
deflateGetDictionary() may return a length less than the window size, even
|
deflateGetDictionary() may return a length less than the window size, even
|
||||||
when more than the window size in input has been provided. It may return up
|
when more than the window size in input has been provided. It may return up
|
||||||
|
@ -712,11 +711,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
|
||||||
used to switch between compression and straight copy of the input data, or
|
used to switch between compression and straight copy of the input data, or
|
||||||
to switch to a different kind of input data requiring a different strategy.
|
to switch to a different kind of input data requiring a different strategy.
|
||||||
If the compression approach (which is a function of the level) or the
|
If the compression approach (which is a function of the level) or the
|
||||||
strategy is changed, and if any input has been consumed in a previous
|
strategy is changed, and if there have been any deflate() calls since the
|
||||||
deflate() call, then the input available so far is compressed with the old
|
state was initialized or reset, then the input available so far is
|
||||||
level and strategy using deflate(strm, Z_BLOCK). There are three approaches
|
compressed with the old level and strategy using deflate(strm, Z_BLOCK).
|
||||||
for the compression levels 0, 1..3, and 4..9 respectively. The new level
|
There are three approaches for the compression levels 0, 1..3, and 4..9
|
||||||
and strategy will take effect at the next call of deflate().
|
respectively. The new level and strategy will take effect at the next call
|
||||||
|
of deflate().
|
||||||
|
|
||||||
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
|
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
|
||||||
not have enough output space to complete, then the parameter change will not
|
not have enough output space to complete, then the parameter change will not
|
||||||
|
@ -865,9 +865,11 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
||||||
detection, or add 16 to decode only the gzip format (the zlib format will
|
detection, or add 16 to decode only the gzip format (the zlib format will
|
||||||
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
|
return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
|
||||||
CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
|
CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
|
||||||
below), inflate() will not automatically decode concatenated gzip streams.
|
below), inflate() will *not* automatically decode concatenated gzip members.
|
||||||
inflate() will return Z_STREAM_END at the end of the gzip stream. The state
|
inflate() will return Z_STREAM_END at the end of the gzip member. The state
|
||||||
would need to be reset to continue decoding a subsequent gzip stream.
|
would need to be reset to continue decoding a subsequent gzip member. This
|
||||||
|
*must* be done if there is more data after a gzip member, in order for the
|
||||||
|
decompression to be compliant with the gzip standard (RFC 1952).
|
||||||
|
|
||||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
|
||||||
|
@ -913,7 +915,7 @@ ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
|
||||||
to dictionary. dictionary must have enough space, where 32768 bytes is
|
to dictionary. dictionary must have enough space, where 32768 bytes is
|
||||||
always enough. If inflateGetDictionary() is called with dictionary equal to
|
always enough. If inflateGetDictionary() is called with dictionary equal to
|
||||||
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
Z_NULL, then only the dictionary length is returned, and nothing is copied.
|
||||||
Similary, if dictLength is Z_NULL, then it is not set.
|
Similarly, if dictLength is Z_NULL, then it is not set.
|
||||||
|
|
||||||
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
|
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
|
||||||
stream state is inconsistent.
|
stream state is inconsistent.
|
||||||
|
@ -1302,14 +1304,14 @@ typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
|
||||||
/*
|
/*
|
||||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||||
|
|
||||||
Opens a gzip (.gz) file for reading or writing. The mode parameter is as
|
Open the gzip (.gz) file at path for reading and decompressing, or
|
||||||
in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
|
compressing and writing. The mode parameter is as in fopen ("rb" or "wb")
|
||||||
a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
|
but can also include a compression level ("wb9") or a strategy: 'f' for
|
||||||
compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
|
filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h",
|
||||||
for fixed code compression as in "wb9F". (See the description of
|
'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression
|
||||||
deflateInit2 for more information about the strategy parameter.) 'T' will
|
as in "wb9F". (See the description of deflateInit2 for more information
|
||||||
request transparent writing or appending with no compression and not using
|
about the strategy parameter.) 'T' will request transparent writing or
|
||||||
the gzip format.
|
appending with no compression and not using the gzip format.
|
||||||
|
|
||||||
"a" can be used instead of "w" to request that the gzip stream that will
|
"a" can be used instead of "w" to request that the gzip stream that will
|
||||||
be written be appended to the file. "+" will result in an error, since
|
be written be appended to the file. "+" will result in an error, since
|
||||||
|
@ -1339,9 +1341,9 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||||
|
|
||||||
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||||
/*
|
/*
|
||||||
gzdopen associates a gzFile with the file descriptor fd. File descriptors
|
Associate a gzFile with the file descriptor fd. File descriptors are
|
||||||
are obtained from calls like open, dup, creat, pipe or fileno (if the file
|
obtained from calls like open, dup, creat, pipe or fileno (if the file has
|
||||||
has been previously opened with fopen). The mode parameter is as in gzopen.
|
been previously opened with fopen). The mode parameter is as in gzopen.
|
||||||
|
|
||||||
The next call of gzclose on the returned gzFile will also close the file
|
The next call of gzclose on the returned gzFile will also close the file
|
||||||
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
|
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
|
||||||
|
@ -1362,13 +1364,13 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
|
ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
|
||||||
/*
|
/*
|
||||||
Set the internal buffer size used by this library's functions. The
|
Set the internal buffer size used by this library's functions for file to
|
||||||
default buffer size is 8192 bytes. This function must be called after
|
size. The default buffer size is 8192 bytes. This function must be called
|
||||||
gzopen() or gzdopen(), and before any other calls that read or write the
|
after gzopen() or gzdopen(), and before any other calls that read or write
|
||||||
file. The buffer memory allocation is always deferred to the first read or
|
the file. The buffer memory allocation is always deferred to the first read
|
||||||
write. Three times that size in buffer space is allocated. A larger buffer
|
or write. Three times that size in buffer space is allocated. A larger
|
||||||
size of, for example, 64K or 128K bytes will noticeably increase the speed
|
buffer size of, for example, 64K or 128K bytes will noticeably increase the
|
||||||
of decompression (reading).
|
speed of decompression (reading).
|
||||||
|
|
||||||
The new buffer size also affects the maximum length for gzprintf().
|
The new buffer size also affects the maximum length for gzprintf().
|
||||||
|
|
||||||
|
@ -1378,9 +1380,9 @@ ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
||||||
/*
|
/*
|
||||||
Dynamically update the compression level or strategy. See the description
|
Dynamically update the compression level and strategy for file. See the
|
||||||
of deflateInit2 for the meaning of these parameters. Previously provided
|
description of deflateInit2 for the meaning of these parameters. Previously
|
||||||
data is flushed before the parameter change.
|
provided data is flushed before applying the parameter changes.
|
||||||
|
|
||||||
gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
|
gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
|
||||||
opened for writing, Z_ERRNO if there is an error writing the flushed data,
|
opened for writing, Z_ERRNO if there is an error writing the flushed data,
|
||||||
|
@ -1389,7 +1391,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||||
/*
|
/*
|
||||||
Reads the given number of uncompressed bytes from the compressed file. If
|
Read and decompress up to len uncompressed bytes from file into buf. If
|
||||||
the input file is not in gzip format, gzread copies the given number of
|
the input file is not in gzip format, gzread copies the given number of
|
||||||
bytes into the buffer directly from the file.
|
bytes into the buffer directly from the file.
|
||||||
|
|
||||||
|
@ -1420,11 +1422,11 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||||
ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
|
ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
|
||||||
gzFile file));
|
gzFile file));
|
||||||
/*
|
/*
|
||||||
Read up to nitems items of size size from file to buf, otherwise operating
|
Read and decompress up to nitems items of size size from file into buf,
|
||||||
as gzread() does. This duplicates the interface of stdio's fread(), with
|
otherwise operating as gzread() does. This duplicates the interface of
|
||||||
size_t request and return types. If the library defines size_t, then
|
stdio's fread(), with size_t request and return types. If the library
|
||||||
z_size_t is identical to size_t. If not, then z_size_t is an unsigned
|
defines size_t, then z_size_t is identical to size_t. If not, then z_size_t
|
||||||
integer type that can contain a pointer.
|
is an unsigned integer type that can contain a pointer.
|
||||||
|
|
||||||
gzfread() returns the number of full items read of size size, or zero if
|
gzfread() returns the number of full items read of size size, or zero if
|
||||||
the end of the file was reached and a full item could not be read, or if
|
the end of the file was reached and a full item could not be read, or if
|
||||||
|
@ -1435,26 +1437,24 @@ ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
|
||||||
|
|
||||||
In the event that the end of file is reached and only a partial item is
|
In the event that the end of file is reached and only a partial item is
|
||||||
available at the end, i.e. the remaining uncompressed data length is not a
|
available at the end, i.e. the remaining uncompressed data length is not a
|
||||||
multiple of size, then the final partial item is nevetheless read into buf
|
multiple of size, then the final partial item is nevertheless read into buf
|
||||||
and the end-of-file flag is set. The length of the partial item read is not
|
and the end-of-file flag is set. The length of the partial item read is not
|
||||||
provided, but could be inferred from the result of gztell(). This behavior
|
provided, but could be inferred from the result of gztell(). This behavior
|
||||||
is the same as the behavior of fread() implementations in common libraries,
|
is the same as the behavior of fread() implementations in common libraries,
|
||||||
but it prevents the direct use of gzfread() to read a concurrently written
|
but it prevents the direct use of gzfread() to read a concurrently written
|
||||||
file, reseting and retrying on end-of-file, when size is not 1.
|
file, resetting and retrying on end-of-file, when size is not 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
|
ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len));
|
||||||
voidpc buf, unsigned len));
|
|
||||||
/*
|
/*
|
||||||
Writes the given number of uncompressed bytes into the compressed file.
|
Compress and write the len uncompressed bytes at buf to file. gzwrite
|
||||||
gzwrite returns the number of uncompressed bytes written or 0 in case of
|
returns the number of uncompressed bytes written or 0 in case of error.
|
||||||
error.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
|
ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
|
||||||
z_size_t nitems, gzFile file));
|
z_size_t nitems, gzFile file));
|
||||||
/*
|
/*
|
||||||
gzfwrite() writes nitems items of size size from buf to file, duplicating
|
Compress and write nitems items of size size from buf to file, duplicating
|
||||||
the interface of stdio's fwrite(), with size_t request and return types. If
|
the interface of stdio's fwrite(), with size_t request and return types. If
|
||||||
the library defines size_t, then z_size_t is identical to size_t. If not,
|
the library defines size_t, then z_size_t is identical to size_t. If not,
|
||||||
then z_size_t is an unsigned integer type that can contain a pointer.
|
then z_size_t is an unsigned integer type that can contain a pointer.
|
||||||
|
@ -1467,22 +1467,22 @@ ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
|
||||||
|
|
||||||
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
|
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
|
||||||
/*
|
/*
|
||||||
Converts, formats, and writes the arguments to the compressed file under
|
Convert, format, compress, and write the arguments (...) to file under
|
||||||
control of the format string, as in fprintf. gzprintf returns the number of
|
control of the string format, as in fprintf. gzprintf returns the number of
|
||||||
uncompressed bytes actually written, or a negative zlib error code in case
|
uncompressed bytes actually written, or a negative zlib error code in case
|
||||||
of error. The number of uncompressed bytes written is limited to 8191, or
|
of error. The number of uncompressed bytes written is limited to 8191, or
|
||||||
one less than the buffer size given to gzbuffer(). The caller should assure
|
one less than the buffer size given to gzbuffer(). The caller should assure
|
||||||
that this limit is not exceeded. If it is exceeded, then gzprintf() will
|
that this limit is not exceeded. If it is exceeded, then gzprintf() will
|
||||||
return an error (0) with nothing written. In this case, there may also be a
|
return an error (0) with nothing written. In this case, there may also be a
|
||||||
buffer overflow with unpredictable consequences, which is possible only if
|
buffer overflow with unpredictable consequences, which is possible only if
|
||||||
zlib was compiled with the insecure functions sprintf() or vsprintf()
|
zlib was compiled with the insecure functions sprintf() or vsprintf(),
|
||||||
because the secure snprintf() or vsnprintf() functions were not available.
|
because the secure snprintf() or vsnprintf() functions were not available.
|
||||||
This can be determined using zlibCompileFlags().
|
This can be determined using zlibCompileFlags().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||||
/*
|
/*
|
||||||
Writes the given null-terminated string to the compressed file, excluding
|
Compress and write the given null-terminated string s to file, excluding
|
||||||
the terminating null character.
|
the terminating null character.
|
||||||
|
|
||||||
gzputs returns the number of characters written, or -1 in case of error.
|
gzputs returns the number of characters written, or -1 in case of error.
|
||||||
|
@ -1490,11 +1490,12 @@ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||||
|
|
||||||
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||||
/*
|
/*
|
||||||
Reads bytes from the compressed file until len-1 characters are read, or a
|
Read and decompress bytes from file into buf, until len-1 characters are
|
||||||
newline character is read and transferred to buf, or an end-of-file
|
read, or until a newline character is read and transferred to buf, or an
|
||||||
condition is encountered. If any characters are read or if len == 1, the
|
end-of-file condition is encountered. If any characters are read or if len
|
||||||
string is terminated with a null character. If no characters are read due
|
is one, the string is terminated with a null character. If no characters
|
||||||
to an end-of-file or len < 1, then the buffer is left untouched.
|
are read due to an end-of-file or len is less than one, then the buffer is
|
||||||
|
left untouched.
|
||||||
|
|
||||||
gzgets returns buf which is a null-terminated string, or it returns NULL
|
gzgets returns buf which is a null-terminated string, or it returns NULL
|
||||||
for end-of-file or in case of error. If there was an error, the contents at
|
for end-of-file or in case of error. If there was an error, the contents at
|
||||||
|
@ -1503,13 +1504,13 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
||||||
/*
|
/*
|
||||||
Writes c, converted to an unsigned char, into the compressed file. gzputc
|
Compress and write c, converted to an unsigned char, into file. gzputc
|
||||||
returns the value that was written, or -1 in case of error.
|
returns the value that was written, or -1 in case of error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Reads one byte from the compressed file. gzgetc returns this byte or -1
|
Read and decompress one byte from file. gzgetc returns this byte or -1
|
||||||
in case of end of file or error. This is implemented as a macro for speed.
|
in case of end of file or error. This is implemented as a macro for speed.
|
||||||
As such, it does not do all of the checking the other functions do. I.e.
|
As such, it does not do all of the checking the other functions do. I.e.
|
||||||
it does not check to see if file is NULL, nor whether the structure file
|
it does not check to see if file is NULL, nor whether the structure file
|
||||||
|
@ -1518,8 +1519,8 @@ ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
||||||
/*
|
/*
|
||||||
Push one character back onto the stream to be read as the first character
|
Push c back onto the stream for file to be read as the first character on
|
||||||
on the next read. At least one character of push-back is allowed.
|
the next read. At least one character of push-back is always allowed.
|
||||||
gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
|
gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
|
||||||
fail if c is -1, and may fail if a character has been pushed but not read
|
fail if c is -1, and may fail if a character has been pushed but not read
|
||||||
yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
|
yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
|
||||||
|
@ -1530,9 +1531,9 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
||||||
/*
|
/*
|
||||||
Flushes all pending output into the compressed file. The parameter flush
|
Flush all pending output to file. The parameter flush is as in the
|
||||||
is as in the deflate() function. The return value is the zlib error number
|
deflate() function. The return value is the zlib error number (see function
|
||||||
(see function gzerror below). gzflush is only permitted when writing.
|
gzerror below). gzflush is only permitted when writing.
|
||||||
|
|
||||||
If the flush parameter is Z_FINISH, the remaining data is written and the
|
If the flush parameter is Z_FINISH, the remaining data is written and the
|
||||||
gzip stream is completed in the output. If gzwrite() is called again, a new
|
gzip stream is completed in the output. If gzwrite() is called again, a new
|
||||||
|
@ -1547,8 +1548,8 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
||||||
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||||
z_off_t offset, int whence));
|
z_off_t offset, int whence));
|
||||||
|
|
||||||
Sets the starting position for the next gzread or gzwrite on the given
|
Set the starting position to offset relative to whence for the next gzread
|
||||||
compressed file. The offset represents a number of bytes in the
|
or gzwrite on file. The offset represents a number of bytes in the
|
||||||
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
uncompressed data stream. The whence parameter is defined as in lseek(2);
|
||||||
the value SEEK_END is not supported.
|
the value SEEK_END is not supported.
|
||||||
|
|
||||||
|
@ -1565,18 +1566,18 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Rewinds the given file. This function is supported only for reading.
|
Rewind file. This function is supported only for reading.
|
||||||
|
|
||||||
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||||
|
|
||||||
Returns the starting position for the next gzread or gzwrite on the given
|
Return the starting position for the next gzread or gzwrite on file.
|
||||||
compressed file. This position represents a number of bytes in the
|
This position represents a number of bytes in the uncompressed data stream,
|
||||||
uncompressed data stream, and is zero when starting, even if appending or
|
and is zero when starting, even if appending or reading a gzip stream from
|
||||||
reading a gzip stream from the middle of a file using gzdopen().
|
the middle of a file using gzdopen().
|
||||||
|
|
||||||
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
||||||
*/
|
*/
|
||||||
|
@ -1584,22 +1585,22 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
|
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
|
||||||
|
|
||||||
Returns the current offset in the file being read or written. This offset
|
Return the current compressed (actual) read or write offset of file. This
|
||||||
includes the count of bytes that precede the gzip stream, for example when
|
offset includes the count of bytes that precede the gzip stream, for example
|
||||||
appending or when using gzdopen() for reading. When reading, the offset
|
when appending or when using gzdopen() for reading. When reading, the
|
||||||
does not include as yet unused buffered input. This information can be used
|
offset does not include as yet unused buffered input. This information can
|
||||||
for a progress indicator. On error, gzoffset() returns -1.
|
be used for a progress indicator. On error, gzoffset() returns -1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Returns true (1) if the end-of-file indicator has been set while reading,
|
Return true (1) if the end-of-file indicator for file has been set while
|
||||||
false (0) otherwise. Note that the end-of-file indicator is set only if the
|
reading, false (0) otherwise. Note that the end-of-file indicator is set
|
||||||
read tried to go past the end of the input, but came up short. Therefore,
|
only if the read tried to go past the end of the input, but came up short.
|
||||||
just like feof(), gzeof() may return false even if there is no more data to
|
Therefore, just like feof(), gzeof() may return false even if there is no
|
||||||
read, in the event that the last read request was for the exact number of
|
more data to read, in the event that the last read request was for the exact
|
||||||
bytes remaining in the input file. This will happen if the input file size
|
number of bytes remaining in the input file. This will happen if the input
|
||||||
is an exact multiple of the buffer size.
|
file size is an exact multiple of the buffer size.
|
||||||
|
|
||||||
If gzeof() returns true, then the read functions will return no more data,
|
If gzeof() returns true, then the read functions will return no more data,
|
||||||
unless the end-of-file indicator is reset by gzclearerr() and the input file
|
unless the end-of-file indicator is reset by gzclearerr() and the input file
|
||||||
|
@ -1608,7 +1609,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
|
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Returns true (1) if file is being copied directly while reading, or false
|
Return true (1) if file is being copied directly while reading, or false
|
||||||
(0) if file is a gzip stream being decompressed.
|
(0) if file is a gzip stream being decompressed.
|
||||||
|
|
||||||
If the input file is empty, gzdirect() will return true, since the input
|
If the input file is empty, gzdirect() will return true, since the input
|
||||||
|
@ -1629,8 +1630,8 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
|
||||||
|
|
||||||
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Flushes all pending output if necessary, closes the compressed file and
|
Flush all pending output for file, if necessary, close file and
|
||||||
deallocates the (de)compression state. Note that once file is closed, you
|
deallocate the (de)compression state. Note that once file is closed, you
|
||||||
cannot call gzerror with file, since its structures have been deallocated.
|
cannot call gzerror with file, since its structures have been deallocated.
|
||||||
gzclose must not be called more than once on the same file, just as free
|
gzclose must not be called more than once on the same file, just as free
|
||||||
must not be called more than once on the same allocation.
|
must not be called more than once on the same allocation.
|
||||||
|
@ -1654,10 +1655,10 @@ ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
|
||||||
|
|
||||||
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||||
/*
|
/*
|
||||||
Returns the error message for the last error which occurred on the given
|
Return the error message for the last error which occurred on file.
|
||||||
compressed file. errnum is set to zlib error number. If an error occurred
|
errnum is set to zlib error number. If an error occurred in the file system
|
||||||
in the file system and not in the compression library, errnum is set to
|
and not in the compression library, errnum is set to Z_ERRNO and the
|
||||||
Z_ERRNO and the application may consult errno to get the exact error code.
|
application may consult errno to get the exact error code.
|
||||||
|
|
||||||
The application must not modify the returned string. Future calls to
|
The application must not modify the returned string. Future calls to
|
||||||
this function may invalidate the previously returned string. If file is
|
this function may invalidate the previously returned string. If file is
|
||||||
|
@ -1670,7 +1671,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||||
|
|
||||||
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
||||||
/*
|
/*
|
||||||
Clears the error and end-of-file flags for file. This is analogous to the
|
Clear the error and end-of-file flags for file. This is analogous to the
|
||||||
clearerr() function in stdio. This is useful for continuing to read a gzip
|
clearerr() function in stdio. This is useful for continuing to read a gzip
|
||||||
file that is being written concurrently.
|
file that is being written concurrently.
|
||||||
*/
|
*/
|
||||||
|
@ -1688,8 +1689,9 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
||||||
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||||
/*
|
/*
|
||||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||||
return the updated checksum. If buf is Z_NULL, this function returns the
|
return the updated checksum. An Adler-32 value is in the range of a 32-bit
|
||||||
required initial value for the checksum.
|
unsigned integer. If buf is Z_NULL, this function returns the required
|
||||||
|
initial value for the checksum.
|
||||||
|
|
||||||
An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
|
An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
|
||||||
much faster.
|
much faster.
|
||||||
|
@ -1722,12 +1724,13 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
|
||||||
negative, the result has no meaning or utility.
|
negative, the result has no meaning or utility.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||||
/*
|
/*
|
||||||
Update a running CRC-32 with the bytes buf[0..len-1] and return the
|
Update a running CRC-32 with the bytes buf[0..len-1] and return the
|
||||||
updated CRC-32. If buf is Z_NULL, this function returns the required
|
updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer.
|
||||||
initial value for the crc. Pre- and post-conditioning (one's complement) is
|
If buf is Z_NULL, this function returns the required initial value for the
|
||||||
performed within this function so it shouldn't be done by the application.
|
crc. Pre- and post-conditioning (one's complement) is performed within this
|
||||||
|
function so it shouldn't be done by the application.
|
||||||
|
|
||||||
Usage example:
|
Usage example:
|
||||||
|
|
||||||
|
@ -1739,7 +1742,7 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||||
if (crc != original_crc) error();
|
if (crc != original_crc) error();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
|
ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf,
|
||||||
z_size_t len));
|
z_size_t len));
|
||||||
/*
|
/*
|
||||||
Same as crc32(), but with a size_t length.
|
Same as crc32(), but with a size_t length.
|
||||||
|
@ -1755,6 +1758,20 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
|
||||||
len2.
|
len2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2));
|
||||||
|
|
||||||
|
Return the operator corresponding to length len2, to be used with
|
||||||
|
crc32_combine_op().
|
||||||
|
*/
|
||||||
|
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op));
|
||||||
|
/*
|
||||||
|
Give the same result as crc32_combine(), using op in place of len2. op is
|
||||||
|
is generated from len2 by crc32_combine_gen(). This will be faster than
|
||||||
|
crc32_combine() if the generated op is used more than once.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* various hacks, don't look :) */
|
/* various hacks, don't look :) */
|
||||||
|
|
||||||
|
@ -1842,6 +1859,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
|
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
|
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
|
||||||
|
@ -1852,6 +1870,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
# define z_gzoffset z_gzoffset64
|
# define z_gzoffset z_gzoffset64
|
||||||
# define z_adler32_combine z_adler32_combine64
|
# define z_adler32_combine z_adler32_combine64
|
||||||
# define z_crc32_combine z_crc32_combine64
|
# define z_crc32_combine z_crc32_combine64
|
||||||
|
# define z_crc32_combine_gen z_crc32_combine_gen64
|
||||||
# else
|
# else
|
||||||
# define gzopen gzopen64
|
# define gzopen gzopen64
|
||||||
# define gzseek gzseek64
|
# define gzseek gzseek64
|
||||||
|
@ -1859,6 +1878,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
# define gzoffset gzoffset64
|
# define gzoffset gzoffset64
|
||||||
# define adler32_combine adler32_combine64
|
# define adler32_combine adler32_combine64
|
||||||
# define crc32_combine crc32_combine64
|
# define crc32_combine crc32_combine64
|
||||||
|
# define crc32_combine_gen crc32_combine_gen64
|
||||||
# endif
|
# endif
|
||||||
# ifndef Z_LARGE64
|
# ifndef Z_LARGE64
|
||||||
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
|
||||||
|
@ -1867,6 +1887,7 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
|
ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
|
ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
|
||||||
|
@ -1875,12 +1896,14 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
|
||||||
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
|
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* Z_SOLO */
|
#else /* Z_SOLO */
|
||||||
|
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t));
|
||||||
|
|
||||||
#endif /* !Z_SOLO */
|
#endif /* !Z_SOLO */
|
||||||
|
|
||||||
|
@ -1890,10 +1913,10 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
|
||||||
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
|
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
|
||||||
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
|
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
|
||||||
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
|
ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int));
|
||||||
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp));
|
ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp));
|
||||||
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
|
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
|
||||||
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
|
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
|
||||||
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
|
#if defined(_WIN32) && !defined(Z_SOLO)
|
||||||
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
|
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
|
||||||
const char *mode));
|
const char *mode));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,9 +61,11 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
#ifdef ZLIB_DEBUG
|
#ifdef ZLIB_DEBUG
|
||||||
flags += 1 << 8;
|
flags += 1 << 8;
|
||||||
#endif
|
#endif
|
||||||
|
/*
|
||||||
#if defined(ASMV) || defined(ASMINF)
|
#if defined(ASMV) || defined(ASMINF)
|
||||||
flags += 1 << 9;
|
flags += 1 << 9;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
#ifdef ZLIB_WINAPI
|
#ifdef ZLIB_WINAPI
|
||||||
flags += 1 << 10;
|
flags += 1 << 10;
|
||||||
#endif
|
#endif
|
||||||
|
@ -119,7 +121,7 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
# endif
|
# endif
|
||||||
int ZLIB_INTERNAL z_verbose = verbose;
|
int ZLIB_INTERNAL z_verbose = verbose;
|
||||||
|
|
||||||
void ZLIB_INTERNAL z_error (m)
|
void ZLIB_INTERNAL z_error(m)
|
||||||
char *m;
|
char *m;
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n", m);
|
fprintf(stderr, "%s\n", m);
|
||||||
|
@ -136,8 +138,8 @@ const char * ZEXPORT zError(err)
|
||||||
return ERR_MSG(err);
|
return ERR_MSG(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32_WCE)
|
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
|
||||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
/* The older Microsoft C Run-Time Library for Windows CE doesn't have
|
||||||
* errno. We define it as a global variable to simplify porting.
|
* errno. We define it as a global variable to simplify porting.
|
||||||
* Its value is always 0 and should not be used.
|
* Its value is always 0 and should not be used.
|
||||||
*/
|
*/
|
||||||
|
@ -214,7 +216,7 @@ local ptr_table table[MAX_PTR];
|
||||||
* a protected system like OS/2. Use Microsoft C instead.
|
* a protected system like OS/2. Use Microsoft C instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
|
||||||
{
|
{
|
||||||
voidpf buf;
|
voidpf buf;
|
||||||
ulg bsize = (ulg)items*size;
|
ulg bsize = (ulg)items*size;
|
||||||
|
@ -240,7 +242,7 @@ voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
@ -277,13 +279,13 @@ void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
||||||
# define _hfree hfree
|
# define _hfree hfree
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
|
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size)
|
||||||
{
|
{
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
return _halloc((long)items, size);
|
return _halloc((long)items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
|
||||||
{
|
{
|
||||||
(void)opaque;
|
(void)opaque;
|
||||||
_hfree(ptr);
|
_hfree(ptr);
|
||||||
|
@ -302,7 +304,7 @@ extern voidp calloc OF((uInt items, uInt size));
|
||||||
extern void free OF((voidpf ptr));
|
extern void free OF((voidpf ptr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
|
voidpf ZLIB_INTERNAL zcalloc(opaque, items, size)
|
||||||
voidpf opaque;
|
voidpf opaque;
|
||||||
unsigned items;
|
unsigned items;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
|
@ -312,7 +314,7 @@ voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
|
||||||
(voidpf)calloc(items, size);
|
(voidpf)calloc(items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZLIB_INTERNAL zcfree (opaque, ptr)
|
void ZLIB_INTERNAL zcfree(opaque, ptr)
|
||||||
voidpf opaque;
|
voidpf opaque;
|
||||||
voidpf ptr;
|
voidpf ptr;
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* zutil.h -- internal interface and configuration of the compression library
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
* Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -29,10 +29,6 @@
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Z_SOLO
|
|
||||||
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef local
|
#ifndef local
|
||||||
# define local static
|
# define local static
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,6 +42,17 @@ typedef unsigned short ush;
|
||||||
typedef ush FAR ushf;
|
typedef ush FAR ushf;
|
||||||
typedef unsigned long ulg;
|
typedef unsigned long ulg;
|
||||||
|
|
||||||
|
#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC)
|
||||||
|
# include <limits.h>
|
||||||
|
# if (ULONG_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned long
|
||||||
|
# elif (ULLONG_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned long long
|
||||||
|
# elif (UINT_MAX == 0xffffffffffffffff)
|
||||||
|
# define Z_U8 unsigned
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
/* (size given to avoid silly warnings with Visual C++) */
|
/* (size given to avoid silly warnings with Visual C++) */
|
||||||
|
|
||||||
|
@ -170,10 +177,6 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
||||||
# if defined(_WIN32_WCE)
|
# if defined(_WIN32_WCE)
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
# ifndef _PTRDIFF_T_DEFINED
|
|
||||||
typedef int ptrdiff_t;
|
|
||||||
# define _PTRDIFF_T_DEFINED
|
|
||||||
# endif
|
|
||||||
# else
|
# else
|
||||||
# define fdopen(fd,type) _fdopen(fd,type)
|
# define fdopen(fd,type) _fdopen(fd,type)
|
||||||
# endif
|
# endif
|
||||||
|
@ -190,6 +193,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* common defaults */
|
/* common defaults */
|
||||||
|
|
Loading…
Add table
Reference in a new issue