Skip to content

Instantly share code, notes, and snippets.

@daniellandau
Created May 15, 2018 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniellandau/bb515809406b527371a7d4ddb7f245e9 to your computer and use it in GitHub Desktop.
Save daniellandau/bb515809406b527371a7d4ddb7f245e9 to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*/
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*/
/*
* Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*/
/*
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*/
/*
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*/
/*!
* @addtogroup config
* @{
* @file
*/
////////////////////////////////////////////////////////////////////////////////
// Declarations
////////////////////////////////////////////////////////////////////////////////
//! @name Threading model options
//@{
//@}
//! @name Configuration options
//@{
//! @def ERPC_THREADS
//!
//! @brief Select threading model.
//!
//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC.
//!
//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads.
//! FreeRTOS can be detected when building with compilers that support __has_include().
//! Otherwise, the default is no threading.
//#define ERPC_THREADS (ERPC_THREADS_FREERTOS)
//! @def ERPC_DEFAULT_BUFFER_SIZE
//!
//! Uncomment to change the size of buffers allocated by BasicMessageBufferFactory in the client
//! and server setup functions (@ref client_setup and @ref server_setup). The default size is 256.
//#define ERPC_DEFAULT_BUFFER_SIZE (256)
//@}
/*! @} */
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Declarations
////////////////////////////////////////////////////////////////////////////////
/* clang-format off */
// Determine if this is a POSIX system.
// Detect Linux, BSD, Cygwin, and Mac OS X.
// Safely detect FreeRTOSConfig.h.
// Detect threading model if not already set.
// Use FreeRTOS if we can auto detect it.
// Handy macro to test threading model. You can also ERPC_THREADS directly to test for threading
// support, i.e. "#if ERPC_THREADS", because ERPC_THREADS_NONE has a value of 0.
// Set default buffer size.
//! @brief Size of buffers allocated by BasicMessageBufferFactory in setup functions.
// Set default buffers count.
//! @brief Count of buffers allocated by StaticMessageBufferFactory.
/* clang-format on */
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
stdint.h synopsis
Macros:
INT8_MIN
INT16_MIN
INT32_MIN
INT64_MIN
INT8_MAX
INT16_MAX
INT32_MAX
INT64_MAX
UINT8_MAX
UINT16_MAX
UINT32_MAX
UINT64_MAX
INT_LEAST8_MIN
INT_LEAST16_MIN
INT_LEAST32_MIN
INT_LEAST64_MIN
INT_LEAST8_MAX
INT_LEAST16_MAX
INT_LEAST32_MAX
INT_LEAST64_MAX
UINT_LEAST8_MAX
UINT_LEAST16_MAX
UINT_LEAST32_MAX
UINT_LEAST64_MAX
INT_FAST8_MIN
INT_FAST16_MIN
INT_FAST32_MIN
INT_FAST64_MIN
INT_FAST8_MAX
INT_FAST16_MAX
INT_FAST32_MAX
INT_FAST64_MAX
UINT_FAST8_MAX
UINT_FAST16_MAX
UINT_FAST32_MAX
UINT_FAST64_MAX
INTPTR_MIN
INTPTR_MAX
UINTPTR_MAX
INTMAX_MIN
INTMAX_MAX
UINTMAX_MAX
PTRDIFF_MIN
PTRDIFF_MAX
SIG_ATOMIC_MIN
SIG_ATOMIC_MAX
SIZE_MAX
WCHAR_MIN
WCHAR_MAX
WINT_MIN
WINT_MAX
INT8_C(value)
INT16_C(value)
INT32_C(value)
INT64_C(value)
UINT8_C(value)
UINT16_C(value)
UINT32_C(value)
UINT64_C(value)
INTMAX_C(value)
UINTMAX_C(value)
*/
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
#pragma diag_push
/* Avoid warning on C++ comments in this file */
#pragma diag_suppress 2581
#pragma CHECK_MISRA("-2.2")
#pragma CHECK_MISRA("-19.4")
#pragma CHECK_MISRA("-19.10")
// The libc++ cmake build system expects to preinclude __config site during
// library builds (_LIBCPP_BUILDING_LIBRARY defined). Then, as part of
// installation, will prepend the contents of __config_site to __config and
// install the result as __config. __config_site does not exist as part of the
// cmake installation.
//
// The TI mkrts system follows the same behavior while bulding the library.
// However, it does not support prepending as part of installation, and so must
// have __config_site exist separately as a pre-generated file.
//
// To ensure that the cmake system still works, we only include __config_site
// when it exists as part of an installation. That is: If a TI compiler is
// being used, the library has been built/installed, and __config_site exists.
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/* #undef _LIBCPP_ABI_UNSTABLE */
/* #undef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE */
/* #undef _LIBCPP_HAS_NO_STDIN */
/* #undef _LIBCPP_HAS_NO_STDOUT */
/* #undef _LIBCPP_HAS_NO_MONOTONIC_CLOCK */
/* #undef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS */
/* #undef _LIBCPP_HAS_MUSL_LIBC */
/* #undef _LIBCPP_HAS_THREAD_API_PTHREAD */
/* #undef _LIBCPP_HAS_THREAD_API_EXTERNAL */
/* #undef _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL */
/*****************************************************************************/
/* LIBCXX_EXTRA.H */
/* */
/* Copyright (c) 2017 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
/*
Changes made to this file affect how TI libc++ is BOTH built and used in
production environments.
*/
/*
The TI RTS has all source and header files flattened into a single directory.
*/
/* #pragma diag_suppress 1585,2866 */
// Change short string representation so that string data starts at offset 0,
// improving its alignment in some cases.
// Fix deque iterator type in order to support incomplete types.
// Fix undefined behavior in how std::list stores its linked nodes.
// Fix undefined behavior in how __tree stores its end and parent nodes.
// Fix undefined behavior in how __hash_table stores its pointer types.
// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr
// provided under the alternate keyword __nullptr, which changes the mangling
// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode.
// Define the `pointer_safety` enum as a C++11 strongly typed enumeration
// instead of as a class simulating an enum. If this option is enabled
// `pointer_safety` and `get_pointer_safety()` will no longer be available
// in C++03.
// Define a key function for `bad_function_call` in the library, to centralize
// its vtable and typeinfo to libc++ rather than having all other libraries
// using that class define their own copies.
// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
// the compiler and '1' otherwise.
// FIXME: ABI detection should be done via compiler builtin macros. This
// is just a placeholder until Clang implements such macros. For now assume
// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
// and allow the user to explicitly specify the ABI to handle cases where this
// heuristic falls short.
// Need to detect which libc we're using if we're on Linux.
// __builtin_strlen can be trivially replaced, but with a hefty runtime cost
// TI targets do not support aligned operator new()
// Currently a dummy value. std::strerror will return "Unknown" for errors that
// are out of the range of those we can print.
// EDG supports __is_literal_type, which is analagous to __is_literal
// TI compilers using libc++ always accept inline namespaces
namespace std {
inline namespace __2 {
}
}
// Allow for build-time disabling of unsigned integer sanitization
// The TI compiler is strict about the difference between extern "C" and
// extern "C++" functions. One cannot be conflated with the other, even if
// the types are otherwise the same.
// FIXME: Remove all usages of this macro once compilers catch up.
// Try to find out if RTTI is disabled.
// g++ and cl.exe have RTTI on by default and define a macro when it is.
// g++ only defines the macro in 4.3.2 and onwards.
// Thread API
// Systems that use capability-based security (FreeBSD with Capsicum,
// Nuxi CloudABI) may only provide local filesystem access (using *at()).
// Functions like open(), rename(), unlink() and stat() should not be
// used, as they attempt to access the global filesystem namespace.
// CloudABI is intended for running networked services. Processes do not
// have standard input and output channels.
// Thread-unsafe functions such as strtok() and localtime()
// are not available.
// Decide whether to use availability macros.
// Define availability macros.
// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
// Availability of stream API in the dylib got dropped and re-added. The
// extern template should effectively be available at:
// availability(macosx,introduced=10.9)
// availability(ios,introduced=7.0)
// Don't warn about macro conflicts when we can restore them at the
// end of the header.
#pragma diag_pop
/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
are defined
*/
/*****************************************************************************/
/* STDINT.H */
/* */
/* Copyright (c) 2002 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
/*-
* 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$
*/
#pragma diag_push
#pragma CHECK_MISRA("none")
/*
* Testing against Clang-specific extensions.
*/
/*
* 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.
*/
/*
* Macro to test if we're using a specific version of gcc or later.
*/
/*
* 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.
*/
/*
* 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.
*/
/*
* TI ADD - check that __GNUC__ is defined before referencing it to avoid
* generating an error when __GNUC__ treated as zero warning is
* promoted to an error via -pdse195 option.
*/
/*
* Keywords added in C11.
*/
/*
* 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.
*/
/*
* 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.
*/
/*
* 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)]);
*/
/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
/* C++11 exposes a load of C99 stuff */
/*
* 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.
* The TI compiler supports __restrict in all compilation modes.
*/
/*
* 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.
*/
/*
* We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
* require it.
*/
/*
* 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.
*/
/*
* 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).
*/
/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
/*
* 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
*/
/*
* 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$");
*/
/*-
* 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:
* defined(_POSIX_SOURCE) 1003.1-1988
* _POSIX_C_SOURCE == 1 1003.1-1990
* _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
* _POSIX_C_SOURCE == 199309 1003.1b-1993
* _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
* and the omnibus ISO/IEC 9945-1: 1996
* _POSIX_C_SOURCE == 200112 1003.1-2001
* _POSIX_C_SOURCE == 200809 1003.1-2008
*
* 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. */
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
/*
* Deal with all versions of POSIX. The ordering relative to the tests above is
* important.
*/
/*-
* 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).
*/
/* User override __EXT1_VISIBLE */
/*
* 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.
*/
/*
* Nullability qualifiers: currently only supported by Clang.
*/
/*
* Type Safety Checking
*
* Clang provides additional attributes to enable checking type safety
* properties that cannot be enforced by the C type system.
*/
/*
* 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.
*/
/* Structure implements a lock. */
/* Function acquires an exclusive or shared lock. */
/* Function attempts to acquire an exclusive or shared lock. */
/* Function releases a lock. */
/* Function asserts that an exclusive or shared lock is held. */
/* Function requires that an exclusive or shared lock is or is not held. */
/* Function should not be analyzed. */
/* Guard variables and structure members by lock. */
#pragma diag_pop
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
/*-
* SPDX-License-Identifier: BSD-4-Clause
*
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
* Copyright (c) 1990, 1993
* The 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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: @(#)ansi.h 8.2 (Berkeley) 1/4/94
* From: @(#)types.h 8.3 (Berkeley) 1/5/94
* $FreeBSD$
*/
#pragma diag_push
/* This file is required to use base types */
#pragma CHECK_MISRA("-6.3")
/*
* Basic types upon which most other types are built.
*/
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
/* LONGLONG */
typedef long long __int64_t;
/* LONGLONG */
typedef unsigned long long __uint64_t;
/*
* Standard type definitions.
*/
typedef __uint32_t __clock_t; /* clock()... */
typedef __int32_t __critical_t;
typedef double __double_t;
typedef float __float_t;
typedef __int32_t __intfptr_t;
typedef __int64_t __intmax_t;
typedef __int32_t __intptr_t;
typedef __int32_t __int_fast8_t;
typedef __int32_t __int_fast16_t;
typedef __int32_t __int_fast32_t;
typedef __int64_t __int_fast64_t;
typedef __int8_t __int_least8_t;
typedef __int16_t __int_least16_t;
typedef __int32_t __int_least32_t;
typedef __int64_t __int_least64_t;
typedef __int32_t __ptrdiff_t; /* ptr1 - ptr2 */
typedef __int32_t __register_t;
typedef __int32_t __segsz_t; /* segment size (in pages) */
typedef __uint32_t __size_t; /* sizeof() */
typedef __int32_t __ssize_t; /* byte count or error */
typedef __uint32_t __time_t;
typedef __uint32_t __uintfptr_t;
typedef __uint64_t __uintmax_t;
typedef __uint32_t __uintptr_t;
typedef __uint32_t __uint_fast8_t;
typedef __uint32_t __uint_fast16_t;
typedef __uint32_t __uint_fast32_t;
typedef __uint64_t __uint_fast64_t;
typedef __uint8_t __uint_least8_t;
typedef __uint16_t __uint_least16_t;
typedef __uint32_t __uint_least32_t;
typedef __uint64_t __uint_least64_t;
typedef __uint32_t __u_register_t;
typedef __uint32_t __vm_offset_t;
typedef __uint32_t __vm_paddr_t;
typedef __uint32_t __vm_size_t;
typedef unsigned short ___wchar_t;
/*
* Unusual type definitions.
*/
typedef struct __va_list_t {
void * __ap;
} __va_list;
#pragma diag_pop
#pragma diag_push
/* This file is required to use types without size and signedness */
#pragma CHECK_MISRA("-6.3")
/*
* Standard type definitions.
*/
typedef __int32_t __blksize_t; /* file block size */
typedef __int64_t __blkcnt_t; /* file block count */
typedef __int32_t __clockid_t; /* clock_gettime()... */
typedef __uint32_t __fflags_t; /* file flags */
typedef __uint64_t __fsblkcnt_t;
typedef __uint64_t __fsfilcnt_t;
typedef __uint32_t __gid_t;
typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */
typedef __uint64_t __ino_t; /* inode number */
typedef long __key_t; /* IPC key (for Sys V IPC) */
typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */
typedef __uint16_t __mode_t; /* permissions */
typedef int __accmode_t; /* access permissions */
typedef int __nl_item;
typedef __uint64_t __nlink_t; /* link count */
typedef __int64_t __off_t; /* file offset */
typedef __int64_t __off64_t; /* file offset (alias) */
typedef __int32_t __pid_t; /* process [group] */
typedef __int64_t __rlim_t; /* resource limit - intentionally */
/* signed, because of legacy code */
/* that uses -1 for RLIM_INFINITY */
typedef __uint8_t __sa_family_t;
typedef __uint32_t __socklen_t;
typedef long __suseconds_t; /* microseconds (signed) */
typedef struct __timer *__timer_t; /* timer_gettime()... */
typedef struct __mq *__mqd_t; /* mq_open()... */
typedef __uint32_t __uid_t;
typedef unsigned int __useconds_t; /* microseconds (unsigned) */
typedef int __cpuwhich_t; /* which parameter for cpuset. */
typedef int __cpulevel_t; /* level parameter for cpuset. */
typedef int __cpusetid_t; /* cpuset identifier. */
/*
* Unusual type definitions.
*/
/*
* rune_t is declared to be an ``int'' instead of the more natural
* ``unsigned long'' or ``long''. Two things are happening here. It is not
* unsigned so that EOF (-1) can be naturally assigned to it and used. Also,
* it looks like 10646 will be a 31 bit standard. This means that if your
* ints cannot hold 32 bits, you will be in trouble. The reason an int was
* chosen over a long is that the is*() and to*() routines take ints (says
* ANSI C), but they use __ct_rune_t instead of int.
*
* NOTE: rune_t is not covered by ANSI nor other standards, and should not
* be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and
* rune_t must be the same type. Also, wint_t should be able to hold all
* members of the largest character set plus one extra value (WEOF), and
* must be at least 16 bits.
*/
typedef int __ct_rune_t; /* arg type for ctype funcs */
typedef __ct_rune_t __rune_t; /* rune_t (see above) */
typedef __ct_rune_t __wint_t; /* wint_t (see above) */
/* Clang already provides these types as built-ins, but only in C++ mode. */
typedef __uint_least16_t __char16_t;
typedef __uint_least32_t __char32_t;
/* In C++11, char16_t and char32_t are built-in types. */
typedef struct {
long long __max_align1 __attribute__((__aligned__(alignof(long long))));
long double __max_align2 __attribute__((__aligned__(alignof(long double))));
} __max_align_t;
typedef __uint64_t __dev_t; /* device number */
typedef __uint32_t __fixpt_t; /* fixed point number */
/*
* mbstate_t is an opaque object to keep conversion state during multibyte
* stream conversions.
*/
typedef int _Mbstatet;
typedef _Mbstatet __mbstate_t;
typedef __uintmax_t __rman_res_t;
/*
* When the following macro is defined, the system uses 64-bit inode numbers.
* Programs can use this to avoid including <sys/param.h>, with its associated
* namespace pollution.
*/
#pragma diag_pop
/*-
* SPDX-License-Identifier: BSD-2-Clause-NetBSD
*
* Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org>
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*
* $FreeBSD$
*/
#pragma diag_push
/* 19.4 is issued for macros that are defined in terms of other macros. */
#pragma CHECK_MISRA("-19.4")
/*
* ISO/IEC 9899:1999
* 7.18.2.1 Limits of exact-width integer types
*/
/* Minimum values of exact-width signed integer types. */
/* Maximum values of exact-width signed integer types. */
/* Maximum values of exact-width unsigned integer types. */
/*
* ISO/IEC 9899:1999
* 7.18.2.2 Limits of minimum-width integer types
*/
/* Minimum values of minimum-width signed integer types. */
/* Maximum values of minimum-width signed integer types. */
/* Maximum values of minimum-width unsigned integer types. */
/*
* ISO/IEC 9899:1999
* 7.18.2.3 Limits of fastest minimum-width integer types
*/
/* Minimum values of fastest minimum-width signed integer types. */
/* Maximum values of fastest minimum-width signed integer types. */
/* Maximum values of fastest minimum-width unsigned integer types. */
/*
* ISO/IEC 9899:1999
* 7.18.2.4 Limits of integer types capable of holding object pointers
*/
/*
* ISO/IEC 9899:1999
* 7.18.2.5 Limits of greatest-width integer types
*/
/*
* ISO/IEC 9899:1999
* 7.18.3 Limits of other integer types
*/
/* Limits of ptrdiff_t. */
/* Limits of sig_atomic_t. */
/* Limit of size_t. */
/* Limits of wint_t. */
#pragma diag_pop
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org>
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;
typedef __uint8_t uint8_t;
typedef __uint16_t uint16_t;
typedef __uint32_t uint32_t;
typedef __uint64_t uint64_t;
typedef __intptr_t intptr_t;
typedef __uintptr_t uintptr_t;
typedef __intmax_t intmax_t;
typedef __uintmax_t uintmax_t;
typedef __int_least8_t int_least8_t;
typedef __int_least16_t int_least16_t;
typedef __int_least32_t int_least32_t;
typedef __int_least64_t int_least64_t;
typedef __uint_least8_t uint_least8_t;
typedef __uint_least16_t uint_least16_t;
typedef __uint_least32_t uint_least32_t;
typedef __uint_least64_t uint_least64_t;
typedef __int_fast8_t int_fast8_t;
typedef __int_fast16_t int_fast16_t;
typedef __int_fast32_t int_fast32_t;
typedef __int_fast64_t int_fast64_t;
typedef __uint_fast8_t uint_fast8_t;
typedef __uint_fast16_t uint_fast16_t;
typedef __uint_fast32_t uint_fast32_t;
typedef __uint_fast64_t uint_fast64_t;
/* GNU and Darwin define this and people seem to think it's portable */
#pragma diag_push
#pragma CHECK_MISRA("-19.4")
/* Limits of wchar_t. */
#pragma diag_pop
/* ISO/IEC 9899:2011 K.3.4.4 */
// Exclude the rest of the file if threading is disabled.
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*
* Include the generic headers required for the FreeRTOS port being used.
*/
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
stddef.h synopsis
Macros:
offsetof(type,member-designator)
NULL
Types:
ptrdiff_t
size_t
max_align_t
nullptr_t
*/
/*****************************************************************************/
/* stddef.h */
/* */
/* Copyright (c) 1993 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
#pragma diag_push
#pragma CHECK_MISRA("-19.7") /* macros required for implementation */
#pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
#pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */
extern "C" {
typedef int ptrdiff_t;
typedef unsigned size_t;
/*----------------------------------------------------------------------------*/
/* C++11 and C11 required max_align_t to be defined. The libc++ cstddef */
/* header expects the macro __DEFINED_max_align_t to be defined if it is to */
/* use the definintion of max_align_t from stddef.h. Only define it if */
/* compiling for C11 or we're in non strict ansi mode. */
/*----------------------------------------------------------------------------*/
typedef long double max_align_t;
#pragma diag_push
#pragma CHECK_MISRA("-19.10") /* need types as macro arguments */
} /* extern "C" */
#pragma diag_pop
extern "C++" {
// -*- C++ -*-
//===--------------------------- __nullptr --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
namespace std
{
typedef decltype(nullptr) nullptr_t;
}
using std::nullptr_t;
}
/* Re-use the compiler's <stddef.h> max_align_t where possible. */
/*
* If stdint.h cannot be located then:
* + If using GCC ensure the -nostdint options is *not* being used.
* + Ensure the project's include path includes the directory in which your
* compiler stores stdint.h.
* + Set any compiler options necessary for it to support C99, as technically
* stdint.h is only mandatory with C99 (FreeRTOS does not require C99 in any
* other way).
* + The FreeRTOS download includes a simple stdint.h definition that can be
* used in cases where none is provided by the compiler. The files only
* contains the typedefs required to build FreeRTOS. Read the instructions
* in FreeRTOS/source/stdint.readme for more information.
*/
extern "C" {
/* Application specific configuration options. */
/*
FreeRTOS V7.4.0 - Copyright (C) 2013 Real Time Engineers Ltd.
FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
***************************************************************************
* *
* FreeRTOS tutorial books are available in pdf and paperback. *
* Complete, revised, and edited pdf reference manuals are also *
* available. *
* *
* Purchasing FreeRTOS documentation will not only help you, by *
* ensuring you get running as quickly as possible and with an *
* in-depth knowledge of how to use FreeRTOS, it will also help *
* the FreeRTOS project to continue with its mission of providing *
* professional grade, cross platform, de facto standard solutions *
* for microcontrollers - completely free of charge! *
* *
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
* *
* Thank you for using FreeRTOS, and thank you for your support! *
* *
***************************************************************************
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
>>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to
distribute a combined work that includes FreeRTOS without being obliged to
provide the source code for proprietary components outside of the FreeRTOS
kernel.
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details. You should have received a copy of the GNU General Public License
and the FreeRTOS license exception along with FreeRTOS; if not itcan be
viewed here: http://www.freertos.org/a00114.html and also obtained by
writing to Real Time Engineers Ltd., contact details for whom are available
on the FreeRTOS WEB site.
1 tab == 4 spaces!
***************************************************************************
* *
* Having a problem? Start by reading the FAQ "My application does *
* not run, what could be wrong?" *
* *
* http://www.FreeRTOS.org/FAQHelp.html *
* *
***************************************************************************
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
license and Real Time Engineers Ltd. contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, and our new
fully thread aware and reentrant UDP/IP stack.
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
Integrity Systems, who sell the code with commercial support,
indemnification and middleware, under the OpenRTOS brand.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
*/
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html.
*----------------------------------------------------------*/
/* USER CODE BEGIN (0) */
/* USER CODE END */
/* USER CODE BEGIN (1) */
/* USER CODE END */
/* USER CODE BEGIN (2) */
/* #undef configSUPPORT_STATIC_ALLOCATION */
/* #define configSUPPORT_STATIC_ALLOCATION 1 */
/* USER CODE END */
/* Co-routine definitions. */
/* Mutexes */
/* Semaphores */
/* Timers */
/* USER CODE BEGIN (3) */
/* USER CODE END */
/* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */
/* USER CODE BEGIN (4) */
/* USER CODE END */
/* debug ASSERT */
/* USER CODE BEGIN (5) */
/* USER CODE END */
/* Basic FreeRTOS definitions. */
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*
* Defines the prototype to which task functions must conform. Defined in this
* file to ensure the type is known before portable.h is included.
*/
typedef void (*TaskFunction_t)( void * );
/* Converts a time in milliseconds to a time in ticks. This macro can be
overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
definition here is not suitable for your application. */
/* FreeRTOS error definitions. */
/* Macros used for basic data corruption checks. */
/* The following errno values are used by FreeRTOS+ components, not FreeRTOS
itself. */
/* The following endian values are used by FreeRTOS+ components, not FreeRTOS
itself. */
/* Definitions specific to the port being used. */
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*-----------------------------------------------------------
* Portable layer API. Each function must be defined for each port.
*----------------------------------------------------------*/
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a
pre-processor definition was used to ensure the pre-processor found the correct
portmacro.h file for the port being used. That scheme was deprecated in favour
of setting the compiler's include path such that it found the correct
portmacro.h file - removing the need for the constant and allowing the
portmacro.h file to be located anywhere in relation to the port being used.
Purely for reasons of backward compatibility the old method is still valid, but
to make it clear that new projects should not use it, support for the port
specific constants has been moved into the deprecated_definitions.h header
file. */
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*-----------------------------------------------------------
* Port specific definitions.
*
* The settings in this file configure FreeRTOS correctly for the
* given hardware and compiler.
*
* These settings should not be altered.
*-----------------------------------------------------------
*/
/* Type definitions. */
typedef uint32_t StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
typedef uint32_t TickType_t;
/* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
not need to be guarded with a critical section. */
/* Architecture specifics. */
/* Critical section handling. */
#pragma SWI_ALIAS(2)
extern void vPortEnterCritical( void );
#pragma SWI_ALIAS(3)
extern void vPortExitCritical( void );
#pragma SWI_ALIAS(5)
extern void vPortDisableInterrupts( void );
#pragma SWI_ALIAS(6)
extern void vPortEnableInterrupts( void );
/* Scheduler utilities. */
#pragma SWI_ALIAS(0)
extern void vPortYield( void );
/* Floating Point Support */
#pragma SWI_ALIAS(4)
extern void vPortTaskUsesFPU(void);
/* Architecture specific optimisations. */
/* Generic helper function. */
unsigned long ulPortCountLeadingZeros( unsigned long ulBitmap );
/* Check the configuration. */
/* Store/clear the ready priorities in a bit map. */
/*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. */
/* MPU specific constants. */
/* MPU Sub Region region */
/* MPU region sizes */
/* Default MPU regions */
typedef struct MPU_REGION_REGISTERS
{
unsigned ulRegionBaseAddress;
unsigned ulRegionSize;
unsigned ulRegionAttribute;
} xMPU_REGION_REGISTERS;
/* Plus 1 to create space for the stack region. */
typedef struct MPU_SETTINGS
{
xMPU_REGION_REGISTERS xRegion[ ( ( ( ( ( 12UL ) - 2 ) - ( 6UL - 1UL ) ) + 1 ) + 1 ) ];
} xMPU_SETTINGS;
/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
did not result in a portmacro.h header file being included - and it should be
included here. In this case the path to the correct portmacro.h header file
must be set in the compiler's include path. */
extern "C" {
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/* This file redefines API functions to be called through a wrapper macro, but
only for ports that are using the MPU. */
/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
included from queue.c or task.c to prevent it from having an effect within
those files. */
/*
* Map standard (non MPU) API functions to equivalents that start
* "MPU_". This will cause the application code to call the MPU_
* version, which wraps the non-MPU version with privilege promoting
* then demoting code, so the kernel code always runs will full
* privileges.
*/
/* Map standard tasks.h API functions to the MPU equivalents. */
/* Map standard queue.h API functions to the MPU equivalents. */
/* Map standard timer.h API functions to the MPU equivalents. */
/* Map standard event_group.h API functions to the MPU equivalents. */
/* Remove the privileged function macro. */
/*
* Setup the stack of a new task so it is ready to be placed under the
* scheduler control. The registers have to be placed on the stack in
* the order that the port expects to find them.
*
*/
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) ;
/* Used by heap_5.c. */
typedef struct HeapRegion
{
uint8_t *pucStartAddress;
size_t xSizeInBytes;
} HeapRegion_t;
/*
* Used to define multiple heap regions for use by heap_5.c. This function
* must be called before any calls to pvPortMalloc() - not creating a task,
* queue, semaphore, mutex, software timer, event group, etc. will result in
* pvPortMalloc being called.
*
* pxHeapRegions passes in an array of HeapRegion_t structures - each of which
* defines a region of memory that can be used as the heap. The array is
* terminated by a HeapRegions_t structure that has a size of 0. The region
* with the lowest start address must appear first in the array.
*/
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) ;
/*
* Map to the memory management routines required for the port.
*/
void *pvPortMalloc( size_t xSize ) ;
void vPortFree( void *pv ) ;
void vPortInitialiseBlocks( void ) ;
size_t xPortGetFreeHeapSize( void ) ;
size_t xPortGetMinimumEverFreeHeapSize( void ) ;
/*
* Setup the hardware ready for the scheduler to take control. This generally
* sets up a tick interrupt and sets timers for the correct tick frequency.
*/
BaseType_t xPortStartScheduler( void ) ;
/*
* Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
* the hardware is left in its original condition after the scheduler stops
* executing.
*/
void vPortEndScheduler( void ) ;
/*
* The structures and methods of manipulating the MPU are contained within the
* port layer.
*
* Fills the xMPUSettings structure with the memory region information
* contained in xRegions.
*/
struct xMEMORY_REGION;
void vPortStoreTaskMPUSettings( xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION * const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth ) ;
}
/* Must be defaulted before configUSE_NEWLIB_REENTRANT is used below. */
/* Required if struct _reent is used. */
/*
* Check all the required application specific macros have been defined.
* These macros are application specific and (as downloaded) are defined
* within FreeRTOSConfig.h.
*/
/* The timers module relies on xTaskGetSchedulerState(). */
/* Remove any unused trace macros. */
/* Used to perform any necessary initialisation - for example, open a file
into which trace is to be written. */
/* Use to close a trace, for example close a file into which trace has been
written. */
/* Called after a task has been selected to run. pxCurrentTCB holds a pointer
to the task control block of the selected task. */
/* Called before stepping the tick count after waking from tickless idle
sleep. */
/* Called immediately before entering tickless idle. */
/* Called when returning to the Idle task after a tickless idle. */
/* Called before a task has been selected to run. pxCurrentTCB holds a pointer
to the task control block of the task being switched out. */
/* Called when a task attempts to take a mutex that is already held by a
lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task
that holds the mutex. uxInheritedPriority is the priority the mutex holder
will inherit (the priority of the task that is attempting to obtain the
muted. */
/* Called when a task releases a mutex, the holding of which had resulted in
the task inheriting the priority of a higher priority task.
pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the
mutex. uxOriginalPriority is the task's configured (base) priority. */
/* Task is about to block because it cannot read from a
queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
upon which the read was attempted. pxCurrentTCB points to the TCB of the
task that attempted the read. */
/* Task is about to block because it cannot write to a
queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
upon which the write was attempted. pxCurrentTCB points to the TCB of the
task that attempted the write. */
/* The following event macros are embedded in the kernel API calls. */
/* Sanity check the configuration. */
/* The tick type can be read atomically, so critical sections used when the
tick count is returned can be defined away. */
/* Definitions to allow backward compatibility with FreeRTOS versions prior to
V8 if desired. */
/* Backward compatibility within the scheduler code only - these definitions
are not really required but are included for completeness. */
/* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even
if floating point hardware is otherwise supported by the FreeRTOS port in use.
This constant is not supported by all FreeRTOS ports that include floating
point support. */
/*
* In line with software engineering best practice, FreeRTOS implements a strict
* data hiding policy, so the real structures used by FreeRTOS to maintain the
* state of tasks, queues, semaphores, etc. are not accessible to the application
* code. However, if the application writer wants to statically allocate such
* an object then the size of the object needs to be know. Dummy structures
* that are guaranteed to have the same size and alignment requirements of the
* real objects are used for this purpose. The dummy list and list item
* structures below are used for inclusion in such a dummy structure.
*/
struct xSTATIC_LIST_ITEM
{
TickType_t xDummy1;
void *pvDummy2[ 4 ];
};
typedef struct xSTATIC_LIST_ITEM StaticListItem_t;
/* See the comments above the struct xSTATIC_LIST_ITEM definition. */
struct xSTATIC_MINI_LIST_ITEM
{
TickType_t xDummy1;
void *pvDummy2[ 2 ];
};
typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t;
/* See the comments above the struct xSTATIC_LIST_ITEM definition. */
typedef struct xSTATIC_LIST
{
UBaseType_t uxDummy1;
void *pvDummy2;
StaticMiniListItem_t xDummy3;
} StaticList_t;
/*
* In line with software engineering best practice, especially when supplying a
* library that is likely to change in future versions, FreeRTOS implements a
* strict data hiding policy. This means the Task structure used internally by
* FreeRTOS is not accessible to application code. However, if the application
* writer wants to statically allocate the memory required to create a task then
* the size of the task object needs to be know. The StaticTask_t structure
* below is provided for this purpose. Its sizes and alignment requirements are
* guaranteed to match those of the genuine structure, no matter which
* architecture is being used, and no matter how the values in FreeRTOSConfig.h
* are set. Its contents are somewhat obfuscated in the hope users will
* recognise that it would be unwise to make direct use of the structure members.
*/
typedef struct xSTATIC_TCB
{
void *pxDummy1;
xMPU_SETTINGS xDummy2;
StaticListItem_t xDummy3[ 2 ];
UBaseType_t uxDummy5;
void *pxDummy6;
uint8_t ucDummy7[ ( 16 ) ];
UBaseType_t uxDummy10[ 2 ];
UBaseType_t uxDummy12[ 2 ];
void *pvDummy15[ 1 ];
uint32_t ulDummy18;
uint8_t ucDummy19;
} StaticTask_t;
/*
* In line with software engineering best practice, especially when supplying a
* library that is likely to change in future versions, FreeRTOS implements a
* strict data hiding policy. This means the Queue structure used internally by
* FreeRTOS is not accessible to application code. However, if the application
* writer wants to statically allocate the memory required to create a queue
* then the size of the queue object needs to be know. The StaticQueue_t
* structure below is provided for this purpose. Its sizes and alignment
* requirements are guaranteed to match those of the genuine structure, no
* matter which architecture is being used, and no matter how the values in
* FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in the hope
* users will recognise that it would be unwise to make direct use of the
* structure members.
*/
typedef struct xSTATIC_QUEUE
{
void *pvDummy1[ 3 ];
union
{
void *pvDummy2;
UBaseType_t uxDummy2;
} u;
StaticList_t xDummy3[ 2 ];
UBaseType_t uxDummy4[ 3 ];
uint8_t ucDummy5[ 2 ];
UBaseType_t uxDummy8;
uint8_t ucDummy9;
} StaticQueue_t;
typedef StaticQueue_t StaticSemaphore_t;
/*
* In line with software engineering best practice, especially when supplying a
* library that is likely to change in future versions, FreeRTOS implements a
* strict data hiding policy. This means the event group structure used
* internally by FreeRTOS is not accessible to application code. However, if
* the application writer wants to statically allocate the memory required to
* create an event group then the size of the event group object needs to be
* know. The StaticEventGroup_t structure below is provided for this purpose.
* Its sizes and alignment requirements are guaranteed to match those of the
* genuine structure, no matter which architecture is being used, and no matter
* how the values in FreeRTOSConfig.h are set. Its contents are somewhat
* obfuscated in the hope users will recognise that it would be unwise to make
* direct use of the structure members.
*/
typedef struct xSTATIC_EVENT_GROUP
{
TickType_t xDummy1;
StaticList_t xDummy2;
UBaseType_t uxDummy3;
} StaticEventGroup_t;
/*
* In line with software engineering best practice, especially when supplying a
* library that is likely to change in future versions, FreeRTOS implements a
* strict data hiding policy. This means the software timer structure used
* internally by FreeRTOS is not accessible to application code. However, if
* the application writer wants to statically allocate the memory required to
* create a software timer then the size of the queue object needs to be know.
* The StaticTimer_t structure below is provided for this purpose. Its sizes
* and alignment requirements are guaranteed to match those of the genuine
* structure, no matter which architecture is being used, and no matter how the
* values in FreeRTOSConfig.h are set. Its contents are somewhat obfuscated in
* the hope users will recognise that it would be unwise to make direct use of
* the structure members.
*/
typedef struct xSTATIC_TIMER
{
void *pvDummy1;
StaticListItem_t xDummy2;
TickType_t xDummy3;
UBaseType_t uxDummy4;
void *pvDummy5[ 2 ];
UBaseType_t uxDummy6;
} StaticTimer_t;
}
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
extern "C" {
/**
* Type by which queues are referenced. For example, a call to xQueueCreate()
* returns an QueueHandle_t variable that can then be used as a parameter to
* xQueueSend(), xQueueReceive(), etc.
*/
typedef void * QueueHandle_t;
/**
* Type by which queue sets are referenced. For example, a call to
* xQueueCreateSet() returns an xQueueSet variable that can then be used as a
* parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc.
*/
typedef void * QueueSetHandle_t;
/**
* Queue sets can contain both queues and semaphores, so the
* QueueSetMemberHandle_t is defined as a type to be used where a parameter or
* return value can be either an QueueHandle_t or an SemaphoreHandle_t.
*/
typedef void * QueueSetMemberHandle_t;
/* For internal use only. */
/* For internal use only. These definitions *must* match those in queue.c. */
/**
* queue. h
* <pre>
QueueHandle_t xQueueCreate(
UBaseType_t uxQueueLength,
UBaseType_t uxItemSize
);
* </pre>
*
* Creates a new queue instance, and returns a handle by which the new queue
* can be referenced.
*
* Internally, within the FreeRTOS implementation, queues use two blocks of
* memory. The first block is used to hold the queue's data structures. The
* second block is used to hold items placed into the queue. If a queue is
* created using xQueueCreate() then both blocks of memory are automatically
* dynamically allocated inside the xQueueCreate() function. (see
* http://www.freertos.org/a00111.html). If a queue is created using
* xQueueCreateStatic() then the application writer must provide the memory that
* will get used by the queue. xQueueCreateStatic() therefore allows a queue to
* be created without using any dynamic memory allocation.
*
* http://www.FreeRTOS.org/Embedded-RTOS-Queues.html
*
* @param uxQueueLength The maximum number of items that the queue can contain.
*
* @param uxItemSize The number of bytes each item in the queue will require.
* Items are queued by copy, not by reference, so this is the number of bytes
* that will be copied for each posted item. Each item on the queue must be
* the same size.
*
* @return If the queue is successfully create then a handle to the newly
* created queue is returned. If the queue cannot be created then 0 is
* returned.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
};
void vATask( void *pvParameters )
{
QueueHandle_t xQueue1, xQueue2;
// Create a queue capable of containing 10 uint32_t values.
xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
if( xQueue1 == 0 )
{
// Queue was not created and must not be used.
}
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
if( xQueue2 == 0 )
{
// Queue was not created and must not be used.
}
// ... Rest of task code.
}
</pre>
* \defgroup xQueueCreate xQueueCreate
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
QueueHandle_t xQueueCreateStatic(
UBaseType_t uxQueueLength,
UBaseType_t uxItemSize,
uint8_t *pucQueueStorageBuffer,
StaticQueue_t *pxQueueBuffer
);
* </pre>
*
* Creates a new queue instance, and returns a handle by which the new queue
* can be referenced.
*
* Internally, within the FreeRTOS implementation, queues use two blocks of
* memory. The first block is used to hold the queue's data structures. The
* second block is used to hold items placed into the queue. If a queue is
* created using xQueueCreate() then both blocks of memory are automatically
* dynamically allocated inside the xQueueCreate() function. (see
* http://www.freertos.org/a00111.html). If a queue is created using
* xQueueCreateStatic() then the application writer must provide the memory that
* will get used by the queue. xQueueCreateStatic() therefore allows a queue to
* be created without using any dynamic memory allocation.
*
* http://www.FreeRTOS.org/Embedded-RTOS-Queues.html
*
* @param uxQueueLength The maximum number of items that the queue can contain.
*
* @param uxItemSize The number of bytes each item in the queue will require.
* Items are queued by copy, not by reference, so this is the number of bytes
* that will be copied for each posted item. Each item on the queue must be
* the same size.
*
* @param pucQueueStorageBuffer If uxItemSize is not zero then
* pucQueueStorageBuffer must point to a uint8_t array that is at least large
* enough to hold the maximum number of items that can be in the queue at any
* one time - which is ( uxQueueLength * uxItemsSize ) bytes. If uxItemSize is
* zero then pucQueueStorageBuffer can be NULL.
*
* @param pxQueueBuffer Must point to a variable of type StaticQueue_t, which
* will be used to hold the queue's data structure.
*
* @return If the queue is created then a handle to the created queue is
* returned. If pxQueueBuffer is NULL then NULL is returned.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
};
#define QUEUE_LENGTH 10
#define ITEM_SIZE sizeof( uint32_t )
// xQueueBuffer will hold the queue structure.
StaticQueue_t xQueueBuffer;
// ucQueueStorage will hold the items posted to the queue. Must be at least
// [(queue length) * ( queue item size)] bytes long.
uint8_t ucQueueStorage[ QUEUE_LENGTH * ITEM_SIZE ];
void vATask( void *pvParameters )
{
QueueHandle_t xQueue1;
// Create a queue capable of containing 10 uint32_t values.
xQueue1 = xQueueCreate( QUEUE_LENGTH, // The number of items the queue can hold.
ITEM_SIZE // The size of each item in the queue
&( ucQueueStorage[ 0 ] ), // The buffer that will hold the items in the queue.
&xQueueBuffer ); // The buffer that will hold the queue structure.
// The queue is guaranteed to be created successfully as no dynamic memory
// allocation is used. Therefore xQueue1 is now a handle to a valid queue.
// ... Rest of task code.
}
</pre>
* \defgroup xQueueCreateStatic xQueueCreateStatic
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueSendToToFront(
QueueHandle_t xQueue,
const void *pvItemToQueue,
TickType_t xTicksToWait
);
* </pre>
*
* This is a macro that calls xQueueGenericSend().
*
* Post an item to the front of a queue. The item is queued by copy, not by
* reference. This function must not be called from an interrupt service
* routine. See xQueueSendFromISR () for an alternative which may be used
* in an ISR.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param xTicksToWait The maximum amount of time the task should block
* waiting for space to become available on the queue, should it already
* be full. The call will return immediately if this is set to 0 and the
* queue is full. The time is defined in tick periods so the constant
* portTICK_PERIOD_MS should be used to convert to real time if this is required.
*
* @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
} xMessage;
uint32_t ulVar = 10UL;
void vATask( void *pvParameters )
{
QueueHandle_t xQueue1, xQueue2;
struct AMessage *pxMessage;
// Create a queue capable of containing 10 uint32_t values.
xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
// ...
if( xQueue1 != 0 )
{
// Send an uint32_t. Wait for 10 ticks for space to become
// available if necessary.
if( xQueueSendToFront( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
{
// Failed to post the message, even after 10 ticks.
}
}
if( xQueue2 != 0 )
{
// Send a pointer to a struct AMessage object. Don't block if the
// queue is already full.
pxMessage = & xMessage;
xQueueSendToFront( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
}
// ... Rest of task code.
}
</pre>
* \defgroup xQueueSend xQueueSend
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueSendToBack(
QueueHandle_t xQueue,
const void *pvItemToQueue,
TickType_t xTicksToWait
);
* </pre>
*
* This is a macro that calls xQueueGenericSend().
*
* Post an item to the back of a queue. The item is queued by copy, not by
* reference. This function must not be called from an interrupt service
* routine. See xQueueSendFromISR () for an alternative which may be used
* in an ISR.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param xTicksToWait The maximum amount of time the task should block
* waiting for space to become available on the queue, should it already
* be full. The call will return immediately if this is set to 0 and the queue
* is full. The time is defined in tick periods so the constant
* portTICK_PERIOD_MS should be used to convert to real time if this is required.
*
* @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
} xMessage;
uint32_t ulVar = 10UL;
void vATask( void *pvParameters )
{
QueueHandle_t xQueue1, xQueue2;
struct AMessage *pxMessage;
// Create a queue capable of containing 10 uint32_t values.
xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
// ...
if( xQueue1 != 0 )
{
// Send an uint32_t. Wait for 10 ticks for space to become
// available if necessary.
if( xQueueSendToBack( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
{
// Failed to post the message, even after 10 ticks.
}
}
if( xQueue2 != 0 )
{
// Send a pointer to a struct AMessage object. Don't block if the
// queue is already full.
pxMessage = & xMessage;
xQueueSendToBack( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
}
// ... Rest of task code.
}
</pre>
* \defgroup xQueueSend xQueueSend
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueSend(
QueueHandle_t xQueue,
const void * pvItemToQueue,
TickType_t xTicksToWait
);
* </pre>
*
* This is a macro that calls xQueueGenericSend(). It is included for
* backward compatibility with versions of FreeRTOS.org that did not
* include the xQueueSendToFront() and xQueueSendToBack() macros. It is
* equivalent to xQueueSendToBack().
*
* Post an item on a queue. The item is queued by copy, not by reference.
* This function must not be called from an interrupt service routine.
* See xQueueSendFromISR () for an alternative which may be used in an ISR.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param xTicksToWait The maximum amount of time the task should block
* waiting for space to become available on the queue, should it already
* be full. The call will return immediately if this is set to 0 and the
* queue is full. The time is defined in tick periods so the constant
* portTICK_PERIOD_MS should be used to convert to real time if this is required.
*
* @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
} xMessage;
uint32_t ulVar = 10UL;
void vATask( void *pvParameters )
{
QueueHandle_t xQueue1, xQueue2;
struct AMessage *pxMessage;
// Create a queue capable of containing 10 uint32_t values.
xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
// ...
if( xQueue1 != 0 )
{
// Send an uint32_t. Wait for 10 ticks for space to become
// available if necessary.
if( xQueueSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10 ) != pdPASS )
{
// Failed to post the message, even after 10 ticks.
}
}
if( xQueue2 != 0 )
{
// Send a pointer to a struct AMessage object. Don't block if the
// queue is already full.
pxMessage = & xMessage;
xQueueSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0 );
}
// ... Rest of task code.
}
</pre>
* \defgroup xQueueSend xQueueSend
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueOverwrite(
QueueHandle_t xQueue,
const void * pvItemToQueue
);
* </pre>
*
* Only for use with queues that have a length of one - so the queue is either
* empty or full.
*
* Post an item on a queue. If the queue is already full then overwrite the
* value held in the queue. The item is queued by copy, not by reference.
*
* This function must not be called from an interrupt service routine.
* See xQueueOverwriteFromISR () for an alternative which may be used in an ISR.
*
* @param xQueue The handle of the queue to which the data is being sent.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @return xQueueOverwrite() is a macro that calls xQueueGenericSend(), and
* therefore has the same return values as xQueueSendToFront(). However, pdPASS
* is the only value that can be returned because xQueueOverwrite() will write
* to the queue even when the queue is already full.
*
* Example usage:
<pre>
void vFunction( void *pvParameters )
{
QueueHandle_t xQueue;
uint32_t ulVarToSend, ulValReceived;
// Create a queue to hold one uint32_t value. It is strongly
// recommended *not* to use xQueueOverwrite() on queues that can
// contain more than one value, and doing so will trigger an assertion
// if configASSERT() is defined.
xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
// Write the value 10 to the queue using xQueueOverwrite().
ulVarToSend = 10;
xQueueOverwrite( xQueue, &ulVarToSend );
// Peeking the queue should now return 10, but leave the value 10 in
// the queue. A block time of zero is used as it is known that the
// queue holds a value.
ulValReceived = 0;
xQueuePeek( xQueue, &ulValReceived, 0 );
if( ulValReceived != 10 )
{
// Error unless the item was removed by a different task.
}
// The queue is still full. Use xQueueOverwrite() to overwrite the
// value held in the queue with 100.
ulVarToSend = 100;
xQueueOverwrite( xQueue, &ulVarToSend );
// This time read from the queue, leaving the queue empty once more.
// A block time of 0 is used again.
xQueueReceive( xQueue, &ulValReceived, 0 );
// The value read should be the last value written, even though the
// queue was already full when the value was written.
if( ulValReceived != 100 )
{
// Error!
}
// ...
}
</pre>
* \defgroup xQueueOverwrite xQueueOverwrite
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueGenericSend(
QueueHandle_t xQueue,
const void * pvItemToQueue,
TickType_t xTicksToWait
BaseType_t xCopyPosition
);
* </pre>
*
* It is preferred that the macros xQueueSend(), xQueueSendToFront() and
* xQueueSendToBack() are used in place of calling this function directly.
*
* Post an item on a queue. The item is queued by copy, not by reference.
* This function must not be called from an interrupt service routine.
* See xQueueSendFromISR () for an alternative which may be used in an ISR.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param xTicksToWait The maximum amount of time the task should block
* waiting for space to become available on the queue, should it already
* be full. The call will return immediately if this is set to 0 and the
* queue is full. The time is defined in tick periods so the constant
* portTICK_PERIOD_MS should be used to convert to real time if this is required.
*
* @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
* item at the back of the queue, or queueSEND_TO_FRONT to place the item
* at the front of the queue (for high priority messages).
*
* @return pdTRUE if the item was successfully posted, otherwise errQUEUE_FULL.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
} xMessage;
uint32_t ulVar = 10UL;
void vATask( void *pvParameters )
{
QueueHandle_t xQueue1, xQueue2;
struct AMessage *pxMessage;
// Create a queue capable of containing 10 uint32_t values.
xQueue1 = xQueueCreate( 10, sizeof( uint32_t ) );
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue2 = xQueueCreate( 10, sizeof( struct AMessage * ) );
// ...
if( xQueue1 != 0 )
{
// Send an uint32_t. Wait for 10 ticks for space to become
// available if necessary.
if( xQueueGenericSend( xQueue1, ( void * ) &ulVar, ( TickType_t ) 10, queueSEND_TO_BACK ) != pdPASS )
{
// Failed to post the message, even after 10 ticks.
}
}
if( xQueue2 != 0 )
{
// Send a pointer to a struct AMessage object. Don't block if the
// queue is already full.
pxMessage = & xMessage;
xQueueGenericSend( xQueue2, ( void * ) &pxMessage, ( TickType_t ) 0, queueSEND_TO_BACK );
}
// ... Rest of task code.
}
</pre>
* \defgroup xQueueSend xQueueSend
* \ingroup QueueManagement
*/
BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) ;
/**
* queue. h
* <pre>
BaseType_t xQueuePeek(
QueueHandle_t xQueue,
void *pvBuffer,
TickType_t xTicksToWait
);</pre>
*
* This is a macro that calls the xQueueGenericReceive() function.
*
* Receive an item from a queue without removing the item from the queue.
* The item is received by copy so a buffer of adequate size must be
* provided. The number of bytes copied into the buffer was defined when
* the queue was created.
*
* Successfully received items remain on the queue so will be returned again
* by the next call, or a call to xQueueReceive().
*
* This macro must not be used in an interrupt service routine. See
* xQueuePeekFromISR() for an alternative that can be called from an interrupt
* service routine.
*
* @param xQueue The handle to the queue from which the item is to be
* received.
*
* @param pvBuffer Pointer to the buffer into which the received item will
* be copied.
*
* @param xTicksToWait The maximum amount of time the task should block
* waiting for an item to receive should the queue be empty at the time
* of the call. The time is defined in tick periods so the constant
* portTICK_PERIOD_MS should be used to convert to real time if this is required.
* xQueuePeek() will return immediately if xTicksToWait is 0 and the queue
* is empty.
*
* @return pdTRUE if an item was successfully received from the queue,
* otherwise pdFALSE.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
} xMessage;
QueueHandle_t xQueue;
// Task to create a queue and post a value.
void vATask( void *pvParameters )
{
struct AMessage *pxMessage;
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
if( xQueue == 0 )
{
// Failed to create the queue.
}
// ...
// Send a pointer to a struct AMessage object. Don't block if the
// queue is already full.
pxMessage = & xMessage;
xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
// ... Rest of task code.
}
// Task to peek the data from the queue.
void vADifferentTask( void *pvParameters )
{
struct AMessage *pxRxedMessage;
if( xQueue != 0 )
{
// Peek a message on the created queue. Block for 10 ticks if a
// message is not immediately available.
if( xQueuePeek( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
{
// pcRxedMessage now points to the struct AMessage variable posted
// by vATask, but the item still remains on the queue.
}
}
// ... Rest of task code.
}
</pre>
* \defgroup xQueueReceive xQueueReceive
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueuePeekFromISR(
QueueHandle_t xQueue,
void *pvBuffer,
);</pre>
*
* A version of xQueuePeek() that can be called from an interrupt service
* routine (ISR).
*
* Receive an item from a queue without removing the item from the queue.
* The item is received by copy so a buffer of adequate size must be
* provided. The number of bytes copied into the buffer was defined when
* the queue was created.
*
* Successfully received items remain on the queue so will be returned again
* by the next call, or a call to xQueueReceive().
*
* @param xQueue The handle to the queue from which the item is to be
* received.
*
* @param pvBuffer Pointer to the buffer into which the received item will
* be copied.
*
* @return pdTRUE if an item was successfully received from the queue,
* otherwise pdFALSE.
*
* \defgroup xQueuePeekFromISR xQueuePeekFromISR
* \ingroup QueueManagement
*/
BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) ;
/**
* queue. h
* <pre>
BaseType_t xQueueReceive(
QueueHandle_t xQueue,
void *pvBuffer,
TickType_t xTicksToWait
);</pre>
*
* This is a macro that calls the xQueueGenericReceive() function.
*
* Receive an item from a queue. The item is received by copy so a buffer of
* adequate size must be provided. The number of bytes copied into the buffer
* was defined when the queue was created.
*
* Successfully received items are removed from the queue.
*
* This function must not be used in an interrupt service routine. See
* xQueueReceiveFromISR for an alternative that can.
*
* @param xQueue The handle to the queue from which the item is to be
* received.
*
* @param pvBuffer Pointer to the buffer into which the received item will
* be copied.
*
* @param xTicksToWait The maximum amount of time the task should block
* waiting for an item to receive should the queue be empty at the time
* of the call. xQueueReceive() will return immediately if xTicksToWait
* is zero and the queue is empty. The time is defined in tick periods so the
* constant portTICK_PERIOD_MS should be used to convert to real time if this is
* required.
*
* @return pdTRUE if an item was successfully received from the queue,
* otherwise pdFALSE.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
} xMessage;
QueueHandle_t xQueue;
// Task to create a queue and post a value.
void vATask( void *pvParameters )
{
struct AMessage *pxMessage;
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
if( xQueue == 0 )
{
// Failed to create the queue.
}
// ...
// Send a pointer to a struct AMessage object. Don't block if the
// queue is already full.
pxMessage = & xMessage;
xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
// ... Rest of task code.
}
// Task to receive from the queue.
void vADifferentTask( void *pvParameters )
{
struct AMessage *pxRxedMessage;
if( xQueue != 0 )
{
// Receive a message on the created queue. Block for 10 ticks if a
// message is not immediately available.
if( xQueueReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
{
// pcRxedMessage now points to the struct AMessage variable posted
// by vATask.
}
}
// ... Rest of task code.
}
</pre>
* \defgroup xQueueReceive xQueueReceive
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueGenericReceive(
QueueHandle_t xQueue,
void *pvBuffer,
TickType_t xTicksToWait
BaseType_t xJustPeek
);</pre>
*
* It is preferred that the macro xQueueReceive() be used rather than calling
* this function directly.
*
* Receive an item from a queue. The item is received by copy so a buffer of
* adequate size must be provided. The number of bytes copied into the buffer
* was defined when the queue was created.
*
* This function must not be used in an interrupt service routine. See
* xQueueReceiveFromISR for an alternative that can.
*
* @param xQueue The handle to the queue from which the item is to be
* received.
*
* @param pvBuffer Pointer to the buffer into which the received item will
* be copied.
*
* @param xTicksToWait The maximum amount of time the task should block
* waiting for an item to receive should the queue be empty at the time
* of the call. The time is defined in tick periods so the constant
* portTICK_PERIOD_MS should be used to convert to real time if this is required.
* xQueueGenericReceive() will return immediately if the queue is empty and
* xTicksToWait is 0.
*
* @param xJustPeek When set to true, the item received from the queue is not
* actually removed from the queue - meaning a subsequent call to
* xQueueReceive() will return the same item. When set to false, the item
* being received from the queue is also removed from the queue.
*
* @return pdTRUE if an item was successfully received from the queue,
* otherwise pdFALSE.
*
* Example usage:
<pre>
struct AMessage
{
char ucMessageID;
char ucData[ 20 ];
} xMessage;
QueueHandle_t xQueue;
// Task to create a queue and post a value.
void vATask( void *pvParameters )
{
struct AMessage *pxMessage;
// Create a queue capable of containing 10 pointers to AMessage structures.
// These should be passed by pointer as they contain a lot of data.
xQueue = xQueueCreate( 10, sizeof( struct AMessage * ) );
if( xQueue == 0 )
{
// Failed to create the queue.
}
// ...
// Send a pointer to a struct AMessage object. Don't block if the
// queue is already full.
pxMessage = & xMessage;
xQueueSend( xQueue, ( void * ) &pxMessage, ( TickType_t ) 0 );
// ... Rest of task code.
}
// Task to receive from the queue.
void vADifferentTask( void *pvParameters )
{
struct AMessage *pxRxedMessage;
if( xQueue != 0 )
{
// Receive a message on the created queue. Block for 10 ticks if a
// message is not immediately available.
if( xQueueGenericReceive( xQueue, &( pxRxedMessage ), ( TickType_t ) 10 ) )
{
// pcRxedMessage now points to the struct AMessage variable posted
// by vATask.
}
}
// ... Rest of task code.
}
</pre>
* \defgroup xQueueReceive xQueueReceive
* \ingroup QueueManagement
*/
BaseType_t MPU_xQueueGenericReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait, const BaseType_t xJustPeek ) ;
/**
* queue. h
* <pre>UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );</pre>
*
* Return the number of messages stored in a queue.
*
* @param xQueue A handle to the queue being queried.
*
* @return The number of messages available in the queue.
*
* \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
* \ingroup QueueManagement
*/
UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ) ;
/**
* queue. h
* <pre>UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );</pre>
*
* Return the number of free spaces available in a queue. This is equal to the
* number of items that can be sent to the queue before the queue becomes full
* if no items are removed.
*
* @param xQueue A handle to the queue being queried.
*
* @return The number of spaces available in the queue.
*
* \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
* \ingroup QueueManagement
*/
UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) ;
/**
* queue. h
* <pre>void vQueueDelete( QueueHandle_t xQueue );</pre>
*
* Delete a queue - freeing all the memory allocated for storing of items
* placed on the queue.
*
* @param xQueue A handle to the queue to be deleted.
*
* \defgroup vQueueDelete vQueueDelete
* \ingroup QueueManagement
*/
void MPU_vQueueDelete( QueueHandle_t xQueue ) ;
/**
* queue. h
* <pre>
BaseType_t xQueueSendToFrontFromISR(
QueueHandle_t xQueue,
const void *pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken
);
</pre>
*
* This is a macro that calls xQueueGenericSendFromISR().
*
* Post an item to the front of a queue. It is safe to use this macro from
* within an interrupt service routine.
*
* Items are queued by copy not reference so it is preferable to only
* queue small items, especially when called from an ISR. In most cases
* it would be preferable to store a pointer to the item being queued.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param pxHigherPriorityTaskWoken xQueueSendToFrontFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xQueueSendToFromFromISR() sets this value to pdTRUE then
* a context switch should be requested before the interrupt is exited.
*
* @return pdTRUE if the data was successfully sent to the queue, otherwise
* errQUEUE_FULL.
*
* Example usage for buffered IO (where the ISR can obtain more than one value
* per call):
<pre>
void vBufferISR( void )
{
char cIn;
BaseType_t xHigherPrioritTaskWoken;
// We have not woken a task at the start of the ISR.
xHigherPriorityTaskWoken = pdFALSE;
// Loop until the buffer is empty.
do
{
// Obtain a byte from the buffer.
cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
// Post the byte.
xQueueSendToFrontFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
} while( portINPUT_BYTE( BUFFER_COUNT ) );
// Now the buffer is empty we can switch context if necessary.
if( xHigherPriorityTaskWoken )
{
taskYIELD ();
}
}
</pre>
*
* \defgroup xQueueSendFromISR xQueueSendFromISR
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueSendToBackFromISR(
QueueHandle_t xQueue,
const void *pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken
);
</pre>
*
* This is a macro that calls xQueueGenericSendFromISR().
*
* Post an item to the back of a queue. It is safe to use this macro from
* within an interrupt service routine.
*
* Items are queued by copy not reference so it is preferable to only
* queue small items, especially when called from an ISR. In most cases
* it would be preferable to store a pointer to the item being queued.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param pxHigherPriorityTaskWoken xQueueSendToBackFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xQueueSendToBackFromISR() sets this value to pdTRUE then
* a context switch should be requested before the interrupt is exited.
*
* @return pdTRUE if the data was successfully sent to the queue, otherwise
* errQUEUE_FULL.
*
* Example usage for buffered IO (where the ISR can obtain more than one value
* per call):
<pre>
void vBufferISR( void )
{
char cIn;
BaseType_t xHigherPriorityTaskWoken;
// We have not woken a task at the start of the ISR.
xHigherPriorityTaskWoken = pdFALSE;
// Loop until the buffer is empty.
do
{
// Obtain a byte from the buffer.
cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
// Post the byte.
xQueueSendToBackFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
} while( portINPUT_BYTE( BUFFER_COUNT ) );
// Now the buffer is empty we can switch context if necessary.
if( xHigherPriorityTaskWoken )
{
taskYIELD ();
}
}
</pre>
*
* \defgroup xQueueSendFromISR xQueueSendFromISR
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueOverwriteFromISR(
QueueHandle_t xQueue,
const void * pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken
);
* </pre>
*
* A version of xQueueOverwrite() that can be used in an interrupt service
* routine (ISR).
*
* Only for use with queues that can hold a single item - so the queue is either
* empty or full.
*
* Post an item on a queue. If the queue is already full then overwrite the
* value held in the queue. The item is queued by copy, not by reference.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param pxHigherPriorityTaskWoken xQueueOverwriteFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xQueueOverwriteFromISR() sets this value to pdTRUE then
* a context switch should be requested before the interrupt is exited.
*
* @return xQueueOverwriteFromISR() is a macro that calls
* xQueueGenericSendFromISR(), and therefore has the same return values as
* xQueueSendToFrontFromISR(). However, pdPASS is the only value that can be
* returned because xQueueOverwriteFromISR() will write to the queue even when
* the queue is already full.
*
* Example usage:
<pre>
QueueHandle_t xQueue;
void vFunction( void *pvParameters )
{
// Create a queue to hold one uint32_t value. It is strongly
// recommended *not* to use xQueueOverwriteFromISR() on queues that can
// contain more than one value, and doing so will trigger an assertion
// if configASSERT() is defined.
xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
}
void vAnInterruptHandler( void )
{
// xHigherPriorityTaskWoken must be set to pdFALSE before it is used.
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
uint32_t ulVarToSend, ulValReceived;
// Write the value 10 to the queue using xQueueOverwriteFromISR().
ulVarToSend = 10;
xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
// The queue is full, but calling xQueueOverwriteFromISR() again will still
// pass because the value held in the queue will be overwritten with the
// new value.
ulVarToSend = 100;
xQueueOverwriteFromISR( xQueue, &ulVarToSend, &xHigherPriorityTaskWoken );
// Reading from the queue will now return 100.
// ...
if( xHigherPrioritytaskWoken == pdTRUE )
{
// Writing to the queue caused a task to unblock and the unblocked task
// has a priority higher than or equal to the priority of the currently
// executing task (the task this interrupt interrupted). Perform a context
// switch so this interrupt returns directly to the unblocked task.
portYIELD_FROM_ISR(); // or portEND_SWITCHING_ISR() depending on the port.
}
}
</pre>
* \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueSendFromISR(
QueueHandle_t xQueue,
const void *pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken
);
</pre>
*
* This is a macro that calls xQueueGenericSendFromISR(). It is included
* for backward compatibility with versions of FreeRTOS.org that did not
* include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()
* macros.
*
* Post an item to the back of a queue. It is safe to use this function from
* within an interrupt service routine.
*
* Items are queued by copy not reference so it is preferable to only
* queue small items, especially when called from an ISR. In most cases
* it would be preferable to store a pointer to the item being queued.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param pxHigherPriorityTaskWoken xQueueSendFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xQueueSendFromISR() sets this value to pdTRUE then
* a context switch should be requested before the interrupt is exited.
*
* @return pdTRUE if the data was successfully sent to the queue, otherwise
* errQUEUE_FULL.
*
* Example usage for buffered IO (where the ISR can obtain more than one value
* per call):
<pre>
void vBufferISR( void )
{
char cIn;
BaseType_t xHigherPriorityTaskWoken;
// We have not woken a task at the start of the ISR.
xHigherPriorityTaskWoken = pdFALSE;
// Loop until the buffer is empty.
do
{
// Obtain a byte from the buffer.
cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
// Post the byte.
xQueueSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWoken );
} while( portINPUT_BYTE( BUFFER_COUNT ) );
// Now the buffer is empty we can switch context if necessary.
if( xHigherPriorityTaskWoken )
{
// Actual macro used here is port specific.
portYIELD_FROM_ISR ();
}
}
</pre>
*
* \defgroup xQueueSendFromISR xQueueSendFromISR
* \ingroup QueueManagement
*/
/**
* queue. h
* <pre>
BaseType_t xQueueGenericSendFromISR(
QueueHandle_t xQueue,
const void *pvItemToQueue,
BaseType_t *pxHigherPriorityTaskWoken,
BaseType_t xCopyPosition
);
</pre>
*
* It is preferred that the macros xQueueSendFromISR(),
* xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place
* of calling this function directly. xQueueGiveFromISR() is an
* equivalent for use by semaphores that don't actually copy any data.
*
* Post an item on a queue. It is safe to use this function from within an
* interrupt service routine.
*
* Items are queued by copy not reference so it is preferable to only
* queue small items, especially when called from an ISR. In most cases
* it would be preferable to store a pointer to the item being queued.
*
* @param xQueue The handle to the queue on which the item is to be posted.
*
* @param pvItemToQueue A pointer to the item that is to be placed on the
* queue. The size of the items the queue will hold was defined when the
* queue was created, so this many bytes will be copied from pvItemToQueue
* into the queue storage area.
*
* @param pxHigherPriorityTaskWoken xQueueGenericSendFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if sending to the queue caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xQueueGenericSendFromISR() sets this value to pdTRUE then
* a context switch should be requested before the interrupt is exited.
*
* @param xCopyPosition Can take the value queueSEND_TO_BACK to place the
* item at the back of the queue, or queueSEND_TO_FRONT to place the item
* at the front of the queue (for high priority messages).
*
* @return pdTRUE if the data was successfully sent to the queue, otherwise
* errQUEUE_FULL.
*
* Example usage for buffered IO (where the ISR can obtain more than one value
* per call):
<pre>
void vBufferISR( void )
{
char cIn;
BaseType_t xHigherPriorityTaskWokenByPost;
// We have not woken a task at the start of the ISR.
xHigherPriorityTaskWokenByPost = pdFALSE;
// Loop until the buffer is empty.
do
{
// Obtain a byte from the buffer.
cIn = portINPUT_BYTE( RX_REGISTER_ADDRESS );
// Post each byte.
xQueueGenericSendFromISR( xRxQueue, &cIn, &xHigherPriorityTaskWokenByPost, queueSEND_TO_BACK );
} while( portINPUT_BYTE( BUFFER_COUNT ) );
// Now the buffer is empty we can switch context if necessary. Note that the
// name of the yield function required is port specific.
if( xHigherPriorityTaskWokenByPost )
{
taskYIELD_YIELD_FROM_ISR();
}
}
</pre>
*
* \defgroup xQueueSendFromISR xQueueSendFromISR
* \ingroup QueueManagement
*/
BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) ;
BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) ;
/**
* queue. h
* <pre>
BaseType_t xQueueReceiveFromISR(
QueueHandle_t xQueue,
void *pvBuffer,
BaseType_t *pxTaskWoken
);
* </pre>
*
* Receive an item from a queue. It is safe to use this function from within an
* interrupt service routine.
*
* @param xQueue The handle to the queue from which the item is to be
* received.
*
* @param pvBuffer Pointer to the buffer into which the received item will
* be copied.
*
* @param pxTaskWoken A task may be blocked waiting for space to become
* available on the queue. If xQueueReceiveFromISR causes such a task to
* unblock *pxTaskWoken will get set to pdTRUE, otherwise *pxTaskWoken will
* remain unchanged.
*
* @return pdTRUE if an item was successfully received from the queue,
* otherwise pdFALSE.
*
* Example usage:
<pre>
QueueHandle_t xQueue;
// Function to create a queue and post some values.
void vAFunction( void *pvParameters )
{
char cValueToPost;
const TickType_t xTicksToWait = ( TickType_t )0xff;
// Create a queue capable of containing 10 characters.
xQueue = xQueueCreate( 10, sizeof( char ) );
if( xQueue == 0 )
{
// Failed to create the queue.
}
// ...
// Post some characters that will be used within an ISR. If the queue
// is full then this task will block for xTicksToWait ticks.
cValueToPost = 'a';
xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
cValueToPost = 'b';
xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
// ... keep posting characters ... this task may block when the queue
// becomes full.
cValueToPost = 'c';
xQueueSend( xQueue, ( void * ) &cValueToPost, xTicksToWait );
}
// ISR that outputs all the characters received on the queue.
void vISR_Routine( void )
{
BaseType_t xTaskWokenByReceive = pdFALSE;
char cRxedChar;
while( xQueueReceiveFromISR( xQueue, ( void * ) &cRxedChar, &xTaskWokenByReceive) )
{
// A character was received. Output the character now.
vOutputCharacter( cRxedChar );
// If removing the character from the queue woke the task that was
// posting onto the queue cTaskWokenByReceive will have been set to
// pdTRUE. No matter how many times this loop iterates only one
// task will be woken.
}
if( cTaskWokenByPost != ( char ) pdFALSE;
{
taskYIELD ();
}
}
</pre>
* \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
* \ingroup QueueManagement
*/
BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) ;
/*
* Utilities to query queues that are safe to use from an ISR. These utilities
* should be used only from witin an ISR, or within a critical section.
*/
BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) ;
BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) ;
UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) ;
/*
* The functions defined above are for passing data to and from tasks. The
* functions below are the equivalents for passing data to and from
* co-routines.
*
* These functions are called from the co-routine macro implementation and
* should not be called directly from application code. Instead use the macro
* wrappers defined within croutine.h.
*/
BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken );
BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken );
BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait );
BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait );
/*
* For internal use only. Use xSemaphoreCreateMutex(),
* xSemaphoreCreateCounting() or xSemaphoreGetMutexHolder() instead of calling
* these functions directly.
*/
QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) ;
QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) ;
QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) ;
QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) ;
void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) ;
/*
* For internal use only. Use xSemaphoreTakeMutexRecursive() or
* xSemaphoreGiveMutexRecursive() instead of calling these functions directly.
*/
BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) ;
BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) ;
/*
* Reset a queue back to its original empty state. The return value is now
* obsolete and is always set to pdPASS.
*/
/*
* The registry is provided as a means for kernel aware debuggers to
* locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add
* a queue, semaphore or mutex handle to the registry if you want the handle
* to be available to a kernel aware debugger. If you are not using a kernel
* aware debugger then this function can be ignored.
*
* configQUEUE_REGISTRY_SIZE defines the maximum number of handles the
* registry can hold. configQUEUE_REGISTRY_SIZE must be greater than 0
* within FreeRTOSConfig.h for the registry to be available. Its value
* does not effect the number of queues, semaphores and mutexes that can be
* created - just the number that the registry can hold.
*
* @param xQueue The handle of the queue being added to the registry. This
* is the handle returned by a call to xQueueCreate(). Semaphore and mutex
* handles can also be passed in here.
*
* @param pcName The name to be associated with the handle. This is the
* name that the kernel aware debugger will display. The queue registry only
* stores a pointer to the string - so the string must be persistent (global or
* preferably in ROM/Flash), not on the stack.
*/
/*
* The registry is provided as a means for kernel aware debuggers to
* locate queues, semaphores and mutexes. Call vQueueAddToRegistry() add
* a queue, semaphore or mutex handle to the registry if you want the handle
* to be available to a kernel aware debugger, and vQueueUnregisterQueue() to
* remove the queue, semaphore or mutex from the register. If you are not using
* a kernel aware debugger then this function can be ignored.
*
* @param xQueue The handle of the queue being removed from the registry.
*/
/*
* The queue registry is provided as a means for kernel aware debuggers to
* locate queues, semaphores and mutexes. Call pcQueueGetName() to look
* up and return the name of a queue in the queue registry from the queue's
* handle.
*
* @param xQueue The handle of the queue the name of which will be returned.
* @return If the queue is in the registry then a pointer to the name of the
* queue is returned. If the queue is not in the registry then NULL is
* returned.
*/
/*
* Generic version of the function used to creaet a queue using dynamic memory
* allocation. This is called by other functions and macros that create other
* RTOS objects that use the queue structure as their base.
*/
QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) ;
/*
* Generic version of the function used to creaet a queue using dynamic memory
* allocation. This is called by other functions and macros that create other
* RTOS objects that use the queue structure as their base.
*/
/*
* Queue sets provide a mechanism to allow a task to block (pend) on a read
* operation from multiple queues or semaphores simultaneously.
*
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
* function.
*
* A queue set must be explicitly created using a call to xQueueCreateSet()
* before it can be used. Once created, standard FreeRTOS queues and semaphores
* can be added to the set using calls to xQueueAddToSet().
* xQueueSelectFromSet() is then used to determine which, if any, of the queues
* or semaphores contained in the set is in a state where a queue read or
* semaphore take operation would be successful.
*
* Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html
* for reasons why queue sets are very rarely needed in practice as there are
* simpler methods of blocking on multiple objects.
*
* Note 2: Blocking on a queue set that contains a mutex will not cause the
* mutex holder to inherit the priority of the blocked task.
*
* Note 3: An additional 4 bytes of RAM is required for each space in a every
* queue added to a queue set. Therefore counting semaphores that have a high
* maximum count value should not be added to a queue set.
*
* Note 4: A receive (in the case of a queue) or take (in the case of a
* semaphore) operation must not be performed on a member of a queue set unless
* a call to xQueueSelectFromSet() has first returned a handle to that set member.
*
* @param uxEventQueueLength Queue sets store events that occur on
* the queues and semaphores contained in the set. uxEventQueueLength specifies
* the maximum number of events that can be queued at once. To be absolutely
* certain that events are not lost uxEventQueueLength should be set to the
* total sum of the length of the queues added to the set, where binary
* semaphores and mutexes have a length of 1, and counting semaphores have a
* length set by their maximum count value. Examples:
* + If a queue set is to hold a queue of length 5, another queue of length 12,
* and a binary semaphore, then uxEventQueueLength should be set to
* (5 + 12 + 1), or 18.
* + If a queue set is to hold three binary semaphores then uxEventQueueLength
* should be set to (1 + 1 + 1 ), or 3.
* + If a queue set is to hold a counting semaphore that has a maximum count of
* 5, and a counting semaphore that has a maximum count of 3, then
* uxEventQueueLength should be set to (5 + 3), or 8.
*
* @return If the queue set is created successfully then a handle to the created
* queue set is returned. Otherwise NULL is returned.
*/
QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) ;
/*
* Adds a queue or semaphore to a queue set that was previously created by a
* call to xQueueCreateSet().
*
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
* function.
*
* Note 1: A receive (in the case of a queue) or take (in the case of a
* semaphore) operation must not be performed on a member of a queue set unless
* a call to xQueueSelectFromSet() has first returned a handle to that set member.
*
* @param xQueueOrSemaphore The handle of the queue or semaphore being added to
* the queue set (cast to an QueueSetMemberHandle_t type).
*
* @param xQueueSet The handle of the queue set to which the queue or semaphore
* is being added.
*
* @return If the queue or semaphore was successfully added to the queue set
* then pdPASS is returned. If the queue could not be successfully added to the
* queue set because it is already a member of a different queue set then pdFAIL
* is returned.
*/
BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) ;
/*
* Removes a queue or semaphore from a queue set. A queue or semaphore can only
* be removed from a set if the queue or semaphore is empty.
*
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
* function.
*
* @param xQueueOrSemaphore The handle of the queue or semaphore being removed
* from the queue set (cast to an QueueSetMemberHandle_t type).
*
* @param xQueueSet The handle of the queue set in which the queue or semaphore
* is included.
*
* @return If the queue or semaphore was successfully removed from the queue set
* then pdPASS is returned. If the queue was not in the queue set, or the
* queue (or semaphore) was not empty, then pdFAIL is returned.
*/
BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) ;
/*
* xQueueSelectFromSet() selects from the members of a queue set a queue or
* semaphore that either contains data (in the case of a queue) or is available
* to take (in the case of a semaphore). xQueueSelectFromSet() effectively
* allows a task to block (pend) on a read operation on all the queues and
* semaphores in a queue set simultaneously.
*
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
* function.
*
* Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html
* for reasons why queue sets are very rarely needed in practice as there are
* simpler methods of blocking on multiple objects.
*
* Note 2: Blocking on a queue set that contains a mutex will not cause the
* mutex holder to inherit the priority of the blocked task.
*
* Note 3: A receive (in the case of a queue) or take (in the case of a
* semaphore) operation must not be performed on a member of a queue set unless
* a call to xQueueSelectFromSet() has first returned a handle to that set member.
*
* @param xQueueSet The queue set on which the task will (potentially) block.
*
* @param xTicksToWait The maximum time, in ticks, that the calling task will
* remain in the Blocked state (with other tasks executing) to wait for a member
* of the queue set to be ready for a successful queue read or semaphore take
* operation.
*
* @return xQueueSelectFromSet() will return the handle of a queue (cast to
* a QueueSetMemberHandle_t type) contained in the queue set that contains data,
* or the handle of a semaphore (cast to a QueueSetMemberHandle_t type) contained
* in the queue set that is available, or NULL if no such queue or semaphore
* exists before before the specified block time expires.
*/
QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) ;
/*
* A version of xQueueSelectFromSet() that can be used from an ISR.
*/
QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) ;
/* Not public API functions. */
void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) ;
BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) ;
void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) ;
UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) ;
uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) ;
}
typedef QueueHandle_t SemaphoreHandle_t;
/**
* semphr. h
* <pre>vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )</pre>
*
* In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a binary semaphore!
* http://www.freertos.org/RTOS-task-notifications.html
*
* This old vSemaphoreCreateBinary() macro is now deprecated in favour of the
* xSemaphoreCreateBinary() function. Note that binary semaphores created using
* the vSemaphoreCreateBinary() macro are created in a state such that the
* first call to 'take' the semaphore would pass, whereas binary semaphores
* created using xSemaphoreCreateBinary() are created in a state such that the
* the semaphore must first be 'given' before it can be 'taken'.
*
* <i>Macro</i> that implements a semaphore by using the existing queue mechanism.
* The queue length is 1 as this is a binary semaphore. The data size is 0
* as we don't want to actually store any data - we just want to know if the
* queue is empty or full.
*
* This type of semaphore can be used for pure synchronisation between tasks or
* between an interrupt and a task. The semaphore need not be given back once
* obtained, so one task/interrupt can continuously 'give' the semaphore while
* another continuously 'takes' the semaphore. For this reason this type of
* semaphore does not use a priority inheritance mechanism. For an alternative
* that does use priority inheritance see xSemaphoreCreateMutex().
*
* @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore = NULL;
void vATask( void * pvParameters )
{
// Semaphore cannot be used before a call to vSemaphoreCreateBinary ().
// This is a macro so pass the variable in directly.
vSemaphoreCreateBinary( xSemaphore );
if( xSemaphore != NULL )
{
// The semaphore was created successfully.
// The semaphore can now be used.
}
}
</pre>
* \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>SemaphoreHandle_t xSemaphoreCreateBinary( void )</pre>
*
* Creates a new binary semaphore instance, and returns a handle by which the
* new semaphore can be referenced.
*
* In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a binary semaphore!
* http://www.freertos.org/RTOS-task-notifications.html
*
* Internally, within the FreeRTOS implementation, binary semaphores use a block
* of memory, in which the semaphore structure is stored. If a binary semaphore
* is created using xSemaphoreCreateBinary() then the required memory is
* automatically dynamically allocated inside the xSemaphoreCreateBinary()
* function. (see http://www.freertos.org/a00111.html). If a binary semaphore
* is created using xSemaphoreCreateBinaryStatic() then the application writer
* must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a
* binary semaphore to be created without using any dynamic memory allocation.
*
* The old vSemaphoreCreateBinary() macro is now deprecated in favour of this
* xSemaphoreCreateBinary() function. Note that binary semaphores created using
* the vSemaphoreCreateBinary() macro are created in a state such that the
* first call to 'take' the semaphore would pass, whereas binary semaphores
* created using xSemaphoreCreateBinary() are created in a state such that the
* the semaphore must first be 'given' before it can be 'taken'.
*
* This type of semaphore can be used for pure synchronisation between tasks or
* between an interrupt and a task. The semaphore need not be given back once
* obtained, so one task/interrupt can continuously 'give' the semaphore while
* another continuously 'takes' the semaphore. For this reason this type of
* semaphore does not use a priority inheritance mechanism. For an alternative
* that does use priority inheritance see xSemaphoreCreateMutex().
*
* @return Handle to the created semaphore, or NULL if the memory required to
* hold the semaphore's data structures could not be allocated.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore = NULL;
void vATask( void * pvParameters )
{
// Semaphore cannot be used before a call to xSemaphoreCreateBinary().
// This is a macro so pass the variable in directly.
xSemaphore = xSemaphoreCreateBinary();
if( xSemaphore != NULL )
{
// The semaphore was created successfully.
// The semaphore can now be used.
}
}
</pre>
* \defgroup xSemaphoreCreateBinary xSemaphoreCreateBinary
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>SemaphoreHandle_t xSemaphoreCreateBinaryStatic( StaticSemaphore_t *pxSemaphoreBuffer )</pre>
*
* Creates a new binary semaphore instance, and returns a handle by which the
* new semaphore can be referenced.
*
* NOTE: In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a binary semaphore!
* http://www.freertos.org/RTOS-task-notifications.html
*
* Internally, within the FreeRTOS implementation, binary semaphores use a block
* of memory, in which the semaphore structure is stored. If a binary semaphore
* is created using xSemaphoreCreateBinary() then the required memory is
* automatically dynamically allocated inside the xSemaphoreCreateBinary()
* function. (see http://www.freertos.org/a00111.html). If a binary semaphore
* is created using xSemaphoreCreateBinaryStatic() then the application writer
* must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a
* binary semaphore to be created without using any dynamic memory allocation.
*
* This type of semaphore can be used for pure synchronisation between tasks or
* between an interrupt and a task. The semaphore need not be given back once
* obtained, so one task/interrupt can continuously 'give' the semaphore while
* another continuously 'takes' the semaphore. For this reason this type of
* semaphore does not use a priority inheritance mechanism. For an alternative
* that does use priority inheritance see xSemaphoreCreateMutex().
*
* @param pxSemaphoreBuffer Must point to a variable of type StaticSemaphore_t,
* which will then be used to hold the semaphore's data structure, removing the
* need for the memory to be allocated dynamically.
*
* @return If the semaphore is created then a handle to the created semaphore is
* returned. If pxSemaphoreBuffer is NULL then NULL is returned.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore = NULL;
StaticSemaphore_t xSemaphoreBuffer;
void vATask( void * pvParameters )
{
// Semaphore cannot be used before a call to xSemaphoreCreateBinary().
// The semaphore's data structures will be placed in the xSemaphoreBuffer
// variable, the address of which is passed into the function. The
// function's parameter is not NULL, so the function will not attempt any
// dynamic memory allocation, and therefore the function will not return
// return NULL.
xSemaphore = xSemaphoreCreateBinary( &xSemaphoreBuffer );
// Rest of task code goes here.
}
</pre>
* \defgroup xSemaphoreCreateBinaryStatic xSemaphoreCreateBinaryStatic
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>xSemaphoreTake(
* SemaphoreHandle_t xSemaphore,
* TickType_t xBlockTime
* )</pre>
*
* <i>Macro</i> to obtain a semaphore. The semaphore must have previously been
* created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or
* xSemaphoreCreateCounting().
*
* @param xSemaphore A handle to the semaphore being taken - obtained when
* the semaphore was created.
*
* @param xBlockTime The time in ticks to wait for the semaphore to become
* available. The macro portTICK_PERIOD_MS can be used to convert this to a
* real time. A block time of zero can be used to poll the semaphore. A block
* time of portMAX_DELAY can be used to block indefinitely (provided
* INCLUDE_vTaskSuspend is set to 1 in FreeRTOSConfig.h).
*
* @return pdTRUE if the semaphore was obtained. pdFALSE
* if xBlockTime expired without the semaphore becoming available.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore = NULL;
// A task that creates a semaphore.
void vATask( void * pvParameters )
{
// Create the semaphore to guard a shared resource.
xSemaphore = xSemaphoreCreateBinary();
}
// A task that uses the semaphore.
void vAnotherTask( void * pvParameters )
{
// ... Do other things.
if( xSemaphore != NULL )
{
// See if we can obtain the semaphore. If the semaphore is not available
// wait 10 ticks to see if it becomes free.
if( xSemaphoreTake( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
{
// We were able to obtain the semaphore and can now access the
// shared resource.
// ...
// We have finished accessing the shared resource. Release the
// semaphore.
xSemaphoreGive( xSemaphore );
}
else
{
// We could not obtain the semaphore and can therefore not access
// the shared resource safely.
}
}
}
</pre>
* \defgroup xSemaphoreTake xSemaphoreTake
* \ingroup Semaphores
*/
/**
* semphr. h
* xSemaphoreTakeRecursive(
* SemaphoreHandle_t xMutex,
* TickType_t xBlockTime
* )
*
* <i>Macro</i> to recursively obtain, or 'take', a mutex type semaphore.
* The mutex must have previously been created using a call to
* xSemaphoreCreateRecursiveMutex();
*
* configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this
* macro to be available.
*
* This macro must not be used on mutexes created using xSemaphoreCreateMutex().
*
* A mutex used recursively can be 'taken' repeatedly by the owner. The mutex
* doesn't become available again until the owner has called
* xSemaphoreGiveRecursive() for each successful 'take' request. For example,
* if a task successfully 'takes' the same mutex 5 times then the mutex will
* not be available to any other task until it has also 'given' the mutex back
* exactly five times.
*
* @param xMutex A handle to the mutex being obtained. This is the
* handle returned by xSemaphoreCreateRecursiveMutex();
*
* @param xBlockTime The time in ticks to wait for the semaphore to become
* available. The macro portTICK_PERIOD_MS can be used to convert this to a
* real time. A block time of zero can be used to poll the semaphore. If
* the task already owns the semaphore then xSemaphoreTakeRecursive() will
* return immediately no matter what the value of xBlockTime.
*
* @return pdTRUE if the semaphore was obtained. pdFALSE if xBlockTime
* expired without the semaphore becoming available.
*
* Example usage:
<pre>
SemaphoreHandle_t xMutex = NULL;
// A task that creates a mutex.
void vATask( void * pvParameters )
{
// Create the mutex to guard a shared resource.
xMutex = xSemaphoreCreateRecursiveMutex();
}
// A task that uses the mutex.
void vAnotherTask( void * pvParameters )
{
// ... Do other things.
if( xMutex != NULL )
{
// See if we can obtain the mutex. If the mutex is not available
// wait 10 ticks to see if it becomes free.
if( xSemaphoreTakeRecursive( xSemaphore, ( TickType_t ) 10 ) == pdTRUE )
{
// We were able to obtain the mutex and can now access the
// shared resource.
// ...
// For some reason due to the nature of the code further calls to
// xSemaphoreTakeRecursive() are made on the same mutex. In real
// code these would not be just sequential calls as this would make
// no sense. Instead the calls are likely to be buried inside
// a more complex call structure.
xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
// The mutex has now been 'taken' three times, so will not be
// available to another task until it has also been given back
// three times. Again it is unlikely that real code would have
// these calls sequentially, but instead buried in a more complex
// call structure. This is just for illustrative purposes.
xSemaphoreGiveRecursive( xMutex );
xSemaphoreGiveRecursive( xMutex );
xSemaphoreGiveRecursive( xMutex );
// Now the mutex can be taken by other tasks.
}
else
{
// We could not obtain the mutex and can therefore not access
// the shared resource safely.
}
}
}
</pre>
* \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>xSemaphoreGive( SemaphoreHandle_t xSemaphore )</pre>
*
* <i>Macro</i> to release a semaphore. The semaphore must have previously been
* created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or
* xSemaphoreCreateCounting(). and obtained using sSemaphoreTake().
*
* This macro must not be used from an ISR. See xSemaphoreGiveFromISR () for
* an alternative which can be used from an ISR.
*
* This macro must also not be used on semaphores created using
* xSemaphoreCreateRecursiveMutex().
*
* @param xSemaphore A handle to the semaphore being released. This is the
* handle returned when the semaphore was created.
*
* @return pdTRUE if the semaphore was released. pdFALSE if an error occurred.
* Semaphores are implemented using queues. An error can occur if there is
* no space on the queue to post a message - indicating that the
* semaphore was not first obtained correctly.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore = NULL;
void vATask( void * pvParameters )
{
// Create the semaphore to guard a shared resource.
xSemaphore = vSemaphoreCreateBinary();
if( xSemaphore != NULL )
{
if( xSemaphoreGive( xSemaphore ) != pdTRUE )
{
// We would expect this call to fail because we cannot give
// a semaphore without first "taking" it!
}
// Obtain the semaphore - don't block if the semaphore is not
// immediately available.
if( xSemaphoreTake( xSemaphore, ( TickType_t ) 0 ) )
{
// We now have the semaphore and can access the shared resource.
// ...
// We have finished accessing the shared resource so can free the
// semaphore.
if( xSemaphoreGive( xSemaphore ) != pdTRUE )
{
// We would not expect this call to fail because we must have
// obtained the semaphore to get here.
}
}
}
}
</pre>
* \defgroup xSemaphoreGive xSemaphoreGive
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )</pre>
*
* <i>Macro</i> to recursively release, or 'give', a mutex type semaphore.
* The mutex must have previously been created using a call to
* xSemaphoreCreateRecursiveMutex();
*
* configUSE_RECURSIVE_MUTEXES must be set to 1 in FreeRTOSConfig.h for this
* macro to be available.
*
* This macro must not be used on mutexes created using xSemaphoreCreateMutex().
*
* A mutex used recursively can be 'taken' repeatedly by the owner. The mutex
* doesn't become available again until the owner has called
* xSemaphoreGiveRecursive() for each successful 'take' request. For example,
* if a task successfully 'takes' the same mutex 5 times then the mutex will
* not be available to any other task until it has also 'given' the mutex back
* exactly five times.
*
* @param xMutex A handle to the mutex being released, or 'given'. This is the
* handle returned by xSemaphoreCreateMutex();
*
* @return pdTRUE if the semaphore was given.
*
* Example usage:
<pre>
SemaphoreHandle_t xMutex = NULL;
// A task that creates a mutex.
void vATask( void * pvParameters )
{
// Create the mutex to guard a shared resource.
xMutex = xSemaphoreCreateRecursiveMutex();
}
// A task that uses the mutex.
void vAnotherTask( void * pvParameters )
{
// ... Do other things.
if( xMutex != NULL )
{
// See if we can obtain the mutex. If the mutex is not available
// wait 10 ticks to see if it becomes free.
if( xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 ) == pdTRUE )
{
// We were able to obtain the mutex and can now access the
// shared resource.
// ...
// For some reason due to the nature of the code further calls to
// xSemaphoreTakeRecursive() are made on the same mutex. In real
// code these would not be just sequential calls as this would make
// no sense. Instead the calls are likely to be buried inside
// a more complex call structure.
xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
xSemaphoreTakeRecursive( xMutex, ( TickType_t ) 10 );
// The mutex has now been 'taken' three times, so will not be
// available to another task until it has also been given back
// three times. Again it is unlikely that real code would have
// these calls sequentially, it would be more likely that the calls
// to xSemaphoreGiveRecursive() would be called as a call stack
// unwound. This is just for demonstrative purposes.
xSemaphoreGiveRecursive( xMutex );
xSemaphoreGiveRecursive( xMutex );
xSemaphoreGiveRecursive( xMutex );
// Now the mutex can be taken by other tasks.
}
else
{
// We could not obtain the mutex and can therefore not access
// the shared resource safely.
}
}
}
</pre>
* \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>
xSemaphoreGiveFromISR(
SemaphoreHandle_t xSemaphore,
BaseType_t *pxHigherPriorityTaskWoken
)</pre>
*
* <i>Macro</i> to release a semaphore. The semaphore must have previously been
* created with a call to xSemaphoreCreateBinary() or xSemaphoreCreateCounting().
*
* Mutex type semaphores (those created using a call to xSemaphoreCreateMutex())
* must not be used with this macro.
*
* This macro can be used from an ISR.
*
* @param xSemaphore A handle to the semaphore being released. This is the
* handle returned when the semaphore was created.
*
* @param pxHigherPriorityTaskWoken xSemaphoreGiveFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if giving the semaphore caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xSemaphoreGiveFromISR() sets this value to pdTRUE then
* a context switch should be requested before the interrupt is exited.
*
* @return pdTRUE if the semaphore was successfully given, otherwise errQUEUE_FULL.
*
* Example usage:
<pre>
\#define LONG_TIME 0xffff
\#define TICKS_TO_WAIT 10
SemaphoreHandle_t xSemaphore = NULL;
// Repetitive task.
void vATask( void * pvParameters )
{
for( ;; )
{
// We want this task to run every 10 ticks of a timer. The semaphore
// was created before this task was started.
// Block waiting for the semaphore to become available.
if( xSemaphoreTake( xSemaphore, LONG_TIME ) == pdTRUE )
{
// It is time to execute.
// ...
// We have finished our task. Return to the top of the loop where
// we will block on the semaphore until it is time to execute
// again. Note when using the semaphore for synchronisation with an
// ISR in this manner there is no need to 'give' the semaphore back.
}
}
}
// Timer ISR
void vTimerISR( void * pvParameters )
{
static uint8_t ucLocalTickCount = 0;
static BaseType_t xHigherPriorityTaskWoken;
// A timer tick has occurred.
// ... Do other time functions.
// Is it time for vATask () to run?
xHigherPriorityTaskWoken = pdFALSE;
ucLocalTickCount++;
if( ucLocalTickCount >= TICKS_TO_WAIT )
{
// Unblock the task by releasing the semaphore.
xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
// Reset the count so we release the semaphore again in 10 ticks time.
ucLocalTickCount = 0;
}
if( xHigherPriorityTaskWoken != pdFALSE )
{
// We can force a context switch here. Context switching from an
// ISR uses port specific syntax. Check the demo task for your port
// to find the syntax required.
}
}
</pre>
* \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>
xSemaphoreTakeFromISR(
SemaphoreHandle_t xSemaphore,
BaseType_t *pxHigherPriorityTaskWoken
)</pre>
*
* <i>Macro</i> to take a semaphore from an ISR. The semaphore must have
* previously been created with a call to xSemaphoreCreateBinary() or
* xSemaphoreCreateCounting().
*
* Mutex type semaphores (those created using a call to xSemaphoreCreateMutex())
* must not be used with this macro.
*
* This macro can be used from an ISR, however taking a semaphore from an ISR
* is not a common operation. It is likely to only be useful when taking a
* counting semaphore when an interrupt is obtaining an object from a resource
* pool (when the semaphore count indicates the number of resources available).
*
* @param xSemaphore A handle to the semaphore being taken. This is the
* handle returned when the semaphore was created.
*
* @param pxHigherPriorityTaskWoken xSemaphoreTakeFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if taking the semaphore caused a task
* to unblock, and the unblocked task has a priority higher than the currently
* running task. If xSemaphoreTakeFromISR() sets this value to pdTRUE then
* a context switch should be requested before the interrupt is exited.
*
* @return pdTRUE if the semaphore was successfully taken, otherwise
* pdFALSE
*/
/**
* semphr. h
* <pre>SemaphoreHandle_t xSemaphoreCreateMutex( void )</pre>
*
* Creates a new mutex type semaphore instance, and returns a handle by which
* the new mutex can be referenced.
*
* Internally, within the FreeRTOS implementation, mutex semaphores use a block
* of memory, in which the mutex structure is stored. If a mutex is created
* using xSemaphoreCreateMutex() then the required memory is automatically
* dynamically allocated inside the xSemaphoreCreateMutex() function. (see
* http://www.freertos.org/a00111.html). If a mutex is created using
* xSemaphoreCreateMutexStatic() then the application writer must provided the
* memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created
* without using any dynamic memory allocation.
*
* Mutexes created using this function can be accessed using the xSemaphoreTake()
* and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and
* xSemaphoreGiveRecursive() macros must not be used.
*
* This type of semaphore uses a priority inheritance mechanism so a task
* 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the
* semaphore it is no longer required.
*
* Mutex type semaphores cannot be used from within interrupt service routines.
*
* See xSemaphoreCreateBinary() for an alternative implementation that can be
* used for pure synchronisation (where one task or interrupt always 'gives' the
* semaphore and another always 'takes' the semaphore) and from within interrupt
* service routines.
*
* @return If the mutex was successfully created then a handle to the created
* semaphore is returned. If there was not enough heap to allocate the mutex
* data structures then NULL is returned.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore;
void vATask( void * pvParameters )
{
// Semaphore cannot be used before a call to xSemaphoreCreateMutex().
// This is a macro so pass the variable in directly.
xSemaphore = xSemaphoreCreateMutex();
if( xSemaphore != NULL )
{
// The semaphore was created successfully.
// The semaphore can now be used.
}
}
</pre>
* \defgroup xSemaphoreCreateMutex xSemaphoreCreateMutex
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSemaphore_t *pxMutexBuffer )</pre>
*
* Creates a new mutex type semaphore instance, and returns a handle by which
* the new mutex can be referenced.
*
* Internally, within the FreeRTOS implementation, mutex semaphores use a block
* of memory, in which the mutex structure is stored. If a mutex is created
* using xSemaphoreCreateMutex() then the required memory is automatically
* dynamically allocated inside the xSemaphoreCreateMutex() function. (see
* http://www.freertos.org/a00111.html). If a mutex is created using
* xSemaphoreCreateMutexStatic() then the application writer must provided the
* memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created
* without using any dynamic memory allocation.
*
* Mutexes created using this function can be accessed using the xSemaphoreTake()
* and xSemaphoreGive() macros. The xSemaphoreTakeRecursive() and
* xSemaphoreGiveRecursive() macros must not be used.
*
* This type of semaphore uses a priority inheritance mechanism so a task
* 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the
* semaphore it is no longer required.
*
* Mutex type semaphores cannot be used from within interrupt service routines.
*
* See xSemaphoreCreateBinary() for an alternative implementation that can be
* used for pure synchronisation (where one task or interrupt always 'gives' the
* semaphore and another always 'takes' the semaphore) and from within interrupt
* service routines.
*
* @param pxMutexBuffer Must point to a variable of type StaticSemaphore_t,
* which will be used to hold the mutex's data structure, removing the need for
* the memory to be allocated dynamically.
*
* @return If the mutex was successfully created then a handle to the created
* mutex is returned. If pxMutexBuffer was NULL then NULL is returned.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore;
StaticSemaphore_t xMutexBuffer;
void vATask( void * pvParameters )
{
// A mutex cannot be used before it has been created. xMutexBuffer is
// into xSemaphoreCreateMutexStatic() so no dynamic memory allocation is
// attempted.
xSemaphore = xSemaphoreCreateMutexStatic( &xMutexBuffer );
// As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
// so there is no need to check it.
}
</pre>
* \defgroup xSemaphoreCreateMutexStatic xSemaphoreCreateMutexStatic
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>SemaphoreHandle_t xSemaphoreCreateRecursiveMutex( void )</pre>
*
* Creates a new recursive mutex type semaphore instance, and returns a handle
* by which the new recursive mutex can be referenced.
*
* Internally, within the FreeRTOS implementation, recursive mutexs use a block
* of memory, in which the mutex structure is stored. If a recursive mutex is
* created using xSemaphoreCreateRecursiveMutex() then the required memory is
* automatically dynamically allocated inside the
* xSemaphoreCreateRecursiveMutex() function. (see
* http://www.freertos.org/a00111.html). If a recursive mutex is created using
* xSemaphoreCreateRecursiveMutexStatic() then the application writer must
* provide the memory that will get used by the mutex.
* xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to
* be created without using any dynamic memory allocation.
*
* Mutexes created using this macro can be accessed using the
* xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() macros. The
* xSemaphoreTake() and xSemaphoreGive() macros must not be used.
*
* A mutex used recursively can be 'taken' repeatedly by the owner. The mutex
* doesn't become available again until the owner has called
* xSemaphoreGiveRecursive() for each successful 'take' request. For example,
* if a task successfully 'takes' the same mutex 5 times then the mutex will
* not be available to any other task until it has also 'given' the mutex back
* exactly five times.
*
* This type of semaphore uses a priority inheritance mechanism so a task
* 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the
* semaphore it is no longer required.
*
* Mutex type semaphores cannot be used from within interrupt service routines.
*
* See xSemaphoreCreateBinary() for an alternative implementation that can be
* used for pure synchronisation (where one task or interrupt always 'gives' the
* semaphore and another always 'takes' the semaphore) and from within interrupt
* service routines.
*
* @return xSemaphore Handle to the created mutex semaphore. Should be of type
* SemaphoreHandle_t.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore;
void vATask( void * pvParameters )
{
// Semaphore cannot be used before a call to xSemaphoreCreateMutex().
// This is a macro so pass the variable in directly.
xSemaphore = xSemaphoreCreateRecursiveMutex();
if( xSemaphore != NULL )
{
// The semaphore was created successfully.
// The semaphore can now be used.
}
}
</pre>
* \defgroup xSemaphoreCreateRecursiveMutex xSemaphoreCreateRecursiveMutex
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic( StaticSemaphore_t *pxMutexBuffer )</pre>
*
* Creates a new recursive mutex type semaphore instance, and returns a handle
* by which the new recursive mutex can be referenced.
*
* Internally, within the FreeRTOS implementation, recursive mutexs use a block
* of memory, in which the mutex structure is stored. If a recursive mutex is
* created using xSemaphoreCreateRecursiveMutex() then the required memory is
* automatically dynamically allocated inside the
* xSemaphoreCreateRecursiveMutex() function. (see
* http://www.freertos.org/a00111.html). If a recursive mutex is created using
* xSemaphoreCreateRecursiveMutexStatic() then the application writer must
* provide the memory that will get used by the mutex.
* xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to
* be created without using any dynamic memory allocation.
*
* Mutexes created using this macro can be accessed using the
* xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive() macros. The
* xSemaphoreTake() and xSemaphoreGive() macros must not be used.
*
* A mutex used recursively can be 'taken' repeatedly by the owner. The mutex
* doesn't become available again until the owner has called
* xSemaphoreGiveRecursive() for each successful 'take' request. For example,
* if a task successfully 'takes' the same mutex 5 times then the mutex will
* not be available to any other task until it has also 'given' the mutex back
* exactly five times.
*
* This type of semaphore uses a priority inheritance mechanism so a task
* 'taking' a semaphore MUST ALWAYS 'give' the semaphore back once the
* semaphore it is no longer required.
*
* Mutex type semaphores cannot be used from within interrupt service routines.
*
* See xSemaphoreCreateBinary() for an alternative implementation that can be
* used for pure synchronisation (where one task or interrupt always 'gives' the
* semaphore and another always 'takes' the semaphore) and from within interrupt
* service routines.
*
* @param pxMutexBuffer Must point to a variable of type StaticSemaphore_t,
* which will then be used to hold the recursive mutex's data structure,
* removing the need for the memory to be allocated dynamically.
*
* @return If the recursive mutex was successfully created then a handle to the
* created recursive mutex is returned. If pxMutexBuffer was NULL then NULL is
* returned.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore;
StaticSemaphore_t xMutexBuffer;
void vATask( void * pvParameters )
{
// A recursive semaphore cannot be used before it is created. Here a
// recursive mutex is created using xSemaphoreCreateRecursiveMutexStatic().
// The address of xMutexBuffer is passed into the function, and will hold
// the mutexes data structures - so no dynamic memory allocation will be
// attempted.
xSemaphore = xSemaphoreCreateRecursiveMutexStatic( &xMutexBuffer );
// As no dynamic memory allocation was performed, xSemaphore cannot be NULL,
// so there is no need to check it.
}
</pre>
* \defgroup xSemaphoreCreateRecursiveMutexStatic xSemaphoreCreateRecursiveMutexStatic
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount )</pre>
*
* Creates a new counting semaphore instance, and returns a handle by which the
* new counting semaphore can be referenced.
*
* In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a counting semaphore!
* http://www.freertos.org/RTOS-task-notifications.html
*
* Internally, within the FreeRTOS implementation, counting semaphores use a
* block of memory, in which the counting semaphore structure is stored. If a
* counting semaphore is created using xSemaphoreCreateCounting() then the
* required memory is automatically dynamically allocated inside the
* xSemaphoreCreateCounting() function. (see
* http://www.freertos.org/a00111.html). If a counting semaphore is created
* using xSemaphoreCreateCountingStatic() then the application writer can
* instead optionally provide the memory that will get used by the counting
* semaphore. xSemaphoreCreateCountingStatic() therefore allows a counting
* semaphore to be created without using any dynamic memory allocation.
*
* Counting semaphores are typically used for two things:
*
* 1) Counting events.
*
* In this usage scenario an event handler will 'give' a semaphore each time
* an event occurs (incrementing the semaphore count value), and a handler
* task will 'take' a semaphore each time it processes an event
* (decrementing the semaphore count value). The count value is therefore
* the difference between the number of events that have occurred and the
* number that have been processed. In this case it is desirable for the
* initial count value to be zero.
*
* 2) Resource management.
*
* In this usage scenario the count value indicates the number of resources
* available. To obtain control of a resource a task must first obtain a
* semaphore - decrementing the semaphore count value. When the count value
* reaches zero there are no free resources. When a task finishes with the
* resource it 'gives' the semaphore back - incrementing the semaphore count
* value. In this case it is desirable for the initial count value to be
* equal to the maximum count value, indicating that all resources are free.
*
* @param uxMaxCount The maximum count value that can be reached. When the
* semaphore reaches this value it can no longer be 'given'.
*
* @param uxInitialCount The count value assigned to the semaphore when it is
* created.
*
* @return Handle to the created semaphore. Null if the semaphore could not be
* created.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore;
void vATask( void * pvParameters )
{
SemaphoreHandle_t xSemaphore = NULL;
// Semaphore cannot be used before a call to xSemaphoreCreateCounting().
// The max value to which the semaphore can count should be 10, and the
// initial value assigned to the count should be 0.
xSemaphore = xSemaphoreCreateCounting( 10, 0 );
if( xSemaphore != NULL )
{
// The semaphore was created successfully.
// The semaphore can now be used.
}
}
</pre>
* \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer )</pre>
*
* Creates a new counting semaphore instance, and returns a handle by which the
* new counting semaphore can be referenced.
*
* In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a counting semaphore!
* http://www.freertos.org/RTOS-task-notifications.html
*
* Internally, within the FreeRTOS implementation, counting semaphores use a
* block of memory, in which the counting semaphore structure is stored. If a
* counting semaphore is created using xSemaphoreCreateCounting() then the
* required memory is automatically dynamically allocated inside the
* xSemaphoreCreateCounting() function. (see
* http://www.freertos.org/a00111.html). If a counting semaphore is created
* using xSemaphoreCreateCountingStatic() then the application writer must
* provide the memory. xSemaphoreCreateCountingStatic() therefore allows a
* counting semaphore to be created without using any dynamic memory allocation.
*
* Counting semaphores are typically used for two things:
*
* 1) Counting events.
*
* In this usage scenario an event handler will 'give' a semaphore each time
* an event occurs (incrementing the semaphore count value), and a handler
* task will 'take' a semaphore each time it processes an event
* (decrementing the semaphore count value). The count value is therefore
* the difference between the number of events that have occurred and the
* number that have been processed. In this case it is desirable for the
* initial count value to be zero.
*
* 2) Resource management.
*
* In this usage scenario the count value indicates the number of resources
* available. To obtain control of a resource a task must first obtain a
* semaphore - decrementing the semaphore count value. When the count value
* reaches zero there are no free resources. When a task finishes with the
* resource it 'gives' the semaphore back - incrementing the semaphore count
* value. In this case it is desirable for the initial count value to be
* equal to the maximum count value, indicating that all resources are free.
*
* @param uxMaxCount The maximum count value that can be reached. When the
* semaphore reaches this value it can no longer be 'given'.
*
* @param uxInitialCount The count value assigned to the semaphore when it is
* created.
*
* @param pxSemaphoreBuffer Must point to a variable of type StaticSemaphore_t,
* which will then be used to hold the semaphore's data structure, removing the
* need for the memory to be allocated dynamically.
*
* @return If the counting semaphore was successfully created then a handle to
* the created counting semaphore is returned. If pxSemaphoreBuffer was NULL
* then NULL is returned.
*
* Example usage:
<pre>
SemaphoreHandle_t xSemaphore;
StaticSemaphore_t xSemaphoreBuffer;
void vATask( void * pvParameters )
{
SemaphoreHandle_t xSemaphore = NULL;
// Counting semaphore cannot be used before they have been created. Create
// a counting semaphore using xSemaphoreCreateCountingStatic(). The max
// value to which the semaphore can count is 10, and the initial value
// assigned to the count will be 0. The address of xSemaphoreBuffer is
// passed in and will be used to hold the semaphore structure, so no dynamic
// memory allocation will be used.
xSemaphore = xSemaphoreCreateCounting( 10, 0, &xSemaphoreBuffer );
// No memory allocation was attempted so xSemaphore cannot be NULL, so there
// is no need to check its value.
}
</pre>
* \defgroup xSemaphoreCreateCountingStatic xSemaphoreCreateCountingStatic
* \ingroup Semaphores
*/
/**
* semphr. h
* <pre>void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );</pre>
*
* Delete a semaphore. This function must be used with care. For example,
* do not delete a mutex type semaphore if the mutex is held by a task.
*
* @param xSemaphore A handle to the semaphore to be deleted.
*
* \defgroup vSemaphoreDelete vSemaphoreDelete
* \ingroup Semaphores
*/
/**
* semphr.h
* <pre>TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );</pre>
*
* If xMutex is indeed a mutex type semaphore, return the current mutex holder.
* If xMutex is not a mutex type semaphore, or the mutex is available (not held
* by a task), return NULL.
*
* Note: This is a good way of determining if the calling task is the mutex
* holder, but not a good way of determining the identity of the mutex holder as
* the holder may change between the function exiting and the returned value
* being tested.
*/
/**
* semphr.h
* <pre>UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );</pre>
*
* If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns
* its current count value. If the semaphore is a binary semaphore then
* uxSemaphoreGetCount() returns 1 if the semaphore is available, and 0 if the
* semaphore is not available.
*
*/
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*
* This is the list implementation used by the scheduler. While it is tailored
* heavily for the schedulers needs, it is also available for use by
* application code.
*
* list_ts can only store pointers to list_item_ts. Each ListItem_t contains a
* numeric value (xItemValue). Most of the time the lists are sorted in
* descending item value order.
*
* Lists are created already containing one list item. The value of this
* item is the maximum possible that can be stored, it is therefore always at
* the end of the list and acts as a marker. The list member pxHead always
* points to this marker - even though it is at the tail of the list. This
* is because the tail contains a wrap back pointer to the true head of
* the list.
*
* In addition to it's value, each list item contains a pointer to the next
* item in the list (pxNext), a pointer to the list it is in (pxContainer)
* and a pointer to back to the object that contains it. These later two
* pointers are included for efficiency of list manipulation. There is
* effectively a two way link between the object containing the list item and
* the list item itself.
*
*
* \page ListIntroduction List Implementation
* \ingroup FreeRTOSIntro
*/
/*
* The list structure members are modified from within interrupts, and therefore
* by rights should be declared volatile. However, they are only modified in a
* functionally atomic way (within critical sections of with the scheduler
* suspended) and are either passed by reference into a function or indexed via
* a volatile variable. Therefore, in all use cases tested so far, the volatile
* qualifier can be omitted in order to provide a moderate performance
* improvement without adversely affecting functional behaviour. The assembly
* instructions generated by the IAR, ARM and GCC compilers when the respective
* compiler's options were set for maximum optimisation has been inspected and
* deemed to be as intended. That said, as compiler technology advances, and
* especially if aggressive cross module optimisation is used (a use case that
* has not been exercised to any great extend) then it is feasible that the
* volatile qualifier will be needed for correct optimisation. It is expected
* that a compiler removing essential code because, without the volatile
* qualifier on the list structure members and with aggressive cross module
* optimisation, the compiler deemed the code unnecessary will result in
* complete and obvious failure of the scheduler. If this is ever experienced
* then the volatile qualifier can be inserted in the relevant places within the
* list structures by simply defining configLIST_VOLATILE to volatile in
* FreeRTOSConfig.h (as per the example at the bottom of this comment block).
* If configLIST_VOLATILE is not defined then the preprocessor directives below
* will simply #define configLIST_VOLATILE away completely.
*
* To use volatile list structure members then add the following line to
* FreeRTOSConfig.h (without the quotes):
* "#define configLIST_VOLATILE volatile"
*/
extern "C" {
/* Macros that can be used to place known values within the list structures,
then check that the known values do not get corrupted during the execution of
the application. These may catch the list data structures being overwritten in
memory. They will not catch data errors caused by incorrect configuration or
use of FreeRTOS.*/
/* Define the macros to do nothing. */
/*
* Definition of the only type of object that a list can contain.
*/
struct xLIST_ITEM
{
/*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */
struct xLIST_ITEM * pxNext; /*< Pointer to the next ListItem_t in the list. */
struct xLIST_ITEM * pxPrevious; /*< Pointer to the previous ListItem_t in the list. */
void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
void * pvContainer; /*< Pointer to the list in which this list item is placed (if any). */
/*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
};
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */
struct xMINI_LIST_ITEM
{
/*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
TickType_t xItemValue;
struct xLIST_ITEM * pxNext;
struct xLIST_ITEM * pxPrevious;
};
typedef struct xMINI_LIST_ITEM MiniListItem_t;
/*
* Definition of the type of queue used by the scheduler.
*/
typedef struct xLIST
{
/*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
UBaseType_t uxNumberOfItems;
ListItem_t * pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */
MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
/*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
} List_t;
/*
* Access macro to set the owner of a list item. The owner of a list item
* is the object (usually a TCB) that contains the list item.
*
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
* \ingroup LinkedList
*/
/*
* Access macro to get the owner of a list item. The owner of a list item
* is the object (usually a TCB) that contains the list item.
*
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
* \ingroup LinkedList
*/
/*
* Access macro to set the value of the list item. In most cases the value is
* used to sort the list in descending order.
*
* \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
/*
* Access macro to retrieve the value of the list item. The value can
* represent anything - for example the priority of a task, or the time at
* which a task should be unblocked.
*
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
/*
* Access macro to retrieve the value of the list item at the head of a given
* list.
*
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
/*
* Return the list item at the head of the list.
*
* \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY
* \ingroup LinkedList
*/
/*
* Return the list item at the head of the list.
*
* \page listGET_NEXT listGET_NEXT
* \ingroup LinkedList
*/
/*
* Return the list item that marks the end of the list
*
* \page listGET_END_MARKER listGET_END_MARKER
* \ingroup LinkedList
*/
/*
* Access macro to determine if a list contains any items. The macro will
* only have the value true if the list is empty.
*
* \page listLIST_IS_EMPTY listLIST_IS_EMPTY
* \ingroup LinkedList
*/
/*
* Access macro to return the number of items in the list.
*/
/*
* Access function to obtain the owner of the next entry in a list.
*
* The list member pxIndex is used to walk through a list. Calling
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list
* and returns that entry's pxOwner parameter. Using multiple calls to this
* function it is therefore possible to move through every item contained in
* a list.
*
* The pxOwner parameter of a list item is a pointer to the object that owns
* the list item. In the scheduler this is normally a task control block.
* The pxOwner parameter effectively creates a two way link between the list
* item and its owner.
*
* @param pxTCB pxTCB is set to the address of the owner of the next list item.
* @param pxList The list from which the next item owner is to be returned.
*
* \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY
* \ingroup LinkedList
*/
/*
* Access function to obtain the owner of the first entry in a list. Lists
* are normally sorted in ascending item value order.
*
* This function returns the pxOwner member of the first item in the list.
* The pxOwner parameter of a list item is a pointer to the object that owns
* the list item. In the scheduler this is normally a task control block.
* The pxOwner parameter effectively creates a two way link between the list
* item and its owner.
*
* @param pxList The list from which the owner of the head item is to be
* returned.
*
* \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY
* \ingroup LinkedList
*/
/*
* Check to see if a list item is within a list. The list item maintains a
* "container" pointer that points to the list it is in. All this macro does
* is check to see if the container and the list match.
*
* @param pxList The list we want to know if the list item is within.
* @param pxListItem The list item we want to know if is in the list.
* @return pdTRUE if the list item is in the list, otherwise pdFALSE.
*/
/*
* Return the list a list item is contained within (referenced from).
*
* @param pxListItem The list item being queried.
* @return A pointer to the List_t object that references the pxListItem
*/
/*
* This provides a crude means of knowing if a list has been initialised, as
* pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise()
* function.
*/
/*
* Must be called before a list is used! This initialises all the members
* of the list structure and inserts the xListEnd item into the list as a
* marker to the back of the list.
*
* @param pxList Pointer to the list being initialised.
*
* \page vListInitialise vListInitialise
* \ingroup LinkedList
*/
void vListInitialise( List_t * const pxList ) ;
/*
* Must be called before a list item is used. This sets the list container to
* null so the item does not think that it is already contained in a list.
*
* @param pxItem Pointer to the list item being initialised.
*
* \page vListInitialiseItem vListInitialiseItem
* \ingroup LinkedList
*/
void vListInitialiseItem( ListItem_t * const pxItem ) ;
/*
* Insert a list item into a list. The item will be inserted into the list in
* a position determined by its item value (descending item value order).
*
* @param pxList The list into which the item is to be inserted.
*
* @param pxNewListItem The item that is to be placed in the list.
*
* \page vListInsert vListInsert
* \ingroup LinkedList
*/
void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) ;
/*
* Insert a list item into a list. The item will be inserted in a position
* such that it will be the last item within the list returned by multiple
* calls to listGET_OWNER_OF_NEXT_ENTRY.
*
* The list member pxIndex is used to walk through a list. Calling
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list.
* Placing an item in a list using vListInsertEnd effectively places the item
* in the list position pointed to by pxIndex. This means that every other
* item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before
* the pxIndex parameter again points to the item being inserted.
*
* @param pxList The list into which the item is to be inserted.
*
* @param pxNewListItem The list item to be inserted into the list.
*
* \page vListInsertEnd vListInsertEnd
* \ingroup LinkedList
*/
void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) ;
/*
* Remove an item from a list. The list item has a pointer to the list that
* it is in, so only the list item need be passed into the function.
*
* @param uxListRemove The item to be removed. The item will remove itself from
* the list pointed to by it's pxContainer parameter.
*
* @return The number of items that remain in the list after the list item has
* been removed.
*
* \page uxListRemove uxListRemove
* \ingroup LinkedList
*/
UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) ;
}
extern "C" {
/*-----------------------------------------------------------
* MACROS AND DEFINITIONS
*----------------------------------------------------------*/
/**
* task. h
*
* Type by which tasks are referenced. For example, a call to xTaskCreate
* returns (via a pointer parameter) an TaskHandle_t variable that can then
* be used as a parameter to vTaskDelete to delete the task.
*
* \defgroup TaskHandle_t TaskHandle_t
* \ingroup Tasks
*/
typedef void * TaskHandle_t;
/*
* Defines the prototype to which the application task hook function must
* conform.
*/
typedef BaseType_t (*TaskHookFunction_t)( void * );
/* Task states returned by eTaskGetState. */
typedef enum
{
eRunning = 0, /* A task is querying the state of itself, so must be running. */
eReady, /* The task being queried is in a read or pending ready list. */
eBlocked, /* The task being queried is in the Blocked state. */
eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */
eInvalid /* Used as an 'invalid state' value. */
} eTaskState;
/* Actions that can be performed when vTaskNotify() is called. */
typedef enum
{
eNoAction = 0, /* Notify the task without updating its notify value. */
eSetBits, /* Set bits in the task's notification value. */
eIncrement, /* Increment the task's notification value. */
eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
} eNotifyAction;
/*
* Used internally only.
*/
typedef struct xTIME_OUT
{
BaseType_t xOverflowCount;
TickType_t xTimeOnEntering;
} TimeOut_t;
/*
* Defines the memory ranges allocated to the task when an MPU is used.
*/
typedef struct xMEMORY_REGION
{
void *pvBaseAddress;
uint32_t ulLengthInBytes;
uint32_t ulParameters;
} MemoryRegion_t;
/*
* Parameters required to create an MPU protected task.
*/
typedef struct xTASK_PARAMETERS
{
TaskFunction_t pvTaskCode;
const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
uint16_t usStackDepth;
void *pvParameters;
UBaseType_t uxPriority;
StackType_t *puxStackBuffer;
MemoryRegion_t xRegions[ ( ( ( ( 12UL ) - 2 ) - ( 6UL - 1UL ) ) + 1 ) ];
} TaskParameters_t;
/* Used with the uxTaskGetSystemState() function to return the state of each task
in the system. */
typedef struct xTASK_STATUS
{
TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
const char *pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
UBaseType_t xTaskNumber; /* A number unique to the task. */
eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
UBaseType_t uxBasePriority; /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex. Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */
uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
StackType_t *pxStackBase; /* Points to the lowest address of the task's stack area. */
uint16_t usStackHighWaterMark; /* The minimum amount of stack space that has remained for the task since the task was created. The closer this value is to zero the closer the task has come to overflowing its stack. */
} TaskStatus_t;
/* Possible return values for eTaskConfirmSleepModeStatus(). */
typedef enum
{
eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */
eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */
eNoTasksWaitingTimeout /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */
} eSleepModeStatus;
/**
* Defines the priority used by the idle task. This must not be modified.
*
* \ingroup TaskUtils
*/
/**
* task. h
*
* Macro for forcing a context switch.
*
* \defgroup taskYIELD taskYIELD
* \ingroup SchedulerControl
*/
/**
* task. h
*
* Macro to mark the start of a critical code region. Preemptive context
* switches cannot occur when in a critical region.
*
* NOTE: This may alter the stack (depending on the portable implementation)
* so must be used with care!
*
* \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
* \ingroup SchedulerControl
*/
/**
* task. h
*
* Macro to mark the end of a critical code region. Preemptive context
* switches cannot occur when in a critical region.
*
* NOTE: This may alter the stack (depending on the portable implementation)
* so must be used with care!
*
* \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
* \ingroup SchedulerControl
*/
/**
* task. h
*
* Macro to disable all maskable interrupts.
*
* \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
* \ingroup SchedulerControl
*/
/**
* task. h
*
* Macro to enable microcontroller interrupts.
*
* \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
* \ingroup SchedulerControl
*/
/* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
0 to generate more optimal code when configASSERT() is defined as the constant
is used in assert() statements. */
/*-----------------------------------------------------------
* TASK CREATION API
*----------------------------------------------------------*/
/**
* task. h
*<pre>
BaseType_t xTaskCreate(
TaskFunction_t pvTaskCode,
const char * const pcName,
uint16_t usStackDepth,
void *pvParameters,
UBaseType_t uxPriority,
TaskHandle_t *pvCreatedTask
);</pre>
*
* Create a new task and add it to the list of tasks that are ready to run.
*
* Internally, within the FreeRTOS implementation, tasks use two blocks of
* memory. The first block is used to hold the task's data structures. The
* second block is used by the task as its stack. If a task is created using
* xTaskCreate() then both blocks of memory are automatically dynamically
* allocated inside the xTaskCreate() function. (see
* http://www.freertos.org/a00111.html). If a task is created using
* xTaskCreateStatic() then the application writer must provide the required
* memory. xTaskCreateStatic() therefore allows a task to be created without
* using any dynamic memory allocation.
*
* See xTaskCreateStatic() for a version that does not use any dynamic memory
* allocation.
*
* xTaskCreate() can only be used to create a task that has unrestricted
* access to the entire microcontroller memory map. Systems that include MPU
* support can alternatively create an MPU constrained task using
* xTaskCreateRestricted().
*
* @param pvTaskCode Pointer to the task entry function. Tasks
* must be implemented to never return (i.e. continuous loop).
*
* @param pcName A descriptive name for the task. This is mainly used to
* facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
* is 16.
*
* @param usStackDepth The size of the task stack specified as the number of
* variables the stack can hold - not the number of bytes. For example, if
* the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
* will be allocated for stack storage.
*
* @param pvParameters Pointer that will be used as the parameter for the task
* being created.
*
* @param uxPriority The priority at which the task should run. Systems that
* include MPU support can optionally create tasks in a privileged (system)
* mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
* example, to create a privileged task at priority 2 the uxPriority parameter
* should be set to ( 2 | portPRIVILEGE_BIT ).
*
* @param pvCreatedTask Used to pass back a handle by which the created task
* can be referenced.
*
* @return pdPASS if the task was successfully created and added to a ready
* list, otherwise an error code defined in the file projdefs.h
*
* Example usage:
<pre>
// Task to be created.
void vTaskCode( void * pvParameters )
{
for( ;; )
{
// Task code goes here.
}
}
// Function that creates a task.
void vOtherFunction( void )
{
static uint8_t ucParameterToPass;
TaskHandle_t xHandle = NULL;
// Create the task, storing the handle. Note that the passed parameter ucParameterToPass
// must exist for the lifetime of the task, so in this case is declared static. If it was just an
// an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
// the new task attempts to access it.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
configASSERT( xHandle );
// Use the handle to delete the task.
if( xHandle != NULL )
{
vTaskDelete( xHandle );
}
}
</pre>
* \defgroup xTaskCreate xTaskCreate
* \ingroup Tasks
*/
BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
const char * const pcName,
const uint16_t usStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * const pxCreatedTask ) ; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
/**
* task. h
*<pre>
TaskHandle_t xTaskCreateStatic( TaskFunction_t pvTaskCode,
const char * const pcName,
uint32_t ulStackDepth,
void *pvParameters,
UBaseType_t uxPriority,
StackType_t *pxStackBuffer,
StaticTask_t *pxTaskBuffer );</pre>
*
* Create a new task and add it to the list of tasks that are ready to run.
*
* Internally, within the FreeRTOS implementation, tasks use two blocks of
* memory. The first block is used to hold the task's data structures. The
* second block is used by the task as its stack. If a task is created using
* xTaskCreate() then both blocks of memory are automatically dynamically
* allocated inside the xTaskCreate() function. (see
* http://www.freertos.org/a00111.html). If a task is created using
* xTaskCreateStatic() then the application writer must provide the required
* memory. xTaskCreateStatic() therefore allows a task to be created without
* using any dynamic memory allocation.
*
* @param pvTaskCode Pointer to the task entry function. Tasks
* must be implemented to never return (i.e. continuous loop).
*
* @param pcName A descriptive name for the task. This is mainly used to
* facilitate debugging. The maximum length of the string is defined by
* configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
*
* @param ulStackDepth The size of the task stack specified as the number of
* variables the stack can hold - not the number of bytes. For example, if
* the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
* will be allocated for stack storage.
*
* @param pvParameters Pointer that will be used as the parameter for the task
* being created.
*
* @param uxPriority The priority at which the task will run.
*
* @param pxStackBuffer Must point to a StackType_t array that has at least
* ulStackDepth indexes - the array will then be used as the task's stack,
* removing the need for the stack to be allocated dynamically.
*
* @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
* then be used to hold the task's data structures, removing the need for the
* memory to be allocated dynamically.
*
* @return If neither pxStackBuffer or pxTaskBuffer are NULL, then the task will
* be created and pdPASS is returned. If either pxStackBuffer or pxTaskBuffer
* are NULL then the task will not be created and
* errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY is returned.
*
* Example usage:
<pre>
// Dimensions the buffer that the task being created will use as its stack.
// NOTE: This is the number of words the stack will hold, not the number of
// bytes. For example, if each stack item is 32-bits, and this is set to 100,
// then 400 bytes (100 * 32-bits) will be allocated.
#define STACK_SIZE 200
// Structure that will hold the TCB of the task being created.
StaticTask_t xTaskBuffer;
// Buffer that the task being created will use as its stack. Note this is
// an array of StackType_t variables. The size of StackType_t is dependent on
// the RTOS port.
StackType_t xStack[ STACK_SIZE ];
// Function that implements the task being created.
void vTaskCode( void * pvParameters )
{
// The parameter value is expected to be 1 as 1 is passed in the
// pvParameters value in the call to xTaskCreateStatic().
configASSERT( ( uint32_t ) pvParameters == 1UL );
for( ;; )
{
// Task code goes here.
}
}
// Function that creates a task.
void vOtherFunction( void )
{
TaskHandle_t xHandle = NULL;
// Create the task without using any dynamic memory allocation.
xHandle = xTaskCreateStatic(
vTaskCode, // Function that implements the task.
"NAME", // Text name for the task.
STACK_SIZE, // Stack size in words, not bytes.
( void * ) 1, // Parameter passed into the task.
tskIDLE_PRIORITY,// Priority at which the task is created.
xStack, // Array to use as the task's stack.
&xTaskBuffer ); // Variable to hold the task's data structure.
// puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
// been created, and xHandle will be the task's handle. Use the handle
// to suspend the task.
vTaskSuspend( xHandle );
}
</pre>
* \defgroup xTaskCreateStatic xTaskCreateStatic
* \ingroup Tasks
*/
/**
* task. h
*<pre>
BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );</pre>
*
* xTaskCreateRestricted() should only be used in systems that include an MPU
* implementation.
*
* Create a new task and add it to the list of tasks that are ready to run.
* The function parameters define the memory regions and associated access
* permissions allocated to the task.
*
* @param pxTaskDefinition Pointer to a structure that contains a member
* for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
* documentation) plus an optional stack buffer and the memory region
* definitions.
*
* @param pxCreatedTask Used to pass back a handle by which the created task
* can be referenced.
*
* @return pdPASS if the task was successfully created and added to a ready
* list, otherwise an error code defined in the file projdefs.h
*
* Example usage:
<pre>
// Create an TaskParameters_t structure that defines the task to be created.
static const TaskParameters_t xCheckTaskParameters =
{
vATask, // pvTaskCode - the function that implements the task.
"ATask", // pcName - just a text name for the task to assist debugging.
100, // usStackDepth - the stack size DEFINED IN WORDS.
NULL, // pvParameters - passed into the task function as the function parameters.
( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
// xRegions - Allocate up to three separate memory regions for access by
// the task, with appropriate access permissions. Different processors have
// different memory alignment requirements - refer to the FreeRTOS documentation
// for full information.
{
// Base address Length Parameters
{ cReadWriteArray, 32, portMPU_REGION_READ_WRITE },
{ cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },
{ cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }
}
};
int main( void )
{
TaskHandle_t xHandle;
// Create a task from the const structure defined above. The task handle
// is requested (the second parameter is not NULL) but in this case just for
// demonstration purposes as its not actually used.
xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
// Start the scheduler.
vTaskStartScheduler();
// Will only get here if there was insufficient memory to create the idle
// and/or timer task.
for( ;; );
}
</pre>
* \defgroup xTaskCreateRestricted xTaskCreateRestricted
* \ingroup Tasks
*/
BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) ;
/**
* task. h
*<pre>
void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );</pre>
*
* Memory regions are assigned to a restricted task when the task is created by
* a call to xTaskCreateRestricted(). These regions can be redefined using
* vTaskAllocateMPURegions().
*
* @param xTask The handle of the task being updated.
*
* @param xRegions A pointer to an MemoryRegion_t structure that contains the
* new memory region definitions.
*
* Example usage:
<pre>
// Define an array of MemoryRegion_t structures that configures an MPU region
// allowing read/write access for 1024 bytes starting at the beginning of the
// ucOneKByte array. The other two of the maximum 3 definable regions are
// unused so set to zero.
static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
{
// Base address Length Parameters
{ ucOneKByte, 1024, portMPU_REGION_READ_WRITE },
{ 0, 0, 0 },
{ 0, 0, 0 }
};
void vATask( void *pvParameters )
{
// This task was created such that it has access to certain regions of
// memory as defined by the MPU configuration. At some point it is
// desired that these MPU regions are replaced with that defined in the
// xAltRegions const struct above. Use a call to vTaskAllocateMPURegions()
// for this purpose. NULL is used as the task handle to indicate that this
// function should modify the MPU regions of the calling task.
vTaskAllocateMPURegions( NULL, xAltRegions );
// Now the task can continue its function, but from this point on can only
// access its stack and the ucOneKByte array (unless any other statically
// defined or shared regions have been declared elsewhere).
}
</pre>
* \defgroup xTaskCreateRestricted xTaskCreateRestricted
* \ingroup Tasks
*/
void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) ;
/**
* task. h
* <pre>void vTaskDelete( TaskHandle_t xTask );</pre>
*
* INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
* See the configuration section for more information.
*
* Remove a task from the RTOS real time kernel's management. The task being
* deleted will be removed from all ready, blocked, suspended and event lists.
*
* NOTE: The idle task is responsible for freeing the kernel allocated
* memory from tasks that have been deleted. It is therefore important that
* the idle task is not starved of microcontroller processing time if your
* application makes any calls to vTaskDelete (). Memory allocated by the
* task code is not automatically freed, and should be freed before the task
* is deleted.
*
* See the demo application file death.c for sample code that utilises
* vTaskDelete ().
*
* @param xTask The handle of the task to be deleted. Passing NULL will
* cause the calling task to be deleted.
*
* Example usage:
<pre>
void vOtherFunction( void )
{
TaskHandle_t xHandle;
// Create the task, storing the handle.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
// Use the handle to delete the task.
vTaskDelete( xHandle );
}
</pre>
* \defgroup vTaskDelete vTaskDelete
* \ingroup Tasks
*/
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) ;
/*-----------------------------------------------------------
* TASK CONTROL API
*----------------------------------------------------------*/
/**
* task. h
* <pre>void vTaskDelay( const TickType_t xTicksToDelay );</pre>
*
* Delay a task for a given number of ticks. The actual time that the
* task remains blocked depends on the tick rate. The constant
* portTICK_PERIOD_MS can be used to calculate real time from the tick
* rate - with the resolution of one tick period.
*
* INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
* See the configuration section for more information.
*
*
* vTaskDelay() specifies a time at which the task wishes to unblock relative to
* the time at which vTaskDelay() is called. For example, specifying a block
* period of 100 ticks will cause the task to unblock 100 ticks after
* vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
* of controlling the frequency of a periodic task as the path taken through the
* code, as well as other task and interrupt activity, will effect the frequency
* at which vTaskDelay() gets called and therefore the time at which the task
* next executes. See vTaskDelayUntil() for an alternative API function designed
* to facilitate fixed frequency execution. It does this by specifying an
* absolute time (rather than a relative time) at which the calling task should
* unblock.
*
* @param xTicksToDelay The amount of time, in tick periods, that
* the calling task should block.
*
* Example usage:
void vTaskFunction( void * pvParameters )
{
// Block for 500ms.
const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
for( ;; )
{
// Simply toggle the LED every 500ms, blocking between each toggle.
vToggleLED();
vTaskDelay( xDelay );
}
}
* \defgroup vTaskDelay vTaskDelay
* \ingroup TaskCtrl
*/
void MPU_vTaskDelay( const TickType_t xTicksToDelay ) ;
/**
* task. h
* <pre>void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );</pre>
*
* INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available.
* See the configuration section for more information.
*
* Delay a task until a specified time. This function can be used by periodic
* tasks to ensure a constant execution frequency.
*
* This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
* cause a task to block for the specified number of ticks from the time vTaskDelay () is
* called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
* execution frequency as the time between a task starting to execute and that task
* calling vTaskDelay () may not be fixed [the task may take a different path though the
* code between calls, or may get interrupted or preempted a different number of times
* each time it executes].
*
* Whereas vTaskDelay () specifies a wake time relative to the time at which the function
* is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
* unblock.
*
* The constant portTICK_PERIOD_MS can be used to calculate real time from the tick
* rate - with the resolution of one tick period.
*
* @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
* task was last unblocked. The variable must be initialised with the current time
* prior to its first use (see the example below). Following this the variable is
* automatically updated within vTaskDelayUntil ().
*
* @param xTimeIncrement The cycle time period. The task will be unblocked at
* time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the
* same xTimeIncrement parameter value will cause the task to execute with
* a fixed interface period.
*
* Example usage:
<pre>
// Perform an action every 10 ticks.
void vTaskFunction( void * pvParameters )
{
TickType_t xLastWakeTime;
const TickType_t xFrequency = 10;
// Initialise the xLastWakeTime variable with the current time.
xLastWakeTime = xTaskGetTickCount ();
for( ;; )
{
// Wait for the next cycle.
vTaskDelayUntil( &xLastWakeTime, xFrequency );
// Perform action here.
}
}
</pre>
* \defgroup vTaskDelayUntil vTaskDelayUntil
* \ingroup TaskCtrl
*/
void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) ;
/**
* task. h
* <pre>BaseType_t xTaskAbortDelay( TaskHandle_t xTask );</pre>
*
* INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
* function to be available.
*
* A task will enter the Blocked state when it is waiting for an event. The
* event it is waiting for can be a temporal event (waiting for a time), such
* as when vTaskDelay() is called, or an event on an object, such as when
* xQueueReceive() or ulTaskNotifyTake() is called. If the handle of a task
* that is in the Blocked state is used in a call to xTaskAbortDelay() then the
* task will leave the Blocked state, and return from whichever function call
* placed the task into the Blocked state.
*
* @param xTask The handle of the task to remove from the Blocked state.
*
* @return If the task referenced by xTask was not in the Blocked state then
* pdFAIL is returned. Otherwise pdPASS is returned.
*
* \defgroup xTaskAbortDelay xTaskAbortDelay
* \ingroup TaskCtrl
*/
BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) ;
/**
* task. h
* <pre>UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask );</pre>
*
* INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
* See the configuration section for more information.
*
* Obtain the priority of any task.
*
* @param xTask Handle of the task to be queried. Passing a NULL
* handle results in the priority of the calling task being returned.
*
* @return The priority of xTask.
*
* Example usage:
<pre>
void vAFunction( void )
{
TaskHandle_t xHandle;
// Create a task, storing the handle.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
// ...
// Use the handle to obtain the priority of the created task.
// It was created with tskIDLE_PRIORITY, but may have changed
// it itself.
if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
{
// The task has changed it's priority.
}
// ...
// Is our priority higher than the created task?
if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
{
// Our priority (obtained using NULL handle) is higher.
}
}
</pre>
* \defgroup uxTaskPriorityGet uxTaskPriorityGet
* \ingroup TaskCtrl
*/
UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t xTask ) ;
/**
* task. h
* <pre>UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask );</pre>
*
* A version of uxTaskPriorityGet() that can be used from an ISR.
*/
UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) ;
/**
* task. h
* <pre>eTaskState eTaskGetState( TaskHandle_t xTask );</pre>
*
* INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
* See the configuration section for more information.
*
* Obtain the state of any task. States are encoded by the eTaskState
* enumerated type.
*
* @param xTask Handle of the task to be queried.
*
* @return The state of xTask at the time the function was called. Note the
* state of the task might change between the function being called, and the
* functions return value being tested by the calling task.
*/
eTaskState MPU_eTaskGetState( TaskHandle_t xTask ) ;
/**
* task. h
* <pre>void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );</pre>
*
* configUSE_TRACE_FACILITY must be defined as 1 for this function to be
* available. See the configuration section for more information.
*
* Populates a TaskStatus_t structure with information about a task.
*
* @param xTask Handle of the task being queried. If xTask is NULL then
* information will be returned about the calling task.
*
* @param pxTaskStatus A pointer to the TaskStatus_t structure that will be
* filled with information about the task referenced by the handle passed using
* the xTask parameter.
*
* @xGetFreeStackSpace The TaskStatus_t structure contains a member to report
* the stack high water mark of the task being queried. Calculating the stack
* high water mark takes a relatively long time, and can make the system
* temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to
* allow the high water mark checking to be skipped. The high watermark value
* will only be written to the TaskStatus_t structure if xGetFreeStackSpace is
* not set to pdFALSE;
*
* @param eState The TaskStatus_t structure contains a member to report the
* state of the task being queried. Obtaining the task state is not as fast as
* a simple assignment - so the eState parameter is provided to allow the state
* information to be omitted from the TaskStatus_t structure. To obtain state
* information then set eState to eInvalid - otherwise the value passed in
* eState will be reported as the task state in the TaskStatus_t structure.
*
* Example usage:
<pre>
void vAFunction( void )
{
TaskHandle_t xHandle;
TaskStatus_t xTaskDetails;
// Obtain the handle of a task from its name.
xHandle = xTaskGetHandle( "Task_Name" );
// Check the handle is not NULL.
configASSERT( xHandle );
// Use the handle to obtain further information about the task.
vTaskGetInfo( xHandle,
&xTaskDetails,
pdTRUE, // Include the high water mark in xTaskDetails.
eInvalid ); // Include the task state in xTaskDetails.
}
</pre>
* \defgroup vTaskGetInfo vTaskGetInfo
* \ingroup TaskCtrl
*/
void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) ;
/**
* task. h
* <pre>void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );</pre>
*
* INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
* See the configuration section for more information.
*
* Set the priority of any task.
*
* A context switch will occur before the function returns if the priority
* being set is higher than the currently executing task.
*
* @param xTask Handle to the task for which the priority is being set.
* Passing a NULL handle results in the priority of the calling task being set.
*
* @param uxNewPriority The priority to which the task will be set.
*
* Example usage:
<pre>
void vAFunction( void )
{
TaskHandle_t xHandle;
// Create a task, storing the handle.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
// ...
// Use the handle to raise the priority of the created task.
vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
// ...
// Use a NULL handle to raise our priority to the same value.
vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
}
</pre>
* \defgroup vTaskPrioritySet vTaskPrioritySet
* \ingroup TaskCtrl
*/
void MPU_vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) ;
/**
* task. h
* <pre>void vTaskSuspend( TaskHandle_t xTaskToSuspend );</pre>
*
* INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
* See the configuration section for more information.
*
* Suspend any task. When suspended a task will never get any microcontroller
* processing time, no matter what its priority.
*
* Calls to vTaskSuspend are not accumulative -
* i.e. calling vTaskSuspend () twice on the same task still only requires one
* call to vTaskResume () to ready the suspended task.
*
* @param xTaskToSuspend Handle to the task being suspended. Passing a NULL
* handle will cause the calling task to be suspended.
*
* Example usage:
<pre>
void vAFunction( void )
{
TaskHandle_t xHandle;
// Create a task, storing the handle.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
// ...
// Use the handle to suspend the created task.
vTaskSuspend( xHandle );
// ...
// The created task will not run during this period, unless
// another task calls vTaskResume( xHandle ).
//...
// Suspend ourselves.
vTaskSuspend( NULL );
// We cannot get here unless another task calls vTaskResume
// with our handle as the parameter.
}
</pre>
* \defgroup vTaskSuspend vTaskSuspend
* \ingroup TaskCtrl
*/
void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ) ;
/**
* task. h
* <pre>void vTaskResume( TaskHandle_t xTaskToResume );</pre>
*
* INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
* See the configuration section for more information.
*
* Resumes a suspended task.
*
* A task that has been suspended by one or more calls to vTaskSuspend ()
* will be made available for running again by a single call to
* vTaskResume ().
*
* @param xTaskToResume Handle to the task being readied.
*
* Example usage:
<pre>
void vAFunction( void )
{
TaskHandle_t xHandle;
// Create a task, storing the handle.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
// ...
// Use the handle to suspend the created task.
vTaskSuspend( xHandle );
// ...
// The created task will not run during this period, unless
// another task calls vTaskResume( xHandle ).
//...
// Resume the suspended task ourselves.
vTaskResume( xHandle );
// The created task will once again get microcontroller processing
// time in accordance with its priority within the system.
}
</pre>
* \defgroup vTaskResume vTaskResume
* \ingroup TaskCtrl
*/
void MPU_vTaskResume( TaskHandle_t xTaskToResume ) ;
/**
* task. h
* <pre>void xTaskResumeFromISR( TaskHandle_t xTaskToResume );</pre>
*
* INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
* available. See the configuration section for more information.
*
* An implementation of vTaskResume() that can be called from within an ISR.
*
* A task that has been suspended by one or more calls to vTaskSuspend ()
* will be made available for running again by a single call to
* xTaskResumeFromISR ().
*
* xTaskResumeFromISR() should not be used to synchronise a task with an
* interrupt if there is a chance that the interrupt could arrive prior to the
* task being suspended - as this can lead to interrupts being missed. Use of a
* semaphore as a synchronisation mechanism would avoid this eventuality.
*
* @param xTaskToResume Handle to the task being readied.
*
* @return pdTRUE if resuming the task should result in a context switch,
* otherwise pdFALSE. This is used by the ISR to determine if a context switch
* may be required following the ISR.
*
* \defgroup vTaskResumeFromISR vTaskResumeFromISR
* \ingroup TaskCtrl
*/
BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) ;
/*-----------------------------------------------------------
* SCHEDULER CONTROL
*----------------------------------------------------------*/
/**
* task. h
* <pre>void vTaskStartScheduler( void );</pre>
*
* Starts the real time kernel tick processing. After calling the kernel
* has control over which tasks are executed and when.
*
* See the demo application file main.c for an example of creating
* tasks and starting the kernel.
*
* Example usage:
<pre>
void vAFunction( void )
{
// Create at least one task before starting the kernel.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
// Start the real time kernel with preemption.
vTaskStartScheduler ();
// Will not get here unless a task calls vTaskEndScheduler ()
}
</pre>
*
* \defgroup vTaskStartScheduler vTaskStartScheduler
* \ingroup SchedulerControl
*/
void vTaskStartScheduler( void ) ;
/**
* task. h
* <pre>void vTaskEndScheduler( void );</pre>
*
* NOTE: At the time of writing only the x86 real mode port, which runs on a PC
* in place of DOS, implements this function.
*
* Stops the real time kernel tick. All created tasks will be automatically
* deleted and multitasking (either preemptive or cooperative) will
* stop. Execution then resumes from the point where vTaskStartScheduler ()
* was called, as if vTaskStartScheduler () had just returned.
*
* See the demo application file main. c in the demo/PC directory for an
* example that uses vTaskEndScheduler ().
*
* vTaskEndScheduler () requires an exit function to be defined within the
* portable layer (see vPortEndScheduler () in port. c for the PC port). This
* performs hardware specific operations such as stopping the kernel tick.
*
* vTaskEndScheduler () will cause all of the resources allocated by the
* kernel to be freed - but will not free resources allocated by application
* tasks.
*
* Example usage:
<pre>
void vTaskCode( void * pvParameters )
{
for( ;; )
{
// Task code goes here.
// At some point we want to end the real time kernel processing
// so call ...
vTaskEndScheduler ();
}
}
void vAFunction( void )
{
// Create at least one task before starting the kernel.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
// Start the real time kernel with preemption.
vTaskStartScheduler ();
// Will only get here when the vTaskCode () task has called
// vTaskEndScheduler (). When we get here we are back to single task
// execution.
}
</pre>
*
* \defgroup vTaskEndScheduler vTaskEndScheduler
* \ingroup SchedulerControl
*/
void vTaskEndScheduler( void ) ;
/**
* task. h
* <pre>void vTaskSuspendAll( void );</pre>
*
* Suspends the scheduler without disabling interrupts. Context switches will
* not occur while the scheduler is suspended.
*
* After calling vTaskSuspendAll () the calling task will continue to execute
* without risk of being swapped out until a call to xTaskResumeAll () has been
* made.
*
* API functions that have the potential to cause a context switch (for example,
* vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
* is suspended.
*
* Example usage:
<pre>
void vTask1( void * pvParameters )
{
for( ;; )
{
// Task code goes here.
// ...
// At some point the task wants to perform a long operation during
// which it does not want to get swapped out. It cannot use
// taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
// operation may cause interrupts to be missed - including the
// ticks.
// Prevent the real time kernel swapping out the task.
vTaskSuspendAll ();
// Perform the operation here. There is no need to use critical
// sections as we have all the microcontroller processing time.
// During this time interrupts will still operate and the kernel
// tick count will be maintained.
// ...
// The operation is complete. Restart the kernel.
xTaskResumeAll ();
}
}
</pre>
* \defgroup vTaskSuspendAll vTaskSuspendAll
* \ingroup SchedulerControl
*/
void MPU_vTaskSuspendAll( void ) ;
/**
* task. h
* <pre>BaseType_t xTaskResumeAll( void );</pre>
*
* Resumes scheduler activity after it was suspended by a call to
* vTaskSuspendAll().
*
* xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
* that were previously suspended by a call to vTaskSuspend().
*
* @return If resuming the scheduler caused a context switch then pdTRUE is
* returned, otherwise pdFALSE is returned.
*
* Example usage:
<pre>
void vTask1( void * pvParameters )
{
for( ;; )
{
// Task code goes here.
// ...
// At some point the task wants to perform a long operation during
// which it does not want to get swapped out. It cannot use
// taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
// operation may cause interrupts to be missed - including the
// ticks.
// Prevent the real time kernel swapping out the task.
vTaskSuspendAll ();
// Perform the operation here. There is no need to use critical
// sections as we have all the microcontroller processing time.
// During this time interrupts will still operate and the real
// time kernel tick count will be maintained.
// ...
// The operation is complete. Restart the kernel. We want to force
// a context switch - but there is no point if resuming the scheduler
// caused a context switch already.
if( !xTaskResumeAll () )
{
taskYIELD ();
}
}
}
</pre>
* \defgroup xTaskResumeAll xTaskResumeAll
* \ingroup SchedulerControl
*/
BaseType_t MPU_xTaskResumeAll( void ) ;
/*-----------------------------------------------------------
* TASK UTILITIES
*----------------------------------------------------------*/
/**
* task. h
* <PRE>TickType_t xTaskGetTickCount( void );</PRE>
*
* @return The count of ticks since vTaskStartScheduler was called.
*
* \defgroup xTaskGetTickCount xTaskGetTickCount
* \ingroup TaskUtils
*/
TickType_t MPU_xTaskGetTickCount( void ) ;
/**
* task. h
* <PRE>TickType_t xTaskGetTickCountFromISR( void );</PRE>
*
* @return The count of ticks since vTaskStartScheduler was called.
*
* This is a version of xTaskGetTickCount() that is safe to be called from an
* ISR - provided that TickType_t is the natural word size of the
* microcontroller being used or interrupt nesting is either not supported or
* not being used.
*
* \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
* \ingroup TaskUtils
*/
TickType_t xTaskGetTickCountFromISR( void ) ;
/**
* task. h
* <PRE>uint16_t uxTaskGetNumberOfTasks( void );</PRE>
*
* @return The number of tasks that the real time kernel is currently managing.
* This includes all ready, blocked and suspended tasks. A task that
* has been deleted but not yet freed by the idle task will also be
* included in the count.
*
* \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
* \ingroup TaskUtils
*/
UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) ;
/**
* task. h
* <PRE>char *pcTaskGetName( TaskHandle_t xTaskToQuery );</PRE>
*
* @return The text (human readable) name of the task referenced by the handle
* xTaskToQuery. A task can query its own name by either passing in its own
* handle, or by setting xTaskToQuery to NULL.
*
* \defgroup pcTaskGetName pcTaskGetName
* \ingroup TaskUtils
*/
char *MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) ; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
/**
* task. h
* <PRE>TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );</PRE>
*
* NOTE: This function takes a relatively long time to complete and should be
* used sparingly.
*
* @return The handle of the task that has the human readable name pcNameToQuery.
* NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle
* must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
*
* \defgroup pcTaskGetHandle pcTaskGetHandle
* \ingroup TaskUtils
*/
TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery ) ; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
/**
* task.h
* <PRE>UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );</PRE>
*
* INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
* this function to be available.
*
* Returns the high water mark of the stack associated with xTask. That is,
* the minimum free stack space there has been (in words, so on a 32 bit machine
* a value of 1 means 4 bytes) since the task started. The smaller the returned
* number the closer the task has come to overflowing its stack.
*
* @param xTask Handle of the task associated with the stack to be checked.
* Set xTask to NULL to check the stack of the calling task.
*
* @return The smallest amount of free stack space there has been (in words, so
* actual spaces on the stack rather than bytes) since the task referenced by
* xTask was created.
*/
UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) ;
/* When using trace macros it is sometimes necessary to include task.h before
FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
so the following two prototypes will cause a compilation error. This can be
fixed by simply guarding against the inclusion of these two prototypes unless
they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
constant. */
/* Each task contains an array of pointers that is dimensioned by the
configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
kernel does not use the pointers itself, so the application writer can use
the pointers for any purpose they wish. The following two functions are
used to set and query a pointer respectively. */
void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) ;
void *MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) ;
/**
* task.h
* <pre>BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );</pre>
*
* Calls the hook function associated with xTask. Passing xTask as NULL has
* the effect of calling the Running tasks (the calling task) hook function.
*
* pvParameter is passed to the hook function for the task to interpret as it
* wants. The return value is the value returned by the task hook function
* registered by the user.
*/
BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) ;
/**
* xTaskGetIdleTaskHandle() is only available if
* INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
*
* Simply returns the handle of the idle task. It is not valid to call
* xTaskGetIdleTaskHandle() before the scheduler has been started.
*/
TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) ;
/**
* configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
* uxTaskGetSystemState() to be available.
*
* uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
* the system. TaskStatus_t structures contain, among other things, members
* for the task handle, task name, task priority, task state, and total amount
* of run time consumed by the task. See the TaskStatus_t structure
* definition in this file for the full member list.
*
* NOTE: This function is intended for debugging use only as its use results in
* the scheduler remaining suspended for an extended period.
*
* @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
* The array must contain at least one TaskStatus_t structure for each task
* that is under the control of the RTOS. The number of tasks under the control
* of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
*
* @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
* parameter. The size is specified as the number of indexes in the array, or
* the number of TaskStatus_t structures contained in the array, not by the
* number of bytes in the array.
*
* @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
* FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
* total run time (as defined by the run time stats clock, see
* http://www.freertos.org/rtos-run-time-stats.html) since the target booted.
* pulTotalRunTime can be set to NULL to omit the total run time information.
*
* @return The number of TaskStatus_t structures that were populated by
* uxTaskGetSystemState(). This should equal the number returned by the
* uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
* in the uxArraySize parameter was too small.
*
* Example usage:
<pre>
// This example demonstrates how a human readable table of run time stats
// information is generated from raw data provided by uxTaskGetSystemState().
// The human readable table is written to pcWriteBuffer
void vTaskGetRunTimeStats( char *pcWriteBuffer )
{
TaskStatus_t *pxTaskStatusArray;
volatile UBaseType_t uxArraySize, x;
uint32_t ulTotalRunTime, ulStatsAsPercentage;
// Make sure the write buffer does not contain a string.
*pcWriteBuffer = 0x00;
// Take a snapshot of the number of tasks in case it changes while this
// function is executing.
uxArraySize = uxTaskGetNumberOfTasks();
// Allocate a TaskStatus_t structure for each task. An array could be
// allocated statically at compile time.
pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
if( pxTaskStatusArray != NULL )
{
// Generate raw status information about each task.
uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
// For percentage calculations.
ulTotalRunTime /= 100UL;
// Avoid divide by zero errors.
if( ulTotalRunTime > 0 )
{
// For each populated position in the pxTaskStatusArray array,
// format the raw data as human readable ASCII data
for( x = 0; x < uxArraySize; x++ )
{
// What percentage of the total run time has the task used?
// This will always be rounded down to the nearest integer.
// ulTotalRunTimeDiv100 has already been divided by 100.
ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
if( ulStatsAsPercentage > 0UL )
{
sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
}
else
{
// If the percentage is zero here then the task has
// consumed less than 1% of the total run time.
sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
}
pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
}
}
// The array is no longer needed, free the memory it consumes.
vPortFree( pxTaskStatusArray );
}
}
</pre>
*/
UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) ;
/**
* task. h
* <PRE>void vTaskList( char *pcWriteBuffer );</PRE>
*
* configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
* both be defined as 1 for this function to be available. See the
* configuration section of the FreeRTOS.org website for more information.
*
* NOTE 1: This function will disable interrupts for its duration. It is
* not intended for normal application runtime use but as a debug aid.
*
* Lists all the current tasks, along with their current state and stack
* usage high water mark.
*
* Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
* suspended ('S').
*
* PLEASE NOTE:
*
* This function is provided for convenience only, and is used by many of the
* demo applications. Do not consider it to be part of the scheduler.
*
* vTaskList() calls uxTaskGetSystemState(), then formats part of the
* uxTaskGetSystemState() output into a human readable table that displays task
* names, states and stack usage.
*
* vTaskList() has a dependency on the sprintf() C library function that might
* bloat the code size, use a lot of stack, and provide different results on
* different platforms. An alternative, tiny, third party, and limited
* functionality implementation of sprintf() is provided in many of the
* FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
* printf-stdarg.c does not provide a full snprintf() implementation!).
*
* It is recommended that production systems call uxTaskGetSystemState()
* directly to get access to raw stats data, rather than indirectly through a
* call to vTaskList().
*
* @param pcWriteBuffer A buffer into which the above mentioned details
* will be written, in ASCII form. This buffer is assumed to be large
* enough to contain the generated report. Approximately 40 bytes per
* task should be sufficient.
*
* \defgroup vTaskList vTaskList
* \ingroup TaskUtils
*/
void MPU_vTaskList( char * pcWriteBuffer ) ; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
/**
* task. h
* <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>
*
* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
* must both be defined as 1 for this function to be available. The application
* must also then provide definitions for
* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
* to configure a peripheral timer/counter and return the timers current count
* value respectively. The counter should be at least 10 times the frequency of
* the tick count.
*
* NOTE 1: This function will disable interrupts for its duration. It is
* not intended for normal application runtime use but as a debug aid.
*
* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
* accumulated execution time being stored for each task. The resolution
* of the accumulated time value depends on the frequency of the timer
* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
* Calling vTaskGetRunTimeStats() writes the total execution time of each
* task into a buffer, both as an absolute count value and as a percentage
* of the total system execution time.
*
* NOTE 2:
*
* This function is provided for convenience only, and is used by many of the
* demo applications. Do not consider it to be part of the scheduler.
*
* vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
* uxTaskGetSystemState() output into a human readable table that displays the
* amount of time each task has spent in the Running state in both absolute and
* percentage terms.
*
* vTaskGetRunTimeStats() has a dependency on the sprintf() C library function
* that might bloat the code size, use a lot of stack, and provide different
* results on different platforms. An alternative, tiny, third party, and
* limited functionality implementation of sprintf() is provided in many of the
* FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
* printf-stdarg.c does not provide a full snprintf() implementation!).
*
* It is recommended that production systems call uxTaskGetSystemState() directly
* to get access to raw stats data, rather than indirectly through a call to
* vTaskGetRunTimeStats().
*
* @param pcWriteBuffer A buffer into which the execution times will be
* written, in ASCII form. This buffer is assumed to be large enough to
* contain the generated report. Approximately 40 bytes per task should
* be sufficient.
*
* \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
* \ingroup TaskUtils
*/
void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer ) ; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
/**
* task. h
* <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>
*
* configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
* function to be available.
*
* When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
* "notification value", which is a 32-bit unsigned integer (uint32_t).
*
* Events can be sent to a task using an intermediary object. Examples of such
* objects are queues, semaphores, mutexes and event groups. Task notifications
* are a method of sending an event directly to a task without the need for such
* an intermediary object.
*
* A notification sent to a task can optionally perform an action, such as
* update, overwrite or increment the task's notification value. In that way
* task notifications can be used to send data to a task, or be used as light
* weight and fast binary or counting semaphores.
*
* A notification sent to a task will remain pending until it is cleared by the
* task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
* already in the Blocked state to wait for a notification when the notification
* arrives then the task will automatically be removed from the Blocked state
* (unblocked) and the notification cleared.
*
* A task can use xTaskNotifyWait() to [optionally] block to wait for a
* notification to be pending, or ulTaskNotifyTake() to [optionally] block
* to wait for its notification value to have a non-zero value. The task does
* not consume any CPU time while it is in the Blocked state.
*
* See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
*
* @param xTaskToNotify The handle of the task being notified. The handle to a
* task can be returned from the xTaskCreate() API function used to create the
* task, and the handle of the currently running task can be obtained by calling
* xTaskGetCurrentTaskHandle().
*
* @param ulValue Data that can be sent with the notification. How the data is
* used depends on the value of the eAction parameter.
*
* @param eAction Specifies how the notification updates the task's notification
* value, if at all. Valid values for eAction are as follows:
*
* eSetBits -
* The task's notification value is bitwise ORed with ulValue. xTaskNofify()
* always returns pdPASS in this case.
*
* eIncrement -
* The task's notification value is incremented. ulValue is not used and
* xTaskNotify() always returns pdPASS in this case.
*
* eSetValueWithOverwrite -
* The task's notification value is set to the value of ulValue, even if the
* task being notified had not yet processed the previous notification (the
* task already had a notification pending). xTaskNotify() always returns
* pdPASS in this case.
*
* eSetValueWithoutOverwrite -
* If the task being notified did not already have a notification pending then
* the task's notification value is set to ulValue and xTaskNotify() will
* return pdPASS. If the task being notified already had a notification
* pending then no action is performed and pdFAIL is returned.
*
* eNoAction -
* The task receives a notification without its notification value being
* updated. ulValue is not used and xTaskNotify() always returns pdPASS in
* this case.
*
* pulPreviousNotificationValue -
* Can be used to pass out the subject task's notification value before any
* bits are modified by the notify function.
*
* @return Dependent on the value of eAction. See the description of the
* eAction parameter.
*
* \defgroup xTaskNotify xTaskNotify
* \ingroup TaskNotifications
*/
BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) ;
/**
* task. h
* <PRE>BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );</PRE>
*
* configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
* function to be available.
*
* When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
* "notification value", which is a 32-bit unsigned integer (uint32_t).
*
* A version of xTaskNotify() that can be used from an interrupt service routine
* (ISR).
*
* Events can be sent to a task using an intermediary object. Examples of such
* objects are queues, semaphores, mutexes and event groups. Task notifications
* are a method of sending an event directly to a task without the need for such
* an intermediary object.
*
* A notification sent to a task can optionally perform an action, such as
* update, overwrite or increment the task's notification value. In that way
* task notifications can be used to send data to a task, or be used as light
* weight and fast binary or counting semaphores.
*
* A notification sent to a task will remain pending until it is cleared by the
* task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
* already in the Blocked state to wait for a notification when the notification
* arrives then the task will automatically be removed from the Blocked state
* (unblocked) and the notification cleared.
*
* A task can use xTaskNotifyWait() to [optionally] block to wait for a
* notification to be pending, or ulTaskNotifyTake() to [optionally] block
* to wait for its notification value to have a non-zero value. The task does
* not consume any CPU time while it is in the Blocked state.
*
* See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
*
* @param xTaskToNotify The handle of the task being notified. The handle to a
* task can be returned from the xTaskCreate() API function used to create the
* task, and the handle of the currently running task can be obtained by calling
* xTaskGetCurrentTaskHandle().
*
* @param ulValue Data that can be sent with the notification. How the data is
* used depends on the value of the eAction parameter.
*
* @param eAction Specifies how the notification updates the task's notification
* value, if at all. Valid values for eAction are as follows:
*
* eSetBits -
* The task's notification value is bitwise ORed with ulValue. xTaskNofify()
* always returns pdPASS in this case.
*
* eIncrement -
* The task's notification value is incremented. ulValue is not used and
* xTaskNotify() always returns pdPASS in this case.
*
* eSetValueWithOverwrite -
* The task's notification value is set to the value of ulValue, even if the
* task being notified had not yet processed the previous notification (the
* task already had a notification pending). xTaskNotify() always returns
* pdPASS in this case.
*
* eSetValueWithoutOverwrite -
* If the task being notified did not already have a notification pending then
* the task's notification value is set to ulValue and xTaskNotify() will
* return pdPASS. If the task being notified already had a notification
* pending then no action is performed and pdFAIL is returned.
*
* eNoAction -
* The task receives a notification without its notification value being
* updated. ulValue is not used and xTaskNotify() always returns pdPASS in
* this case.
*
* @param pxHigherPriorityTaskWoken xTaskNotifyFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
* task to which the notification was sent to leave the Blocked state, and the
* unblocked task has a priority higher than the currently running task. If
* xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
* be requested before the interrupt is exited. How a context switch is
* requested from an ISR is dependent on the port - see the documentation page
* for the port in use.
*
* @return Dependent on the value of eAction. See the description of the
* eAction parameter.
*
* \defgroup xTaskNotify xTaskNotify
* \ingroup TaskNotifications
*/
BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) ;
/**
* task. h
* <PRE>BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );</pre>
*
* configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
* function to be available.
*
* When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
* "notification value", which is a 32-bit unsigned integer (uint32_t).
*
* Events can be sent to a task using an intermediary object. Examples of such
* objects are queues, semaphores, mutexes and event groups. Task notifications
* are a method of sending an event directly to a task without the need for such
* an intermediary object.
*
* A notification sent to a task can optionally perform an action, such as
* update, overwrite or increment the task's notification value. In that way
* task notifications can be used to send data to a task, or be used as light
* weight and fast binary or counting semaphores.
*
* A notification sent to a task will remain pending until it is cleared by the
* task calling xTaskNotifyWait() or ulTaskNotifyTake(). If the task was
* already in the Blocked state to wait for a notification when the notification
* arrives then the task will automatically be removed from the Blocked state
* (unblocked) and the notification cleared.
*
* A task can use xTaskNotifyWait() to [optionally] block to wait for a
* notification to be pending, or ulTaskNotifyTake() to [optionally] block
* to wait for its notification value to have a non-zero value. The task does
* not consume any CPU time while it is in the Blocked state.
*
* See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
*
* @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
* will be cleared in the calling task's notification value before the task
* checks to see if any notifications are pending, and optionally blocks if no
* notifications are pending. Setting ulBitsToClearOnEntry to ULONG_MAX (if
* limits.h is included) or 0xffffffffUL (if limits.h is not included) will have
* the effect of resetting the task's notification value to 0. Setting
* ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
*
* @param ulBitsToClearOnExit If a notification is pending or received before
* the calling task exits the xTaskNotifyWait() function then the task's
* notification value (see the xTaskNotify() API function) is passed out using
* the pulNotificationValue parameter. Then any bits that are set in
* ulBitsToClearOnExit will be cleared in the task's notification value (note
* *pulNotificationValue is set before any bits are cleared). Setting
* ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
* (if limits.h is not included) will have the effect of resetting the task's
* notification value to 0 before the function exits. Setting
* ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
* when the function exits (in which case the value passed out in
* pulNotificationValue will match the task's notification value).
*
* @param pulNotificationValue Used to pass the task's notification value out
* of the function. Note the value passed out will not be effected by the
* clearing of any bits caused by ulBitsToClearOnExit being non-zero.
*
* @param xTicksToWait The maximum amount of time that the task should wait in
* the Blocked state for a notification to be received, should a notification
* not already be pending when xTaskNotifyWait() was called. The task
* will not consume any processing time while it is in the Blocked state. This
* is specified in kernel ticks, the macro pdMS_TO_TICSK( value_in_ms ) can be
* used to convert a time specified in milliseconds to a time specified in
* ticks.
*
* @return If a notification was received (including notifications that were
* already pending when xTaskNotifyWait was called) then pdPASS is
* returned. Otherwise pdFAIL is returned.
*
* \defgroup xTaskNotifyWait xTaskNotifyWait
* \ingroup TaskNotifications
*/
BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) ;
/**
* task. h
* <PRE>BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );</PRE>
*
* configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
* to be available.
*
* When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
* "notification value", which is a 32-bit unsigned integer (uint32_t).
*
* Events can be sent to a task using an intermediary object. Examples of such
* objects are queues, semaphores, mutexes and event groups. Task notifications
* are a method of sending an event directly to a task without the need for such
* an intermediary object.
*
* A notification sent to a task can optionally perform an action, such as
* update, overwrite or increment the task's notification value. In that way
* task notifications can be used to send data to a task, or be used as light
* weight and fast binary or counting semaphores.
*
* xTaskNotifyGive() is a helper macro intended for use when task notifications
* are used as light weight and faster binary or counting semaphore equivalents.
* Actual FreeRTOS semaphores are given using the xSemaphoreGive() API function,
* the equivalent action that instead uses a task notification is
* xTaskNotifyGive().
*
* When task notifications are being used as a binary or counting semaphore
* equivalent then the task being notified should wait for the notification
* using the ulTaskNotificationTake() API function rather than the
* xTaskNotifyWait() API function.
*
* See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
*
* @param xTaskToNotify The handle of the task being notified. The handle to a
* task can be returned from the xTaskCreate() API function used to create the
* task, and the handle of the currently running task can be obtained by calling
* xTaskGetCurrentTaskHandle().
*
* @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
* eAction parameter set to eIncrement - so pdPASS is always returned.
*
* \defgroup xTaskNotifyGive xTaskNotifyGive
* \ingroup TaskNotifications
*/
/**
* task. h
* <PRE>void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
*
* configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
* to be available.
*
* When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
* "notification value", which is a 32-bit unsigned integer (uint32_t).
*
* A version of xTaskNotifyGive() that can be called from an interrupt service
* routine (ISR).
*
* Events can be sent to a task using an intermediary object. Examples of such
* objects are queues, semaphores, mutexes and event groups. Task notifications
* are a method of sending an event directly to a task without the need for such
* an intermediary object.
*
* A notification sent to a task can optionally perform an action, such as
* update, overwrite or increment the task's notification value. In that way
* task notifications can be used to send data to a task, or be used as light
* weight and fast binary or counting semaphores.
*
* vTaskNotifyGiveFromISR() is intended for use when task notifications are
* used as light weight and faster binary or counting semaphore equivalents.
* Actual FreeRTOS semaphores are given from an ISR using the
* xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
* a task notification is vTaskNotifyGiveFromISR().
*
* When task notifications are being used as a binary or counting semaphore
* equivalent then the task being notified should wait for the notification
* using the ulTaskNotificationTake() API function rather than the
* xTaskNotifyWait() API function.
*
* See http://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
*
* @param xTaskToNotify The handle of the task being notified. The handle to a
* task can be returned from the xTaskCreate() API function used to create the
* task, and the handle of the currently running task can be obtained by calling
* xTaskGetCurrentTaskHandle().
*
* @param pxHigherPriorityTaskWoken vTaskNotifyGiveFromISR() will set
* *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
* task to which the notification was sent to leave the Blocked state, and the
* unblocked task has a priority higher than the currently running task. If
* vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
* should be requested before the interrupt is exited. How a context switch is
* requested from an ISR is dependent on the port - see the documentation page
* for the port in use.
*
* \defgroup xTaskNotifyWait xTaskNotifyWait
* \ingroup TaskNotifications
*/
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) ;
/**
* task. h
* <PRE>uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );</pre>
*
* configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
* function to be available.
*
* When configUSE_TASK_NOTIFICATIONS is set to one each task has its own private
* "notification value", which is a 32-bit unsigned integer (uint32_t).
*
* Events can be sent to a task using an intermediary object. Examples of such
* objects are queues, semaphores, mutexes and event groups. Task notifications
* are a method of sending an event directly to a task without the need for such
* an intermediary object.
*
* A notification sent to a task can optionally perform an action, such as
* update, overwrite or increment the task's notification value. In that way
* task notifications can be used to send data to a task, or be used as light
* weight and fast binary or counting semaphores.
*
* ulTaskNotifyTake() is intended for use when a task notification is used as a
* faster and lighter weight binary or counting semaphore alternative. Actual
* FreeRTOS semaphores are taken using the xSemaphoreTake() API function, the
* equivalent action that instead uses a task notification is
* ulTaskNotifyTake().
*
* When a task is using its notification value as a binary or counting semaphore
* other tasks should send notifications to it using the xTaskNotifyGive()
* macro, or xTaskNotify() function with the eAction parameter set to
* eIncrement.
*
* ulTaskNotifyTake() can either clear the task's notification value to
* zero on exit, in which case the notification value acts like a binary
* semaphore, or decrement the task's notification value on exit, in which case
* the notification value acts like a counting semaphore.
*
* A task can use ulTaskNotifyTake() to [optionally] block to wait for a
* the task's notification value to be non-zero. The task does not consume any
* CPU time while it is in the Blocked state.
*
* Where as xTaskNotifyWait() will return when a notification is pending,
* ulTaskNotifyTake() will return when the task's notification value is
* not zero.
*
* See http://www.FreeRTOS.org/RTOS-task-notifications.html for details.
*
* @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
* notification value is decremented when the function exits. In this way the
* notification value acts like a counting semaphore. If xClearCountOnExit is
* not pdFALSE then the task's notification value is cleared to zero when the
* function exits. In this way the notification value acts like a binary
* semaphore.
*
* @param xTicksToWait The maximum amount of time that the task should wait in
* the Blocked state for the task's notification value to be greater than zero,
* should the count not already be greater than zero when
* ulTaskNotifyTake() was called. The task will not consume any processing
* time while it is in the Blocked state. This is specified in kernel ticks,
* the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time
* specified in milliseconds to a time specified in ticks.
*
* @return The task's notification count before it is either cleared to zero or
* decremented (see the xClearCountOnExit parameter).
*
* \defgroup ulTaskNotifyTake ulTaskNotifyTake
* \ingroup TaskNotifications
*/
uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) ;
/**
* task. h
* <PRE>BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );</pre>
*
* If the notification state of the task referenced by the handle xTask is
* eNotified, then set the task's notification state to eNotWaitingNotification.
* The task's notification value is not altered. Set xTask to NULL to clear the
* notification state of the calling task.
*
* @return pdTRUE if the task's notification state was set to
* eNotWaitingNotification, otherwise pdFALSE.
* \defgroup xTaskNotifyStateClear xTaskNotifyStateClear
* \ingroup TaskNotifications
*/
BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask );
/*-----------------------------------------------------------
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
*----------------------------------------------------------*/
/*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
* INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
* AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
*
* Called from the real time kernel tick (either preemptive or cooperative),
* this increments the tick count and checks if any tasks that are blocked
* for a finite period required removing from a blocked list and placing on
* a ready list. If a non-zero value is returned then a context switch is
* required because either:
* + A task was removed from a blocked list because its timeout had expired,
* or
* + Time slicing is in use and there is a task of equal priority to the
* currently running task.
*/
BaseType_t xTaskIncrementTick( void ) ;
/*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
*
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
*
* Removes the calling task from the ready list and places it both
* on the list of tasks waiting for a particular event, and the
* list of delayed tasks. The task will be removed from both lists
* and replaced on the ready list should either the event occur (and
* there be no higher priority tasks waiting on the same event) or
* the delay period expires.
*
* The 'unordered' version replaces the event list item value with the
* xItemValue value, and inserts the list item at the end of the list.
*
* The 'ordered' version uses the existing event list item value (which is the
* owning tasks priority) to insert the list item into the event list is task
* priority order.
*
* @param pxEventList The list containing tasks that are blocked waiting
* for the event to occur.
*
* @param xItemValue The item value to use for the event list item when the
* event list is not ordered by task priority.
*
* @param xTicksToWait The maximum amount of time that the task should wait
* for the event to occur. This is specified in kernel ticks,the constant
* portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
* period.
*/
void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) ;
void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) ;
/*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
*
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
*
* This function performs nearly the same function as vTaskPlaceOnEventList().
* The difference being that this function does not permit tasks to block
* indefinitely, whereas vTaskPlaceOnEventList() does.
*
*/
void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) ;
/*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
* INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
*
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
*
* Removes a task from both the specified event list and the list of blocked
* tasks, and places it on a ready queue.
*
* xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called
* if either an event occurs to unblock a task, or the block timeout period
* expires.
*
* xTaskRemoveFromEventList() is used when the event list is in task priority
* order. It removes the list item from the head of the event list as that will
* have the highest priority owning task of all the tasks on the event list.
* xTaskRemoveFromUnorderedEventList() is used when the event list is not
* ordered and the event list items hold something other than the owning tasks
* priority. In this case the event list item value is updated to the value
* passed in the xItemValue parameter.
*
* @return pdTRUE if the task being removed has a higher priority than the task
* making the call, otherwise pdFALSE.
*/
BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) ;
BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) ;
/*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
* INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
* AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
*
* Sets the pointer to the current TCB to the TCB of the highest priority task
* that is ready to run.
*/
void vTaskSwitchContext( void ) ;
/*
* THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
* THE EVENT BITS MODULE.
*/
TickType_t uxTaskResetEventItemValue( void ) ;
/*
* Return the handle of the calling task.
*/
TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) ;
/*
* Capture the current time status for future reference.
*/
void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) ;
/*
* Compare the time status now with that previously captured to see if the
* timeout has expired.
*/
BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) ;
/*
* Shortcut used by the queue implementation to prevent unnecessary call to
* taskYIELD();
*/
void vTaskMissedYield( void ) ;
/*
* Returns the scheduler state as taskSCHEDULER_RUNNING,
* taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
*/
BaseType_t MPU_xTaskGetSchedulerState( void ) ;
/*
* Raises the priority of the mutex holder to that of the calling task should
* the mutex holder have a priority less than the calling task.
*/
void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) ;
/*
* Set the priority of a task back to its proper priority in the case that it
* inherited a higher priority while it was holding a semaphore.
*/
BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) ;
/*
* Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
*/
UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) ;
/*
* Set the uxTaskNumber of the task referenced by the xTask parameter to
* uxHandle.
*/
void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) ;
/*
* Only available when configUSE_TICKLESS_IDLE is set to 1.
* If tickless mode is being used, or a low power mode is implemented, then
* the tick interrupt will not execute during idle periods. When this is the
* case, the tick count value maintained by the scheduler needs to be kept up
* to date with the actual execution time by being skipped forward by a time
* equal to the idle period.
*/
void vTaskStepTick( const TickType_t xTicksToJump ) ;
/*
* Only avilable when configUSE_TICKLESS_IDLE is set to 1.
* Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
* specific sleep function to determine if it is ok to proceed with the sleep,
* and if it is ok to proceed, if it is ok to sleep indefinitely.
*
* This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
* called with the scheduler suspended, not from within a critical section. It
* is therefore possible for an interrupt to request a context switch between
* portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
* entered. eTaskConfirmSleepModeStatus() should be called from a short
* critical section between the timer being stopped and the sleep mode being
* entered to ensure it is ok to proceed into the sleep mode.
*/
eSleepModeStatus eTaskConfirmSleepModeStatus( void ) ;
/*
* For internal use only. Increment the mutex held count when a mutex is
* taken and return the handle of the task that has taken the mutex.
*/
void *pvTaskIncrementMutexHeldCount( void ) ;
}
/*!
* @addtogroup port_threads
* @{
* @file
*/
////////////////////////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////////////////////////
//! @brief Thread function type.
//!
//! @param arg User provided argument that was passed into the start() method.
typedef void (*thread_entry_t)(void *arg);
////////////////////////////////////////////////////////////////////////////////
// Declarations
////////////////////////////////////////////////////////////////////////////////
namespace erpc {
/*!
* @brief Simple thread class.
*
* @ingroup port_threads
*/
class Thread
{
public:
//! @brief Unique identifier for a thread.
typedef void *thread_id_t;
/*!
* @brief Default constructor for use with the init() method.
*
* If this constructor is used, the init() method must be called before the thread can be
* started.
*
* @param name Optional name for the thread.
*/
Thread(const char *name = 0);
/*!
* @brief Constructor.
*
* This constructor fully initializes the thread object.
*
* @param entry
* @param priority
* @param stackSize
* @param name Optional name for the thread.
*/
Thread(thread_entry_t entry, uint32_t priority = 0, uint32_t stackSize = 0, const char *name = 0);
virtual ~Thread();
void setName(const char *name) { m_name = name; }
const char *getName() const { return m_name; }
void init(thread_entry_t entry, uint32_t priority = 0, uint32_t stackSize = 0);
void start(void *arg = 0);
static void sleep(uint32_t usecs);
thread_id_t getThreadId() const
{
return reinterpret_cast<thread_id_t>(m_task);
}
static thread_id_t getCurrentThreadId()
{
return reinterpret_cast<thread_id_t>(MPU_xTaskGetCurrentTaskHandle());
}
static Thread *getCurrentThread();
bool operator==(Thread &o);
protected:
virtual void threadEntryPoint();
private:
const char *m_name;
thread_entry_t m_entry;
void *m_arg;
uint32_t m_stackSize;
uint32_t m_priority;
TaskHandle_t m_task;
Thread *m_next;
static Thread *s_first;
static void threadEntryPointStub(void *arg);
private:
Thread(const Thread &o);
Thread &operator=(const Thread &o);
};
/*!
* @brief Mutex.
*
* If the OS supports it, the mutex will be recursive.
*
* @ingroup port_threads
*/
class Mutex
{
public:
/*!
* @brief
*/
class Guard
{
public:
Guard(Mutex &mutex)
: m_mutex(mutex)
{
m_mutex.lock();
}
~Guard() { m_mutex.unlock(); }
private:
Mutex &m_mutex;
};
Mutex();
~Mutex();
bool tryLock();
bool lock();
bool unlock();
private:
SemaphoreHandle_t m_mutex;
private:
Mutex(const Mutex &o);
Mutex &operator=(const Mutex &o);
};
/*!
* @brief Simple semaphore class.
*
* @ingroup port_threads
*/
class Semaphore
{
public:
static const uint32_t kWaitForever = 0xffffffff;
Semaphore(int count = 0);
~Semaphore();
void put();
bool get(uint32_t timeout = kWaitForever);
int getCount() const;
private:
SemaphoreHandle_t m_sem;
private:
Semaphore(const Semaphore &o);
Semaphore &operator=(const Semaphore &o);
};
} // namespace erpc
/*! @} */
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////
/*
* Copyright (c) 2014, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*/
/*
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*/
/*!
* @addtogroup infra
* @{
*/
////////////////////////////////////////////////////////////////////////////////
// Definitions
////////////////////////////////////////////////////////////////////////////////
/*! @brief eRPC status return codes. */
enum _erpc_status
{
//! No error occurred.
kErpcStatus_Success = 0,
//! Generic failure.
kErpcStatus_Fail = 1,
//! Argument is an invalid value.
kErpcStatus_InvalidArgument = 4,
//! Operated timed out.
kErpcStatus_Timeout = 5,
//! Message header contains an unknown version.
kErpcStatus_InvalidMessageVersion = 6,
//! Expected a reply message but got another message type.
kErpcStatus_ExpectedReply,
//! Message is corrupted.
kErpcStatus_CrcCheckFailed,
//! Attempt to read or write past the end of a buffer.
kErpcStatus_BufferOverrun,
//! Could not find host with given name.
kErpcStatus_UnknownName,
//! Failed to connect to host.
kErpcStatus_ConnectionFailure,
//! Connected closed by peer.
kErpcStatus_ConnectionClosed,
//! Memory allocation error.
kErpcStatus_MemoryError,
//! Server is stopped.
kErpcStatus_ServerIsDown,
//! Transport layer initialization failed.
kErpcStatus_InitFailed,
//! Failed to receive data.
kErpcStatus_ReceiveFailed,
//! Failed to send data.
kErpcStatus_SendFailed
};
/*! @brief Type used for all status and error return values. */
typedef int32_t erpc_status_t;
/*! @} */
/*
* Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
*/
// -*- C++ -*-
//===--------------------------- cstddef ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
cstddef synopsis
Macros:
offsetof(type,member-designator)
NULL
namespace std
{
Types:
ptrdiff_t
size_t
max_align_t
nullptr_t
byte // C++17
} // std
*/
// Don't include our own <stddef.h>; we don't want to declare ::nullptr_t.
namespace std { inline namespace __2 {
using ::ptrdiff_t;
using ::size_t;
// Re-use the compiler's <stddef.h> max_align_t where possible.
using ::max_align_t;
} }
/*!
* @addtogroup infra_codec
* @{
* @file
*/
////////////////////////////////////////////////////////////////////////////////
// Classes
////////////////////////////////////////////////////////////////////////////////
namespace erpc {
/*!
* @brief Represents a memory buffer containing a message.
*
* The MessageBuffer object does not own the buffer memory. It simply provides an interface
* to accessing that memory in a convenient manner.
*
* @ingroup infra_codec
*/
class MessageBuffer
{
public:
/*!
* @brief Constructor.
*
* This function initializes object attributes.
*/
MessageBuffer()
: m_buf(0)
, m_len(0)
, m_used(0)
{
}
/*!
* @brief Constructor.
*
* This function initializes object attributes.
*
* param[in] buffer Pointer to buffer.
* param[in] length Length of buffer.
*/
MessageBuffer(uint8_t *buffer, uint16_t length)
: m_buf(buffer)
, m_len(length)
, m_used(0)
{
}
/*!
* @brief This function set new buffer and his length.
*
* This function set buffer to read/write data.
*
* @param[in] buffer Pointer to another buffer to read/write data.
* @param[in] length Length of buffer.
*/
void set(uint8_t *buffer, uint16_t length)
{
m_buf = buffer;
m_len = length;
m_used = 0;
}
/*!
* @brief This function returns pointer to buffer to read/write.
*
* @return Pointer to buffer to read/write.
*/
uint8_t *get() { return m_buf; }
/*!
* @brief This function returns pointer to buffer to read/write.
*
* @return Pointer to buffer to read/write.
*/
const uint8_t *get() const { return m_buf; }
/*!
* @brief This function returns length of buffer.
*
* @return Length of buffer.
*/
uint16_t getLength() const { return m_len; }
/*!
* @brief This function returns length of used space of buffer.
*
* @return Length of used space of buffer.
*/
uint16_t getUsed() const { return m_used; }
/*!
* @brief This function returns length of free space of buffer.
*
* @return Length of free space of buffer.
*/
uint16_t getFree() const { return m_len - m_used; }
/*!
* @brief This function sets length of used space of buffer.
*
* @param[in] used Length of used space of buffer.
*/
void setUsed(uint16_t used) { m_used = used; }
erpc_status_t read(uint16_t offset, void *data, uint32_t length);
erpc_status_t write(uint16_t offset, const void *data, uint32_t length);
erpc_status_t copy(const MessageBuffer *other);
void swap(MessageBuffer *other);
operator uint8_t *() { return m_buf; }
operator const uint8_t *() const { return m_buf; }
uint8_t &operator[](int index) { return m_buf[index]; }
const uint8_t &operator[](int index) const { return m_buf[index]; }
/*!
* @brief Cursor within a MessageBuffer.
*/
class Cursor
{
public:
/*!
* @brief Constructor.
*
* This function initializes object attributes.
*/
Cursor()
: m_buffer(0)
, m_pos(0)
, m_remaining(0)
{
}
/*!
* @brief Constructor.
*
* This function initializes object attributes.
*
* param[in] buffer MessageBuffer for sending/receiving.
*/
Cursor(MessageBuffer *buffer)
: m_buffer(buffer)
, m_pos(buffer->get())
, m_remaining(buffer->getLength())
{
}
/*!
* @brief Set message buffer.
*
* @param[in] buffer Message buffer to set.
*/
void set(MessageBuffer *buffer);
/*!
* @brief Return position in buffer.
*
* Return position, where it last write/read.
*
* @return Return position in buffer.
*/
uint8_t *get() { return m_pos; }
/*!
* @brief Return position in buffer.
*
* Return position, where it last write/read.
*
* @return Return position in buffer.
*/
const uint8_t *get() const { return m_pos; }
/*!
* @brief Return remaining free space in current buffer.
*
* @return Remaining free space in current buffer.
*/
uint16_t getRemaining() const { return m_remaining; }
/*!
* @brief Read data from current buffer.
*
* @param[out] data Pointer to value, where copy read data.
* @param[in] length How much bytes need be read.
*
* @retval kErpcStatus_Success
* @retval kErpcStatus_BufferOverrun
*/
erpc_status_t read(void *data, uint32_t length);
/*!
* @brief Read data from current buffer.
*
* @param[out] data Pointer to value to be sent.
* @param[in] length How much bytes need be wrote.
*
* @retval kErpcStatus_Success
* @retval kErpcStatus_BufferOverrun
*/
erpc_status_t write(const void *data, uint32_t length);
operator uint8_t *() { return m_pos; }
operator const uint8_t *() const { return m_pos; }
uint8_t &operator[](int index) { return m_pos[index]; }
const uint8_t &operator[](int index) const { return m_pos[index]; }
Cursor &operator+=(uint16_t n)
{
m_pos += n;
m_remaining -= n;
return *this;
}
Cursor &operator-=(uint16_t n)
{
m_pos -= n;
m_remaining += n;
return *this;
}
Cursor &operator++()
{
++m_pos;
--m_remaining;
return *this;
}
Cursor &operator--()
{
--m_pos;
++m_remaining;
return *this;
}
private:
MessageBuffer *m_buffer; /*!< Buffer for reading or writing data. */
uint8_t *m_pos; /*!< Position in buffer, where it last write/read */
uint16_t m_remaining; /*!< Remaining space in buffer. */
};
private:
uint8_t *volatile m_buf; /*!< Buffer used to read write data. */
uint16_t volatile m_len; /*!< Length of buffer. */
uint16_t volatile m_used; /*!< Used buffer bytes. */
};
/*!
* @brief Abstract interface for message buffer factory.
*
* @ingroup infra_codec
*/
class MessageBufferFactory
{
public:
/*!
* @brief Constructor.
*
* This function initializes object attributes.
*/
MessageBufferFactory() {}
/*!
* @brief ClientManager destructor
*/
virtual ~MessageBufferFactory() {}
/*!
* @brief This function creates new message buffer.
*
* @return New created MessageBuffer.
*/
virtual MessageBuffer create() = 0;
/*!
* @brief This function inform server if it has to create buffer for received message.
*
* @return Has to return TRUE when server need create buffer for receiving message.
*/
virtual bool createServerBuffer() { return true; }
/*!
* @brief This function is preparing output buffer on server side.
*
* This function do decision if this function want reuse buffer, or use new buffer.
* In case of using new buffer function has to free given buffer.
*
* @param[in] message MessageBuffer which can be reused.
*/
virtual erpc_status_t prepareServerBufferForSend(MessageBuffer *message);
/*!
* @brief This function disposes message buffer.
*
* @param[in] buf MessageBuffer to dispose.
*/
virtual void dispose(MessageBuffer *buf) = 0;
};
} // namespace erpc
/*! @} */
// -*- C++ -*-
//===--------------------------- cstring ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
cstring synopsis
Macros:
NULL
namespace std
{
Types:
size_t
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
void* memmove(void* s1, const void* s2, size_t n);
char* strcpy (char* restrict s1, const char* restrict s2);
char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
char* strcat (char* restrict s1, const char* restrict s2);
char* strncat(char* restrict s1, const char* restrict s2, size_t n);
int memcmp(const void* s1, const void* s2, size_t n);
int strcmp (const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
int strcoll(const char* s1, const char* s2);
size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
const void* memchr(const void* s, int c, size_t n);
void* memchr( void* s, int c, size_t n);
const char* strchr(const char* s, int c);
char* strchr( char* s, int c);
size_t strcspn(const char* s1, const char* s2);
const char* strpbrk(const char* s1, const char* s2);
char* strpbrk( char* s1, const char* s2);
const char* strrchr(const char* s, int c);
char* strrchr( char* s, int c);
size_t strspn(const char* s1, const char* s2);
const char* strstr(const char* s1, const char* s2);
char* strstr( char* s1, const char* s2);
char* strtok(char* restrict s1, const char* restrict s2);
void* memset(void* s, int c, size_t n);
char* strerror(int errnum);
size_t strlen(const char* s);
} // std
*/
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
string.h synopsis
Macros:
NULL
Types:
size_t
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
void* memmove(void* s1, const void* s2, size_t n);
char* strcpy (char* restrict s1, const char* restrict s2);
char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
char* strcat (char* restrict s1, const char* restrict s2);
char* strncat(char* restrict s1, const char* restrict s2, size_t n);
int memcmp(const void* s1, const void* s2, size_t n);
int strcmp (const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
int strcoll(const char* s1, const char* s2);
size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
const void* memchr(const void* s, int c, size_t n);
void* memchr( void* s, int c, size_t n);
const char* strchr(const char* s, int c);
char* strchr( char* s, int c);
size_t strcspn(const char* s1, const char* s2);
const char* strpbrk(const char* s1, const char* s2);
char* strpbrk( char* s1, const char* s2);
const char* strrchr(const char* s, int c);
char* strrchr( char* s, int c);
size_t strspn(const char* s1, const char* s2);
const char* strstr(const char* s1, const char* s2);
char* strstr( char* s1, const char* s2);
char* strtok(char* restrict s1, const char* restrict s2);
void* memset(void* s, int c, size_t n);
char* strerror(int errnum);
size_t strlen(const char* s);
*/
/*****************************************************************************/
/* string.h */
/* */
/* Copyright (c) 1993 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
#pragma diag_push
#pragma CHECK_MISRA("-6.3") /* standard types required for standard headers */
#pragma CHECK_MISRA("-19.1") /* #includes required for implementation */
#pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
#pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */
extern "C" {
/*****************************************************************************/
/* _ti_config.h */
/* */
/* Copyright (c) 2017 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
#pragma diag_push
#pragma CHECK_MISRA("-19.4")
#pragma CHECK_MISRA("-19.1")
/* Common definitions */
/* C++ */
/* C++11 */
/* _TI_NOEXCEPT_CPP14 is defined to noexcept only when compiling for C++14. It
is intended to be used for functions like abort and atexit that are supposed
to be declared noexcept only in C++14 mode. */
/* Target-specific definitions */
/*****************************************************************************/
/* linkage.h */
/* */
/* Copyright (c) 1998 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
#pragma diag_push
#pragma CHECK_MISRA("-19.4") /* macros required for implementation */
/* No modifiers are needed to access code or data */
/*--------------------------------------------------------------------------*/
/* Define _IDECL ==> how inline functions are declared */
/*--------------------------------------------------------------------------*/
#pragma diag_pop
#pragma diag_pop
#pragma diag_push
#pragma CHECK_MISRA("-19.4") /* macros required for implementation */
#pragma diag_pop
size_t strlen(const char *string);
char *strcpy(char * __restrict dest,
const char * __restrict src);
char *strncpy(char * __restrict dest,
const char * __restrict src, size_t n);
char *strcat(char * __restrict string1,
const char * __restrict string2);
char *strncat(char * __restrict dest,
const char * __restrict src, size_t n);
char *strchr(const char *string, int c);
char *strrchr(const char *string, int c);
int strcmp(const char *string1, const char *string2);
int strncmp(const char *string1, const char *string2, size_t n);
int strcoll(const char *string1, const char *_string2);
size_t strxfrm(char * __restrict to,
const char * __restrict from, size_t n);
char *strpbrk(const char *string, const char *chs);
size_t strspn(const char *string, const char *chs);
size_t strcspn(const char *string, const char *chs);
char *strstr(const char *string1, const char *string2);
char *strtok(char * __restrict str1,
const char * __restrict str2);
char *strerror(int _errno);
char *strdup(const char *string);
void *memmove(void *s1, const void *s2, size_t n);
#pragma diag_push
#pragma CHECK_MISRA("-16.4") /* false positives due to builtin declarations */
void *memcpy(void * __restrict s1,
const void * __restrict s2, size_t n);
#pragma diag_pop
int memcmp(const void *cs, const void *ct, size_t n);
void *memchr(const void *cs, int c, size_t n);
void *memset(void *mem, int ch, size_t length);
} /* extern "C" */
/*----------------------------------------------------------------------------*/
/* If sys/cdefs.h is available, go ahead and include it. xlocale.h assumes */
/* this file will have already included sys/cdefs.h. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Include xlocale/_string.h> if POSIX is enabled. This will expose the */
/* xlocale string interface. */
/*----------------------------------------------------------------------------*/
#pragma diag_pop
/* MSVCRT, GNU libc and its derivates may already have the correct prototype in */
/* <string.h>. This macro can be defined by users if their C library provides */
/* the right signature. */
namespace std { inline namespace __2 {
using ::size_t;
using ::memcpy;
using ::memmove;
using ::strcpy;
using ::strncpy;
using ::strcat;
using ::strncat;
using ::memcmp;
using ::strcmp;
using ::strncmp;
using ::strcoll;
using ::strxfrm;
using ::memchr;
using ::strchr;
using ::strcspn;
using ::strpbrk;
using ::strrchr;
using ::strspn;
using ::strstr;
using ::strtok;
using ::memset;
using ::strerror;
using ::strlen;
} }
/*!
* @addtogroup infra_transport
* @{
* @file
*/
////////////////////////////////////////////////////////////////////////////////
// Classes
////////////////////////////////////////////////////////////////////////////////
namespace erpc {
/*!
* @brief Abstract interface for transport layer.
*
* @ingroup infra_transport
*/
class Transport
{
public:
/*!
* @brief Constructor.
*/
Transport()
{
}
/*!
* @brief Transport destructor
*/
virtual ~Transport() {}
/*!
* @brief Prototype for receiving message.
*
* Each transport layer need define this function.
*
* @param[out] message Will return pointer to received message buffer.
*
* @return based on receive implementation.
*/
virtual erpc_status_t receive(MessageBuffer *message) = 0;
/*!
* @brief Prototype for send message.
*
* Each transport layer need define this function.
*
* @param[in] message Pass message buffer to send.
*
* @return based on send implementation.
*/
virtual erpc_status_t send(MessageBuffer *message) = 0;
/*!
* @brief Poll for an incoming message.
*
* This function should return true if are some messages to process by server,
* the return value should be tested before calling receive function to avoid
* waiting for a new message (receive can be implemented as blocking function).
*
* @retval True when a message is available to process, else false.
*/
virtual bool hasMessage() { return true; }
};
/*!
* @brief Abstract interface for transport factory.
*
* @ingroup infra_transport
*/
class TransportFactory
{
public:
/*!
* @brief Constructor.
*/
TransportFactory() {}
/*!
* @brief TransportFactory destructor
*/
virtual ~TransportFactory() {}
/*!
* @brief Return created transport object.
*
* @return Pointer to created transport object.
*/
virtual Transport *create() = 0;
};
} // namespace erpc
/*! @} */
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern "C" {
/* Includes */
/* WARNING! All changes made to this file will be lost! */
/* #undef CSP_POSIX */
/* #undef CSP_WINDOWS */
/* #undef CSP_MACOSX */
/* #undef CSP_DEBUG */
/* #undef CSP_USE_PROMISC */
/* #undef CSP_USE_QOS */
/* #undef CSP_USE_DEDUP */
/* #undef CSP_USE_INIT_SHUTDOWN */
/* #undef CSP_BIG_ENDIAN */
/* CSP includes */
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Make bool for compilers without stdbool.h */
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
stdbool.h synopsis
Macros:
__bool_true_false_are_defined
*/
/*
* Copyright (c) 2000 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>
* All rights reserved.
*
* Copyright (c) 2014-2014 Texas Instruments Incorporated
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD: release/10.0.0/include/stdbool.h 228878 2011-12-25 20:15:41Z ed $
*/
/**
* RESERVED PORTS (SERVICES)
*/
enum csp_reserved_ports_e {
CSP_CMP = 0,
CSP_PING = 1,
CSP_PS = 2,
CSP_MEMFREE = 3,
CSP_REBOOT = 4,
CSP_BUF_FREE = 5,
CSP_UPTIME = 6,
CSP_ANY = (31 + 1),
CSP_PROMISC = (31 + 2)
};
typedef enum {
CSP_PRIO_CRITICAL = 0,
CSP_PRIO_HIGH = 1,
CSP_PRIO_NORM = 2,
CSP_PRIO_LOW = 3,
} csp_prio_t;
/** Size of bit-fields in CSP header */
/** Highest number to be entered in field */
/** Identifier field masks */
/** @brief This union defines a CSP identifier and allows access to the individual fields or the entire identifier */
typedef union {
uint32_t ext;
struct __attribute__((__packed__)) {
unsigned int flags : 8;
unsigned int sport : 6;
unsigned int dport : 6;
unsigned int dst : 5;
unsigned int src : 5;
unsigned int pri : 2;
};
} csp_id_t;
/** Broadcast address */
/** Default routing address */
/** CSP Flags */
/** CSP Socket options */
/** CSP Connect options */
/**
* CSP PACKET STRUCTURE
* Note: This structure is constructed to fit
* with all interface frame types in order to
* have buffer reuse
*/
typedef struct __attribute__((__packed__)) {
uint8_t padding[8]; /**< Interface dependent padding */
uint16_t length; /**< Length field must be just before CSP ID */
csp_id_t id; /**< CSP id must be just before data */
union {
uint8_t data[0]; /**< This just points to the rest of the buffer, without a size indication. */
uint16_t data16[0]; /**< The data 16 and 32 types makes it easy to reference an integer (properly aligned) */
uint32_t data32[0]; /**< without the compiler warning about strict aliasing rules. */
};
} csp_packet_t;
/** Interface TX function */
struct csp_iface_s;
typedef int (*nexthop_t)(struct csp_iface_s * interface, csp_packet_t *packet, uint32_t timeout);
/** Interface struct */
typedef struct csp_iface_s {
const char *name; /**< Interface name (keep below 10 bytes) */
void * driver; /**< Pointer to interface handler structure */
nexthop_t nexthop; /**< Next hop function */
uint16_t mtu; /**< Maximum Transmission Unit of interface */
uint8_t split_horizon_off; /**< Disable the route-loop prevention on if */
uint32_t tx; /**< Successfully transmitted packets */
uint32_t rx; /**< Successfully received packets */
uint32_t tx_error; /**< Transmit errors */
uint32_t rx_error; /**< Receive errors */
uint32_t drop; /**< Dropped packets */
uint32_t autherr; /**< Authentication errors */
uint32_t frame; /**< Frame format errors */
uint32_t txbytes; /**< Transmitted bytes */
uint32_t rxbytes; /**< Received bytes */
uint32_t irq; /**< Interrupts */
struct csp_iface_s *next; /**< Next interface */
} csp_iface_t;
/**
* This define must be equal to the size of the packet overhead in csp_packet_t.
* It is used in csp_buffer_get() to check the allocated buffer size against
* the required buffer size.
*/
/** Forward declaration of socket and connection structures */
typedef struct csp_conn_s csp_socket_t;
typedef struct csp_conn_s csp_conn_t;
/* CSP_REBOOT magic values */
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern "C" {
/* Set OS */
} /* extern "C" */
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 GomSpace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern "C" {
} /* extern "C" */
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
inttypes.h synopsis
This entire header is C99 / C++0X
#include <stdint.h> // <cinttypes> includes <cstdint>
Macros:
PRId8
PRId16
PRId32
PRId64
PRIdLEAST8
PRIdLEAST16
PRIdLEAST32
PRIdLEAST64
PRIdFAST8
PRIdFAST16
PRIdFAST32
PRIdFAST64
PRIdMAX
PRIdPTR
PRIi8
PRIi16
PRIi32
PRIi64
PRIiLEAST8
PRIiLEAST16
PRIiLEAST32
PRIiLEAST64
PRIiFAST8
PRIiFAST16
PRIiFAST32
PRIiFAST64
PRIiMAX
PRIiPTR
PRIo8
PRIo16
PRIo32
PRIo64
PRIoLEAST8
PRIoLEAST16
PRIoLEAST32
PRIoLEAST64
PRIoFAST8
PRIoFAST16
PRIoFAST32
PRIoFAST64
PRIoMAX
PRIoPTR
PRIu8
PRIu16
PRIu32
PRIu64
PRIuLEAST8
PRIuLEAST16
PRIuLEAST32
PRIuLEAST64
PRIuFAST8
PRIuFAST16
PRIuFAST32
PRIuFAST64
PRIuMAX
PRIuPTR
PRIx8
PRIx16
PRIx32
PRIx64
PRIxLEAST8
PRIxLEAST16
PRIxLEAST32
PRIxLEAST64
PRIxFAST8
PRIxFAST16
PRIxFAST32
PRIxFAST64
PRIxMAX
PRIxPTR
PRIX8
PRIX16
PRIX32
PRIX64
PRIXLEAST8
PRIXLEAST16
PRIXLEAST32
PRIXLEAST64
PRIXFAST8
PRIXFAST16
PRIXFAST32
PRIXFAST64
PRIXMAX
PRIXPTR
SCNd8
SCNd16
SCNd32
SCNd64
SCNdLEAST8
SCNdLEAST16
SCNdLEAST32
SCNdLEAST64
SCNdFAST8
SCNdFAST16
SCNdFAST32
SCNdFAST64
SCNdMAX
SCNdPTR
SCNi8
SCNi16
SCNi32
SCNi64
SCNiLEAST8
SCNiLEAST16
SCNiLEAST32
SCNiLEAST64
SCNiFAST8
SCNiFAST16
SCNiFAST32
SCNiFAST64
SCNiMAX
SCNiPTR
SCNo8
SCNo16
SCNo32
SCNo64
SCNoLEAST8
SCNoLEAST16
SCNoLEAST32
SCNoLEAST64
SCNoFAST8
SCNoFAST16
SCNoFAST32
SCNoFAST64
SCNoMAX
SCNoPTR
SCNu8
SCNu16
SCNu32
SCNu64
SCNuLEAST8
SCNuLEAST16
SCNuLEAST32
SCNuLEAST64
SCNuFAST8
SCNuFAST16
SCNuFAST32
SCNuFAST64
SCNuMAX
SCNuPTR
SCNx8
SCNx16
SCNx32
SCNx64
SCNxLEAST8
SCNxLEAST16
SCNxLEAST32
SCNxLEAST64
SCNxFAST8
SCNxFAST16
SCNxFAST32
SCNxFAST64
SCNxMAX
SCNxPTR
Types:
imaxdiv_t
intmax_t imaxabs(intmax_t j);
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base);
uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base);
intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
*/
/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
for C++11 unless __STDC_FORMAT_MACROS is defined
*/
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org>
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
/*-
* SPDX-License-Identifier: BSD-2-Clause-NetBSD
*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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: $NetBSD: int_fmtio.h,v 1.2 2001/04/26 16:25:21 kleink Exp $
* $FreeBSD$
*/
/*
* Macros for format specifiers.
*/
/* fprintf(3) macros for signed integers. */
/* fprintf(3) macros for unsigned integers. */
/* fscanf(3) macros for signed integers. */
/* fscanf(3) macros for unsigned integers. */
typedef struct {
intmax_t quot; /* Quotient. */
intmax_t rem; /* Remainder. */
} imaxdiv_t;
extern "C" {
intmax_t imaxabs(intmax_t) __attribute__((__const__));
imaxdiv_t imaxdiv(intmax_t, intmax_t) __attribute__((__const__));
intmax_t strtoimax(const char * __restrict, char ** __restrict, int);
uintmax_t strtoumax(const char * __restrict, char ** __restrict, int);
intmax_t wcstoimax(const wchar_t * __restrict,
wchar_t ** __restrict, int);
uintmax_t wcstoumax(const wchar_t * __restrict,
wchar_t ** __restrict, int);
}
extern "C" {
/** Debug levels */
typedef enum {
CSP_ERROR = 0,
CSP_WARN = 1,
CSP_INFO = 2,
CSP_BUFFER = 3,
CSP_PACKET = 4,
CSP_PROTOCOL = 5,
CSP_LOCK = 6,
} csp_debug_level_t;
/* Extract filename component from path */
/* Implement csp_assert_fail_action to override default failure action */
extern void __attribute__((weak)) csp_assert_fail_action(char *assertion, const char *file, int line);
/**
* This function should not be used directly, use csp_log_<level>() macro instead
* @param level
* @param format
*/
void do_csp_debug(csp_debug_level_t level, const char *format, ...);
/**
* Toggle debug level on/off
* @param level Level to toggle
*/
void csp_debug_toggle_level(csp_debug_level_t level);
/**
* Set debug level
* @param level Level to set
* @param value New level value
*/
void csp_debug_set_level(csp_debug_level_t level, bool value);
/**
* Get current debug level value
* @param level Level value to get
* @return Level value
*/
int csp_debug_get_level(csp_debug_level_t level);
} /* extern "C" */
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern "C" {
/**
* Start the buffer handling system
* You must specify the number for buffers and the size. All buffers are fixed
* size so you must specify the size of your largest buffer.
*
* @param count Number of buffers to allocate
* @param size Buffer size in bytes.
*
* @return CSP_ERR_NONE if malloc() succeeded, CSP_ERR message otherwise.
*/
int csp_buffer_init(int count, int size);
/**
* Get a reference to a free buffer. This function can only be called
* from task context.
*
* @param size Specify what data-size you will put in the buffer
* @return pointer to a free csp_packet_t or NULL if out of memory
*/
void * csp_buffer_get(size_t size);
/**
* Get a reference to a free buffer. This function can only be called
* from interrupt context.
*
* @param buf_size Specify what data-size you will put in the buffer
* @return pointer to a free csp_packet_t or NULL if out of memory
*/
void * csp_buffer_get_isr(size_t buf_size);
/**
* Free a buffer after use.
* @param packet pointer to memory area, must be acquired by csp_buffer_get().
*/
void csp_buffer_free(void *packet);
/**
* Free a buffer after use in ISR context.
* @param packet pointer to memory area, must be acquired by csp_buffer_get().
*/
void csp_buffer_free_isr(void *packet);
/**
* Clone an existing packet and increase/decrease cloned packet size.
* @param buffer Existing buffer to clone.
*/
void * csp_buffer_clone(void *buffer);
/**
* Return how many buffers that are currently free.
* @return number of free buffers
*/
int csp_buffer_remaining(void);
/**
* Return the size of the CSP buffers
* @return size of CSP buffers
*/
int csp_buffer_size(void);
} /* extern "C" */
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 GomSpace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Find outgoing interface in routing table
* @param id Destination node
* @return pointer to outgoing interface or NULL
*/
csp_iface_t * csp_rtable_find_iface(uint8_t id);
/**
* Find MAC address associated with node
* @param id Destination node
* @return MAC address
*/
uint8_t csp_rtable_find_mac(uint8_t id);
/**
* Setup routing entry
* @param node Host
* @param mask Number of bits in netmask
* @param ifc Interface
* @param mac MAC address
* @return CSP error type
*/
int csp_rtable_set(uint8_t node, uint8_t mask, csp_iface_t *ifc, uint8_t mac);
/**
* Print routing table to stdout
*/
void csp_rtable_print(void);
/**
* Load the routing table from a buffer
* (deprecated, please use new csp_rtable_load)
*
* Warning:
* The table will be RAW from memory and contains direct pointers, not interface names.
* Therefore it's very important that a saved routing table is deleted after a firmware update
*
* @param route_table_in pointer to routing table buffer
*/
void csp_route_table_load(uint8_t route_table_in[5 * (((1 << (5)) - 1) + 2)]);
/**
* Save the routing table to a buffer
* (deprecated, please use new csp_rtable_save)
*
* Warning:
* The table will be RAW from memory and contains direct pointers, not interface names.
* Therefore it's very important that a saved routing table is deleted after a firmware update
*
* @param route_table_out pointer to routing table buffer
*/
void csp_route_table_save(uint8_t route_table_out[5 * (((1 << (5)) - 1) + 2)]);
/**
* Save routing table as a string to a buffer, which can be parsed
* again by csp_rtable_load.
* @param buffer pointer to buffer
* @param maxlen length of buffer
* @return length of saved string
*/
int csp_rtable_save(char * buffer, int maxlen);
/**
* Load routing table from a string in the format
* %u/%u %s %u
* - Address
* - Netmask
* - Ifname
* - Mac Address (this field is optional)
* An example routing string is "0/0 I2C, 8/2 KISS"
* The string must be \0 null terminated
* The string must NOT be const.
* @param buffer Pointer to string
*/
void csp_rtable_load(char * buffer);
/**
* Check string for valid routing table
* @param buffer Pointer to string
* @return number of valid entries found
*/
int csp_rtable_check(char * buffer);
/**
* Clear routing table:
* This could be done before load to ensure an entire clean table is loaded.
*/
void csp_rtable_clear(void);
/**
* Setup routing entry to single node
* (deprecated, please use csp_rtable_set)
*
* @param node Host
* @param ifc Interface
* @param mac MAC address
* @return CSP error type
*/
/**
* Print routing table
* (deprecated, please use csp_rtable_print)
*/
/**
* Print list of interfaces
* (deprecated, please use csp_iflist_print)
*/
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 GomSpace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Add interface to list
* @param ifc Pointer to interface to add
*/
void csp_iflist_add(csp_iface_t *ifc);
/**
* Lookup interface by name
* @param name String with interface name
* @return Pointer to interface or NULL if not found
*/
csp_iface_t * csp_iflist_get_by_name(char *name);
/**
* Print list of interfaces to stdout
*/
void csp_iflist_print(void);
/** csp_init
* Start up the can-space protocol
* @param my_node_address The CSP node address
*/
int csp_init(uint8_t my_node_address);
/** csp_set_address
* Set the systems own address
* @param addr The new address of the system
*/
void csp_set_address(uint8_t addr);
/** csp_get_address
* Get the systems own address
* @return The current address of the system
*/
uint8_t csp_get_address(void);
/** csp_set_hostname
* Set subsystem hostname.
* This function takes a pointer to a string, which should remain static
* @param hostname Hostname to set
*/
void csp_set_hostname(const char *hostname);
/** csp_get_hostname
* Get current subsystem hostname.
* @return Pointer to char array with current hostname.
*/
const char *csp_get_hostname(void);
/** csp_set_model
* Set subsystem model name.
* This function takes a pointer to a string, which should remain static
* @param model Model name to set
*/
void csp_set_model(const char *model);
/** csp_get_model
* Get current model name.
* @return Pointer to char array with current model name.
*/
const char *csp_get_model(void);
/** csp_set_revision
* Set subsystem revision. This can be used to override the CMP revision field.
* This function takes a pointer to a string, which should remain static
* @param revision Revision name to set
*/
void csp_set_revision(const char *revision);
/** csp_get_revision
* Get subsystem revision.
* @return Pointer to char array with software revision.
*/
const char *csp_get_revision(void);
/** csp_socket
* Create CSP socket endpoint
* @param opts Socket options
* @return Pointer to socket on success, NULL on failure
*/
csp_socket_t *csp_socket(uint32_t opts);
/**
* Wait for a new connection on a socket created by csp_socket
* @param socket Socket to accept connections on
* @param timeout use CSP_MAX_DELAY for infinite timeout
* @return Return pointer to csp_conn_t or NULL if timeout was reached
*/
csp_conn_t *csp_accept(csp_socket_t *socket, uint32_t timeout);
/**
* Read data from a connection
* This fuction uses the RX queue of a connection to receive a packet
* If no packet is available and a timeout has been specified
* The call will block.
* Do NOT call this from ISR
* @param conn pointer to connection
* @param timeout timeout in ms, use CSP_MAX_DELAY for infinite blocking time
* @return Returns pointer to csp_packet_t, which you MUST free yourself, either by calling csp_buffer_free() or reusing the buffer for a new csp_send.
*/
csp_packet_t *csp_read(csp_conn_t *conn, uint32_t timeout);
/**
* Send a packet on an already established connection
* @param conn pointer to connection
* @param packet pointer to packet,
* @param timeout a timeout to wait for TX to complete. NOTE: not all underlying drivers supports flow-control.
* @return returns 1 if successful and 0 otherwise. you MUST free the frame yourself if the transmission was not successful.
*/
int csp_send(csp_conn_t *conn, csp_packet_t *packet, uint32_t timeout);
/**
* Send a packet on an already established connection, and change the default priority of the connection
*
* @note When using this function, the priority of the connection will change. If you need to change it back
* use another call to csp_send_prio, or ensure that all packets sent on a given connection is using send_prio call.
*
* @param prio csp priority
* @param conn pointer to connection
* @param packet pointer to packet,
* @param timeout a timeout to wait for TX to complete. NOTE: not all underlying drivers supports flow-control.
* @return returns 1 if successful and 0 otherwise. you MUST free the frame yourself if the transmission was not successful.
*/
int csp_send_prio(uint8_t prio, csp_conn_t *conn, csp_packet_t *packet, uint32_t timeout);
/**
* Perform an entire request/reply transaction
* Copies both input buffer and reply to output buffeer.
* Also makes the connection and closes it again
* @param prio CSP Prio
* @param dest CSP Dest
* @param port CSP Port
* @param timeout timeout in ms
* @param outbuf pointer to outgoing data buffer
* @param outlen length of request to send
* @param inbuf pointer to incoming data buffer
* @param inlen length of expected reply, -1 for unknown size (note inbuf MUST be large enough)
* @return Return 1 or reply size if successful, 0 if error or incoming length does not match or -1 if timeout was reached
*/
int csp_transaction(uint8_t prio, uint8_t dest, uint8_t port, uint32_t timeout, void *outbuf, int outlen, void *inbuf, int inlen);
/**
* Use an existing connection to perform a transaction,
* This is only possible if the next packet is on the same port and destination!
* @param conn pointer to connection structure
* @param timeout timeout in ms
* @param outbuf pointer to outgoing data buffer
* @param outlen length of request to send
* @param inbuf pointer to incoming data buffer
* @param inlen length of expected reply, -1 for unknown size (note inbuf MUST be large enough)
* @return
*/
int csp_transaction_persistent(csp_conn_t *conn, uint32_t timeout, void *outbuf, int outlen, void *inbuf, int inlen);
/**
* Read data from a connection-less server socket
* This fuction uses the socket directly to receive a frame
* If no packet is available and a timeout has been specified the call will block.
* Do NOT call this from ISR
* @return Returns pointer to csp_packet_t, which you MUST free yourself, either by calling csp_buffer_free() or reusing the buffer for a new csp_send.
*/
csp_packet_t *csp_recvfrom(csp_socket_t *socket, uint32_t timeout);
/**
* Send a packet without previously opening a connection
* @param prio CSP_PRIO_x
* @param dest destination node
* @param dport destination port
* @param src_port source port
* @param opts CSP_O_x
* @param packet pointer to packet
* @param timeout timeout used by interfaces with blocking send
* @return -1 if error (you must free packet), 0 if OK (you must discard pointer)
*/
int csp_sendto(uint8_t prio, uint8_t dest, uint8_t dport, uint8_t src_port, uint32_t opts, csp_packet_t *packet, uint32_t timeout);
/**
* Send a packet as a direct reply to the source of an incoming packet,
* but still without holding an entire connection
* @param request_packet pointer to packet to reply to
* @param reply_packet actual reply data
* @param opts CSP_O_x
* @param timeout timeout used by interfaces with blocking send
* @return -1 if error (you must free packet), 0 if OK (you must discard pointer)
*/
int csp_sendto_reply(csp_packet_t * request_packet, csp_packet_t * reply_packet, uint32_t opts, uint32_t timeout);
/** csp_connect
* Used to establish outgoing connections
* This function searches the port table for free slots and finds an unused
* connection from the connection pool
* There is no handshake in the CSP protocol
* @param prio Connection priority.
* @param dest Destination address.
* @param dport Destination port.
* @param timeout Timeout in ms.
* @param opts Connection options.
* @return a pointer to a new connection or NULL
*/
csp_conn_t *csp_connect(uint8_t prio, uint8_t dest, uint8_t dport, uint32_t timeout, uint32_t opts);
/** csp_close
* Closes a given connection and frees buffers used.
* @param conn pointer to connection structure
* @return CSP_ERR_NONE if connection was closed. Otherwise, an err code is returned.
*/
int csp_close(csp_conn_t *conn);
/**
* @param conn pointer to connection structure
* @return destination port of an incoming connection
*/
int csp_conn_dport(csp_conn_t *conn);
/**
* @param conn pointer to connection structure
* @return source port of an incoming connection
*/
int csp_conn_sport(csp_conn_t *conn);
/**
* @param conn pointer to connection structure
* @return destination address of an incoming connection
*/
int csp_conn_dst(csp_conn_t *conn);
/**
* @param conn pointer to connection structure
* @return source address of an incoming connection
*/
int csp_conn_src(csp_conn_t *conn);
/**
* @param conn pointer to connection structure
* @return flags field of an incoming connection
*/
int csp_conn_flags(csp_conn_t *conn);
/**
* Set socket to listen for incoming connections
* @param socket Socket to enable listening on
* @param conn_queue_length Lenght of backlog connection queue
* @return 0 on success, -1 on error.
*/
int csp_listen(csp_socket_t *socket, size_t conn_queue_length);
/**
* Bind port to socket
* @param socket Socket to bind port to
* @param port Port number to bind
* @return 0 on success, -1 on error.
*/
int csp_bind(csp_socket_t *socket, uint8_t port);
/**
* Start the router task.
* @param task_stack_size The number of portStackType to allocate. This only affects FreeRTOS systems.
* @param priority The OS task priority of the router
*/
int csp_route_start_task(unsigned int task_stack_size, unsigned int priority);
/**
* Call the router worker function manually (without the router task)
* This must be run inside a loop or called periodically for the csp router to work.
* Use this function instead of calling and starting the router task.
* @param timeout max blocking time
* @return -1 if no packet was processed, 0 otherwise
*/
int csp_route_work(uint32_t timeout);
/**
* Start the bridge task.
* @param task_stack_size The number of portStackType to allocate. This only affects FreeRTOS systems.
* @param priority The OS task priority of the router
* @param _if_a pointer to first side
* @param _if_b pointer to second side
* @return CSP_ERR type
*/
int csp_bridge_start(unsigned int task_stack_size, unsigned int task_priority, csp_iface_t * _if_a, csp_iface_t * _if_b);
/**
* Enable promiscuous mode packet queue
* This function is used to enable promiscuous mode for the router.
* If enabled, a copy of all incoming packets are placed in a queue
* that can be read with csp_promisc_get(). Not all interface drivers
* support promiscuous mode.
*
* @param buf_size Size of buffer for incoming packets
*/
int csp_promisc_enable(unsigned int buf_size);
/**
* Disable promiscuous mode.
* If the queue was initialised prior to this, it can be re-enabled
* by calling promisc_enable(0)
*/
void csp_promisc_disable(void);
/**
* Get packet from promiscuous mode packet queue
* Returns the first packet from the promiscuous mode packet queue.
* The queue is FIFO, so the returned packet is the oldest one
* in the queue.
*
* @param timeout Timeout in ms to wait for a new packet
*/
csp_packet_t *csp_promisc_read(uint32_t timeout);
/**
* Send multiple packets using the simple fragmentation protocol
* CSP will add total size and offset to all packets
* This can be read by the client using the csp_sfp_recv, if the CSP_FFRAG flag is set
* @param conn pointer to connection
* @param data pointer to data to send
* @param totalsize size of data to send
* @param mtu maximum transfer unit
* @param timeout timeout in ms to wait for csp_send()
* @return 0 if OK, -1 if ERR
*/
int csp_sfp_send(csp_conn_t * conn, void * data, int totalsize, int mtu, uint32_t timeout);
/**
* Same as csp_sfp_send but with option to supply your own memcpy function.
* This is usefull if you wish to send data stored in flash memory or another location
* @param conn pointer to connection
* @param data pointer to data to send
* @param totalsize size of data to send
* @param mtu maximum transfer unit
* @param timeout timeout in ms to wait for csp_send()
* @param memcpyfcn, pointer to memcpy function
* @return 0 if OK, -1 if ERR
*/
int csp_sfp_send_own_memcpy(csp_conn_t * conn, void * data, int totalsize, int mtu, uint32_t timeout, void * (*memcpyfcn)(void *, const void *, size_t));
/**
* This is the counterpart to the csp_sfp_send function
* @param conn pointer to active conn, on which you expect to receive sfp packed data
* @param dataout pointer to NULL pointer, whill be overwritten with malloc pointer
* @param datasize actual size of received data
* @param timeout timeout in ms to wait for csp_recv()
* @return 0 if OK, -1 if ERR
*/
int csp_sfp_recv(csp_conn_t * conn, void ** dataout, int * datasize, uint32_t timeout);
/**
* This is the counterpart to the csp_sfp_send function
* @param conn pointer to active conn, on which you expect to receive sfp packed data
* @param dataout pointer to NULL pointer, whill be overwritten with malloc pointer
* @param datasize actual size of received data
* @param timeout timeout in ms to wait for csp_recv()
* @param first_packet This is a pointer to the first SFP packet (previously received with csp_read)
* @return 0 if OK, -1 if ERR
*/
int csp_sfp_recv_fp(csp_conn_t * conn, void ** dataout, int * datasize, uint32_t timeout, csp_packet_t * first_packet);
/**
* If the given packet is a service-request (that is uses one of the csp service ports)
* it will be handled according to the CSP service handler.
* This function will either use the packet buffer or delete it,
* so this function is typically called in the last "default" clause of
* a switch/case statement in a csp_listener task.
* In order to listen to csp service ports, bind your listener to the CSP_ANY port.
* This function may only be called from task context.
* @param conn Pointer to the new connection
* @param packet Pointer to the first packet, obtained by using csp_read()
*/
void csp_service_handler(csp_conn_t *conn, csp_packet_t *packet);
/**
* Send a single ping/echo packet
* @param node node id
* @param timeout timeout in ms
* @param size size of packet to transmit
* @param conn_options csp connection options
* @return >0 = Echo time in ms, -1 = ERR
*/
int csp_ping(uint8_t node, uint32_t timeout, unsigned int size, uint8_t conn_options);
/**
* Send a single ping/echo packet without waiting for reply
* @param node node id
*/
void csp_ping_noreply(uint8_t node);
/**
* Request process list.
* @note This is only available for FreeRTOS systems
* @param node node id
* @param timeout timeout in ms
*/
void csp_ps(uint8_t node, uint32_t timeout);
/**
* Request amount of free memory
* @param node node id
* @param timeout timeout in ms
*/
void csp_memfree(uint8_t node, uint32_t timeout);
/**
* Request number of free buffer elements
* @param node node id
* @param timeout timeout in ms
*/
void csp_buf_free(uint8_t node, uint32_t timeout);
/**
* Reboot subsystem
* @param node node id
*/
void csp_reboot(uint8_t node);
/**
* Shutdown subsystem
* @param node node id
*/
void csp_shutdown(uint8_t node);
/**
* Request subsystem uptime
* @param node node id
* @param timeout timeout in ms
*/
void csp_uptime(uint8_t node, uint32_t timeout);
/**
* Set RDP options
* @param window_size Window size
* @param conn_timeout_ms Connection timeout in ms
* @param packet_timeout_ms Packet timeout in ms
* @param delayed_acks Enable/disable delayed acknowledgements
* @param ack_timeout Acknowledgement timeout when delayed ACKs is enabled
* @param ack_delay_count Send acknowledgement for every ack_delay_count packets
*/
void csp_rdp_set_opt(unsigned int window_size, unsigned int conn_timeout_ms,
unsigned int packet_timeout_ms, unsigned int delayed_acks,
unsigned int ack_timeout, unsigned int ack_delay_count);
/**
* Get RDP options
* @param window_size Window size
* @param conn_timeout_ms Connection timeout in ms
* @param packet_timeout_ms Packet timeout in ms
* @param delayed_acks Enable/disable delayed acknowledgements
* @param ack_timeout Acknowledgement timeout when delayed ACKs is enabled
* @param ack_delay_count Send acknowledgement for every ack_delay_count packets
*/
void csp_rdp_get_opt(unsigned int *window_size, unsigned int *conn_timeout_ms,
unsigned int *packet_timeout_ms, unsigned int *delayed_acks,
unsigned int *ack_timeout, unsigned int *ack_delay_count);
/**
* Set XTEA key
* @param key Pointer to key array
* @param keylen Length of key
* @return 0 if key was successfully set, -1 otherwise
*/
int csp_xtea_set_key(char *key, uint32_t keylen);
/**
* Set HMAC key
* @param key Pointer to key array
* @param keylen Length of key
* @return 0 if key was successfully set, -1 otherwise
*/
int csp_hmac_set_key(char *key, uint32_t keylen);
/**
* Print connection table
*/
void csp_conn_print_table(void);
int csp_conn_print_table_str(char * str_buf, int str_size);
/**
* Print buffer usage table
*/
void csp_buffer_print_table(void);
typedef void * csp_memptr_t;
typedef csp_memptr_t (*csp_memcpy_fnc_t)(csp_memptr_t, const csp_memptr_t, size_t);
void csp_cmp_set_memcpy(csp_memcpy_fnc_t fnc);
/**
* Set csp_debug hook function
* @param f Hook function
*/
/*****************************************************************************/
/* stdarg.h */
/* */
/* Copyright (c) 1996 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
#pragma diag_push
#pragma CHECK_MISRA("-19.7") /* need function-like macros */
#pragma CHECK_MISRA("-19.10") /* need types as macro arguments */
#pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
#pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */
typedef __va_list va_list;
#pragma diag_pop
typedef void (*csp_debug_hook_func_t)(csp_debug_level_t level, const char *format, va_list args);
void csp_debug_hook_set(csp_debug_hook_func_t f);
} /* extern "C" */
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 GomSpace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern "C" {
/*
Cubesat Space Protocol - A small network-layer protocol designed for Cubesats
Copyright (C) 2012 Gomspace ApS (http://www.gomspace.com)
Copyright (C) 2012 AAUSAT3 Project (http://aausat3.space.aau.dk)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern "C" {
/**
* Inputs a new packet into the system
* This function is called from interface drivers ISR to route and accept packets.
* But it can also be called from a task, provided that the pxTaskWoken parameter is NULL!
*
* EXTREMELY IMPORTANT:
* pxTaskWoken arg must ALWAYS be NULL if called from task,
* and ALWAYS be NON NULL if called from ISR!
* If this condition is met, this call is completely thread-safe
*
* This function is fire and forget, it returns void, meaning
* that a packet will always be either accepted or dropped
* so the memory will always be freed.
*
* @param packet A pointer to the incoming packet
* @param interface A pointer to the incoming interface TX function.
* @param pxTaskWoken This must be a pointer a valid variable if called from ISR or NULL otherwise!
*/
void csp_qfifo_write(csp_packet_t *packet, csp_iface_t *interface, long *pxTaskWoken);
/**
* csp_new_packet is deprecated, use csp_qfifo_write
*/
/**
* Get MAC layer address of next hop.
* @param node Next hop node
* @return MAC layer address
*/
uint8_t csp_route_get_mac(uint8_t node);
/**
* Register your interface in the router core using this function.
* This must be done in the interface init() function.
*/
void csp_iflist_add(csp_iface_t * ifc);
} /* extern "C" */
/** CAN interface modes */
extern csp_iface_t csp_if_can;
/* CAN configuration struct */
struct csp_can_config {
uint32_t bitrate;
uint32_t clock_speed;
char *ifc;
};
/**
* Init CAN interface
* @param mode Must be either CSP_CAN_MASKED or CSP_CAN_PROMISC
* @param conf Pointer to configuration struct.
* @return 0 if CAN interface was successfully initialized, -1 otherwise
*/
int csp_can_init(uint8_t mode, struct csp_can_config *conf);
} /* extern "C" */
/*!
* @addtogroup tcp_transport
* @{
* @file
*/
////////////////////////////////////////////////////////////////////////////////
// Classes
////////////////////////////////////////////////////////////////////////////////
namespace erpc {
/*!
* @brief CubeSat Space Protocol transport implementation.
*
* @ingroup csp_transport
*/
class CSPTransport : public Transport
{
public:
/*!
* @brief Server constructor.
*
* This function initializes object attributes as a server.
*
* @param[in] port Specify the listening port number.
*/
CSPTransport(int port);
/*!
* @brief Client constructor.
*
* This function initializes object attributes as a client.
*
* @param[in] port Specify the listening port number.
* @param[in] dest_addr Specify the server address.
* @param[in] dest_port Specify the server port.
*/
CSPTransport(int port, int dest_addr, int dest_port);
/*!
* @brief TCPTransport destructor
*/
virtual ~CSPTransport();
void cspTransportClose(void);
private:
void cspTransportInit(void);
protected:
bool m_isServer; /*!< If true then server is using transport, else client. */
int m_dst_node_address; /*!< Specify address of the destination node. */
int m_sport; /*!< Specify the source port number. */
int m_dport; /*!< Specify the destination port number. */
//int buffer_start; /*!< Specify the buffer start location. */
//int buffer_length; /*!< Specify the buffer used lenght. */
//uint8_t buffer[BUFFER_SIZE]; /*!< Buffer for received data. */
csp_socket_t *recvSocket; /*!< Listening socket. */
csp_packet_t *out_packet; /*!< Outgoing packet pointer. */
csp_packet_t *in_packet; /*!< Incoming packet pointer. */
Mutex m_sendLock; //!< Mutex protecting send.
Mutex m_receiveLock; //!< Mutex protecting receive.
/*!
* @brief This function read data.
*
* @param[inout] data Preallocated buffer for receiving data.
* @param[in] size Size of data to read.
*
* @retval #kErpcStatus_Success When data was read successfully.
* @retval #kErpcStatus_ReceiveFailed When reading data ends with error.
* @retval #kErpcStatus_ConnectionClosed Peer closed the connection.
*/
virtual erpc_status_t receive(MessageBuffer *message);
/*!
* @brief This function writes data.
*
* @param[in] data Buffer to send.
* @param[in] size Size of data to send.
*
* @retval #kErpcStatus_Success When data was written successfully.
* @retval #kErpcStatus_SendFailed When writing data ends with error.
* @retval #kErpcStatus_ConnectionClosed Peer closed the connection.
*/
virtual erpc_status_t send(MessageBuffer *message);
};
} // namespace erpc
/*! @} */
// -*- C++ -*-
//===-------------------------- cassert -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
cassert synopsis
Macros:
assert
*/
/*****************************************************************************/
/* assert.h */
/* */
/* Copyright (c) 1993 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
#pragma diag_push
#pragma CHECK_MISRA("-6.3") /* standard types required for standard headers */
#pragma CHECK_MISRA("-19.4") /* macros required for implementation */
#pragma CHECK_MISRA("-19.7") /* macros required for implementation */
#pragma CHECK_MISRA("-19.13") /* # and ## required for implementation */
extern "C"
{
extern void _abort_msg(const char *msg);
} /* extern "C" */
#pragma diag_pop
// -*- C++ -*-
//===---------------------------- cstdio ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
cstdio synopsis
Macros:
BUFSIZ
EOF
FILENAME_MAX
FOPEN_MAX
L_tmpnam
NULL
SEEK_CUR
SEEK_END
SEEK_SET
TMP_MAX
_IOFBF
_IOLBF
_IONBF
stderr
stdin
stdout
namespace std
{
Types:
FILE
fpos_t
size_t
int remove(const char* filename);
int rename(const char* old, const char* new);
FILE* tmpfile(void);
char* tmpnam(char* s);
int fclose(FILE* stream);
int fflush(FILE* stream);
FILE* fopen(const char* restrict filename, const char* restrict mode);
FILE* freopen(const char* restrict filename, const char * restrict mode,
FILE * restrict stream);
void setbuf(FILE* restrict stream, char* restrict buf);
int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
int fprintf(FILE* restrict stream, const char* restrict format, ...);
int fscanf(FILE* restrict stream, const char * restrict format, ...);
int printf(const char* restrict format, ...);
int scanf(const char* restrict format, ...);
int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
int sprintf(char* restrict s, const char* restrict format, ...);
int sscanf(const char* restrict s, const char* restrict format, ...);
int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
int vprintf(const char* restrict format, va_list arg);
int vscanf(const char* restrict format, va_list arg); // C99
int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
va_list arg);
int vsprintf(char* restrict s, const char* restrict format, va_list arg);
int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
int fgetc(FILE* stream);
char* fgets(char* restrict s, int n, FILE* restrict stream);
int fputc(int c, FILE* stream);
int fputs(const char* restrict s, FILE* restrict stream);
int getc(FILE* stream);
int getchar(void);
char* gets(char* s); // removed in C++14
int putc(int c, FILE* stream);
int putchar(int c);
int puts(const char* s);
int ungetc(int c, FILE* stream);
size_t fread(void* restrict ptr, size_t size, size_t nmemb,
FILE* restrict stream);
size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
FILE* restrict stream);
int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
int fseek(FILE* stream, long offset, int whence);
int fsetpos(FILE*stream, const fpos_t* pos);
long ftell(FILE* stream);
void rewind(FILE* stream);
void clearerr(FILE* stream);
int feof(FILE* stream);
int ferror(FILE* stream);
void perror(const char* s);
} // std
*/
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
stdio.h synopsis
Macros:
BUFSIZ
EOF
FILENAME_MAX
FOPEN_MAX
L_tmpnam
NULL
SEEK_CUR
SEEK_END
SEEK_SET
TMP_MAX
_IOFBF
_IOLBF
_IONBF
stderr
stdin
stdout
Types:
FILE
fpos_t
size_t
int remove(const char* filename);
int rename(const char* old, const char* new);
FILE* tmpfile(void);
char* tmpnam(char* s);
int fclose(FILE* stream);
int fflush(FILE* stream);
FILE* fopen(const char* restrict filename, const char* restrict mode);
FILE* freopen(const char* restrict filename, const char * restrict mode,
FILE * restrict stream);
void setbuf(FILE* restrict stream, char* restrict buf);
int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
int fprintf(FILE* restrict stream, const char* restrict format, ...);
int fscanf(FILE* restrict stream, const char * restrict format, ...);
int printf(const char* restrict format, ...);
int scanf(const char* restrict format, ...);
int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
int sprintf(char* restrict s, const char* restrict format, ...);
int sscanf(const char* restrict s, const char* restrict format, ...);
int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
int vprintf(const char* restrict format, va_list arg);
int vscanf(const char* restrict format, va_list arg); // C99
int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
va_list arg);
int vsprintf(char* restrict s, const char* restrict format, va_list arg);
int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
int fgetc(FILE* stream);
char* fgets(char* restrict s, int n, FILE* restrict stream);
int fputc(int c, FILE* stream);
int fputs(const char* restrict s, FILE* restrict stream);
int getc(FILE* stream);
int getchar(void);
char* gets(char* s); // removed in C++14
int putc(int c, FILE* stream);
int putchar(int c);
int puts(const char* s);
int ungetc(int c, FILE* stream);
size_t fread(void* restrict ptr, size_t size, size_t nmemb,
FILE* restrict stream);
size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
FILE* restrict stream);
int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
int fseek(FILE* stream, long offset, int whence);
int fsetpos(FILE*stream, const fpos_t* pos);
long ftell(FILE* stream);
void rewind(FILE* stream);
void clearerr(FILE* stream);
int feof(FILE* stream);
int ferror(FILE* stream);
void perror(const char* s);
*/
/*****************************************************************************/
/* STDIO.H */
/* */
/* Copyright (c) 1993 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
/*---------------------------------------------------------------------------*/
/* Attributes are only available in relaxed ANSI mode. */
/*---------------------------------------------------------------------------*/
extern "C" {
/****************************************************************************/
/* TYPES THAT ANSI REQUIRES TO BE DEFINED */
/****************************************************************************/
struct __sFILE {
int fd; /* File descriptor */
unsigned char* buf; /* Pointer to start of buffer */
unsigned char* pos; /* Position in buffer */
unsigned char* bufend; /* Pointer to end of buffer */
unsigned char* buff_stop; /* Pointer to last read char in buffer */
unsigned int flags; /* File status flags (see below) */
};
typedef struct __sFILE FILE;
typedef long fpos_t;
/****************************************************************************/
/* DEVICE AND STREAM RELATED MACROS */
/****************************************************************************/
/****************************************************************************/
/* MACROS THAT DEFINE AND USE FILE STATUS FLAGS */
/****************************************************************************/
/****************************************************************************/
/* MACROS THAT ANSI REQUIRES TO BE DEFINED */
/****************************************************************************/
/******** END OF ANSI MACROS ************************************************/
/****************************************************************************/
/* DEVICE AND STREAM RELATED DATA STRUCTURES AND MACROS */
/****************************************************************************/
extern FILE _ftable[10];
extern char __TI_tmpnams[10][16];
/****************************************************************************/
/* FUNCTION DEFINITIONS - ANSI */
/****************************************************************************/
/****************************************************************************/
/* OPERATIONS ON FILES */
/****************************************************************************/
extern int remove(const char *_file);
extern int rename(const char *_old, const char *_new);
extern FILE *tmpfile(void);
extern char *tmpnam(char *_s);
/****************************************************************************/
/* FILE ACCESS FUNCTIONS */
/****************************************************************************/
extern int fclose(FILE * __restrict _fp);
extern FILE *fopen(const char * __restrict _fname,
const char * __restrict _mode);
extern FILE *freopen(const char * __restrict _fname,
const char * __restrict _mode,
FILE * __restrict _fp);
extern void setbuf(FILE * __restrict _fp,
char * __restrict _buf);
extern int setvbuf(FILE * __restrict _fp,
char * __restrict _buf,
int _type, size_t _size);
extern int fflush(FILE *_fp);
/****************************************************************************/
/* FORMATTED INPUT/OUTPUT FUNCTIONS */
/****************************************************************************/
extern int fprintf(FILE * __restrict _fp,
const char * __restrict _format, ...)
__attribute__((__format__ (__printf__, 2, 3)));
extern int fscanf(FILE * __restrict _fp,
const char * __restrict _fmt, ...)
__attribute__((__format__ (__scanf__, 2, 3)));
extern int printf(const char * __restrict _format, ...)
__attribute__((__format__ (__printf__, 1, 2)));
extern int scanf(const char * __restrict _fmt, ...)
__attribute__((__format__ (__scanf__, 1, 2)));
extern int sprintf(char * __restrict _string,
const char * __restrict _format, ...)
__attribute__((__format__ (__printf__, 2, 3)));
extern int snprintf(char * __restrict _string, size_t _n,
const char * __restrict _format, ...)
__attribute__((__format__ (__printf__, 3, 4)));
extern int sscanf(const char * __restrict _str,
const char * __restrict _fmt, ...)
__attribute__((__format__ (__scanf__, 2, 3)));
extern int vfprintf(FILE * __restrict _fp,
const char * __restrict _format, va_list _ap)
__attribute__((__format__ (__printf__, 2, 0)));
extern int vfscanf(FILE * __restrict _fp,
const char * __restrict _fmt, va_list _ap)
__attribute__((__format__ (__scanf__, 2, 0)));
extern int vprintf(const char * __restrict _format, va_list _ap)
__attribute__((__format__ (__printf__, 1, 0)));
extern int vscanf(const char * __restrict _format, va_list _ap)
__attribute__((__format__ (__scanf__, 1, 0)));
extern int vsprintf(char * __restrict _string,
const char * __restrict _format, va_list _ap)
__attribute__((__format__ (__printf__, 2, 0)));
extern int vsnprintf(char * __restrict _string, size_t _n,
const char * __restrict _format, va_list _ap)
__attribute__((__format__ (__printf__, 3, 0)));
extern int vsscanf(const char * __restrict _str,
const char * __restrict _fmt, va_list _ap)
__attribute__((__format__ (__scanf__, 2, 0)));
extern int asprintf(char **, const char *, ...)
__attribute__((__format__ (__printf__, 2, 3)));
extern int vasprintf(char **, const char *, va_list)
__attribute__((__format__ (__printf__, 2, 0)));
/****************************************************************************/
/* CHARACTER INPUT/OUTPUT FUNCTIONS */
/****************************************************************************/
extern int fgetc(FILE *_fp);
extern char *fgets(char * __restrict _ptr, int _size,
FILE * __restrict _fp);
extern int fputc(int _c, FILE *_fp);
extern int fputs(const char * __restrict _ptr,
FILE * __restrict _fp);
extern int getc(FILE *_p);
extern int getchar(void);
extern char *gets(char *_ptr);
extern int putc(int _x, FILE *_fp);
extern int putchar(int _x);
extern int puts(const char *_ptr);
extern int ungetc(int _c, FILE *_fp);
/****************************************************************************/
/* DIRECT INPUT/OUTPUT FUNCTIONS */
/****************************************************************************/
extern size_t fread(void * __restrict _ptr,
size_t _size, size_t _count,
FILE * __restrict _fp);
extern size_t fwrite(const void * __restrict _ptr,
size_t _size, size_t _count,
FILE * __restrict _fp);
/****************************************************************************/
/* FILE POSITIONING FUNCTIONS */
/****************************************************************************/
extern int fgetpos(FILE * __restrict _fp,
fpos_t * __restrict _pos);
extern int fseek(FILE *_fp, long _offset,
int _ptrname);
extern int fsetpos(FILE * __restrict _fp,
const fpos_t * __restrict _pos);
extern long ftell(FILE *_fp);
extern void rewind(FILE *_fp);
/****************************************************************************/
/* ERROR-HANDLING FUNCTIONS */
/****************************************************************************/
extern void clearerr(FILE *_fp);
extern int feof(FILE *_fp);
extern int ferror(FILE *_fp);
extern void perror(const char *_s);
} /* extern "C" */
/*----------------------------------------------------------------------------*/
/* If sys/cdefs.h is available, go ahead and include it. xlocale.h assumes */
/* this file will have already included sys/cdefs.h. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Include xlocale/_stdio.h if xlocale.h has already been included. This is */
/* to conform with FreeBSD's xlocale implementation. */
/*----------------------------------------------------------------------------*/
/* snprintf */
namespace std { inline namespace __2 {
using ::FILE;
using ::fpos_t;
using ::size_t;
using ::fclose;
using ::fflush;
using ::setbuf;
using ::setvbuf;
using ::fprintf;
using ::fscanf;
using ::snprintf;
using ::sprintf;
using ::sscanf;
using ::vfprintf;
using ::vfscanf;
using ::vsscanf;
using ::vsnprintf;
using ::vsprintf;
using ::fgetc;
using ::fgets;
using ::fputc;
using ::fputs;
using ::getc;
using ::putc;
using ::ungetc;
using ::fread;
using ::fwrite;
using ::fgetpos;
using ::fseek;
using ::fsetpos;
using ::ftell;
using ::rewind;
using ::clearerr;
using ::feof;
using ::ferror;
using ::perror;
using ::fopen;
using ::freopen;
using ::remove;
using ::rename;
using ::tmpfile;
using ::tmpnam;
using ::getchar;
using ::scanf;
using ::vscanf;
using ::printf;
using ::putchar;
using ::puts;
using ::vprintf;
} }
// -*- C++ -*-
//===----------------------------- new ------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
new synopsis
namespace std
{
class bad_alloc
: public exception
{
public:
bad_alloc() noexcept;
bad_alloc(const bad_alloc&) noexcept;
bad_alloc& operator=(const bad_alloc&) noexcept;
virtual const char* what() const noexcept;
};
class bad_array_length : public bad_alloc // FIXME: Not part of C++
{
public:
bad_array_length() noexcept;
};
class bad_array_new_length : public bad_alloc // C++14
{
public:
bad_array_new_length() noexcept;
};
enum class align_val_t : size_t {}; // C++17
struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
new_handler set_new_handler(new_handler new_p) noexcept;
new_handler get_new_handler() noexcept;
} // std
void* operator new(std::size_t size); // replaceable
void* operator new(std::size_t size, std::align_val_t alignment); // replaceable, C++17
void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable
void* operator new(std::size_t size, std::align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
void operator delete(void* ptr) noexcept; // replaceable
void operator delete(void* ptr, std::size_t size) noexcept; // replaceable, C++14
void operator delete(void* ptr, std::align_val_t alignment) noexcept; // replaceable, C++17
void operator delete(void* ptr, std::size_t size,
std::align_val_t alignment) noexcept; // replaceable, C++17
void operator delete(void* ptr, const std::nothrow_t&) noexcept; // replaceable
void operator delete(void* ptr, std:align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
void* operator new[](std::size_t size); // replaceable
void* operator new[](std::size_t size,
std::align_val_t alignment) noexcept; // replaceable, C++17
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable
void* operator new[](std::size_t size, std::align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
void operator delete[](void* ptr) noexcept; // replaceable
void operator delete[](void* ptr, std::size_t size) noexcept; // replaceable, C++14
void operator delete[](void* ptr,
std::align_val_t alignment) noexcept; // replaceable, C++17
void operator delete[](void* ptr, std::size_t size,
std::align_val_t alignment) noexcept; // replaceable, C++17
void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // replaceable
void operator delete[](void* ptr, std::align_val_t alignment,
const std::nothrow_t&) noexcept; // replaceable, C++17
void* operator new (std::size_t size, void* ptr) noexcept;
void* operator new[](std::size_t size, void* ptr) noexcept;
void operator delete (void* ptr, void*) noexcept;
void operator delete[](void* ptr, void*) noexcept;
*/
// -*- C++ -*-
//===-------------------------- exception ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
exception synopsis
namespace std
{
class exception
{
public:
exception() noexcept;
exception(const exception&) noexcept;
exception& operator=(const exception&) noexcept;
virtual ~exception() noexcept;
virtual const char* what() const noexcept;
};
class bad_exception
: public exception
{
public:
bad_exception() noexcept;
bad_exception(const bad_exception&) noexcept;
bad_exception& operator=(const bad_exception&) noexcept;
virtual ~bad_exception() noexcept;
virtual const char* what() const noexcept;
};
typedef void (*unexpected_handler)();
unexpected_handler set_unexpected(unexpected_handler f ) noexcept;
unexpected_handler get_unexpected() noexcept;
[[noreturn]] void unexpected();
typedef void (*terminate_handler)();
terminate_handler set_terminate(terminate_handler f ) noexcept;
terminate_handler get_terminate() noexcept;
[[noreturn]] void terminate() noexcept;
bool uncaught_exception() noexcept;
int uncaught_exceptions() noexcept; // C++17
typedef unspecified exception_ptr;
exception_ptr current_exception() noexcept;
void rethrow_exception [[noreturn]] (exception_ptr p);
template<class E> exception_ptr make_exception_ptr(E e) noexcept;
class nested_exception
{
public:
nested_exception() noexcept;
nested_exception(const nested_exception&) noexcept = default;
nested_exception& operator=(const nested_exception&) noexcept = default;
virtual ~nested_exception() = default;
// access functions
[[noreturn]] void rethrow_nested() const;
exception_ptr nested_ptr() const noexcept;
};
template <class T> [[noreturn]] void throw_with_nested(T&& t);
template <class E> void rethrow_if_nested(const E& e);
} // std
*/
// -*- C++ -*-
//===--------------------------- cstdlib ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
cstdlib synopsis
Macros:
EXIT_FAILURE
EXIT_SUCCESS
MB_CUR_MAX
NULL
RAND_MAX
namespace std
{
Types:
size_t
div_t
ldiv_t
lldiv_t // C99
double atof (const char* nptr);
int atoi (const char* nptr);
long atol (const char* nptr);
long long atoll(const char* nptr); // C99
double strtod (const char* restrict nptr, char** restrict endptr);
float strtof (const char* restrict nptr, char** restrict endptr); // C99
long double strtold (const char* restrict nptr, char** restrict endptr); // C99
long strtol (const char* restrict nptr, char** restrict endptr, int base);
long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
int rand(void);
void srand(unsigned int seed);
void* calloc(size_t nmemb, size_t size);
void free(void* ptr);
void* malloc(size_t size);
void* realloc(void* ptr, size_t size);
void abort(void);
int atexit(void (*func)(void));
void exit(int status);
void _Exit(int status);
char* getenv(const char* name);
int system(const char* string);
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
void qsort(void* base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
int abs( int j);
long abs( long j);
long long abs(long long j); // C++0X
long labs( long j);
long long llabs(long long j); // C99
div_t div( int numer, int denom);
ldiv_t div( long numer, long denom);
lldiv_t div(long long numer, long long denom); // C++0X
ldiv_t ldiv( long numer, long denom);
lldiv_t lldiv(long long numer, long long denom); // C99
int mblen(const char* s, size_t n);
int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
int wctomb(char* s, wchar_t wchar);
size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
int at_quick_exit(void (*func)(void)) // C++11
void quick_exit(int status); // C++11
void *aligned_alloc(size_t alignment, size_t size); // C11
} // std
*/
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
stdlib.h synopsis
Macros:
EXIT_FAILURE
EXIT_SUCCESS
MB_CUR_MAX
NULL
RAND_MAX
Types:
size_t
div_t
ldiv_t
lldiv_t // C99
double atof (const char* nptr);
int atoi (const char* nptr);
long atol (const char* nptr);
long long atoll(const char* nptr); // C99
double strtod (const char* restrict nptr, char** restrict endptr);
float strtof (const char* restrict nptr, char** restrict endptr); // C99
long double strtold (const char* restrict nptr, char** restrict endptr); // C99
long strtol (const char* restrict nptr, char** restrict endptr, int base);
long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
int rand(void);
void srand(unsigned int seed);
void* calloc(size_t nmemb, size_t size);
void free(void* ptr);
void* malloc(size_t size);
void* realloc(void* ptr, size_t size);
void abort(void);
int atexit(void (*func)(void));
void exit(int status);
void _Exit(int status);
char* getenv(const char* name);
int system(const char* string);
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
void qsort(void* base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
int abs( int j);
long abs( long j);
long long abs(long long j); // C++0X
long labs( long j);
long long llabs(long long j); // C99
div_t div( int numer, int denom);
ldiv_t div( long numer, long denom);
lldiv_t div(long long numer, long long denom); // C++0X
ldiv_t ldiv( long numer, long denom);
lldiv_t lldiv(long long numer, long long denom); // C99
int mblen(const char* s, size_t n);
int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
int wctomb(char* s, wchar_t wchar);
size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
int at_quick_exit(void (*func)(void)) // C++11
void quick_exit(int status); // C++11
void *aligned_alloc(size_t alignment, size_t size); // C11
*/
/*****************************************************************************/
/* stdlib.h */
/* */
/* Copyright (c) 1993 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
#pragma diag_push
#pragma CHECK_MISRA("-6.3") /* standard types required for standard headers */
#pragma CHECK_MISRA("-8.5") /* need to define inline function */
#pragma CHECK_MISRA("-19.1") /* #includes required for implementation */
#pragma CHECK_MISRA("-19.7") /* need function-like macros */
#pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
#pragma CHECK_MISRA("-20.2") /* standard headers must define standard names */
/*---------------------------------------------------------------------------*/
/* Attributes are only available in relaxed ANSI mode. */
/*---------------------------------------------------------------------------*/
extern "C" {
#pragma diag_push
#pragma CHECK_MISRA("-5.7") /* keep names intact */
typedef struct { int quot, rem; } div_t;
typedef struct { int quot, rem; } ldiv_t;
typedef struct { long long quot, rem; } lldiv_t;
#pragma diag_pop
/*---------------------------------------------------------------*/
/* NOTE - Normally, abs, labs, and fabs are expanded inline, so */
/* no formal definition is really required. However, ANSI */
/* requires that they exist as separate functions, so */
/* they are supplied in the library. The prototype is */
/* here mainly for documentation. */
/*---------------------------------------------------------------*/
#pragma diag_push
#pragma CHECK_MISRA("-16.4") /* false positives due to builtin declarations */
int abs(int _val);
long labs(long _val);
long long llabs(long long _val);
#pragma diag_pop
int atoi(const char *_st);
long atol(const char *_st);
long long atoll(const char *_st);
int ltoa(long val, char *buffer);
static inline double atof(const char *_st);
long strtol(const char * __restrict _st,
char ** __restrict _endptr, int _base);
unsigned long strtoul(const char * __restrict _st,
char ** __restrict _endptr, int _base);
long long strtoll(const char * __restrict _st,
char ** __restrict _endptr, int _base);
unsigned long long strtoull(const char * __restrict _st,
char ** __restrict _endptr,
int _base);
float strtof(const char * __restrict _st,
char ** __restrict _endptr);
double strtod(const char * __restrict _st,
char ** __restrict _endptr);
long double strtold(const char * __restrict _st,
char ** __restrict _endptr);
int rand(void);
void srand(unsigned _seed);
void *calloc(size_t _num, size_t _size)
__attribute__((malloc));
void *malloc(size_t _size)
__attribute__((malloc));
void *realloc(void *_ptr, size_t _size)
__attribute__((malloc));
void free(void *_ptr);
void *memalign(size_t _aln, size_t _size)
__attribute__((malloc));
[[noreturn]] void abort(void) noexcept;
typedef void (*__TI_atexit_fn)(void);
int atexit(__TI_atexit_fn _func) noexcept;
typedef int (*__TI_compar_fn)(const void *_a,const void *_b);
void *bsearch(const void *_key, const void *_base,
size_t _nmemb, size_t _size,
__TI_compar_fn compar);
void qsort(void *_base, size_t _nmemb, size_t _size,
__TI_compar_fn compar);
[[noreturn]] void exit(int _status);
[[noreturn]] void _Exit(int _status);
div_t div(int _numer, int _denom);
ldiv_t ldiv(long _numer, long _denom);
lldiv_t lldiv(long long _numer, long long _denom);
char *getenv(const char *_string);
int system(const char *_name);
int mblen(const char *_s, size_t _n);
size_t mbstowcs(wchar_t * __restrict _dest,
const char * __restrict _src, size_t _n);
int mbtowc(wchar_t * __restrict _dest,
const char * __restrict _src, size_t _n);
size_t wcstombs(char * __restrict _dest,
const wchar_t * __restrict _src, size_t _n);
int wctomb(char *_s, wchar_t _wc);
} /* extern "C" */
static inline double atof(const char *_st)
{
return strtod(_st, (char **)0);
}
/*****************************************************************************/
/* If we leave these active when in relaxed ANSI mode, we get infinite */
/* recursion due to changes in type matching. See comment in */
/* ansi/sys_predef.c line 4377 on why we specifically check the */
/* __TI_STRICT_ANSI_MODE__ macro here and its relation to strict ANSI and */
/* relaxed ANSI parser modes. */
/*****************************************************************************/
#pragma diag_pop
#pragma diag_push
/* C2000-specific additions to header implemented with #include */
#pragma CHECK_MISRA("-19.1")
#pragma CHECK_MISRA("-19.15")
/*----------------------------------------------------------------------------*/
/* If sys/cdefs.h is available, go ahead and include it. xlocale.h assumes */
/* this file will have already included sys/cdefs.h. */
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Include xlocale/_stdlib.h if xlocale.h has already been included. This */
/* comes from FreeBSD's stdlib.h. */
/*----------------------------------------------------------------------------*/
#pragma diag_pop
extern "C++" {
/* MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined */
inline __attribute__ ((__always_inline__)) long abs( long __x) noexcept {return labs(__x);}
inline __attribute__ ((__always_inline__)) long long abs(long long __x) noexcept {return llabs(__x);}
inline __attribute__ ((__always_inline__)) ldiv_t div( long __x, long __y) noexcept {return ldiv(__x, __y);}
inline __attribute__ ((__always_inline__)) lldiv_t div(long long __x, long long __y) noexcept {return lldiv(__x, __y);}
} /* extern "C++" */
namespace std { inline namespace __2 {
using ::size_t;
using ::div_t;
using ::ldiv_t;
using ::lldiv_t;
using ::atof;
using ::atoi;
using ::atol;
using ::atoll;
using ::strtod;
using ::strtof;
using ::strtold;
using ::strtol;
using ::strtoll;
using ::strtoul;
using ::strtoull;
using ::rand;
using ::srand;
using ::calloc;
using ::free;
using ::malloc;
using ::realloc;
using ::abort;
using ::atexit;
using ::exit;
using ::_Exit;
using ::getenv;
using ::system;
using ::bsearch;
using ::qsort;
using ::abs;
using ::labs;
using ::llabs;
using ::div;
using ::ldiv;
using ::lldiv;
using ::mblen;
using ::mbtowc;
using ::wctomb;
using ::mbstowcs;
using ::wcstombs;
} }
// -*- C++ -*-
//===------------------------ type_traits ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
type_traits synopsis
namespace std
{
// helper class:
template <class T, T v> struct integral_constant;
typedef integral_constant<bool, true> true_type; // C++11
typedef integral_constant<bool, false> false_type; // C++11
template <bool B> // C++14
using bool_constant = integral_constant<bool, B>; // C++14
typedef bool_constant<true> true_type; // C++14
typedef bool_constant<false> false_type; // C++14
// helper traits
template <bool, class T = void> struct enable_if;
template <bool, class T, class F> struct conditional;
// Primary classification traits:
template <class T> struct is_void;
template <class T> struct is_null_pointer; // C++14
template <class T> struct is_integral;
template <class T> struct is_floating_point;
template <class T> struct is_array;
template <class T> struct is_pointer;
template <class T> struct is_lvalue_reference;
template <class T> struct is_rvalue_reference;
template <class T> struct is_member_object_pointer;
template <class T> struct is_member_function_pointer;
template <class T> struct is_enum;
template <class T> struct is_union;
template <class T> struct is_class;
template <class T> struct is_function;
// Secondary classification traits:
template <class T> struct is_reference;
template <class T> struct is_arithmetic;
template <class T> struct is_fundamental;
template <class T> struct is_member_pointer;
template <class T> struct is_scalar;
template <class T> struct is_object;
template <class T> struct is_compound;
// Const-volatile properties and transformations:
template <class T> struct is_const;
template <class T> struct is_volatile;
template <class T> struct remove_const;
template <class T> struct remove_volatile;
template <class T> struct remove_cv;
template <class T> struct add_const;
template <class T> struct add_volatile;
template <class T> struct add_cv;
// Reference transformations:
template <class T> struct remove_reference;
template <class T> struct add_lvalue_reference;
template <class T> struct add_rvalue_reference;
// Pointer transformations:
template <class T> struct remove_pointer;
template <class T> struct add_pointer;
// Integral properties:
template <class T> struct is_signed;
template <class T> struct is_unsigned;
template <class T> struct make_signed;
template <class T> struct make_unsigned;
// Array properties and transformations:
template <class T> struct rank;
template <class T, unsigned I = 0> struct extent;
template <class T> struct remove_extent;
template <class T> struct remove_all_extents;
// Member introspection:
template <class T> struct is_pod;
template <class T> struct is_trivial;
template <class T> struct is_trivially_copyable;
template <class T> struct is_standard_layout;
template <class T> struct is_literal_type;
template <class T> struct is_empty;
template <class T> struct is_polymorphic;
template <class T> struct is_abstract;
template <class T> struct is_final; // C++14
template <class T> struct is_aggregate; // C++17
template <class T, class... Args> struct is_constructible;
template <class T> struct is_default_constructible;
template <class T> struct is_copy_constructible;
template <class T> struct is_move_constructible;
template <class T, class U> struct is_assignable;
template <class T> struct is_copy_assignable;
template <class T> struct is_move_assignable;
template <class T, class U> struct is_swappable_with; // C++17
template <class T> struct is_swappable; // C++17
template <class T> struct is_destructible;
template <class T, class... Args> struct is_trivially_constructible;
template <class T> struct is_trivially_default_constructible;
template <class T> struct is_trivially_copy_constructible;
template <class T> struct is_trivially_move_constructible;
template <class T, class U> struct is_trivially_assignable;
template <class T> struct is_trivially_copy_assignable;
template <class T> struct is_trivially_move_assignable;
template <class T> struct is_trivially_destructible;
template <class T, class... Args> struct is_nothrow_constructible;
template <class T> struct is_nothrow_default_constructible;
template <class T> struct is_nothrow_copy_constructible;
template <class T> struct is_nothrow_move_constructible;
template <class T, class U> struct is_nothrow_assignable;
template <class T> struct is_nothrow_copy_assignable;
template <class T> struct is_nothrow_move_assignable;
template <class T, class U> struct is_nothrow_swappable_with; // C++17
template <class T> struct is_nothrow_swappable; // C++17
template <class T> struct is_nothrow_destructible;
template <class T> struct has_virtual_destructor;
// Relationships between types:
template <class T, class U> struct is_same;
template <class Base, class Derived> struct is_base_of;
template <class From, class To> struct is_convertible;
template <class, class R = void> struct is_callable; // not defined
template <class Fn, class... ArgTypes, class R>
struct is_callable<Fn(ArgTypes...), R>;
template <class, class R = void> struct is_nothrow_callable; // not defined
template <class Fn, class... ArgTypes, class R>
struct is_nothrow_callable<Fn(ArgTypes...), R>;
// Alignment properties and transformations:
template <class T> struct alignment_of;
template <size_t Len, size_t Align = most_stringent_alignment_requirement>
struct aligned_storage;
template <size_t Len, class... Types> struct aligned_union;
template <class T> struct decay;
template <class... T> struct common_type;
template <class T> struct underlying_type;
template <class> class result_of; // undefined
template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
// const-volatile modifications:
template <class T>
using remove_const_t = typename remove_const<T>::type; // C++14
template <class T>
using remove_volatile_t = typename remove_volatile<T>::type; // C++14
template <class T>
using remove_cv_t = typename remove_cv<T>::type; // C++14
template <class T>
using add_const_t = typename add_const<T>::type; // C++14
template <class T>
using add_volatile_t = typename add_volatile<T>::type; // C++14
template <class T>
using add_cv_t = typename add_cv<T>::type; // C++14
// reference modifications:
template <class T>
using remove_reference_t = typename remove_reference<T>::type; // C++14
template <class T>
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14
template <class T>
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14
// sign modifications:
template <class T>
using make_signed_t = typename make_signed<T>::type; // C++14
template <class T>
using make_unsigned_t = typename make_unsigned<T>::type; // C++14
// array modifications:
template <class T>
using remove_extent_t = typename remove_extent<T>::type; // C++14
template <class T>
using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14
// pointer modifications:
template <class T>
using remove_pointer_t = typename remove_pointer<T>::type; // C++14
template <class T>
using add_pointer_t = typename add_pointer<T>::type; // C++14
// other transformations:
template <size_t Len, std::size_t Align=default-alignment>
using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
template <std::size_t Len, class... Types>
using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
template <class T>
using decay_t = typename decay<T>::type; // C++14
template <bool b, class T=void>
using enable_if_t = typename enable_if<b,T>::type; // C++14
template <bool b, class T, class F>
using conditional_t = typename conditional<b,T,F>::type; // C++14
template <class... T>
using common_type_t = typename common_type<T...>::type; // C++14
template <class T>
using underlying_type_t = typename underlying_type<T>::type; // C++14
template <class F, class... ArgTypes>
using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
template <class...>
using void_t = void; // C++17
// See C++14 20.10.4.1, primary type categories
template <class T> constexpr bool is_void_v
= is_void<T>::value; // C++17
template <class T> constexpr bool is_null_pointer_v
= is_null_pointer<T>::value; // C++17
template <class T> constexpr bool is_integral_v
= is_integral<T>::value; // C++17
template <class T> constexpr bool is_floating_point_v
= is_floating_point<T>::value; // C++17
template <class T> constexpr bool is_array_v
= is_array<T>::value; // C++17
template <class T> constexpr bool is_pointer_v
= is_pointer<T>::value; // C++17
template <class T> constexpr bool is_lvalue_reference_v
= is_lvalue_reference<T>::value; // C++17
template <class T> constexpr bool is_rvalue_reference_v
= is_rvalue_reference<T>::value; // C++17
template <class T> constexpr bool is_member_object_pointer_v
= is_member_object_pointer<T>::value; // C++17
template <class T> constexpr bool is_member_function_pointer_v
= is_member_function_pointer<T>::value; // C++17
template <class T> constexpr bool is_enum_v
= is_enum<T>::value; // C++17
template <class T> constexpr bool is_union_v
= is_union<T>::value; // C++17
template <class T> constexpr bool is_class_v
= is_class<T>::value; // C++17
template <class T> constexpr bool is_function_v
= is_function<T>::value; // C++17
// See C++14 20.10.4.2, composite type categories
template <class T> constexpr bool is_reference_v
= is_reference<T>::value; // C++17
template <class T> constexpr bool is_arithmetic_v
= is_arithmetic<T>::value; // C++17
template <class T> constexpr bool is_fundamental_v
= is_fundamental<T>::value; // C++17
template <class T> constexpr bool is_object_v
= is_object<T>::value; // C++17
template <class T> constexpr bool is_scalar_v
= is_scalar<T>::value; // C++17
template <class T> constexpr bool is_compound_v
= is_compound<T>::value; // C++17
template <class T> constexpr bool is_member_pointer_v
= is_member_pointer<T>::value; // C++17
// See C++14 20.10.4.3, type properties
template <class T> constexpr bool is_const_v
= is_const<T>::value; // C++17
template <class T> constexpr bool is_volatile_v
= is_volatile<T>::value; // C++17
template <class T> constexpr bool is_trivial_v
= is_trivial<T>::value; // C++17
template <class T> constexpr bool is_trivially_copyable_v
= is_trivially_copyable<T>::value; // C++17
template <class T> constexpr bool is_standard_layout_v
= is_standard_layout<T>::value; // C++17
template <class T> constexpr bool is_pod_v
= is_pod<T>::value; // C++17
template <class T> constexpr bool is_literal_type_v
= is_literal_type<T>::value; // C++17
template <class T> constexpr bool is_empty_v
= is_empty<T>::value; // C++17
template <class T> constexpr bool is_polymorphic_v
= is_polymorphic<T>::value; // C++17
template <class T> constexpr bool is_abstract_v
= is_abstract<T>::value; // C++17
template <class T> constexpr bool is_final_v
= is_final<T>::value; // C++17
template <class T> constexpr bool is_aggregate_v
= is_aggregate<T>::value; // C++17
template <class T> constexpr bool is_signed_v
= is_signed<T>::value; // C++17
template <class T> constexpr bool is_unsigned_v
= is_unsigned<T>::value; // C++17
template <class T, class... Args> constexpr bool is_constructible_v
= is_constructible<T, Args...>::value; // C++17
template <class T> constexpr bool is_default_constructible_v
= is_default_constructible<T>::value; // C++17
template <class T> constexpr bool is_copy_constructible_v
= is_copy_constructible<T>::value; // C++17
template <class T> constexpr bool is_move_constructible_v
= is_move_constructible<T>::value; // C++17
template <class T, class U> constexpr bool is_assignable_v
= is_assignable<T, U>::value; // C++17
template <class T> constexpr bool is_copy_assignable_v
= is_copy_assignable<T>::value; // C++17
template <class T> constexpr bool is_move_assignable_v
= is_move_assignable<T>::value; // C++17
template <class T, class U> constexpr bool is_swappable_with_v
= is_swappable_with<T, U>::value; // C++17
template <class T> constexpr bool is_swappable_v
= is_swappable<T>::value; // C++17
template <class T> constexpr bool is_destructible_v
= is_destructible<T>::value; // C++17
template <class T, class... Args> constexpr bool is_trivially_constructible_v
= is_trivially_constructible<T, Args...>::value; // C++17
template <class T> constexpr bool is_trivially_default_constructible_v
= is_trivially_default_constructible<T>::value; // C++17
template <class T> constexpr bool is_trivially_copy_constructible_v
= is_trivially_copy_constructible<T>::value; // C++17
template <class T> constexpr bool is_trivially_move_constructible_v
= is_trivially_move_constructible<T>::value; // C++17
template <class T, class U> constexpr bool is_trivially_assignable_v
= is_trivially_assignable<T, U>::value; // C++17
template <class T> constexpr bool is_trivially_copy_assignable_v
= is_trivially_copy_assignable<T>::value; // C++17
template <class T> constexpr bool is_trivially_move_assignable_v
= is_trivially_move_assignable<T>::value; // C++17
template <class T> constexpr bool is_trivially_destructible_v
= is_trivially_destructible<T>::value; // C++17
template <class T, class... Args> constexpr bool is_nothrow_constructible_v
= is_nothrow_constructible<T, Args...>::value; // C++17
template <class T> constexpr bool is_nothrow_default_constructible_v
= is_nothrow_default_constructible<T>::value; // C++17
template <class T> constexpr bool is_nothrow_copy_constructible_v
= is_nothrow_copy_constructible<T>::value; // C++17
template <class T> constexpr bool is_nothrow_move_constructible_v
= is_nothrow_move_constructible<T>::value; // C++17
template <class T, class U> constexpr bool is_nothrow_assignable_v
= is_nothrow_assignable<T, U>::value; // C++17
template <class T> constexpr bool is_nothrow_copy_assignable_v
= is_nothrow_copy_assignable<T>::value; // C++17
template <class T> constexpr bool is_nothrow_move_assignable_v
= is_nothrow_move_assignable<T>::value; // C++17
template <class T, class U> constexpr bool is_nothrow_swappable_with_v
= is_nothrow_swappable_with<T, U>::value; // C++17
template <class T> constexpr bool is_nothrow_swappable_v
= is_nothrow_swappable<T>::value; // C++17
template <class T> constexpr bool is_nothrow_destructible_v
= is_nothrow_destructible<T>::value; // C++17
template <class T> constexpr bool has_virtual_destructor_v
= has_virtual_destructor<T>::value; // C++17
// See C++14 20.10.5, type property queries
template <class T> constexpr size_t alignment_of_v
= alignment_of<T>::value; // C++17
template <class T> constexpr size_t rank_v
= rank<T>::value; // C++17
template <class T, unsigned I = 0> constexpr size_t extent_v
= extent<T, I>::value; // C++17
// See C++14 20.10.6, type relations
template <class T, class U> constexpr bool is_same_v
= is_same<T, U>::value; // C++17
template <class Base, class Derived> constexpr bool is_base_of_v
= is_base_of<Base, Derived>::value; // C++17
template <class From, class To> constexpr bool is_convertible_v
= is_convertible<From, To>::value; // C++17
template <class T, class R = void> constexpr bool is_callable_v
= is_callable<T, R>::value; // C++17
template <class T, class R = void> constexpr bool is_nothrow_callable_v
= is_nothrow_callable<T, R>::value; // C++17
// [meta.logical], logical operator traits:
template<class... B> struct conjunction; // C++17
template<class... B>
constexpr bool conjunction_v = conjunction<B...>::value; // C++17
template<class... B> struct disjunction; // C++17
template<class... B>
constexpr bool disjunction_v = disjunction<B...>::value; // C++17
template<class B> struct negation; // C++17
template<class B>
constexpr bool negation_v = negation<B>::value; // C++17
}
*/
namespace std { inline namespace __2 {
template <class _T1, class _T2> struct pair;
template <class _Tp> class reference_wrapper;
template <class _Tp> struct hash;
template <class>
struct __void_t { typedef void type; };
template <class _Tp>
struct __identity { typedef _Tp type; };
template <class _Tp, bool>
struct __dependent_type : public _Tp {};
template <bool _Bp, class _If, class _Then>
struct conditional {typedef _If type;};
template <class _If, class _Then>
struct conditional<false, _If, _Then> {typedef _Then type;};
template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
template <bool, class _Tp> struct __lazy_enable_if {};
template <class _Tp> struct __lazy_enable_if<true, _Tp> {typedef typename _Tp::type type;};
template <bool, class _Tp = void> struct enable_if {};
template <class _Tp> struct enable_if<true, _Tp> {typedef _Tp type;};
template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
// addressof
template <class _Tp>
inline __attribute__ ((__always_inline__))
_Tp*
addressof(_Tp& __x) noexcept
{
return reinterpret_cast<_Tp *>(
const_cast<char *>(&reinterpret_cast<const volatile char &>(__x)));
}
template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete;
struct __two {char __lx[2];};
// helper class:
template <class _Tp, _Tp __v>
struct integral_constant
{
static constexpr const _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant type;
__attribute__ ((__always_inline__))
constexpr operator value_type() const noexcept {return value;}
__attribute__ ((__always_inline__))
constexpr value_type operator ()() const noexcept {return value;}
};
template <class _Tp, _Tp __v>
constexpr const _Tp integral_constant<_Tp, __v>::value;
typedef integral_constant<bool,(true)> true_type;
typedef integral_constant<bool,(false)> false_type;
// __lazy_and
template <bool _Last, class ..._Preds>
struct __lazy_and_impl;
template <class ..._Preds>
struct __lazy_and_impl<false, _Preds...> : false_type {};
template <>
struct __lazy_and_impl<true> : true_type {};
template <class _Pred>
struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
template <class _Hp, class ..._Tp>
struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
template <class _P1, class ..._Pr>
struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
// __lazy_or
template <bool _List, class ..._Preds>
struct __lazy_or_impl;
template <class ..._Preds>
struct __lazy_or_impl<true, _Preds...> : true_type {};
template <>
struct __lazy_or_impl<false> : false_type {};
template <class _Hp, class ..._Tp>
struct __lazy_or_impl<false, _Hp, _Tp...>
: __lazy_or_impl<_Hp::type::value, _Tp...> {};
template <class _P1, class ..._Pr>
struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {};
// __lazy_not
template <class _Pred>
struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
// __and_
template<class...> struct __and_;
template<> struct __and_<> : true_type {};
template<class _B0> struct __and_<_B0> : _B0 {};
template<class _B0, class _B1>
struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {};
template<class _B0, class _B1, class _B2, class... _Bn>
struct __and_<_B0, _B1, _B2, _Bn...>
: conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {};
// __or_
template<class...> struct __or_;
template<> struct __or_<> : false_type {};
template<class _B0> struct __or_<_B0> : _B0 {};
template<class _B0, class _B1>
struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {};
template<class _B0, class _B1, class _B2, class... _Bn>
struct __or_<_B0, _B1, _B2, _Bn...>
: conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {};
// __not_
template<class _Tp>
struct __not_ : conditional<_Tp::value, false_type, true_type>::type {};
// is_const
template <class _Tp> struct is_const : public false_type {};
template <class _Tp> struct is_const<_Tp const> : public true_type {};
// is_volatile
template <class _Tp> struct is_volatile : public false_type {};
template <class _Tp> struct is_volatile<_Tp volatile> : public true_type {};
// remove_const
template <class _Tp> struct remove_const {typedef _Tp type;};
template <class _Tp> struct remove_const<const _Tp> {typedef _Tp type;};
template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
// remove_volatile
template <class _Tp> struct remove_volatile {typedef _Tp type;};
template <class _Tp> struct remove_volatile<volatile _Tp> {typedef _Tp type;};
template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
// remove_cv
template <class _Tp> struct remove_cv
{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
// is_void
template <class _Tp> struct __libcpp_is_void : public false_type {};
template <> struct __libcpp_is_void<void> : public true_type {};
template <class _Tp> struct is_void
: public __libcpp_is_void<typename remove_cv<_Tp>::type> {};
// __is_nullptr_t
template <class _Tp> struct __is_nullptr_t_impl : public false_type {};
template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
template <class _Tp> struct __is_nullptr_t
: public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
template <class _Tp> struct is_null_pointer
: public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
// is_integral
template <class _Tp> struct __libcpp_is_integral : public false_type {};
template <> struct __libcpp_is_integral<bool> : public true_type {};
template <> struct __libcpp_is_integral<char> : public true_type {};
template <> struct __libcpp_is_integral<signed char> : public true_type {};
template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
template <> struct __libcpp_is_integral<char16_t> : public true_type {};
template <> struct __libcpp_is_integral<char32_t> : public true_type {};
template <> struct __libcpp_is_integral<short> : public true_type {};
template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
template <> struct __libcpp_is_integral<int> : public true_type {};
template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
template <> struct __libcpp_is_integral<long> : public true_type {};
template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
template <> struct __libcpp_is_integral<long long> : public true_type {};
template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
template <class _Tp> struct is_integral
: public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
// is_floating_point
template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
template <> struct __libcpp_is_floating_point<float> : public true_type {};
template <> struct __libcpp_is_floating_point<double> : public true_type {};
template <> struct __libcpp_is_floating_point<long double> : public true_type {};
template <class _Tp> struct is_floating_point
: public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
// is_array
template <class _Tp> struct is_array
: public false_type {};
template <class _Tp> struct is_array<_Tp[]>
: public true_type {};
template <class _Tp, size_t _Np> struct is_array<_Tp[_Np]>
: public true_type {};
// is_pointer
template <class _Tp> struct __libcpp_is_pointer : public false_type {};
template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
template <class _Tp> struct is_pointer
: public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
// is_reference
template <class _Tp> struct is_lvalue_reference : public false_type {};
template <class _Tp> struct is_lvalue_reference<_Tp&> : public true_type {};
template <class _Tp> struct is_rvalue_reference : public false_type {};
template <class _Tp> struct is_rvalue_reference<_Tp&&> : public true_type {};
template <class _Tp> struct is_reference : public false_type {};
template <class _Tp> struct is_reference<_Tp&> : public true_type {};
template <class _Tp> struct is_reference<_Tp&&> : public true_type {};
// is_union
template <class _Tp> struct is_union
: public integral_constant<bool, __is_union(_Tp)> {};
// is_class
template <class _Tp> struct is_class
: public integral_constant<bool, __is_class(_Tp)> {};
// is_same
template <class _Tp, class _Up> struct is_same : public false_type {};
template <class _Tp> struct is_same<_Tp, _Tp> : public true_type {};
// is_function
namespace __libcpp_is_function_imp
{
struct __dummy_type {};
template <class _Tp> char __test(_Tp*);
template <class _Tp> char __test(__dummy_type);
template <class _Tp> __two __test(...);
template <class _Tp> _Tp& __source(int);
template <class _Tp> __dummy_type __source(...);
}
template <class _Tp, bool = is_class<_Tp>::value ||
is_union<_Tp>::value ||
is_void<_Tp>::value ||
is_reference<_Tp>::value ||
__is_nullptr_t<_Tp>::value >
struct __libcpp_is_function
: public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
{};
template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
template <class _Tp> struct is_function
: public __libcpp_is_function<_Tp> {};
// is_member_function_pointer
// template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {};
// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
//
template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
struct __member_pointer_traits_imp
{ // forward declaration; specializations later
};
template <class _Tp> struct __libcpp_is_member_function_pointer
: public false_type {};
template <class _Ret, class _Class>
struct __libcpp_is_member_function_pointer<_Ret _Class::*>
: public is_function<_Ret> {};
template <class _Tp> struct is_member_function_pointer
: public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
// is_member_pointer
template <class _Tp> struct __libcpp_is_member_pointer : public false_type {};
template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
template <class _Tp> struct is_member_pointer
: public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
// is_member_object_pointer
template <class _Tp> struct is_member_object_pointer
: public integral_constant<bool, is_member_pointer<_Tp>::value &&
!is_member_function_pointer<_Tp>::value> {};
// is_enum
template <class _Tp> struct is_enum
: public integral_constant<bool, __is_enum(_Tp)> {};
// is_arithmetic
template <class _Tp> struct is_arithmetic
: public integral_constant<bool, is_integral<_Tp>::value ||
is_floating_point<_Tp>::value> {};
// is_fundamental
template <class _Tp> struct is_fundamental
: public integral_constant<bool, is_void<_Tp>::value ||
__is_nullptr_t<_Tp>::value ||
is_arithmetic<_Tp>::value> {};
// is_scalar
template <class _Tp> struct is_scalar
: public integral_constant<bool, is_arithmetic<_Tp>::value ||
is_member_pointer<_Tp>::value ||
is_pointer<_Tp>::value ||
__is_nullptr_t<_Tp>::value ||
is_enum<_Tp>::value > {};
template <> struct is_scalar<nullptr_t> : public true_type {};
// is_object
template <class _Tp> struct is_object
: public integral_constant<bool, is_scalar<_Tp>::value ||
is_array<_Tp>::value ||
is_union<_Tp>::value ||
is_class<_Tp>::value > {};
// is_compound
template <class _Tp> struct is_compound
: public integral_constant<bool, !is_fundamental<_Tp>::value> {};
// __is_referenceable [defns.referenceable]
struct __is_referenceable_impl {
template <class _Tp> static _Tp& __test(int);
template <class _Tp> static __two __test(...);
};
template <class _Tp>
struct __is_referenceable : integral_constant<bool,
!is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
// add_const
template <class _Tp, bool = is_reference<_Tp>::value ||
is_function<_Tp>::value ||
is_const<_Tp>::value >
struct __add_const {typedef _Tp type;};
template <class _Tp>
struct __add_const<_Tp, false> {typedef const _Tp type;};
template <class _Tp> struct add_const
{typedef typename __add_const<_Tp>::type type;};
template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
// add_volatile
template <class _Tp, bool = is_reference<_Tp>::value ||
is_function<_Tp>::value ||
is_volatile<_Tp>::value >
struct __add_volatile {typedef _Tp type;};
template <class _Tp>
struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
template <class _Tp> struct add_volatile
{typedef typename __add_volatile<_Tp>::type type;};
template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
// add_cv
template <class _Tp> struct add_cv
{typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
// remove_reference
template <class _Tp> struct remove_reference {typedef _Tp type;};
template <class _Tp> struct remove_reference<_Tp&> {typedef _Tp type;};
template <class _Tp> struct remove_reference<_Tp&&> {typedef _Tp type;};
template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
// add_lvalue_reference
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _Tp type; };
template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _Tp& type; };
template <class _Tp> struct add_lvalue_reference
{typedef typename __add_lvalue_reference_impl<_Tp>::type type;};
template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _Tp type; };
template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _Tp&& type; };
template <class _Tp> struct add_rvalue_reference
{typedef typename __add_rvalue_reference_impl<_Tp>::type type;};
template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
template <class _Tp> _Tp&& __declval(int);
template <class _Tp> _Tp __declval(long);
template <class _Tp>
decltype(std::__2::__declval<_Tp>(0))
declval() noexcept;
// __uncvref
template <class _Tp>
struct __uncvref {
typedef typename remove_cv<typename remove_reference<_Tp>::type>::type type;
};
template <class _Tp>
struct __unconstref {
typedef typename remove_const<typename remove_reference<_Tp>::type>::type type;
};
template <class _Tp>
using __uncvref_t = typename __uncvref<_Tp>::type;
// __is_same_uncvref
template <class _Tp, class _Up>
struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
typename __uncvref<_Up>::type> {};
struct __any
{
__any(...);
};
// remove_pointer
template <class _Tp> struct remove_pointer {typedef _Tp type;};
template <class _Tp> struct remove_pointer<_Tp*> {typedef _Tp type;};
template <class _Tp> struct remove_pointer<_Tp* const> {typedef _Tp type;};
template <class _Tp> struct remove_pointer<_Tp* volatile> {typedef _Tp type;};
template <class _Tp> struct remove_pointer<_Tp* const volatile> {typedef _Tp type;};
template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
// add_pointer
template <class _Tp,
bool = __is_referenceable<_Tp>::value ||
is_same<typename remove_cv<_Tp>::type, void>::value>
struct __add_pointer_impl
{typedef typename remove_reference<_Tp>::type* type;};
template <class _Tp> struct __add_pointer_impl<_Tp, false>
{typedef _Tp type;};
template <class _Tp> struct add_pointer
{typedef typename __add_pointer_impl<_Tp>::type type;};
template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
// is_signed
template <class _Tp, bool = is_integral<_Tp>::value>
struct __libcpp_is_signed_impl : public integral_constant<bool,(_Tp(-1) < _Tp(0))> {};
template <class _Tp>
struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
template <class _Tp, bool = is_arithmetic<_Tp>::value>
struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {};
template <class _Tp> struct is_signed : public __libcpp_is_signed<_Tp> {};
// is_unsigned
template <class _Tp, bool = is_integral<_Tp>::value>
struct __libcpp_is_unsigned_impl : public integral_constant<bool,(_Tp(0) < _Tp(-1))> {};
template <class _Tp>
struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
template <class _Tp, bool = is_arithmetic<_Tp>::value>
struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
template <class _Tp> struct is_unsigned : public __libcpp_is_unsigned<_Tp> {};
// rank
template <class _Tp> struct rank
: public integral_constant<size_t, 0> {};
template <class _Tp> struct rank<_Tp[]>
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
template <class _Tp, size_t _Np> struct rank<_Tp[_Np]>
: public integral_constant<size_t, rank<_Tp>::value + 1> {};
// extent
template <class _Tp, unsigned _Ip = 0> struct extent
: public integral_constant<size_t, 0> {};
template <class _Tp> struct extent<_Tp[], 0>
: public integral_constant<size_t, 0> {};
template <class _Tp, unsigned _Ip> struct extent<_Tp[], _Ip>
: public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
template <class _Tp, size_t _Np> struct extent<_Tp[_Np], 0>
: public integral_constant<size_t, _Np> {};
template <class _Tp, size_t _Np, unsigned _Ip> struct extent<_Tp[_Np], _Ip>
: public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
// remove_extent
template <class _Tp> struct remove_extent
{typedef _Tp type;};
template <class _Tp> struct remove_extent<_Tp[]>
{typedef _Tp type;};
template <class _Tp, size_t _Np> struct remove_extent<_Tp[_Np]>
{typedef _Tp type;};
template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
// remove_all_extents
template <class _Tp> struct remove_all_extents
{typedef _Tp type;};
template <class _Tp> struct remove_all_extents<_Tp[]>
{typedef typename remove_all_extents<_Tp>::type type;};
template <class _Tp, size_t _Np> struct remove_all_extents<_Tp[_Np]>
{typedef typename remove_all_extents<_Tp>::type type;};
template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
// decay
template <class _Up, bool>
struct __decay {
typedef typename remove_cv<_Up>::type type;
};
template <class _Up>
struct __decay<_Up, true> {
public:
typedef typename conditional
<
is_array<_Up>::value,
typename remove_extent<_Up>::type*,
typename conditional
<
is_function<_Up>::value,
typename add_pointer<_Up>::type,
typename remove_cv<_Up>::type
>::type
>::type type;
};
template <class _Tp>
struct decay
{
private:
typedef typename remove_reference<_Tp>::type _Up;
public:
typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type;
};
template <class _Tp> using decay_t = typename decay<_Tp>::type;
// is_abstract
template <class _Tp> struct is_abstract
: public integral_constant<bool, __is_abstract(_Tp)> {};
// is_final
template <class _Tp> struct
__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
template <class _Tp> struct
is_final : public integral_constant<bool, __is_final(_Tp)> {};
// is_aggregate
// is_base_of
template <class _Bp, class _Dp>
struct is_base_of
: public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
// is_convertible
template <class _T1, class _T2> struct is_convertible
: public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
!is_abstract<_T2>::value> {};
// is_empty
template <class _Tp>
struct is_empty
: public integral_constant<bool, __is_empty(_Tp)> {};
// is_polymorphic
template <class _Tp>
struct is_polymorphic
: public integral_constant<bool, __is_polymorphic(_Tp)> {};
// has_virtual_destructor
template <class _Tp> struct has_virtual_destructor
: public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
// alignment_of
template <class _Tp> struct alignment_of
: public integral_constant<size_t, __alignof__(_Tp)> {};
// aligned_storage
template <class _Hp, class _Tp>
struct __type_list
{
typedef _Hp _Head;
typedef _Tp _Tail;
};
struct __nat
{
__nat() = delete;
__nat(const __nat&) = delete;
__nat& operator=(const __nat&) = delete;
~__nat() = delete;
};
template <class _Tp>
struct __align_type
{
static const size_t value = alignment_of<_Tp>::value;
typedef _Tp type;
};
struct __struct_double {long double __lx;};
struct __struct_double4 {double __lx[4];};
typedef
__type_list<__align_type<unsigned char>,
__type_list<__align_type<unsigned short>,
__type_list<__align_type<unsigned int>,
__type_list<__align_type<unsigned long>,
__type_list<__align_type<unsigned long long>,
__type_list<__align_type<double>,
__type_list<__align_type<long double>,
__type_list<__align_type<__struct_double>,
__type_list<__align_type<__struct_double4>,
__type_list<__align_type<int*>,
__nat
> > > > > > > > > > __all_types;
template <class _TL, size_t _Align> struct __find_pod;
template <class _Hp, size_t _Align>
struct __find_pod<__type_list<_Hp, __nat>, _Align>
{
typedef typename conditional<
_Align == _Hp::value,
typename _Hp::type,
void
>::type type;
};
template <class _Hp, class _Tp, size_t _Align>
struct __find_pod<__type_list<_Hp, _Tp>, _Align>
{
typedef typename conditional<
_Align == _Hp::value,
typename _Hp::type,
typename __find_pod<_Tp, _Align>::type
>::type type;
};
template <class _TL, size_t _Len> struct __find_max_align;
template <class _Hp, size_t _Len>
struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
template <size_t _Len, size_t _A1, size_t _A2>
struct __select_align
{
private:
static const size_t __min = _A2 < _A1 ? _A2 : _A1;
static const size_t __max = _A1 < _A2 ? _A2 : _A1;
public:
static const size_t value = _Len < __max ? __min : __max;
};
template <class _Hp, class _Tp, size_t _Len>
struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
: public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
struct aligned_storage
{
typedef typename __find_pod<__all_types, _Align>::type _Aligner;
static_assert(!is_void<_Aligner>::value, "");
union type
{
_Aligner __align;
unsigned char __data[(_Len + _Align - 1)/_Align * _Align];
};
};
template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
template <size_t _Len>struct aligned_storage<_Len, 0x1>{ struct alignas(0x1) type { unsigned char __lx[(_Len + 0x1 - 1)/0x1 * 0x1]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x2>{ struct alignas(0x2) type { unsigned char __lx[(_Len + 0x2 - 1)/0x2 * 0x2]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x4>{ struct alignas(0x4) type { unsigned char __lx[(_Len + 0x4 - 1)/0x4 * 0x4]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x8>{ struct alignas(0x8) type { unsigned char __lx[(_Len + 0x8 - 1)/0x8 * 0x8]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x10>{ struct alignas(0x10) type { unsigned char __lx[(_Len + 0x10 - 1)/0x10 * 0x10]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x20>{ struct alignas(0x20) type { unsigned char __lx[(_Len + 0x20 - 1)/0x20 * 0x20]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x40>{ struct alignas(0x40) type { unsigned char __lx[(_Len + 0x40 - 1)/0x40 * 0x40]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x80>{ struct alignas(0x80) type { unsigned char __lx[(_Len + 0x80 - 1)/0x80 * 0x80]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x100>{ struct alignas(0x100) type { unsigned char __lx[(_Len + 0x100 - 1)/0x100 * 0x100]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x200>{ struct alignas(0x200) type { unsigned char __lx[(_Len + 0x200 - 1)/0x200 * 0x200]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x400>{ struct alignas(0x400) type { unsigned char __lx[(_Len + 0x400 - 1)/0x400 * 0x400]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x800>{ struct alignas(0x800) type { unsigned char __lx[(_Len + 0x800 - 1)/0x800 * 0x800]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x1000>{ struct alignas(0x1000) type { unsigned char __lx[(_Len + 0x1000 - 1)/0x1000 * 0x1000]; };};
template <size_t _Len>struct aligned_storage<_Len, 0x2000>{ struct alignas(0x2000) type { unsigned char __lx[(_Len + 0x2000 - 1)/0x2000 * 0x2000]; };};
// PE/COFF does not support alignment beyond 8192 (=0x2000)
template <size_t _Len>struct aligned_storage<_Len, 0x4000>{ struct alignas(0x4000) type { unsigned char __lx[(_Len + 0x4000 - 1)/0x4000 * 0x4000]; };};
// aligned_union
template <size_t _I0, size_t ..._In>
struct __static_max;
template <size_t _I0>
struct __static_max<_I0>
{
static const size_t value = _I0;
};
template <size_t _I0, size_t _I1, size_t ..._In>
struct __static_max<_I0, _I1, _In...>
{
static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
__static_max<_I1, _In...>::value;
};
template <size_t _Len, class _Type0, class ..._Types>
struct aligned_union
{
static const size_t alignment_value = __static_max<__alignof__(_Type0),
__alignof__(_Types)...>::value;
static const size_t __len = __static_max<_Len, sizeof(_Type0),
sizeof(_Types)...>::value;
typedef typename aligned_storage<__len, alignment_value>::type type;
};
template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
template <class _Tp>
struct __numeric_type
{
static void __test(...);
static float __test(float);
static double __test(char);
static double __test(int);
static double __test(unsigned);
static double __test(long);
static double __test(unsigned long);
static double __test(long long);
static double __test(unsigned long long);
static double __test(double);
static long double __test(long double);
typedef decltype(__test(declval<_Tp>())) type;
static const bool value = !is_same<type, void>::value;
};
template <>
struct __numeric_type<void>
{
static const bool value = true;
};
// __promote
template <class _A1, class _A2 = void, class _A3 = void,
bool = __numeric_type<_A1>::value &&
__numeric_type<_A2>::value &&
__numeric_type<_A3>::value>
class __promote_imp
{
public:
static const bool value = false;
};
template <class _A1, class _A2, class _A3>
class __promote_imp<_A1, _A2, _A3, true>
{
private:
typedef typename __promote_imp<_A1>::type __type1;
typedef typename __promote_imp<_A2>::type __type2;
typedef typename __promote_imp<_A3>::type __type3;
public:
typedef decltype(__type1() + __type2() + __type3()) type;
static const bool value = true;
};
template <class _A1, class _A2>
class __promote_imp<_A1, _A2, void, true>
{
private:
typedef typename __promote_imp<_A1>::type __type1;
typedef typename __promote_imp<_A2>::type __type2;
public:
typedef decltype(__type1() + __type2()) type;
static const bool value = true;
};
template <class _A1>
class __promote_imp<_A1, void, void, true>
{
public:
typedef typename __numeric_type<_A1>::type type;
static const bool value = true;
};
template <class _A1, class _A2 = void, class _A3 = void>
class __promote : public __promote_imp<_A1, _A2, _A3> {};
// make_signed / make_unsigned
typedef
__type_list<signed char,
__type_list<signed short,
__type_list<signed int,
__type_list<signed long,
__type_list<signed long long,
__nat
> > > > > __signed_types;
typedef
__type_list<unsigned char,
__type_list<unsigned short,
__type_list<unsigned int,
__type_list<unsigned long,
__type_list<unsigned long long,
__nat
> > > > > __unsigned_types;
template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
template <class _Hp, class _Tp, size_t _Size>
struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
{
typedef _Hp type;
};
template <class _Hp, class _Tp, size_t _Size>
struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
{
typedef typename __find_first<_Tp, _Size>::type type;
};
template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
bool = is_volatile<typename remove_reference<_Tp>::type>::value>
struct __apply_cv
{
typedef _Up type;
};
template <class _Tp, class _Up>
struct __apply_cv<_Tp, _Up, true, false>
{
typedef const _Up type;
};
template <class _Tp, class _Up>
struct __apply_cv<_Tp, _Up, false, true>
{
typedef volatile _Up type;
};
template <class _Tp, class _Up>
struct __apply_cv<_Tp, _Up, true, true>
{
typedef const volatile _Up type;
};
template <class _Tp, class _Up>
struct __apply_cv<_Tp&, _Up, false, false>
{
typedef _Up& type;
};
template <class _Tp, class _Up>
struct __apply_cv<_Tp&, _Up, true, false>
{
typedef const _Up& type;
};
template <class _Tp, class _Up>
struct __apply_cv<_Tp&, _Up, false, true>
{
typedef volatile _Up& type;
};
template <class _Tp, class _Up>
struct __apply_cv<_Tp&, _Up, true, true>
{
typedef const volatile _Up& type;
};
template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
struct __make_signed {};
template <class _Tp>
struct __make_signed<_Tp, true>
{
typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
};
template <> struct __make_signed<bool, true> {};
template <> struct __make_signed< signed short, true> {typedef short type;};
template <> struct __make_signed<unsigned short, true> {typedef short type;};
template <> struct __make_signed< signed int, true> {typedef int type;};
template <> struct __make_signed<unsigned int, true> {typedef int type;};
template <> struct __make_signed< signed long, true> {typedef long type;};
template <> struct __make_signed<unsigned long, true> {typedef long type;};
template <> struct __make_signed< signed long long, true> {typedef long long type;};
template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
template <class _Tp>
struct make_signed
{
typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
};
template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
struct __make_unsigned {};
template <class _Tp>
struct __make_unsigned<_Tp, true>
{
typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
};
template <> struct __make_unsigned<bool, true> {};
template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;};
template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;};
template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;};
template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;};
template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;};
template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
template <class _Tp>
struct make_unsigned
{
typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
};
template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
// bullet 1 - sizeof...(Tp) == 0
template <class ..._Tp>
struct common_type {};
// bullet 2 - sizeof...(Tp) == 1
template <class _Tp>
struct common_type<_Tp>
: public common_type<_Tp, _Tp> {};
// bullet 3 - sizeof...(Tp) == 2
template <class _Tp, class _Up, class = void>
struct __common_type2_imp {};
template <class _Tp, class _Up>
struct __common_type2_imp<_Tp, _Up,
typename __void_t<decltype(
true ? std::__2::declval<_Tp>() : std::__2::declval<_Up>()
)>::type>
{
typedef typename decay<decltype(
true ? std::__2::declval<_Tp>() : std::__2::declval<_Up>()
)>::type type;
};
template <class _Tp, class _Up,
class _DTp = typename decay<_Tp>::type,
class _DUp = typename decay<_Up>::type>
using __common_type2 =
typename conditional<
is_same<_Tp, _DTp>::value && is_same<_Up, _DUp>::value,
__common_type2_imp<_Tp, _Up>,
common_type<_DTp, _DUp>
>::type;
template <class _Tp, class _Up>
struct common_type<_Tp, _Up>
: __common_type2<_Tp, _Up> {};
// bullet 4 - sizeof...(Tp) > 2
template <class ...Tp> struct __common_types;
template <class, class = void>
struct __common_type_impl {};
template <class _Tp, class _Up>
struct __common_type_impl<
__common_types<_Tp, _Up>,
typename __void_t<typename common_type<_Tp, _Up>::type>::type>
{
typedef typename common_type<_Tp, _Up>::type type;
};
template <class _Tp, class _Up, class ..._Vp>
struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>,
typename __void_t<typename common_type<_Tp, _Up>::type>::type>
: __common_type_impl<
__common_types<typename common_type<_Tp, _Up>::type, _Vp...> >
{
};
template <class _Tp, class _Up, class ..._Vp>
struct common_type<_Tp, _Up, _Vp...>
: __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {};
template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
// is_assignable
template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
template <class _Tp, class _Arg>
typename __select_2nd<decltype((std::__2::declval<_Tp>() = std::__2::declval<_Arg>())), true_type>::type
__is_assignable_test(int);
template <class, class>
false_type __is_assignable_test(...);
template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
struct __is_assignable_imp
: public decltype((std::__2::__is_assignable_test<_Tp, _Arg>(0))) {};
template <class _Tp, class _Arg>
struct __is_assignable_imp<_Tp, _Arg, true>
: public false_type
{
};
template <class _Tp, class _Arg>
struct is_assignable
: public __is_assignable_imp<_Tp, _Arg> {};
// is_copy_assignable
template <class _Tp> struct is_copy_assignable
: public is_assignable<typename add_lvalue_reference<_Tp>::type,
typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
// is_move_assignable
template <class _Tp> struct is_move_assignable
: public is_assignable<typename add_lvalue_reference<_Tp>::type,
typename add_rvalue_reference<_Tp>::type> {};
// is_destructible
// if it's a reference, return true
// if it's a function, return false
// if it's void, return false
// if it's an array of unknown bound, return false
// Otherwise, return "std::declval<_Up&>().~_Up()" is well-formed
// where _Up is remove_all_extents<_Tp>::type
template <class>
struct __is_destructible_apply { typedef int type; };
template <typename _Tp>
struct __is_destructor_wellformed {
template <typename _Tp1>
static char __test (
typename __is_destructible_apply<decltype(std::__2::declval<_Tp1&>().~_Tp1())>::type
);
template <typename _Tp1>
static __two __test (...);
static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
};
template <class _Tp, bool>
struct __destructible_imp;
template <class _Tp>
struct __destructible_imp<_Tp, false>
: public std::__2::integral_constant<bool,
__is_destructor_wellformed<typename std::__2::remove_all_extents<_Tp>::type>::value> {};
template <class _Tp>
struct __destructible_imp<_Tp, true>
: public std::__2::true_type {};
template <class _Tp, bool>
struct __destructible_false;
template <class _Tp>
struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, std::__2::is_reference<_Tp>::value> {};
template <class _Tp>
struct __destructible_false<_Tp, true> : public std::__2::false_type {};
template <class _Tp>
struct is_destructible
: public __destructible_false<_Tp, std::__2::is_function<_Tp>::value> {};
template <class _Tp>
struct is_destructible<_Tp[]>
: public std::__2::false_type {};
template <>
struct is_destructible<void>
: public std::__2::false_type {};
// move
template <class _Tp>
inline __attribute__ ((__always_inline__)) constexpr
typename remove_reference<_Tp>::type&&
move(_Tp&& __t) noexcept
{
typedef typename remove_reference<_Tp>::type _Up;
return static_cast<_Up&&>(__t);
}
template <class _Tp>
inline __attribute__ ((__always_inline__)) constexpr
_Tp&&
forward(typename remove_reference<_Tp>::type& __t) noexcept
{
return static_cast<_Tp&&>(__t);
}
template <class _Tp>
inline __attribute__ ((__always_inline__)) constexpr
_Tp&&
forward(typename remove_reference<_Tp>::type&& __t) noexcept
{
static_assert(!is_lvalue_reference<_Tp>::value,
"can not forward an rvalue as an lvalue");
return static_cast<_Tp&&>(__t);
}
template <class _Tp>
inline __attribute__ ((__always_inline__))
typename decay<_Tp>::type
__decay_copy(_Tp&& __t)
{
return std::__2::forward<_Tp>(__t);
}
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
{
typedef _Class _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false>
{
typedef _Class _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
{
typedef _Class const _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false>
{
typedef _Class const _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
{
typedef _Class volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false>
{
typedef _Class volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
{
typedef _Class const volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false>
{
typedef _Class const volatile _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
{
typedef _Class& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false>
{
typedef _Class& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
{
typedef _Class const& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false>
{
typedef _Class const& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
{
typedef _Class volatile& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false>
{
typedef _Class volatile& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
{
typedef _Class const volatile& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false>
{
typedef _Class const volatile& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
{
typedef _Class&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false>
{
typedef _Class&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
{
typedef _Class const&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false>
{
typedef _Class const&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
{
typedef _Class volatile&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false>
{
typedef _Class volatile&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
{
typedef _Class const volatile&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param...);
};
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false>
{
typedef _Class const volatile&& _ClassType;
typedef _Rp _ReturnType;
typedef _Rp (_FnType) (_Param..., ...);
};
template <class _Rp, class _Class>
struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
{
typedef _Class _ClassType;
typedef _Rp _ReturnType;
};
template <class _MP>
struct __member_pointer_traits
: public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
is_member_function_pointer<_MP>::value,
is_member_object_pointer<_MP>::value>
{
// typedef ... _ClassType;
// typedef ... _ReturnType;
// typedef ... _FnType;
};
template <class _DecayedFp>
struct __member_pointer_class_type {};
template <class _Ret, class _ClassType>
struct __member_pointer_class_type<_Ret _ClassType::*> {
typedef _ClassType type;
};
// result_of
template <class _Callable> class result_of;
// template <class T, class... Args> struct is_constructible;
namespace __is_construct
{
struct __nat {};
}
template <class _Tp, class... _Args>
struct __libcpp_is_constructible;
template <class _To, class _From>
struct __is_invalid_base_to_derived_cast {
static_assert(is_reference<_To>::value, "Wrong specialization");
using _RawFrom = __uncvref_t<_From>;
using _RawTo = __uncvref_t<_To>;
static const bool value = __lazy_and<
__lazy_not<is_same<_RawFrom, _RawTo>>,
is_base_of<_RawFrom, _RawTo>,
__lazy_not<__libcpp_is_constructible<_RawTo, _From>>
>::value;
};
template <class _To, class _From>
struct __is_invalid_lvalue_to_rvalue_cast : false_type {
static_assert(is_reference<_To>::value, "Wrong specialization");
};
template <class _ToRef, class _FromRef>
struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> {
using _RawFrom = __uncvref_t<_FromRef>;
using _RawTo = __uncvref_t<_ToRef>;
static const bool value = __lazy_and<
__lazy_not<is_function<_RawTo>>,
__lazy_or<
is_same<_RawFrom, _RawTo>,
is_base_of<_RawTo, _RawFrom>>
>::value;
};
struct __is_constructible_helper
{
template <class _To>
static void __eat(_To);
// This overload is needed to work around a Clang bug that disallows
// static_cast<T&&>(e) for non-reference-compatible types.
// Example: static_cast<int&&>(declval<double>());
// NOTE: The static_cast implementation below is required to support
// classes with explicit conversion operators.
template <class _To, class _From,
class = decltype(__eat<_To>(std::__2::declval<_From>()))>
static true_type __test_cast(int);
template <class _To, class _From,
class = decltype(static_cast<_To>(std::__2::declval<_From>()))>
static integral_constant<bool,
!__is_invalid_base_to_derived_cast<_To, _From>::value &&
!__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value
> __test_cast(long);
template <class, class>
static false_type __test_cast(...);
template <class _Tp, class ..._Args,
class = decltype(_Tp(std::__2::declval<_Args>()...))>
static true_type __test_nary(int);
template <class _Tp, class...>
static false_type __test_nary(...);
template <class _Tp, class _A0, class = decltype(::new _Tp(std::__2::declval<_A0>()))>
static is_destructible<_Tp> __test_unary(int);
template <class, class>
static false_type __test_unary(...);
};
template <class _Tp, bool = is_void<_Tp>::value>
struct __is_default_constructible
: decltype(__is_constructible_helper::__test_nary<_Tp>(0))
{};
template <class _Tp>
struct __is_default_constructible<_Tp, true> : false_type {};
template <class _Tp>
struct __is_default_constructible<_Tp[], false> : false_type {};
template <class _Tp, size_t _Nx>
struct __is_default_constructible<_Tp[_Nx], false>
: __is_default_constructible<typename remove_all_extents<_Tp>::type> {};
template <class _Tp, class... _Args>
struct __libcpp_is_constructible
{
static_assert(sizeof...(_Args) > 1, "Wrong specialization");
typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0))
type;
};
template <class _Tp>
struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {};
template <class _Tp, class _A0>
struct __libcpp_is_constructible<_Tp, _A0>
: public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0))
{};
template <class _Tp, class _A0>
struct __libcpp_is_constructible<_Tp&, _A0>
: public decltype(__is_constructible_helper::
__test_cast<_Tp&, _A0>(0))
{};
template <class _Tp, class _A0>
struct __libcpp_is_constructible<_Tp&&, _A0>
: public decltype(__is_constructible_helper::
__test_cast<_Tp&&, _A0>(0))
{};
template <class _Tp, class... _Args>
struct is_constructible
: public __libcpp_is_constructible<_Tp, _Args...>::type {};
// is_default_constructible
template <class _Tp>
struct is_default_constructible
: public is_constructible<_Tp>
{};
// is_copy_constructible
template <class _Tp>
struct is_copy_constructible
: public is_constructible<_Tp,
typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
// is_move_constructible
template <class _Tp>
struct is_move_constructible
: public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
{};
// is_trivially_constructible
template <class _Tp, class... _Args>
struct is_trivially_constructible
: integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
{
};
// is_trivially_default_constructible
template <class _Tp> struct is_trivially_default_constructible
: public is_trivially_constructible<_Tp>
{};
// is_trivially_copy_constructible
template <class _Tp> struct is_trivially_copy_constructible
: public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type>
{};
// is_trivially_move_constructible
template <class _Tp> struct is_trivially_move_constructible
: public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
{};
// is_trivially_assignable
template <class _Tp, class _Arg>
struct is_trivially_assignable
: integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
{
};
// is_trivially_copy_assignable
template <class _Tp> struct is_trivially_copy_assignable
: public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
// is_trivially_move_assignable
template <class _Tp> struct is_trivially_move_assignable
: public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
typename add_rvalue_reference<_Tp>::type>
{};
// is_trivially_destructible
template <class _Tp> struct is_trivially_destructible
: public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {};
// is_nothrow_constructible
template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
template <class _Tp, class... _Args>
struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...>
: public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
{
};
template <class _Tp>
void __implicit_conversion_to(_Tp) noexcept { }
template <class _Tp, class _Arg>
struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg>
: public integral_constant<bool, noexcept(__implicit_conversion_to<_Tp>(declval<_Arg>()))>
{
};
template <class _Tp, bool _IsReference, class... _Args>
struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...>
: public false_type
{
};
template <class _Tp, class... _Args>
struct is_nothrow_constructible
: __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
{
};
template <class _Tp, size_t _Ns>
struct is_nothrow_constructible<_Tp[_Ns]>
: __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp>
{
};
// is_nothrow_default_constructible
template <class _Tp> struct is_nothrow_default_constructible
: public is_nothrow_constructible<_Tp>
{};
// is_nothrow_copy_constructible
template <class _Tp> struct is_nothrow_copy_constructible
: public is_nothrow_constructible<_Tp,
typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
// is_nothrow_move_constructible
template <class _Tp> struct is_nothrow_move_constructible
: public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
{};
// is_nothrow_assignable
template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
template <class _Tp, class _Arg>
struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
: public false_type
{
};
template <class _Tp, class _Arg>
struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
: public integral_constant<bool, noexcept(std::__2::declval<_Tp>() = std::__2::declval<_Arg>()) >
{
};
template <class _Tp, class _Arg>
struct is_nothrow_assignable
: public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
{
};
// is_nothrow_copy_assignable
template <class _Tp> struct is_nothrow_copy_assignable
: public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {};
// is_nothrow_move_assignable
template <class _Tp> struct is_nothrow_move_assignable
: public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
typename add_rvalue_reference<_Tp>::type>
{};
// is_nothrow_destructible
template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
template <class _Tp>
struct __libcpp_is_nothrow_destructible<false, _Tp>
: public false_type
{
};
template <class _Tp>
struct __libcpp_is_nothrow_destructible<true, _Tp>
: public integral_constant<bool, noexcept(std::__2::declval<_Tp>().~_Tp()) >
{
};
template <class _Tp>
struct is_nothrow_destructible
: public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
{
};
template <class _Tp, size_t _Ns>
struct is_nothrow_destructible<_Tp[_Ns]>
: public is_nothrow_destructible<_Tp>
{
};
template <class _Tp>
struct is_nothrow_destructible<_Tp&>
: public true_type
{
};
template <class _Tp>
struct is_nothrow_destructible<_Tp&&>
: public true_type
{
};
// is_pod
template <class _Tp> struct is_pod
: public integral_constant<bool, __is_pod(_Tp)> {};
// is_literal_type;
template <class _Tp> struct is_literal_type
: public integral_constant<bool, __is_literal_type(_Tp)>
{};
// is_standard_layout;
template <class _Tp> struct is_standard_layout
: public integral_constant<bool, __is_standard_layout(_Tp)>
{};
// is_trivially_copyable;
template <class _Tp> struct is_trivially_copyable
: public integral_constant<bool, __is_trivially_copyable(_Tp)>
{};
// is_trivial;
template <class _Tp> struct is_trivial
: public integral_constant<bool, __is_trivial(_Tp)>
{};
template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
template <class _Tp> struct __is_reference_wrapper
: public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
// Check for complete types
template <class ..._Tp> struct __check_complete;
template <>
struct __check_complete<>
{
};
template <class _Hp, class _T0, class ..._Tp>
struct __check_complete<_Hp, _T0, _Tp...>
: private __check_complete<_Hp>,
private __check_complete<_T0, _Tp...>
{
};
template <class _Hp>
struct __check_complete<_Hp, _Hp>
: private __check_complete<_Hp>
{
};
template <class _Tp>
struct __check_complete<_Tp>
{
static_assert(sizeof(_Tp) > 0, "Type must be complete.");
};
template <class _Tp>
struct __check_complete<_Tp&>
: private __check_complete<_Tp>
{
};
template <class _Tp>
struct __check_complete<_Tp&&>
: private __check_complete<_Tp>
{
};
template <class _Rp, class ..._Param>
struct __check_complete<_Rp (*)(_Param...)>
: private __check_complete<_Rp>
{
};
template <class ..._Param>
struct __check_complete<void (*)(_Param...)>
{
};
template <class _Rp, class ..._Param>
struct __check_complete<_Rp (_Param...)>
: private __check_complete<_Rp>
{
};
template <class ..._Param>
struct __check_complete<void (_Param...)>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...)>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) const>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) &>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) const&>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) &&>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class, class ..._Param>
struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
: private __check_complete<_Class>
{
};
template <class _Rp, class _Class>
struct __check_complete<_Rp _Class::*>
: private __check_complete<_Class>
{
};
template <class _Fp, class _A0,
class _DecayFp = typename decay<_Fp>::type,
class _DecayA0 = typename decay<_A0>::type,
class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
using __enable_if_bullet1 = typename enable_if
<
is_member_function_pointer<_DecayFp>::value
&& is_base_of<_ClassT, _DecayA0>::value
>::type;
template <class _Fp, class _A0,
class _DecayFp = typename decay<_Fp>::type,
class _DecayA0 = typename decay<_A0>::type>
using __enable_if_bullet2 = typename enable_if
<
is_member_function_pointer<_DecayFp>::value
&& __is_reference_wrapper<_DecayA0>::value
>::type;
template <class _Fp, class _A0,
class _DecayFp = typename decay<_Fp>::type,
class _DecayA0 = typename decay<_A0>::type,
class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
using __enable_if_bullet3 = typename enable_if
<
is_member_function_pointer<_DecayFp>::value
&& !is_base_of<_ClassT, _DecayA0>::value
&& !__is_reference_wrapper<_DecayA0>::value
>::type;
template <class _Fp, class _A0,
class _DecayFp = typename decay<_Fp>::type,
class _DecayA0 = typename decay<_A0>::type,
class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
using __enable_if_bullet4 = typename enable_if
<
is_member_object_pointer<_DecayFp>::value
&& is_base_of<_ClassT, _DecayA0>::value
>::type;
template <class _Fp, class _A0,
class _DecayFp = typename decay<_Fp>::type,
class _DecayA0 = typename decay<_A0>::type>
using __enable_if_bullet5 = typename enable_if
<
is_member_object_pointer<_DecayFp>::value
&& __is_reference_wrapper<_DecayA0>::value
>::type;
template <class _Fp, class _A0,
class _DecayFp = typename decay<_Fp>::type,
class _DecayA0 = typename decay<_A0>::type,
class _ClassT = typename __member_pointer_class_type<_DecayFp>::type>
using __enable_if_bullet6 = typename enable_if
<
is_member_object_pointer<_DecayFp>::value
&& !is_base_of<_ClassT, _DecayA0>::value
&& !__is_reference_wrapper<_DecayA0>::value
>::type;
// __invoke forward declarations
// fall back - none of the bullets
template <class ..._Args>
auto __invoke(__any, _Args&& ...__args) -> __nat;
template <class ..._Args>
auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat;
// bullets 1, 2 and 3
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet1<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept((std::__2::forward<_A0>(__a0).*__f)(std::__2::forward<_Args>(__args)...))) -> decltype((std::__2::forward<_A0>(__a0).*__f)(std::__2::forward<_Args>(__args)...)) { return (std::__2::forward<_A0>(__a0).*__f)(std::__2::forward<_Args>(__args)...); }
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet1<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
constexpr auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept((std::__2::forward<_A0>(__a0).*__f)(std::__2::forward<_Args>(__args)...))) -> decltype((std::__2::forward<_A0>(__a0).*__f)(std::__2::forward<_Args>(__args)...)) { return (std::__2::forward<_A0>(__a0).*__f)(std::__2::forward<_Args>(__args)...); }
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet2<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept((__a0 . get().*__f)(std::__2::forward<_Args>(__args)...))) -> decltype((__a0 . get().*__f)(std::__2::forward<_Args>(__args)...)) { return (__a0 . get().*__f)(std::__2::forward<_Args>(__args)...); }
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet2<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
constexpr auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept((__a0 . get().*__f)(std::__2::forward<_Args>(__args)...))) -> decltype((__a0 . get().*__f)(std::__2::forward<_Args>(__args)...)) { return (__a0 . get().*__f)(std::__2::forward<_Args>(__args)...); }
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet3<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
auto
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept(((*std::__2::forward<_A0>(__a0)).*__f)(std::__2::forward<_Args>(__args)...))) -> decltype(((*std::__2::forward<_A0>(__a0)).*__f)(std::__2::forward<_Args>(__args)...)) { return ((*std::__2::forward<_A0>(__a0)).*__f)(std::__2::forward<_Args>(__args)...); }
template <class _Fp, class _A0, class ..._Args,
class = __enable_if_bullet3<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
constexpr auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
noexcept(noexcept(((*std::__2::forward<_A0>(__a0)).*__f)(std::__2::forward<_Args>(__args)...))) -> decltype(((*std::__2::forward<_A0>(__a0)).*__f)(std::__2::forward<_Args>(__args)...)) { return ((*std::__2::forward<_A0>(__a0)).*__f)(std::__2::forward<_Args>(__args)...); }
// bullets 4, 5 and 6
template <class _Fp, class _A0,
class = __enable_if_bullet4<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
auto
__invoke(_Fp&& __f, _A0&& __a0)
noexcept(noexcept(std::__2::forward<_A0>(__a0).*__f)) -> decltype(std::__2::forward<_A0>(__a0).*__f) { return std::__2::forward<_A0>(__a0).*__f; }
template <class _Fp, class _A0,
class = __enable_if_bullet4<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
constexpr auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0)
noexcept(noexcept(std::__2::forward<_A0>(__a0).*__f)) -> decltype(std::__2::forward<_A0>(__a0).*__f) { return std::__2::forward<_A0>(__a0).*__f; }
template <class _Fp, class _A0,
class = __enable_if_bullet5<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
auto
__invoke(_Fp&& __f, _A0&& __a0)
noexcept(noexcept(__a0 . get().*__f)) -> decltype(__a0 . get().*__f) { return __a0 . get().*__f; }
template <class _Fp, class _A0,
class = __enable_if_bullet5<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
constexpr auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0)
noexcept(noexcept(__a0 . get().*__f)) -> decltype(__a0 . get().*__f) { return __a0 . get().*__f; }
template <class _Fp, class _A0,
class = __enable_if_bullet6<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
auto
__invoke(_Fp&& __f, _A0&& __a0)
noexcept(noexcept((*std::__2::forward<_A0>(__a0)).*__f)) -> decltype((*std::__2::forward<_A0>(__a0)).*__f) { return (*std::__2::forward<_A0>(__a0)).*__f; }
template <class _Fp, class _A0,
class = __enable_if_bullet6<_Fp, _A0>>
inline __attribute__ ((__always_inline__))
constexpr auto
__invoke_constexpr(_Fp&& __f, _A0&& __a0)
noexcept(noexcept((*std::__2::forward<_A0>(__a0)).*__f)) -> decltype((*std::__2::forward<_A0>(__a0)).*__f) { return (*std::__2::forward<_A0>(__a0)).*__f; }
// bullet 7
template <class _Fp, class ..._Args>
inline __attribute__ ((__always_inline__))
auto
__invoke(_Fp&& __f, _Args&& ...__args)
noexcept(noexcept(std::__2::forward<_Fp>(__f)(std::__2::forward<_Args>(__args)...))) -> decltype(std::__2::forward<_Fp>(__f)(std::__2::forward<_Args>(__args)...)) { return std::__2::forward<_Fp>(__f)(std::__2::forward<_Args>(__args)...); }
template <class _Fp, class ..._Args>
inline __attribute__ ((__always_inline__))
constexpr auto
__invoke_constexpr(_Fp&& __f, _Args&& ...__args)
noexcept(noexcept(std::__2::forward<_Fp>(__f)(std::__2::forward<_Args>(__args)...))) -> decltype(std::__2::forward<_Fp>(__f)(std::__2::forward<_Args>(__args)...)) { return std::__2::forward<_Fp>(__f)(std::__2::forward<_Args>(__args)...); }
// __invokable
template <class _Ret, class _Fp, class ..._Args>
struct __invokable_r
: private __check_complete<_Fp>
{
using _Result = decltype(
std::__2::__invoke(std::__2::declval<_Fp>(), std::__2::declval<_Args>()...));
using type =
typename conditional<
!is_same<_Result, __nat>::value,
typename conditional<
is_void<_Ret>::value,
true_type,
is_convertible<_Result, _Ret>
>::type,
false_type
>::type;
static const bool value = type::value;
};
template <class _Fp, class ..._Args>
using __invokable = __invokable_r<void, _Fp, _Args...>;
template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp {
static const bool value = false;
};
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...>
{
typedef __nothrow_invokable_r_imp _ThisT;
template <class _Tp>
static void __test_noexcept(_Tp) noexcept;
static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>(
std::__2::__invoke(std::__2::declval<_Fp>(), std::__2::declval<_Args>()...)));
};
template <class _Ret, class _Fp, class ..._Args>
struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...>
{
static const bool value = noexcept(
std::__2::__invoke(std::__2::declval<_Fp>(), std::__2::declval<_Args>()...));
};
template <class _Ret, class _Fp, class ..._Args>
using __nothrow_invokable_r =
__nothrow_invokable_r_imp<
__invokable_r<_Ret, _Fp, _Args...>::value,
is_void<_Ret>::value,
_Ret, _Fp, _Args...
>;
template <class _Fp, class ..._Args>
struct __invoke_of
: public enable_if<
__invokable<_Fp, _Args...>::value,
typename __invokable_r<void, _Fp, _Args...>::_Result>
{
};
// result_of
template <class _Fp, class ..._Args>
class result_of<_Fp(_Args...)>
: public __invoke_of<_Fp, _Args...>
{
};
template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
template <class _Tp> struct __is_swappable;
template <class _Tp> struct __is_nothrow_swappable;
template <class _Tp>
inline __attribute__ ((__always_inline__))
typename enable_if
<
is_move_constructible<_Tp>::value &&
is_move_assignable<_Tp>::value
>::type
swap(_Tp& __x, _Tp& __y) noexcept(is_nothrow_move_constructible<_Tp> ::value && is_nothrow_move_assignable<_Tp> ::value)
{
_Tp __t(std::__2::move(__x));
__x = std::__2::move(__y);
__y = std::__2::move(__t);
}
template<class _Tp, size_t _Np>
inline __attribute__ ((__always_inline__))
typename enable_if<
__is_swappable<_Tp>::value
>::type
swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) noexcept(__is_nothrow_swappable<_Tp> ::value);
template <class _ForwardIterator1, class _ForwardIterator2>
inline __attribute__ ((__always_inline__))
void
iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
// _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
noexcept(noexcept(swap(*std::__2::declval<_ForwardIterator1>(), *std::__2::declval<_ForwardIterator2>())))
{
swap(*__a, *__b);
}
// __swappable
namespace __detail
{
// ALL generic swap overloads MUST already have a declaration available at this point.
template <class _Tp, class _Up = _Tp,
bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
struct __swappable_with
{
template <class _LHS, class _RHS>
static decltype(swap(std::__2::declval<_LHS>(), std::__2::declval<_RHS>()))
__test_swap(int);
template <class, class>
static __nat __test_swap(long);
// Extra parens are needed for the C++03 definition of decltype.
typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
static const bool value = !is_same<__swap1, __nat>::value
&& !is_same<__swap2, __nat>::value;
};
template <class _Tp, class _Up>
struct __swappable_with<_Tp, _Up, false> : false_type {};
template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
struct __nothrow_swappable_with {
static const bool value =
noexcept(swap(std::__2::declval<_Tp>(), std::__2::declval<_Up>()))
&& noexcept(swap(std::__2::declval<_Up>(), std::__2::declval<_Tp>()));
};
template <class _Tp, class _Up>
struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
} // __detail
template <class _Tp>
struct __is_swappable
: public integral_constant<bool, __detail::__swappable_with<_Tp&>::value>
{
};
template <class _Tp>
struct __is_nothrow_swappable
: public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value>
{
};
template <class _Tp>
struct underlying_type
{
typedef __underlying_type(_Tp) type;
};
template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
template <class _Tp, bool = is_enum<_Tp>::value>
struct __sfinae_underlying_type
{
typedef typename underlying_type<_Tp>::type type;
typedef decltype(((type)1) + 0) __promoted_type;
};
template <class _Tp>
struct __sfinae_underlying_type<_Tp, false> {};
inline __attribute__ ((__always_inline__))
int __convert_to_integral(int __val) { return __val; }
inline __attribute__ ((__always_inline__))
unsigned __convert_to_integral(unsigned __val) { return __val; }
inline __attribute__ ((__always_inline__))
long __convert_to_integral(long __val) { return __val; }
inline __attribute__ ((__always_inline__))
unsigned long __convert_to_integral(unsigned long __val) { return __val; }
inline __attribute__ ((__always_inline__))
long long __convert_to_integral(long long __val) { return __val; }
inline __attribute__ ((__always_inline__))
unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
template <class _Tp>
inline __attribute__ ((__always_inline__))
typename __sfinae_underlying_type<_Tp>::__promoted_type
__convert_to_integral(_Tp __val) { return __val; }
template <class _Tp>
struct __has_operator_addressof_member_imp
{
template <class _Up>
static auto __test(int)
-> typename __select_2nd<decltype(std::__2::declval<_Up>().operator&()), true_type>::type;
template <class>
static auto __test(long) -> false_type;
static const bool value = decltype(__test<_Tp>(0))::value;
};
template <class _Tp>
struct __has_operator_addressof_free_imp
{
template <class _Up>
static auto __test(int)
-> typename __select_2nd<decltype(operator&(std::__2::declval<_Up>())), true_type>::type;
template <class>
static auto __test(long) -> false_type;
static const bool value = decltype(__test<_Tp>(0))::value;
};
template <class _Tp>
struct __has_operator_addressof
: public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value
|| __has_operator_addressof_free_imp<_Tp>::value>
{};
// These traits are used in __tree and __hash_table
struct __extract_key_fail_tag {};
struct __extract_key_self_tag {};
struct __extract_key_first_tag {};
template <class _ValTy, class _Key,
class _RawValTy = typename __unconstref<_ValTy>::type>
struct __can_extract_key
: conditional<is_same<_RawValTy, _Key>::value, __extract_key_self_tag,
__extract_key_fail_tag>::type {};
template <class _Pair, class _Key, class _First, class _Second>
struct __can_extract_key<_Pair, _Key, pair<_First, _Second>>
: conditional<is_same<typename remove_const<_First>::type, _Key>::value,
__extract_key_first_tag, __extract_key_fail_tag>::type {};
// __can_extract_map_key uses true_type/false_type instead of the tags.
// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
// and _ValTy == _Key.
template <class _ValTy, class _Key, class _ContainerValueTy,
class _RawValTy = typename __unconstref<_ValTy>::type>
struct __can_extract_map_key
: integral_constant<bool, is_same<_RawValTy, _Key>::value> {};
// This specialization returns __extract_key_fail_tag for non-map containers
// because _Key == _ContainerValueTy
template <class _ValTy, class _Key, class _RawValTy>
struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy>
: false_type {};
} }
namespace std // purposefully not using versioning namespace
{
class exception
{
public:
__attribute__ ((__always_inline__)) exception() noexcept {}
virtual ~exception() noexcept;
virtual const char* what() const noexcept;
};
class bad_exception
: public exception
{
public:
__attribute__ ((__always_inline__)) bad_exception() noexcept {}
virtual ~bad_exception() noexcept;
virtual const char* what() const noexcept;
};
typedef void (*unexpected_handler)();
unexpected_handler set_unexpected(unexpected_handler) noexcept;
unexpected_handler get_unexpected() noexcept;
[[noreturn]] void unexpected();
typedef void (*terminate_handler)();
terminate_handler set_terminate(terminate_handler) noexcept;
terminate_handler get_terminate() noexcept;
[[noreturn]] void terminate() noexcept;
bool uncaught_exception() noexcept;
int uncaught_exceptions() noexcept;
class exception_ptr;
exception_ptr current_exception() noexcept;
[[noreturn]] void rethrow_exception(exception_ptr);
class exception_ptr
{
void* __ptr_;
public:
__attribute__ ((__always_inline__)) exception_ptr() noexcept : __ptr_() {}
__attribute__ ((__always_inline__)) exception_ptr(nullptr_t) noexcept : __ptr_() {}
exception_ptr(const exception_ptr&) noexcept;
exception_ptr& operator=(const exception_ptr&) noexcept;
~exception_ptr() noexcept;
__attribute__ ((__always_inline__)) explicit operator bool() const noexcept
{return __ptr_ != nullptr;}
friend __attribute__ ((__always_inline__))
bool operator==(const exception_ptr& __x, const exception_ptr& __y) noexcept
{return __x.__ptr_ == __y.__ptr_;}
friend __attribute__ ((__always_inline__))
bool operator!=(const exception_ptr& __x, const exception_ptr& __y) noexcept
{return !(__x == __y);}
friend exception_ptr current_exception() noexcept;
friend void rethrow_exception(exception_ptr);
};
template<class _Ep>
exception_ptr
make_exception_ptr(_Ep __e) noexcept
{
((void)__e);
std::__2::abort();
}
// nested_exception
class nested_exception
{
exception_ptr __ptr_;
public:
nested_exception() noexcept;
// nested_exception(const nested_exception&) noexcept = default;
// nested_exception& operator=(const nested_exception&) noexcept = default;
virtual ~nested_exception() noexcept;
// access functions
[[noreturn]] void rethrow_nested() const;
__attribute__ ((__always_inline__)) exception_ptr nested_ptr() const noexcept {return __ptr_;}
};
template <class _Tp>
struct __nested
: public _Tp,
public nested_exception
{
__attribute__ ((__always_inline__)) explicit __nested(const _Tp& __t) : _Tp(__t) {}
};
template <class _Tp>
[[noreturn]]
void
throw_with_nested(_Tp&& __t)
{
((void)__t);
// FIXME: Make this abort
}
template <class _From, class _To>
struct __can_dynamic_cast : public integral_constant<bool,(is_polymorphic<_From> ::value && (!is_base_of<_To, _From> ::value || is_convertible<const _From*, const _To* > ::value))> {};
template <class _Ep>
inline __attribute__ ((__always_inline__))
void
rethrow_if_nested(const _Ep& __e,
typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)
{
const nested_exception* __nep = dynamic_cast<const nested_exception*>(std::__2::addressof(__e));
if (__nep)
__nep->rethrow_nested();
}
template <class _Ep>
inline __attribute__ ((__always_inline__))
void
rethrow_if_nested(const _Ep&,
typename enable_if<!__can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0)
{
}
} // std
namespace std // purposefully not using versioning namespace
{
struct nothrow_t {};
extern const nothrow_t nothrow;
class bad_alloc
: public exception
{
public:
bad_alloc() noexcept;
virtual ~bad_alloc() noexcept;
virtual const char* what() const noexcept;
};
class bad_array_new_length
: public bad_alloc
{
public:
bad_array_new_length() noexcept;
virtual ~bad_array_new_length() noexcept;
virtual const char* what() const noexcept;
};
typedef void (*new_handler)();
new_handler set_new_handler(new_handler) noexcept;
new_handler get_new_handler() noexcept;
[[noreturn]] void __throw_bad_alloc(); // not in C++ spec
class
bad_array_length : public bad_alloc {
public:
bad_array_length() noexcept;
virtual ~bad_array_length() noexcept;
virtual const char* what() const noexcept;
};
} // std
void* operator new(std::size_t __sz) ;
void* operator new(std::size_t __sz, const std::nothrow_t&) noexcept ;
void operator delete(void* __p) noexcept;
void operator delete(void* __p, const std::nothrow_t&) noexcept;
void operator delete(void* __p, std::size_t __sz) noexcept;
void* operator new[](std::size_t __sz) ;
void* operator new[](std::size_t __sz, const std::nothrow_t&) noexcept ;
void operator delete[](void* __p) noexcept;
void operator delete[](void* __p, const std::nothrow_t&) noexcept;
void operator delete[](void* __p, std::size_t __sz) noexcept;
inline __attribute__ ((__always_inline__)) void* operator new (std::size_t, void* __p) noexcept {return __p;}
inline __attribute__ ((__always_inline__)) void* operator new[](std::size_t, void* __p) noexcept {return __p;}
inline __attribute__ ((__always_inline__)) void operator delete (void*, void*) noexcept {}
inline __attribute__ ((__always_inline__)) void operator delete[](void*, void*) noexcept {}
namespace std { inline namespace __2 {
inline __attribute__ ((__always_inline__)) void *__allocate(size_t __size) {
return ::operator new(__size);
}
inline __attribute__ ((__always_inline__)) void __libcpp_deallocate(void *__ptr) {
::operator delete(__ptr);
}
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_bad_array_length()
{
std::__2::abort();
}
} }
/*-
* Copyright (c) 1982, 1986, 1989, 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
*
* Copyright (c) 2014-2014 Texas Instruments Incorporated
*
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, 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.
* 4. 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.
*
* @(#)signal.h 8.4 (Berkeley) 5/4/95
* $FreeBSD: release/10.0.0/sys/sys/signal.h 233519 2012-03-26 19:12:09Z rmh $
*/
extern "C" {
int raise(int);
typedef void __sighandler_t(int);
__sighandler_t *signal(int s, __sighandler_t * t);
typedef int sig_atomic_t;
}
// -*- C++ -*-
//===--------------------------- string -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
string synopsis
namespace std
{
template <class stateT>
class fpos
{
private:
stateT st;
public:
fpos(streamoff = streamoff());
operator streamoff() const;
stateT state() const;
void state(stateT);
fpos& operator+=(streamoff);
fpos operator+ (streamoff) const;
fpos& operator-=(streamoff);
fpos operator- (streamoff) const;
};
template <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y);
template <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y);
template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y);
template <class charT>
struct char_traits
{
typedef charT char_type;
typedef ... int_type;
typedef streamoff off_type;
typedef streampos pos_type;
typedef mbstate_t state_type;
static void assign(char_type& c1, const char_type& c2) noexcept;
static constexpr bool eq(char_type c1, char_type c2) noexcept;
static constexpr bool lt(char_type c1, char_type c2) noexcept;
static int compare(const char_type* s1, const char_type* s2, size_t n);
static size_t length(const char_type* s);
static const char_type* find(const char_type* s, size_t n, const char_type& a);
static char_type* move(char_type* s1, const char_type* s2, size_t n);
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
static char_type* assign(char_type* s, size_t n, char_type a);
static constexpr int_type not_eof(int_type c) noexcept;
static constexpr char_type to_char_type(int_type c) noexcept;
static constexpr int_type to_int_type(char_type c) noexcept;
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
static constexpr int_type eof() noexcept;
};
template <> struct char_traits<char>;
template <> struct char_traits<wchar_t>;
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_string
{
public:
// types:
typedef traits traits_type;
typedef typename traits_type::char_type value_type;
typedef Allocator allocator_type;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::difference_type difference_type;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
typedef implementation-defined iterator;
typedef implementation-defined const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
static const size_type npos = -1;
basic_string()
noexcept(is_nothrow_default_constructible<allocator_type>::value);
explicit basic_string(const allocator_type& a);
basic_string(const basic_string& str);
basic_string(basic_string&& str)
noexcept(is_nothrow_move_constructible<allocator_type>::value);
basic_string(const basic_string& str, size_type pos,
const allocator_type& a = allocator_type());
basic_string(const basic_string& str, size_type pos, size_type n,
const Allocator& a = Allocator());
template<class T>
basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17
explicit basic_string(const basic_string_view<charT, traits> sv, const Allocator& a = Allocator());
basic_string(const value_type* s, const allocator_type& a = allocator_type());
basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type());
basic_string(size_type n, value_type c, const allocator_type& a = allocator_type());
template<class InputIterator>
basic_string(InputIterator begin, InputIterator end,
const allocator_type& a = allocator_type());
basic_string(initializer_list<value_type>, const Allocator& = Allocator());
basic_string(const basic_string&, const Allocator&);
basic_string(basic_string&&, const Allocator&);
~basic_string();
operator basic_string_view<charT, traits>() const noexcept;
basic_string& operator=(const basic_string& str);
basic_string& operator=(basic_string_view<charT, traits> sv);
basic_string& operator=(basic_string&& str)
noexcept(
allocator_type::propagate_on_container_move_assignment::value ||
allocator_type::is_always_equal::value ); // C++17
basic_string& operator=(const value_type* s);
basic_string& operator=(value_type c);
basic_string& operator=(initializer_list<value_type>);
iterator begin() noexcept;
const_iterator begin() const noexcept;
iterator end() noexcept;
const_iterator end() const noexcept;
reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;
const_iterator cbegin() const noexcept;
const_iterator cend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
size_type size() const noexcept;
size_type length() const noexcept;
size_type max_size() const noexcept;
size_type capacity() const noexcept;
void resize(size_type n, value_type c);
void resize(size_type n);
void reserve(size_type res_arg = 0);
void shrink_to_fit();
void clear() noexcept;
bool empty() const noexcept;
const_reference operator[](size_type pos) const;
reference operator[](size_type pos);
const_reference at(size_type n) const;
reference at(size_type n);
basic_string& operator+=(const basic_string& str);
basic_string& operator+=(basic_string_view<charT, traits> sv);
basic_string& operator+=(const value_type* s);
basic_string& operator+=(value_type c);
basic_string& operator+=(initializer_list<value_type>);
basic_string& append(const basic_string& str);
basic_string& append(basic_string_view<charT, traits> sv);
basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14
template <class T>
basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17
basic_string& append(const value_type* s, size_type n);
basic_string& append(const value_type* s);
basic_string& append(size_type n, value_type c);
template<class InputIterator>
basic_string& append(InputIterator first, InputIterator last);
basic_string& append(initializer_list<value_type>);
void push_back(value_type c);
void pop_back();
reference front();
const_reference front() const;
reference back();
const_reference back() const;
basic_string& assign(const basic_string& str);
basic_string& assign(basic_string_view<charT, traits> sv);
basic_string& assign(basic_string&& str);
basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14
template <class T>
basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17
basic_string& assign(const value_type* s, size_type n);
basic_string& assign(const value_type* s);
basic_string& assign(size_type n, value_type c);
template<class InputIterator>
basic_string& assign(InputIterator first, InputIterator last);
basic_string& assign(initializer_list<value_type>);
basic_string& insert(size_type pos1, const basic_string& str);
basic_string& insert(size_type pos1, basic_string_view<charT, traits> sv);
basic_string& insert(size_type pos1, const basic_string& str,
size_type pos2, size_type n);
template <class T>
basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17
basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14
basic_string& insert(size_type pos, const value_type* s);
basic_string& insert(size_type pos, size_type n, value_type c);
iterator insert(const_iterator p, value_type c);
iterator insert(const_iterator p, size_type n, value_type c);
template<class InputIterator>
iterator insert(const_iterator p, InputIterator first, InputIterator last);
iterator insert(const_iterator p, initializer_list<value_type>);
basic_string& erase(size_type pos = 0, size_type n = npos);
iterator erase(const_iterator position);
iterator erase(const_iterator first, const_iterator last);
basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
basic_string& replace(size_type pos1, size_type n1, basic_string_view<charT, traits> sv);
basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
size_type pos2, size_type n2=npos); // C++14
template <class T>
basic_string& replace(size_type pos1, size_type n1, const T& t,
size_type pos2, size_type n); // C++17
basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2);
basic_string& replace(size_type pos, size_type n1, const value_type* s);
basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);
basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
basic_string& replace(const_iterator i1, const_iterator i2, basic_string_view<charT, traits> sv);
basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n);
basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s);
basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c);
template<class InputIterator>
basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>);
size_type copy(value_type* s, size_type n, size_type pos = 0) const;
basic_string substr(size_type pos = 0, size_type n = npos) const;
void swap(basic_string& str)
noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
allocator_traits<allocator_type>::is_always_equal::value); // C++17
const value_type* c_str() const noexcept;
const value_type* data() const noexcept;
value_type* data() noexcept; // C++17
allocator_type get_allocator() const noexcept;
size_type find(const basic_string& str, size_type pos = 0) const noexcept;
size_type find(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
size_type find(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find(const value_type* s, size_type pos = 0) const noexcept;
size_type find(value_type c, size_type pos = 0) const noexcept;
size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
size_type rfind(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;
size_type rfind(const value_type* s, size_type pos = npos) const noexcept;
size_type rfind(value_type c, size_type pos = npos) const noexcept;
size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
size_type find_first_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept;
size_type find_first_of(value_type c, size_type pos = 0) const noexcept;
size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;
size_type find_last_of(value_type c, size_type pos = npos) const noexcept;
size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
size_type find_first_not_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept;
size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;
size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
size_type find_last_not_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;
size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;
int compare(const basic_string& str) const noexcept;
int compare(basic_string_view<charT, traits> sv) const noexcept;
int compare(size_type pos1, size_type n1, const basic_string& str) const;
int compare(size_type pos1, size_type n1, basic_string_view<charT, traits> sv) const;
int compare(size_type pos1, size_type n1, const basic_string& str,
size_type pos2, size_type n2=npos) const; // C++14
template <class T>
int compare(size_type pos1, size_type n1, const T& t,
size_type pos2, size_type n2=npos) const; // C++17
int compare(const value_type* s) const noexcept;
int compare(size_type pos1, size_type n1, const value_type* s) const;
int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;
bool __invariants() const;
};
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
operator+(const basic_string<charT, traits, Allocator>& lhs,
const basic_string<charT, traits, Allocator>& rhs);
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs);
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
template<class charT, class traits, class Allocator>
basic_string<charT, traits, Allocator>
operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);
template<class charT, class traits, class Allocator>
bool operator==(const basic_string<charT, traits, Allocator>& lhs,
const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator< (const basic_string<charT, traits, Allocator>& lhs,
const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator> (const basic_string<charT, traits, Allocator>& lhs,
const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
template<class charT, class traits, class Allocator>
bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
template<class charT, class traits, class Allocator>
void swap(basic_string<charT, traits, Allocator>& lhs,
basic_string<charT, traits, Allocator>& rhs)
noexcept(noexcept(lhs.swap(rhs)));
template<class charT, class traits, class Allocator>
basic_istream<charT, traits>&
operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
template<class charT, class traits, class Allocator>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str);
template<class charT, class traits, class Allocator>
basic_istream<charT, traits>&
getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str,
charT delim);
template<class charT, class traits, class Allocator>
basic_istream<charT, traits>&
getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
typedef basic_string<char16_t> u16string;
typedef basic_string<char32_t> u32string;
int stoi (const string& str, size_t* idx = 0, int base = 10);
long stol (const string& str, size_t* idx = 0, int base = 10);
unsigned long stoul (const string& str, size_t* idx = 0, int base = 10);
long long stoll (const string& str, size_t* idx = 0, int base = 10);
unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);
float stof (const string& str, size_t* idx = 0);
double stod (const string& str, size_t* idx = 0);
long double stold(const string& str, size_t* idx = 0);
string to_string(int val);
string to_string(unsigned val);
string to_string(long val);
string to_string(unsigned long val);
string to_string(long long val);
string to_string(unsigned long long val);
string to_string(float val);
string to_string(double val);
string to_string(long double val);
int stoi (const wstring& str, size_t* idx = 0, int base = 10);
long stol (const wstring& str, size_t* idx = 0, int base = 10);
unsigned long stoul (const wstring& str, size_t* idx = 0, int base = 10);
long long stoll (const wstring& str, size_t* idx = 0, int base = 10);
unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);
float stof (const wstring& str, size_t* idx = 0);
double stod (const wstring& str, size_t* idx = 0);
long double stold(const wstring& str, size_t* idx = 0);
wstring to_wstring(int val);
wstring to_wstring(unsigned val);
wstring to_wstring(long val);
wstring to_wstring(unsigned long val);
wstring to_wstring(long long val);
wstring to_wstring(unsigned long long val);
wstring to_wstring(float val);
wstring to_wstring(double val);
wstring to_wstring(long double val);
template <> struct hash<string>;
template <> struct hash<u16string>;
template <> struct hash<u32string>;
template <> struct hash<wstring>;
basic_string<char> operator "" s( const char *str, size_t len ); // C++14
basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14
basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14
basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14
} // std
*/
// -*- C++ -*-
//===------------------------ string_view ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
string_view synopsis
namespace std {
// 7.2, Class template basic_string_view
template<class charT, class traits = char_traits<charT>>
class basic_string_view;
// 7.9, basic_string_view non-member comparison functions
template<class charT, class traits>
constexpr bool operator==(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator!=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator< (basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator> (basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator<=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
template<class charT, class traits>
constexpr bool operator>=(basic_string_view<charT, traits> x,
basic_string_view<charT, traits> y) noexcept;
// see below, sufficient additional overloads of comparison functions
// 7.10, Inserters and extractors
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os,
basic_string_view<charT, traits> str);
// basic_string_view typedef names
typedef basic_string_view<char> string_view;
typedef basic_string_view<char16_t> u16string_view;
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<wchar_t> wstring_view;
template<class charT, class traits = char_traits<charT>>
class basic_string_view {
public:
// types
typedef traits traits_type;
typedef charT value_type;
typedef charT* pointer;
typedef const charT* const_pointer;
typedef charT& reference;
typedef const charT& const_reference;
typedef implementation-defined const_iterator;
typedef const_iterator iterator;
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef const_reverse_iterator reverse_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
static constexpr size_type npos = size_type(-1);
// 7.3, basic_string_view constructors and assignment operators
constexpr basic_string_view() noexcept;
constexpr basic_string_view(const basic_string_view&) noexcept = default;
basic_string_view& operator=(const basic_string_view&) noexcept = default;
template<class Allocator>
constexpr basic_string_view(const charT* str);
constexpr basic_string_view(const charT* str, size_type len);
// 7.4, basic_string_view iterator support
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr const_iterator cbegin() const noexcept;
constexpr const_iterator cend() const noexcept;
const_reverse_iterator rbegin() const noexcept;
const_reverse_iterator rend() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_reverse_iterator crend() const noexcept;
// 7.5, basic_string_view capacity
constexpr size_type size() const noexcept;
constexpr size_type length() const noexcept;
constexpr size_type max_size() const noexcept;
constexpr bool empty() const noexcept;
// 7.6, basic_string_view element access
constexpr const_reference operator[](size_type pos) const;
constexpr const_reference at(size_type pos) const;
constexpr const_reference front() const;
constexpr const_reference back() const;
constexpr const_pointer data() const noexcept;
// 7.7, basic_string_view modifiers
constexpr void remove_prefix(size_type n);
constexpr void remove_suffix(size_type n);
constexpr void swap(basic_string_view& s) noexcept;
size_type copy(charT* s, size_type n, size_type pos = 0) const;
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
constexpr int compare(basic_string_view s) const noexcept;
constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
constexpr int compare(size_type pos1, size_type n1,
basic_string_view s, size_type pos2, size_type n2) const;
constexpr int compare(const charT* s) const;
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
constexpr int compare(size_type pos1, size_type n1,
const charT* s, size_type n2) const;
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
constexpr size_type find(const charT* s, size_type pos = 0) const;
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
constexpr size_type rfind(const charT* s, size_type pos = npos) const;
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
private:
const_pointer data_; // exposition only
size_type size_; // exposition only
};
// 7.11, Hash support
template <class T> struct hash;
template <> struct hash<string_view>;
template <> struct hash<u16string_view>;
template <> struct hash<u32string_view>;
template <> struct hash<wstring_view>;
constexpr basic_string_view<char> operator "" sv( const char *str, size_t len ) noexcept;
constexpr basic_string_view<wchar_t> operator "" sv( const wchar_t *str, size_t len ) noexcept;
constexpr basic_string_view<char16_t> operator "" sv( const char16_t *str, size_t len ) noexcept;
constexpr basic_string_view<char32_t> operator "" sv( const char32_t *str, size_t len ) noexcept;
} // namespace std
*/
// -*- C++ -*-
//===-------------------------- __string ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
string synopsis
namespace std
{
template <class charT>
struct char_traits
{
typedef charT char_type;
typedef ... int_type;
typedef streamoff off_type;
typedef streampos pos_type;
typedef mbstate_t state_type;
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
static constexpr bool eq(char_type c1, char_type c2) noexcept;
static constexpr bool lt(char_type c1, char_type c2) noexcept;
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
static constexpr size_t length(const char_type* s);
static constexpr const char_type*
find(const char_type* s, size_t n, const char_type& a);
static char_type* move(char_type* s1, const char_type* s2, size_t n);
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
static char_type* assign(char_type* s, size_t n, char_type a);
static constexpr int_type not_eof(int_type c) noexcept;
static constexpr char_type to_char_type(int_type c) noexcept;
static constexpr int_type to_int_type(char_type c) noexcept;
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
static constexpr int_type eof() noexcept;
};
template <> struct char_traits<char>;
template <> struct char_traits<wchar_t>;
} // std
*/
// -*- C++ -*-
//===-------------------------- algorithm ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
algorithm synopsis
#include <initializer_list>
namespace std
{
template <class InputIterator, class Predicate>
bool
all_of(InputIterator first, InputIterator last, Predicate pred);
template <class InputIterator, class Predicate>
bool
any_of(InputIterator first, InputIterator last, Predicate pred);
template <class InputIterator, class Predicate>
bool
none_of(InputIterator first, InputIterator last, Predicate pred);
template <class InputIterator, class Function>
Function
for_each(InputIterator first, InputIterator last, Function f);
template<class InputIterator, class Size, class Function>
InputIterator for_each_n(InputIterator first, Size n, Function f); // C++17
template <class InputIterator, class T>
InputIterator
find(InputIterator first, InputIterator last, const T& value);
template <class InputIterator, class Predicate>
InputIterator
find_if(InputIterator first, InputIterator last, Predicate pred);
template<class InputIterator, class Predicate>
InputIterator
find_if_not(InputIterator first, InputIterator last, Predicate pred);
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1
find_end(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
ForwardIterator1
find_end(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1
find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
ForwardIterator1
find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
template <class ForwardIterator>
ForwardIterator
adjacent_find(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class BinaryPredicate>
ForwardIterator
adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
template <class InputIterator, class T>
typename iterator_traits<InputIterator>::difference_type
count(InputIterator first, InputIterator last, const T& value);
template <class InputIterator, class Predicate>
typename iterator_traits<InputIterator>::difference_type
count_if(InputIterator first, InputIterator last, Predicate pred);
template <class InputIterator1, class InputIterator2>
pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
template <class InputIterator1, class InputIterator2>
pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2); // **C++14**
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, BinaryPredicate pred);
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
pair<InputIterator1, InputIterator2>
mismatch(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
BinaryPredicate pred); // **C++14**
template <class InputIterator1, class InputIterator2>
bool
equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
template <class InputIterator1, class InputIterator2>
bool
equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2); // **C++14**
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
bool
equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, BinaryPredicate pred);
template <class InputIterator1, class InputIterator2, class BinaryPredicate>
bool
equal(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
BinaryPredicate pred); // **C++14**
template<class ForwardIterator1, class ForwardIterator2>
bool
is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2);
template<class ForwardIterator1, class ForwardIterator2>
bool
is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
bool
is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, BinaryPredicate pred);
template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
bool
is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
BinaryPredicate pred); // **C++14**
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator1
search(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
ForwardIterator1
search(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
template <class ForwardIterator, class Size, class T>
ForwardIterator
search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
template <class ForwardIterator, class Size, class T, class BinaryPredicate>
ForwardIterator
search_n(ForwardIterator first, ForwardIterator last,
Size count, const T& value, BinaryPredicate pred);
template <class InputIterator, class OutputIterator>
OutputIterator
copy(InputIterator first, InputIterator last, OutputIterator result);
template<class InputIterator, class OutputIterator, class Predicate>
OutputIterator
copy_if(InputIterator first, InputIterator last,
OutputIterator result, Predicate pred);
template<class InputIterator, class Size, class OutputIterator>
OutputIterator
copy_n(InputIterator first, Size n, OutputIterator result);
template <class BidirectionalIterator1, class BidirectionalIterator2>
BidirectionalIterator2
copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
BidirectionalIterator2 result);
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator2
swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
template <class ForwardIterator1, class ForwardIterator2>
void
iter_swap(ForwardIterator1 a, ForwardIterator2 b);
template <class InputIterator, class OutputIterator, class UnaryOperation>
OutputIterator
transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
OutputIterator
transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
OutputIterator result, BinaryOperation binary_op);
template <class ForwardIterator, class T>
void
replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
template <class ForwardIterator, class Predicate, class T>
void
replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
template <class InputIterator, class OutputIterator, class T>
OutputIterator
replace_copy(InputIterator first, InputIterator last, OutputIterator result,
const T& old_value, const T& new_value);
template <class InputIterator, class OutputIterator, class Predicate, class T>
OutputIterator
replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
template <class ForwardIterator, class T>
void
fill(ForwardIterator first, ForwardIterator last, const T& value);
template <class OutputIterator, class Size, class T>
OutputIterator
fill_n(OutputIterator first, Size n, const T& value);
template <class ForwardIterator, class Generator>
void
generate(ForwardIterator first, ForwardIterator last, Generator gen);
template <class OutputIterator, class Size, class Generator>
OutputIterator
generate_n(OutputIterator first, Size n, Generator gen);
template <class ForwardIterator, class T>
ForwardIterator
remove(ForwardIterator first, ForwardIterator last, const T& value);
template <class ForwardIterator, class Predicate>
ForwardIterator
remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
template <class InputIterator, class OutputIterator, class T>
OutputIterator
remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
template <class InputIterator, class OutputIterator, class Predicate>
OutputIterator
remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
template <class ForwardIterator>
ForwardIterator
unique(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class BinaryPredicate>
ForwardIterator
unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
template <class InputIterator, class OutputIterator>
OutputIterator
unique_copy(InputIterator first, InputIterator last, OutputIterator result);
template <class InputIterator, class OutputIterator, class BinaryPredicate>
OutputIterator
unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
template <class BidirectionalIterator>
void
reverse(BidirectionalIterator first, BidirectionalIterator last);
template <class BidirectionalIterator, class OutputIterator>
OutputIterator
reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
template <class ForwardIterator>
ForwardIterator
rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
template <class ForwardIterator, class OutputIterator>
OutputIterator
rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
template <class RandomAccessIterator>
void
random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14, removed in C++17
template <class RandomAccessIterator, class RandomNumberGenerator>
void
random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
RandomNumberGenerator& rand); // deprecated in C++14, removed in C++17
template<class PopulationIterator, class SampleIterator,
class Distance, class UniformRandomBitGenerator>
SampleIterator sample(PopulationIterator first, PopulationIterator last,
SampleIterator out, Distance n,
UniformRandomBitGenerator&& g); // C++17
template<class RandomAccessIterator, class UniformRandomNumberGenerator>
void shuffle(RandomAccessIterator first, RandomAccessIterator last,
UniformRandomNumberGenerator&& g);
template <class InputIterator, class Predicate>
bool
is_partitioned(InputIterator first, InputIterator last, Predicate pred);
template <class ForwardIterator, class Predicate>
ForwardIterator
partition(ForwardIterator first, ForwardIterator last, Predicate pred);
template <class InputIterator, class OutputIterator1,
class OutputIterator2, class Predicate>
pair<OutputIterator1, OutputIterator2>
partition_copy(InputIterator first, InputIterator last,
OutputIterator1 out_true, OutputIterator2 out_false,
Predicate pred);
template <class ForwardIterator, class Predicate>
ForwardIterator
stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
template<class ForwardIterator, class Predicate>
ForwardIterator
partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
template <class ForwardIterator>
bool
is_sorted(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Compare>
bool
is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
template<class ForwardIterator>
ForwardIterator
is_sorted_until(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Compare>
ForwardIterator
is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
template <class RandomAccessIterator>
void
sort(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
void
sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
void
stable_sort(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
void
stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
void
partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
void
partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
template <class InputIterator, class RandomAccessIterator>
RandomAccessIterator
partial_sort_copy(InputIterator first, InputIterator last,
RandomAccessIterator result_first, RandomAccessIterator result_last);
template <class InputIterator, class RandomAccessIterator, class Compare>
RandomAccessIterator
partial_sort_copy(InputIterator first, InputIterator last,
RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
template <class RandomAccessIterator>
void
nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
void
nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
template <class ForwardIterator, class T>
ForwardIterator
lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
template <class ForwardIterator, class T, class Compare>
ForwardIterator
lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
template <class ForwardIterator, class T>
ForwardIterator
upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
template <class ForwardIterator, class T, class Compare>
ForwardIterator
upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
template <class ForwardIterator, class T>
pair<ForwardIterator, ForwardIterator>
equal_range(ForwardIterator first, ForwardIterator last, const T& value);
template <class ForwardIterator, class T, class Compare>
pair<ForwardIterator, ForwardIterator>
equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
template <class ForwardIterator, class T>
bool
binary_search(ForwardIterator first, ForwardIterator last, const T& value);
template <class ForwardIterator, class T, class Compare>
bool
binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
OutputIterator
merge(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
OutputIterator
merge(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class BidirectionalIterator>
void
inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
template <class BidirectionalIterator, class Compare>
void
inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
template <class InputIterator1, class InputIterator2>
bool
includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
template <class InputIterator1, class InputIterator2, class Compare>
bool
includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
OutputIterator
set_union(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
OutputIterator
set_union(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
OutputIterator
set_intersection(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
OutputIterator
set_intersection(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
OutputIterator
set_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
OutputIterator
set_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
OutputIterator
set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
OutputIterator
set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class RandomAccessIterator>
void
push_heap(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
void
push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
void
pop_heap(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
void
pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
void
make_heap(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
void
make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
void
sort_heap(RandomAccessIterator first, RandomAccessIterator last);
template <class RandomAccessIterator, class Compare>
void
sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
template <class RandomAccessIterator>
bool
is_heap(RandomAccessIterator first, RandomAccessiterator last);
template <class RandomAccessIterator, class Compare>
bool
is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
template <class RandomAccessIterator>
RandomAccessIterator
is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
template <class RandomAccessIterator, class Compare>
RandomAccessIterator
is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
template <class ForwardIterator>
ForwardIterator
min_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
template <class ForwardIterator, class Compare>
ForwardIterator
min_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
template <class T>
const T&
min(const T& a, const T& b); // constexpr in C++14
template <class T, class Compare>
const T&
min(const T& a, const T& b, Compare comp); // constexpr in C++14
template<class T>
T
min(initializer_list<T> t); // constexpr in C++14
template<class T, class Compare>
T
min(initializer_list<T> t, Compare comp); // constexpr in C++14
template<class T>
constexpr const T& clamp( const T& v, const T& lo, const T& hi ); // C++17
template<class T, class Compare>
constexpr const T& clamp( const T& v, const T& lo, const T& hi, Compare comp ); // C++17
template <class ForwardIterator>
ForwardIterator
max_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
template <class ForwardIterator, class Compare>
ForwardIterator
max_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
template <class T>
const T&
max(const T& a, const T& b); // constexpr in C++14
template <class T, class Compare>
const T&
max(const T& a, const T& b, Compare comp); // constexpr in C++14
template<class T>
T
max(initializer_list<T> t); // constexpr in C++14
template<class T, class Compare>
T
max(initializer_list<T> t, Compare comp); // constexpr in C++14
template<class ForwardIterator>
pair<ForwardIterator, ForwardIterator>
minmax_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
template<class ForwardIterator, class Compare>
pair<ForwardIterator, ForwardIterator>
minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
template<class T>
pair<const T&, const T&>
minmax(const T& a, const T& b); // constexpr in C++14
template<class T, class Compare>
pair<const T&, const T&>
minmax(const T& a, const T& b, Compare comp); // constexpr in C++14
template<class T>
pair<T, T>
minmax(initializer_list<T> t); // constexpr in C++14
template<class T, class Compare>
pair<T, T>
minmax(initializer_list<T> t, Compare comp); // constexpr in C++14
template <class InputIterator1, class InputIterator2>
bool
lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
template <class InputIterator1, class InputIterator2, class Compare>
bool
lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, Compare comp);
template <class BidirectionalIterator>
bool
next_permutation(BidirectionalIterator first, BidirectionalIterator last);
template <class BidirectionalIterator, class Compare>
bool
next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
template <class BidirectionalIterator>
bool
prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
template <class BidirectionalIterator, class Compare>
bool
prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
} // std
*/
// -*- C++ -*-
//===----------------------- initializer_list -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
initializer_list synopsis
namespace std
{
template<class E>
class initializer_list
{
public:
typedef E value_type;
typedef const E& reference;
typedef const E& const_reference;
typedef size_t size_type;
typedef const E* iterator;
typedef const E* const_iterator;
initializer_list() noexcept; // constexpr in C++14
size_t size() const noexcept; // constexpr in C++14
const E* begin() const noexcept; // constexpr in C++14
const E* end() const noexcept; // constexpr in C++14
};
template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14
template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14
} // std
*/
namespace std // purposefully not versioned
{
template<class _Ep>
class initializer_list
{
const _Ep* __begin_;
size_t __size_;
__attribute__ ((__always_inline__))
constexpr
initializer_list(const _Ep* __b, size_t __s) noexcept
: __begin_(__b),
__size_(__s)
{}
public:
typedef _Ep value_type;
typedef const _Ep& reference;
typedef const _Ep& const_reference;
typedef size_t size_type;
typedef const _Ep* iterator;
typedef const _Ep* const_iterator;
__attribute__ ((__always_inline__))
constexpr
initializer_list() noexcept : __begin_(nullptr), __size_(0) {}
__attribute__ ((__always_inline__))
constexpr
size_t size() const noexcept {return __size_;}
__attribute__ ((__always_inline__))
constexpr
const _Ep* begin() const noexcept {return __begin_;}
__attribute__ ((__always_inline__))
constexpr
const _Ep* end() const noexcept {return __begin_ + __size_;}
};
template<class _Ep>
inline __attribute__ ((__always_inline__))
constexpr
const _Ep*
begin(initializer_list<_Ep> __il) noexcept
{
return __il.begin();
}
template<class _Ep>
inline __attribute__ ((__always_inline__))
constexpr
const _Ep*
end(initializer_list<_Ep> __il) noexcept
{
return __il.end();
}
} // std
// -*- C++ -*-
//===-------------------------- utility -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
utility synopsis
namespace std
{
template <class T>
void
swap(T& a, T& b);
namespace rel_ops
{
template<class T> bool operator!=(const T&, const T&);
template<class T> bool operator> (const T&, const T&);
template<class T> bool operator<=(const T&, const T&);
template<class T> bool operator>=(const T&, const T&);
}
template<class T>
void
swap(T& a, T& b) noexcept(is_nothrow_move_constructible<T>::value &&
is_nothrow_move_assignable<T>::value);
template <class T, size_t N>
void
swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14
template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14
template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14
template <class T>
typename conditional
<
!is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
const T&,
T&&
>::type
move_if_noexcept(T& x) noexcept; // constexpr in C++14
template <class T> constexpr add_const<T>_t& as_const(T& t) noexcept; // C++17
template <class T> void as_const(const T&&) = delete; // C++17
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
template <class T1, class T2>
struct pair
{
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair(const pair&) = default;
pair(pair&&) = default;
constexpr pair();
pair(const T1& x, const T2& y); // constexpr in C++14
template <class U, class V> pair(U&& x, V&& y); // constexpr in C++14
template <class U, class V> pair(const pair<U, V>& p); // constexpr in C++14
template <class U, class V> pair(pair<U, V>&& p); // constexpr in C++14
template <class... Args1, class... Args2>
pair(piecewise_construct_t, tuple<Args1...> first_args,
tuple<Args2...> second_args);
template <class U, class V> pair& operator=(const pair<U, V>& p);
pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
is_nothrow_move_assignable<T2>::value);
template <class U, class V> pair& operator=(pair<U, V>&& p);
void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> &&
is_nothrow_swappable_v<T2>);
};
template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); // constexpr in C++14
template <class T1, class T2>
void
swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
struct piecewise_construct_t { };
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
template <class T> class tuple_size;
template <size_t I, class T> class tuple_element;
template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
template <class T1, class T2> struct tuple_element<1, pair<T1, T2> >;
template<size_t I, class T1, class T2>
typename tuple_element<I, pair<T1, T2> >::type&
get(pair<T1, T2>&) noexcept; // constexpr in C++14
template<size_t I, class T1, class T2>
const typename tuple_element<I, pair<T1, T2> >::type&
get(const pair<T1, T2>&) noexcept; // constexpr in C++14
template<size_t I, class T1, class T2>
typename tuple_element<I, pair<T1, T2> >::type&&
get(pair<T1, T2>&&) noexcept; // constexpr in C++14
template<size_t I, class T1, class T2>
const typename tuple_element<I, pair<T1, T2> >::type&&
get(const pair<T1, T2>&&) noexcept; // constexpr in C++14
template<class T1, class T2>
constexpr T1& get(pair<T1, T2>&) noexcept; // C++14
template<class T1, class T2>
constexpr const T1& get(const pair<T1, T2>&) noexcept; // C++14
template<class T1, class T2>
constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14
template<class T1, class T2>
constexpr const T1&& get(const pair<T1, T2>&&) noexcept; // C++14
template<class T1, class T2>
constexpr T1& get(pair<T2, T1>&) noexcept; // C++14
template<class T1, class T2>
constexpr const T1& get(const pair<T2, T1>&) noexcept; // C++14
template<class T1, class T2>
constexpr T1&& get(pair<T2, T1>&&) noexcept; // C++14
template<class T1, class T2>
constexpr const T1&& get(const pair<T2, T1>&&) noexcept; // C++14
// C++14
template<class T, T... I>
struct integer_sequence
{
typedef T value_type;
static constexpr size_t size() noexcept;
};
template<size_t... I>
using index_sequence = integer_sequence<size_t, I...>;
template<class T, T N>
using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
template<size_t N>
using make_index_sequence = make_integer_sequence<size_t, N>;
template<class... T>
using index_sequence_for = make_index_sequence<sizeof...(T)>;
template<class T, class U=T>
T exchange(T& obj, U&& new_value);
// 20.2.7, in-place construction // C++17
struct in_place_t {
explicit in_place_t() = default;
};
inline constexpr in_place_t in_place{};
template <class T>
struct in_place_type_t {
explicit in_place_type_t() = default;
};
template <class T>
inline constexpr in_place_type_t<T> in_place_type{};
template <size_t I>
struct in_place_index_t {
explicit in_place_index_t() = default;
};
template <size_t I>
inline constexpr in_place_index_t<I> in_place_index{};
} // std
*/
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
namespace std { inline namespace __2 {
template <class _Tp> class tuple_size;
template <class _Tp, class...>
using __enable_if_tuple_size_imp = _Tp;
template <class _Tp>
class tuple_size<__enable_if_tuple_size_imp<
const _Tp,
typename enable_if<!is_volatile<_Tp>::value>::type,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <class _Tp>
class tuple_size<__enable_if_tuple_size_imp<
volatile _Tp,
typename enable_if<!is_const<_Tp>::value>::type,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <class _Tp>
class tuple_size<__enable_if_tuple_size_imp<
const volatile _Tp,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <size_t _Ip, class _Tp> class tuple_element;
template <size_t _Ip, class _Tp>
class tuple_element<_Ip, const _Tp>
{
public:
typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <size_t _Ip, class _Tp>
class tuple_element<_Ip, volatile _Tp>
{
public:
typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <size_t _Ip, class _Tp>
class tuple_element<_Ip, const volatile _Tp>
{
public:
typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <class _Tp> struct __tuple_like : false_type {};
template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
// tuple specializations
template <size_t...> struct __tuple_indices {};
template <class _IdxType, _IdxType... _Values>
struct __integer_sequence {
template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
template <size_t _Sp>
using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
};
namespace __detail {
template<typename _Tp, size_t ..._Extra> struct __repeat;
template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
typedef __integer_sequence<_Tp,
_Np...,
sizeof...(_Np) + _Np...,
2 * sizeof...(_Np) + _Np...,
3 * sizeof...(_Np) + _Np...,
4 * sizeof...(_Np) + _Np...,
5 * sizeof...(_Np) + _Np...,
6 * sizeof...(_Np) + _Np...,
7 * sizeof...(_Np) + _Np...,
_Extra...> type;
};
template<size_t _Np> struct __parity;
template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
} // namespace detail
template <size_t _Ep, size_t _Sp>
using __make_indices_imp =
typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
template <size_t _Ep, size_t _Sp = 0>
struct __make_tuple_indices
{
static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
typedef __make_indices_imp<_Ep, _Sp> type;
};
template <class ..._Tp> class tuple;
template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
template <class ..._Tp>
class tuple_size<tuple<_Tp...> >
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
template <size_t _Ip, class ..._Tp>
__attribute__ ((__always_inline__)) constexpr
typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(tuple<_Tp...>&) noexcept;
template <size_t _Ip, class ..._Tp>
__attribute__ ((__always_inline__)) constexpr
const typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(const tuple<_Tp...>&) noexcept;
template <size_t _Ip, class ..._Tp>
__attribute__ ((__always_inline__)) constexpr
typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(tuple<_Tp...>&&) noexcept;
template <size_t _Ip, class ..._Tp>
__attribute__ ((__always_inline__)) constexpr
const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(const tuple<_Tp...>&&) noexcept;
// pair specializations
template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
template <size_t _Ip, class _T1, class _T2>
__attribute__ ((__always_inline__)) constexpr
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(pair<_T1, _T2>&) noexcept;
template <size_t _Ip, class _T1, class _T2>
__attribute__ ((__always_inline__)) constexpr
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>&) noexcept;
template <size_t _Ip, class _T1, class _T2>
__attribute__ ((__always_inline__)) constexpr
typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(pair<_T1, _T2>&&) noexcept;
template <size_t _Ip, class _T1, class _T2>
__attribute__ ((__always_inline__)) constexpr
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(const pair<_T1, _T2>&&) noexcept;
// array specializations
template <class _Tp, size_t _Size> struct array;
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
template <size_t _Ip, class _Tp, size_t _Size>
__attribute__ ((__always_inline__)) constexpr
_Tp&
get(array<_Tp, _Size>&) noexcept;
template <size_t _Ip, class _Tp, size_t _Size>
__attribute__ ((__always_inline__)) constexpr
const _Tp&
get(const array<_Tp, _Size>&) noexcept;
template <size_t _Ip, class _Tp, size_t _Size>
__attribute__ ((__always_inline__)) constexpr
_Tp&&
get(array<_Tp, _Size>&&) noexcept;
template <size_t _Ip, class _Tp, size_t _Size>
__attribute__ ((__always_inline__)) constexpr
const _Tp&&
get(const array<_Tp, _Size>&&) noexcept;
// __tuple_types
template <class ..._Tp> struct __tuple_types {};
namespace __indexer_detail {
template <size_t _Idx, class _Tp>
struct __indexed { using type = _Tp; };
template <class _Types, class _Indexes> struct __indexer;
template <class ..._Types, size_t ..._Idx>
struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
: __indexed<_Idx, _Types>...
{};
template <size_t _Idx, class _Tp>
__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
} // namespace __indexer_detail
template <size_t _Idx, class ..._Types>
using __type_pack_element = typename decltype(
__indexer_detail::__at_index<_Idx>(
__indexer_detail::__indexer<
__tuple_types<_Types...>,
typename __make_tuple_indices<sizeof...(_Types)>::type
>{})
)::type;
template <size_t _Ip, class ..._Types>
class tuple_element<_Ip, __tuple_types<_Types...>>
{
public:
static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
typedef __type_pack_element<_Ip, _Types...> type;
};
template <class ..._Tp>
class tuple_size<__tuple_types<_Tp...> >
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
struct __apply_cv_mf;
template <>
struct __apply_cv_mf<false, false, false> {
template <class _Tp> using __apply = _Tp;
};
template <>
struct __apply_cv_mf<false, true, false> {
template <class _Tp> using __apply = const _Tp;
};
template <>
struct __apply_cv_mf<false, false, true> {
template <class _Tp> using __apply = volatile _Tp;
};
template <>
struct __apply_cv_mf<false, true, true> {
template <class _Tp> using __apply = const volatile _Tp;
};
template <>
struct __apply_cv_mf<true, false, false> {
template <class _Tp> using __apply = _Tp&;
};
template <>
struct __apply_cv_mf<true, true, false> {
template <class _Tp> using __apply = const _Tp&;
};
template <>
struct __apply_cv_mf<true, false, true> {
template <class _Tp> using __apply = volatile _Tp&;
};
template <>
struct __apply_cv_mf<true, true, true> {
template <class _Tp> using __apply = const volatile _Tp&;
};
template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
using __apply_cv_t = __apply_cv_mf<
is_lvalue_reference<_Tp>::value,
is_const<_RawTp>::value,
is_volatile<_RawTp>::value>;
// __make_tuple_types
// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
// lvalue_reference type, then __tuple_types<_Types&...> is the result.
template <class _TupleTypes, class _TupleIndices>
struct __make_tuple_types_flat;
template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
// Specialization for pair, tuple, and __tuple_types
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
using __apply_quals = __tuple_types<
typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
>;
};
template <class _Vt, size_t _Np, size_t ..._Idx>
struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
template <size_t>
using __value_type = _Vt;
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
using __apply_quals = __tuple_types<
typename _ApplyFn::template __apply<__value_type<_Idx>>...
>;
};
template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
size_t _Sp = 0,
bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
struct __make_tuple_types
{
static_assert(_Sp <= _Ep, "__make_tuple_types input error");
using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
using type = typename _Maker::template __apply_quals<_Tp>;
};
template <class ..._Types, size_t _Ep>
struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
typedef __tuple_types<_Types...> type;
};
template <class ..._Types, size_t _Ep>
struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
typedef __tuple_types<_Types...> type;
};
template <bool ..._Preds>
struct __all_dummy;
template <bool ..._Pred>
using __all = is_same<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>;
struct __tuple_sfinae_base {
template <template <class, class...> class _Trait,
class ..._LArgs, class ..._RArgs>
static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
-> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type(true)...>;
template <template <class...> class>
static auto __do_test(...) -> false_type;
template <class _FromArgs, class _ToArgs>
using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
template <class _FromArgs, class _ToArgs>
using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
template <class _FromArgs, class _ToArgs>
using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
};
// __tuple_convertible
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
bool = __tuple_like<_Up>::value>
struct __tuple_convertible
: public false_type {};
template <class _Tp, class _Up>
struct __tuple_convertible<_Tp, _Up, true, true>
: public __tuple_sfinae_base::__convertible<
typename __make_tuple_types<_Tp>::type
, typename __make_tuple_types<_Up>::type
>
{};
// __tuple_constructible
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
bool = __tuple_like<_Up>::value>
struct __tuple_constructible
: public false_type {};
template <class _Tp, class _Up>
struct __tuple_constructible<_Tp, _Up, true, true>
: public __tuple_sfinae_base::__constructible<
typename __make_tuple_types<_Tp>::type
, typename __make_tuple_types<_Up>::type
>
{};
// __tuple_assignable
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
bool = __tuple_like<_Up>::value>
struct __tuple_assignable
: public false_type {};
template <class _Tp, class _Up>
struct __tuple_assignable<_Tp, _Up, true, true>
: public __tuple_sfinae_base::__assignable<
typename __make_tuple_types<_Tp>::type
, typename __make_tuple_types<_Up&>::type
>
{};
template <size_t _Ip, class ..._Tp>
class tuple_element<_Ip, tuple<_Tp...> >
{
public:
typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
};
template <size_t _Ip, class ..._Tp>
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
template <bool _IsTuple, class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp : false_type {};
template <class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
: integral_constant<bool, _SizeTrait::value == _Expected> {};
template <class _Tuple, size_t _ExpectedSize,
class _RawTuple = typename __uncvref<_Tuple>::type>
using __tuple_like_with_size = __tuple_like_with_size_imp<
__tuple_like<_RawTuple>::value,
tuple_size<_RawTuple>, _ExpectedSize
>;
struct __check_tuple_constructor_fail {
template <class ...>
static constexpr bool __enable_default() { return false; }
template <class ...>
static constexpr bool __enable_explicit() { return false; }
template <class ...>
static constexpr bool __enable_implicit() { return false; }
template <class ...>
static constexpr bool __enable_assign() { return false; }
};
} }
// -*- C++ -*-
//===---------------------------- limits ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
limits synopsis
namespace std
{
template<class T>
class numeric_limits
{
public:
static constexpr bool is_specialized = false;
static constexpr T min() noexcept;
static constexpr T max() noexcept;
static constexpr T lowest() noexcept;
static constexpr int digits = 0;
static constexpr int digits10 = 0;
static constexpr int max_digits10 = 0;
static constexpr bool is_signed = false;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
static constexpr int radix = 0;
static constexpr T epsilon() noexcept;
static constexpr T round_error() noexcept;
static constexpr int min_exponent = 0;
static constexpr int min_exponent10 = 0;
static constexpr int max_exponent = 0;
static constexpr int max_exponent10 = 0;
static constexpr bool has_infinity = false;
static constexpr bool has_quiet_NaN = false;
static constexpr bool has_signaling_NaN = false;
static constexpr float_denorm_style has_denorm = denorm_absent;
static constexpr bool has_denorm_loss = false;
static constexpr T infinity() noexcept;
static constexpr T quiet_NaN() noexcept;
static constexpr T signaling_NaN() noexcept;
static constexpr T denorm_min() noexcept;
static constexpr bool is_iec559 = false;
static constexpr bool is_bounded = false;
static constexpr bool is_modulo = false;
static constexpr bool traps = false;
static constexpr bool tinyness_before = false;
static constexpr float_round_style round_style = round_toward_zero;
};
enum __attribute__((packed)) float_round_style
{
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};
enum __attribute__((packed)) float_denorm_style
{
denorm_indeterminate = -1,
denorm_absent = 0,
denorm_present = 1
};
template<> class numeric_limits<cv bool>;
template<> class numeric_limits<cv char>;
template<> class numeric_limits<cv signed char>;
template<> class numeric_limits<cv unsigned char>;
template<> class numeric_limits<cv wchar_t>;
template<> class numeric_limits<cv char16_t>;
template<> class numeric_limits<cv char32_t>;
template<> class numeric_limits<cv short>;
template<> class numeric_limits<cv int>;
template<> class numeric_limits<cv long>;
template<> class numeric_limits<cv long long>;
template<> class numeric_limits<cv unsigned short>;
template<> class numeric_limits<cv unsigned int>;
template<> class numeric_limits<cv unsigned long>;
template<> class numeric_limits<cv unsigned long long>;
template<> class numeric_limits<cv float>;
template<> class numeric_limits<cv double>;
template<> class numeric_limits<cv long double>;
} // std
*/
// -*- C++ -*-
//===--------------------- support/ti/limits.h ----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
float.h synopsis
Macros:
FLT_ROUNDS
FLT_EVAL_METHOD // C99
FLT_RADIX
FLT_MANT_DIG
DBL_MANT_DIG
LDBL_MANT_DIG
DECIMAL_DIG // C99
FLT_DIG
DBL_DIG
LDBL_DIG
FLT_MIN_EXP
DBL_MIN_EXP
LDBL_MIN_EXP
FLT_MIN_10_EXP
DBL_MIN_10_EXP
LDBL_MIN_10_EXP
FLT_MAX_EXP
DBL_MAX_EXP
LDBL_MAX_EXP
FLT_MAX_10_EXP
DBL_MAX_10_EXP
LDBL_MAX_10_EXP
FLT_MAX
DBL_MAX
LDBL_MAX
FLT_EPSILON
DBL_EPSILON
LDBL_EPSILON
FLT_MIN
DBL_MIN
LDBL_MIN
*/
/*****************************************************************************/
/* float.h */
/* */
/* Copyright (c) 1993 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* 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. */
/* */
/* Neither the name of Texas Instruments Incorporated 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 COPYRIGHT HOLDERS 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 COPYRIGHT */
/* OWNER 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. */
/* */
/*****************************************************************************/
/********************************************************************/
/* KEY: FLT_ - APPLIES TO TYPE FLOAT */
/* DBL_ - APPLIES TO TYPE DOUBLE */
/* LDBL_ - APPLIES TO TYPE LONG DOUBLE */
/********************************************************************/
#pragma diag_push
#pragma CHECK_MISRA("-20.1") /* standard headers must define standard names */
#pragma diag_pop
_Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
// -*- C++ -*-
//===------------------------ __undef_macros ------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
namespace std { inline namespace __2 {
enum __attribute__((packed)) float_round_style
{
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};
enum __attribute__((packed)) float_denorm_style
{
denorm_indeterminate = -1,
denorm_absent = 0,
denorm_present = 1
};
template <class _Tp, bool = is_arithmetic<_Tp>::value>
class __libcpp_numeric_limits
{
protected:
typedef _Tp type;
static constexpr const bool is_specialized = false;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return type();}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return type();}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return type();}
static constexpr const int digits = 0;
static constexpr const int digits10 = 0;
static constexpr const int max_digits10 = 0;
static constexpr const bool is_signed = false;
static constexpr const bool is_integer = false;
static constexpr const bool is_exact = false;
static constexpr const int radix = 0;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return type();}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return type();}
static constexpr const int min_exponent = 0;
static constexpr const int min_exponent10 = 0;
static constexpr const int max_exponent = 0;
static constexpr const int max_exponent10 = 0;
static constexpr const bool has_infinity = false;
static constexpr const bool has_quiet_NaN = false;
static constexpr const bool has_signaling_NaN = false;
static constexpr const float_denorm_style has_denorm = denorm_absent;
static constexpr const bool has_denorm_loss = false;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return type();}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return type();}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return type();}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return type();}
static constexpr const bool is_iec559 = false;
static constexpr const bool is_bounded = false;
static constexpr const bool is_modulo = false;
static constexpr const bool traps = false;
static constexpr const bool tinyness_before = false;
static constexpr const float_round_style round_style = round_toward_zero;
};
template <class _Tp, int __digits, bool _IsSigned>
struct __libcpp_compute_min
{
static constexpr const _Tp value = _Tp(_Tp(1) << __digits);
};
template <class _Tp, int __digits>
struct __libcpp_compute_min<_Tp, __digits, false>
{
static constexpr const _Tp value = _Tp(0);
};
template <class _Tp>
class __libcpp_numeric_limits<_Tp, true>
{
protected:
typedef _Tp type;
static constexpr const bool is_specialized = true;
static constexpr const bool is_signed = type(-1) < type(0);
static constexpr const int digits = static_cast<int>(sizeof(type) * 8 - is_signed);
static constexpr const int digits10 = digits * 3 / 10;
static constexpr const int max_digits10 = 0;
static constexpr const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
static constexpr const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return __min;}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return __max;}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return min();}
static constexpr const bool is_integer = true;
static constexpr const bool is_exact = true;
static constexpr const int radix = 2;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return type(0);}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return type(0);}
static constexpr const int min_exponent = 0;
static constexpr const int min_exponent10 = 0;
static constexpr const int max_exponent = 0;
static constexpr const int max_exponent10 = 0;
static constexpr const bool has_infinity = false;
static constexpr const bool has_quiet_NaN = false;
static constexpr const bool has_signaling_NaN = false;
static constexpr const float_denorm_style has_denorm = denorm_absent;
static constexpr const bool has_denorm_loss = false;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return type(0);}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return type(0);}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return type(0);}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return type(0);}
static constexpr const bool is_iec559 = false;
static constexpr const bool is_bounded = true;
static constexpr const bool is_modulo = !std::__2::is_signed<_Tp>::value;
static constexpr const bool traps = false;
static constexpr const bool tinyness_before = false;
static constexpr const float_round_style round_style = round_toward_zero;
};
template <>
class __libcpp_numeric_limits<bool, true>
{
protected:
typedef bool type;
static constexpr const bool is_specialized = true;
static constexpr const bool is_signed = false;
static constexpr const int digits = 1;
static constexpr const int digits10 = 0;
static constexpr const int max_digits10 = 0;
static constexpr const type __min = false;
static constexpr const type __max = true;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return __min;}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return __max;}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return min();}
static constexpr const bool is_integer = true;
static constexpr const bool is_exact = true;
static constexpr const int radix = 2;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return type(0);}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return type(0);}
static constexpr const int min_exponent = 0;
static constexpr const int min_exponent10 = 0;
static constexpr const int max_exponent = 0;
static constexpr const int max_exponent10 = 0;
static constexpr const bool has_infinity = false;
static constexpr const bool has_quiet_NaN = false;
static constexpr const bool has_signaling_NaN = false;
static constexpr const float_denorm_style has_denorm = denorm_absent;
static constexpr const bool has_denorm_loss = false;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return type(0);}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return type(0);}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return type(0);}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return type(0);}
static constexpr const bool is_iec559 = false;
static constexpr const bool is_bounded = true;
static constexpr const bool is_modulo = false;
static constexpr const bool traps = false;
static constexpr const bool tinyness_before = false;
static constexpr const float_round_style round_style = round_toward_zero;
};
template <>
class __libcpp_numeric_limits<float, true>
{
protected:
typedef float type;
static constexpr const bool is_specialized = true;
static constexpr const bool is_signed = true;
static constexpr const int digits = 24;
static constexpr const int digits10 = 6;
static constexpr const int max_digits10 = 2+(digits * 30103l)/100000l;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return 1.175494351E-38F;}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return 3.402823466E+38F;}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return -max();}
static constexpr const bool is_integer = false;
static constexpr const bool is_exact = false;
static constexpr const int radix = 2;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return 1.192092896E-07F;}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return 0.5F;}
static constexpr const int min_exponent = (-125);
static constexpr const int min_exponent10 = (-37);
static constexpr const int max_exponent = 128;
static constexpr const int max_exponent10 = 38;
static constexpr const bool has_infinity = true;
static constexpr const bool has_quiet_NaN = true;
static constexpr const bool has_signaling_NaN = false;
static constexpr const float_denorm_style has_denorm = denorm_absent;
static constexpr const bool has_denorm_loss = false;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return __builtin_huge_valf();}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return __builtin_nanf("");}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return __builtin_nansf("");}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return has_denorm == denorm_absent ? min() : (0.0f);}
static constexpr const bool is_iec559 = false; // Because has_signaling_NaN is false
static constexpr const bool is_bounded = true;
static constexpr const bool is_modulo = false;
static constexpr const bool traps = false;
static constexpr const bool tinyness_before = false;
static constexpr const float_round_style round_style = round_to_nearest;
};
template <>
class __libcpp_numeric_limits<double, true>
{
protected:
typedef double type;
static constexpr const bool is_specialized = true;
static constexpr const bool is_signed = true;
static constexpr const int digits = 53;
static constexpr const int digits10 = 15;
static constexpr const int max_digits10 = 2+(digits * 30103l)/100000l;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return 2.2250738585072014E-308;}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return 1.7976931348623157E+308;}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return -max();}
static constexpr const bool is_integer = false;
static constexpr const bool is_exact = false;
static constexpr const int radix = 2;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return 2.2204460492503131E-16;}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return 0.5;}
static constexpr const int min_exponent = (-1021);
static constexpr const int min_exponent10 = (-307);
static constexpr const int max_exponent = 1024;
static constexpr const int max_exponent10 = 308;
static constexpr const bool has_infinity = true;
static constexpr const bool has_quiet_NaN = true;
static constexpr const bool has_signaling_NaN = false;
static constexpr const float_denorm_style has_denorm = denorm_absent;
static constexpr const bool has_denorm_loss = false;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return __builtin_huge_val();}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return __builtin_nan("");}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return __builtin_nans("");}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return has_denorm == denorm_absent ? min() : (0.0);}
static constexpr const bool is_iec559 = false; // Because has_signaling_NaN is false
static constexpr const bool is_bounded = true;
static constexpr const bool is_modulo = false;
static constexpr const bool traps = false;
static constexpr const bool tinyness_before = false;
static constexpr const float_round_style round_style = round_to_nearest;
};
template <>
class __libcpp_numeric_limits<long double, true>
{
protected:
typedef long double type;
static constexpr const bool is_specialized = true;
static constexpr const bool is_signed = true;
static constexpr const int digits = 53;
static constexpr const int digits10 = 15;
static constexpr const int max_digits10 = 2+(digits * 30103l)/100000l;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return 2.2250738585072014E-308L;}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return 1.7976931348623157E+308L;}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return -max();}
static constexpr const bool is_integer = false;
static constexpr const bool is_exact = false;
static constexpr const int radix = 2;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return 2.2204460492503131E-16L;}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return 0.5;}
static constexpr const int min_exponent = (-1021);
static constexpr const int min_exponent10 = (-307);
static constexpr const int max_exponent = 1024;
static constexpr const int max_exponent10 = 308;
static constexpr const bool has_infinity = true;
static constexpr const bool has_quiet_NaN = true;
static constexpr const bool has_signaling_NaN = false;
static constexpr const float_denorm_style has_denorm = denorm_absent;
static constexpr const bool has_denorm_loss = false;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return __builtin_huge_vall();}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return __builtin_nanl("");}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return __builtin_nansl("");}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return has_denorm == denorm_absent ? min() : (0.0l);}
static constexpr const bool is_iec559 = false; // Because has_signaling_NaN is false
static constexpr const bool is_bounded = true;
static constexpr const bool is_modulo = false;
static constexpr const bool traps = false;
static constexpr const bool tinyness_before = false;
static constexpr const float_round_style round_style = round_to_nearest;
};
template <class _Tp>
class numeric_limits
: private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
{
typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
typedef typename __base::type type;
public:
static constexpr const bool is_specialized = __base::is_specialized;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return __base::min();}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return __base::max();}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return __base::lowest();}
static constexpr const int digits = __base::digits;
static constexpr const int digits10 = __base::digits10;
static constexpr const int max_digits10 = __base::max_digits10;
static constexpr const bool is_signed = __base::is_signed;
static constexpr const bool is_integer = __base::is_integer;
static constexpr const bool is_exact = __base::is_exact;
static constexpr const int radix = __base::radix;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return __base::epsilon();}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return __base::round_error();}
static constexpr const int min_exponent = __base::min_exponent;
static constexpr const int min_exponent10 = __base::min_exponent10;
static constexpr const int max_exponent = __base::max_exponent;
static constexpr const int max_exponent10 = __base::max_exponent10;
static constexpr const bool has_infinity = __base::has_infinity;
static constexpr const bool has_quiet_NaN = __base::has_quiet_NaN;
static constexpr const bool has_signaling_NaN = __base::has_signaling_NaN;
static constexpr const float_denorm_style has_denorm = __base::has_denorm;
static constexpr const bool has_denorm_loss = __base::has_denorm_loss;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return __base::infinity();}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return __base::quiet_NaN();}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return __base::signaling_NaN();}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return __base::denorm_min();}
static constexpr const bool is_iec559 = __base::is_iec559;
static constexpr const bool is_bounded = __base::is_bounded;
static constexpr const bool is_modulo = __base::is_modulo;
static constexpr const bool traps = __base::traps;
static constexpr const bool tinyness_before = __base::tinyness_before;
static constexpr const float_round_style round_style = __base::round_style;
};
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::is_specialized;
template <class _Tp>
constexpr const int numeric_limits<_Tp>::digits;
template <class _Tp>
constexpr const int numeric_limits<_Tp>::digits10;
template <class _Tp>
constexpr const int numeric_limits<_Tp>::max_digits10;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::is_signed;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::is_integer;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::is_exact;
template <class _Tp>
constexpr const int numeric_limits<_Tp>::radix;
template <class _Tp>
constexpr const int numeric_limits<_Tp>::min_exponent;
template <class _Tp>
constexpr const int numeric_limits<_Tp>::min_exponent10;
template <class _Tp>
constexpr const int numeric_limits<_Tp>::max_exponent;
template <class _Tp>
constexpr const int numeric_limits<_Tp>::max_exponent10;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::has_infinity;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::has_quiet_NaN;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::has_signaling_NaN;
template <class _Tp>
constexpr const float_denorm_style numeric_limits<_Tp>::has_denorm;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::has_denorm_loss;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::is_iec559;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::is_bounded;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::is_modulo;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::traps;
template <class _Tp>
constexpr const bool numeric_limits<_Tp>::tinyness_before;
template <class _Tp>
constexpr const float_round_style numeric_limits<_Tp>::round_style;
template <class _Tp>
class numeric_limits<const _Tp>
: private numeric_limits<_Tp>
{
typedef numeric_limits<_Tp> __base;
typedef _Tp type;
public:
static constexpr const bool is_specialized = __base::is_specialized;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return __base::min();}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return __base::max();}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return __base::lowest();}
static constexpr const int digits = __base::digits;
static constexpr const int digits10 = __base::digits10;
static constexpr const int max_digits10 = __base::max_digits10;
static constexpr const bool is_signed = __base::is_signed;
static constexpr const bool is_integer = __base::is_integer;
static constexpr const bool is_exact = __base::is_exact;
static constexpr const int radix = __base::radix;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return __base::epsilon();}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return __base::round_error();}
static constexpr const int min_exponent = __base::min_exponent;
static constexpr const int min_exponent10 = __base::min_exponent10;
static constexpr const int max_exponent = __base::max_exponent;
static constexpr const int max_exponent10 = __base::max_exponent10;
static constexpr const bool has_infinity = __base::has_infinity;
static constexpr const bool has_quiet_NaN = __base::has_quiet_NaN;
static constexpr const bool has_signaling_NaN = __base::has_signaling_NaN;
static constexpr const float_denorm_style has_denorm = __base::has_denorm;
static constexpr const bool has_denorm_loss = __base::has_denorm_loss;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return __base::infinity();}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return __base::quiet_NaN();}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return __base::signaling_NaN();}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return __base::denorm_min();}
static constexpr const bool is_iec559 = __base::is_iec559;
static constexpr const bool is_bounded = __base::is_bounded;
static constexpr const bool is_modulo = __base::is_modulo;
static constexpr const bool traps = __base::traps;
static constexpr const bool tinyness_before = __base::tinyness_before;
static constexpr const float_round_style round_style = __base::round_style;
};
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::is_specialized;
template <class _Tp>
constexpr const int numeric_limits<const _Tp>::digits;
template <class _Tp>
constexpr const int numeric_limits<const _Tp>::digits10;
template <class _Tp>
constexpr const int numeric_limits<const _Tp>::max_digits10;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::is_signed;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::is_integer;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::is_exact;
template <class _Tp>
constexpr const int numeric_limits<const _Tp>::radix;
template <class _Tp>
constexpr const int numeric_limits<const _Tp>::min_exponent;
template <class _Tp>
constexpr const int numeric_limits<const _Tp>::min_exponent10;
template <class _Tp>
constexpr const int numeric_limits<const _Tp>::max_exponent;
template <class _Tp>
constexpr const int numeric_limits<const _Tp>::max_exponent10;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::has_infinity;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::has_quiet_NaN;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::has_signaling_NaN;
template <class _Tp>
constexpr const float_denorm_style numeric_limits<const _Tp>::has_denorm;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::has_denorm_loss;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::is_iec559;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::is_bounded;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::is_modulo;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::traps;
template <class _Tp>
constexpr const bool numeric_limits<const _Tp>::tinyness_before;
template <class _Tp>
constexpr const float_round_style numeric_limits<const _Tp>::round_style;
template <class _Tp>
class numeric_limits<volatile _Tp>
: private numeric_limits<_Tp>
{
typedef numeric_limits<_Tp> __base;
typedef _Tp type;
public:
static constexpr const bool is_specialized = __base::is_specialized;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return __base::min();}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return __base::max();}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return __base::lowest();}
static constexpr const int digits = __base::digits;
static constexpr const int digits10 = __base::digits10;
static constexpr const int max_digits10 = __base::max_digits10;
static constexpr const bool is_signed = __base::is_signed;
static constexpr const bool is_integer = __base::is_integer;
static constexpr const bool is_exact = __base::is_exact;
static constexpr const int radix = __base::radix;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return __base::epsilon();}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return __base::round_error();}
static constexpr const int min_exponent = __base::min_exponent;
static constexpr const int min_exponent10 = __base::min_exponent10;
static constexpr const int max_exponent = __base::max_exponent;
static constexpr const int max_exponent10 = __base::max_exponent10;
static constexpr const bool has_infinity = __base::has_infinity;
static constexpr const bool has_quiet_NaN = __base::has_quiet_NaN;
static constexpr const bool has_signaling_NaN = __base::has_signaling_NaN;
static constexpr const float_denorm_style has_denorm = __base::has_denorm;
static constexpr const bool has_denorm_loss = __base::has_denorm_loss;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return __base::infinity();}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return __base::quiet_NaN();}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return __base::signaling_NaN();}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return __base::denorm_min();}
static constexpr const bool is_iec559 = __base::is_iec559;
static constexpr const bool is_bounded = __base::is_bounded;
static constexpr const bool is_modulo = __base::is_modulo;
static constexpr const bool traps = __base::traps;
static constexpr const bool tinyness_before = __base::tinyness_before;
static constexpr const float_round_style round_style = __base::round_style;
};
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::is_specialized;
template <class _Tp>
constexpr const int numeric_limits<volatile _Tp>::digits;
template <class _Tp>
constexpr const int numeric_limits<volatile _Tp>::digits10;
template <class _Tp>
constexpr const int numeric_limits<volatile _Tp>::max_digits10;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::is_signed;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::is_integer;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::is_exact;
template <class _Tp>
constexpr const int numeric_limits<volatile _Tp>::radix;
template <class _Tp>
constexpr const int numeric_limits<volatile _Tp>::min_exponent;
template <class _Tp>
constexpr const int numeric_limits<volatile _Tp>::min_exponent10;
template <class _Tp>
constexpr const int numeric_limits<volatile _Tp>::max_exponent;
template <class _Tp>
constexpr const int numeric_limits<volatile _Tp>::max_exponent10;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::has_infinity;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::has_quiet_NaN;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::has_signaling_NaN;
template <class _Tp>
constexpr const float_denorm_style numeric_limits<volatile _Tp>::has_denorm;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::has_denorm_loss;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::is_iec559;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::is_bounded;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::is_modulo;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::traps;
template <class _Tp>
constexpr const bool numeric_limits<volatile _Tp>::tinyness_before;
template <class _Tp>
constexpr const float_round_style numeric_limits<volatile _Tp>::round_style;
template <class _Tp>
class numeric_limits<const volatile _Tp>
: private numeric_limits<_Tp>
{
typedef numeric_limits<_Tp> __base;
typedef _Tp type;
public:
static constexpr const bool is_specialized = __base::is_specialized;
__attribute__ ((__always_inline__)) static constexpr type min() noexcept {return __base::min();}
__attribute__ ((__always_inline__)) static constexpr type max() noexcept {return __base::max();}
__attribute__ ((__always_inline__)) static constexpr type lowest() noexcept {return __base::lowest();}
static constexpr const int digits = __base::digits;
static constexpr const int digits10 = __base::digits10;
static constexpr const int max_digits10 = __base::max_digits10;
static constexpr const bool is_signed = __base::is_signed;
static constexpr const bool is_integer = __base::is_integer;
static constexpr const bool is_exact = __base::is_exact;
static constexpr const int radix = __base::radix;
__attribute__ ((__always_inline__)) static constexpr type epsilon() noexcept {return __base::epsilon();}
__attribute__ ((__always_inline__)) static constexpr type round_error() noexcept {return __base::round_error();}
static constexpr const int min_exponent = __base::min_exponent;
static constexpr const int min_exponent10 = __base::min_exponent10;
static constexpr const int max_exponent = __base::max_exponent;
static constexpr const int max_exponent10 = __base::max_exponent10;
static constexpr const bool has_infinity = __base::has_infinity;
static constexpr const bool has_quiet_NaN = __base::has_quiet_NaN;
static constexpr const bool has_signaling_NaN = __base::has_signaling_NaN;
static constexpr const float_denorm_style has_denorm = __base::has_denorm;
static constexpr const bool has_denorm_loss = __base::has_denorm_loss;
__attribute__ ((__always_inline__)) static constexpr type infinity() noexcept {return __base::infinity();}
__attribute__ ((__always_inline__)) static constexpr type quiet_NaN() noexcept {return __base::quiet_NaN();}
__attribute__ ((__always_inline__)) static constexpr type signaling_NaN() noexcept {return __base::signaling_NaN();}
__attribute__ ((__always_inline__)) static constexpr type denorm_min() noexcept {return __base::denorm_min();}
static constexpr const bool is_iec559 = __base::is_iec559;
static constexpr const bool is_bounded = __base::is_bounded;
static constexpr const bool is_modulo = __base::is_modulo;
static constexpr const bool traps = __base::traps;
static constexpr const bool tinyness_before = __base::tinyness_before;
static constexpr const float_round_style round_style = __base::round_style;
};
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::is_specialized;
template <class _Tp>
constexpr const int numeric_limits<const volatile _Tp>::digits;
template <class _Tp>
constexpr const int numeric_limits<const volatile _Tp>::digits10;
template <class _Tp>
constexpr const int numeric_limits<const volatile _Tp>::max_digits10;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::is_signed;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::is_integer;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::is_exact;
template <class _Tp>
constexpr const int numeric_limits<const volatile _Tp>::radix;
template <class _Tp>
constexpr const int numeric_limits<const volatile _Tp>::min_exponent;
template <class _Tp>
constexpr const int numeric_limits<const volatile _Tp>::min_exponent10;
template <class _Tp>
constexpr const int numeric_limits<const volatile _Tp>::max_exponent;
template <class _Tp>
constexpr const int numeric_limits<const volatile _Tp>::max_exponent10;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::has_infinity;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::has_quiet_NaN;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::has_signaling_NaN;
template <class _Tp>
constexpr const float_denorm_style numeric_limits<const volatile _Tp>::has_denorm;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::has_denorm_loss;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::is_iec559;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::is_bounded;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::is_modulo;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::traps;
template <class _Tp>
constexpr const bool numeric_limits<const volatile _Tp>::tinyness_before;
template <class _Tp>
constexpr const float_round_style numeric_limits<const volatile _Tp>::round_style;
} }
_Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")")
// -*- C++ -*-
//===--------------------------- cstdint ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
cstdint synopsis
Macros:
INT8_MIN
INT16_MIN
INT32_MIN
INT64_MIN
INT8_MAX
INT16_MAX
INT32_MAX
INT64_MAX
UINT8_MAX
UINT16_MAX
UINT32_MAX
UINT64_MAX
INT_LEAST8_MIN
INT_LEAST16_MIN
INT_LEAST32_MIN
INT_LEAST64_MIN
INT_LEAST8_MAX
INT_LEAST16_MAX
INT_LEAST32_MAX
INT_LEAST64_MAX
UINT_LEAST8_MAX
UINT_LEAST16_MAX
UINT_LEAST32_MAX
UINT_LEAST64_MAX
INT_FAST8_MIN
INT_FAST16_MIN
INT_FAST32_MIN
INT_FAST64_MIN
INT_FAST8_MAX
INT_FAST16_MAX
INT_FAST32_MAX
INT_FAST64_MAX
UINT_FAST8_MAX
UINT_FAST16_MAX
UINT_FAST32_MAX
UINT_FAST64_MAX
INTPTR_MIN
INTPTR_MAX
UINTPTR_MAX
INTMAX_MIN
INTMAX_MAX
UINTMAX_MAX
PTRDIFF_MIN
PTRDIFF_MAX
SIG_ATOMIC_MIN
SIG_ATOMIC_MAX
SIZE_MAX
WCHAR_MIN
WCHAR_MAX
WINT_MIN
WINT_MAX
INT8_C(value)
INT16_C(value)
INT32_C(value)
INT64_C(value)
UINT8_C(value)
UINT16_C(value)
UINT32_C(value)
UINT64_C(value)
INTMAX_C(value)
UINTMAX_C(value)
namespace std
{
Types:
int8_t
int16_t
int32_t
int64_t
uint8_t
uint16_t
uint32_t
uint64_t
int_least8_t
int_least16_t
int_least32_t
int_least64_t
uint_least8_t
uint_least16_t
uint_least32_t
uint_least64_t
int_fast8_t
int_fast16_t
int_fast32_t
int_fast64_t
uint_fast8_t
uint_fast16_t
uint_fast32_t
uint_fast64_t
intptr_t
uintptr_t
intmax_t
uintmax_t
} // std
*/
namespace std { inline namespace __2 {
using::int8_t;
using::int16_t;
using::int32_t;
using::int64_t;
using::uint8_t;
using::uint16_t;
using::uint32_t;
using::uint64_t;
using::int_least8_t;
using::int_least16_t;
using::int_least32_t;
using::int_least64_t;
using::uint_least8_t;
using::uint_least16_t;
using::uint_least32_t;
using::uint_least64_t;
using::int_fast8_t;
using::int_fast16_t;
using::int_fast32_t;
using::int_fast64_t;
using::uint_fast8_t;
using::uint_fast16_t;
using::uint_fast32_t;
using::uint_fast64_t;
using::intptr_t;
using::uintptr_t;
using::intmax_t;
using::uintmax_t;
} }
// -*- C++ -*-
//===--------------------------- __debug ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
class __libcpp_debug_exception;
namespace std { inline namespace __2 {
struct __libcpp_debug_info {
__attribute__ ((__always_inline__)) constexpr
__libcpp_debug_info()
: __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
__attribute__ ((__always_inline__)) constexpr
__libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
: __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
const char* __file_;
int __line_;
const char* __pred_;
const char* __msg_;
};
/// __libcpp_debug_function_type - The type of the assertion failure handler.
typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&);
/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
/// fails.
extern __libcpp_debug_function_type __libcpp_debug_function;
/// __libcpp_abort_debug_function - A debug handler that aborts when called.
[[noreturn]]
void __libcpp_abort_debug_function(__libcpp_debug_info const&);
/// __libcpp_throw_debug_function - A debug handler that throws
/// an instance of __libcpp_debug_exception when called.
[[noreturn]]
void __libcpp_throw_debug_function(__libcpp_debug_info const&);
/// __libcpp_set_debug_function - Set the debug handler to the specified
/// function.
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
// Setup the throwing debug handler during dynamic initialization.
} }
namespace std { inline namespace __2 {
namespace rel_ops
{
template<class _Tp>
inline __attribute__ ((__always_inline__))
bool
operator!=(const _Tp& __x, const _Tp& __y)
{
return !(__x == __y);
}
template<class _Tp>
inline __attribute__ ((__always_inline__))
bool
operator> (const _Tp& __x, const _Tp& __y)
{
return __y < __x;
}
template<class _Tp>
inline __attribute__ ((__always_inline__))
bool
operator<=(const _Tp& __x, const _Tp& __y)
{
return !(__y < __x);
}
template<class _Tp>
inline __attribute__ ((__always_inline__))
bool
operator>=(const _Tp& __x, const _Tp& __y)
{
return !(__x < __y);
}
} // rel_ops
// swap_ranges
template <class _ForwardIterator1, class _ForwardIterator2>
inline __attribute__ ((__always_inline__))
_ForwardIterator2
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
{
for(; __first1 != __last1; ++__first1, (void) ++__first2)
swap(*__first1, *__first2);
return __first2;
}
// forward declared in <type_traits>
template<class _Tp, size_t _Np>
inline __attribute__ ((__always_inline__))
typename enable_if<
__is_swappable<_Tp>::value
>::type
swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) noexcept(__is_nothrow_swappable<_Tp> ::value)
{
std::__2::swap_ranges(__a, __a + _Np, __b);
}
template <class _Tp>
inline __attribute__ ((__always_inline__)) constexpr
typename conditional
<
!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value,
const _Tp&,
_Tp&&
>::type
move_if_noexcept(_Tp& __x) noexcept
{
return std::__2::move(__x);
}
struct piecewise_construct_t { };
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
template <class _T1, class _T2>
struct pair
{
typedef _T1 first_type;
typedef _T2 second_type;
_T1 first;
_T2 second;
pair(pair const&) = default;
pair(pair&&) = default;
template <bool _Val>
using _EnableB = typename enable_if<_Val, bool>::type;
struct _CheckArgs {
template <class _U1, class _U2>
static constexpr bool __enable_default() {
return is_default_constructible<_U1>::value
&& is_default_constructible<_U2>::value;
}
template <class _U1, class _U2>
static constexpr bool __enable_explicit() {
return is_constructible<first_type, _U1>::value
&& is_constructible<second_type, _U2>::value
&& (!is_convertible<_U1, first_type>::value
|| !is_convertible<_U2, second_type>::value);
}
template <class _U1, class _U2>
static constexpr bool __enable_implicit() {
return is_constructible<first_type, _U1>::value
&& is_constructible<second_type, _U2>::value
&& is_convertible<_U1, first_type>::value
&& is_convertible<_U2, second_type>::value;
}
};
template <bool _MaybeEnable>
using _CheckArgsDep = typename conditional<
_MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type;
struct _CheckTupleLikeConstructor {
template <class _Tuple>
static constexpr bool __enable_implicit() {
return __tuple_convertible<_Tuple, pair>::value;
}
template <class _Tuple>
static constexpr bool __enable_explicit() {
return __tuple_constructible<_Tuple, pair>::value
&& !__tuple_convertible<_Tuple, pair>::value;
}
template <class _Tuple>
static constexpr bool __enable_assign() {
return __tuple_assignable<_Tuple, pair>::value;
}
};
template <class _Tuple>
using _CheckTLC = typename conditional<
__tuple_like_with_size<_Tuple, 2>::value
&& !is_same<typename decay<_Tuple>::type, pair>::value,
_CheckTupleLikeConstructor,
__check_tuple_constructor_fail
>::type;
template<bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>()
> = false>
__attribute__ ((__always_inline__)) constexpr
pair() : first(), second() {}
template <bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
> = false>
__attribute__ ((__always_inline__)) constexpr
explicit pair(_T1 const& __t1, _T2 const& __t2)
: first(__t1), second(__t2) {}
template<bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>()
> = false>
__attribute__ ((__always_inline__)) constexpr
pair(_T1 const& __t1, _T2 const& __t2)
: first(__t1), second(__t2) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1, _U2>()
> = false>
__attribute__ ((__always_inline__)) constexpr
explicit pair(_U1&& __u1, _U2&& __u2)
: first(std::__2::forward<_U1>(__u1)), second(std::__2::forward<_U2>(__u2)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1, _U2>()
> = false>
__attribute__ ((__always_inline__)) constexpr
pair(_U1&& __u1, _U2&& __u2)
: first(std::__2::forward<_U1>(__u1)), second(std::__2::forward<_U2>(__u2)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>()
> = false>
__attribute__ ((__always_inline__)) constexpr
explicit pair(pair<_U1, _U2> const& __p)
: first(__p.first), second(__p.second) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>()
> = false>
__attribute__ ((__always_inline__)) constexpr
pair(pair<_U1, _U2> const& __p)
: first(__p.first), second(__p.second) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_explicit<_U1, _U2>()
> = false>
__attribute__ ((__always_inline__)) constexpr
explicit pair(pair<_U1, _U2>&&__p)
: first(std::__2::forward<_U1>(__p.first)), second(std::__2::forward<_U2>(__p.second)) {}
template<class _U1, class _U2, _EnableB<
_CheckArgs::template __enable_implicit<_U1, _U2>()
> = false>
__attribute__ ((__always_inline__)) constexpr
pair(pair<_U1, _U2>&& __p)
: first(std::__2::forward<_U1>(__p.first)), second(std::__2::forward<_U2>(__p.second)) {}
template<class _Tuple, _EnableB<
_CheckTLC<_Tuple>::template __enable_explicit<_Tuple>()
> = false>
__attribute__ ((__always_inline__)) constexpr
explicit pair(_Tuple&& __p)
: first(std::__2::get<0>(std::__2::forward<_Tuple>(__p))),
second(std::__2::get<1>(std::__2::forward<_Tuple>(__p))) {}
template<class _Tuple, _EnableB<
_CheckTLC<_Tuple>::template __enable_implicit<_Tuple>()
> = false>
__attribute__ ((__always_inline__)) constexpr
pair(_Tuple&& __p)
: first(std::__2::get<0>(std::__2::forward<_Tuple>(__p))),
second(std::__2::get<1>(std::__2::forward<_Tuple>(__p))) {}
template <class... _Args1, class... _Args2>
__attribute__ ((__always_inline__))
pair(piecewise_construct_t __pc,
tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
: pair(__pc, __first_args, __second_args,
typename __make_tuple_indices<sizeof...(_Args1)>::type(),
typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
__attribute__ ((__always_inline__))
pair& operator=(typename conditional<
is_copy_assignable<first_type>::value &&
is_copy_assignable<second_type>::value,
pair, __nat>::type const& __p)
noexcept(is_nothrow_copy_assignable<first_type> ::value && is_nothrow_copy_assignable<second_type> ::value)
{
first = __p.first;
second = __p.second;
return *this;
}
__attribute__ ((__always_inline__))
pair& operator=(typename conditional<
is_move_assignable<first_type>::value &&
is_move_assignable<second_type>::value,
pair, __nat>::type&& __p)
noexcept(is_nothrow_move_assignable<first_type> ::value && is_nothrow_move_assignable<second_type> ::value)
{
first = std::__2::forward<first_type>(__p.first);
second = std::__2::forward<second_type>(__p.second);
return *this;
}
template <class _Tuple, _EnableB<
_CheckTLC<_Tuple>::template __enable_assign<_Tuple>()
> = false>
__attribute__ ((__always_inline__))
pair& operator=(_Tuple&& __p) {
first = std::__2::get<0>(std::__2::forward<_Tuple>(__p));
second = std::__2::get<1>(std::__2::forward<_Tuple>(__p));
return *this;
}
__attribute__ ((__always_inline__))
void
swap(pair& __p) noexcept(__is_nothrow_swappable<first_type> ::value && __is_nothrow_swappable<second_type> ::value)
{
using std::__2::swap;
swap(first, __p.first);
swap(second, __p.second);
}
private:
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
__attribute__ ((__always_inline__))
pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>);
};
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return __x.first == __y.first && __x.second == __y.second;
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return !(__x == __y);
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second);
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return __y < __x;
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return !(__x < __y);
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return !(__y < __x);
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
typename enable_if
<
__is_swappable<_T1>::value &&
__is_swappable<_T2>::value,
void
>::type
swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
noexcept((__is_nothrow_swappable<_T1> ::value && __is_nothrow_swappable<_T2> ::value))
{
__x.swap(__y);
}
template <class _Tp>
struct __make_pair_return_impl
{
typedef _Tp type;
};
template <class _Tp>
struct __make_pair_return_impl<reference_wrapper<_Tp>>
{
typedef _Tp& type;
};
template <class _Tp>
struct __make_pair_return
{
typedef typename __make_pair_return_impl<typename decay<_Tp>::type>::type type;
};
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
make_pair(_T1&& __t1, _T2&& __t2)
{
return pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
(std::__2::forward<_T1>(__t1), std::__2::forward<_T2>(__t2));
}
template <class _T1, class _T2>
class tuple_size<pair<_T1, _T2> >
: public integral_constant<size_t, 2> {};
template <size_t _Ip, class _T1, class _T2>
class tuple_element<_Ip, pair<_T1, _T2> >
{
static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>");
};
template <class _T1, class _T2>
class tuple_element<0, pair<_T1, _T2> >
{
public:
typedef _T1 type;
};
template <class _T1, class _T2>
class tuple_element<1, pair<_T1, _T2> >
{
public:
typedef _T2 type;
};
template <size_t _Ip> struct __get_pair;
template <>
struct __get_pair<0>
{
template <class _T1, class _T2>
static
__attribute__ ((__always_inline__)) constexpr
_T1&
get(pair<_T1, _T2>& __p) noexcept {return __p.first;}
template <class _T1, class _T2>
static
__attribute__ ((__always_inline__)) constexpr
const _T1&
get(const pair<_T1, _T2>& __p) noexcept {return __p.first;}
template <class _T1, class _T2>
static
__attribute__ ((__always_inline__)) constexpr
_T1&&
get(pair<_T1, _T2>&& __p) noexcept {return std::__2::forward<_T1>(__p.first);}
template <class _T1, class _T2>
static
__attribute__ ((__always_inline__)) constexpr
const _T1&&
get(const pair<_T1, _T2>&& __p) noexcept {return std::__2::forward<const _T1>(__p.first);}
};
template <>
struct __get_pair<1>
{
template <class _T1, class _T2>
static
__attribute__ ((__always_inline__)) constexpr
_T2&
get(pair<_T1, _T2>& __p) noexcept {return __p.second;}
template <class _T1, class _T2>
static
__attribute__ ((__always_inline__)) constexpr
const _T2&
get(const pair<_T1, _T2>& __p) noexcept {return __p.second;}
template <class _T1, class _T2>
static
__attribute__ ((__always_inline__)) constexpr
_T2&&
get(pair<_T1, _T2>&& __p) noexcept {return std::__2::forward<_T2>(__p.second);}
template <class _T1, class _T2>
static
__attribute__ ((__always_inline__)) constexpr
const _T2&&
get(const pair<_T1, _T2>&& __p) noexcept {return std::__2::forward<const _T2>(__p.second);}
};
template <size_t _Ip, class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(pair<_T1, _T2>& __p) noexcept
{
return __get_pair<_Ip>::get(__p);
}
template <size_t _Ip, class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>& __p) noexcept
{
return __get_pair<_Ip>::get(__p);
}
template <size_t _Ip, class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(pair<_T1, _T2>&& __p) noexcept
{
return __get_pair<_Ip>::get(std::__2::move(__p));
}
template <size_t _Ip, class _T1, class _T2>
inline __attribute__ ((__always_inline__)) constexpr
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(const pair<_T1, _T2>&& __p) noexcept
{
return __get_pair<_Ip>::get(std::__2::move(__p));
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
constexpr _T1 & get(pair<_T1, _T2>& __p) noexcept
{
return __get_pair<0>::get(__p);
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
constexpr _T1 const & get(pair<_T1, _T2> const& __p) noexcept
{
return __get_pair<0>::get(__p);
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
constexpr _T1 && get(pair<_T1, _T2>&& __p) noexcept
{
return __get_pair<0>::get(std::__2::move(__p));
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
constexpr _T1 const && get(pair<_T1, _T2> const&& __p) noexcept
{
return __get_pair<0>::get(std::__2::move(__p));
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
constexpr _T1 & get(pair<_T2, _T1>& __p) noexcept
{
return __get_pair<1>::get(__p);
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
constexpr _T1 const & get(pair<_T2, _T1> const& __p) noexcept
{
return __get_pair<1>::get(__p);
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
constexpr _T1 && get(pair<_T2, _T1>&& __p) noexcept
{
return __get_pair<1>::get(std::__2::move(__p));
}
template <class _T1, class _T2>
inline __attribute__ ((__always_inline__))
constexpr _T1 const && get(pair<_T2, _T1> const&& __p) noexcept
{
return __get_pair<1>::get(std::__2::move(__p));
}
template<class _Tp, _Tp... _Ip>
struct integer_sequence
{
typedef _Tp value_type;
static_assert( is_integral<_Tp>::value,
"std::integer_sequence can only be instantiated with an integral type" );
static
__attribute__ ((__always_inline__))
constexpr
size_t
size() noexcept { return sizeof...(_Ip); }
};
template<size_t... _Ip>
using index_sequence = integer_sequence<size_t, _Ip...>;
template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked =
typename __detail::__make<_Np>::type::template __convert<integer_sequence, _Tp>;
template <class _Tp, _Tp _Ep>
struct __make_integer_sequence_checked
{
static_assert(is_integral<_Tp>::value,
"std::make_integer_sequence can only be instantiated with an integral type" );
static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length");
// Workaround GCC bug by preventing bad installations when 0 <= _Ep
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929
typedef __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type;
};
template <class _Tp, _Tp _Ep>
using __make_integer_sequence = typename __make_integer_sequence_checked<_Tp, _Ep>::type;
template<class _Tp, _Tp _Np>
using make_integer_sequence = __make_integer_sequence<_Tp, _Np>;
template<size_t _Np>
using make_index_sequence = make_integer_sequence<size_t, _Np>;
template<class... _Tp>
using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
template<class _T1, class _T2 = _T1>
inline __attribute__ ((__always_inline__))
_T1 exchange(_T1& __obj, _T2 && __new_value)
{
_T1 __old_value = std::__2::move(__obj);
__obj = std::__2::forward<_T2>(__new_value);
return __old_value;
}
template <class _Arg, class _Result>
struct unary_function
{
typedef _Arg argument_type;
typedef _Result result_type;
};
template <class _Size>
inline __attribute__ ((__always_inline__))
_Size
__loadword(const void* __p)
{
_Size __r;
std::memcpy(&__r, __p, sizeof(__r));
return __r;
}
// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
// is 64 bits. This is because cityhash64 uses 64bit x 64bit
// multiplication, which can be very slow on 32-bit systems.
template <class _Size, size_t = sizeof(_Size)*8>
struct __murmur2_or_cityhash;
template <class _Size>
struct __murmur2_or_cityhash<_Size, 32>
{
inline _Size operator()(const void* __key, _Size __len)
;
};
// murmur2
template <class _Size>
_Size
__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
{
const _Size __m = 0x5bd1e995;
const _Size __r = 24;
_Size __h = __len;
const unsigned char* __data = static_cast<const unsigned char*>(__key);
for (; __len >= 4; __data += 4, __len -= 4)
{
_Size __k = __loadword<_Size>(__data);
__k *= __m;
__k ^= __k >> __r;
__k *= __m;
__h *= __m;
__h ^= __k;
}
switch (__len)
{
case 3:
__h ^= (_Size)(__data[2]) << 16;
case 2:
__h ^= (_Size)(__data[1]) << 8;
case 1:
__h ^= (_Size)(__data[0]);
__h *= __m;
}
__h ^= __h >> 13;
__h *= __m;
__h ^= __h >> 15;
return __h;
}
template <class _Size>
struct __murmur2_or_cityhash<_Size, 64>
{
inline _Size operator()(const void* __key, _Size __len) ;
private:
// Some primes between 2^63 and 2^64.
static const _Size __k0 = 0xc3a5c85c97cb3127ULL;
static const _Size __k1 = 0xb492b66fbe98f273ULL;
static const _Size __k2 = 0x9ae16a3b2f90404fULL;
static const _Size __k3 = 0xc949d7c7509e6557ULL;
static _Size __rotate(_Size __val, int __shift) {
return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift)));
}
static _Size __rotate_by_at_least_1(_Size __val, int __shift) {
return (__val >> __shift) | (__val << (64 - __shift));
}
static _Size __shift_mix(_Size __val) {
return __val ^ (__val >> 47);
}
static _Size __hash_len_16(_Size __u, _Size __v)
{
const _Size __mul = 0x9ddfea08eb382d69ULL;
_Size __a = (__u ^ __v) * __mul;
__a ^= (__a >> 47);
_Size __b = (__v ^ __a) * __mul;
__b ^= (__b >> 47);
__b *= __mul;
return __b;
}
static _Size __hash_len_0_to_16(const char* __s, _Size __len)
{
if (__len > 8) {
const _Size __a = __loadword<_Size>(__s);
const _Size __b = __loadword<_Size>(__s + __len - 8);
return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
}
if (__len >= 4) {
const uint32_t __a = __loadword<uint32_t>(__s);
const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);
return __hash_len_16(__len + (__a << 3), __b);
}
if (__len > 0) {
const unsigned char __a = __s[0];
const unsigned char __b = __s[__len >> 1];
const unsigned char __c = __s[__len - 1];
const uint32_t __y = static_cast<uint32_t>(__a) +
(static_cast<uint32_t>(__b) << 8);
const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2);
return __shift_mix(__y * __k2 ^ __z * __k3) * __k2;
}
return __k2;
}
static _Size __hash_len_17_to_32(const char *__s, _Size __len)
{
const _Size __a = __loadword<_Size>(__s) * __k1;
const _Size __b = __loadword<_Size>(__s + 8);
const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2;
const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0;
return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,
__a + __rotate(__b ^ __k3, 20) - __c + __len);
}
// Return a 16-byte hash for 48 bytes. Quick and dirty.
// Callers do best to use "random-looking" values for a and b.
static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
_Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b)
{
__a += __w;
__b = __rotate(__b + __a + __z, 21);
const _Size __c = __a;
__a += __x;
__a += __y;
__b += __rotate(__a, 44);
return pair<_Size, _Size>(__a + __z, __b + __c);
}
// Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
const char* __s, _Size __a, _Size __b)
{
return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s),
__loadword<_Size>(__s + 8),
__loadword<_Size>(__s + 16),
__loadword<_Size>(__s + 24),
__a,
__b);
}
// Return an 8-byte hash for 33 to 64 bytes.
static _Size __hash_len_33_to_64(const char *__s, size_t __len)
{
_Size __z = __loadword<_Size>(__s + 24);
_Size __a = __loadword<_Size>(__s) +
(__len + __loadword<_Size>(__s + __len - 16)) * __k0;
_Size __b = __rotate(__a + __z, 52);
_Size __c = __rotate(__a, 37);
__a += __loadword<_Size>(__s + 8);
__c += __rotate(__a, 7);
__a += __loadword<_Size>(__s + 16);
_Size __vf = __a + __z;
_Size __vs = __b + __rotate(__a, 31) + __c;
__a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32);
__z += __loadword<_Size>(__s + __len - 8);
__b = __rotate(__a + __z, 52);
__c = __rotate(__a, 37);
__a += __loadword<_Size>(__s + __len - 24);
__c += __rotate(__a, 7);
__a += __loadword<_Size>(__s + __len - 16);
_Size __wf = __a + __z;
_Size __ws = __b + __rotate(__a, 31) + __c;
_Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);
return __shift_mix(__r * __k0 + __vs) * __k2;
}
};
// cityhash64
template <class _Size>
_Size
__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
{
const char* __s = static_cast<const char*>(__key);
if (__len <= 32) {
if (__len <= 16) {
return __hash_len_0_to_16(__s, __len);
} else {
return __hash_len_17_to_32(__s, __len);
}
} else if (__len <= 64) {
return __hash_len_33_to_64(__s, __len);
}
// For strings over 64 bytes we hash the end first, and then as we
// loop we keep 56 bytes of state: v, w, x, y, and z.
_Size __x = __loadword<_Size>(__s + __len - 40);
_Size __y = __loadword<_Size>(__s + __len - 16) +
__loadword<_Size>(__s + __len - 56);
_Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len,
__loadword<_Size>(__s + __len - 24));
pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
__x = __x * __k1 + __loadword<_Size>(__s);
// Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
__len = (__len - 1) & ~static_cast<_Size>(63);
do {
__x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1;
__y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1;
__x ^= __w.second;
__y += __v.first + __loadword<_Size>(__s + 40);
__z = __rotate(__z + __w.first, 33) * __k1;
__v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
__w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
__y + __loadword<_Size>(__s + 16));
std::swap(__z, __x);
__s += 64;
__len -= 64;
} while (__len != 0);
return __hash_len_16(
__hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z,
__hash_len_16(__v.second, __w.second) + __x);
}
// JBN
template <class _Size>
struct __murmur2_or_cityhash<_Size, 16>
{
inline _Size operator()(const void* __key, _Size __len)
;
};
template <class _Size>
_Size
__murmur2_or_cityhash<_Size, 16>::operator()(const void *__key, _Size __len)
{
return __murmur2_or_cityhash<uint32_t>()(__key, __len) & 0x0000ffff;
}
template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
struct __scalar_hash;
template <class _Tp>
struct __scalar_hash<_Tp, 0>
: public unary_function<_Tp, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(_Tp __v) const noexcept
{
union
{
_Tp __t;
size_t __a;
} __u;
__u.__a = 0;
__u.__t = __v;
return __u.__a;
}
};
template <class _Tp>
struct __scalar_hash<_Tp, 1>
: public unary_function<_Tp, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(_Tp __v) const noexcept
{
union
{
_Tp __t;
size_t __a;
} __u;
__u.__t = __v;
return __u.__a;
}
};
template <class _Tp>
struct __scalar_hash<_Tp, 2>
: public unary_function<_Tp, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(_Tp __v) const noexcept
{
union
{
_Tp __t;
struct
{
size_t __a;
size_t __b;
} __s;
} __u;
__u.__t = __v;
return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
}
};
template <class _Tp>
struct __scalar_hash<_Tp, 3>
: public unary_function<_Tp, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(_Tp __v) const noexcept
{
union
{
_Tp __t;
struct
{
size_t __a;
size_t __b;
size_t __c;
} __s;
} __u;
__u.__t = __v;
return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
}
};
template <class _Tp>
struct __scalar_hash<_Tp, 4>
: public unary_function<_Tp, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(_Tp __v) const noexcept
{
union
{
_Tp __t;
struct
{
size_t __a;
size_t __b;
size_t __c;
size_t __d;
} __s;
} __u;
__u.__t = __v;
return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
}
};
struct _PairT {
size_t first;
size_t second;
};
__attribute__ ((__always_inline__))
inline size_t __hash_combine(size_t __lhs, size_t __rhs) noexcept {
typedef __scalar_hash<_PairT> _HashT;
const _PairT __p = {__lhs, __rhs};
return _HashT()(__p);
}
template<class _Tp>
struct hash<_Tp*>
: public unary_function<_Tp*, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(_Tp* __v) const noexcept
{
union
{
_Tp* __t;
size_t __a;
} __u;
__u.__t = __v;
return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
}
};
template <>
struct hash<bool>
: public unary_function<bool, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(bool __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<char>
: public unary_function<char, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(char __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<signed char>
: public unary_function<signed char, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(signed char __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<unsigned char>
: public unary_function<unsigned char, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(unsigned char __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<char16_t>
: public unary_function<char16_t, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(char16_t __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<char32_t>
: public unary_function<char32_t, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(char32_t __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<wchar_t>
: public unary_function<wchar_t, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(wchar_t __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<short>
: public unary_function<short, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(short __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<unsigned short>
: public unary_function<unsigned short, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(unsigned short __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<int>
: public unary_function<int, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(int __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<unsigned int>
: public unary_function<unsigned int, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(unsigned int __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<long>
: public unary_function<long, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(long __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<unsigned long>
: public unary_function<unsigned long, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(unsigned long __v) const noexcept {return static_cast<size_t>(__v);}
};
template <>
struct hash<long long>
: public __scalar_hash<long long>
{
};
template <>
struct hash<unsigned long long>
: public __scalar_hash<unsigned long long>
{
};
template <>
struct hash<float>
: public __scalar_hash<float>
{
__attribute__ ((__always_inline__))
size_t operator()(float __v) const noexcept
{
// -0.0 and 0.0 should return same hash
if (__v == 0)
return 0;
return __scalar_hash<float>::operator()(__v);
}
};
template <>
struct hash<double>
: public __scalar_hash<double>
{
__attribute__ ((__always_inline__))
size_t operator()(double __v) const noexcept
{
// -0.0 and 0.0 should return same hash
if (__v == 0)
return 0;
return __scalar_hash<double>::operator()(__v);
}
};
template <>
struct hash<long double>
: public __scalar_hash<long double>
{
__attribute__ ((__always_inline__))
size_t operator()(long double __v) const noexcept
{
// -0.0 and 0.0 should return same hash
if (__v == 0)
return 0;
return __scalar_hash<long double>::operator()(__v);
}
};
template <class _Tp, bool = is_enum<_Tp>::value>
struct __enum_hash
: public unary_function<_Tp, size_t>
{
__attribute__ ((__always_inline__))
size_t operator()(_Tp __v) const noexcept
{
typedef typename underlying_type<_Tp>::type type;
return hash<type>{}(static_cast<type>(__v));
}
};
template <class _Tp>
struct __enum_hash<_Tp, false> {
__enum_hash() = delete;
__enum_hash(__enum_hash const&) = delete;
__enum_hash& operator=(__enum_hash const&) = delete;
};
template <class _Tp>
struct hash : public __enum_hash<_Tp>
{
};
template <class _Key, class _Hash>
using __check_hash_requirements = integral_constant<bool,
is_copy_constructible<_Hash>::value &&
is_move_constructible<_Hash>::value &&
__invokable_r<size_t, _Hash, _Key const&>::value
>;
template <class _Key, class _Hash = std::hash<_Key> >
using __has_enabled_hash = integral_constant<bool,
__check_hash_requirements<_Key, _Hash>::value &&
is_default_constructible<_Hash>::value
>;
template <class _Type, class ...>
using __enable_hash_helper = _Type;
} }
// -*- C++ -*-
//===-------------------------- memory ------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
memory synopsis
namespace std
{
struct allocator_arg_t { };
constexpr allocator_arg_t allocator_arg = allocator_arg_t();
template <class T, class Alloc> struct uses_allocator;
template <class Ptr>
struct pointer_traits
{
typedef Ptr pointer;
typedef <details> element_type;
typedef <details> difference_type;
template <class U> using rebind = <details>;
static pointer pointer_to(<details>);
};
template <class T>
struct pointer_traits<T*>
{
typedef T* pointer;
typedef T element_type;
typedef ptrdiff_t difference_type;
template <class U> using rebind = U*;
static pointer pointer_to(<details>) noexcept;
};
template <class Alloc>
struct allocator_traits
{
typedef Alloc allocator_type;
typedef typename allocator_type::value_type
value_type;
typedef Alloc::pointer | value_type* pointer;
typedef Alloc::const_pointer
| pointer_traits<pointer>::rebind<const value_type>
const_pointer;
typedef Alloc::void_pointer
| pointer_traits<pointer>::rebind<void>
void_pointer;
typedef Alloc::const_void_pointer
| pointer_traits<pointer>::rebind<const void>
const_void_pointer;
typedef Alloc::difference_type
| pointer_traits<pointer>::difference_type
difference_type;
typedef Alloc::size_type
| make_unsigned<difference_type>::type
size_type;
typedef Alloc::propagate_on_container_copy_assignment
| false_type propagate_on_container_copy_assignment;
typedef Alloc::propagate_on_container_move_assignment
| false_type propagate_on_container_move_assignment;
typedef Alloc::propagate_on_container_swap
| false_type propagate_on_container_swap;
typedef Alloc::is_always_equal
| is_empty is_always_equal;
template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>;
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
static pointer allocate(allocator_type& a, size_type n);
static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;
template <class T, class... Args>
static void construct(allocator_type& a, T* p, Args&&... args);
template <class T>
static void destroy(allocator_type& a, T* p);
static size_type max_size(const allocator_type& a); // noexcept in C++14
static allocator_type
select_on_container_copy_construction(const allocator_type& a);
};
template <>
class allocator<void>
{
public:
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template <class _Up> struct rebind {typedef allocator<_Up> other;};
};
template <class T>
class allocator
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef typename add_lvalue_reference<T>::type reference;
typedef typename add_lvalue_reference<const T>::type const_reference;
typedef T value_type;
template <class U> struct rebind {typedef allocator<U> other;};
allocator() noexcept;
allocator(const allocator&) noexcept;
template <class U> allocator(const allocator<U>&) noexcept;
~allocator();
pointer address(reference x) const noexcept;
const_pointer address(const_reference x) const noexcept;
pointer allocate(size_type, allocator<void>::const_pointer hint = 0);
void deallocate(pointer p, size_type n) noexcept;
size_type max_size() const noexcept;
template<class U, class... Args>
void construct(U* p, Args&&... args);
template <class U>
void destroy(U* p);
};
template <class T, class U>
bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
template <class T, class U>
bool operator!=(const allocator<T>&, const allocator<U>&) noexcept;
template <class OutputIterator, class T>
class raw_storage_iterator
: public iterator<output_iterator_tag,
T, // purposefully not C++03
ptrdiff_t, // purposefully not C++03
T*, // purposefully not C++03
raw_storage_iterator&> // purposefully not C++03
{
public:
explicit raw_storage_iterator(OutputIterator x);
raw_storage_iterator& operator*();
raw_storage_iterator& operator=(const T& element);
raw_storage_iterator& operator++();
raw_storage_iterator operator++(int);
};
template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
template <class T> void return_temporary_buffer(T* p) noexcept;
template <class T> T* addressof(T& r) noexcept;
template <class T> T* addressof(const T&& r) noexcept = delete;
template <class InputIterator, class ForwardIterator>
ForwardIterator
uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
template <class InputIterator, class Size, class ForwardIterator>
ForwardIterator
uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
template <class ForwardIterator, class T>
void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
template <class ForwardIterator, class Size, class T>
ForwardIterator
uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
template <class T>
void destroy_at(T* location);
template <class ForwardIterator>
void destroy(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator destroy_n(ForwardIterator first, Size n);
template <class InputIterator, class ForwardIterator>
ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result);
template <class InputIterator, class Size, class ForwardIterator>
pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result);
template <class ForwardIterator>
void uninitialized_value_construct(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n);
template <class ForwardIterator>
void uninitialized_default_construct(ForwardIterator first, ForwardIterator last);
template <class ForwardIterator, class Size>
ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n);
template <class Y> struct auto_ptr_ref {}; // removed in C++17
template<class X>
class auto_ptr // removed in C++17
{
public:
typedef X element_type;
explicit auto_ptr(X* p =0) throw();
auto_ptr(auto_ptr&) throw();
template<class Y> auto_ptr(auto_ptr<Y>&) throw();
auto_ptr& operator=(auto_ptr&) throw();
template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
auto_ptr& operator=(auto_ptr_ref<X> r) throw();
~auto_ptr() throw();
typename add_lvalue_reference<X>::type operator*() const throw();
X* operator->() const throw();
X* get() const throw();
X* release() throw();
void reset(X* p =0) throw();
auto_ptr(auto_ptr_ref<X>) throw();
template<class Y> operator auto_ptr_ref<Y>() throw();
template<class Y> operator auto_ptr<Y>() throw();
};
template <class T>
struct default_delete
{
constexpr default_delete() noexcept = default;
template <class U> default_delete(const default_delete<U>&) noexcept;
void operator()(T*) const noexcept;
};
template <class T>
struct default_delete<T[]>
{
constexpr default_delete() noexcept = default;
void operator()(T*) const noexcept;
template <class U> void operator()(U*) const = delete;
};
template <class T, class D = default_delete<T>>
class unique_ptr
{
public:
typedef see below pointer;
typedef T element_type;
typedef D deleter_type;
// constructors
constexpr unique_ptr() noexcept;
explicit unique_ptr(pointer p) noexcept;
unique_ptr(pointer p, see below d1) noexcept;
unique_ptr(pointer p, see below d2) noexcept;
unique_ptr(unique_ptr&& u) noexcept;
unique_ptr(nullptr_t) noexcept : unique_ptr() { }
template <class U, class E>
unique_ptr(unique_ptr<U, E>&& u) noexcept;
template <class U>
unique_ptr(auto_ptr<U>&& u) noexcept; // removed in C++17
// destructor
~unique_ptr();
// assignment
unique_ptr& operator=(unique_ptr&& u) noexcept;
template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
unique_ptr& operator=(nullptr_t) noexcept;
// observers
typename add_lvalue_reference<T>::type operator*() const;
pointer operator->() const noexcept;
pointer get() const noexcept;
deleter_type& get_deleter() noexcept;
const deleter_type& get_deleter() const noexcept;
explicit operator bool() const noexcept;
// modifiers
pointer release() noexcept;
void reset(pointer p = pointer()) noexcept;
void swap(unique_ptr& u) noexcept;
};
template <class T, class D>
class unique_ptr<T[], D>
{
public:
typedef implementation-defined pointer;
typedef T element_type;
typedef D deleter_type;
// constructors
constexpr unique_ptr() noexcept;
explicit unique_ptr(pointer p) noexcept;
unique_ptr(pointer p, see below d) noexcept;
unique_ptr(pointer p, see below d) noexcept;
unique_ptr(unique_ptr&& u) noexcept;
unique_ptr(nullptr_t) noexcept : unique_ptr() { }
// destructor
~unique_ptr();
// assignment
unique_ptr& operator=(unique_ptr&& u) noexcept;
unique_ptr& operator=(nullptr_t) noexcept;
// observers
T& operator[](size_t i) const;
pointer get() const noexcept;
deleter_type& get_deleter() noexcept;
const deleter_type& get_deleter() const noexcept;
explicit operator bool() const noexcept;
// modifiers
pointer release() noexcept;
void reset(pointer p = pointer()) noexcept;
void reset(nullptr_t) noexcept;
template <class U> void reset(U) = delete;
void swap(unique_ptr& u) noexcept;
};
template <class T, class D>
void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
template <class T1, class D1, class T2, class D2>
bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
template <class T1, class D1, class T2, class D2>
bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
template <class T1, class D1, class T2, class D2>
bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
template <class T1, class D1, class T2, class D2>
bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
template <class T1, class D1, class T2, class D2>
bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
template <class T1, class D1, class T2, class D2>
bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
template <class T, class D>
bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
template <class T, class D>
bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
template <class T, class D>
bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
template <class T, class D>
bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
template <class T, class D>
bool operator<(const unique_ptr<T, D>& x, nullptr_t);
template <class T, class D>
bool operator<(nullptr_t, const unique_ptr<T, D>& y);
template <class T, class D>
bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
template <class T, class D>
bool operator<=(nullptr_t, const unique_ptr<T, D>& y);
template <class T, class D>
bool operator>(const unique_ptr<T, D>& x, nullptr_t);
template <class T, class D>
bool operator>(nullptr_t, const unique_ptr<T, D>& y);
template <class T, class D>
bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
template <class T, class D>
bool operator>=(nullptr_t, const unique_ptr<T, D>& y);
class bad_weak_ptr
: public std::exception
{
bad_weak_ptr() noexcept;
};
template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args); // C++14
template<class T> unique_ptr<T> make_unique(size_t n); // C++14
template<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N]
template<class T>
class shared_ptr
{
public:
typedef T element_type;
typedef weak_ptr<T> weak_type; // C++17
// constructors:
constexpr shared_ptr() noexcept;
template<class Y> explicit shared_ptr(Y* p);
template<class Y, class D> shared_ptr(Y* p, D d);
template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
template <class D> shared_ptr(nullptr_t p, D d);
template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept;
shared_ptr(const shared_ptr& r) noexcept;
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
shared_ptr(shared_ptr&& r) noexcept;
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
template<class Y> shared_ptr(auto_ptr<Y>&& r); // removed in C++17
template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
shared_ptr(nullptr_t) : shared_ptr() { }
// destructor:
~shared_ptr();
// assignment:
shared_ptr& operator=(const shared_ptr& r) noexcept;
template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept;
shared_ptr& operator=(shared_ptr&& r) noexcept;
template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); // removed in C++17
template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
// modifiers:
void swap(shared_ptr& r) noexcept;
void reset() noexcept;
template<class Y> void reset(Y* p);
template<class Y, class D> void reset(Y* p, D d);
template<class Y, class D, class A> void reset(Y* p, D d, A a);
// observers:
T* get() const noexcept;
T& operator*() const noexcept;
T* operator->() const noexcept;
long use_count() const noexcept;
bool unique() const noexcept;
explicit operator bool() const noexcept;
template<class U> bool owner_before(shared_ptr<U> const& b) const noexcept;
template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept;
};
// shared_ptr comparisons:
template<class T, class U>
bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
template<class T, class U>
bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
template<class T, class U>
bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
template<class T, class U>
bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
template<class T, class U>
bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
template<class T, class U>
bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
template <class T>
bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
template <class T>
bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
template <class T>
bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
template <class T>
bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
template <class T>
bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
template <class T>
bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
template <class T>
bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
template <class T>
bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
template <class T>
bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
template <class T>
bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
template <class T>
bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
template <class T>
bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
// shared_ptr specialized algorithms:
template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
// shared_ptr casts:
template<class T, class U>
shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept;
template<class T, class U>
shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept;
template<class T, class U>
shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept;
// shared_ptr I/O:
template<class E, class T, class Y>
basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
// shared_ptr get_deleter:
template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
template<class T, class... Args>
shared_ptr<T> make_shared(Args&&... args);
template<class T, class A, class... Args>
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
template<class T>
class weak_ptr
{
public:
typedef T element_type;
// constructors
constexpr weak_ptr() noexcept;
template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
weak_ptr(weak_ptr const& r) noexcept;
template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
weak_ptr(weak_ptr&& r) noexcept; // C++14
template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14
// destructor
~weak_ptr();
// assignment
weak_ptr& operator=(weak_ptr const& r) noexcept;
template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14
template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14
// modifiers
void swap(weak_ptr& r) noexcept;
void reset() noexcept;
// observers
long use_count() const noexcept;
bool expired() const noexcept;
shared_ptr<T> lock() const noexcept;
template<class U> bool owner_before(shared_ptr<U> const& b) const noexcept;
template<class U> bool owner_before(weak_ptr<U> const& b) const noexcept;
};
// weak_ptr specialized algorithms:
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
// class owner_less:
template<class T> struct owner_less;
template<class T>
struct owner_less<shared_ptr<T>>
: binary_function<shared_ptr<T>, shared_ptr<T>, bool>
{
typedef bool result_type;
bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const noexcept;
bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept;
bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept;
};
template<class T>
struct owner_less<weak_ptr<T>>
: binary_function<weak_ptr<T>, weak_ptr<T>, bool>
{
typedef bool result_type;
bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const noexcept;
bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const noexcept;
bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const noexcept;
};
template <> // Added in C++14
struct owner_less<void>
{
template <class _Tp, class _Up>
bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept;
template <class _Tp, class _Up>
bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept;
template <class _Tp, class _Up>
bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept;
template <class _Tp, class _Up>
bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept;
typedef void is_transparent;
};
template<class T>
class enable_shared_from_this
{
protected:
constexpr enable_shared_from_this() noexcept;
enable_shared_from_this(enable_shared_from_this const&) noexcept;
enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept;
~enable_shared_from_this();
public:
shared_ptr<T> shared_from_this();
shared_ptr<T const> shared_from_this() const;
};
template<class T>
bool atomic_is_lock_free(const shared_ptr<T>* p);
template<class T>
shared_ptr<T> atomic_load(const shared_ptr<T>* p);
template<class T>
shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
template<class T>
void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
template<class T>
void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
template<class T>
shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
template<class T>
shared_ptr<T>
atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
template<class T>
bool
atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
template<class T>
bool
atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
template<class T>
bool
atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
shared_ptr<T> w, memory_order success,
memory_order failure);
template<class T>
bool
atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
shared_ptr<T> w, memory_order success,
memory_order failure);
// Hash support
template <class T> struct hash;
template <class T, class D> struct hash<unique_ptr<T, D> >;
template <class T> struct hash<shared_ptr<T> >;
// Pointer safety
enum class pointer_safety { relaxed, preferred, strict };
void declare_reachable(void *p);
template <class T> T *undeclare_reachable(T *p);
void declare_no_pointers(char *p, size_t n);
void undeclare_no_pointers(char *p, size_t n);
pointer_safety get_pointer_safety() noexcept;
void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
} // std
*/
// -*- C++ -*-
//===-------------------------- typeinfo ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
typeinfo synopsis
namespace std {
class type_info
{
public:
virtual ~type_info();
bool operator==(const type_info& rhs) const noexcept;
bool operator!=(const type_info& rhs) const noexcept;
bool before(const type_info& rhs) const noexcept;
size_t hash_code() const noexcept;
const char* name() const noexcept;
type_info(const type_info& rhs) = delete;
type_info& operator=(const type_info& rhs) = delete;
};
class bad_cast
: public exception
{
public:
bad_cast() noexcept;
bad_cast(const bad_cast&) noexcept;
bad_cast& operator=(const bad_cast&) noexcept;
virtual const char* what() const noexcept;
};
class bad_typeid
: public exception
{
public:
bad_typeid() noexcept;
bad_typeid(const bad_typeid&) noexcept;
bad_typeid& operator=(const bad_typeid&) noexcept;
virtual const char* what() const noexcept;
};
} // std
*/
namespace std // purposefully not using versioning namespace
{
#pragma define_type_info
class type_info
{
type_info& operator=(const type_info&);
type_info(const type_info&);
protected:
const char *__type_name;
__attribute__ ((__always_inline__))
explicit type_info(const char* __n) : __type_name(__n) {}
public:
virtual ~type_info();
__attribute__ ((__always_inline__))
const char* name() const noexcept
{ return __type_name; }
__attribute__ ((__always_inline__))
bool before(const type_info& __arg) const noexcept
{ return __type_name < __arg.__type_name; }
__attribute__ ((__always_inline__))
size_t hash_code() const noexcept
{ return reinterpret_cast<size_t>(__type_name); }
__attribute__ ((__always_inline__))
bool operator==(const type_info& __arg) const noexcept
{ return __type_name == __arg.__type_name; }
__attribute__ ((__always_inline__))
bool operator!=(const type_info& __arg) const noexcept
{ return !operator==(__arg); }
};
class bad_cast
: public exception
{
public:
bad_cast() noexcept;
virtual ~bad_cast() noexcept;
virtual const char* what() const noexcept;
};
class bad_typeid
: public exception
{
public:
bad_typeid() noexcept;
virtual ~bad_typeid() noexcept;
virtual const char* what() const noexcept;
};
} // std
namespace std { inline namespace __2 {
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_bad_cast()
{
std::__2::abort();
}
} }
// -*- C++ -*-
//===-------------------------- iterator ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
iterator synopsis
namespace std
{
template<class Iterator>
struct iterator_traits
{
typedef typename Iterator::difference_type difference_type;
typedef typename Iterator::value_type value_type;
typedef typename Iterator::pointer pointer;
typedef typename Iterator::reference reference;
typedef typename Iterator::iterator_category iterator_category;
};
template<class T>
struct iterator_traits<T*>
{
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef random_access_iterator_tag iterator_category;
};
template<class T>
struct iterator_traits<const T*>
{
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef const T* pointer;
typedef const T& reference;
typedef random_access_iterator_tag iterator_category;
};
template<class Category, class T, class Distance = ptrdiff_t,
class Pointer = T*, class Reference = T&>
struct iterator
{
typedef T value_type;
typedef Distance difference_type;
typedef Pointer pointer;
typedef Reference reference;
typedef Category iterator_category;
};
struct input_iterator_tag {};
struct output_iterator_tag {};
struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
// 27.4.3, iterator operations
// extension: second argument not conforming to C++03
template <class InputIterator> // constexpr in C++17
constexpr void advance(InputIterator& i,
typename iterator_traits<InputIterator>::difference_type n);
template <class InputIterator> // constexpr in C++17
constexpr typename iterator_traits<InputIterator>::difference_type
distance(InputIterator first, InputIterator last);
template <class InputIterator> // constexpr in C++17
constexpr InputIterator next(InputIterator x,
typename iterator_traits<InputIterator>::difference_type n = 1);
template <class BidirectionalIterator> // constexpr in C++17
constexpr BidirectionalIterator prev(BidirectionalIterator x,
typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
template <class Iterator>
class reverse_iterator
: public iterator<typename iterator_traits<Iterator>::iterator_category,
typename iterator_traits<Iterator>::value_type,
typename iterator_traits<Iterator>::difference_type,
typename iterator_traits<Iterator>::pointer,
typename iterator_traits<Iterator>::reference>
{
protected:
Iterator current;
public:
typedef Iterator iterator_type;
typedef typename iterator_traits<Iterator>::difference_type difference_type;
typedef typename iterator_traits<Iterator>::reference reference;
typedef typename iterator_traits<Iterator>::pointer pointer;
constexpr reverse_iterator();
constexpr explicit reverse_iterator(Iterator x);
template <class U> constexpr reverse_iterator(const reverse_iterator<U>& u);
template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u);
constexpr Iterator base() const;
constexpr reference operator*() const;
constexpr pointer operator->() const;
constexpr reverse_iterator& operator++();
constexpr reverse_iterator operator++(int);
constexpr reverse_iterator& operator--();
constexpr reverse_iterator operator--(int);
constexpr reverse_iterator operator+ (difference_type n) const;
constexpr reverse_iterator& operator+=(difference_type n);
constexpr reverse_iterator operator- (difference_type n) const;
constexpr reverse_iterator& operator-=(difference_type n);
constexpr reference operator[](difference_type n) const;
};
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr auto
operator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y)
-> decltype(__y.base() - __x.base()); // constexpr in C++17
template <class Iterator>
constexpr reverse_iterator<Iterator>
operator+(typename reverse_iterator<Iterator>::difference_type n,
const reverse_iterator<Iterator>& x); // constexpr in C++17
template <class Iterator>
constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17
template <class Container>
class back_insert_iterator
{
protected:
Container* container;
public:
typedef Container container_type;
typedef void value_type;
typedef void difference_type;
typedef void reference;
typedef void pointer;
explicit back_insert_iterator(Container& x);
back_insert_iterator& operator=(const typename Container::value_type& value);
back_insert_iterator& operator*();
back_insert_iterator& operator++();
back_insert_iterator operator++(int);
};
template <class Container> back_insert_iterator<Container> back_inserter(Container& x);
template <class Container>
class front_insert_iterator
{
protected:
Container* container;
public:
typedef Container container_type;
typedef void value_type;
typedef void difference_type;
typedef void reference;
typedef void pointer;
explicit front_insert_iterator(Container& x);
front_insert_iterator& operator=(const typename Container::value_type& value);
front_insert_iterator& operator*();
front_insert_iterator& operator++();
front_insert_iterator operator++(int);
};
template <class Container> front_insert_iterator<Container> front_inserter(Container& x);
template <class Container>
class insert_iterator
{
protected:
Container* container;
typename Container::iterator iter;
public:
typedef Container container_type;
typedef void value_type;
typedef void difference_type;
typedef void reference;
typedef void pointer;
insert_iterator(Container& x, typename Container::iterator i);
insert_iterator& operator=(const typename Container::value_type& value);
insert_iterator& operator*();
insert_iterator& operator++();
insert_iterator& operator++(int);
};
template <class Container, class Iterator>
insert_iterator<Container> inserter(Container& x, Iterator i);
template <class Iterator>
class move_iterator {
public:
typedef Iterator iterator_type;
typedef typename iterator_traits<Iterator>::difference_type difference_type;
typedef Iterator pointer;
typedef typename iterator_traits<Iterator>::value_type value_type;
typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
typedef value_type&& reference;
constexpr move_iterator(); // all the constexprs are in C++17
constexpr explicit move_iterator(Iterator i);
template <class U>
constexpr move_iterator(const move_iterator<U>& u);
template <class U>
constexpr move_iterator& operator=(const move_iterator<U>& u);
constexpr iterator_type base() const;
constexpr reference operator*() const;
constexpr pointer operator->() const;
constexpr move_iterator& operator++();
constexpr move_iterator operator++(int);
constexpr move_iterator& operator--();
constexpr move_iterator operator--(int);
constexpr move_iterator operator+(difference_type n) const;
constexpr move_iterator& operator+=(difference_type n);
constexpr move_iterator operator-(difference_type n) const;
constexpr move_iterator& operator-=(difference_type n);
constexpr unspecified operator[](difference_type n) const;
private:
Iterator current; // exposition only
};
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator==(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator!=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator<(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator<=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator>(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr bool // constexpr in C++17
operator>=(const move_iterator<Iterator1>& x, const move_iterator<Iterator2>& y);
template <class Iterator1, class Iterator2>
constexpr auto // constexpr in C++17
operator-(const move_iterator<Iterator1>& x,
const move_iterator<Iterator2>& y) -> decltype(x.base() - y.base());
template <class Iterator>
constexpr move_iterator<Iterator> operator+( // constexpr in C++17
typename move_iterator<Iterator>::difference_type n,
const move_iterator<Iterator>& x);
template <class Iterator> // constexpr in C++17
constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i);
template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t>
class istream_iterator
: public iterator<input_iterator_tag, T, Distance, const T*, const T&>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_istream<charT,traits> istream_type;
constexpr istream_iterator();
istream_iterator(istream_type& s);
istream_iterator(const istream_iterator& x);
~istream_iterator();
const T& operator*() const;
const T* operator->() const;
istream_iterator& operator++();
istream_iterator operator++(int);
};
template <class T, class charT, class traits, class Distance>
bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y);
template <class T, class charT, class traits, class Distance>
bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
const istream_iterator<T,charT,traits,Distance>& y);
template <class T, class charT = char, class traits = char_traits<charT> >
class ostream_iterator
: public iterator<output_iterator_tag, void, void, void ,void>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_ostream<charT,traits> ostream_type;
ostream_iterator(ostream_type& s);
ostream_iterator(ostream_type& s, const charT* delimiter);
ostream_iterator(const ostream_iterator& x);
~ostream_iterator();
ostream_iterator& operator=(const T& value);
ostream_iterator& operator*();
ostream_iterator& operator++();
ostream_iterator& operator++(int);
};
template<class charT, class traits = char_traits<charT> >
class istreambuf_iterator
: public iterator<input_iterator_tag, charT,
typename traits::off_type, unspecified,
charT>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef typename traits::int_type int_type;
typedef basic_streambuf<charT,traits> streambuf_type;
typedef basic_istream<charT,traits> istream_type;
istreambuf_iterator() noexcept;
istreambuf_iterator(istream_type& s) noexcept;
istreambuf_iterator(streambuf_type* s) noexcept;
istreambuf_iterator(a-private-type) noexcept;
charT operator*() const;
pointer operator->() const;
istreambuf_iterator& operator++();
a-private-type operator++(int);
bool equal(const istreambuf_iterator& b) const;
};
template <class charT, class traits>
bool operator==(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b);
template <class charT, class traits>
bool operator!=(const istreambuf_iterator<charT,traits>& a,
const istreambuf_iterator<charT,traits>& b);
template <class charT, class traits = char_traits<charT> >
class ostreambuf_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef basic_streambuf<charT,traits> streambuf_type;
typedef basic_ostream<charT,traits> ostream_type;
ostreambuf_iterator(ostream_type& s) noexcept;
ostreambuf_iterator(streambuf_type* s) noexcept;
ostreambuf_iterator& operator=(charT c);
ostreambuf_iterator& operator*();
ostreambuf_iterator& operator++();
ostreambuf_iterator& operator++(int);
bool failed() const noexcept;
};
template <class C> constexpr auto begin(C& c) -> decltype(c.begin());
template <class C> constexpr auto begin(const C& c) -> decltype(c.begin());
template <class C> constexpr auto end(C& c) -> decltype(c.end());
template <class C> constexpr auto end(const C& c) -> decltype(c.end());
template <class T, size_t N> constexpr T* begin(T (&array)[N]);
template <class T, size_t N> constexpr T* end(T (&array)[N]);
template <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c)); // C++14
template <class C> auto constexpr cend(const C& c) -> decltype(std::end(c)); // C++14
template <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14
template <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14
template <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14
template <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14
template <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14
template <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il); // C++14
template <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14
template <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14
template <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14
template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14
// 24.8, container access:
template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17
template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17
template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17
template <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17
template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17
template <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17
} // std
*/
// -*- C++ -*-
//===--------------------------- iosfwd -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
iosfwd synopsis
namespace std
{
template<class charT> struct char_traits;
template<class T> class allocator;
class ios_base;
template <class charT, class traits = char_traits<charT> > class basic_ios;
template <class charT, class traits = char_traits<charT> > class basic_streambuf;
template <class charT, class traits = char_traits<charT> > class basic_istream;
template <class charT, class traits = char_traits<charT> > class basic_ostream;
template <class charT, class traits = char_traits<charT> > class basic_iostream;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringbuf;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_istringstream;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_ostringstream;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringstream;
template <class charT, class traits = char_traits<charT> > class basic_filebuf;
template <class charT, class traits = char_traits<charT> > class basic_ifstream;
template <class charT, class traits = char_traits<charT> > class basic_ofstream;
template <class charT, class traits = char_traits<charT> > class basic_fstream;
template <class charT, class traits = char_traits<charT> > class istreambuf_iterator;
template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
typedef basic_ios<char> ios;
typedef basic_ios<wchar_t> wios;
typedef basic_streambuf<char> streambuf;
typedef basic_istream<char> istream;
typedef basic_ostream<char> ostream;
typedef basic_iostream<char> iostream;
typedef basic_stringbuf<char> stringbuf;
typedef basic_istringstream<char> istringstream;
typedef basic_ostringstream<char> ostringstream;
typedef basic_stringstream<char> stringstream;
typedef basic_filebuf<char> filebuf;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
typedef basic_fstream<char> fstream;
typedef basic_streambuf<wchar_t> wstreambuf;
typedef basic_istream<wchar_t> wistream;
typedef basic_ostream<wchar_t> wostream;
typedef basic_iostream<wchar_t> wiostream;
typedef basic_stringbuf<wchar_t> wstringbuf;
typedef basic_istringstream<wchar_t> wistringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
typedef basic_stringstream<wchar_t> wstringstream;
typedef basic_filebuf<wchar_t> wfilebuf;
typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
template <class state> class fpos;
typedef fpos<char_traits<char>::state_type> streampos;
typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
} // std
*/
/* -*- C++ -*- */
/*===--------------------------- complex.h --------------------------------===*/
/* */
/* The LLVM Compiler Infrastructure */
/* */
/* This file is dual licensed under the MIT and the University of Illinois Open
** Source Licenses. See LICENSE.TXT for details.
*/
/*===----------------------------------------------------------------------===*/
/*
wchar.h synopsis
Macros:
NULL
WCHAR_MAX
WCHAR_MIN
WEOF
Types:
mbstate_t
size_t
tm
wint_t
int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99
int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99
int vwprintf(const wchar_t* restrict format, va_list arg);
int vwscanf(const wchar_t* restrict format, va_list arg); // C99
int wprintf(const wchar_t* restrict format, ...);
int wscanf(const wchar_t* restrict format, ...);
wint_t fgetwc(FILE* stream);
wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
wint_t fputwc(wchar_t c, FILE* stream);
int fputws(const wchar_t* restrict s, FILE* restrict stream);
int fwide(FILE* stream, int mode);
wint_t getwc(FILE* stream);
wint_t getwchar();
wint_t putwc(wchar_t c, FILE* stream);
wint_t putwchar(wchar_t c);
wint_t ungetwc(wint_t c, FILE* stream);
double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
int wcscmp(const wchar_t* s1, const wchar_t* s2);
int wcscoll(const wchar_t* s1, const wchar_t* s2);
int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
const wchar_t* wcschr(const wchar_t* s, wchar_t c);
wchar_t* wcschr( wchar_t* s, wchar_t c);
size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
size_t wcslen(const wchar_t* s);
const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2);
const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
wchar_t* wcsrchr( wchar_t* s, wchar_t c);
size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2);
wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n);
int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
const tm* restrict timeptr);
wint_t btowc(int c);
int wctob(wint_t c);
int mbsinit(const mbstate_t* ps);
size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
mbstate_t* restrict ps);
size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
mbstate_t* restrict ps);
*/
/*-
* SPDX-License-Identifier: (BSD-2-Clause AND BSD-2-Clause-NetBSD)
*
* Copyright (c)1999 Citrus Project,
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Julian Coleman.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*
* $NetBSD: wchar.h,v 1.8 2000/12/22 05:31:42 itojun Exp $
*/
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2003 Marcel Moolenaar
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
* $FreeBSD$
*/
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 1988, 1993
* The 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.
*
* @(#)limits.h 8.3 (Berkeley) 1/4/94
* $FreeBSD$
*/
/*
* According to ANSI (section 2.2.4.2), the values below must be usable by
* #if preprocessing directives. Additionally, the expression must have the
* same type as would an expression that is an object of the corresponding
* type converted according to the integral promotions. The subtraction for
* INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
* unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
*/
/* max value for an unsigned long long */
/* Quads and long longs are the same size. Ensure they stay in sync. */
/* Minimum signal stack size. */
typedef __mbstate_t mbstate_t;
typedef __wint_t wint_t;
struct tm;
extern "C" {
wint_t btowc(int);
wint_t fgetwc(FILE *);
wchar_t *
fgetws(wchar_t * __restrict, int, FILE * __restrict);
wint_t fputwc(wchar_t, FILE *);
int fputws(const wchar_t * __restrict, FILE * __restrict);
int fwide(FILE *, int);
int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
wint_t getwc(FILE *);
wint_t getwchar(void);
size_t mbrlen(const char * __restrict, size_t, mbstate_t * __restrict);
size_t mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
mbstate_t * __restrict);
int mbsinit(const mbstate_t *);
size_t mbsrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
mbstate_t * __restrict);
wint_t putwc(wchar_t, FILE *);
wint_t putwchar(wchar_t);
int swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
...);
int swscanf(const wchar_t * __restrict, const wchar_t * __restrict, ...);
wint_t ungetwc(wint_t, FILE *);
int vfwprintf(FILE * __restrict, const wchar_t * __restrict,
__va_list);
int vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
__va_list);
int vwprintf(const wchar_t * __restrict, __va_list);
size_t wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
wchar_t *wcscat(wchar_t * __restrict, const wchar_t * __restrict);
wchar_t *wcschr(const wchar_t *, wchar_t) ;
int wcscmp(const wchar_t *, const wchar_t *) ;
int wcscoll(const wchar_t *, const wchar_t *);
wchar_t *wcscpy(wchar_t * __restrict, const wchar_t * __restrict);
size_t wcscspn(const wchar_t *, const wchar_t *) ;
size_t wcsftime(wchar_t * __restrict, size_t, const wchar_t * __restrict,
const struct tm * __restrict);
size_t wcslen(const wchar_t *) ;
wchar_t *wcsncat(wchar_t * __restrict, const wchar_t * __restrict,
size_t);
int wcsncmp(const wchar_t *, const wchar_t *, size_t) ;
wchar_t *wcsncpy(wchar_t * __restrict , const wchar_t * __restrict, size_t);
wchar_t *wcspbrk(const wchar_t *, const wchar_t *) ;
wchar_t *wcsrchr(const wchar_t *, wchar_t) ;
size_t wcsrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
mbstate_t * __restrict);
size_t wcsspn(const wchar_t *, const wchar_t *) ;
wchar_t *wcsstr(const wchar_t * __restrict, const wchar_t * __restrict)
;
size_t wcsxfrm(wchar_t * __restrict, const wchar_t * __restrict, size_t);
int wctob(wint_t);
double wcstod(const wchar_t * __restrict, wchar_t ** __restrict);
wchar_t *wcstok(wchar_t * __restrict, const wchar_t * __restrict,
wchar_t ** __restrict);
long wcstol(const wchar_t * __restrict, wchar_t ** __restrict, int);
unsigned long
wcstoul(const wchar_t * __restrict, wchar_t ** __restrict, int);
wchar_t *wmemchr(const wchar_t *, wchar_t, size_t) ;
int wmemcmp(const wchar_t *, const wchar_t *, size_t) ;
wchar_t *wmemcpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
wchar_t *wmemset(wchar_t *, wchar_t, size_t);
int wprintf(const wchar_t * __restrict, ...);
int wscanf(const wchar_t * __restrict, ...);
extern FILE *__stdinp;
extern FILE *__stdoutp;
extern FILE *__stderrp;
int vfwscanf(FILE * __restrict, const wchar_t * __restrict,
__va_list);
int vswscanf(const wchar_t * __restrict, const wchar_t * __restrict,
__va_list);
int vwscanf(const wchar_t * __restrict, __va_list);
float wcstof(const wchar_t * __restrict, wchar_t ** __restrict);
long double
wcstold(const wchar_t * __restrict, wchar_t ** __restrict);
/* LONGLONG */
long long
wcstoll(const wchar_t * __restrict, wchar_t ** __restrict, int);
/* LONGLONG */
unsigned long long
wcstoull(const wchar_t * __restrict, wchar_t ** __restrict, int);
int wcswidth(const wchar_t *, size_t);
int wcwidth(wchar_t);
size_t mbsnrtowcs(wchar_t * __restrict, const char ** __restrict, size_t,
size_t, mbstate_t * __restrict);
FILE *open_wmemstream(wchar_t **, size_t *);
wchar_t *wcpcpy(wchar_t * __restrict, const wchar_t * __restrict);
wchar_t *wcpncpy(wchar_t * __restrict, const wchar_t * __restrict, size_t);
wchar_t *wcsdup(const wchar_t *) ;
int wcscasecmp(const wchar_t *, const wchar_t *);
int wcsncasecmp(const wchar_t *, const wchar_t *, size_t n);
size_t wcsnlen(const wchar_t *, size_t) ;
size_t wcsnrtombs(char * __restrict, const wchar_t ** __restrict, size_t,
size_t, mbstate_t * __restrict);
wchar_t *fgetwln(FILE * __restrict, size_t * __restrict);
size_t wcslcat(wchar_t *, const wchar_t *, size_t);
size_t wcslcpy(wchar_t *, const wchar_t *, size_t);
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2011, 2012 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by David Chisnall under sponsorship from
* the FreeBSD Foundation.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
* $FreeBSD$
*/
typedef struct _xlocale *locale_t;
int wcscasecmp_l(const wchar_t *, const wchar_t *,
locale_t);
int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t,
locale_t);
int wcscoll_l(const wchar_t *, const wchar_t *, locale_t);
size_t wcsxfrm_l(wchar_t * __restrict,
const wchar_t * __restrict, size_t, locale_t);
/*
* Only declare the non-POSIX functions if we're included from xlocale.h.
*/
}
/* Determine whether we have const-correct overloads for wcschr and friends. */
namespace std { inline namespace __2 {
class ios_base;
template<class _CharT> struct char_traits;
template<class _Tp> class allocator;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_ios;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_streambuf;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_istream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_ostream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_iostream;
template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_stringbuf;
template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_istringstream;
template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_ostringstream;
template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_stringstream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_filebuf;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_ifstream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_ofstream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class basic_fstream;
template <class _CharT, class _Traits = char_traits<_CharT> >
class istreambuf_iterator;
template <class _CharT, class _Traits = char_traits<_CharT> >
class ostreambuf_iterator;
typedef basic_ios<char> ios;
typedef basic_ios<wchar_t> wios;
typedef basic_streambuf<char> streambuf;
typedef basic_istream<char> istream;
typedef basic_ostream<char> ostream;
typedef basic_iostream<char> iostream;
typedef basic_stringbuf<char> stringbuf;
typedef basic_istringstream<char> istringstream;
typedef basic_ostringstream<char> ostringstream;
typedef basic_stringstream<char> stringstream;
typedef basic_filebuf<char> filebuf;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
typedef basic_fstream<char> fstream;
typedef basic_streambuf<wchar_t> wstreambuf;
typedef basic_istream<wchar_t> wistream;
typedef basic_ostream<wchar_t> wostream;
typedef basic_iostream<wchar_t> wiostream;
typedef basic_stringbuf<wchar_t> wstringbuf;
typedef basic_istringstream<wchar_t> wistringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
typedef basic_stringstream<wchar_t> wstringstream;
typedef basic_filebuf<wchar_t> wfilebuf;
typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
template <class _State> class fpos;
typedef fpos<mbstate_t> streampos;
typedef fpos<mbstate_t> wstreampos;
typedef fpos<mbstate_t> u16streampos;
typedef fpos<mbstate_t> u32streampos;
typedef long long streamoff; // for char_traits in <string>
template <class _CharT, // for <stdexcept>
class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> >
class basic_string;
typedef basic_string<char, char_traits<char>, allocator<char> > string;
typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
// Include other forward declarations here
template <class _Tp, class _Alloc = allocator<_Tp> >
class vector;
} }
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
namespace std { inline namespace __2 {
template <class _Arg1, class _Arg2, class _Result>
struct binary_function
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
};
template <class _Tp>
struct __has_result_type
{
private:
struct __two {char __lx; char __lxx;};
template <class _Up> static __two __test(...);
template <class _Up> static char __test(typename _Up::result_type* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
template <class _Tp = void>
struct less : binary_function<_Tp, _Tp, bool>
{
constexpr __attribute__ ((__always_inline__))
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x < __y;}
};
template <>
struct less<void>
{
template <class _T1, class _T2>
constexpr __attribute__ ((__always_inline__))
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(std::__2::forward<_T1>(__t) < std::__2::forward<_T2>(__u)))
-> decltype (std::__2::forward<_T1>(__t) < std::__2::forward<_T2>(__u))
{ return std::__2::forward<_T1>(__t) < std::__2::forward<_T2>(__u); }
typedef void is_transparent;
};
// __weak_result_type
template <class _Tp>
struct __derives_from_unary_function
{
private:
struct __two {char __lx; char __lxx;};
static __two __test(...);
template <class _Ap, class _Rp>
static unary_function<_Ap, _Rp>
__test(const volatile unary_function<_Ap, _Rp>*);
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
};
template <class _Tp>
struct __derives_from_binary_function
{
private:
struct __two {char __lx; char __lxx;};
static __two __test(...);
template <class _A1, class _A2, class _Rp>
static binary_function<_A1, _A2, _Rp>
__test(const volatile binary_function<_A1, _A2, _Rp>*);
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
};
template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
struct __maybe_derive_from_unary_function // bool is true
: public __derives_from_unary_function<_Tp>::type
{
};
template <class _Tp>
struct __maybe_derive_from_unary_function<_Tp, false>
{
};
template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
struct __maybe_derive_from_binary_function // bool is true
: public __derives_from_binary_function<_Tp>::type
{
};
template <class _Tp>
struct __maybe_derive_from_binary_function<_Tp, false>
{
};
template <class _Tp, bool = __has_result_type<_Tp>::value>
struct __weak_result_type_imp // bool is true
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp>
{
typedef typename _Tp::result_type result_type;
};
template <class _Tp>
struct __weak_result_type_imp<_Tp, false>
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp>
{
};
template <class _Tp>
struct __weak_result_type
: public __weak_result_type_imp<_Tp>
{
};
// 0 argument case
template <class _Rp>
struct __weak_result_type<_Rp ()>
{
typedef _Rp result_type;
};
template <class _Rp>
struct __weak_result_type<_Rp (&)()>
{
typedef _Rp result_type;
};
template <class _Rp>
struct __weak_result_type<_Rp (*)()>
{
typedef _Rp result_type;
};
// 1 argument case
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (_A1)>
: public unary_function<_A1, _Rp>
{
};
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (&)(_A1)>
: public unary_function<_A1, _Rp>
{
};
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (*)(_A1)>
: public unary_function<_A1, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)()>
: public unary_function<_Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() const>
: public unary_function<const _Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() volatile>
: public unary_function<volatile _Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() const volatile>
: public unary_function<const volatile _Cp*, _Rp>
{
};
// 2 argument case
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (_A1, _A2)>
: public binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (*)(_A1, _A2)>
: public binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (&)(_A1, _A2)>
: public binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1)>
: public binary_function<_Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
: public binary_function<const _Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
: public binary_function<volatile _Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
: public binary_function<const volatile _Cp*, _A1, _Rp>
{
};
// 3 or more arguments
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
{
typedef _Rp result_type;
};
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
{
typedef _Rp result_type;
};
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
{
typedef _Rp result_type;
};
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
{
typedef _Rp result_type;
};
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
{
typedef _Rp result_type;
};
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
{
typedef _Rp result_type;
};
template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
{
typedef _Rp result_type;
};
template <class _Tp, class ..._Args>
struct __invoke_return
{
typedef decltype(__invoke(std::__2::declval<_Tp>(), std::__2::declval<_Args>()...)) type;
};
template <class _Ret>
struct __invoke_void_return_wrapper
{
template <class ..._Args>
static _Ret __call(_Args&&... __args) {
return __invoke(std::__2::forward<_Args>(__args)...);
}
};
template <>
struct __invoke_void_return_wrapper<void>
{
template <class ..._Args>
static void __call(_Args&&... __args) {
__invoke(std::__2::forward<_Args>(__args)...);
}
};
template <class _Tp>
class reference_wrapper
: public __weak_result_type<_Tp>
{
public:
// types
typedef _Tp type;
private:
type* __f_;
public:
// construct/copy/destroy
__attribute__ ((__always_inline__)) reference_wrapper(type& __f) noexcept
: __f_(std::__2::addressof(__f)) {}
private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
// access
__attribute__ ((__always_inline__)) operator type& () const noexcept {return *__f_;}
__attribute__ ((__always_inline__)) type& get() const noexcept {return *__f_;}
// invoke
template <class... _ArgTypes>
__attribute__ ((__always_inline__))
typename __invoke_of<type&, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
return __invoke(get(), std::__2::forward<_ArgTypes>(__args)...);
}
};
template <class _Tp>
inline __attribute__ ((__always_inline__))
reference_wrapper<_Tp>
ref(_Tp& __t) noexcept
{
return reference_wrapper<_Tp>(__t);
}
template <class _Tp>
inline __attribute__ ((__always_inline__))
reference_wrapper<_Tp>
ref(reference_wrapper<_Tp> __t) noexcept
{
return ref(__t.get());
}
template <class _Tp>
inline __attribute__ ((__always_inline__))
reference_wrapper<const _Tp>
cref(const _Tp& __t) noexcept
{
return reference_wrapper<const _Tp>(__t);
}
template <class _Tp>
inline __attribute__ ((__always_inline__))
reference_wrapper<const _Tp>
cref(reference_wrapper<_Tp> __t) noexcept
{
return cref(__t.get());
}
template <class _Tp> void ref(const _Tp&&) = delete;
template <class _Tp> void cref(const _Tp&&) = delete;
template <class _Tp, class, class = void>
struct __is_transparent : false_type {};
template <class _Tp, class _Up>
struct __is_transparent<_Tp, _Up,
typename __void_t<typename _Tp::is_transparent>::type>
: true_type {};
// allocator_arg_t
struct allocator_arg_t { };
constexpr allocator_arg_t allocator_arg = allocator_arg_t();
// uses_allocator
template <class _Tp>
struct __has_allocator_type
{
private:
struct __two {char __lx; char __lxx;};
template <class _Up> static __two __test(...);
template <class _Up> static char __test(typename _Up::allocator_type* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
struct __uses_allocator
: public integral_constant<bool,
is_convertible<_Alloc, typename _Tp::allocator_type>::value>
{
};
template <class _Tp, class _Alloc>
struct __uses_allocator<_Tp, _Alloc, false>
: public false_type
{
};
template <class _Tp, class _Alloc>
struct uses_allocator
: public __uses_allocator<_Tp, _Alloc>
{
};
// allocator construction
template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor_imp
{
typedef typename __uncvref<_Alloc>::type _RawAlloc;
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
static const bool __ic =
is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
static const int value = __ua ? 2 - __ic : 0;
};
template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor
: integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
{};
template <class _Tp, class _Allocator, class... _Args>
inline __attribute__ ((__always_inline__))
void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
{
new (__storage) _Tp (std::__2::forward<_Args>(__args)...);
}
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline __attribute__ ((__always_inline__))
void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
{
new (__storage) _Tp (allocator_arg, __a, std::__2::forward<_Args>(__args)...);
}
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline __attribute__ ((__always_inline__))
void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
{
new (__storage) _Tp (std::__2::forward<_Args>(__args)..., __a);
}
// FIXME: Theis should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args>
inline __attribute__ ((__always_inline__))
void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args)
{
__user_alloc_construct_impl(
__uses_alloc_ctor<_Tp, _Allocator>(),
__storage, __a, std::__2::forward<_Args>(__args)...
);
}
} }
namespace std { inline namespace __2 {
struct input_iterator_tag {};
struct output_iterator_tag {};
struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
template <class _Tp>
struct __has_iterator_category
{
private:
struct __two {char __lx; char __lxx;};
template <class _Up> static __two __test(...);
template <class _Up> static char __test(typename _Up::iterator_category* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
template <class _Iter, bool> struct __iterator_traits_impl {};
template <class _Iter>
struct __iterator_traits_impl<_Iter, true>
{
typedef typename _Iter::difference_type difference_type;
typedef typename _Iter::value_type value_type;
typedef typename _Iter::pointer pointer;
typedef typename _Iter::reference reference;
typedef typename _Iter::iterator_category iterator_category;
};
template <class _Iter, bool> struct __iterator_traits {};
template <class _Iter>
struct __iterator_traits<_Iter, true>
: __iterator_traits_impl
<
_Iter,
is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value
>
{};
// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category
// exists. Else iterator_traits<Iterator> will be an empty class. This is a
// conforming extension which allows some programs to compile and behave as
// the client expects instead of failing at compile time.
template <class _Iter>
struct iterator_traits
: __iterator_traits<_Iter, __has_iterator_category<_Iter>::value> {};
template<class _Tp>
struct iterator_traits<_Tp*>
{
typedef ptrdiff_t difference_type;
typedef typename remove_const<_Tp>::type value_type;
typedef _Tp* pointer;
typedef _Tp& reference;
typedef random_access_iterator_tag iterator_category;
};
template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>
struct __has_iterator_category_convertible_to
: public integral_constant<bool, is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up>::value>
{};
template <class _Tp, class _Up>
struct __has_iterator_category_convertible_to<_Tp, _Up, false> : public false_type {};
template <class _Tp>
struct __is_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {};
template <class _Tp>
struct __is_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {};
template <class _Tp>
struct __is_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {};
template <class _Tp>
struct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
template <class _Tp>
struct __is_exactly_input_iterator
: public integral_constant<bool,
__has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
!__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
template<class _Category, class _Tp, class _Distance = ptrdiff_t,
class _Pointer = _Tp*, class _Reference = _Tp&>
struct iterator
{
typedef _Tp value_type;
typedef _Distance difference_type;
typedef _Pointer pointer;
typedef _Reference reference;
typedef _Category iterator_category;
};
template <class _InputIter>
inline __attribute__ ((__always_inline__))
void __advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag)
{
for (; __n > 0; --__n)
++__i;
}
template <class _BiDirIter>
inline __attribute__ ((__always_inline__))
void __advance(_BiDirIter& __i,
typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag)
{
if (__n >= 0)
for (; __n > 0; --__n)
++__i;
else
for (; __n < 0; ++__n)
--__i;
}
template <class _RandIter>
inline __attribute__ ((__always_inline__))
void __advance(_RandIter& __i,
typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag)
{
__i += __n;
}
template <class _InputIter>
inline __attribute__ ((__always_inline__))
void advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n)
{
__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
}
template <class _InputIter>
inline __attribute__ ((__always_inline__))
typename iterator_traits<_InputIter>::difference_type
__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
{
typename iterator_traits<_InputIter>::difference_type __r(0);
for (; __first != __last; ++__first)
++__r;
return __r;
}
template <class _RandIter>
inline __attribute__ ((__always_inline__))
typename iterator_traits<_RandIter>::difference_type
__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
{
return __last - __first;
}
template <class _InputIter>
inline __attribute__ ((__always_inline__))
typename iterator_traits<_InputIter>::difference_type
distance(_InputIter __first, _InputIter __last)
{
return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
}
template <class _InputIter>
inline __attribute__ ((__always_inline__))
typename enable_if
<
__is_input_iterator<_InputIter>::value,
_InputIter
>::type
next(_InputIter __x,
typename iterator_traits<_InputIter>::difference_type __n = 1)
{
std::__2::advance(__x, __n);
return __x;
}
template <class _BidirectionalIter>
inline __attribute__ ((__always_inline__))
typename enable_if
<
__is_bidirectional_iterator<_BidirectionalIter>::value,
_BidirectionalIter
>::type
prev(_BidirectionalIter __x,
typename iterator_traits<_BidirectionalIter>::difference_type __n = 1)
{
std::__2::advance(__x, -__n);
return __x;
}
template <class _Tp, class = void>
struct __is_stashing_iterator : false_type {};
template <class _Tp>
struct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type>
: true_type {};
template <class _Iter>
class reverse_iterator
: public iterator<typename iterator_traits<_Iter>::iterator_category,
typename iterator_traits<_Iter>::value_type,
typename iterator_traits<_Iter>::difference_type,
typename iterator_traits<_Iter>::pointer,
typename iterator_traits<_Iter>::reference>
{
private:
/*mutable*/ _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break
static_assert(!__is_stashing_iterator<_Iter>::value,
"The specified iterator type cannot be used with reverse_iterator; "
"Using stashing iterators with reverse_iterator causes undefined behavior");
protected:
_Iter current;
public:
typedef _Iter iterator_type;
typedef typename iterator_traits<_Iter>::difference_type difference_type;
typedef typename iterator_traits<_Iter>::reference reference;
typedef typename iterator_traits<_Iter>::pointer pointer;
__attribute__ ((__always_inline__))
reverse_iterator() : __t(), current() {}
__attribute__ ((__always_inline__))
explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
template <class _Up>
__attribute__ ((__always_inline__))
reverse_iterator(const reverse_iterator<_Up>& __u) : __t(__u.base()), current(__u.base()) {}
template <class _Up>
__attribute__ ((__always_inline__))
reverse_iterator& operator=(const reverse_iterator<_Up>& __u)
{ __t = current = __u.base(); return *this; }
__attribute__ ((__always_inline__))
_Iter base() const {return current;}
__attribute__ ((__always_inline__))
reference operator*() const {_Iter __tmp = current; return *--__tmp;}
__attribute__ ((__always_inline__))
pointer operator->() const {return std::__2::addressof(operator*());}
__attribute__ ((__always_inline__))
reverse_iterator& operator++() {--current; return *this;}
__attribute__ ((__always_inline__))
reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;}
__attribute__ ((__always_inline__))
reverse_iterator& operator--() {++current; return *this;}
__attribute__ ((__always_inline__))
reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;}
__attribute__ ((__always_inline__))
reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);}
__attribute__ ((__always_inline__))
reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;}
__attribute__ ((__always_inline__))
reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);}
__attribute__ ((__always_inline__))
reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;}
__attribute__ ((__always_inline__))
reference operator[](difference_type __n) const {return *(*this + __n);}
};
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
{
return __x.base() == __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
{
return __x.base() > __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
{
return __x.base() != __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
{
return __x.base() < __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
{
return __x.base() <= __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
{
return __x.base() >= __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
auto
operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
-> decltype(__y.base() - __x.base())
{
return __y.base() - __x.base();
}
template <class _Iter>
inline __attribute__ ((__always_inline__))
reverse_iterator<_Iter>
operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
{
return reverse_iterator<_Iter>(__x.base() - __n);
}
template <class _Iter>
inline __attribute__ ((__always_inline__))
reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
{
return reverse_iterator<_Iter>(__i);
}
template <class _Container>
class back_insert_iterator
: public iterator<output_iterator_tag,
void,
void,
void,
void>
{
protected:
_Container* container;
public:
typedef _Container container_type;
__attribute__ ((__always_inline__)) explicit back_insert_iterator(_Container& __x) : container(std::__2::addressof(__x)) {}
__attribute__ ((__always_inline__)) back_insert_iterator& operator=(const typename _Container::value_type& __value_)
{container->push_back(__value_); return *this;}
__attribute__ ((__always_inline__)) back_insert_iterator& operator=(typename _Container::value_type&& __value_)
{container->push_back(std::__2::move(__value_)); return *this;}
__attribute__ ((__always_inline__)) back_insert_iterator& operator*() {return *this;}
__attribute__ ((__always_inline__)) back_insert_iterator& operator++() {return *this;}
__attribute__ ((__always_inline__)) back_insert_iterator operator++(int) {return *this;}
};
template <class _Container>
inline __attribute__ ((__always_inline__))
back_insert_iterator<_Container>
back_inserter(_Container& __x)
{
return back_insert_iterator<_Container>(__x);
}
template <class _Container>
class front_insert_iterator
: public iterator<output_iterator_tag,
void,
void,
void,
void>
{
protected:
_Container* container;
public:
typedef _Container container_type;
__attribute__ ((__always_inline__)) explicit front_insert_iterator(_Container& __x) : container(std::__2::addressof(__x)) {}
__attribute__ ((__always_inline__)) front_insert_iterator& operator=(const typename _Container::value_type& __value_)
{container->push_front(__value_); return *this;}
__attribute__ ((__always_inline__)) front_insert_iterator& operator=(typename _Container::value_type&& __value_)
{container->push_front(std::__2::move(__value_)); return *this;}
__attribute__ ((__always_inline__)) front_insert_iterator& operator*() {return *this;}
__attribute__ ((__always_inline__)) front_insert_iterator& operator++() {return *this;}
__attribute__ ((__always_inline__)) front_insert_iterator operator++(int) {return *this;}
};
template <class _Container>
inline __attribute__ ((__always_inline__))
front_insert_iterator<_Container>
front_inserter(_Container& __x)
{
return front_insert_iterator<_Container>(__x);
}
template <class _Container>
class insert_iterator
: public iterator<output_iterator_tag,
void,
void,
void,
void>
{
protected:
_Container* container;
typename _Container::iterator iter;
public:
typedef _Container container_type;
__attribute__ ((__always_inline__)) insert_iterator(_Container& __x, typename _Container::iterator __i)
: container(std::__2::addressof(__x)), iter(__i) {}
__attribute__ ((__always_inline__)) insert_iterator& operator=(const typename _Container::value_type& __value_)
{iter = container->insert(iter, __value_); ++iter; return *this;}
__attribute__ ((__always_inline__)) insert_iterator& operator=(typename _Container::value_type&& __value_)
{iter = container->insert(iter, std::__2::move(__value_)); ++iter; return *this;}
__attribute__ ((__always_inline__)) insert_iterator& operator*() {return *this;}
__attribute__ ((__always_inline__)) insert_iterator& operator++() {return *this;}
__attribute__ ((__always_inline__)) insert_iterator& operator++(int) {return *this;}
};
template <class _Container>
inline __attribute__ ((__always_inline__))
insert_iterator<_Container>
inserter(_Container& __x, typename _Container::iterator __i)
{
return insert_iterator<_Container>(__x, __i);
}
template <class _Tp, class _CharT = char,
class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
class istream_iterator
: public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef basic_istream<_CharT,_Traits> istream_type;
private:
istream_type* __in_stream_;
_Tp __value_;
public:
__attribute__ ((__always_inline__)) constexpr istream_iterator() : __in_stream_(0), __value_() {}
__attribute__ ((__always_inline__)) istream_iterator(istream_type& __s) : __in_stream_(std::__2::addressof(__s))
{
if (!(*__in_stream_ >> __value_))
__in_stream_ = 0;
}
__attribute__ ((__always_inline__)) const _Tp& operator*() const {return __value_;}
__attribute__ ((__always_inline__)) const _Tp* operator->() const {return std::__2::addressof((operator*()));}
__attribute__ ((__always_inline__)) istream_iterator& operator++()
{
if (!(*__in_stream_ >> __value_))
__in_stream_ = 0;
return *this;
}
__attribute__ ((__always_inline__)) istream_iterator operator++(int)
{istream_iterator __t(*this); ++(*this); return __t;}
friend __attribute__ ((__always_inline__))
bool operator==(const istream_iterator& __x, const istream_iterator& __y)
{return __x.__in_stream_ == __y.__in_stream_;}
friend __attribute__ ((__always_inline__))
bool operator!=(const istream_iterator& __x, const istream_iterator& __y)
{return !(__x == __y);}
};
template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
class ostream_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef basic_ostream<_CharT,_Traits> ostream_type;
private:
ostream_type* __out_stream_;
const char_type* __delim_;
public:
__attribute__ ((__always_inline__)) ostream_iterator(ostream_type& __s) noexcept
: __out_stream_(std::__2::addressof(__s)), __delim_(0) {}
__attribute__ ((__always_inline__)) ostream_iterator(ostream_type& __s, const _CharT* __delimiter) noexcept
: __out_stream_(std::__2::addressof(__s)), __delim_(__delimiter) {}
__attribute__ ((__always_inline__)) ostream_iterator& operator=(const _Tp& __value_)
{
*__out_stream_ << __value_;
if (__delim_)
*__out_stream_ << __delim_;
return *this;
}
__attribute__ ((__always_inline__)) ostream_iterator& operator*() {return *this;}
__attribute__ ((__always_inline__)) ostream_iterator& operator++() {return *this;}
__attribute__ ((__always_inline__)) ostream_iterator& operator++(int) {return *this;}
};
template<class _CharT, class _Traits>
class istreambuf_iterator
: public iterator<input_iterator_tag, _CharT,
typename _Traits::off_type, _CharT*,
_CharT>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename _Traits::int_type int_type;
typedef basic_streambuf<_CharT,_Traits> streambuf_type;
typedef basic_istream<_CharT,_Traits> istream_type;
private:
mutable streambuf_type* __sbuf_;
class __proxy
{
char_type __keep_;
streambuf_type* __sbuf_;
__attribute__ ((__always_inline__)) __proxy(char_type __c, streambuf_type* __s)
: __keep_(__c), __sbuf_(__s) {}
friend class istreambuf_iterator;
public:
__attribute__ ((__always_inline__)) char_type operator*() const {return __keep_;}
};
__attribute__ ((__always_inline__))
bool __test_for_eof() const
{
if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))
__sbuf_ = 0;
return __sbuf_ == 0;
}
public:
__attribute__ ((__always_inline__)) constexpr istreambuf_iterator() noexcept : __sbuf_(0) {}
__attribute__ ((__always_inline__)) istreambuf_iterator(istream_type& __s) noexcept
: __sbuf_(__s.rdbuf()) {}
__attribute__ ((__always_inline__)) istreambuf_iterator(streambuf_type* __s) noexcept
: __sbuf_(__s) {}
__attribute__ ((__always_inline__)) istreambuf_iterator(const __proxy& __p) noexcept
: __sbuf_(__p.__sbuf_) {}
__attribute__ ((__always_inline__)) char_type operator*() const
{return static_cast<char_type>(__sbuf_->sgetc());}
__attribute__ ((__always_inline__)) istreambuf_iterator& operator++()
{
__sbuf_->sbumpc();
return *this;
}
__attribute__ ((__always_inline__)) __proxy operator++(int)
{
return __proxy(__sbuf_->sbumpc(), __sbuf_);
}
__attribute__ ((__always_inline__)) bool equal(const istreambuf_iterator& __b) const
{return __test_for_eof() == __b.__test_for_eof();}
};
template <class _CharT, class _Traits>
inline __attribute__ ((__always_inline__))
bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
const istreambuf_iterator<_CharT,_Traits>& __b)
{return __a.equal(__b);}
template <class _CharT, class _Traits>
inline __attribute__ ((__always_inline__))
bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,
const istreambuf_iterator<_CharT,_Traits>& __b)
{return !__a.equal(__b);}
template <class _CharT, class _Traits>
class ostreambuf_iterator
: public iterator<output_iterator_tag, void, void, void, void>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef basic_streambuf<_CharT,_Traits> streambuf_type;
typedef basic_ostream<_CharT,_Traits> ostream_type;
private:
streambuf_type* __sbuf_;
public:
__attribute__ ((__always_inline__)) ostreambuf_iterator(ostream_type& __s) noexcept
: __sbuf_(__s.rdbuf()) {}
__attribute__ ((__always_inline__)) ostreambuf_iterator(streambuf_type* __s) noexcept
: __sbuf_(__s) {}
__attribute__ ((__always_inline__)) ostreambuf_iterator& operator=(_CharT __c)
{
if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
__sbuf_ = 0;
return *this;
}
__attribute__ ((__always_inline__)) ostreambuf_iterator& operator*() {return *this;}
__attribute__ ((__always_inline__)) ostreambuf_iterator& operator++() {return *this;}
__attribute__ ((__always_inline__)) ostreambuf_iterator& operator++(int) {return *this;}
__attribute__ ((__always_inline__)) bool failed() const noexcept {return __sbuf_ == 0;}
template <class _Ch, class _Tr>
friend
ostreambuf_iterator<_Ch, _Tr>
__pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
ios_base& __iob, _Ch __fl);
};
template <class _Iter>
class move_iterator
{
private:
_Iter __i;
public:
typedef _Iter iterator_type;
typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
typedef typename iterator_traits<iterator_type>::value_type value_type;
typedef typename iterator_traits<iterator_type>::difference_type difference_type;
typedef iterator_type pointer;
typedef typename iterator_traits<iterator_type>::reference __reference;
typedef typename conditional<
is_reference<__reference>::value,
typename remove_reference<__reference>::type&&,
__reference
>::type reference;
__attribute__ ((__always_inline__))
move_iterator() : __i() {}
__attribute__ ((__always_inline__))
explicit move_iterator(_Iter __x) : __i(__x) {}
template <class _Up>
__attribute__ ((__always_inline__))
move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {}
__attribute__ ((__always_inline__)) _Iter base() const {return __i;}
__attribute__ ((__always_inline__))
reference operator*() const { return static_cast<reference>(*__i); }
__attribute__ ((__always_inline__))
pointer operator->() const { return __i;}
__attribute__ ((__always_inline__))
move_iterator& operator++() {++__i; return *this;}
__attribute__ ((__always_inline__))
move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;}
__attribute__ ((__always_inline__))
move_iterator& operator--() {--__i; return *this;}
__attribute__ ((__always_inline__))
move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;}
__attribute__ ((__always_inline__))
move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);}
__attribute__ ((__always_inline__))
move_iterator& operator+=(difference_type __n) {__i += __n; return *this;}
__attribute__ ((__always_inline__))
move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);}
__attribute__ ((__always_inline__))
move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;}
__attribute__ ((__always_inline__))
reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); }
};
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() == __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() < __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() != __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() > __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() >= __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
{
return __x.base() <= __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
auto
operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
-> decltype(__x.base() - __y.base())
{
return __x.base() - __y.base();
}
template <class _Iter>
inline __attribute__ ((__always_inline__))
move_iterator<_Iter>
operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
{
return move_iterator<_Iter>(__x.base() + __n);
}
template <class _Iter>
inline __attribute__ ((__always_inline__))
move_iterator<_Iter>
make_move_iterator(_Iter __i)
{
return move_iterator<_Iter>(__i);
}
// __wrap_iter
template <class _Iter> class __wrap_iter;
template <class _Iter1, class _Iter2>
__attribute__ ((__always_inline__))
bool
operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
__attribute__ ((__always_inline__))
bool
operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
__attribute__ ((__always_inline__))
bool
operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
__attribute__ ((__always_inline__))
bool
operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
__attribute__ ((__always_inline__))
bool
operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
__attribute__ ((__always_inline__))
bool
operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
__attribute__ ((__always_inline__))
auto
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
-> decltype(__x.base() - __y.base());
template <class _Iter>
__attribute__ ((__always_inline__))
__wrap_iter<_Iter>
operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) noexcept;
template <class _Ip, class _Op> _Op __attribute__ ((__always_inline__)) copy(_Ip, _Ip, _Op);
template <class _B1, class _B2> _B2 __attribute__ ((__always_inline__)) copy_backward(_B1, _B1, _B2);
template <class _Ip, class _Op> _Op __attribute__ ((__always_inline__)) move(_Ip, _Ip, _Op);
template <class _B1, class _B2> _B2 __attribute__ ((__always_inline__)) move_backward(_B1, _B1, _B2);
template <class _Tp>
__attribute__ ((__always_inline__))
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
_Tp*
>::type
__unwrap_iter(__wrap_iter<_Tp*>);
template <class _Iter>
class __wrap_iter
{
public:
typedef _Iter iterator_type;
typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
typedef typename iterator_traits<iterator_type>::value_type value_type;
typedef typename iterator_traits<iterator_type>::difference_type difference_type;
typedef typename iterator_traits<iterator_type>::pointer pointer;
typedef typename iterator_traits<iterator_type>::reference reference;
private:
iterator_type __i;
public:
__attribute__ ((__always_inline__)) __wrap_iter() noexcept
: __i{}
{
}
template <class _Up> __attribute__ ((__always_inline__)) __wrap_iter(const __wrap_iter<_Up>& __u,
typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) noexcept
: __i(__u.base())
{
}
__attribute__ ((__always_inline__)) reference operator*() const noexcept
{
return *__i;
}
__attribute__ ((__always_inline__)) pointer operator->() const noexcept
{
return (pointer)std::__2::addressof(*__i);
}
__attribute__ ((__always_inline__)) __wrap_iter& operator++() noexcept
{
++__i;
return *this;
}
__attribute__ ((__always_inline__)) __wrap_iter operator++(int) noexcept
{__wrap_iter __tmp(*this); ++(*this); return __tmp;}
__attribute__ ((__always_inline__)) __wrap_iter& operator--() noexcept
{
--__i;
return *this;
}
__attribute__ ((__always_inline__)) __wrap_iter operator--(int) noexcept
{__wrap_iter __tmp(*this); --(*this); return __tmp;}
__attribute__ ((__always_inline__)) __wrap_iter operator+ (difference_type __n) const noexcept
{__wrap_iter __w(*this); __w += __n; return __w;}
__attribute__ ((__always_inline__)) __wrap_iter& operator+=(difference_type __n) noexcept
{
__i += __n;
return *this;
}
__attribute__ ((__always_inline__)) __wrap_iter operator- (difference_type __n) const noexcept
{return *this + (-__n);}
__attribute__ ((__always_inline__)) __wrap_iter& operator-=(difference_type __n) noexcept
{*this += -__n; return *this;}
__attribute__ ((__always_inline__)) reference operator[](difference_type __n) const noexcept
{
return __i[__n];
}
__attribute__ ((__always_inline__)) iterator_type base() const noexcept {return __i;}
private:
__attribute__ ((__always_inline__)) __wrap_iter(iterator_type __x) noexcept : __i(__x) {}
template <class _Up> friend class __wrap_iter;
template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
template <class _Tp, class _Alloc> friend class vector;
template <class _Iter1, class _Iter2>
friend
bool
operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
friend
bool
operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
friend
bool
operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
friend
bool
operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
friend
bool
operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
friend
bool
operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) noexcept;
template <class _Iter1, class _Iter2>
friend
auto
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
-> decltype(__x.base() - __y.base());
template <class _Iter1>
friend
__wrap_iter<_Iter1>
operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) noexcept;
template <class _Ip, class _Op> friend _Op copy(_Ip, _Ip, _Op);
template <class _B1, class _B2> friend _B2 copy_backward(_B1, _B1, _B2);
template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op);
template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2);
template <class _Tp>
friend
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
_Tp*
>::type
__unwrap_iter(__wrap_iter<_Tp*>);
};
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
{
return __x.base() == __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
{
return __x.base() < __y.base();
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
{
return !(__x == __y);
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
{
return __y < __x;
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
{
return !(__x < __y);
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
bool
operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
{
return !(__y < __x);
}
template <class _Iter1>
inline __attribute__ ((__always_inline__))
bool
operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) noexcept
{
return !(__x == __y);
}
template <class _Iter1>
inline __attribute__ ((__always_inline__))
bool
operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) noexcept
{
return __y < __x;
}
template <class _Iter1>
inline __attribute__ ((__always_inline__))
bool
operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) noexcept
{
return !(__x < __y);
}
template <class _Iter1>
inline __attribute__ ((__always_inline__))
bool
operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) noexcept
{
return !(__y < __x);
}
template <class _Iter1, class _Iter2>
inline __attribute__ ((__always_inline__))
auto
operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept
-> decltype(__x.base() - __y.base())
{
return __x.base() - __y.base();
}
template <class _Iter>
inline __attribute__ ((__always_inline__))
__wrap_iter<_Iter>
operator+(typename __wrap_iter<_Iter>::difference_type __n,
__wrap_iter<_Iter> __x) noexcept
{
__x += __n;
return __x;
}
template <class _Iter>
struct __libcpp_is_trivial_iterator
: public integral_constant<bool,(is_pointer<_Iter> ::value)> {};
template <class _Iter>
struct __libcpp_is_trivial_iterator<move_iterator<_Iter> >
: public integral_constant<bool,(__libcpp_is_trivial_iterator<_Iter> ::value)> {};
template <class _Iter>
struct __libcpp_is_trivial_iterator<reverse_iterator<_Iter> >
: public integral_constant<bool,(__libcpp_is_trivial_iterator<_Iter> ::value)> {};
template <class _Iter>
struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> >
: public integral_constant<bool,(__libcpp_is_trivial_iterator<_Iter> ::value)> {};
template <class _Tp, size_t _Np>
inline __attribute__ ((__always_inline__)) constexpr
_Tp*
begin(_Tp (&__array)[_Np])
{
return __array;
}
template <class _Tp, size_t _Np>
inline __attribute__ ((__always_inline__)) constexpr
_Tp*
end(_Tp (&__array)[_Np])
{
return __array + _Np;
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto
begin(_Cp& __c) -> decltype(__c.begin())
{
return __c.begin();
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto
begin(const _Cp& __c) -> decltype(__c.begin())
{
return __c.begin();
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto
end(_Cp& __c) -> decltype(__c.end())
{
return __c.end();
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto
end(const _Cp& __c) -> decltype(__c.end())
{
return __c.end();
}
template <class _Tp, size_t _Np>
inline __attribute__ ((__always_inline__))
reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
{
return reverse_iterator<_Tp*>(__array + _Np);
}
template <class _Tp, size_t _Np>
inline __attribute__ ((__always_inline__))
reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
{
return reverse_iterator<_Tp*>(__array);
}
template <class _Ep>
inline __attribute__ ((__always_inline__))
reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
{
return reverse_iterator<const _Ep*>(__il.end());
}
template <class _Ep>
inline __attribute__ ((__always_inline__))
reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
{
return reverse_iterator<const _Ep*>(__il.begin());
}
template <class _Cp>
inline __attribute__ ((__always_inline__)) constexpr
auto cbegin(const _Cp& __c) -> decltype(std::__2::begin(__c))
{
return std::__2::begin(__c);
}
template <class _Cp>
inline __attribute__ ((__always_inline__)) constexpr
auto cend(const _Cp& __c) -> decltype(std::__2::end(__c))
{
return std::__2::end(__c);
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
{
return __c.rbegin();
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
{
return __c.rbegin();
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto rend(_Cp& __c) -> decltype(__c.rend())
{
return __c.rend();
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto rend(const _Cp& __c) -> decltype(__c.rend())
{
return __c.rend();
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto crbegin(const _Cp& __c) -> decltype(std::__2::rbegin(__c))
{
return std::__2::rbegin(__c);
}
template <class _Cp>
inline __attribute__ ((__always_inline__))
auto crend(const _Cp& __c) -> decltype(std::__2::rend(__c))
{
return std::__2::rend(__c);
}
} }
// -*- C++ -*-
//===--------------------------- tuple ------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
tuple synopsis
namespace std
{
template <class... T>
class tuple {
public:
constexpr tuple();
explicit tuple(const T&...); // constexpr in C++14
template <class... U>
explicit tuple(U&&...); // constexpr in C++14
tuple(const tuple&) = default;
tuple(tuple&&) = default;
template <class... U>
tuple(const tuple<U...>&); // constexpr in C++14
template <class... U>
tuple(tuple<U...>&&); // constexpr in C++14
template <class U1, class U2>
tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
template <class U1, class U2>
tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
// allocator-extended constructors
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a);
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, const T&...);
template <class Alloc, class... U>
tuple(allocator_arg_t, const Alloc& a, U&&...);
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, const tuple&);
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, tuple&&);
template <class Alloc, class... U>
tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
template <class Alloc, class... U>
tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
template <class Alloc, class U1, class U2>
tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
template <class Alloc, class U1, class U2>
tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
tuple& operator=(const tuple&);
tuple&
operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
template <class... U>
tuple& operator=(const tuple<U...>&);
template <class... U>
tuple& operator=(tuple<U...>&&);
template <class U1, class U2>
tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
template <class U1, class U2>
tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
};
const unspecified ignore;
template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
// [tuple.apply], calling a function with a tuple of arguments:
template <class F, class Tuple>
constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
template <class T, class Tuple>
constexpr T make_from_tuple(Tuple&& t); // C++17
// 20.4.1.4, tuple helper classes:
template <class T> class tuple_size; // undefined
template <class... T> class tuple_size<tuple<T...>>;
template <class T>
constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
template <size_t I, class T> class tuple_element; // undefined
template <size_t I, class... T> class tuple_element<I, tuple<T...>>;
template <size_t I, class T>
using tuple_element_t = typename tuple_element <I, T>::type; // C++14
// 20.4.1.5, element access:
template <size_t I, class... T>
typename tuple_element<I, tuple<T...>>::type&
get(tuple<T...>&) noexcept; // constexpr in C++14
template <size_t I, class... T>
const typename tuple_element<I, tuple<T...>>::type&
get(const tuple<T...>&) noexcept; // constexpr in C++14
template <size_t I, class... T>
typename tuple_element<I, tuple<T...>>::type&&
get(tuple<T...>&&) noexcept; // constexpr in C++14
template <size_t I, class... T>
const typename tuple_element<I, tuple<T...>>::type&&
get(const tuple<T...>&&) noexcept; // constexpr in C++14
template <class T1, class... T>
constexpr T1& get(tuple<T...>&) noexcept; // C++14
template <class T1, class... T>
constexpr const T1& get(const tuple<T...>&) noexcept; // C++14
template <class T1, class... T>
constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
template <class T1, class... T>
constexpr const T1&& get(const tuple<T...>&&) noexcept; // C++14
// 20.4.1.6, relational operators:
template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
template <class... Types, class Alloc>
struct uses_allocator<tuple<Types...>, Alloc>;
template <class... Types>
void
swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
} // std
*/
namespace std { inline namespace __2 {
// __tuple_leaf
template <size_t _Ip, class _Hp,
bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
>
class __tuple_leaf;
template <size_t _Ip, class _Hp, bool _Ep>
inline __attribute__ ((__always_inline__))
void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
noexcept(__is_nothrow_swappable<_Hp> ::value)
{
swap(__x.get(), __y.get());
}
template <size_t _Ip, class _Hp, bool>
class __tuple_leaf
{
_Hp __value_;
template <class _Tp>
static constexpr bool __can_bind_reference() {
using _RawTp = typename remove_reference<_Tp>::type;
using _RawHp = typename remove_reference<_Hp>::type;
using _CheckLValueArg = integral_constant<bool,
is_lvalue_reference<_Tp>::value
|| is_same<_RawTp, reference_wrapper<_RawHp>>::value
|| is_same<_RawTp, reference_wrapper<typename remove_const<_RawHp>::type>>::value
>;
return !is_reference<_Hp>::value
|| (is_lvalue_reference<_Hp>::value && _CheckLValueArg::value)
|| (is_rvalue_reference<_Hp>::value && !is_lvalue_reference<_Tp>::value);
}
__tuple_leaf& operator=(const __tuple_leaf&);
public:
__attribute__ ((__always_inline__)) constexpr __tuple_leaf()
noexcept(is_nothrow_default_constructible<_Hp> ::value) : __value_()
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
__attribute__ ((__always_inline__))
__tuple_leaf(integral_constant<int, 0>, const _Alloc&)
: __value_()
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
__attribute__ ((__always_inline__))
__tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
: __value_(allocator_arg_t(), __a)
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
__attribute__ ((__always_inline__))
__tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
: __value_(__a)
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Tp,
class = typename enable_if<
__lazy_and<
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
, is_constructible<_Hp, _Tp>
>::value
>::type
>
__attribute__ ((__always_inline__)) constexpr
explicit __tuple_leaf(_Tp&& __t) noexcept((is_nothrow_constructible<_Hp, _Tp> ::value))
: __value_(std::__2::forward<_Tp>(__t))
{static_assert(__can_bind_reference<_Tp>(),
"Attempted to construct a reference element in a tuple with an rvalue");}
template <class _Tp, class _Alloc>
__attribute__ ((__always_inline__))
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
: __value_(std::__2::forward<_Tp>(__t))
{static_assert(__can_bind_reference<_Tp>(),
"Attempted to construct a reference element in a tuple with an rvalue");}
template <class _Tp, class _Alloc>
__attribute__ ((__always_inline__))
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
: __value_(allocator_arg_t(), __a, std::__2::forward<_Tp>(__t))
{static_assert(!is_reference<_Hp>::value,
"Attempted to uses-allocator construct a reference element in a tuple");}
template <class _Tp, class _Alloc>
__attribute__ ((__always_inline__))
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: __value_(std::__2::forward<_Tp>(__t), __a)
{static_assert(!is_reference<_Hp>::value,
"Attempted to uses-allocator construct a reference element in a tuple");}
__tuple_leaf(const __tuple_leaf& __t) = default;
__tuple_leaf(__tuple_leaf&& __t) = default;
template <class _Tp>
__attribute__ ((__always_inline__))
__tuple_leaf&
operator=(_Tp&& __t) noexcept((is_nothrow_assignable<_Hp&, _Tp> ::value))
{
__value_ = std::__2::forward<_Tp>(__t);
return *this;
}
__attribute__ ((__always_inline__))
int swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable<__tuple_leaf> ::value)
{
std::__2::swap(*this, __t);
return 0;
}
__attribute__ ((__always_inline__)) constexpr _Hp& get() noexcept {return __value_;}
__attribute__ ((__always_inline__)) constexpr const _Hp& get() const noexcept {return __value_;}
};
template <size_t _Ip, class _Hp>
class __tuple_leaf<_Ip, _Hp, true>
: private _Hp
{
__tuple_leaf& operator=(const __tuple_leaf&);
public:
__attribute__ ((__always_inline__)) constexpr __tuple_leaf()
noexcept(is_nothrow_default_constructible<_Hp> ::value) {}
template <class _Alloc>
__attribute__ ((__always_inline__))
__tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
template <class _Alloc>
__attribute__ ((__always_inline__))
__tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
: _Hp(allocator_arg_t(), __a) {}
template <class _Alloc>
__attribute__ ((__always_inline__))
__tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
: _Hp(__a) {}
template <class _Tp,
class = typename enable_if<
__lazy_and<
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
, is_constructible<_Hp, _Tp>
>::value
>::type
>
__attribute__ ((__always_inline__)) constexpr
explicit __tuple_leaf(_Tp&& __t) noexcept((is_nothrow_constructible<_Hp, _Tp> ::value))
: _Hp(std::__2::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
__attribute__ ((__always_inline__))
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
: _Hp(std::__2::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
__attribute__ ((__always_inline__))
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
: _Hp(allocator_arg_t(), __a, std::__2::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
__attribute__ ((__always_inline__))
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: _Hp(std::__2::forward<_Tp>(__t), __a) {}
__tuple_leaf(__tuple_leaf const &) = default;
__tuple_leaf(__tuple_leaf &&) = default;
template <class _Tp>
__attribute__ ((__always_inline__))
__tuple_leaf&
operator=(_Tp&& __t) noexcept((is_nothrow_assignable<_Hp&, _Tp> ::value))
{
_Hp::operator=(std::__2::forward<_Tp>(__t));
return *this;
}
__attribute__ ((__always_inline__))
int
swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable<__tuple_leaf> ::value)
{
std::__2::swap(*this, __t);
return 0;
}
__attribute__ ((__always_inline__)) constexpr _Hp& get() noexcept {return static_cast<_Hp&>(*this);}
__attribute__ ((__always_inline__)) constexpr const _Hp& get() const noexcept {return static_cast<const _Hp&>(*this);}
};
template <class ..._Tp>
__attribute__ ((__always_inline__))
void __swallow(_Tp&&...) noexcept {}
template <class ..._Tp>
struct __lazy_all : __all<_Tp::value...> {};
template <class _Tp>
struct __all_default_constructible;
template <class ..._Tp>
struct __all_default_constructible<__tuple_types<_Tp...>>
: __all<is_default_constructible<_Tp>::value...>
{ };
// __tuple_impl
template<class _Indx, class ..._Tp> struct __tuple_impl;
template<size_t ..._Indx, class ..._Tp>
struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
: public __tuple_leaf<_Indx, _Tp>...
{
__attribute__ ((__always_inline__))
constexpr __tuple_impl()
noexcept(__all<is_nothrow_default_constructible<_Tp> ::value ...> ::value) {}
template <size_t ..._Uf, class ..._Tf,
size_t ..._Ul, class ..._Tl, class ..._Up>
__attribute__ ((__always_inline__)) constexpr
explicit
__tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
__tuple_indices<_Ul...>, __tuple_types<_Tl...>,
_Up&&... __u)
noexcept((__all<is_nothrow_constructible<_Tf, _Up> ::value ...> ::value && __all<is_nothrow_default_constructible<_Tl> ::value ...> ::value)) :
__tuple_leaf<_Uf, _Tf>(std::__2::forward<_Up>(__u))...,
__tuple_leaf<_Ul, _Tl>()...
{}
template <class _Alloc, size_t ..._Uf, class ..._Tf,
size_t ..._Ul, class ..._Tl, class ..._Up>
__attribute__ ((__always_inline__))
explicit
__tuple_impl(allocator_arg_t, const _Alloc& __a,
__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
__tuple_indices<_Ul...>, __tuple_types<_Tl...>,
_Up&&... __u) :
__tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
std::__2::forward<_Up>(__u))...,
__tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
{}
template <class _Tuple,
class = typename enable_if
<
__tuple_constructible<_Tuple, tuple<_Tp...> >::value
>::type
>
__attribute__ ((__always_inline__)) constexpr
__tuple_impl(_Tuple&& __t) noexcept((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx, typename __make_tuple_types<_Tuple> ::type> ::type> ::value ...> ::value))
: __tuple_leaf<_Indx, _Tp>(std::__2::forward<typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(std::__2::get<_Indx>(__t)))...
{}
template <class _Alloc, class _Tuple,
class = typename enable_if
<
__tuple_constructible<_Tuple, tuple<_Tp...> >::value
>::type
>
__attribute__ ((__always_inline__))
__tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
: __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(), __a,
std::__2::forward<typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(std::__2::get<_Indx>(__t)))...
{}
template <class _Tuple>
__attribute__ ((__always_inline__))
typename enable_if
<
__tuple_assignable<_Tuple, tuple<_Tp...> >::value,
__tuple_impl&
>::type
operator=(_Tuple&& __t) noexcept((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx, typename __make_tuple_types<_Tuple> ::type> ::type> ::value ...> ::value))
{
__swallow(__tuple_leaf<_Indx, _Tp>::operator=(std::__2::forward<typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(std::__2::get<_Indx>(__t)))...);
return *this;
}
__tuple_impl(const __tuple_impl&) = default;
__tuple_impl(__tuple_impl&&) = default;
__attribute__ ((__always_inline__))
__tuple_impl&
operator=(const __tuple_impl& __t) noexcept((__all<is_nothrow_copy_assignable<_Tp> ::value ...> ::value))
{
__swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
return *this;
}
__attribute__ ((__always_inline__))
__tuple_impl&
operator=(__tuple_impl&& __t) noexcept((__all<is_nothrow_move_assignable<_Tp> ::value ...> ::value))
{
__swallow(__tuple_leaf<_Indx, _Tp>::operator=(std::__2::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
return *this;
}
__attribute__ ((__always_inline__))
void swap(__tuple_impl& __t)
noexcept(__all<__is_nothrow_swappable<_Tp> ::value ...> ::value)
{
__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
}
};
template <class ..._Tp>
class tuple
{
typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
_BaseT __base_;
static constexpr bool _EnableImplicitReducedArityExtension = false;
template <class ..._Args>
struct _PackExpandsToThisTuple : false_type {};
template <class _Arg>
struct _PackExpandsToThisTuple<_Arg>
: is_same<typename __uncvref<_Arg>::type, tuple> {};
template <bool _MaybeEnable, class _Dummy = void>
struct _CheckArgsConstructor : __check_tuple_constructor_fail {};
template <class _Dummy>
struct _CheckArgsConstructor<true, _Dummy>
{
template <class ..._Args>
static constexpr bool __enable_default() {
return __all<is_default_constructible<_Args>::value...>::value;
}
template <class ..._Args>
static constexpr bool __enable_explicit() {
return
__tuple_constructible<
tuple<_Args...>,
typename __make_tuple_types<tuple,
sizeof...(_Args) < sizeof...(_Tp) ?
sizeof...(_Args) :
sizeof...(_Tp)>::type
>::value &&
!__tuple_convertible<
tuple<_Args...>,
typename __make_tuple_types<tuple,
sizeof...(_Args) < sizeof...(_Tp) ?
sizeof...(_Args) :
sizeof...(_Tp)>::type
>::value &&
__all_default_constructible<
typename __make_tuple_types<tuple, sizeof...(_Tp),
sizeof...(_Args) < sizeof...(_Tp) ?
sizeof...(_Args) :
sizeof...(_Tp)>::type
>::value;
}
template <class ..._Args>
static constexpr bool __enable_implicit() {
return
__tuple_convertible<
tuple<_Args...>,
typename __make_tuple_types<tuple,
sizeof...(_Args) < sizeof...(_Tp) ?
sizeof...(_Args) :
sizeof...(_Tp)>::type
>::value &&
__all_default_constructible<
typename __make_tuple_types<tuple, sizeof...(_Tp),
sizeof...(_Args) < sizeof...(_Tp) ?
sizeof...(_Args) :
sizeof...(_Tp)>::type
>::value;
}
};
template <bool _MaybeEnable,
bool = sizeof...(_Tp) == 1,
class _Dummy = void>
struct _CheckTupleLikeConstructor : __check_tuple_constructor_fail {};
template <class _Dummy>
struct _CheckTupleLikeConstructor<true, false, _Dummy>
{
template <class _Tuple>
static constexpr bool __enable_implicit() {
return __tuple_convertible<_Tuple, tuple>::value;
}
template <class _Tuple>
static constexpr bool __enable_explicit() {
return __tuple_constructible<_Tuple, tuple>::value
&& !__tuple_convertible<_Tuple, tuple>::value;
}
};
template <class _Dummy>
struct _CheckTupleLikeConstructor<true, true, _Dummy>
{
// This trait is used to disable the tuple-like constructor when
// the UTypes... constructor should be selected instead.
// See LWG issue #2549.
template <class _Tuple>
using _PreferTupleLikeConstructor = __lazy_or<
// Don't attempt the two checks below if the tuple we are given
// has the same type as this tuple.
is_same<typename __uncvref<_Tuple>::type, tuple>,
__lazy_and<
__lazy_not<is_constructible<_Tp..., _Tuple>>,
__lazy_not<is_convertible<_Tuple, _Tp...>>
>
>;
template <class _Tuple>
static constexpr bool __enable_implicit() {
return __lazy_and<
__tuple_convertible<_Tuple, tuple>,
_PreferTupleLikeConstructor<_Tuple>
>::value;
}
template <class _Tuple>
static constexpr bool __enable_explicit() {
return __lazy_and<
__tuple_constructible<_Tuple, tuple>,
_PreferTupleLikeConstructor<_Tuple>,
__lazy_not<__tuple_convertible<_Tuple, tuple>>
>::value;
}
};
template <size_t _Jp, class ..._Up> friend constexpr
typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) noexcept;
template <size_t _Jp, class ..._Up> friend constexpr
const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) noexcept;
template <size_t _Jp, class ..._Up> friend constexpr
typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) noexcept;
template <size_t _Jp, class ..._Up> friend constexpr
const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) noexcept;
public:
template <bool _Dummy = true, class = typename enable_if<
_CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>()
>::type>
__attribute__ ((__always_inline__))
constexpr tuple()
noexcept(__all<is_nothrow_default_constructible<_Tp> ::value ...> ::value) {}
tuple(tuple const&) = default;
tuple(tuple&&) = default;
template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = typename enable_if<
__lazy_and<
is_same<allocator_arg_t, _AllocArgT>,
__lazy_all<__dependent_type<is_default_constructible<_Tp>, _Dummy>...>
>::value
>::type>
__attribute__ ((__always_inline__))
tuple(_AllocArgT, _Alloc const& __a)
: __base_(allocator_arg_t(), __a,
__tuple_indices<>(), __tuple_types<>(),
typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
__tuple_types<_Tp...>()) {}
template <bool _Dummy = true,
typename enable_if
<
_CheckArgsConstructor<
_Dummy
>::template __enable_implicit<_Tp const&...>(),
bool
>::type = false
>
__attribute__ ((__always_inline__)) constexpr
tuple(const _Tp& ... __t) noexcept((__all<is_nothrow_copy_constructible<_Tp> ::value ...> ::value))
: __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
typename __make_tuple_indices<0>::type(),
typename __make_tuple_types<tuple, 0>::type(),
__t...
) {}
template <bool _Dummy = true,
typename enable_if
<
_CheckArgsConstructor<
_Dummy
>::template __enable_explicit<_Tp const&...>(),
bool
>::type = false
>
__attribute__ ((__always_inline__)) constexpr
explicit tuple(const _Tp& ... __t) noexcept((__all<is_nothrow_copy_constructible<_Tp> ::value ...> ::value))
: __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
typename __make_tuple_indices<0>::type(),
typename __make_tuple_types<tuple, 0>::type(),
__t...
) {}
template <class _Alloc, bool _Dummy = true,
typename enable_if
<
_CheckArgsConstructor<
_Dummy
>::template __enable_implicit<_Tp const&...>(),
bool
>::type = false
>
__attribute__ ((__always_inline__))
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
typename __make_tuple_indices<0>::type(),
typename __make_tuple_types<tuple, 0>::type(),
__t...
) {}
template <class _Alloc, bool _Dummy = true,
typename enable_if
<
_CheckArgsConstructor<
_Dummy
>::template __enable_explicit<_Tp const&...>(),
bool
>::type = false
>
__attribute__ ((__always_inline__))
explicit
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
typename __make_tuple_indices<0>::type(),
typename __make_tuple_types<tuple, 0>::type(),
__t...
) {}
template <class ..._Up,
bool _PackIsTuple = _PackExpandsToThisTuple<_Up...>::value,
typename enable_if
<
_CheckArgsConstructor<
sizeof...(_Up) == sizeof...(_Tp)
&& !_PackIsTuple
>::template __enable_implicit<_Up...>() ||
_CheckArgsConstructor<
_EnableImplicitReducedArityExtension
&& sizeof...(_Up) < sizeof...(_Tp)
&& !_PackIsTuple
>::template __enable_implicit<_Up...>(),
bool
>::type = false
>
__attribute__ ((__always_inline__)) constexpr
tuple(_Up&&... __u)
noexcept(( is_nothrow_constructible<_BaseT, typename __make_tuple_indices<sizeof ...(_Up)> ::type, typename __make_tuple_types<tuple, sizeof ...(_Up)> ::type, typename __make_tuple_indices<sizeof ...(_Tp), sizeof ...(_Up)> ::type, typename __make_tuple_types<tuple, sizeof ...(_Tp), sizeof ...(_Up)> ::type, _Up ... > ::value ))
: __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
std::__2::forward<_Up>(__u)...) {}
template <class ..._Up,
typename enable_if
<
_CheckArgsConstructor<
sizeof...(_Up) <= sizeof...(_Tp)
&& !_PackExpandsToThisTuple<_Up...>::value
>::template __enable_explicit<_Up...>() ||
_CheckArgsConstructor<
!_EnableImplicitReducedArityExtension
&& sizeof...(_Up) < sizeof...(_Tp)
&& !_PackExpandsToThisTuple<_Up...>::value
>::template __enable_implicit<_Up...>(),
bool
>::type = false
>
__attribute__ ((__always_inline__)) constexpr
explicit
tuple(_Up&&... __u)
noexcept(( is_nothrow_constructible<_BaseT, typename __make_tuple_indices<sizeof ...(_Up)> ::type, typename __make_tuple_types<tuple, sizeof ...(_Up)> ::type, typename __make_tuple_indices<sizeof ...(_Tp), sizeof ...(_Up)> ::type, typename __make_tuple_types<tuple, sizeof ...(_Tp), sizeof ...(_Up)> ::type, _Up ... > ::value ))
: __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
std::__2::forward<_Up>(__u)...) {}
template <class _Alloc, class ..._Up,
typename enable_if
<
_CheckArgsConstructor<
sizeof...(_Up) == sizeof...(_Tp) &&
!_PackExpandsToThisTuple<_Up...>::value
>::template __enable_implicit<_Up...>(),
bool
>::type = false
>
__attribute__ ((__always_inline__))
tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
std::__2::forward<_Up>(__u)...) {}
template <class _Alloc, class ..._Up,
typename enable_if
<
_CheckArgsConstructor<
sizeof...(_Up) == sizeof...(_Tp) &&
!_PackExpandsToThisTuple<_Up...>::value
>::template __enable_explicit<_Up...>(),
bool
>::type = false
>
__attribute__ ((__always_inline__))
explicit
tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
: __base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
std::__2::forward<_Up>(__u)...) {}
template <class _Tuple,
typename enable_if
<
_CheckTupleLikeConstructor<
__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
&& !_PackExpandsToThisTuple<_Tuple>::value
>::template __enable_implicit<_Tuple>(),
bool
>::type = false
>
__attribute__ ((__always_inline__)) constexpr
tuple(_Tuple&& __t) noexcept((is_nothrow_constructible<_BaseT, _Tuple> ::value))
: __base_(std::__2::forward<_Tuple>(__t)) {}
template <class _Tuple,
typename enable_if
<
_CheckTupleLikeConstructor<
__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
&& !_PackExpandsToThisTuple<_Tuple>::value
>::template __enable_explicit<_Tuple>(),
bool
>::type = false
>
__attribute__ ((__always_inline__)) constexpr
explicit
tuple(_Tuple&& __t) noexcept((is_nothrow_constructible<_BaseT, _Tuple> ::value))
: __base_(std::__2::forward<_Tuple>(__t)) {}
template <class _Alloc, class _Tuple,
typename enable_if
<
_CheckTupleLikeConstructor<
__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
>::template __enable_implicit<_Tuple>(),
bool
>::type = false
>
__attribute__ ((__always_inline__))
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
: __base_(allocator_arg_t(), __a, std::__2::forward<_Tuple>(__t)) {}
template <class _Alloc, class _Tuple,
typename enable_if
<
_CheckTupleLikeConstructor<
__tuple_like_with_size<_Tuple, sizeof...(_Tp)>::value
>::template __enable_explicit<_Tuple>(),
bool
>::type = false
>
__attribute__ ((__always_inline__))
explicit
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
: __base_(allocator_arg_t(), __a, std::__2::forward<_Tuple>(__t)) {}
using _CanCopyAssign = __all<is_copy_assignable<_Tp>::value...>;
using _CanMoveAssign = __all<is_move_assignable<_Tp>::value...>;
__attribute__ ((__always_inline__))
tuple& operator=(typename conditional<_CanCopyAssign::value, tuple, __nat>::type const& __t)
noexcept((__all<is_nothrow_copy_assignable<_Tp> ::value ...> ::value))
{
__base_.operator=(__t.__base_);
return *this;
}
__attribute__ ((__always_inline__))
tuple& operator=(typename conditional<_CanMoveAssign::value, tuple, __nat>::type&& __t)
noexcept((__all<is_nothrow_move_assignable<_Tp> ::value ...> ::value))
{
__base_.operator=(static_cast<_BaseT&&>(__t.__base_));
return *this;
}
template <class _Tuple,
class = typename enable_if
<
__tuple_assignable<_Tuple, tuple>::value
>::type
>
__attribute__ ((__always_inline__))
tuple&
operator=(_Tuple&& __t) noexcept((is_nothrow_assignable<_BaseT&, _Tuple> ::value))
{
__base_.operator=(std::__2::forward<_Tuple>(__t));
return *this;
}
__attribute__ ((__always_inline__))
void swap(tuple& __t) noexcept(__all<__is_nothrow_swappable<_Tp> ::value ...> ::value)
{__base_.swap(__t.__base_);}
};
template <>
class tuple<>
{
public:
__attribute__ ((__always_inline__))
constexpr tuple() noexcept {}
template <class _Alloc>
__attribute__ ((__always_inline__))
tuple(allocator_arg_t, const _Alloc&) noexcept {}
template <class _Alloc>
__attribute__ ((__always_inline__))
tuple(allocator_arg_t, const _Alloc&, const tuple&) noexcept {}
template <class _Up>
__attribute__ ((__always_inline__))
tuple(array<_Up, 0>) noexcept {}
template <class _Alloc, class _Up>
__attribute__ ((__always_inline__))
tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) noexcept {}
__attribute__ ((__always_inline__))
void swap(tuple&) noexcept {}
};
template <class ..._Tp>
inline __attribute__ ((__always_inline__))
typename enable_if
<
__all<__is_swappable<_Tp>::value...>::value,
void
>::type
swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
noexcept(__all<__is_nothrow_swappable<_Tp> ::value ...> ::value)
{__t.swap(__u);}
// get
template <size_t _Ip, class ..._Tp>
inline __attribute__ ((__always_inline__)) constexpr
typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(tuple<_Tp...>& __t) noexcept
{
typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
}
template <size_t _Ip, class ..._Tp>
inline __attribute__ ((__always_inline__)) constexpr
const typename tuple_element<_Ip, tuple<_Tp...> >::type&
get(const tuple<_Tp...>& __t) noexcept
{
typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
}
template <size_t _Ip, class ..._Tp>
inline __attribute__ ((__always_inline__)) constexpr
typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(tuple<_Tp...>&& __t) noexcept
{
typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
return static_cast<type&&>(
static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
}
template <size_t _Ip, class ..._Tp>
inline __attribute__ ((__always_inline__)) constexpr
const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(const tuple<_Tp...>&& __t) noexcept
{
typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
return static_cast<const type&&>(
static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
}
namespace __find_detail {
static constexpr size_t __not_found = (size_t)-1;
static constexpr size_t __ambiguous = __not_found - 1;
inline __attribute__ ((__always_inline__))
constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
return !__matches ? __res :
(__res == __not_found ? __curr_i : __ambiguous);
}
template <size_t _Nx>
inline __attribute__ ((__always_inline__))
constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
return __i == _Nx ? __not_found :
__find_idx_return(__i, __find_idx(__i + 1, __matches), __matches[__i]);
}
template <class _T1, class ..._Args>
struct __find_exactly_one_checked {
static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
static constexpr size_t value = __find_detail::__find_idx(0, __matches);
static_assert (value != __not_found, "type not found in type list" );
static_assert(value != __ambiguous,"type occurs more than once in type list");
};
template <class _T1>
struct __find_exactly_one_checked<_T1> {
static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
};
} // namespace __find_detail;
template <typename _T1, typename... _Args>
struct __find_exactly_one_t
: public __find_detail::__find_exactly_one_checked<_T1, _Args...> {
};
template <class _T1, class... _Args>
inline __attribute__ ((__always_inline__))
constexpr _T1& get(tuple<_Args...>& __tup) noexcept
{
return std::__2::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
}
template <class _T1, class... _Args>
inline __attribute__ ((__always_inline__))
constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
{
return std::__2::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
}
template <class _T1, class... _Args>
inline __attribute__ ((__always_inline__))
constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
{
return std::__2::get<__find_exactly_one_t<_T1, _Args...>::value>(std::__2::move(__tup));
}
template <class _T1, class... _Args>
inline __attribute__ ((__always_inline__))
constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept
{
return std::__2::get<__find_exactly_one_t<_T1, _Args...>::value>(std::__2::move(__tup));
}
// tie
template <class ..._Tp>
inline __attribute__ ((__always_inline__)) constexpr
tuple<_Tp&...>
tie(_Tp&... __t) noexcept
{
return tuple<_Tp&...>(__t...);
}
template <class _Up>
struct __ignore_t
{
template <class _Tp>
__attribute__ ((__always_inline__)) constexpr
const __ignore_t& operator=(_Tp&&) const {return *this;}
};
namespace {
constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
}
template <class _Tp>
struct __make_tuple_return_impl
{
typedef _Tp type;
};
template <class _Tp>
struct __make_tuple_return_impl<reference_wrapper<_Tp> >
{
typedef _Tp& type;
};
template <class _Tp>
struct __make_tuple_return
{
typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
};
template <class... _Tp>
inline __attribute__ ((__always_inline__)) constexpr
tuple<typename __make_tuple_return<_Tp>::type...>
make_tuple(_Tp&&... __t)
{
return tuple<typename __make_tuple_return<_Tp>::type...>(std::__2::forward<_Tp>(__t)...);
}
template <class... _Tp>
inline __attribute__ ((__always_inline__)) constexpr
tuple<_Tp&&...>
forward_as_tuple(_Tp&&... __t) noexcept
{
return tuple<_Tp&&...>(std::__2::forward<_Tp>(__t)...);
}
template <size_t _Ip>
struct __tuple_equal
{
template <class _Tp, class _Up>
__attribute__ ((__always_inline__)) constexpr
bool operator()(const _Tp& __x, const _Up& __y)
{
return __tuple_equal<_Ip - 1>()(__x, __y) && std::__2::get<_Ip-1>(__x) == std::__2::get<_Ip-1>(__y);
}
};
template <>
struct __tuple_equal<0>
{
template <class _Tp, class _Up>
__attribute__ ((__always_inline__)) constexpr
bool operator()(const _Tp&, const _Up&)
{
return true;
}
};
template <class ..._Tp, class ..._Up>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
}
template <class ..._Tp, class ..._Up>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return !(__x == __y);
}
template <size_t _Ip>
struct __tuple_less
{
template <class _Tp, class _Up>
__attribute__ ((__always_inline__)) constexpr
bool operator()(const _Tp& __x, const _Up& __y)
{
const size_t __idx = tuple_size<_Tp>::value - _Ip;
if (std::__2::get<__idx>(__x) < std::__2::get<__idx>(__y))
return true;
if (std::__2::get<__idx>(__y) < std::__2::get<__idx>(__x))
return false;
return __tuple_less<_Ip-1>()(__x, __y);
}
};
template <>
struct __tuple_less<0>
{
template <class _Tp, class _Up>
__attribute__ ((__always_inline__)) constexpr
bool operator()(const _Tp&, const _Up&)
{
return false;
}
};
template <class ..._Tp, class ..._Up>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return __tuple_less<sizeof...(_Tp)>()(__x, __y);
}
template <class ..._Tp, class ..._Up>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return __y < __x;
}
template <class ..._Tp, class ..._Up>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return !(__x < __y);
}
template <class ..._Tp, class ..._Up>
inline __attribute__ ((__always_inline__)) constexpr
bool
operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return !(__y < __x);
}
// tuple_cat
template <class _Tp, class _Up> struct __tuple_cat_type;
template <class ..._Ttypes, class ..._Utypes>
struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
{
typedef tuple<_Ttypes..., _Utypes...> type;
};
template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
struct __tuple_cat_return_1
{
};
template <class ..._Types, class _Tuple0>
struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
{
typedef typename __tuple_cat_type<tuple<_Types...>,
typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
type;
};
template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
: public __tuple_cat_return_1<
typename __tuple_cat_type<
tuple<_Types...>,
typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
>::type,
__tuple_like<typename remove_reference<_Tuple1>::type>::value,
_Tuple1, _Tuples...>
{
};
template <class ..._Tuples> struct __tuple_cat_return;
template <class _Tuple0, class ..._Tuples>
struct __tuple_cat_return<_Tuple0, _Tuples...>
: public __tuple_cat_return_1<tuple<>,
__tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
_Tuples...>
{
};
template <>
struct __tuple_cat_return<>
{
typedef tuple<> type;
};
inline __attribute__ ((__always_inline__)) constexpr
tuple<>
tuple_cat()
{
return tuple<>();
}
template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
struct __tuple_cat_return_ref_imp;
template <class ..._Types, size_t ..._I0, class _Tuple0>
struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
{
typedef typename remove_reference<_Tuple0>::type _T0;
typedef tuple<_Types..., typename __apply_cv<_Tuple0,
typename tuple_element<_I0, _T0>::type>::type&&...> type;
};
template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
_Tuple0, _Tuple1, _Tuples...>
: public __tuple_cat_return_ref_imp<
tuple<_Types..., typename __apply_cv<_Tuple0,
typename tuple_element<_I0,
typename remove_reference<_Tuple0>::type>::type>::type&&...>,
typename __make_tuple_indices<tuple_size<typename
remove_reference<_Tuple1>::type>::value>::type,
_Tuple1, _Tuples...>
{
};
template <class _Tuple0, class ..._Tuples>
struct __tuple_cat_return_ref
: public __tuple_cat_return_ref_imp<tuple<>,
typename __make_tuple_indices<
tuple_size<typename remove_reference<_Tuple0>::type>::value
>::type, _Tuple0, _Tuples...>
{
};
template <class _Types, class _I0, class _J0>
struct __tuple_cat;
template <class ..._Types, size_t ..._I0, size_t ..._J0>
struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
{
template <class _Tuple0>
__attribute__ ((__always_inline__)) constexpr
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
{
return forward_as_tuple(std::__2::forward<_Types>(std::__2::get<_I0>(__t))...,
std::__2::get<_J0>(std::__2::forward<_Tuple0>(__t0))...);
}
template <class _Tuple0, class _Tuple1, class ..._Tuples>
__attribute__ ((__always_inline__)) constexpr
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
{
typedef typename remove_reference<_Tuple0>::type _T0;
typedef typename remove_reference<_Tuple1>::type _T1;
return __tuple_cat<
tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
(forward_as_tuple(
std::__2::forward<_Types>(std::__2::get<_I0>(__t))...,
std::__2::get<_J0>(std::__2::forward<_Tuple0>(__t0))...
),
std::__2::forward<_Tuple1>(__t1),
std::__2::forward<_Tuples>(__tpls)...);
}
};
template <class _Tuple0, class... _Tuples>
inline __attribute__ ((__always_inline__)) constexpr
typename __tuple_cat_return<_Tuple0, _Tuples...>::type
tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
{
typedef typename remove_reference<_Tuple0>::type _T0;
return __tuple_cat<tuple<>, __tuple_indices<>,
typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
(tuple<>(), std::__2::forward<_Tuple0>(__t0),
std::__2::forward<_Tuples>(__tpls)...);
}
template <class ..._Tp, class _Alloc>
struct uses_allocator<tuple<_Tp...>, _Alloc>
: true_type {};
template <class _T1, class _T2>
template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
inline __attribute__ ((__always_inline__))
pair<_T1, _T2>::pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>)
: first(std::__2::forward<_Args1>(std::__2::get<_I1>( __first_args))...),
second(std::__2::forward<_Args2>(std::__2::get<_I2>(__second_args))...)
{
}
} }
// -*- C++ -*-
//===--------------------------- stdexcept --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
stdexcept synopsis
namespace std
{
class logic_error;
class domain_error;
class invalid_argument;
class length_error;
class out_of_range;
class runtime_error;
class range_error;
class overflow_error;
class underflow_error;
for each class xxx_error:
class xxx_error : public exception // at least indirectly
{
public:
explicit xxx_error(const string& what_arg);
explicit xxx_error(const char* what_arg);
virtual const char* what() const noexcept // returns what_arg
};
} // std
*/
namespace std { inline namespace __2 {
class __libcpp_refstring
{
const char* __imp_;
bool __uses_refcount() const;
public:
explicit __libcpp_refstring(const char* __msg);
__libcpp_refstring(const __libcpp_refstring& __s) noexcept;
__libcpp_refstring& operator=(const __libcpp_refstring& __s) noexcept;
~__libcpp_refstring();
const char* c_str() const noexcept {return __imp_;}
};
} }
namespace std // purposefully not using versioning namespace
{
class logic_error
: public exception
{
private:
std::__2::__libcpp_refstring __imp_;
public:
explicit logic_error(const string&);
explicit logic_error(const char*);
logic_error(const logic_error&) noexcept;
logic_error& operator=(const logic_error&) noexcept;
virtual ~logic_error() noexcept;
virtual const char* what() const noexcept;
};
class runtime_error
: public exception
{
private:
std::__2::__libcpp_refstring __imp_;
public:
explicit runtime_error(const string&);
explicit runtime_error(const char*);
runtime_error(const runtime_error&) noexcept;
runtime_error& operator=(const runtime_error&) noexcept;
virtual ~runtime_error() noexcept;
virtual const char* what() const noexcept;
};
class domain_error
: public logic_error
{
public:
__attribute__ ((__always_inline__)) explicit domain_error(const string& __s) : logic_error(__s) {}
__attribute__ ((__always_inline__)) explicit domain_error(const char* __s) : logic_error(__s) {}
virtual ~domain_error() noexcept;
};
class invalid_argument
: public logic_error
{
public:
__attribute__ ((__always_inline__)) explicit invalid_argument(const string& __s) : logic_error(__s) {}
__attribute__ ((__always_inline__)) explicit invalid_argument(const char* __s) : logic_error(__s) {}
virtual ~invalid_argument() noexcept;
};
class length_error
: public logic_error
{
public:
__attribute__ ((__always_inline__)) explicit length_error(const string& __s) : logic_error(__s) {}
__attribute__ ((__always_inline__)) explicit length_error(const char* __s) : logic_error(__s) {}
virtual ~length_error() noexcept;
};
class out_of_range
: public logic_error
{
public:
__attribute__ ((__always_inline__)) explicit out_of_range(const string& __s) : logic_error(__s) {}
__attribute__ ((__always_inline__)) explicit out_of_range(const char* __s) : logic_error(__s) {}
virtual ~out_of_range() noexcept;
};
class range_error
: public runtime_error
{
public:
__attribute__ ((__always_inline__)) explicit range_error(const string& __s) : runtime_error(__s) {}
__attribute__ ((__always_inline__)) explicit range_error(const char* __s) : runtime_error(__s) {}
virtual ~range_error() noexcept;
};
class overflow_error
: public runtime_error
{
public:
__attribute__ ((__always_inline__)) explicit overflow_error(const string& __s) : runtime_error(__s) {}
__attribute__ ((__always_inline__)) explicit overflow_error(const char* __s) : runtime_error(__s) {}
virtual ~overflow_error() noexcept;
};
class underflow_error
: public runtime_error
{
public:
__attribute__ ((__always_inline__)) explicit underflow_error(const string& __s) : runtime_error(__s) {}
__attribute__ ((__always_inline__)) explicit underflow_error(const char* __s) : runtime_error(__s) {}
virtual ~underflow_error() noexcept;
};
} // std
namespace std { inline namespace __2 {
// in the dylib
[[noreturn]] void __throw_runtime_error(const char*);
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_logic_error(const char*__msg)
{
((void)__msg);
std::__2::abort();
}
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_domain_error(const char*__msg)
{
((void)__msg);
std::__2::abort();
}
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_invalid_argument(const char*__msg)
{
((void)__msg);
std::__2::abort();
}
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_length_error(const char*__msg)
{
((void)__msg);
std::__2::abort();
}
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_out_of_range(const char*__msg)
{
((void)__msg);
std::__2::abort();
}
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_range_error(const char*__msg)
{
((void)__msg);
std::__2::abort();
}
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_overflow_error(const char*__msg)
{
((void)__msg);
std::__2::abort();
}
[[noreturn]] inline __attribute__ ((__always_inline__))
void __throw_underflow_error(const char*__msg)
{
((void)__msg);
std::__2::abort();
}
} }
// -*- C++ -*-
//===-------------------------- cassert -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
cassert synopsis
Macros:
assert
*/
_Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")")
// -*- C++ -*-
//===------------------------ __undef_macros ------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
namespace std { inline namespace __2 {
template <class _ValueType>
inline __attribute__ ((__always_inline__))
_ValueType __libcpp_relaxed_load(_ValueType const* __value) {
return *__value;
}
template <class _ValueType>
inline __attribute__ ((__always_inline__))
_ValueType __libcpp_acquire_load(_ValueType const* __value) {
return *__value;
}
// addressof moved to <type_traits>
template <class _Tp> class allocator;
template <>
class allocator<void>
{
public:
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
template <class _Up> struct rebind {typedef allocator<_Up> other;};
};
template <>
class allocator<const void>
{
public:
typedef const void* pointer;
typedef const void* const_pointer;
typedef const void value_type;
template <class _Up> struct rebind {typedef allocator<_Up> other;};
};
// pointer_traits
template <class _Tp, class = void>
struct __has_element_type : false_type {};
template <class _Tp>
struct __has_element_type<_Tp,
typename __void_t<typename _Tp::element_type>::type> : true_type {};
template <class _Ptr, bool = __has_element_type<_Ptr>::value>
struct __pointer_traits_element_type;
template <class _Ptr>
struct __pointer_traits_element_type<_Ptr, true>
{
typedef typename _Ptr::element_type type;
};
template <template <class, class...> class _Sp, class _Tp, class ..._Args>
struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
{
typedef typename _Sp<_Tp, _Args...>::element_type type;
};
template <template <class, class...> class _Sp, class _Tp, class ..._Args>
struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
{
typedef _Tp type;
};
template <class _Tp, class = void>
struct __has_difference_type : false_type {};
template <class _Tp>
struct __has_difference_type<_Tp,
typename __void_t<typename _Tp::difference_type>::type> : true_type {};
template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
struct __pointer_traits_difference_type
{
typedef ptrdiff_t type;
};
template <class _Ptr>
struct __pointer_traits_difference_type<_Ptr, true>
{
typedef typename _Ptr::difference_type type;
};
template <class _Tp, class _Up>
struct __has_rebind
{
private:
struct __two {char __lx; char __lxx;};
template <class _Xp> static __two __test(...);
template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
struct __pointer_traits_rebind
{
typedef typename _Tp::template rebind<_Up> type;
};
template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
{
typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
};
template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
{
typedef _Sp<_Up, _Args...> type;
};
template <class _Ptr>
struct pointer_traits
{
typedef _Ptr pointer;
typedef typename __pointer_traits_element_type<pointer>::type element_type;
typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
private:
struct __nat {};
public:
__attribute__ ((__always_inline__))
static pointer pointer_to(typename conditional<is_void<element_type>::value,
__nat, element_type>::type& __r)
{return pointer::pointer_to(__r);}
};
template <class _Tp>
struct pointer_traits<_Tp*>
{
typedef _Tp* pointer;
typedef _Tp element_type;
typedef ptrdiff_t difference_type;
template <class _Up> using rebind = _Up*;
private:
struct __nat {};
public:
__attribute__ ((__always_inline__))
static pointer pointer_to(typename conditional<is_void<element_type>::value,
__nat, element_type>::type& __r) noexcept
{return std::__2::addressof(__r);}
};
template <class _From, class _To>
struct __rebind_pointer {
typedef typename pointer_traits<_From>::template rebind<_To> type;
};
// allocator_traits
template <class _Tp, class = void>
struct __has_pointer_type : false_type {};
template <class _Tp>
struct __has_pointer_type<_Tp,
typename __void_t<typename _Tp::pointer>::type> : true_type {};
namespace __pointer_type_imp
{
template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value>
struct __pointer_type
{
typedef typename _Dp::pointer type;
};
template <class _Tp, class _Dp>
struct __pointer_type<_Tp, _Dp, false>
{
typedef _Tp* type;
};
} // __pointer_type_imp
template <class _Tp, class _Dp>
struct __pointer_type
{
typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
};
template <class _Tp, class = void>
struct __has_const_pointer : false_type {};
template <class _Tp>
struct __has_const_pointer<_Tp,
typename __void_t<typename _Tp::const_pointer>::type> : true_type {};
template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
struct __const_pointer
{
typedef typename _Alloc::const_pointer type;
};
template <class _Tp, class _Ptr, class _Alloc>
struct __const_pointer<_Tp, _Ptr, _Alloc, false>
{
typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
};
template <class _Tp, class = void>
struct __has_void_pointer : false_type {};
template <class _Tp>
struct __has_void_pointer<_Tp,
typename __void_t<typename _Tp::void_pointer>::type> : true_type {};
template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>
struct __void_pointer
{
typedef typename _Alloc::void_pointer type;
};
template <class _Ptr, class _Alloc>
struct __void_pointer<_Ptr, _Alloc, false>
{
typedef typename pointer_traits<_Ptr>::template rebind<void> type;
};
template <class _Tp, class = void>
struct __has_const_void_pointer : false_type {};
template <class _Tp>
struct __has_const_void_pointer<_Tp,
typename __void_t<typename _Tp::const_void_pointer>::type> : true_type {};
template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>
struct __const_void_pointer
{
typedef typename _Alloc::const_void_pointer type;
};
template <class _Ptr, class _Alloc>
struct __const_void_pointer<_Ptr, _Alloc, false>
{
typedef typename pointer_traits<_Ptr>::template rebind<const void> type;
};
template <class _Tp>
inline __attribute__ ((__always_inline__))
_Tp*
__to_raw_pointer(_Tp* __p) noexcept
{
return __p;
}
template <class _Pointer>
inline __attribute__ ((__always_inline__))
typename pointer_traits<_Pointer>::element_type*
__to_raw_pointer(_Pointer __p) noexcept
{
return std::__2::__to_raw_pointer(__p.operator->());
}
template <class _Tp, class = void>
struct __has_size_type : false_type {};
template <class _Tp>
struct __has_size_type<_Tp,
typename __void_t<typename _Tp::size_type>::type> : true_type {};
template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
struct __size_type
{
typedef typename make_unsigned<_DiffType>::type type;
};
template <class _Alloc, class _DiffType>
struct __size_type<_Alloc, _DiffType, true>
{
typedef typename _Alloc::size_type type;
};
template <class _Tp, class = void>
struct __has_propagate_on_container_copy_assignment : false_type {};
template <class _Tp>
struct __has_propagate_on_container_copy_assignment<_Tp,
typename __void_t<typename _Tp::propagate_on_container_copy_assignment>::type>
: true_type {};
template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
struct __propagate_on_container_copy_assignment
{
typedef false_type type;
};
template <class _Alloc>
struct __propagate_on_container_copy_assignment<_Alloc, true>
{
typedef typename _Alloc::propagate_on_container_copy_assignment type;
};
template <class _Tp, class = void>
struct __has_propagate_on_container_move_assignment : false_type {};
template <class _Tp>
struct __has_propagate_on_container_move_assignment<_Tp,
typename __void_t<typename _Tp::propagate_on_container_move_assignment>::type>
: true_type {};
template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
struct __propagate_on_container_move_assignment
{
typedef false_type type;
};
template <class _Alloc>
struct __propagate_on_container_move_assignment<_Alloc, true>
{
typedef typename _Alloc::propagate_on_container_move_assignment type;
};
template <class _Tp, class = void>
struct __has_propagate_on_container_swap : false_type {};
template <class _Tp>
struct __has_propagate_on_container_swap<_Tp,
typename __void_t<typename _Tp::propagate_on_container_swap>::type>
: true_type {};
template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
struct __propagate_on_container_swap
{
typedef false_type type;
};
template <class _Alloc>
struct __propagate_on_container_swap<_Alloc, true>
{
typedef typename _Alloc::propagate_on_container_swap type;
};
template <class _Tp, class = void>
struct __has_is_always_equal : false_type {};
template <class _Tp>
struct __has_is_always_equal<_Tp,
typename __void_t<typename _Tp::is_always_equal>::type>
: true_type {};
template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
struct __is_always_equal
{
typedef typename std::__2::is_empty<_Alloc>::type type;
};
template <class _Alloc>
struct __is_always_equal<_Alloc, true>
{
typedef typename _Alloc::is_always_equal type;
};
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
struct __has_rebind_other
{
private:
struct __two {char __lx; char __lxx;};
template <class _Xp> static __two __test(...);
template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
template <class _Tp, class _Up>
struct __has_rebind_other<_Tp, _Up, false>
{
static const bool value = false;
};
template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
struct __allocator_traits_rebind
{
typedef typename _Tp::template rebind<_Up>::other type;
};
template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>
{
typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
};
template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
{
typedef _Alloc<_Up, _Args...> type;
};
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
auto
__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
-> decltype((void)__a.allocate(__sz, __p), true_type());
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
auto
__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
-> false_type;
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
struct __has_allocate_hint
: integral_constant<bool,
is_same<
decltype(std::__2::__has_allocate_hint_test(declval<_Alloc>(),
declval<_SizeType>(),
declval<_ConstVoidPtr>())),
true_type>::value>
{
};
template <class _Alloc, class _Tp, class ..._Args>
decltype(std::__2::declval<_Alloc>().construct(std::__2::declval<_Tp*>(),
std::__2::declval<_Args>()...),
true_type())
__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args);
template <class _Alloc, class _Pointer, class ..._Args>
false_type
__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args);
template <class _Alloc, class _Pointer, class ..._Args>
struct __has_construct
: integral_constant<bool,
is_same<
decltype(std::__2::__has_construct_test(declval<_Alloc>(),
declval<_Pointer>(),
declval<_Args>()...)),
true_type>::value>
{
};
template <class _Alloc, class _Pointer>
auto
__has_destroy_test(_Alloc&& __a, _Pointer&& __p)
-> decltype(__a.destroy(__p), true_type());
template <class _Alloc, class _Pointer>
auto
__has_destroy_test(const _Alloc& __a, _Pointer&& __p)
-> false_type;
template <class _Alloc, class _Pointer>
struct __has_destroy
: integral_constant<bool,
is_same<
decltype(std::__2::__has_destroy_test(declval<_Alloc>(),
declval<_Pointer>())),
true_type>::value>
{
};
template <class _Alloc>
auto
__has_max_size_test(_Alloc&& __a)
-> decltype(__a.max_size(), true_type());
template <class _Alloc>
auto
__has_max_size_test(const volatile _Alloc& __a)
-> false_type;
template <class _Alloc>
struct __has_max_size
: integral_constant<bool,
is_same<
decltype(std::__2::__has_max_size_test(declval<_Alloc&>())),
true_type>::value>
{
};
template <class _Alloc>
auto
__has_select_on_container_copy_construction_test(_Alloc&& __a)
-> decltype(__a.select_on_container_copy_construction(), true_type());
template <class _Alloc>
auto
__has_select_on_container_copy_construction_test(const volatile _Alloc& __a)
-> false_type;
template <class _Alloc>
struct __has_select_on_container_copy_construction
: integral_constant<bool,
is_same<
decltype(std::__2::__has_select_on_container_copy_construction_test(declval<_Alloc&>())),
true_type>::value>
{
};
template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
struct __alloc_traits_difference_type
{
typedef typename pointer_traits<_Ptr>::difference_type type;
};
template <class _Alloc, class _Ptr>
struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
{
typedef typename _Alloc::difference_type type;
};
template <class _Alloc>
struct allocator_traits
{
typedef _Alloc allocator_type;
typedef typename allocator_type::value_type value_type;
typedef typename __pointer_type<value_type, allocator_type>::type pointer;
typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer;
typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer;
typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type;
typedef typename __size_type<allocator_type, difference_type>::type size_type;
typedef typename __propagate_on_container_copy_assignment<allocator_type>::type
propagate_on_container_copy_assignment;
typedef typename __propagate_on_container_move_assignment<allocator_type>::type
propagate_on_container_move_assignment;
typedef typename __propagate_on_container_swap<allocator_type>::type
propagate_on_container_swap;
typedef typename __is_always_equal<allocator_type>::type
is_always_equal;
template <class _Tp> using rebind_alloc =
typename __allocator_traits_rebind<allocator_type, _Tp>::type;
template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
__attribute__ ((__always_inline__))
static pointer allocate(allocator_type& __a, size_type __n)
{return __a.allocate(__n);}
__attribute__ ((__always_inline__))
static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
{return __allocate(__a, __n, __hint,
__has_allocate_hint<allocator_type, size_type, const_void_pointer>());}
__attribute__ ((__always_inline__))
static void deallocate(allocator_type& __a, pointer __p, size_type __n) noexcept
{__a.deallocate(__p, __n);}
template <class _Tp, class... _Args>
__attribute__ ((__always_inline__))
static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
{__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
__a, __p, std::__2::forward<_Args>(__args)...);}
template <class _Tp>
__attribute__ ((__always_inline__))
static void destroy(allocator_type& __a, _Tp* __p)
{__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
__attribute__ ((__always_inline__))
static size_type max_size(const allocator_type& __a) noexcept
{return __max_size(__has_max_size<const allocator_type>(), __a);}
__attribute__ ((__always_inline__))
static allocator_type
select_on_container_copy_construction(const allocator_type& __a)
{return __select_on_container_copy_construction(
__has_select_on_container_copy_construction<const allocator_type>(),
__a);}
template <class _Ptr>
__attribute__ ((__always_inline__))
static
void
__construct_forward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2)
{
for (; __begin1 != __end1; ++__begin1, ++__begin2)
construct(__a, std::__2::__to_raw_pointer(__begin2), std::__2::move_if_noexcept(*__begin1));
}
template <class _Tp>
__attribute__ ((__always_inline__))
static
typename enable_if
<
(is_same<allocator_type, allocator<_Tp> >::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
{
ptrdiff_t _Np = __end1 - __begin1;
if (_Np > 0)
{
std::__2::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
__begin2 += _Np;
}
}
template <class _Iter, class _Ptr>
__attribute__ ((__always_inline__))
static
void
__construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2)
{
for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
construct(__a, std::__2::__to_raw_pointer(__begin2), *__begin1);
}
template <class _Tp>
__attribute__ ((__always_inline__))
static
typename enable_if
<
(is_same<allocator_type, allocator<_Tp> >::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_range_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
{
typedef typename remove_const<_Tp>::type _Vp;
ptrdiff_t _Np = __end1 - __begin1;
if (_Np > 0)
{
std::__2::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp));
__begin2 += _Np;
}
}
template <class _Ptr>
__attribute__ ((__always_inline__))
static
void
__construct_backward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2)
{
while (__end1 != __begin1)
{
construct(__a, std::__2::__to_raw_pointer(__end2-1), std::__2::move_if_noexcept(*--__end1));
--__end2;
}
}
template <class _Tp>
__attribute__ ((__always_inline__))
static
typename enable_if
<
(is_same<allocator_type, allocator<_Tp> >::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_backward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
{
ptrdiff_t _Np = __end1 - __begin1;
__end2 -= _Np;
if (_Np > 0)
std::__2::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
}
private:
__attribute__ ((__always_inline__))
static pointer __allocate(allocator_type& __a, size_type __n,
const_void_pointer __hint, true_type)
{return __a.allocate(__n, __hint);}
__attribute__ ((__always_inline__))
static pointer __allocate(allocator_type& __a, size_type __n,
const_void_pointer, false_type)
{return __a.allocate(__n);}
template <class _Tp, class... _Args>
__attribute__ ((__always_inline__))
static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args)
{__a.construct(__p, std::__2::forward<_Args>(__args)...);}
template <class _Tp, class... _Args>
__attribute__ ((__always_inline__))
static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
{
::new ((void*)__p) _Tp(std::__2::forward<_Args>(__args)...);
}
template <class _Tp>
__attribute__ ((__always_inline__))
static void __destroy(true_type, allocator_type& __a, _Tp* __p)
{__a.destroy(__p);}
template <class _Tp>
__attribute__ ((__always_inline__))
static void __destroy(false_type, allocator_type&, _Tp* __p)
{
__p->~_Tp();
}
__attribute__ ((__always_inline__))
static size_type __max_size(true_type, const allocator_type& __a)
{return __a.max_size();}
__attribute__ ((__always_inline__))
static size_type __max_size(false_type, const allocator_type&)
{return numeric_limits<size_type>::max(); }
__attribute__ ((__always_inline__))
static allocator_type
__select_on_container_copy_construction(true_type, const allocator_type& __a)
{return __a.select_on_container_copy_construction();}
__attribute__ ((__always_inline__))
static allocator_type
__select_on_container_copy_construction(false_type, const allocator_type& __a)
{return __a;}
};
template <class _Traits, class _Tp>
struct __rebind_alloc_helper
{
typedef typename _Traits::template rebind_alloc<_Tp> type;
};
// allocator
template <class _Tp>
class allocator
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef _Tp value_type;
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
template <class _Up> struct rebind {typedef allocator<_Up> other;};
__attribute__ ((__always_inline__)) allocator() noexcept {}
template <class _Up> __attribute__ ((__always_inline__)) allocator(const allocator<_Up>&) noexcept {}
__attribute__ ((__always_inline__)) pointer address(reference __x) const noexcept
{return std::__2::addressof(__x);}
__attribute__ ((__always_inline__)) const_pointer address(const_reference __x) const noexcept
{return std::__2::addressof(__x);}
__attribute__ ((__always_inline__)) pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
{
if (__n > max_size())
__throw_length_error("allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
return static_cast<pointer>(std::__2::__allocate(__n * sizeof(_Tp)));
}
__attribute__ ((__always_inline__)) void deallocate(pointer __p, size_type) noexcept
{std::__2::__libcpp_deallocate((void*)__p);}
__attribute__ ((__always_inline__)) size_type max_size() const noexcept
{return size_type(~0) / sizeof(_Tp);}
template <class _Up, class... _Args>
__attribute__ ((__always_inline__))
void
construct(_Up* __p, _Args&&... __args)
{
::new((void*)__p) _Up(std::__2::forward<_Args>(__args)...);
}
__attribute__ ((__always_inline__)) void destroy(pointer __p) {__p->~_Tp();}
};
template <class _Tp>
class allocator<const _Tp>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef const _Tp* pointer;
typedef const _Tp* const_pointer;
typedef const _Tp& reference;
typedef const _Tp& const_reference;
typedef const _Tp value_type;
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
template <class _Up> struct rebind {typedef allocator<_Up> other;};
__attribute__ ((__always_inline__)) allocator() noexcept {}
template <class _Up> __attribute__ ((__always_inline__)) allocator(const allocator<_Up>&) noexcept {}
__attribute__ ((__always_inline__)) const_pointer address(const_reference __x) const noexcept
{return std::__2::addressof(__x);}
__attribute__ ((__always_inline__)) pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
{
if (__n > max_size())
__throw_length_error("allocator<const T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
return static_cast<pointer>(std::__2::__allocate(__n * sizeof(_Tp)));
}
__attribute__ ((__always_inline__)) void deallocate(pointer __p, size_type) noexcept
{std::__2::__libcpp_deallocate((void*) const_cast<_Tp *>(__p));}
__attribute__ ((__always_inline__)) size_type max_size() const noexcept
{return size_type(~0) / sizeof(_Tp);}
template <class _Up, class... _Args>
__attribute__ ((__always_inline__))
void
construct(_Up* __p, _Args&&... __args)
{
::new((void*)__p) _Up(std::__2::forward<_Args>(__args)...);
}
__attribute__ ((__always_inline__)) void destroy(pointer __p) {__p->~_Tp();}
};
template <class _Tp, class _Up>
inline __attribute__ ((__always_inline__))
bool operator==(const allocator<_Tp>&, const allocator<_Up>&) noexcept {return true;}
template <class _Tp, class _Up>
inline __attribute__ ((__always_inline__))
bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) noexcept {return false;}
template <class _OutputIterator, class _Tp>
class raw_storage_iterator
: public iterator<output_iterator_tag,
_Tp, // purposefully not C++03
ptrdiff_t, // purposefully not C++03
_Tp*, // purposefully not C++03
raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03
{
private:
_OutputIterator __x_;
public:
__attribute__ ((__always_inline__)) explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}
__attribute__ ((__always_inline__)) raw_storage_iterator& operator*() {return *this;}
__attribute__ ((__always_inline__)) raw_storage_iterator& operator=(const _Tp& __element)
{::new(&*__x_) _Tp(__element); return *this;}
__attribute__ ((__always_inline__)) raw_storage_iterator& operator=(_Tp&& __element)
{::new(&*__x_) _Tp(std::__2::move(__element)); return *this;}
__attribute__ ((__always_inline__)) raw_storage_iterator& operator++() {++__x_; return *this;}
__attribute__ ((__always_inline__)) raw_storage_iterator operator++(int)
{raw_storage_iterator __t(*this); ++__x_; return __t;}
__attribute__ ((__always_inline__)) _OutputIterator base() const { return __x_; }
};
template <class _Tp>
pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __n) noexcept
{
pair<_Tp*, ptrdiff_t> __r(0, 0);
const ptrdiff_t __m = (~ptrdiff_t(0) ^
ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * 8 - 1)))
/ sizeof(_Tp);
if (__n > __m)
__n = __m;
while (__n > 0)
{
__r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
if (__r.first)
{
__r.second = __n;
break;
}
__n /= 2;
}
return __r;
}
template <class _Tp>
inline __attribute__ ((__always_inline__))
void return_temporary_buffer(_Tp* __p) noexcept {::operator delete(__p);}
template <class _Tp>
struct auto_ptr_ref
{
_Tp* __ptr_;
};
template<class _Tp>
class auto_ptr
{
private:
_Tp* __ptr_;
public:
typedef _Tp element_type;
__attribute__ ((__always_inline__)) explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {}
__attribute__ ((__always_inline__)) auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {}
template<class _Up> __attribute__ ((__always_inline__)) auto_ptr(auto_ptr<_Up>& __p) throw()
: __ptr_(__p.release()) {}
__attribute__ ((__always_inline__)) auto_ptr& operator=(auto_ptr& __p) throw()
{reset(__p.release()); return *this;}
template<class _Up> __attribute__ ((__always_inline__)) auto_ptr& operator=(auto_ptr<_Up>& __p) throw()
{reset(__p.release()); return *this;}
__attribute__ ((__always_inline__)) auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw()
{reset(__p.__ptr_); return *this;}
__attribute__ ((__always_inline__)) ~auto_ptr() throw() {delete __ptr_;}
__attribute__ ((__always_inline__)) _Tp& operator*() const throw()
{return *__ptr_;}
__attribute__ ((__always_inline__)) _Tp* operator->() const throw() {return __ptr_;}
__attribute__ ((__always_inline__)) _Tp* get() const throw() {return __ptr_;}
__attribute__ ((__always_inline__)) _Tp* release() throw()
{
_Tp* __t = __ptr_;
__ptr_ = 0;
return __t;
}
__attribute__ ((__always_inline__)) void reset(_Tp* __p = 0) throw()
{
if (__ptr_ != __p)
delete __ptr_;
__ptr_ = __p;
}
__attribute__ ((__always_inline__)) auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {}
template<class _Up> __attribute__ ((__always_inline__)) operator auto_ptr_ref<_Up>() throw()
{auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;}
template<class _Up> __attribute__ ((__always_inline__)) operator auto_ptr<_Up>() throw()
{return auto_ptr<_Up>(release());}
};
template <>
class auto_ptr<void>
{
public:
typedef void element_type;
};
template <class _Tp, int _Idx,
bool _CanBeEmptyBase =
is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value>
struct __compressed_pair_elem {
typedef _Tp _ParamT;
typedef _Tp& reference;
typedef const _Tp& const_reference;
constexpr __compressed_pair_elem()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment