IFC @ r253461
This commit is contained in:
commit
749888363d
6
Makefile
6
Makefile
@ -32,6 +32,12 @@
|
||||
# targets - Print a list of supported TARGET/TARGET_ARCH pairs
|
||||
# for world and kernel targets.
|
||||
# toolchains - Build a toolchain for all world and kernel targets.
|
||||
#
|
||||
# "quick" way to test all kernel builds:
|
||||
# _jflag=`sysctl -n hw.ncpu`
|
||||
# _jflag=$(($_jflag * 2))
|
||||
# [ $_jflag -gt 12 ] && _jflag=12
|
||||
# make universe -DMAKE_JUST_KERNELS JFLAG=-j${_jflag}
|
||||
#
|
||||
# This makefile is simple by design. The FreeBSD make automatically reads
|
||||
# the /usr/share/mk/sys.mk unless the -m argument is specified on the
|
||||
|
@ -1237,7 +1237,7 @@ _kerberos5_bootstrap_tools= \
|
||||
# Please document (add comment) why something is in 'bootstrap-tools'.
|
||||
# Try to bound the building of the bootstrap-tool to just the
|
||||
# FreeBSD versions that need the tool built at this stage of the build.
|
||||
bootstrap-tools:
|
||||
bootstrap-tools: .MAKE
|
||||
.for _tool in \
|
||||
${_clang_tblgen} \
|
||||
${_kerberos5_bootstrap_tools} \
|
||||
@ -1290,7 +1290,7 @@ _gcc_tools= gnu/usr.bin/cc/cc_tools
|
||||
_rescue= rescue/rescue
|
||||
.endif
|
||||
|
||||
build-tools:
|
||||
build-tools: .MAKE
|
||||
.for _tool in \
|
||||
bin/csh \
|
||||
bin/sh \
|
||||
@ -1352,7 +1352,7 @@ _cc= gnu/usr.bin/cc
|
||||
.endif
|
||||
.endif
|
||||
|
||||
cross-tools:
|
||||
cross-tools: .MAKE
|
||||
.for _tool in \
|
||||
${_clang_libs} \
|
||||
${_clang} \
|
||||
@ -1383,12 +1383,12 @@ hierarchy hier:
|
||||
# interdependencies (__L) are built automatically by the
|
||||
# ${.CURDIR}/tools/make_libdeps.sh script.
|
||||
#
|
||||
libraries:
|
||||
cd ${.CURDIR}; \
|
||||
${MAKE} -f Makefile.inc1 _prereq_libs; \
|
||||
${MAKE} -f Makefile.inc1 _startup_libs; \
|
||||
${MAKE} -f Makefile.inc1 _prebuild_libs; \
|
||||
${MAKE} -f Makefile.inc1 _generic_libs;
|
||||
libraries: .MAKE
|
||||
cd ${.CURDIR} && \
|
||||
${MAKE} -f Makefile.inc1 _prereq_libs && \
|
||||
${MAKE} -f Makefile.inc1 _startup_libs && \
|
||||
${MAKE} -f Makefile.inc1 _prebuild_libs && \
|
||||
${MAKE} -f Makefile.inc1 _generic_libs
|
||||
|
||||
#
|
||||
# static libgcc.a prerequisite for shared libc
|
||||
@ -1542,7 +1542,7 @@ lib/libradius__L: lib/libmd__L
|
||||
.endif
|
||||
|
||||
.for _lib in ${_prereq_libs}
|
||||
${_lib}__PL: .PHONY
|
||||
${_lib}__PL: .PHONY .MAKE
|
||||
.if exists(${.CURDIR}/${_lib})
|
||||
${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
|
||||
cd ${.CURDIR}/${_lib} && \
|
||||
@ -1554,7 +1554,7 @@ ${_lib}__PL: .PHONY
|
||||
.endfor
|
||||
|
||||
.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
|
||||
${_lib}__L: .PHONY
|
||||
${_lib}__L: .PHONY .MAKE
|
||||
.if exists(${.CURDIR}/${_lib})
|
||||
${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
|
||||
cd ${.CURDIR}/${_lib} && \
|
||||
@ -1568,7 +1568,7 @@ ${_lib}__L: .PHONY
|
||||
# libpam is special: we need to build static PAM modules before
|
||||
# static PAM library, and dynamic PAM library before dynamic PAM
|
||||
# modules.
|
||||
lib/libpam__L: .PHONY
|
||||
lib/libpam__L: .PHONY .MAKE
|
||||
${_+_}@${ECHODIR} "===> lib/libpam (obj,depend,all,install)"; \
|
||||
cd ${.CURDIR}/lib/libpam && \
|
||||
${MAKE} DIRPRFX=lib/libpam/ obj && \
|
||||
@ -1583,7 +1583,7 @@ _generic_libs: ${_generic_libs:S/$/__L/}
|
||||
|
||||
.for __target in all clean cleandepend cleandir depend includes obj
|
||||
.for entry in ${SUBDIR}
|
||||
${entry}.${__target}__D: .PHONY
|
||||
${entry}.${__target}__D: .PHONY .MAKE
|
||||
${_+_}@set -e; if test -d ${.CURDIR}/${entry}.${MACHINE_ARCH}; then \
|
||||
${ECHODIR} "===> ${DIRPRFX}${entry}.${MACHINE_ARCH} (${__target})"; \
|
||||
edir=${entry}.${MACHINE_ARCH}; \
|
||||
|
@ -38,6 +38,9 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20130710: libkvm version bump
|
||||
OLD_LIBS+=lib/libkvm.so.5
|
||||
OLD_LIBS+=usr/lib32/libkvm.so.5
|
||||
# 20130623: dialog update from 1.1 to 1.2
|
||||
OLD_LIBS+=usr/lib/libdialog.so.7
|
||||
OLD_LIBS+=usr/lib32/libdialog.so.7
|
||||
|
19
UPDATING
19
UPDATING
@ -31,6 +31,25 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW:
|
||||
disable the most expensive debugging functionality run
|
||||
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
|
||||
20130716:
|
||||
The default ARM ABI has changed to the ARM EABI. The old ABI is
|
||||
incompatible with the ARM EABI and all programs and modules will
|
||||
need to be rebuilt to work with a new kernel.
|
||||
|
||||
To keep using the old ABI ensure the WITHOUT_ARM_EABI knob is set.
|
||||
|
||||
NOTE: Support for the old ABI will be removed in the future and
|
||||
users are advised to upgrade.
|
||||
|
||||
20130709:
|
||||
pkg_install has been disconnected from the build if you really need it
|
||||
you should add WITH_PKGTOOLS in your src.conf(5).
|
||||
|
||||
20130709:
|
||||
Most of network statistics structures were changed to be able
|
||||
keep 64-bits counters. Thus all tools, that work with networking
|
||||
statistics, must be rebuilt (netstat(1), bsnmpd(1), etc.)
|
||||
|
||||
20130629:
|
||||
Fix targets that run multiple make's to use && rather than ;
|
||||
so that subsequent steps depend on success of previous.
|
||||
|
@ -170,8 +170,8 @@ state3:
|
||||
if (minusc) {
|
||||
evalstring(minusc, sflag ? 0 : EV_EXIT);
|
||||
}
|
||||
state4:
|
||||
if (sflag || minusc == NULL) {
|
||||
state4: /* XXX ??? - why isn't this before the "if" statement */
|
||||
cmdloop(1);
|
||||
}
|
||||
exitshell(exitstatus);
|
||||
|
@ -3997,7 +3997,7 @@ print_dedup_stats(nvlist_t *config)
|
||||
|
||||
/*
|
||||
* If the pool was faulted then we may not have been able to
|
||||
* obtain the config. Otherwise, if have anything in the dedup
|
||||
* obtain the config. Otherwise, if we have anything in the dedup
|
||||
* table continue processing the stats.
|
||||
*/
|
||||
if (nvlist_lookup_uint64_array(config, ZPOOL_CONFIG_DDT_OBJ_STATS,
|
||||
|
@ -9103,8 +9103,6 @@ get_note_type (unsigned e_type)
|
||||
return _("NT_FPREGS (floating point registers)");
|
||||
case NT_PSINFO:
|
||||
return _("NT_PSINFO (psinfo structure)");
|
||||
case NT_THRMISC:
|
||||
return _("NT_THRMISC (thrmisc structure)");
|
||||
case NT_LWPSTATUS:
|
||||
return _("NT_LWPSTATUS (lwpstatus_t structure)");
|
||||
case NT_LWPSINFO:
|
||||
@ -9129,6 +9127,52 @@ get_note_type (unsigned e_type)
|
||||
return buff;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_freebsd_note_type (unsigned e_type)
|
||||
{
|
||||
static char buff[64];
|
||||
|
||||
if (elf_header.e_type == ET_CORE)
|
||||
switch (e_type)
|
||||
{
|
||||
case NT_THRMISC:
|
||||
return _("NT_THRMISC (thrmisc structure)");
|
||||
case NT_PROCSTAT_PROC:
|
||||
return _("NT_PROCSTAT_PROC (proc data)");
|
||||
case NT_PROCSTAT_FILES:
|
||||
return _("NT_PROCSTAT_FILES (files data)");
|
||||
case NT_PROCSTAT_VMMAP:
|
||||
return _("NT_PROCSTAT_VMMAP (vmmap data)");
|
||||
case NT_PROCSTAT_GROUPS:
|
||||
return _("NT_PROCSTAT_GROUPS (groups data)");
|
||||
case NT_PROCSTAT_UMASK:
|
||||
return _("NT_PROCSTAT_UMASK (umask data)");
|
||||
case NT_PROCSTAT_RLIMIT:
|
||||
return _("NT_PROCSTAT_RLIMIT (rlimit data)");
|
||||
case NT_PROCSTAT_OSREL:
|
||||
return _("NT_PROCSTAT_OSREL (osreldate data)");
|
||||
case NT_PROCSTAT_PSSTRINGS:
|
||||
return _("NT_PROCSTAT_PSSTRINGS (ps_strings data)");
|
||||
case NT_PROCSTAT_AUXV:
|
||||
return _("NT_PROCSTAT_AUXV (auxv data)");
|
||||
default:
|
||||
return get_note_type(e_type);
|
||||
}
|
||||
else
|
||||
switch (e_type)
|
||||
{
|
||||
case NT_FREEBSD_ABI_TAG:
|
||||
return _("NT_FREEBSD_ABI_TAG");
|
||||
case NT_FREEBSD_NOINIT_TAG:
|
||||
return _("NT_FREEBSD_NOINIT_TAG");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
snprintf (buff, sizeof(buff), _("Unknown note type: (0x%08x)"), e_type);
|
||||
return buff;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_netbsd_elfcore_note_type (unsigned e_type)
|
||||
{
|
||||
@ -9206,6 +9250,10 @@ process_note (Elf_Internal_Note *pnote)
|
||||
note type strings. */
|
||||
nt = get_note_type (pnote->type);
|
||||
|
||||
else if (const_strneq (pnote->namedata, "FreeBSD"))
|
||||
/* FreeBSD-specific core file notes. */
|
||||
nt = get_freebsd_note_type (pnote->type);
|
||||
|
||||
else if (const_strneq (pnote->namedata, "NetBSD-CORE"))
|
||||
/* NetBSD-specific core file notes. */
|
||||
nt = get_netbsd_elfcore_note_type (pnote->type);
|
||||
@ -9215,7 +9263,7 @@ process_note (Elf_Internal_Note *pnote)
|
||||
note type strings. */
|
||||
nt = get_note_type (pnote->type);
|
||||
|
||||
printf (" %s\t\t0x%08lx\t%s\n",
|
||||
printf (" %-13s 0x%08lx\t%s\n",
|
||||
pnote->namesz ? pnote->namedata : "(NONE)",
|
||||
pnote->descsz, nt);
|
||||
return 1;
|
||||
|
@ -388,7 +388,6 @@
|
||||
#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
|
||||
#define NT_TASKSTRUCT 4 /* Contains copy of task struct */
|
||||
#define NT_AUXV 6 /* Contains copy of Elfxx_auxv_t */
|
||||
#define NT_THRMISC 7 /* Contains copy of thrmisc struct */
|
||||
#define NT_PRXFPREG 0x46e62b7f /* Contains a user_xfpregs_struct; */
|
||||
/* note name must be "LINUX". */
|
||||
|
||||
@ -401,6 +400,19 @@
|
||||
#define NT_LWPSINFO 17 /* Has a struct lwpsinfo_t */
|
||||
#define NT_WIN32PSTATUS 18 /* Has a struct win32_pstatus */
|
||||
|
||||
/* Note segments for core files on FreeBSD systems. Note name
|
||||
must start with "FreeBSD". */
|
||||
#define NT_THRMISC 7 /* Contains copy of thrmisc struct */
|
||||
#define NT_PROCSTAT_PROC 8
|
||||
#define NT_PROCSTAT_FILES 9
|
||||
#define NT_PROCSTAT_VMMAP 10
|
||||
#define NT_PROCSTAT_GROUPS 11
|
||||
#define NT_PROCSTAT_UMASK 12
|
||||
#define NT_PROCSTAT_RLIMIT 13
|
||||
#define NT_PROCSTAT_OSREL 14
|
||||
#define NT_PROCSTAT_PSSTRINGS 15
|
||||
#define NT_PROCSTAT_AUXV 16
|
||||
|
||||
|
||||
/* Note segments for core files on NetBSD systems. Note name
|
||||
must start with "NetBSD-CORE". */
|
||||
|
@ -333,7 +333,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
|
||||
}
|
||||
// do middle whole words
|
||||
__storage_type __nw = __n / __bits_per_word;
|
||||
_VSTD::memset(__first.__seg_, 0, __nw * sizeof(__storage_type));
|
||||
_VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type));
|
||||
__n -= __nw * __bits_per_word;
|
||||
// do last partial word
|
||||
if (__n > 0)
|
||||
@ -363,7 +363,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
|
||||
}
|
||||
// do middle whole words
|
||||
__storage_type __nw = __n / __bits_per_word;
|
||||
_VSTD::memset(__first.__seg_, -1, __nw * sizeof(__storage_type));
|
||||
_VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type));
|
||||
__n -= __nw * __bits_per_word;
|
||||
// do last partial word
|
||||
if (__n > 0)
|
||||
@ -430,7 +430,9 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
|
||||
// __first.__ctz_ == 0;
|
||||
// do middle words
|
||||
__storage_type __nw = __n / __bits_per_word;
|
||||
_VSTD::memmove(__result.__seg_, __first.__seg_, __nw * sizeof(__storage_type));
|
||||
_VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
|
||||
_VSTD::__to_raw_pointer(__first.__seg_),
|
||||
__nw * sizeof(__storage_type));
|
||||
__n -= __nw * __bits_per_word;
|
||||
__result.__seg_ += __nw;
|
||||
// do last word
|
||||
@ -569,7 +571,9 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
|
||||
__storage_type __nw = __n / __bits_per_word;
|
||||
__result.__seg_ -= __nw;
|
||||
__last.__seg_ -= __nw;
|
||||
_VSTD::memmove(__result.__seg_, __last.__seg_, __nw * sizeof(__storage_type));
|
||||
_VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
|
||||
_VSTD::__to_raw_pointer(__last.__seg_),
|
||||
__nw * sizeof(__storage_type));
|
||||
__n -= __nw * __bits_per_word;
|
||||
// do last word
|
||||
if (__n > 0)
|
||||
@ -870,6 +874,7 @@ struct __bit_array
|
||||
{
|
||||
typedef typename _Cp::difference_type difference_type;
|
||||
typedef typename _Cp::__storage_type __storage_type;
|
||||
typedef typename _Cp::__storage_pointer __storage_pointer;
|
||||
typedef typename _Cp::iterator iterator;
|
||||
static const unsigned __bits_per_word = _Cp::__bits_per_word;
|
||||
static const unsigned _Np = 4;
|
||||
@ -880,9 +885,15 @@ struct __bit_array
|
||||
_LIBCPP_INLINE_VISIBILITY static difference_type capacity()
|
||||
{return static_cast<difference_type>(_Np * __bits_per_word);}
|
||||
_LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__word_, 0);}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(__word_ + __size_ / __bits_per_word,
|
||||
static_cast<unsigned>(__size_ % __bits_per_word));}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator begin()
|
||||
{
|
||||
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY iterator end()
|
||||
{
|
||||
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
|
||||
static_cast<unsigned>(__size_ % __bits_per_word));
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Cp>
|
||||
|
@ -56,6 +56,18 @@
|
||||
# endif // __LONG_LONG_SUPPORTED
|
||||
#endif // __FreeBSD__
|
||||
|
||||
#ifdef __NetBSD__
|
||||
# include <sys/endian.h>
|
||||
# if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN 0
|
||||
# else // _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 0
|
||||
# define _LIBCPP_BIG_ENDIAN 1
|
||||
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_HAS_QUICK_EXIT
|
||||
#endif // __NetBSD__
|
||||
|
||||
#ifdef _WIN32
|
||||
# define _LIBCPP_LITTLE_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN 0
|
||||
@ -135,6 +147,10 @@
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
#ifndef __has_attribute
|
||||
#define __has_attribute(__x) 0
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HIDDEN
|
||||
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
|
||||
#endif
|
||||
@ -212,7 +228,9 @@ typedef __char32_t char32_t;
|
||||
# define _LIBCPP_NORETURN __attribute__ ((noreturn))
|
||||
#endif
|
||||
|
||||
#if !(__has_feature(cxx_defaulted_functions))
|
||||
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
#endif // !(__has_feature(cxx_defaulted_functions))
|
||||
|
||||
#if !(__has_feature(cxx_deleted_functions))
|
||||
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
@ -272,9 +290,19 @@ typedef __char32_t char32_t;
|
||||
#define _LIBCPP_HAS_NO_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) && (__ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L)
|
||||
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
|
||||
#if defined(__FreeBSD__)
|
||||
#define _LIBCPP_HAS_QUICK_EXIT
|
||||
#define _LIBCPP_HAS_C11_FEATURES
|
||||
#elif defined(__linux__)
|
||||
#include <features.h>
|
||||
#if __GLIBC_PREREQ(2, 15)
|
||||
#define _LIBCPP_HAS_QUICK_EXIT
|
||||
#endif
|
||||
#if __GLIBC_PREREQ(2, 17)
|
||||
#define _LIBCPP_HAS_C11_FEATURES
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (__has_feature(cxx_noexcept))
|
||||
@ -418,8 +446,14 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
#define _LIBCPP_DEFAULT {}
|
||||
#else
|
||||
#define _LIBCPP_DEFAULT = default;
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _NOALIAS __attribute__((malloc))
|
||||
#define _NOALIAS __attribute__((__malloc__))
|
||||
#else
|
||||
#define _NOALIAS
|
||||
#endif
|
||||
@ -451,7 +485,7 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__)
|
||||
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
@ -476,6 +510,14 @@ template <unsigned> struct __static_assert_check {};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_STD_VER
|
||||
# if __cplusplus <= 201103L
|
||||
# define _LIBCPP_STD_VER 11
|
||||
# else
|
||||
# define _LIBCPP_STD_VER 13 // current year, or date of c++14 ratification
|
||||
# endif
|
||||
#endif // _LIBCPP_STD_VER
|
||||
|
||||
#ifdef _LIBCPP_DEBUG2
|
||||
# include <__debug>
|
||||
#else
|
||||
|
@ -292,7 +292,8 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
|
||||
|
||||
// bullets 1 and 2
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args>
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
@ -301,7 +302,8 @@ __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
return (_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...);
|
||||
}
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args>
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
@ -312,7 +314,8 @@ __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
|
||||
// bullets 3 and 4
|
||||
|
||||
template <class _Fp, class _A0>
|
||||
template <class _Fp, class _A0,
|
||||
class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
@ -321,7 +324,8 @@ __invoke(_Fp&& __f, _A0&& __a0)
|
||||
return _VSTD::forward<_A0>(__a0).*__f;
|
||||
}
|
||||
|
||||
template <class _Fp, class _A0>
|
||||
template <class _Fp, class _A0,
|
||||
class>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
|
@ -33,7 +33,6 @@ template <class _NodePtr>
|
||||
struct __hash_node_base
|
||||
{
|
||||
typedef __hash_node_base __first_node;
|
||||
// typedef _NodePtr pointer;
|
||||
|
||||
_NodePtr __next_;
|
||||
|
||||
@ -111,7 +110,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __node_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return _VSTD::addressof(__node_->__value_);}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__node_->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_iterator& operator++()
|
||||
@ -189,7 +188,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __node_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return _VSTD::addressof(__node_->__value_);}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__node_->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_const_iterator& operator++()
|
||||
@ -255,7 +254,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __node_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return &__node_->__value_;}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__node_->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_local_iterator& operator++()
|
||||
@ -345,7 +344,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __node_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return &__node_->__value_;}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__node_->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_const_local_iterator& operator++()
|
||||
@ -505,8 +504,15 @@ public:
|
||||
__node_allocator;
|
||||
typedef allocator_traits<__node_allocator> __node_traits;
|
||||
typedef typename __node_traits::pointer __node_pointer;
|
||||
typedef typename __node_traits::const_pointer __node_const_pointer;
|
||||
typedef typename __node_traits::pointer __node_const_pointer;
|
||||
typedef __hash_node_base<__node_pointer> __first_node;
|
||||
typedef typename pointer_traits<__node_pointer>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind<__first_node>
|
||||
#else
|
||||
rebind<__first_node>::other
|
||||
#endif
|
||||
__node_base_pointer;
|
||||
|
||||
private:
|
||||
|
||||
@ -558,9 +564,9 @@ public:
|
||||
|
||||
public:
|
||||
typedef __hash_iterator<__node_pointer> iterator;
|
||||
typedef __hash_const_iterator<__node_const_pointer> const_iterator;
|
||||
typedef __hash_const_iterator<__node_pointer> const_iterator;
|
||||
typedef __hash_local_iterator<__node_pointer> local_iterator;
|
||||
typedef __hash_const_local_iterator<__node_const_pointer> const_local_iterator;
|
||||
typedef __hash_const_local_iterator<__node_pointer> const_local_iterator;
|
||||
|
||||
__hash_table()
|
||||
_NOEXCEPT_(
|
||||
@ -706,7 +712,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_bucket_count() const _NOEXCEPT
|
||||
{return __bucket_list_.get_deleter().__alloc().max_size();}
|
||||
{return __pointer_alloc_traits::max_size(__bucket_list_.get_deleter().__alloc());}
|
||||
size_type bucket_size(size_type __n) const;
|
||||
_LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT
|
||||
{
|
||||
@ -807,6 +813,9 @@ private:
|
||||
|
||||
void __deallocate(__node_pointer __np) _NOEXCEPT;
|
||||
__node_pointer __detach() _NOEXCEPT;
|
||||
|
||||
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_map;
|
||||
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_multimap;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
@ -893,7 +902,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u)
|
||||
if (size() > 0)
|
||||
{
|
||||
__bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
|
||||
static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
|
||||
static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
|
||||
__u.__p1_.first().__next_ = nullptr;
|
||||
__u.size() = 0;
|
||||
}
|
||||
@ -917,7 +926,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
|
||||
__p1_.first().__next_ = __u.__p1_.first().__next_;
|
||||
__u.__p1_.first().__next_ = nullptr;
|
||||
__bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
|
||||
static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
|
||||
static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
|
||||
size() = __u.size();
|
||||
__u.size() = 0;
|
||||
}
|
||||
@ -1014,7 +1023,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
|
||||
if (size() > 0)
|
||||
{
|
||||
__bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
|
||||
static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
|
||||
static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
|
||||
__u.__p1_.first().__next_ = nullptr;
|
||||
__u.size() = 0;
|
||||
}
|
||||
@ -1236,7 +1245,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __
|
||||
__node_pointer __pn = __bucket_list_[__chash];
|
||||
if (__pn == nullptr)
|
||||
{
|
||||
__pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
|
||||
__pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
|
||||
__nd->__next_ = __pn->__next_;
|
||||
__pn->__next_ = __nd;
|
||||
// fix up __bucket_list_
|
||||
@ -1274,7 +1283,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c
|
||||
__node_pointer __pn = __bucket_list_[__chash];
|
||||
if (__pn == nullptr)
|
||||
{
|
||||
__pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
|
||||
__pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
|
||||
__cp->__next_ = __pn->__next_;
|
||||
__pn->__next_ = __cp;
|
||||
// fix up __bucket_list_
|
||||
@ -1322,7 +1331,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
|
||||
{
|
||||
if (__p != end() && key_eq()(*__p, __cp->__value_))
|
||||
{
|
||||
__node_pointer __np = const_cast<__node_pointer>(__p.__node_);
|
||||
__node_pointer __np = __p.__node_;
|
||||
__cp->__hash_ = __np->__hash_;
|
||||
size_type __bc = bucket_count();
|
||||
if (size()+1 > __bc * max_load_factor() || __bc == 0)
|
||||
@ -1380,7 +1389,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x)
|
||||
__node_pointer __pn = __bucket_list_[__chash];
|
||||
if (__pn == nullptr)
|
||||
{
|
||||
__pn = static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
|
||||
__pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
|
||||
__h->__next_ = __pn->__next_;
|
||||
__pn->__next_ = __h.get();
|
||||
// fix up __bucket_list_
|
||||
@ -1542,7 +1551,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
|
||||
{
|
||||
for (size_type __i = 0; __i < __nbc; ++__i)
|
||||
__bucket_list_[__i] = nullptr;
|
||||
__node_pointer __pp(static_cast<__node_pointer>(_VSTD::addressof(__p1_.first())));
|
||||
__node_pointer __pp(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())));
|
||||
__node_pointer __cp = __pp->__next_;
|
||||
if (__cp != nullptr)
|
||||
{
|
||||
@ -1700,7 +1709,7 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p)
|
||||
{
|
||||
__node_pointer __np = const_cast<__node_pointer>(__p.__node_);
|
||||
__node_pointer __np = __p.__node_;
|
||||
iterator __r(__np);
|
||||
++__r;
|
||||
remove(__p);
|
||||
@ -1717,7 +1726,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first,
|
||||
++__first;
|
||||
erase(__p);
|
||||
}
|
||||
__node_pointer __np = const_cast<__node_pointer>(__last.__node_);
|
||||
__node_pointer __np = __last.__node_;
|
||||
return iterator (__np);
|
||||
}
|
||||
|
||||
@ -1757,7 +1766,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
|
||||
__hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
|
||||
{
|
||||
// current node
|
||||
__node_pointer __cn = const_cast<__node_pointer>(__p.__node_);
|
||||
__node_pointer __cn = __p.__node_;
|
||||
size_type __bc = bucket_count();
|
||||
size_t __chash = __constrain_hash(__cn->__hash_, __bc);
|
||||
// find previous node
|
||||
@ -1767,7 +1776,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
|
||||
// Fix up __bucket_list_
|
||||
// if __pn is not in same bucket (before begin is not in same bucket) &&
|
||||
// if __cn->__next_ is not in same bucket (nullptr is not in same bucket)
|
||||
if (__pn == _VSTD::addressof(__p1_.first()) || __constrain_hash(__pn->__hash_, __bc) != __chash)
|
||||
if (__pn == static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()))
|
||||
|| __constrain_hash(__pn->__hash_, __bc) != __chash)
|
||||
{
|
||||
if (__cn->__next_ == nullptr || __constrain_hash(__cn->__next_->__hash_, __bc) != __chash)
|
||||
__bucket_list_[__chash] = nullptr;
|
||||
@ -1907,10 +1917,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
|
||||
__p3_.swap(__u.__p3_);
|
||||
if (size() > 0)
|
||||
__bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
|
||||
static_cast<__node_pointer>(_VSTD::addressof(__p1_.first()));
|
||||
static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
|
||||
if (__u.size() > 0)
|
||||
__u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash_, __u.bucket_count())] =
|
||||
static_cast<__node_pointer>(_VSTD::addressof(__u.__p1_.first()));
|
||||
static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__u.__p1_.first()));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Hash, class _Equal, class _Alloc>
|
||||
|
@ -339,12 +339,12 @@ public:
|
||||
static const mask punct = _PUNCT;
|
||||
static const mask xdigit = _HEX;
|
||||
static const mask blank = _BLANK;
|
||||
#elif (defined(__APPLE__) || defined(__FreeBSD__)) || defined(EMSCRIPTEN)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
|
||||
#ifdef __APPLE__
|
||||
typedef __uint32_t mask;
|
||||
#elif defined(__FreeBSD__)
|
||||
typedef unsigned long mask;
|
||||
#elif defined(EMSCRIPTEN)
|
||||
#elif defined(EMSCRIPTEN) || defined(__NetBSD__)
|
||||
typedef unsigned short mask;
|
||||
#endif
|
||||
static const mask space = _CTYPE_S;
|
||||
@ -356,7 +356,11 @@ public:
|
||||
static const mask digit = _CTYPE_D;
|
||||
static const mask punct = _CTYPE_P;
|
||||
static const mask xdigit = _CTYPE_X;
|
||||
# if defined(__NetBSD__)
|
||||
static const mask blank = _CTYPE_BL;
|
||||
# else
|
||||
static const mask blank = _CTYPE_B;
|
||||
# endif
|
||||
#elif defined(__sun__)
|
||||
typedef unsigned int mask;
|
||||
static const mask space = _ISSPACE;
|
||||
@ -596,6 +600,10 @@ public:
|
||||
static const int* __classic_upper_table() _NOEXCEPT;
|
||||
static const int* __classic_lower_table() _NOEXCEPT;
|
||||
#endif
|
||||
#if defined(__NetBSD__)
|
||||
static const short* __classic_upper_table() _NOEXCEPT;
|
||||
static const short* __classic_lower_table() _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
~ctype();
|
||||
|
@ -290,7 +290,7 @@ void
|
||||
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
|
||||
{
|
||||
while (__begin_ != __new_begin)
|
||||
__alloc_traits::destroy(__alloc(), __begin_++);
|
||||
__alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
@ -307,7 +307,7 @@ void
|
||||
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
|
||||
{
|
||||
while (__new_last != __end_)
|
||||
__alloc_traits::destroy(__alloc(), --__end_);
|
||||
__alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
@ -320,7 +320,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
|
||||
: __end_cap_(0, __a)
|
||||
: __end_cap_(nullptr, __a)
|
||||
{
|
||||
__first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
|
||||
__begin_ = __end_ = __first_ + __start;
|
||||
@ -331,21 +331,21 @@ template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||
: __first_(0), __begin_(0), __end_(0), __end_cap_(0)
|
||||
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
|
||||
: __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a)
|
||||
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
|
||||
: __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a)
|
||||
: __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,8 @@ private:
|
||||
const codecvt<char_type, char, state_type>* __cv_;
|
||||
state_type* __st_;
|
||||
int __encoding_;
|
||||
int_type __last_consumed_;
|
||||
bool __last_consumed_is_next_;
|
||||
bool __always_noconv_;
|
||||
|
||||
__stdinbuf(const __stdinbuf&);
|
||||
@ -66,7 +68,9 @@ private:
|
||||
template <class _CharT>
|
||||
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
|
||||
: __file_(__fp),
|
||||
__st_(__st)
|
||||
__st_(__st),
|
||||
__last_consumed_(traits_type::eof()),
|
||||
__last_consumed_is_next_(false)
|
||||
{
|
||||
imbue(this->getloc());
|
||||
}
|
||||
@ -100,6 +104,16 @@ template <class _CharT>
|
||||
typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::__getchar(bool __consume)
|
||||
{
|
||||
if (__last_consumed_is_next_)
|
||||
{
|
||||
int_type __result = __last_consumed_;
|
||||
if (__consume)
|
||||
{
|
||||
__last_consumed_ = traits_type::eof();
|
||||
__last_consumed_is_next_ = false;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
char __extbuf[__limit];
|
||||
int __nread = _VSTD::max(1, __encoding_);
|
||||
for (int __i = 0; __i < __nread; ++__i)
|
||||
@ -154,6 +168,8 @@ __stdinbuf<_CharT>::__getchar(bool __consume)
|
||||
return traits_type::eof();
|
||||
}
|
||||
}
|
||||
else
|
||||
__last_consumed_ = traits_type::to_int_type(__1buf);
|
||||
return traits_type::to_int_type(__1buf);
|
||||
}
|
||||
|
||||
@ -162,28 +178,41 @@ typename __stdinbuf<_CharT>::int_type
|
||||
__stdinbuf<_CharT>::pbackfail(int_type __c)
|
||||
{
|
||||
if (traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
return __c;
|
||||
char __extbuf[__limit];
|
||||
char* __enxt;
|
||||
const char_type __ci = traits_type::to_char_type(__c);
|
||||
const char_type* __inxt;
|
||||
switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
|
||||
__extbuf, __extbuf + sizeof(__extbuf), __enxt))
|
||||
{
|
||||
case _VSTD::codecvt_base::ok:
|
||||
break;
|
||||
case _VSTD::codecvt_base::noconv:
|
||||
__extbuf[0] = static_cast<char>(__c);
|
||||
__enxt = __extbuf + 1;
|
||||
break;
|
||||
case codecvt_base::partial:
|
||||
case codecvt_base::error:
|
||||
return traits_type::eof();
|
||||
if (!__last_consumed_is_next_)
|
||||
{
|
||||
__c = __last_consumed_;
|
||||
__last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
|
||||
traits_type::eof());
|
||||
}
|
||||
return __c;
|
||||
}
|
||||
while (__enxt > __extbuf)
|
||||
if (ungetc(*--__enxt, __file_) == EOF)
|
||||
if (__last_consumed_is_next_)
|
||||
{
|
||||
char __extbuf[__limit];
|
||||
char* __enxt;
|
||||
const char_type __ci = traits_type::to_char_type(__last_consumed_);
|
||||
const char_type* __inxt;
|
||||
switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
|
||||
__extbuf, __extbuf + sizeof(__extbuf), __enxt))
|
||||
{
|
||||
case _VSTD::codecvt_base::ok:
|
||||
break;
|
||||
case _VSTD::codecvt_base::noconv:
|
||||
__extbuf[0] = static_cast<char>(__last_consumed_);
|
||||
__enxt = __extbuf + 1;
|
||||
break;
|
||||
case codecvt_base::partial:
|
||||
case codecvt_base::error:
|
||||
return traits_type::eof();
|
||||
return traits_type::not_eof(__c);
|
||||
}
|
||||
while (__enxt > __extbuf)
|
||||
if (ungetc(*--__enxt, __file_) == EOF)
|
||||
return traits_type::eof();
|
||||
}
|
||||
__last_consumed_ = __c;
|
||||
__last_consumed_is_next_ = true;
|
||||
return __c;
|
||||
}
|
||||
|
||||
// __stdoutbuf
|
||||
@ -234,30 +263,31 @@ __stdoutbuf<_CharT>::overflow(int_type __c)
|
||||
char_type __1buf;
|
||||
if (!traits_type::eq_int_type(__c, traits_type::eof()))
|
||||
{
|
||||
this->setp(&__1buf, &__1buf+1);
|
||||
*this->pptr() = traits_type::to_char_type(__c);
|
||||
this->pbump(1);
|
||||
__1buf = traits_type::to_char_type(__c);
|
||||
if (__always_noconv_)
|
||||
{
|
||||
if (fwrite(this->pbase(), sizeof(char_type), 1, __file_) != 1)
|
||||
if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
|
||||
return traits_type::eof();
|
||||
}
|
||||
else
|
||||
{
|
||||
char* __extbe = __extbuf;
|
||||
codecvt_base::result __r;
|
||||
char_type* pbase = &__1buf;
|
||||
char_type* pptr = pbase + 1;
|
||||
char_type* epptr = pptr;
|
||||
do
|
||||
{
|
||||
const char_type* __e;
|
||||
__r = __cv_->out(*__st_, this->pbase(), this->pptr(), __e,
|
||||
__r = __cv_->out(*__st_, pbase, pptr, __e,
|
||||
__extbuf,
|
||||
__extbuf + sizeof(__extbuf),
|
||||
__extbe);
|
||||
if (__e == this->pbase())
|
||||
if (__e == pbase)
|
||||
return traits_type::eof();
|
||||
if (__r == codecvt_base::noconv)
|
||||
{
|
||||
if (fwrite(this->pbase(), 1, 1, __file_) != 1)
|
||||
if (fwrite(pbase, 1, 1, __file_) != 1)
|
||||
return traits_type::eof();
|
||||
}
|
||||
else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
|
||||
@ -267,15 +297,13 @@ __stdoutbuf<_CharT>::overflow(int_type __c)
|
||||
return traits_type::eof();
|
||||
if (__r == codecvt_base::partial)
|
||||
{
|
||||
this->setp((char_type*)__e, this->pptr());
|
||||
this->pbump(static_cast<int>(this->epptr() - this->pbase()));
|
||||
pbase = (char_type*)__e;
|
||||
}
|
||||
}
|
||||
else
|
||||
return traits_type::eof();
|
||||
} while (__r == codecvt_base::partial);
|
||||
}
|
||||
this->setp(0, 0);
|
||||
}
|
||||
return traits_type::not_eof(__c);
|
||||
}
|
||||
|
@ -644,7 +644,8 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const
|
||||
{return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__tree_iterator& operator++()
|
||||
@ -686,7 +687,7 @@ class _LIBCPP_TYPE_VIS __tree_const_iterator
|
||||
{
|
||||
typedef _ConstNodePtr __node_pointer;
|
||||
typedef typename pointer_traits<__node_pointer>::element_type __node;
|
||||
typedef const typename __node::base __node_base;
|
||||
typedef typename __node::base __node_base;
|
||||
typedef typename pointer_traits<__node_pointer>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind<__node_base>
|
||||
@ -729,7 +730,8 @@ public:
|
||||
: __ptr_(__p.__ptr_) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &__ptr_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const
|
||||
{return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__tree_const_iterator& operator++()
|
||||
@ -779,8 +781,10 @@ public:
|
||||
typedef typename __alloc_traits::size_type size_type;
|
||||
typedef typename __alloc_traits::difference_type difference_type;
|
||||
|
||||
typedef __tree_node<value_type, typename __alloc_traits::void_pointer> __node;
|
||||
typedef __tree_node_base<typename __alloc_traits::void_pointer> __node_base;
|
||||
typedef typename __alloc_traits::void_pointer __void_pointer;
|
||||
|
||||
typedef __tree_node<value_type, __void_pointer> __node;
|
||||
typedef __tree_node_base<__void_pointer> __node_base;
|
||||
typedef typename __alloc_traits::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<__node>
|
||||
@ -790,9 +794,9 @@ public:
|
||||
__node_allocator;
|
||||
typedef allocator_traits<__node_allocator> __node_traits;
|
||||
typedef typename __node_traits::pointer __node_pointer;
|
||||
typedef typename __node_traits::const_pointer __node_const_pointer;
|
||||
typedef typename __node_traits::pointer __node_const_pointer;
|
||||
typedef typename __node_base::pointer __node_base_pointer;
|
||||
typedef typename __node_base::const_pointer __node_base_const_pointer;
|
||||
typedef typename __node_base::pointer __node_base_const_pointer;
|
||||
private:
|
||||
typedef typename __node_base::base __end_node_t;
|
||||
typedef typename pointer_traits<__node_pointer>::template
|
||||
@ -804,9 +808,9 @@ private:
|
||||
__end_node_ptr;
|
||||
typedef typename pointer_traits<__node_pointer>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind<const __end_node_t>
|
||||
rebind<__end_node_t>
|
||||
#else
|
||||
rebind<const __end_node_t>::other
|
||||
rebind<__end_node_t>::other
|
||||
#endif
|
||||
__end_node_const_ptr;
|
||||
|
||||
@ -828,7 +832,7 @@ public:
|
||||
{
|
||||
return static_cast<__node_const_pointer>
|
||||
(
|
||||
pointer_traits<__end_node_const_ptr>::pointer_to(__pair1_.first())
|
||||
pointer_traits<__end_node_const_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first()))
|
||||
);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -865,7 +869,7 @@ public:
|
||||
{return static_cast<__node_const_pointer>(__end_node()->__left_);}
|
||||
|
||||
typedef __tree_iterator<value_type, __node_pointer, difference_type> iterator;
|
||||
typedef __tree_const_iterator<value_type, __node_const_pointer, difference_type> const_iterator;
|
||||
typedef __tree_const_iterator<value_type, __node_pointer, difference_type> const_iterator;
|
||||
|
||||
explicit __tree(const value_compare& __comp)
|
||||
_NOEXCEPT_(
|
||||
@ -1102,6 +1106,9 @@ private:
|
||||
|
||||
__node_pointer __detach();
|
||||
static __node_pointer __detach(__node_pointer);
|
||||
|
||||
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS map;
|
||||
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS multimap;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Compare, class _Allocator>
|
||||
@ -1161,7 +1168,7 @@ __tree<_Tp, _Compare, _Allocator>::__detach(__node_pointer __cache)
|
||||
{
|
||||
if (__cache->__parent_ == nullptr)
|
||||
return nullptr;
|
||||
if (__tree_is_left_child(__cache))
|
||||
if (__tree_is_left_child(static_cast<__node_base_pointer>(__cache)))
|
||||
{
|
||||
__cache->__parent_->__left_ = nullptr;
|
||||
__cache = static_cast<__node_pointer>(__cache->__parent_);
|
||||
@ -1294,7 +1301,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t)
|
||||
__begin_node() = __end_node();
|
||||
else
|
||||
{
|
||||
__end_node()->__left_->__parent_ = __end_node();
|
||||
__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
|
||||
__t.__begin_node() = __t.__end_node();
|
||||
__t.__end_node()->__left_ = nullptr;
|
||||
__t.size() = 0;
|
||||
@ -1314,7 +1321,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __
|
||||
{
|
||||
__begin_node() = __t.__begin_node();
|
||||
__end_node()->__left_ = __t.__end_node()->__left_;
|
||||
__end_node()->__left_->__parent_ = __end_node();
|
||||
__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
|
||||
size() = __t.size();
|
||||
__t.__begin_node() = __t.__end_node();
|
||||
__t.__end_node()->__left_ = nullptr;
|
||||
@ -1342,7 +1349,7 @@ __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
|
||||
__begin_node() = __end_node();
|
||||
else
|
||||
{
|
||||
__end_node()->__left_->__parent_ = __end_node();
|
||||
__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
|
||||
__t.__begin_node() = __t.__end_node();
|
||||
__t.__end_node()->__left_ = nullptr;
|
||||
__t.size() = 0;
|
||||
@ -1447,11 +1454,11 @@ __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
|
||||
if (size() == 0)
|
||||
__begin_node() = __end_node();
|
||||
else
|
||||
__end_node()->__left_->__parent_ = __end_node();
|
||||
__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
|
||||
if (__t.size() == 0)
|
||||
__t.__begin_node() = __t.__end_node();
|
||||
else
|
||||
__t.__end_node()->__left_->__parent_ = __t.__end_node();
|
||||
__t.__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__t.__end_node());
|
||||
}
|
||||
|
||||
template <class _Tp, class _Compare, class _Allocator>
|
||||
@ -1483,7 +1490,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(typename __node_base::pointer
|
||||
__nd = static_cast<__node_pointer>(__nd->__right_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent->__right_;
|
||||
}
|
||||
}
|
||||
@ -1493,13 +1500,13 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(typename __node_base::pointer
|
||||
__nd = static_cast<__node_pointer>(__nd->__left_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent->__left_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
__parent = __end_node();
|
||||
__parent = static_cast<__node_base_pointer>(__end_node());
|
||||
return __parent->__left_;
|
||||
}
|
||||
|
||||
@ -1522,7 +1529,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(typename __node_base::pointe
|
||||
__nd = static_cast<__node_pointer>(__nd->__left_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent->__left_;
|
||||
}
|
||||
}
|
||||
@ -1532,13 +1539,13 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(typename __node_base::pointe
|
||||
__nd = static_cast<__node_pointer>(__nd->__right_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent->__right_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
__parent = __end_node();
|
||||
__parent = static_cast<__node_base_pointer>(__end_node());
|
||||
return __parent->__left_;
|
||||
}
|
||||
|
||||
@ -1563,12 +1570,12 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint,
|
||||
// *prev(__hint) <= __v <= *__hint
|
||||
if (__hint.__ptr_->__left_ == nullptr)
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__hint.__ptr_);
|
||||
__parent = static_cast<__node_base_pointer>(__hint.__ptr_);
|
||||
return __parent->__left_;
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__prior.__ptr_);
|
||||
__parent = static_cast<__node_base_pointer>(__prior.__ptr_);
|
||||
return __parent->__right_;
|
||||
}
|
||||
}
|
||||
@ -1600,7 +1607,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(typename __node_base::pointer& _
|
||||
__nd = static_cast<__node_pointer>(__nd->__left_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent->__left_;
|
||||
}
|
||||
}
|
||||
@ -1610,18 +1617,18 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(typename __node_base::pointer& _
|
||||
__nd = static_cast<__node_pointer>(__nd->__right_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent->__right_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
__parent = __end_node();
|
||||
__parent = static_cast<__node_base_pointer>(__end_node());
|
||||
return __parent->__left_;
|
||||
}
|
||||
|
||||
@ -1648,12 +1655,12 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint,
|
||||
// *prev(__hint) < __v < *__hint
|
||||
if (__hint.__ptr_->__left_ == nullptr)
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__hint.__ptr_);
|
||||
__parent = static_cast<__node_base_pointer>(__hint.__ptr_);
|
||||
return __parent->__left_;
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__prior.__ptr_);
|
||||
__parent = static_cast<__node_base_pointer>(__prior.__ptr_);
|
||||
return __parent->__right_;
|
||||
}
|
||||
}
|
||||
@ -1669,12 +1676,12 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint,
|
||||
// *__hint < __v < *_VSTD::next(__hint)
|
||||
if (__hint.__ptr_->__right_ == nullptr)
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__hint.__ptr_);
|
||||
__parent = static_cast<__node_base_pointer>(__hint.__ptr_);
|
||||
return __parent->__right_;
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__next.__ptr_);
|
||||
__parent = static_cast<__node_base_pointer>(__next.__ptr_);
|
||||
return __parent->__left_;
|
||||
}
|
||||
}
|
||||
@ -1682,7 +1689,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint,
|
||||
return __find_equal(__parent, __v);
|
||||
}
|
||||
// else __v == *__hint
|
||||
__parent = const_cast<__node_pointer&>(__hint.__ptr_);
|
||||
__parent = static_cast<__node_base_pointer>(__hint.__ptr_);
|
||||
return __parent;
|
||||
}
|
||||
|
||||
@ -1729,7 +1736,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique(_Args&&... __args)
|
||||
bool __inserted = false;
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
__r = __h.release();
|
||||
__inserted = true;
|
||||
}
|
||||
@ -1747,7 +1754,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique(const_iterator __p, _Ar
|
||||
__node_pointer __r = static_cast<__node_pointer>(__child);
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
__r = __h.release();
|
||||
}
|
||||
return iterator(__r);
|
||||
@ -1761,7 +1768,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args)
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_);
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
return iterator(static_cast<__node_pointer>(__h.release()));
|
||||
}
|
||||
|
||||
@ -1774,7 +1781,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p,
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_);
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
return iterator(static_cast<__node_pointer>(__h.release()));
|
||||
}
|
||||
|
||||
@ -1812,7 +1819,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(_Vp&& __v)
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v));
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_);
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
return iterator(__h.release());
|
||||
}
|
||||
|
||||
@ -1824,7 +1831,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, _Vp&& __v)
|
||||
__node_holder __h = __construct_node(_VSTD::forward<_Vp>(__v));
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_);
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
return iterator(__h.release());
|
||||
}
|
||||
|
||||
@ -1854,7 +1861,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_unique(const value_type& __v)
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__node_holder __h = __construct_node(__v);
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
__r = __h.release();
|
||||
__inserted = true;
|
||||
}
|
||||
@ -1871,7 +1878,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, const val
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__node_holder __h = __construct_node(__v);
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
__r = __h.release();
|
||||
}
|
||||
return iterator(__r);
|
||||
@ -1884,7 +1891,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(const value_type& __v)
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_leaf_high(__parent, __v);
|
||||
__node_holder __h = __construct_node(__v);
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
return iterator(__h.release());
|
||||
}
|
||||
|
||||
@ -1895,7 +1902,7 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const valu
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_leaf(__p, __parent, __v);
|
||||
__node_holder __h = __construct_node(__v);
|
||||
__insert_node_at(__parent, __child, __h.get());
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
return iterator(__h.release());
|
||||
}
|
||||
|
||||
@ -1909,7 +1916,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_unique(__node_pointer __nd)
|
||||
bool __inserted = false;
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__insert_node_at(__parent, __child, __nd);
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
|
||||
__r = __nd;
|
||||
__inserted = true;
|
||||
}
|
||||
@ -1926,7 +1933,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_unique(const_iterator __p,
|
||||
__node_pointer __r = static_cast<__node_pointer>(__child);
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__insert_node_at(__parent, __child, __nd);
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
|
||||
__r = __nd;
|
||||
}
|
||||
return iterator(__r);
|
||||
@ -1938,7 +1945,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd)
|
||||
{
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_leaf_high(__parent, __nd->__value_);
|
||||
__insert_node_at(__parent, __child, __nd);
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
|
||||
return iterator(__nd);
|
||||
}
|
||||
|
||||
@ -1949,7 +1956,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p,
|
||||
{
|
||||
__node_base_pointer __parent;
|
||||
__node_base_pointer& __child = __find_leaf(__p, __parent, __nd->__value_);
|
||||
__insert_node_at(__parent, __child, __nd);
|
||||
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
|
||||
return iterator(__nd);
|
||||
}
|
||||
|
||||
@ -1957,7 +1964,7 @@ template <class _Tp, class _Compare, class _Allocator>
|
||||
typename __tree<_Tp, _Compare, _Allocator>::iterator
|
||||
__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p)
|
||||
{
|
||||
__node_pointer __np = const_cast<__node_pointer>(__p.__ptr_);
|
||||
__node_pointer __np = __p.__ptr_;
|
||||
iterator __r(__np);
|
||||
++__r;
|
||||
if (__begin_node() == __np)
|
||||
@ -1977,7 +1984,7 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l)
|
||||
{
|
||||
while (__f != __l)
|
||||
__f = erase(__f);
|
||||
return iterator(const_cast<__node_pointer>(__l.__ptr_));
|
||||
return iterator(__l.__ptr_);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Compare, class _Allocator>
|
||||
@ -2264,7 +2271,7 @@ template <class _Tp, class _Compare, class _Allocator>
|
||||
typename __tree<_Tp, _Compare, _Allocator>::__node_holder
|
||||
__tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT
|
||||
{
|
||||
__node_pointer __np = const_cast<__node_pointer>(__p.__ptr_);
|
||||
__node_pointer __np = __p.__ptr_;
|
||||
if (__begin_node() == __np)
|
||||
{
|
||||
if (__np->__right_ != nullptr)
|
||||
|
@ -87,30 +87,63 @@ 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,
|
||||
@ -1087,6 +1120,32 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
|
||||
return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
pair<_InputIterator1, _InputIterator2>
|
||||
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2,
|
||||
_BinaryPredicate __pred)
|
||||
{
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
break;
|
||||
return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
pair<_InputIterator1, _InputIterator2>
|
||||
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
||||
return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
#endif
|
||||
|
||||
// equal
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
||||
@ -1110,6 +1169,60 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
|
||||
return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__equal(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred,
|
||||
input_iterator_tag, input_iterator_tag )
|
||||
{
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
return false;
|
||||
return __first1 == __last1 && __first2 == __last2;
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
|
||||
random_access_iterator_tag, random_access_iterator_tag )
|
||||
{
|
||||
if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
|
||||
return false;
|
||||
return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2,
|
||||
typename add_lvalue_reference<_BinaryPredicate>::type>
|
||||
(__first1, __last1, __first2, __pred );
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred )
|
||||
{
|
||||
return _VSTD::__equal<typename add_lvalue_reference<_BinaryPredicate>::type>
|
||||
(__first1, __last1, __first2, __last2, __pred,
|
||||
typename iterator_traits<_InputIterator1>::iterator_category(),
|
||||
typename iterator_traits<_InputIterator2>::iterator_category());
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
equal(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _InputIterator2 __last2)
|
||||
{
|
||||
typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
||||
return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
|
||||
typename iterator_traits<_InputIterator1>::iterator_category(),
|
||||
typename iterator_traits<_InputIterator2>::iterator_category());
|
||||
}
|
||||
#endif
|
||||
|
||||
// is_permutation
|
||||
|
||||
template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
@ -1169,6 +1282,100 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template<class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
|
||||
bool
|
||||
__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
|
||||
_BinaryPredicate __pred,
|
||||
forward_iterator_tag, forward_iterator_tag )
|
||||
{
|
||||
// shorten sequences as much as possible by lopping of any equal parts
|
||||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
|
||||
if (!__pred(*__first1, *__first2))
|
||||
goto __not_done;
|
||||
return __first1 == __last1 && __first2 == __last2;
|
||||
__not_done:
|
||||
// __first1 != __last1 && __first2 != __last2 && *__first1 != *__first2
|
||||
typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
|
||||
_D1 __l1 = _VSTD::distance(__first1, __last1);
|
||||
|
||||
typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2;
|
||||
_D2 __l2 = _VSTD::distance(__first2, __last2);
|
||||
if (__l1 != __l2)
|
||||
return false;
|
||||
|
||||
// For each element in [f1, l1) see if there are the same number of
|
||||
// equal elements in [f2, l2)
|
||||
for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i)
|
||||
{
|
||||
// Have we already counted the number of *__i in [f1, l1)?
|
||||
for (_ForwardIterator1 __j = __first1; __j != __i; ++__j)
|
||||
if (__pred(*__j, *__i))
|
||||
goto __next_iter;
|
||||
{
|
||||
// Count number of *__i in [f2, l2)
|
||||
_D1 __c2 = 0;
|
||||
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
|
||||
if (__pred(*__i, *__j))
|
||||
++__c2;
|
||||
if (__c2 == 0)
|
||||
return false;
|
||||
// Count number of *__i in [__i, l1) (we can start with 1)
|
||||
_D1 __c1 = 1;
|
||||
for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
|
||||
if (__pred(*__i, *__j))
|
||||
++__c1;
|
||||
if (__c1 != __c2)
|
||||
return false;
|
||||
}
|
||||
__next_iter:;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
bool
|
||||
__is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
|
||||
_RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
|
||||
_BinaryPredicate __pred,
|
||||
random_access_iterator_tag, random_access_iterator_tag )
|
||||
{
|
||||
if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
|
||||
return false;
|
||||
return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2,
|
||||
typename add_lvalue_reference<_BinaryPredicate>::type>
|
||||
(__first1, __last1, __first2, __pred );
|
||||
}
|
||||
|
||||
template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
|
||||
_BinaryPredicate __pred )
|
||||
{
|
||||
return _VSTD::__is_permutation<typename add_lvalue_reference<_BinaryPredicate>::type>
|
||||
(__first1, __last1, __first2, __last2, __pred,
|
||||
typename iterator_traits<_ForwardIterator1>::iterator_category(),
|
||||
typename iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
}
|
||||
|
||||
template<class _ForwardIterator1, class _ForwardIterator2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
|
||||
typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
|
||||
return _VSTD::__is_permutation(__first1, __last1, __first2, __last2,
|
||||
__equal_to<__v1, __v2>(),
|
||||
typename iterator_traits<_ForwardIterator1>::iterator_category(),
|
||||
typename iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
}
|
||||
#endif
|
||||
|
||||
// search
|
||||
|
||||
template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
|
||||
|
@ -622,7 +622,12 @@ struct __atomic_base // false
|
||||
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__atomic_base() _NOEXCEPT {} // = default;
|
||||
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
__atomic_base() _NOEXCEPT = default;
|
||||
#else
|
||||
__atomic_base() _NOEXCEPT : __a_() {}
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
|
||||
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
@ -645,7 +650,7 @@ struct __atomic_base<_Tp, true>
|
||||
{
|
||||
typedef __atomic_base<_Tp, false> __base;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__atomic_base() _NOEXCEPT {} // = default;
|
||||
__atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
|
||||
|
||||
@ -726,7 +731,7 @@ struct atomic
|
||||
{
|
||||
typedef __atomic_base<_Tp> __base;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic() _NOEXCEPT {} // = default;
|
||||
atomic() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
|
||||
|
||||
@ -746,7 +751,7 @@ struct atomic<_Tp*>
|
||||
{
|
||||
typedef __atomic_base<_Tp*> __base;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic() _NOEXCEPT {} // = default;
|
||||
atomic() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
|
||||
|
||||
@ -1367,7 +1372,12 @@ typedef struct atomic_flag
|
||||
{__c11_atomic_store(&__a_, false, __m);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic_flag() _NOEXCEPT {} // = default;
|
||||
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
atomic_flag() _NOEXCEPT = default;
|
||||
#else
|
||||
atomic_flag() _NOEXCEPT : __a_() {}
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
|
||||
|
||||
|
@ -915,7 +915,14 @@ protected:
|
||||
__pointer_allocator;
|
||||
typedef allocator_traits<__pointer_allocator> __map_traits;
|
||||
typedef typename __map_traits::pointer __map_pointer;
|
||||
typedef typename __map_traits::const_pointer __map_const_pointer;
|
||||
typedef typename __alloc_traits::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<const_pointer>
|
||||
#else
|
||||
rebind_alloc<const_pointer>::other
|
||||
#endif
|
||||
__const_pointer_allocator;
|
||||
typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer;
|
||||
typedef __split_buffer<pointer, __pointer_allocator> __map;
|
||||
|
||||
typedef __deque_iterator<value_type, pointer, reference, __map_pointer,
|
||||
@ -1053,7 +1060,7 @@ template <class _Tp, class _Allocator>
|
||||
typename __deque_base<_Tp, _Allocator>::const_iterator
|
||||
__deque_base<_Tp, _Allocator>::begin() const _NOEXCEPT
|
||||
{
|
||||
__map_const_pointer __mp = __map_.begin() + __start_ / __block_size;
|
||||
__map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size);
|
||||
return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
|
||||
}
|
||||
|
||||
@ -1071,7 +1078,7 @@ typename __deque_base<_Tp, _Allocator>::const_iterator
|
||||
__deque_base<_Tp, _Allocator>::end() const _NOEXCEPT
|
||||
{
|
||||
size_type __p = size() + __start_;
|
||||
__map_const_pointer __mp = __map_.begin() + __p / __block_size;
|
||||
__map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size);
|
||||
return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
|
||||
}
|
||||
|
||||
@ -1341,6 +1348,8 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool __invariants() const {return __base::__invariants();}
|
||||
private:
|
||||
typedef typename __base::__map_const_pointer __map_const_pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_type __recommend_blocks(size_type __n)
|
||||
{
|
||||
@ -2505,9 +2514,9 @@ void
|
||||
deque<_Tp, _Allocator>::pop_front()
|
||||
{
|
||||
allocator_type& __a = __base::__alloc();
|
||||
__alloc_traits::destroy(__a, *(__base::__map_.begin() +
|
||||
__base::__start_ / __base::__block_size) +
|
||||
__base::__start_ % __base::__block_size);
|
||||
__alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() +
|
||||
__base::__start_ / __base::__block_size) +
|
||||
__base::__start_ % __base::__block_size));
|
||||
--__base::size();
|
||||
if (++__base::__start_ >= 2 * __base::__block_size)
|
||||
{
|
||||
@ -2523,9 +2532,9 @@ deque<_Tp, _Allocator>::pop_back()
|
||||
{
|
||||
allocator_type& __a = __base::__alloc();
|
||||
size_type __p = __base::size() + __base::__start_ - 1;
|
||||
__alloc_traits::destroy(__a, *(__base::__map_.begin() +
|
||||
__p / __base::__block_size) +
|
||||
__p % __base::__block_size);
|
||||
__alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() +
|
||||
__p / __base::__block_size) +
|
||||
__p % __base::__block_size));
|
||||
--__base::size();
|
||||
if (__back_spare() >= 2 * __base::__block_size)
|
||||
{
|
||||
@ -2556,7 +2565,7 @@ deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __
|
||||
__fe = __fb + __bs;
|
||||
}
|
||||
if (__fb <= __vt && __vt < __fe)
|
||||
__vt = (const_iterator(__f.__m_iter_, __vt) -= __f - __r).__ptr_;
|
||||
__vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) -= __f - __r).__ptr_;
|
||||
__r = _VSTD::move(__fb, __fe, __r);
|
||||
__n -= __bs;
|
||||
__f += __bs;
|
||||
@ -2587,7 +2596,7 @@ deque<_Tp, _Allocator>::__move_backward_and_check(iterator __f, iterator __l, it
|
||||
__lb = __le - __bs;
|
||||
}
|
||||
if (__lb <= __vt && __vt < __le)
|
||||
__vt = (const_iterator(__l.__m_iter_, __vt) += __r - __l - 1).__ptr_;
|
||||
__vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) += __r - __l - 1).__ptr_;
|
||||
__r = _VSTD::move_backward(__lb, __le, __r);
|
||||
__n -= __bs;
|
||||
__l -= __bs - 1;
|
||||
@ -2618,7 +2627,7 @@ deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
|
||||
__fe = __fb + __bs;
|
||||
}
|
||||
if (__fb <= __vt && __vt < __fe)
|
||||
__vt = (const_iterator(__f.__m_iter_, __vt) += __r - __f).__ptr_;
|
||||
__vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) += __r - __f).__ptr_;
|
||||
for (; __fb != __fe; ++__fb, ++__r, ++__base::size())
|
||||
__alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb));
|
||||
__n -= __bs;
|
||||
@ -2654,7 +2663,7 @@ deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterat
|
||||
__lb = __le - __bs;
|
||||
}
|
||||
if (__lb <= __vt && __vt < __le)
|
||||
__vt = (const_iterator(__l.__m_iter_, __vt) -= __l - __r + 1).__ptr_;
|
||||
__vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) -= __l - __r + 1).__ptr_;
|
||||
while (__le != __lb)
|
||||
{
|
||||
__alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le));
|
||||
|
@ -232,7 +232,7 @@ public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename pointer_traits<__node_pointer>::element_type::value_type
|
||||
value_type;
|
||||
typedef value_type& reference;
|
||||
typedef value_type& reference;
|
||||
typedef typename pointer_traits<__node_pointer>::difference_type
|
||||
difference_type;
|
||||
typedef typename pointer_traits<__node_pointer>::template
|
||||
@ -249,7 +249,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __ptr_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return &__ptr_->__value_;}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_iterator& operator++()
|
||||
@ -303,7 +303,7 @@ class _LIBCPP_TYPE_VIS __forward_list_const_iterator
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef typename __node::value_type value_type;
|
||||
typedef const value_type& reference;
|
||||
typedef const value_type& reference;
|
||||
typedef typename pointer_traits<__node_const_pointer>::difference_type
|
||||
difference_type;
|
||||
typedef typename pointer_traits<__node_const_pointer>::template
|
||||
@ -323,7 +323,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return __ptr_->__value_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return &__ptr_->__value_;}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_const_iterator& operator++()
|
||||
@ -368,18 +368,27 @@ protected:
|
||||
__node_allocator;
|
||||
typedef allocator_traits<__node_allocator> __node_traits;
|
||||
typedef typename __node_traits::pointer __node_pointer;
|
||||
typedef typename __node_traits::const_pointer __node_const_pointer;
|
||||
typedef typename __node_traits::pointer __node_const_pointer;
|
||||
|
||||
typedef typename allocator_traits<allocator_type>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<__begin_node>
|
||||
#else
|
||||
rebind_alloc<__begin_node>::other
|
||||
#endif
|
||||
__begin_node_allocator;
|
||||
typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer;
|
||||
|
||||
__compressed_pair<__begin_node, __node_allocator> __before_begin_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__node_pointer __before_begin() _NOEXCEPT
|
||||
{return pointer_traits<__node_pointer>::pointer_to(
|
||||
static_cast<__node&>(__before_begin_.first()));}
|
||||
{return static_cast<__node_pointer>(pointer_traits<__begin_node_pointer>::
|
||||
pointer_to(__before_begin_.first()));}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__node_const_pointer __before_begin() const _NOEXCEPT
|
||||
{return pointer_traits<__node_const_pointer>::pointer_to(
|
||||
static_cast<const __node&>(__before_begin_.first()));}
|
||||
{return static_cast<__node_const_pointer>(pointer_traits<__begin_node_pointer>::
|
||||
pointer_to(const_cast<__begin_node&>(__before_begin_.first())));}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__node_allocator& __alloc() _NOEXCEPT
|
||||
@ -389,7 +398,7 @@ protected:
|
||||
{return __before_begin_.second();}
|
||||
|
||||
typedef __forward_list_iterator<__node_pointer> iterator;
|
||||
typedef __forward_list_const_iterator<__node_const_pointer> const_iterator;
|
||||
typedef __forward_list_const_iterator<__node_pointer> const_iterator;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__forward_list_base()
|
||||
@ -1050,7 +1059,7 @@ template <class... _Args>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args)
|
||||
{
|
||||
__node_pointer const __r = const_cast<__node_pointer>(__p.__ptr_);
|
||||
__node_pointer const __r = __p.__ptr_;
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
|
||||
@ -1067,7 +1076,7 @@ template <class _Tp, class _Alloc>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v)
|
||||
{
|
||||
__node_pointer const __r = const_cast<__node_pointer>(__p.__ptr_);
|
||||
__node_pointer const __r = __p.__ptr_;
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
|
||||
@ -1083,7 +1092,7 @@ template <class _Tp, class _Alloc>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v)
|
||||
{
|
||||
__node_pointer const __r = const_cast<__node_pointer>(__p.__ptr_);
|
||||
__node_pointer const __r = __p.__ptr_;
|
||||
__node_allocator& __a = base::__alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
|
||||
@ -1098,7 +1107,7 @@ typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n,
|
||||
const value_type& __v)
|
||||
{
|
||||
__node_pointer __r = const_cast<__node_pointer>(__p.__ptr_);
|
||||
__node_pointer __r = __p.__ptr_;
|
||||
if (__n > 0)
|
||||
{
|
||||
__node_allocator& __a = base::__alloc();
|
||||
@ -1148,7 +1157,7 @@ typename enable_if
|
||||
forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
|
||||
_InputIterator __f, _InputIterator __l)
|
||||
{
|
||||
__node_pointer __r = const_cast<__node_pointer>(__p.__ptr_);
|
||||
__node_pointer __r = __p.__ptr_;
|
||||
if (__f != __l)
|
||||
{
|
||||
__node_allocator& __a = base::__alloc();
|
||||
@ -1192,7 +1201,7 @@ template <class _Tp, class _Alloc>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::erase_after(const_iterator __f)
|
||||
{
|
||||
__node_pointer __p = const_cast<__node_pointer>(__f.__ptr_);
|
||||
__node_pointer __p = __f.__ptr_;
|
||||
__node_pointer __n = __p->__next_;
|
||||
__p->__next_ = __n->__next_;
|
||||
__node_allocator& __a = base::__alloc();
|
||||
@ -1205,10 +1214,10 @@ template <class _Tp, class _Alloc>
|
||||
typename forward_list<_Tp, _Alloc>::iterator
|
||||
forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l)
|
||||
{
|
||||
__node_pointer __e = const_cast<__node_pointer>(__l.__ptr_);
|
||||
__node_pointer __e = __l.__ptr_;
|
||||
if (__f != __l)
|
||||
{
|
||||
__node_pointer __p = const_cast<__node_pointer>(__f.__ptr_);
|
||||
__node_pointer __p = __f.__ptr_;
|
||||
__node_pointer __n = __p->__next_;
|
||||
if (__n != __e)
|
||||
{
|
||||
@ -1302,12 +1311,10 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
|
||||
const_iterator __lm1 = __x.before_begin();
|
||||
while (__lm1.__ptr_->__next_ != nullptr)
|
||||
++__lm1;
|
||||
const_cast<__node_pointer>(__lm1.__ptr_)->__next_ =
|
||||
const_cast<__node_pointer>(__p.__ptr_)->__next_;
|
||||
__lm1.__ptr_->__next_ = __p.__ptr_->__next_;
|
||||
}
|
||||
const_cast<__node_pointer>(__p.__ptr_)->__next_ =
|
||||
const_cast<__node_pointer>(__x.__before_begin())->__next_;
|
||||
const_cast<__node_pointer>(__x.__before_begin())->__next_ = nullptr;
|
||||
__p.__ptr_->__next_ = __x.__before_begin()->__next_;
|
||||
__x.__before_begin()->__next_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1320,12 +1327,9 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
|
||||
const_iterator __lm1 = _VSTD::next(__i);
|
||||
if (__p != __i && __p != __lm1)
|
||||
{
|
||||
const_cast<__node_pointer>(__i.__ptr_)->__next_ =
|
||||
const_cast<__node_pointer>(__lm1.__ptr_)->__next_;
|
||||
const_cast<__node_pointer>(__lm1.__ptr_)->__next_ =
|
||||
const_cast<__node_pointer>(__p.__ptr_)->__next_;
|
||||
const_cast<__node_pointer>(__p.__ptr_)->__next_ =
|
||||
const_cast<__node_pointer>(__lm1.__ptr_);
|
||||
__i.__ptr_->__next_ = __lm1.__ptr_->__next_;
|
||||
__lm1.__ptr_->__next_ = __p.__ptr_->__next_;
|
||||
__p.__ptr_->__next_ = __lm1.__ptr_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1342,12 +1346,9 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
|
||||
++__lm1;
|
||||
if (__f != __lm1)
|
||||
{
|
||||
const_cast<__node_pointer>(__lm1.__ptr_)->__next_ =
|
||||
const_cast<__node_pointer>(__p.__ptr_)->__next_;
|
||||
const_cast<__node_pointer>(__p.__ptr_)->__next_ =
|
||||
const_cast<__node_pointer>(__f.__ptr_)->__next_;
|
||||
const_cast<__node_pointer>(__f.__ptr_)->__next_ =
|
||||
const_cast<__node_pointer>(__l.__ptr_);
|
||||
__lm1.__ptr_->__next_ = __p.__ptr_->__next_;
|
||||
__p.__ptr_->__next_ = __f.__ptr_->__next_;
|
||||
__f.__ptr_->__next_ = __l.__ptr_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1139,8 +1139,11 @@ public:
|
||||
function(const function&);
|
||||
function(function&&) _NOEXCEPT;
|
||||
template<class _Fp>
|
||||
function(_Fp,
|
||||
typename enable_if<__callable<_Fp>::value>::type* = 0);
|
||||
function(_Fp, typename enable_if
|
||||
<
|
||||
__callable<_Fp>::value &&
|
||||
!is_same<_Fp, function>::value
|
||||
>::type* = 0);
|
||||
|
||||
template<class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1162,7 +1165,8 @@ public:
|
||||
template<class _Fp>
|
||||
typename enable_if
|
||||
<
|
||||
__callable<typename decay<_Fp>::type>::value,
|
||||
__callable<typename decay<_Fp>::type>::value &&
|
||||
!is_same<typename remove_reference<_Fp>::type, function>::value,
|
||||
function&
|
||||
>::type
|
||||
operator=(_Fp&&);
|
||||
@ -1266,7 +1270,11 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
|
||||
template<class _Rp, class ..._ArgTypes>
|
||||
template <class _Fp>
|
||||
function<_Rp(_ArgTypes...)>::function(_Fp __f,
|
||||
typename enable_if<__callable<_Fp>::value>::type*)
|
||||
typename enable_if
|
||||
<
|
||||
__callable<_Fp>::value &&
|
||||
!is_same<_Fp, function>::value
|
||||
>::type*)
|
||||
: __f_(0)
|
||||
{
|
||||
if (__not_null(__f))
|
||||
@ -1370,7 +1378,8 @@ template<class _Rp, class ..._ArgTypes>
|
||||
template <class _Fp>
|
||||
typename enable_if
|
||||
<
|
||||
function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value,
|
||||
function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
|
||||
!is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
|
||||
function<_Rp(_ArgTypes...)>&
|
||||
>::type
|
||||
function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
|
||||
@ -1594,12 +1603,24 @@ template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
|
||||
class _TupleUj>
|
||||
struct ____mu_return;
|
||||
|
||||
template <bool _Invokable, class _Ti, class ..._Uj>
|
||||
struct ____mu_return_invokable // false
|
||||
{
|
||||
typedef __nat type;
|
||||
};
|
||||
|
||||
template <class _Ti, class ..._Uj>
|
||||
struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
|
||||
struct ____mu_return_invokable<true, _Ti, _Uj...>
|
||||
{
|
||||
typedef typename __invoke_of<_Ti&, _Uj...>::type type;
|
||||
};
|
||||
|
||||
template <class _Ti, class ..._Uj>
|
||||
struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
|
||||
: public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Ti, class _TupleUj>
|
||||
struct ____mu_return<_Ti, false, false, true, _TupleUj>
|
||||
{
|
||||
@ -1737,7 +1758,9 @@ public:
|
||||
template <class _Gp, class ..._BA,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<_Fd, _Gp>::value
|
||||
is_constructible<_Fd, _Gp>::value &&
|
||||
!is_same<typename remove_reference<_Gp>::type,
|
||||
__bind>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
|
||||
@ -1802,7 +1825,13 @@ public:
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
template <class _Gp, class ..._BA>
|
||||
template <class _Gp, class ..._BA,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<_Fd, _Gp>::value &&
|
||||
!is_same<typename remove_reference<_Gp>::type,
|
||||
__bind_r>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
|
||||
: base(_VSTD::forward<_Gp>(__f),
|
||||
|
@ -403,6 +403,72 @@ _LIBCPP_DECLARE_STRONG_ENUM(launch)
|
||||
};
|
||||
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
|
||||
#ifdef _LIBCXX_UNDERLYING_TYPE
|
||||
typedef underlying_type<launch>::type __launch_underlying_type;
|
||||
#else
|
||||
typedef int __launch_underlying_type;
|
||||
#endif
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR
|
||||
launch
|
||||
operator&(launch __x, launch __y)
|
||||
{
|
||||
return static_cast<launch>(static_cast<__launch_underlying_type>(__x) &
|
||||
static_cast<__launch_underlying_type>(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR
|
||||
launch
|
||||
operator|(launch __x, launch __y)
|
||||
{
|
||||
return static_cast<launch>(static_cast<__launch_underlying_type>(__x) |
|
||||
static_cast<__launch_underlying_type>(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR
|
||||
launch
|
||||
operator^(launch __x, launch __y)
|
||||
{
|
||||
return static_cast<launch>(static_cast<__launch_underlying_type>(__x) ^
|
||||
static_cast<__launch_underlying_type>(__y));
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR
|
||||
launch
|
||||
operator~(launch __x)
|
||||
{
|
||||
return static_cast<launch>(~static_cast<__launch_underlying_type>(__x) & 3);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
launch&
|
||||
operator&=(launch& __x, launch __y)
|
||||
{
|
||||
__x = __x & __y; return __x;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
launch&
|
||||
operator|=(launch& __x, launch __y)
|
||||
{
|
||||
__x = __x | __y; return __x;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
launch&
|
||||
operator^=(launch& __x, launch __y)
|
||||
{
|
||||
__x = __x ^ __y; return __x;
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_STRONG_ENUMS
|
||||
|
||||
//enum class future_status
|
||||
_LIBCPP_DECLARE_STRONG_ENUM(future_status)
|
||||
{
|
||||
|
@ -1144,8 +1144,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
|
||||
break;
|
||||
}
|
||||
++__gc_;
|
||||
char_type __ch = traits_type::to_char_type(__i);
|
||||
if (traits_type::eq(__ch, static_cast<char_type>(__dlm)))
|
||||
if (traits_type::eq_int_type(__i, __dlm))
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1160,8 +1159,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
|
||||
break;
|
||||
}
|
||||
++__gc_;
|
||||
char_type __ch = traits_type::to_char_type(__i);
|
||||
if (traits_type::eq(__ch, static_cast<char_type>(__dlm)))
|
||||
if (traits_type::eq_int_type(__i, __dlm))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1135,7 +1135,14 @@ public:
|
||||
#endif
|
||||
return *__i;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return &(operator*());}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
"Attempted to dereference a non-dereferenceable iterator");
|
||||
#endif
|
||||
return (pointer)&reinterpret_cast<const volatile char&>(*__i);
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
@ -196,13 +196,20 @@ struct __list_node_base
|
||||
rebind<__list_node<_Tp, _VoidPtr> >::other pointer;
|
||||
#endif
|
||||
|
||||
typedef typename pointer_traits<_VoidPtr>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind<__list_node_base> __base_pointer;
|
||||
#else
|
||||
rebind<__list_node_base>::other __base_pointer;
|
||||
#endif
|
||||
|
||||
pointer __prev_;
|
||||
pointer __next_;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__list_node_base()
|
||||
: __prev_(static_cast<pointer>(this)),
|
||||
__next_(static_cast<pointer>(this))
|
||||
: __prev_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this))),
|
||||
__next_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this)))
|
||||
{}
|
||||
};
|
||||
|
||||
@ -305,7 +312,14 @@ public:
|
||||
return __ptr_->__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return &(operator*());}
|
||||
pointer operator->() const
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
"Attempted to dereference a non-dereferenceable list::iterator");
|
||||
#endif
|
||||
return pointer_traits<pointer>::pointer_to(__ptr_->__value_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__list_iterator& operator++()
|
||||
@ -352,9 +366,9 @@ class _LIBCPP_TYPE_VIS __list_const_iterator
|
||||
{
|
||||
typedef typename pointer_traits<_VoidPtr>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind<const __list_node<_Tp, _VoidPtr> > __node_pointer;
|
||||
rebind<__list_node<_Tp, _VoidPtr> > __node_pointer;
|
||||
#else
|
||||
rebind<const __list_node<_Tp, _VoidPtr> >::other __node_pointer;
|
||||
rebind<__list_node<_Tp, _VoidPtr> >::other __node_pointer;
|
||||
#endif
|
||||
|
||||
__node_pointer __ptr_;
|
||||
@ -439,7 +453,14 @@ public:
|
||||
return __ptr_->__value_;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return &(operator*());}
|
||||
pointer operator->() const
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
"Attempted to dereference a non-dereferenceable list::iterator");
|
||||
#endif
|
||||
return pointer_traits<pointer>::pointer_to(__ptr_->__value_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__list_const_iterator& operator++()
|
||||
@ -505,11 +526,20 @@ protected:
|
||||
__node_allocator;
|
||||
typedef allocator_traits<__node_allocator> __node_alloc_traits;
|
||||
typedef typename __node_alloc_traits::pointer __node_pointer;
|
||||
typedef typename __node_alloc_traits::const_pointer __node_const_pointer;
|
||||
typedef typename __node_alloc_traits::pointer __node_const_pointer;
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
typedef typename __alloc_traits::difference_type difference_type;
|
||||
|
||||
typedef typename __alloc_traits::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<__node_base>
|
||||
#else
|
||||
rebind_alloc<__node_base>::other
|
||||
#endif
|
||||
__node_base_allocator;
|
||||
typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
|
||||
|
||||
__node_base __end_;
|
||||
__compressed_pair<size_type, __node_allocator> __size_alloc_;
|
||||
|
||||
@ -525,7 +555,7 @@ protected:
|
||||
const __node_allocator& __node_alloc() const _NOEXCEPT
|
||||
{return __size_alloc_.second();}
|
||||
|
||||
static void __unlink_nodes(__node_base& __f, __node_base& __l) _NOEXCEPT;
|
||||
static void __unlink_nodes(__node_pointer __f, __node_pointer __l) _NOEXCEPT;
|
||||
|
||||
__list_imp()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
|
||||
@ -557,18 +587,22 @@ protected:
|
||||
iterator end() _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return iterator(static_cast<__node_pointer>(&__end_), this);
|
||||
return iterator(static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__end_)), this);
|
||||
#else
|
||||
return iterator(static_cast<__node_pointer>(&__end_));
|
||||
return iterator(static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__end_)));
|
||||
#endif
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return const_iterator(static_cast<__node_const_pointer>(&__end_), this);
|
||||
return const_iterator(static_cast<__node_const_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_))), this);
|
||||
#else
|
||||
return const_iterator(static_cast<__node_const_pointer>(&__end_));
|
||||
return const_iterator(static_cast<__node_const_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_))));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -637,11 +671,11 @@ private:
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
__list_imp<_Tp, _Alloc>::__unlink_nodes(__node_base& __f, __node_base& __l)
|
||||
__list_imp<_Tp, _Alloc>::__unlink_nodes(__node_pointer __f, __node_pointer __l)
|
||||
_NOEXCEPT
|
||||
{
|
||||
__f.__prev_->__next_ = __l.__next_;
|
||||
__l.__next_->__prev_ = __f.__prev_;
|
||||
__f->__prev_->__next_ = __l->__next_;
|
||||
__l->__next_->__prev_ = __f->__prev_;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
@ -676,15 +710,16 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
|
||||
{
|
||||
__node_allocator& __na = __node_alloc();
|
||||
__node_pointer __f = __end_.__next_;
|
||||
__node_pointer __l = static_cast<__node_pointer>(&__end_);
|
||||
__unlink_nodes(*__f, *__l->__prev_);
|
||||
__node_pointer __l = static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__end_));
|
||||
__unlink_nodes(__f, __l->__prev_);
|
||||
__sz() = 0;
|
||||
while (__f != __l)
|
||||
{
|
||||
__node& __n = *__f;
|
||||
__node_pointer __n = __f;
|
||||
__f = __f->__next_;
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n.__value_));
|
||||
__node_alloc_traits::deallocate(__na, _VSTD::addressof(__n), 1);
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
|
||||
__node_alloc_traits::deallocate(__na, __n, 1);
|
||||
}
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__c_node* __c = __get_db()->__find_c_and_lock(this);
|
||||
@ -719,16 +754,20 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
|
||||
swap(__sz(), __c.__sz());
|
||||
swap(__end_, __c.__end_);
|
||||
if (__sz() == 0)
|
||||
__end_.__next_ = __end_.__prev_ = &static_cast<__node&>(__end_);
|
||||
__end_.__next_ = __end_.__prev_ = static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__end_));
|
||||
else
|
||||
__end_.__prev_->__next_ = __end_.__next_->__prev_
|
||||
= &static_cast<__node&>(__end_);
|
||||
= static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__end_));
|
||||
if (__c.__sz() == 0)
|
||||
__c.__end_.__next_ = __c.__end_.__prev_
|
||||
= &static_cast<__node&>(__c.__end_);
|
||||
= static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
|
||||
else
|
||||
__c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_
|
||||
= &static_cast<__node&>(__c.__end_);
|
||||
= static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__libcpp_db* __db = __get_db();
|
||||
__c_node* __cn1 = __db->__find_c_and_lock(this);
|
||||
@ -740,7 +779,8 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
|
||||
{
|
||||
--__p;
|
||||
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
|
||||
if (__i->__ptr_ == static_cast<__node_pointer>(&__c.__end_))
|
||||
if (__i->__ptr_ == static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)))
|
||||
{
|
||||
__cn2->__add(*__p);
|
||||
if (--__cn1->end_ != __p)
|
||||
@ -753,7 +793,8 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
|
||||
{
|
||||
--__p;
|
||||
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
|
||||
if (__i->__ptr_ == static_cast<__node_pointer>(&__end_))
|
||||
if (__i->__ptr_ == static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__end_)))
|
||||
{
|
||||
__cn1->__add(*__p);
|
||||
if (--__cn2->end_ != __p)
|
||||
@ -775,6 +816,8 @@ class _LIBCPP_TYPE_VIS list
|
||||
typedef typename base::__node_allocator __node_allocator;
|
||||
typedef typename base::__node_pointer __node_pointer;
|
||||
typedef typename base::__node_alloc_traits __node_alloc_traits;
|
||||
typedef typename base::__node_base __node_base;
|
||||
typedef typename base::__node_base_pointer __node_base_pointer;
|
||||
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
@ -1014,7 +1057,7 @@ public:
|
||||
#endif // _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
||||
private:
|
||||
static void __link_nodes(__node& __p, __node& __f, __node& __l);
|
||||
static void __link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l);
|
||||
iterator __iterator(size_type __n);
|
||||
template <class _Comp>
|
||||
static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
|
||||
@ -1028,12 +1071,12 @@ private:
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
list<_Tp, _Alloc>::__link_nodes(__node& __p, __node& __f, __node& __l)
|
||||
list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l)
|
||||
{
|
||||
__p.__prev_->__next_ = &__f;
|
||||
__f.__prev_ = __p.__prev_;
|
||||
__p.__prev_ = &__l;
|
||||
__l.__next_ = &__p;
|
||||
__p->__prev_->__next_ = __f;
|
||||
__f->__prev_ = __p->__prev_;
|
||||
__p->__prev_ = __l;
|
||||
__l->__next_ = __p;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
@ -1290,7 +1333,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), *__hold, *__hold);
|
||||
__link_nodes(__p.__ptr_, __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return iterator(__hold.release(), this);
|
||||
@ -1307,9 +1350,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
|
||||
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
|
||||
"list::insert(iterator, n, x) called with an iterator not"
|
||||
" referring to this list");
|
||||
iterator __r(const_cast<__node_pointer>(__p.__ptr_), this);
|
||||
iterator __r(__p.__ptr_, this);
|
||||
#else
|
||||
iterator __r(const_cast<__node_pointer>(__p.__ptr_));
|
||||
iterator __r(__p.__ptr_);
|
||||
#endif
|
||||
if (__n > 0)
|
||||
{
|
||||
@ -1359,7 +1402,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), *__r.__ptr_, *__e.__ptr_);
|
||||
__link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
|
||||
base::__sz() += __ds;
|
||||
}
|
||||
return __r;
|
||||
@ -1375,9 +1418,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
|
||||
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
|
||||
"list::insert(iterator, range) called with an iterator not"
|
||||
" referring to this list");
|
||||
iterator __r(const_cast<__node_pointer>(__p.__ptr_), this);
|
||||
iterator __r(__p.__ptr_, this);
|
||||
#else
|
||||
iterator __r(const_cast<__node_pointer>(__p.__ptr_));
|
||||
iterator __r(__p.__ptr_);
|
||||
#endif
|
||||
if (__f != __l)
|
||||
{
|
||||
@ -1427,7 +1470,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), *__r.__ptr_, *__e.__ptr_);
|
||||
__link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
|
||||
base::__sz() += __ds;
|
||||
}
|
||||
return __r;
|
||||
@ -1441,7 +1484,7 @@ list<_Tp, _Alloc>::push_front(const value_type& __x)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_nodes(*base::__end_.__next_, *__hold, *__hold);
|
||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1454,7 +1497,8 @@ list<_Tp, _Alloc>::push_back(const value_type& __x)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_nodes(static_cast<__node&>(base::__end_), *__hold, *__hold);
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1469,7 +1513,7 @@ list<_Tp, _Alloc>::push_front(value_type&& __x)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||
__link_nodes(*base::__end_.__next_, *__hold, *__hold);
|
||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1482,7 +1526,8 @@ list<_Tp, _Alloc>::push_back(value_type&& __x)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||
__link_nodes(static_cast<__node&>(base::__end_), *__hold, *__hold);
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1498,7 +1543,7 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__link_nodes(*base::__end_.__next_, *__hold, *__hold);
|
||||
__link_nodes(base::__end_.__next_, __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1512,7 +1557,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__link_nodes(static_cast<__node&>(base::__end_), *__hold, *__hold);
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
__hold.release();
|
||||
}
|
||||
@ -1532,7 +1578,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), *__hold, *__hold);
|
||||
__link_nodes(__p.__ptr_, __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return iterator(__hold.release(), this);
|
||||
@ -1557,7 +1603,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), *__hold, *__hold);
|
||||
__link_nodes(__p.__ptr_, __hold.get(), __hold.get());
|
||||
++base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return iterator(__hold.release(), this);
|
||||
@ -1574,7 +1620,7 @@ list<_Tp, _Alloc>::pop_front()
|
||||
{
|
||||
_LIBCPP_ASSERT(!empty(), "list::pop_front() called with empty list");
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
__node& __n = *base::__end_.__next_;
|
||||
__node_pointer __n = base::__end_.__next_;
|
||||
base::__unlink_nodes(__n, __n);
|
||||
--base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@ -1583,7 +1629,7 @@ list<_Tp, _Alloc>::pop_front()
|
||||
{
|
||||
--__p;
|
||||
iterator* __i = static_cast<iterator*>((*__p)->__i_);
|
||||
if (__i->__ptr_ == &__n)
|
||||
if (__i->__ptr_ == __n)
|
||||
{
|
||||
(*__p)->__c_ = nullptr;
|
||||
if (--__c->end_ != __p)
|
||||
@ -1592,17 +1638,17 @@ list<_Tp, _Alloc>::pop_front()
|
||||
}
|
||||
__get_db()->unlock();
|
||||
#endif
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n.__value_));
|
||||
__node_alloc_traits::deallocate(__na, _VSTD::addressof(__n), 1);
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
|
||||
__node_alloc_traits::deallocate(__na, __n, 1);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
void
|
||||
list<_Tp, _Alloc>::pop_back()
|
||||
{
|
||||
_LIBCPP_ASSERT(!empty(), "list::pop_front() called with empty list");
|
||||
_LIBCPP_ASSERT(!empty(), "list::pop_back() called with empty list");
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
__node& __n = *base::__end_.__prev_;
|
||||
__node_pointer __n = base::__end_.__prev_;
|
||||
base::__unlink_nodes(__n, __n);
|
||||
--base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@ -1611,7 +1657,7 @@ list<_Tp, _Alloc>::pop_back()
|
||||
{
|
||||
--__p;
|
||||
iterator* __i = static_cast<iterator*>((*__p)->__i_);
|
||||
if (__i->__ptr_ == &__n)
|
||||
if (__i->__ptr_ == __n)
|
||||
{
|
||||
(*__p)->__c_ = nullptr;
|
||||
if (--__c->end_ != __p)
|
||||
@ -1620,8 +1666,8 @@ list<_Tp, _Alloc>::pop_back()
|
||||
}
|
||||
__get_db()->unlock();
|
||||
#endif
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n.__value_));
|
||||
__node_alloc_traits::deallocate(__na, _VSTD::addressof(__n), 1);
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
|
||||
__node_alloc_traits::deallocate(__na, __n, 1);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
@ -1636,8 +1682,8 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
|
||||
_LIBCPP_ASSERT(__p != end(),
|
||||
"list::erase(iterator) called with a non-dereferenceable iterator");
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
__node& __n = const_cast<__node&>(*__p.__ptr_);
|
||||
__node_pointer __r = __n.__next_;
|
||||
__node_pointer __n = __p.__ptr_;
|
||||
__node_pointer __r = __n->__next_;
|
||||
base::__unlink_nodes(__n, __n);
|
||||
--base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@ -1646,7 +1692,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
|
||||
{
|
||||
--__p;
|
||||
iterator* __i = static_cast<iterator*>((*__p)->__i_);
|
||||
if (__i->__ptr_ == &__n)
|
||||
if (__i->__ptr_ == __n)
|
||||
{
|
||||
(*__p)->__c_ = nullptr;
|
||||
if (--__c->end_ != __p)
|
||||
@ -1655,8 +1701,8 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
|
||||
}
|
||||
__get_db()->unlock();
|
||||
#endif
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n.__value_));
|
||||
__node_alloc_traits::deallocate(__na, _VSTD::addressof(__n), 1);
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
|
||||
__node_alloc_traits::deallocate(__na, __n, 1);
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return iterator(__r, this);
|
||||
#else
|
||||
@ -1676,10 +1722,10 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
|
||||
if (__f != __l)
|
||||
{
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
base::__unlink_nodes(const_cast<__node&>(*__f.__ptr_), *__l.__ptr_->__prev_);
|
||||
base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
|
||||
while (__f != __l)
|
||||
{
|
||||
__node& __n = const_cast<__node&>(*__f.__ptr_);
|
||||
__node_pointer __n = __f.__ptr_;
|
||||
++__f;
|
||||
--base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@ -1688,7 +1734,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
|
||||
{
|
||||
--__p;
|
||||
iterator* __i = static_cast<iterator*>((*__p)->__i_);
|
||||
if (__i->__ptr_ == &__n)
|
||||
if (__i->__ptr_ == __n)
|
||||
{
|
||||
(*__p)->__c_ = nullptr;
|
||||
if (--__c->end_ != __p)
|
||||
@ -1697,14 +1743,14 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
|
||||
}
|
||||
__get_db()->unlock();
|
||||
#endif
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n.__value_));
|
||||
__node_alloc_traits::deallocate(__na, _VSTD::addressof(__n), 1);
|
||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
|
||||
__node_alloc_traits::deallocate(__na, __n, 1);
|
||||
}
|
||||
}
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
return iterator(const_cast<__node_pointer>(__l.__ptr_), this);
|
||||
return iterator(__l.__ptr_, this);
|
||||
#else
|
||||
return iterator(const_cast<__node_pointer>(__l.__ptr_));
|
||||
return iterator(__l.__ptr_);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1762,7 +1808,8 @@ list<_Tp, _Alloc>::resize(size_type __n)
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__link_nodes(static_cast<__node&>(base::__end_), *__r.__ptr_, *__e.__ptr_);
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_);
|
||||
base::__sz() += __ds;
|
||||
}
|
||||
}
|
||||
@ -1821,7 +1868,8 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
|
||||
throw;
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
__link_nodes(static_cast<__node&>(base::__end_), *__r.__ptr_, *__e.__ptr_);
|
||||
__link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
|
||||
pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_);
|
||||
base::__sz() += __ds;
|
||||
}
|
||||
}
|
||||
@ -1839,10 +1887,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
|
||||
#endif
|
||||
if (!__c.empty())
|
||||
{
|
||||
__node& __f = *__c.__end_.__next_;
|
||||
__node& __l = *__c.__end_.__prev_;
|
||||
__node_pointer __f = __c.__end_.__next_;
|
||||
__node_pointer __l = __c.__end_.__prev_;
|
||||
base::__unlink_nodes(__f, __l);
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), __f, __l);
|
||||
__link_nodes(__p.__ptr_, __f, __l);
|
||||
base::__sz() += __c.__sz();
|
||||
__c.__sz() = 0;
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@ -1853,7 +1901,8 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
|
||||
{
|
||||
--__p;
|
||||
iterator* __i = static_cast<iterator*>((*__p)->__i_);
|
||||
if (__i->__ptr_ != static_cast<__node_pointer>(&__c.__end_))
|
||||
if (__i->__ptr_ != static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)))
|
||||
{
|
||||
__cn1->__add(*__p);
|
||||
(*__p)->__c_ = __cn1;
|
||||
@ -1883,9 +1932,9 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
|
||||
#endif
|
||||
if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
|
||||
{
|
||||
__node& __f = const_cast<__node&>(*__i.__ptr_);
|
||||
__node_pointer __f = __i.__ptr_;
|
||||
base::__unlink_nodes(__f, __f);
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), __f, __f);
|
||||
__link_nodes(__p.__ptr_, __f, __f);
|
||||
--__c.__sz();
|
||||
++base::__sz();
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@ -1896,7 +1945,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
|
||||
{
|
||||
--__p;
|
||||
iterator* __j = static_cast<iterator*>((*__p)->__i_);
|
||||
if (__j->__ptr_ == &__f)
|
||||
if (__j->__ptr_ == __f)
|
||||
{
|
||||
__cn1->__add(*__p);
|
||||
(*__p)->__c_ = __cn1;
|
||||
@ -1937,11 +1986,11 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
|
||||
__c.__sz() -= __s;
|
||||
base::__sz() += __s;
|
||||
}
|
||||
__node& __first = const_cast<__node&>(*__f.__ptr_);
|
||||
__node_pointer __first = __f.__ptr_;
|
||||
--__l;
|
||||
__node& __last = const_cast<__node&>(*__l.__ptr_);
|
||||
__node_pointer __last = __l.__ptr_;
|
||||
base::__unlink_nodes(__first, __last);
|
||||
__link_nodes(const_cast<__node&>(*__p.__ptr_), __first, __last);
|
||||
__link_nodes(__p.__ptr_, __first, __last);
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__libcpp_db* __db = __get_db();
|
||||
__c_node* __cn1 = __db->__find_c_and_lock(this);
|
||||
@ -1950,7 +1999,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
|
||||
{
|
||||
--__p;
|
||||
iterator* __j = static_cast<iterator*>((*__p)->__i_);
|
||||
for (__node_pointer __k = const_cast<__node_pointer>(__f.__ptr_);
|
||||
for (__node_pointer __k = __f.__ptr_;
|
||||
__k != __l.__ptr_; __k = __k->__next_)
|
||||
{
|
||||
if (__j->__ptr_ == __k)
|
||||
@ -2056,12 +2105,12 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
|
||||
;
|
||||
base::__sz() += __ds;
|
||||
__c.__sz() -= __ds;
|
||||
__node& __f = *__f2.__ptr_;
|
||||
__node& __l = *__m2.__ptr_->__prev_;
|
||||
__node_pointer __f = __f2.__ptr_;
|
||||
__node_pointer __l = __m2.__ptr_->__prev_;
|
||||
__f2 = __m2;
|
||||
base::__unlink_nodes(__f, __l);
|
||||
__m2 = _VSTD::next(__f1);
|
||||
__link_nodes(*__f1.__ptr_, __f, __l);
|
||||
__link_nodes(__f1.__ptr_, __f, __l);
|
||||
__f1 = __m2;
|
||||
}
|
||||
else
|
||||
@ -2076,7 +2125,8 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
|
||||
{
|
||||
--__p;
|
||||
iterator* __i = static_cast<iterator*>((*__p)->__i_);
|
||||
if (__i->__ptr_ != static_cast<__node_pointer>(&__c.__end_))
|
||||
if (__i->__ptr_ != static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)))
|
||||
{
|
||||
__cn1->__add(*__p);
|
||||
(*__p)->__c_ = __cn1;
|
||||
@ -2119,9 +2169,9 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
|
||||
case 2:
|
||||
if (__comp(*--__e2, *__f1))
|
||||
{
|
||||
__node& __f = *__e2.__ptr_;
|
||||
__node_pointer __f = __e2.__ptr_;
|
||||
base::__unlink_nodes(__f, __f);
|
||||
__link_nodes(*__f1.__ptr_, __f, __f);
|
||||
__link_nodes(__f1.__ptr_, __f, __f);
|
||||
return __e2;
|
||||
}
|
||||
return __f1;
|
||||
@ -2135,13 +2185,13 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
|
||||
iterator __m2 = _VSTD::next(__f2);
|
||||
for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
|
||||
;
|
||||
__node& __f = *__f2.__ptr_;
|
||||
__node& __l = *__m2.__ptr_->__prev_;
|
||||
__node_pointer __f = __f2.__ptr_;
|
||||
__node_pointer __l = __m2.__ptr_->__prev_;
|
||||
__r = __f2;
|
||||
__e1 = __f2 = __m2;
|
||||
base::__unlink_nodes(__f, __l);
|
||||
__m2 = _VSTD::next(__f1);
|
||||
__link_nodes(*__f1.__ptr_, __f, __l);
|
||||
__link_nodes(__f1.__ptr_, __f, __l);
|
||||
__f1 = __m2;
|
||||
}
|
||||
else
|
||||
@ -2153,14 +2203,14 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
|
||||
iterator __m2 = _VSTD::next(__f2);
|
||||
for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
|
||||
;
|
||||
__node& __f = *__f2.__ptr_;
|
||||
__node& __l = *__m2.__ptr_->__prev_;
|
||||
__node_pointer __f = __f2.__ptr_;
|
||||
__node_pointer __l = __m2.__ptr_->__prev_;
|
||||
if (__e1 == __f2)
|
||||
__e1 = __m2;
|
||||
__f2 = __m2;
|
||||
base::__unlink_nodes(__f, __l);
|
||||
__m2 = _VSTD::next(__f1);
|
||||
__link_nodes(*__f1.__ptr_, __f, __l);
|
||||
__link_nodes(__f1.__ptr_, __f, __l);
|
||||
__f1 = __m2;
|
||||
}
|
||||
else
|
||||
@ -2198,7 +2248,8 @@ template <class _Tp, class _Alloc>
|
||||
bool
|
||||
list<_Tp, _Alloc>::__dereferenceable(const const_iterator* __i) const
|
||||
{
|
||||
return __i->__ptr_ != &this->__end_;
|
||||
return __i->__ptr_ != static_cast<__node_pointer>(
|
||||
pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(this->__end_)));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
|
@ -206,6 +206,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
# define _LIBCPP_GET_C_LOCALE 0
|
||||
#elif defined(__NetBSD__)
|
||||
# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
|
||||
#else
|
||||
# define _LIBCPP_GET_C_LOCALE __cloc()
|
||||
// Get the C locale object
|
||||
@ -354,20 +356,6 @@ size_t __mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len,
|
||||
#endif
|
||||
}
|
||||
|
||||
inline
|
||||
int __sprintf_l(char *__s, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
va_start(__va, __format);
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __res = vsprintf_l(__s, __l, __format, __va);
|
||||
#else
|
||||
__locale_raii __current(uselocale(__l), uselocale);
|
||||
int __res = vsprintf(__s, __format, __va);
|
||||
#endif
|
||||
va_end(__va);
|
||||
return __res;
|
||||
}
|
||||
|
||||
inline
|
||||
int __snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
|
||||
va_list __va;
|
||||
@ -1801,9 +1789,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = sprintf_l(__nar, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
@ -1831,9 +1819,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = sprintf_l(__nar, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
@ -1861,9 +1849,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = sprintf_l(__nar, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
@ -1891,9 +1879,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
+ 1;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = sprintf_l(__nar, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
@ -2055,9 +2043,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
|
||||
const unsigned __nbuf = 20;
|
||||
char __nar[__nbuf];
|
||||
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
|
||||
int __nc = sprintf_l(__nar, _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
|
||||
#else
|
||||
int __nc = __sprintf_l(__nar, __cloc(), __fmt, __v);
|
||||
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
|
||||
#endif
|
||||
char* __ne = __nar + __nc;
|
||||
char* __np = this->__identify_padding(__nar, __ne, __iob);
|
||||
|
@ -381,7 +381,7 @@ swap(multimap<Key, T, Compare, Allocator>& x,
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, bool = is_empty<_Compare>::value
|
||||
template <class _Key, class _CP, class _Compare, bool = is_empty<_Compare>::value
|
||||
#if __has_feature(is_final)
|
||||
&& !__is_final(_Compare)
|
||||
#endif
|
||||
@ -389,8 +389,6 @@ template <class _Key, class _Tp, class _Compare, bool = is_empty<_Compare>::valu
|
||||
class __map_value_compare
|
||||
: private _Compare
|
||||
{
|
||||
typedef pair<typename std::remove_const<_Key>::type, _Tp> _Pp;
|
||||
typedef pair<const _Key, _Tp> _CP;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__map_value_compare()
|
||||
@ -404,41 +402,20 @@ public:
|
||||
const _Compare& key_comp() const _NOEXCEPT {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _CP& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _Pp& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x.first, __y.first);}
|
||||
{return static_cast<const _Compare&>(*this)(__x.__cc.first, __y.__cc.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _Key& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _CP& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Pp& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Key& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x.first, __y);}
|
||||
{return static_cast<const _Compare&>(*this)(__x.__cc.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _CP& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Pp& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Key& __y) const
|
||||
{return static_cast<const _Compare&>(*this)(__x, __y);}
|
||||
{return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);}
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _Compare>
|
||||
class __map_value_compare<_Key, _Tp, _Compare, false>
|
||||
template <class _Key, class _CP, class _Compare>
|
||||
class __map_value_compare<_Key, _CP, _Compare, false>
|
||||
{
|
||||
_Compare comp;
|
||||
|
||||
typedef pair<typename std::remove_const<_Key>::type, _Tp> _Pp;
|
||||
typedef pair<const _Key, _Tp> _CP;
|
||||
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__map_value_compare()
|
||||
@ -453,31 +430,13 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _CP& __y) const
|
||||
{return comp(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _Pp& __y) const
|
||||
{return comp(__x.first, __y.first);}
|
||||
{return comp(__x.__cc.first, __y.__cc.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _CP& __x, const _Key& __y) const
|
||||
{return comp(__x.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _CP& __y) const
|
||||
{return comp(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Pp& __y) const
|
||||
{return comp(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Key& __y) const
|
||||
{return comp(__x.first, __y);}
|
||||
{return comp(__x.__cc.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _CP& __y) const
|
||||
{return comp(__x, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Pp& __y) const
|
||||
{return comp(__x, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Key& __y) const
|
||||
{return comp(__x, __y);}
|
||||
{return comp(__x, __y.__cc.first);}
|
||||
};
|
||||
|
||||
template <class _Allocator>
|
||||
@ -489,8 +448,8 @@ class __map_node_destructor
|
||||
public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
private:
|
||||
typedef typename value_type::first_type first_type;
|
||||
typedef typename value_type::second_type second_type;
|
||||
typedef typename value_type::value_type::first_type first_type;
|
||||
typedef typename value_type::value_type::second_type second_type;
|
||||
|
||||
allocator_type& __na_;
|
||||
|
||||
@ -522,9 +481,9 @@ public:
|
||||
void operator()(pointer __p) _NOEXCEPT
|
||||
{
|
||||
if (__second_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second));
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
|
||||
if (__first_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first));
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
|
||||
if (__p)
|
||||
__alloc_traits::deallocate(__na_, __p, 1);
|
||||
}
|
||||
@ -542,8 +501,8 @@ class _LIBCPP_TYPE_VIS __map_iterator
|
||||
_TreeIterator __i_;
|
||||
|
||||
typedef typename _TreeIterator::__pointer_traits __pointer_traits;
|
||||
typedef const typename _TreeIterator::value_type::first_type __key_type;
|
||||
typedef typename _TreeIterator::value_type::second_type __mapped_type;
|
||||
typedef const typename _TreeIterator::value_type::value_type::first_type __key_type;
|
||||
typedef typename _TreeIterator::value_type::value_type::second_type __mapped_type;
|
||||
public:
|
||||
typedef bidirectional_iterator_tag iterator_category;
|
||||
typedef pair<__key_type, __mapped_type> value_type;
|
||||
@ -564,9 +523,9 @@ public:
|
||||
__map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return *operator->();}
|
||||
reference operator*() const {return __i_->__cc;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return (pointer)__i_.operator->();}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__map_iterator& operator++() {++__i_; return *this;}
|
||||
@ -607,8 +566,8 @@ class _LIBCPP_TYPE_VIS __map_const_iterator
|
||||
_TreeIterator __i_;
|
||||
|
||||
typedef typename _TreeIterator::__pointer_traits __pointer_traits;
|
||||
typedef const typename _TreeIterator::value_type::first_type __key_type;
|
||||
typedef typename _TreeIterator::value_type::second_type __mapped_type;
|
||||
typedef const typename _TreeIterator::value_type::value_type::first_type __key_type;
|
||||
typedef typename _TreeIterator::value_type::value_type::second_type __mapped_type;
|
||||
public:
|
||||
typedef bidirectional_iterator_tag iterator_category;
|
||||
typedef pair<__key_type, __mapped_type> value_type;
|
||||
@ -634,9 +593,9 @@ public:
|
||||
: __i_(__i.__i_) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return *operator->();}
|
||||
reference operator*() const {return __i_->__cc;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return (pointer)__i_.operator->();}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__map_const_iterator& operator++() {++__i_; return *this;}
|
||||
@ -679,6 +638,7 @@ public:
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Allocator allocator_type;
|
||||
typedef value_type& reference;
|
||||
@ -699,8 +659,51 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
typedef pair<key_type, mapped_type> __value_type;
|
||||
typedef __map_value_compare<key_type, mapped_type, key_compare> __vc;
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
union __value_type
|
||||
{
|
||||
typedef typename map::value_type value_type;
|
||||
typedef typename map::__nc_value_type __nc_value_type;
|
||||
value_type __cc;
|
||||
__nc_value_type __nc;
|
||||
|
||||
template <class ..._Args>
|
||||
__value_type(_Args&& ...__args)
|
||||
: __cc(std::forward<_Args>(__args)...) {}
|
||||
|
||||
__value_type(const __value_type& __v)
|
||||
: __cc(std::move(__v.__cc)) {}
|
||||
|
||||
__value_type(__value_type&& __v)
|
||||
: __nc(std::move(__v.__nc)) {}
|
||||
|
||||
__value_type& operator=(const __value_type& __v)
|
||||
{__nc = __v.__cc; return *this;}
|
||||
|
||||
__value_type& operator=(__value_type&& __v)
|
||||
{__nc = std::move(__v.__nc); return *this;}
|
||||
|
||||
~__value_type() {__cc.~value_type();}
|
||||
};
|
||||
#else
|
||||
struct __value_type
|
||||
{
|
||||
typedef typename map::value_type value_type;
|
||||
value_type __cc;
|
||||
|
||||
__value_type() {}
|
||||
|
||||
template <class _A0>
|
||||
__value_type(const _A0& __a0)
|
||||
: __cc(__a0) {}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
__value_type(const _A0& __a0, const _A1& __a1)
|
||||
: __cc(__a0, __a1) {}
|
||||
};
|
||||
#endif
|
||||
typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
|
||||
typedef typename allocator_traits<allocator_type>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<__value_type>
|
||||
@ -764,7 +767,14 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
map& operator=(const map& __m)
|
||||
{
|
||||
#if __cplusplus >= 201103L
|
||||
__tree_ = __m.__tree_;
|
||||
#else
|
||||
__tree_.clear();
|
||||
__tree_.value_comp() = __m.__tree_.value_comp();
|
||||
__tree_.__copy_assign_alloc(__m.__tree_);
|
||||
insert(__m.begin(), __m.end());
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -986,32 +996,17 @@ private:
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node();
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<value_type, _A0>::value,
|
||||
__node_holder
|
||||
>::type
|
||||
__construct_node(_A0&& __a0);
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<key_type, _A0>::value,
|
||||
__node_holder
|
||||
>::type
|
||||
__construct_node(_A0&& __a0);
|
||||
__node_holder __construct_node(_A0&& __a0);
|
||||
__node_holder __construct_node_with_key(key_type&& __k);
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _A0, class _A1, class ..._Args>
|
||||
__node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node(const key_type& __k);
|
||||
#endif
|
||||
__node_holder __construct_node_with_key(const key_type& __k);
|
||||
|
||||
__node_base_pointer&
|
||||
__find_equal_key(__node_base_pointer& __parent, const key_type& __k);
|
||||
__node_base_pointer&
|
||||
__find_equal_key(const_iterator __hint,
|
||||
__node_base_pointer& __parent, const key_type& __k);
|
||||
__node_base_const_pointer
|
||||
__find_equal_key(__node_base_const_pointer& __parent, const key_type& __k) const;
|
||||
};
|
||||
@ -1030,97 +1025,37 @@ map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __pa
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (__tree_.value_comp().key_comp()(__k, __nd->__value_.first))
|
||||
if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
|
||||
{
|
||||
if (__nd->__left_ != nullptr)
|
||||
__nd = static_cast<__node_pointer>(__nd->__left_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent->__left_;
|
||||
}
|
||||
}
|
||||
else if (__tree_.value_comp().key_comp()(__nd->__value_.first, __k))
|
||||
else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
|
||||
{
|
||||
if (__nd->__right_ != nullptr)
|
||||
__nd = static_cast<__node_pointer>(__nd->__right_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent->__right_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
__parent = __tree_.__end_node();
|
||||
__parent = static_cast<__node_base_pointer>(__tree_.__end_node());
|
||||
return __parent->__left_;
|
||||
}
|
||||
|
||||
// Find place to insert if __k doesn't exist
|
||||
// First check prior to __hint.
|
||||
// Next check after __hint.
|
||||
// Next do O(log N) search.
|
||||
// Set __parent to parent of null leaf
|
||||
// Return reference to null leaf
|
||||
// If __k exists, set parent to node of __k and return reference to node of __k
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer&
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(const_iterator __hint,
|
||||
__node_base_pointer& __parent,
|
||||
const key_type& __k)
|
||||
{
|
||||
if (__hint == end() || __tree_.value_comp().key_comp()(__k, __hint->first)) // check before
|
||||
{
|
||||
// __k < *__hint
|
||||
const_iterator __prior = __hint;
|
||||
if (__prior == begin() || __tree_.value_comp().key_comp()((--__prior)->first, __k))
|
||||
{
|
||||
// *prev(__hint) < __k < *__hint
|
||||
if (__hint.__ptr_->__left_ == nullptr)
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__hint.__ptr_);
|
||||
return __parent->__left_;
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__prior.__ptr_);
|
||||
return __parent->__right_;
|
||||
}
|
||||
}
|
||||
// __k <= *prev(__hint)
|
||||
return __find_equal_key(__parent, __k);
|
||||
}
|
||||
else if (__tree_.value_comp().key_comp()(__hint->first, __k)) // check after
|
||||
{
|
||||
// *__hint < __k
|
||||
const_iterator __next = _VSTD::next(__hint);
|
||||
if (__next == end() || __tree_.value_comp().key_comp()(__k, __next->first))
|
||||
{
|
||||
// *__hint < __k < *next(__hint)
|
||||
if (__hint.__ptr_->__right_ == nullptr)
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__hint.__ptr_);
|
||||
return __parent->__right_;
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = const_cast<__node_pointer&>(__next.__ptr_);
|
||||
return __parent->__left_;
|
||||
}
|
||||
}
|
||||
// *next(__hint) <= __k
|
||||
return __find_equal_key(__parent, __k);
|
||||
}
|
||||
// else __k == *__hint
|
||||
__parent = const_cast<__node_pointer&>(__hint.__ptr_);
|
||||
return __parent;
|
||||
}
|
||||
|
||||
// Find __k
|
||||
// Set __parent to parent of null leaf and
|
||||
// return reference to null leaf iv __k does not exist.
|
||||
@ -1135,34 +1070,34 @@ map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (__tree_.value_comp().key_comp()(__k, __nd->__value_.first))
|
||||
if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
|
||||
{
|
||||
if (__nd->__left_ != nullptr)
|
||||
__nd = static_cast<__node_pointer>(__nd->__left_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return const_cast<const __node_base_const_pointer&>(__parent->__left_);
|
||||
}
|
||||
}
|
||||
else if (__tree_.value_comp().key_comp()(__nd->__value_.first, __k))
|
||||
else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
|
||||
{
|
||||
if (__nd->__right_ != nullptr)
|
||||
__nd = static_cast<__node_pointer>(__nd->__right_);
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return const_cast<const __node_base_const_pointer&>(__parent->__right_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__parent = __nd;
|
||||
__parent = static_cast<__node_base_pointer>(__nd);
|
||||
return __parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
__parent = __tree_.__end_node();
|
||||
__parent = static_cast<__node_base_pointer>(__tree_.__end_node());
|
||||
return const_cast<const __node_base_const_pointer&>(__parent->__left_);
|
||||
}
|
||||
|
||||
@ -1187,20 +1122,16 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node()
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<pair<const _Key, _Tp>, _A0>::value,
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
>::type
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
@ -1212,21 +1143,16 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<_Key, _A0>::value,
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
>::type
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), _VSTD::forward<_A0>(__a0));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
return _VSTD::move(__h);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
@ -1248,23 +1174,21 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0, _A1&& __a1, _
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node(const key_type& __k)
|
||||
map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k);
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return _VSTD::move(__h);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
_Tp&
|
||||
map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
|
||||
@ -1274,11 +1198,11 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
|
||||
__node_pointer __r = static_cast<__node_pointer>(__child);
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__node_holder __h = __construct_node(__k);
|
||||
__tree_.__insert_node_at(__parent, __child, __h.get());
|
||||
__node_holder __h = __construct_node_with_key(__k);
|
||||
__tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
__r = __h.release();
|
||||
}
|
||||
return __r->__value_.second;
|
||||
return __r->__value_.__cc.second;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -1292,11 +1216,11 @@ map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k)
|
||||
__node_pointer __r = static_cast<__node_pointer>(__child);
|
||||
if (__child == nullptr)
|
||||
{
|
||||
__node_holder __h = __construct_node(_VSTD::move(__k));
|
||||
__tree_.__insert_node_at(__parent, __child, __h.get());
|
||||
__node_holder __h = __construct_node_with_key(_VSTD::move(__k));
|
||||
__tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
|
||||
__r = __h.release();
|
||||
}
|
||||
return __r->__value_.second;
|
||||
return __r->__value_.__cc.second;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -1311,7 +1235,7 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
|
||||
if (__child == nullptr)
|
||||
throw out_of_range("map::at: key not found");
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return static_cast<__node_pointer>(__child)->__value_.second;
|
||||
return static_cast<__node_pointer>(__child)->__value_.__cc.second;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
@ -1324,7 +1248,7 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
|
||||
if (__child == nullptr)
|
||||
throw out_of_range("map::at: key not found");
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
return static_cast<__node_const_pointer>(__child)->__value_.second;
|
||||
return static_cast<__node_const_pointer>(__child)->__value_.__cc.second;
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
@ -1429,6 +1353,7 @@ public:
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef _Compare key_compare;
|
||||
typedef _Allocator allocator_type;
|
||||
typedef value_type& reference;
|
||||
@ -1450,8 +1375,50 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
typedef pair<key_type, mapped_type> __value_type;
|
||||
typedef __map_value_compare<key_type, mapped_type, key_compare> __vc;
|
||||
#if __cplusplus >= 201103L
|
||||
union __value_type
|
||||
{
|
||||
typedef typename multimap::value_type value_type;
|
||||
typedef typename multimap::__nc_value_type __nc_value_type;
|
||||
value_type __cc;
|
||||
__nc_value_type __nc;
|
||||
|
||||
template <class ..._Args>
|
||||
__value_type(_Args&& ...__args)
|
||||
: __cc(std::forward<_Args>(__args)...) {}
|
||||
|
||||
__value_type(const __value_type& __v)
|
||||
: __cc(std::move(__v.__cc)) {}
|
||||
|
||||
__value_type(__value_type&& __v)
|
||||
: __nc(std::move(__v.__nc)) {}
|
||||
|
||||
__value_type& operator=(const __value_type& __v)
|
||||
{__nc = __v.__cc; return *this;}
|
||||
|
||||
__value_type& operator=(__value_type&& __v)
|
||||
{__nc = std::move(__v.__nc); return *this;}
|
||||
|
||||
~__value_type() {__cc.~value_type();}
|
||||
};
|
||||
#else
|
||||
struct __value_type
|
||||
{
|
||||
typedef typename multimap::value_type value_type;
|
||||
value_type __cc;
|
||||
|
||||
__value_type() {}
|
||||
|
||||
template <class _A0>
|
||||
__value_type(const _A0& __a0)
|
||||
: __cc(__a0) {}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
__value_type(const _A0& __a0, const _A1& __a1)
|
||||
: __cc(__a0, __a1) {}
|
||||
};
|
||||
#endif
|
||||
typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
|
||||
typedef typename allocator_traits<allocator_type>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<__value_type>
|
||||
@ -1516,7 +1483,14 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
multimap& operator=(const multimap& __m)
|
||||
{
|
||||
#if __cplusplus >= 201103L
|
||||
__tree_ = __m.__tree_;
|
||||
#else
|
||||
__tree_.clear();
|
||||
__tree_.value_comp() = __m.__tree_.value_comp();
|
||||
__tree_.__copy_assign_alloc(__m.__tree_);
|
||||
insert(__m.begin(), __m.end());
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -1725,18 +1699,7 @@ private:
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node();
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<value_type, _A0>::value,
|
||||
__node_holder
|
||||
>::type
|
||||
__construct_node(_A0&& __a0);
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<key_type, _A0>::value,
|
||||
__node_holder
|
||||
>::type
|
||||
__node_holder
|
||||
__construct_node(_A0&& __a0);
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _A0, class _A1, class ..._Args>
|
||||
@ -1766,20 +1729,16 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node()
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<pair<const _Key, _Tp>, _A0>::value,
|
||||
typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
>::type
|
||||
typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
@ -1790,24 +1749,6 @@ multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
|
||||
return __h;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<_Key, _A0>::value,
|
||||
typename multimap<_Key, _Tp, _Compare, _Allocator>::__node_holder
|
||||
>::type
|
||||
multimap<_Key, _Tp, _Compare, _Allocator>::__construct_node(_A0&& __a0)
|
||||
{
|
||||
__node_allocator& __na = __tree_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), _VSTD::forward<_A0>(__a0));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Key, class _Tp, class _Compare, class _Allocator>
|
||||
|
@ -350,6 +350,10 @@ class bad_weak_ptr
|
||||
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
|
||||
{
|
||||
@ -1750,7 +1754,7 @@ public:
|
||||
typedef const _Tp* const_pointer;
|
||||
typedef const _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Tp value_type;
|
||||
typedef const _Tp value_type;
|
||||
|
||||
typedef true_type propagate_on_container_move_assignment;
|
||||
|
||||
@ -2036,6 +2040,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
|
||||
@ -2051,10 +2059,6 @@ public:
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;}
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
|
||||
|
||||
@ -2131,6 +2135,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
|
||||
@ -2146,10 +2154,6 @@ public:
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
|
||||
|
||||
@ -2227,6 +2231,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
|
||||
@ -2243,10 +2251,6 @@ public:
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return __first_;}
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
|
||||
|
||||
@ -2321,6 +2325,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
|
||||
@ -2336,10 +2344,6 @@ public:
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
|
||||
|
||||
@ -2409,6 +2413,10 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class... _Args1, class... _Args2>
|
||||
@ -2422,10 +2430,6 @@ public:
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_reference first() _NOEXCEPT {return base::first();}
|
||||
_LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();}
|
||||
|
||||
@ -3079,8 +3083,61 @@ move(unique_ptr<_Tp, _Dp>& __t)
|
||||
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
template<class _Tp>
|
||||
struct __unique_if
|
||||
{
|
||||
typedef unique_ptr<_Tp> __unique_single;
|
||||
};
|
||||
|
||||
template<class _Tp>
|
||||
struct __unique_if<_Tp[]>
|
||||
{
|
||||
typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
|
||||
};
|
||||
|
||||
template<class _Tp, size_t _Np>
|
||||
struct __unique_if<_Tp[_Np]>
|
||||
{
|
||||
typedef void __unique_array_known_bound;
|
||||
};
|
||||
|
||||
template<class _Tp, class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __unique_if<_Tp>::__unique_single
|
||||
make_unique(_Args&&... __args)
|
||||
{
|
||||
return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename __unique_if<_Tp>::__unique_array_unknown_bound
|
||||
make_unique(size_t __n)
|
||||
{
|
||||
typedef typename remove_extent<_Tp>::type _Up;
|
||||
return unique_ptr<_Tp>(new _Up[__n]());
|
||||
}
|
||||
|
||||
template<class _Tp, class... _Args>
|
||||
typename __unique_if<_Tp>::__unique_array_known_bound
|
||||
make_unique(_Args&&...) = delete;
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
template <class _Tp> struct hash;
|
||||
|
||||
template <class _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_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.
|
||||
@ -3104,7 +3161,7 @@ __murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
|
||||
const unsigned char* __data = static_cast<const unsigned char*>(__key);
|
||||
for (; __len >= 4; __data += 4, __len -= 4)
|
||||
{
|
||||
_Size __k = *(const _Size*)__data;
|
||||
_Size __k = __loadword<_Size>(__data);
|
||||
__k *= __m;
|
||||
__k ^= __k >> __r;
|
||||
__k *= __m;
|
||||
@ -3163,13 +3220,13 @@ struct __murmur2_or_cityhash<_Size, 64>
|
||||
|
||||
static _Size __hash_len_0_to_16(const char* __s, _Size __len) {
|
||||
if (__len > 8) {
|
||||
const _Size __a = *(const _Size*)__s;
|
||||
const _Size __b = *(const _Size*)(__s + __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 = *(const uint32_t*)(__s);
|
||||
const uint32_t __b = *(const uint32_t*)(__s + __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) {
|
||||
@ -3185,10 +3242,10 @@ struct __murmur2_or_cityhash<_Size, 64>
|
||||
}
|
||||
|
||||
static _Size __hash_len_17_to_32(const char *__s, _Size __len) {
|
||||
const _Size __a = *(const _Size*)(__s) * __k1;
|
||||
const _Size __b = *(const _Size*)(__s + 8);
|
||||
const _Size __c = *(const _Size*)(__s + __len - 8) * __k2;
|
||||
const _Size __d = *(const _Size*)(__s + __len - 16) * __k0;
|
||||
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);
|
||||
}
|
||||
@ -3209,33 +3266,33 @@ struct __murmur2_or_cityhash<_Size, 64>
|
||||
// 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(*(const _Size*)(__s),
|
||||
*(const _Size*)(__s + 8),
|
||||
*(const _Size*)(__s + 16),
|
||||
*(const _Size*)(__s + 24),
|
||||
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 = *(const _Size*)(__s + 24);
|
||||
_Size __a = *(const _Size*)(__s) +
|
||||
(__len + *(const _Size*)(__s + __len - 16)) * __k0;
|
||||
_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 += *(const _Size*)(__s + 8);
|
||||
__a += __loadword<_Size>(__s + 8);
|
||||
__c += __rotate(__a, 7);
|
||||
__a += *(const _Size*)(__s + 16);
|
||||
__a += __loadword<_Size>(__s + 16);
|
||||
_Size __vf = __a + __z;
|
||||
_Size __vs = __b + __rotate(__a, 31) + __c;
|
||||
__a = *(const _Size*)(__s + 16) + *(const _Size*)(__s + __len - 32);
|
||||
__z += *(const _Size*)(__s + __len - 8);
|
||||
__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 += *(const _Size*)(__s + __len - 24);
|
||||
__a += __loadword<_Size>(__s + __len - 24);
|
||||
__c += __rotate(__a, 7);
|
||||
__a += *(const _Size*)(__s + __len - 16);
|
||||
__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);
|
||||
@ -3261,26 +3318,26 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __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 = *(const _Size*)(__s + __len - 40);
|
||||
_Size __y = *(const _Size*)(__s + __len - 16) +
|
||||
*(const _Size*)(__s + __len - 56);
|
||||
_Size __z = __hash_len_16(*(const _Size*)(__s + __len - 48) + __len,
|
||||
*(const _Size*)(__s + __len - 24));
|
||||
_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 + *(const _Size*)(__s);
|
||||
__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 + *(const _Size*)(__s + 8), 37) * __k1;
|
||||
__y = __rotate(__y + __v.second + *(const _Size*)(__s + 48), 42) * __k1;
|
||||
__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 + *(const _Size*)(__s + 40);
|
||||
__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 + *(const _Size*)(__s + 16));
|
||||
__y + __loadword<_Size>(__s + 16));
|
||||
std::swap(__z, __x);
|
||||
__s += 64;
|
||||
__len -= 64;
|
||||
|
@ -1880,7 +1880,7 @@ public:
|
||||
seed(_Sseq& __q)
|
||||
{__seed(__q, integral_constant<unsigned,
|
||||
1 + (__m == 0 ? (sizeof(result_type) * __CHAR_BIT__ - 1)/32
|
||||
: (__m-1) / 0x100000000ull)>());}
|
||||
: (__m > 0x100000000ull))>());}
|
||||
|
||||
// generating functions
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -1969,7 +1969,7 @@ linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q,
|
||||
uint32_t __ar[__k+3];
|
||||
__q.generate(__ar, __ar + __k + 3);
|
||||
result_type __s = static_cast<result_type>((__ar[3] +
|
||||
(uint64_t)__ar[4] << 32) % __m);
|
||||
((uint64_t)__ar[4] << 32)) % __m);
|
||||
__x_ = __c == 0 && __s == 0 ? result_type(1) : __s;
|
||||
}
|
||||
|
||||
|
@ -2843,6 +2843,15 @@ private:
|
||||
const basic_regex<_Cp, _Tp>& __e,
|
||||
regex_constants::match_flag_type __flags);
|
||||
|
||||
template <class _Iter, class _Ap, class _Cp, class _Tp>
|
||||
friend
|
||||
bool
|
||||
regex_search(__wrap_iter<_Iter> __first,
|
||||
__wrap_iter<_Iter> __last,
|
||||
match_results<__wrap_iter<_Iter>, _Ap>& __m,
|
||||
const basic_regex<_Cp, _Tp>& __e,
|
||||
regex_constants::match_flag_type __flags);
|
||||
|
||||
template <class, class> friend class __lookahead;
|
||||
};
|
||||
|
||||
@ -2921,7 +2930,7 @@ __lookahead<_CharT, _Traits>::__exec(__state& __s) const
|
||||
bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
|
||||
__m,
|
||||
__s.__flags_ | regex_constants::match_continuous,
|
||||
true);
|
||||
__s.__at_first_ && __s.__current_ == __s.__first_);
|
||||
if (__matched != __invert_)
|
||||
{
|
||||
__s.__do_ = __state::__accept_but_not_consume;
|
||||
@ -3420,6 +3429,7 @@ basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first,
|
||||
case '+':
|
||||
case '?':
|
||||
case '{':
|
||||
case '}':
|
||||
__push_char(*__temp);
|
||||
__first = ++__temp;
|
||||
break;
|
||||
@ -3903,7 +3913,7 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
|
||||
{
|
||||
__val = 8 * __val + *__first - '0';
|
||||
if (++__first != __last && ('0' <= *__first && *__first <= '7'))
|
||||
__val = 8 * __val + *__first - '0';
|
||||
__val = 8 * __val + *__first++ - '0';
|
||||
}
|
||||
if (__str)
|
||||
*__str = _CharT(__val);
|
||||
@ -4481,7 +4491,7 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
|
||||
++__first;
|
||||
}
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
else if (__str)
|
||||
else
|
||||
throw regex_error(regex_constants::error_escape);
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
break;
|
||||
@ -5807,6 +5817,21 @@ regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _Iter, class _Allocator, class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
regex_search(__wrap_iter<_Iter> __first,
|
||||
__wrap_iter<_Iter> __last,
|
||||
match_results<__wrap_iter<_Iter>, _Allocator>& __m,
|
||||
const basic_regex<_CharT, _Traits>& __e,
|
||||
regex_constants::match_flag_type __flags = regex_constants::match_default)
|
||||
{
|
||||
match_results<const _CharT*> __mc;
|
||||
bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
|
||||
__m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
|
||||
return __r;
|
||||
}
|
||||
|
||||
template <class _Allocator, class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
@ -6044,7 +6069,7 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
|
||||
{
|
||||
__flags_ |= regex_constants::__no_update_pos;
|
||||
_BidirectionalIterator __start = __match_[0].second;
|
||||
if (__match_.length() == 0)
|
||||
if (__match_.empty())
|
||||
{
|
||||
if (__start == __end_)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -137,6 +137,64 @@ namespace std
|
||||
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
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
@ -154,9 +212,18 @@ template <bool _Bp, class _If, class _Then>
|
||||
template <class _If, class _Then>
|
||||
struct _LIBCPP_TYPE_VIS conditional<false, _If, _Then> {typedef _Then type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
|
||||
#endif
|
||||
|
||||
template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS enable_if {};
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS enable_if<true, _Tp> {typedef _Tp type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
|
||||
#endif
|
||||
|
||||
|
||||
struct __two {char __lx[2];};
|
||||
|
||||
// helper class:
|
||||
@ -191,16 +258,25 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_volatile<_Tp volatile> : public
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_const {typedef _Tp type;};
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_const<const _Tp> {typedef _Tp type;};
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// remove_volatile
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_volatile {typedef _Tp type;};
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;};
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// remove_cv
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_cv
|
||||
{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// is_void
|
||||
|
||||
@ -446,6 +522,10 @@ struct __add_const<_Tp, false> {typedef const _Tp type;};
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS add_const
|
||||
{typedef typename __add_const<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// add_volatile
|
||||
|
||||
template <class _Tp, bool = is_reference<_Tp>::value ||
|
||||
@ -459,11 +539,19 @@ struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS add_volatile
|
||||
{typedef typename __add_volatile<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// add_cv
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS add_cv
|
||||
{typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// remove_reference
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference {typedef _Tp type;};
|
||||
@ -472,6 +560,10 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference<_Tp&> {typedef _T
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference<_Tp&&> {typedef _Tp type;};
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// add_lvalue_reference
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS add_lvalue_reference {typedef _Tp& type;};
|
||||
@ -481,6 +573,10 @@ template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<const void>
|
||||
template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<volatile void> {typedef volatile void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<const volatile void> {typedef const volatile void type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS add_rvalue_reference {typedef _Tp&& type;};
|
||||
@ -489,6 +585,10 @@ template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<const void>
|
||||
template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<volatile void> {typedef volatile void type;};
|
||||
template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<const volatile void> {typedef const volatile void type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -518,11 +618,19 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const>
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;};
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// add_pointer
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS add_pointer
|
||||
{typedef typename remove_reference<_Tp>::type* type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// is_signed
|
||||
|
||||
template <class _Tp, bool = is_integral<_Tp>::value>
|
||||
@ -584,6 +692,10 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS remove_extent<_Tp[]>
|
||||
template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS remove_extent<_Tp[_Np]>
|
||||
{typedef _Tp type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// remove_all_extents
|
||||
|
||||
template <class _Tp> struct _LIBCPP_TYPE_VIS remove_all_extents
|
||||
@ -593,6 +705,10 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[]>
|
||||
template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[_Np]>
|
||||
{typedef typename remove_all_extents<_Tp>::type type;};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
|
||||
#endif
|
||||
|
||||
// is_abstract
|
||||
|
||||
namespace __is_abstract_imp
|
||||
@ -916,7 +1032,7 @@ 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, const size_t _Align = __find_max_align<__all_types, _Len>::value>
|
||||
template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
|
||||
struct _LIBCPP_TYPE_VIS aligned_storage
|
||||
{
|
||||
typedef typename __find_pod<__all_types, _Align>::type _Aligner;
|
||||
@ -928,6 +1044,11 @@ struct _LIBCPP_TYPE_VIS aligned_storage
|
||||
};
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
|
||||
using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
|
||||
#endif
|
||||
|
||||
#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
|
||||
template <size_t _Len>\
|
||||
struct _LIBCPP_TYPE_VIS aligned_storage<_Len, n>\
|
||||
@ -989,6 +1110,10 @@ struct aligned_union
|
||||
typedef typename aligned_storage<__len, alignment_value>::type type;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
// __promote
|
||||
@ -1150,6 +1275,10 @@ struct _LIBCPP_TYPE_VIS make_signed
|
||||
typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
|
||||
#endif
|
||||
|
||||
template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
|
||||
struct __make_unsigned {};
|
||||
|
||||
@ -1175,6 +1304,10 @@ struct _LIBCPP_TYPE_VIS make_unsigned
|
||||
typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Tp, class _Up = void, class V = void>
|
||||
@ -1233,6 +1366,10 @@ struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, _Vp...>
|
||||
typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
// is_assignable
|
||||
@ -1411,6 +1548,10 @@ public:
|
||||
>::type type;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using decay_t = typename decay<_Tp>::type;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Tp>
|
||||
@ -1653,7 +1794,7 @@ struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
|
||||
|
||||
template <class _MP>
|
||||
struct __member_pointer_traits
|
||||
: public __member_pointer_traits_imp<_MP,
|
||||
: public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
|
||||
is_member_function_pointer<_MP>::value,
|
||||
is_member_object_pointer<_MP>::value>
|
||||
{
|
||||
@ -2878,13 +3019,27 @@ __invoke(__any, _Args&& ...__args)
|
||||
|
||||
// bullets 1 and 2
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args>
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
|
||||
is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
|
||||
typename remove_reference<_A0>::type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
-> decltype((_VSTD::forward<_A0>(__a0).*__f)(_VSTD::forward<_Args>(__args)...));
|
||||
|
||||
template <class _Fp, class _A0, class ..._Args>
|
||||
template <class _Fp, class _A0, class ..._Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_member_function_pointer<typename remove_reference<_Fp>::type>::value &&
|
||||
!is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
|
||||
typename remove_reference<_A0>::type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
@ -2892,13 +3047,27 @@ __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
|
||||
|
||||
// bullets 3 and 4
|
||||
|
||||
template <class _Fp, class _A0>
|
||||
template <class _Fp, class _A0,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
|
||||
is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
|
||||
typename remove_reference<_A0>::type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
-> decltype(_VSTD::forward<_A0>(__a0).*__f);
|
||||
|
||||
template <class _Fp, class _A0>
|
||||
template <class _Fp, class _A0,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_member_object_pointer<typename remove_reference<_Fp>::type>::value &&
|
||||
!is_base_of<typename __member_pointer_traits<typename remove_reference<_Fp>::type>::_ClassType,
|
||||
typename remove_reference<_A0>::type>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__invoke(_Fp&& __f, _A0&& __a0)
|
||||
@ -2956,6 +3125,10 @@ class _LIBCPP_TYPE_VIS result_of<_Fp(_Args...)>
|
||||
{
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
|
||||
#endif
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Tp>
|
||||
@ -3050,6 +3223,10 @@ struct underlying_type
|
||||
typedef _LIBCXX_UNDERLYING_TYPE(_Tp) type;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
|
||||
#endif
|
||||
|
||||
#else // _LIBCXX_UNDERLYING_TYPE
|
||||
|
||||
template <class _Tp, bool _Support = false>
|
||||
|
@ -325,7 +325,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, bool = is_empty<_Hash>::value
|
||||
template <class _Key, class _Cp, class _Hash, bool = is_empty<_Hash>::value
|
||||
#if __has_feature(is_final)
|
||||
&& !__is_final(_Hash)
|
||||
#endif
|
||||
@ -333,8 +333,6 @@ template <class _Key, class _Tp, class _Hash, bool = is_empty<_Hash>::value
|
||||
class __unordered_map_hasher
|
||||
: private _Hash
|
||||
{
|
||||
typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
|
||||
typedef pair<const _Key, _Tp> _Cp;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__unordered_map_hasher()
|
||||
@ -347,23 +345,18 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const _Hash& hash_function() const _NOEXCEPT {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Pp& __x) const
|
||||
{return static_cast<const _Hash&>(*this)(__x.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Cp& __x) const
|
||||
{return static_cast<const _Hash&>(*this)(__x.first);}
|
||||
{return static_cast<const _Hash&>(*this)(__x.__cc.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Key& __x) const
|
||||
{return static_cast<const _Hash&>(*this)(__x);}
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _Hash>
|
||||
class __unordered_map_hasher<_Key, _Tp, _Hash, false>
|
||||
template <class _Key, class _Cp, class _Hash>
|
||||
class __unordered_map_hasher<_Key, _Cp, _Hash, false>
|
||||
{
|
||||
_Hash __hash_;
|
||||
|
||||
typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
|
||||
typedef pair<const _Key, _Tp> _Cp;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__unordered_map_hasher()
|
||||
@ -376,17 +369,14 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Pp& __x) const
|
||||
{return __hash_(__x.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Cp& __x) const
|
||||
{return __hash_(__x.first);}
|
||||
{return __hash_(__x.__cc.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_t operator()(const _Key& __x) const
|
||||
{return __hash_(__x);}
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _Pred, bool = is_empty<_Pred>::value
|
||||
template <class _Key, class _Cp, class _Pred, bool = is_empty<_Pred>::value
|
||||
#if __has_feature(is_final)
|
||||
&& !__is_final(_Pred)
|
||||
#endif
|
||||
@ -394,8 +384,6 @@ template <class _Key, class _Tp, class _Pred, bool = is_empty<_Pred>::value
|
||||
class __unordered_map_equal
|
||||
: private _Pred
|
||||
{
|
||||
typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
|
||||
typedef pair<const _Key, _Tp> _Cp;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__unordered_map_equal()
|
||||
@ -408,41 +396,21 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const _Pred& key_eq() const _NOEXCEPT {return *this;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Pp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Cp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Key& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Pp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Cp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
|
||||
{return static_cast<const _Pred&>(*this)(__x.__cc.first, __y.__cc.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Key& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Pp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x, __y.first);}
|
||||
{return static_cast<const _Pred&>(*this)(__x.__cc.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Cp& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Key& __y) const
|
||||
{return static_cast<const _Pred&>(*this)(__x, __y);}
|
||||
{return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _Pred>
|
||||
class __unordered_map_equal<_Key, _Tp, _Pred, false>
|
||||
template <class _Key, class _Cp, class _Pred>
|
||||
class __unordered_map_equal<_Key, _Cp, _Pred, false>
|
||||
{
|
||||
_Pred __pred_;
|
||||
|
||||
typedef pair<typename remove_const<_Key>::type, _Tp> _Pp;
|
||||
typedef pair<const _Key, _Tp> _Cp;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__unordered_map_equal()
|
||||
@ -455,32 +423,14 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Pp& __y) const
|
||||
{return __pred_(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Cp& __y) const
|
||||
{return __pred_(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Pp& __x, const _Key& __y) const
|
||||
{return __pred_(__x.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Pp& __y) const
|
||||
{return __pred_(__x.first, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Cp& __y) const
|
||||
{return __pred_(__x.first, __y.first);}
|
||||
{return __pred_(__x.__cc.first, __y.__cc.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Cp& __x, const _Key& __y) const
|
||||
{return __pred_(__x.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Pp& __y) const
|
||||
{return __pred_(__x, __y.first);}
|
||||
{return __pred_(__x.__cc.first, __y);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Cp& __y) const
|
||||
{return __pred_(__x, __y.first);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _Key& __x, const _Key& __y) const
|
||||
{return __pred_(__x, __y);}
|
||||
{return __pred_(__x, __y.__cc.first);}
|
||||
};
|
||||
|
||||
template <class _Alloc>
|
||||
@ -492,8 +442,8 @@ class __hash_map_node_destructor
|
||||
public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
private:
|
||||
typedef typename value_type::first_type first_type;
|
||||
typedef typename value_type::second_type second_type;
|
||||
typedef typename value_type::value_type::first_type first_type;
|
||||
typedef typename value_type::value_type::second_type second_type;
|
||||
|
||||
allocator_type& __na_;
|
||||
|
||||
@ -535,9 +485,9 @@ public:
|
||||
void operator()(pointer __p) _NOEXCEPT
|
||||
{
|
||||
if (__second_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second));
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
|
||||
if (__first_constructed)
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first));
|
||||
__alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
|
||||
if (__p)
|
||||
__alloc_traits::deallocate(__na_, __p, 1);
|
||||
}
|
||||
@ -549,8 +499,8 @@ class _LIBCPP_TYPE_VIS __hash_map_iterator
|
||||
_HashIterator __i_;
|
||||
|
||||
typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits;
|
||||
typedef const typename _HashIterator::value_type::first_type key_type;
|
||||
typedef typename _HashIterator::value_type::second_type mapped_type;
|
||||
typedef const typename _HashIterator::value_type::value_type::first_type key_type;
|
||||
typedef typename _HashIterator::value_type::value_type::second_type mapped_type;
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef pair<key_type, mapped_type> value_type;
|
||||
@ -571,9 +521,9 @@ public:
|
||||
__hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return *operator->();}
|
||||
reference operator*() const {return __i_->__cc;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return (pointer)__i_.operator->();}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_iterator& operator++() {++__i_; return *this;}
|
||||
@ -605,8 +555,8 @@ class _LIBCPP_TYPE_VIS __hash_map_const_iterator
|
||||
_HashIterator __i_;
|
||||
|
||||
typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits;
|
||||
typedef const typename _HashIterator::value_type::first_type key_type;
|
||||
typedef typename _HashIterator::value_type::second_type mapped_type;
|
||||
typedef const typename _HashIterator::value_type::value_type::first_type key_type;
|
||||
typedef typename _HashIterator::value_type::value_type::second_type mapped_type;
|
||||
public:
|
||||
typedef forward_iterator_tag iterator_category;
|
||||
typedef pair<key_type, mapped_type> value_type;
|
||||
@ -632,9 +582,9 @@ public:
|
||||
: __i_(__i.__i_) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator*() const {return *operator->();}
|
||||
reference operator*() const {return __i_->__cc;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pointer operator->() const {return (pointer)__i_.operator->();}
|
||||
pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hash_map_const_iterator& operator++() {++__i_; return *this;}
|
||||
@ -671,13 +621,56 @@ public:
|
||||
typedef _Pred key_equal;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
private:
|
||||
typedef pair<key_type, mapped_type> __value_type;
|
||||
typedef __unordered_map_hasher<key_type, mapped_type, hasher> __hasher;
|
||||
typedef __unordered_map_equal<key_type, mapped_type, key_equal> __key_equal;
|
||||
#if __cplusplus >= 201103L
|
||||
union __value_type
|
||||
{
|
||||
typedef typename unordered_map::value_type value_type;
|
||||
typedef typename unordered_map::__nc_value_type __nc_value_type;
|
||||
value_type __cc;
|
||||
__nc_value_type __nc;
|
||||
|
||||
template <class ..._Args>
|
||||
__value_type(_Args&& ...__args)
|
||||
: __cc(std::forward<_Args>(__args)...) {}
|
||||
|
||||
__value_type(const __value_type& __v)
|
||||
: __cc(std::move(__v.__cc)) {}
|
||||
|
||||
__value_type(__value_type&& __v)
|
||||
: __nc(std::move(__v.__nc)) {}
|
||||
|
||||
__value_type& operator=(const __value_type& __v)
|
||||
{__nc = __v.__cc; return *this;}
|
||||
|
||||
__value_type& operator=(__value_type&& __v)
|
||||
{__nc = std::move(__v.__nc); return *this;}
|
||||
|
||||
~__value_type() {__cc.~value_type();}
|
||||
};
|
||||
#else
|
||||
struct __value_type
|
||||
{
|
||||
typedef typename unordered_map::value_type value_type;
|
||||
value_type __cc;
|
||||
|
||||
__value_type() {}
|
||||
|
||||
template <class _A0>
|
||||
__value_type(const _A0& __a0)
|
||||
: __cc(__a0) {}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
__value_type(const _A0& __a0, const _A1& __a1)
|
||||
: __cc(__a0, __a1) {}
|
||||
};
|
||||
#endif
|
||||
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
|
||||
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
|
||||
typedef typename allocator_traits<allocator_type>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<__value_type>
|
||||
@ -750,7 +743,16 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unordered_map& operator=(const unordered_map& __u)
|
||||
{
|
||||
#if __cplusplus >= 201103L
|
||||
__table_ = __u.__table_;
|
||||
#else
|
||||
__table_.clear();
|
||||
__table_.hash_function() = __u.__table_.hash_function();
|
||||
__table_.key_eq() = __u.__table_.key_eq();
|
||||
__table_.max_load_factor() = __u.__table_.max_load_factor();
|
||||
__table_.__copy_assign_alloc(__u.__table_);
|
||||
insert(__u.begin(), __u.end());
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -907,26 +909,15 @@ private:
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node();
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<value_type, _A0>::value,
|
||||
__node_holder
|
||||
>::type
|
||||
__construct_node(_A0&& __a0);
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<key_type, _A0>::value,
|
||||
__node_holder
|
||||
>::type
|
||||
__node_holder
|
||||
__construct_node(_A0&& __a0);
|
||||
__node_holder __construct_node_with_key(key_type&& __k);
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _A0, class _A1, class ..._Args>
|
||||
__node_holder __construct_node(_A0&& __a0, _A1&& __a1, _Args&& ...__args);
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node(const key_type& __k);
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node_with_key(const key_type& __k);
|
||||
};
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
@ -1105,11 +1096,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<pair<const _Key, _Tp>, _A0>::value,
|
||||
typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
>::type
|
||||
typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
|
||||
{
|
||||
__node_allocator& __na = __table_.__node_alloc();
|
||||
@ -1122,22 +1109,16 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<_Key, _A0>::value,
|
||||
typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
>::type
|
||||
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
|
||||
typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_type&& __k)
|
||||
{
|
||||
__node_allocator& __na = __table_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first),
|
||||
_VSTD::forward<_A0>(__a0));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), _VSTD::move(__k));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
return _VSTD::move(__h);
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
@ -1172,23 +1153,21 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args)
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
|
||||
unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k)
|
||||
{
|
||||
__node_allocator& __na = __table_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first), __k);
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first), __k);
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return _VSTD::move(__h);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _InputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -1207,7 +1186,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
|
||||
iterator __i = find(__k);
|
||||
if (__i != end())
|
||||
return __i->second;
|
||||
__node_holder __h = __construct_node(__k);
|
||||
__node_holder __h = __construct_node_with_key(__k);
|
||||
pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
|
||||
__h.release();
|
||||
return __r.first->second;
|
||||
@ -1222,7 +1201,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
|
||||
iterator __i = find(__k);
|
||||
if (__i != end())
|
||||
return __i->second;
|
||||
__node_holder __h = __construct_node(_VSTD::move(__k));
|
||||
__node_holder __h = __construct_node_with_key(_VSTD::move(__k));
|
||||
pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
|
||||
__h.release();
|
||||
return __r.first->second;
|
||||
@ -1304,13 +1283,56 @@ public:
|
||||
typedef _Pred key_equal;
|
||||
typedef _Alloc allocator_type;
|
||||
typedef pair<const key_type, mapped_type> value_type;
|
||||
typedef pair<key_type, mapped_type> __nc_value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
private:
|
||||
typedef pair<key_type, mapped_type> __value_type;
|
||||
typedef __unordered_map_hasher<key_type, mapped_type, hasher> __hasher;
|
||||
typedef __unordered_map_equal<key_type, mapped_type, key_equal> __key_equal;
|
||||
#if __cplusplus >= 201103L
|
||||
union __value_type
|
||||
{
|
||||
typedef typename unordered_multimap::value_type value_type;
|
||||
typedef typename unordered_multimap::__nc_value_type __nc_value_type;
|
||||
value_type __cc;
|
||||
__nc_value_type __nc;
|
||||
|
||||
template <class ..._Args>
|
||||
__value_type(_Args&& ...__args)
|
||||
: __cc(std::forward<_Args>(__args)...) {}
|
||||
|
||||
__value_type(const __value_type& __v)
|
||||
: __cc(std::move(__v.__cc)) {}
|
||||
|
||||
__value_type(__value_type&& __v)
|
||||
: __nc(std::move(__v.__nc)) {}
|
||||
|
||||
__value_type& operator=(const __value_type& __v)
|
||||
{__nc = __v.__cc; return *this;}
|
||||
|
||||
__value_type& operator=(__value_type&& __v)
|
||||
{__nc = std::move(__v.__nc); return *this;}
|
||||
|
||||
~__value_type() {__cc.~value_type();}
|
||||
};
|
||||
#else
|
||||
struct __value_type
|
||||
{
|
||||
typedef typename unordered_multimap::value_type value_type;
|
||||
value_type __cc;
|
||||
|
||||
__value_type() {}
|
||||
|
||||
template <class _A0>
|
||||
__value_type(const _A0& __a0)
|
||||
: __cc(__a0) {}
|
||||
|
||||
template <class _A0, class _A1>
|
||||
__value_type(const _A0& __a0, const _A1& __a1)
|
||||
: __cc(__a0, __a1) {}
|
||||
};
|
||||
#endif
|
||||
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
|
||||
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
|
||||
typedef typename allocator_traits<allocator_type>::template
|
||||
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
|
||||
rebind_alloc<__value_type>
|
||||
@ -1382,7 +1404,16 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
unordered_multimap& operator=(const unordered_multimap& __u)
|
||||
{
|
||||
#if __cplusplus >= 201103L
|
||||
__table_ = __u.__table_;
|
||||
#else
|
||||
__table_.clear();
|
||||
__table_.hash_function() = __u.__table_.hash_function();
|
||||
__table_.key_eq() = __u.__table_.key_eq();
|
||||
__table_.max_load_factor() = __u.__table_.max_load_factor();
|
||||
__table_.__copy_assign_alloc(__u.__table_);
|
||||
insert(__u.begin(), __u.end());
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@ -1529,18 +1560,7 @@ private:
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__node_holder __construct_node();
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<value_type, _A0>::value,
|
||||
__node_holder
|
||||
>::type
|
||||
__construct_node(_A0&& __a0);
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<key_type, _A0>::value,
|
||||
__node_holder
|
||||
>::type
|
||||
__node_holder
|
||||
__construct_node(_A0&& __a0);
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
template <class _A0, class _A1, class ..._Args>
|
||||
@ -1727,11 +1747,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node()
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<pair<const _Key, _Tp>, _A0>::value,
|
||||
typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
>::type
|
||||
typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
|
||||
{
|
||||
__node_allocator& __na = __table_.__node_alloc();
|
||||
@ -1743,25 +1759,6 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0
|
||||
return __h;
|
||||
}
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
template <class _A0>
|
||||
typename enable_if
|
||||
<
|
||||
is_constructible<_Key, _A0>::value,
|
||||
typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
|
||||
>::type
|
||||
unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(_A0&& __a0)
|
||||
{
|
||||
__node_allocator& __na = __table_.__node_alloc();
|
||||
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.first),
|
||||
_VSTD::forward<_A0>(__a0));
|
||||
__h.get_deleter().__first_constructed = true;
|
||||
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.second));
|
||||
__h.get_deleter().__second_constructed = true;
|
||||
return __h;
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
|
||||
|
@ -117,6 +117,27 @@ template<size_t I, class T1, class T2>
|
||||
typename tuple_element<I, std::pair<T1, T2> >::type&&
|
||||
get(std::pair<T1, T2>&&) noexcept;
|
||||
|
||||
// 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)>;
|
||||
|
||||
} // std
|
||||
|
||||
*/
|
||||
@ -578,6 +599,92 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
template<class _Tp, _Tp... _Ip>
|
||||
struct _LIBCPP_TYPE_VIS integer_sequence
|
||||
{
|
||||
typedef _Tp value_type;
|
||||
static_assert( is_integral<_Tp>::value,
|
||||
"std::integer_sequence can only be instantiated with an integral type" );
|
||||
static
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
size_t
|
||||
size() noexcept { return sizeof...(_Ip); }
|
||||
};
|
||||
|
||||
template<size_t... _Ip>
|
||||
using index_sequence = integer_sequence<size_t, _Ip...>;
|
||||
|
||||
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> {}; };
|
||||
|
||||
template<typename _Tp, typename _Up> struct __convert {
|
||||
template<typename> struct __result;
|
||||
template<_Tp ..._Np> struct __result<integer_sequence<_Tp, _Np...> > { typedef integer_sequence<_Up, _Np...> type; };
|
||||
};
|
||||
template<typename _Tp> struct __convert<_Tp, _Tp> { template<typename _Up> struct __result { typedef _Up type; }; };
|
||||
|
||||
}
|
||||
|
||||
template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked =
|
||||
typename __detail::__convert<size_t, _Tp>::template __result<typename __detail::__make<_Np>::type>::type;
|
||||
|
||||
template <class _Tp, _Tp _Ep>
|
||||
struct __make_integer_sequence
|
||||
{
|
||||
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 input shall not be negative");
|
||||
typedef __make_integer_sequence_unchecked<_Tp, _Ep> type;
|
||||
};
|
||||
|
||||
template<class _Tp, _Tp _Np>
|
||||
using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type;
|
||||
|
||||
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)>;
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_UTILITY
|
||||
|
@ -365,12 +365,7 @@ protected:
|
||||
{return static_cast<size_type>(__end_cap() - __begin_);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(const_pointer __new_last) _NOEXCEPT
|
||||
{__destruct_at_end(__new_last, false_type());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(const_pointer __new_last, false_type) _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(const_pointer __new_last, true_type) _NOEXCEPT;
|
||||
void __destruct_at_end(pointer __new_last) _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __copy_assign_alloc(const __vector_base& __c)
|
||||
@ -437,43 +432,35 @@ private:
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
void
|
||||
__vector_base<_Tp, _Allocator>::__destruct_at_end(const_pointer __new_last, false_type) _NOEXCEPT
|
||||
__vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
|
||||
{
|
||||
while (__new_last != __end_)
|
||||
__alloc_traits::destroy(__alloc(), const_cast<pointer>(--__end_));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
void
|
||||
__vector_base<_Tp, _Allocator>::__destruct_at_end(const_pointer __new_last, true_type) _NOEXCEPT
|
||||
{
|
||||
__end_ = const_cast<pointer>(__new_last);
|
||||
__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
__vector_base<_Tp, _Allocator>::__vector_base()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||
: __begin_(0),
|
||||
__end_(0),
|
||||
__end_cap_(0)
|
||||
: __begin_(nullptr),
|
||||
__end_(nullptr),
|
||||
__end_cap_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
__vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
__end_(0),
|
||||
__end_cap_(0, __a)
|
||||
: __begin_(nullptr),
|
||||
__end_(nullptr),
|
||||
__end_cap_(nullptr, __a)
|
||||
{
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
__vector_base<_Tp, _Allocator>::~__vector_base()
|
||||
{
|
||||
if (__begin_ != 0)
|
||||
if (__begin_ != nullptr)
|
||||
{
|
||||
clear();
|
||||
__alloc_traits::deallocate(__alloc(), __begin_, capacity());
|
||||
@ -797,7 +784,7 @@ private:
|
||||
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
|
||||
void __move_assign(vector& __c, false_type);
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __destruct_at_end(const_pointer __new_last) _NOEXCEPT
|
||||
void __destruct_at_end(pointer __new_last) _NOEXCEPT
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__c_node* __c = __get_db()->__find_c_and_lock(this);
|
||||
@ -878,11 +865,11 @@ template <class _Tp, class _Allocator>
|
||||
void
|
||||
vector<_Tp, _Allocator>::deallocate() _NOEXCEPT
|
||||
{
|
||||
if (this->__begin_ != 0)
|
||||
if (this->__begin_ != nullptr)
|
||||
{
|
||||
clear();
|
||||
__alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity());
|
||||
this->__begin_ = this->__end_ = this->__end_cap() = 0;
|
||||
this->__begin_ = this->__end_ = this->__end_cap() = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1171,7 +1158,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
|
||||
this->__begin_ = __x.__begin_;
|
||||
this->__end_ = __x.__end_;
|
||||
this->__end_cap() = __x.__end_cap();
|
||||
__x.__begin_ = __x.__end_ = __x.__end_cap() = 0;
|
||||
__x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
@ -1597,7 +1584,8 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
|
||||
#endif
|
||||
_LIBCPP_ASSERT(__position != end(),
|
||||
"vector::erase(iterator) called with a non-dereferenceable iterator");
|
||||
pointer __p = const_cast<pointer>(&*__position);
|
||||
difference_type __ps = __position - cbegin();
|
||||
pointer __p = this->__begin_ + __ps;
|
||||
iterator __r = __make_iter(__p);
|
||||
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
|
||||
return __r;
|
||||
@ -1943,9 +1931,9 @@ template <class _Tp, class _Allocator>
|
||||
bool
|
||||
vector<_Tp, _Allocator>::__invariants() const
|
||||
{
|
||||
if (this->__begin_ == 0)
|
||||
if (this->__begin_ == nullptr)
|
||||
{
|
||||
if (this->__end_ != 0 || this->__end_cap() != 0)
|
||||
if (this->__end_ != nullptr || this->__end_cap() != nullptr)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@ -2307,7 +2295,7 @@ private:
|
||||
{return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
|
||||
{return iterator(const_cast<__storage_pointer>(__p.__seg_), __p.__ctz_);}
|
||||
{return begin() + (__p - cbegin());}
|
||||
#endif // _LIBCPP_DEBUG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -2414,11 +2402,11 @@ template <class _Allocator>
|
||||
void
|
||||
vector<bool, _Allocator>::deallocate() _NOEXCEPT
|
||||
{
|
||||
if (this->__begin_ != 0)
|
||||
if (this->__begin_ != nullptr)
|
||||
{
|
||||
__storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
|
||||
__invalidate_all_iterators();
|
||||
this->__begin_ = 0;
|
||||
this->__begin_ = nullptr;
|
||||
this->__size_ = this->__cap() = 0;
|
||||
}
|
||||
}
|
||||
@ -2481,7 +2469,7 @@ template <class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
vector<bool, _Allocator>::vector()
|
||||
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
@ -2490,7 +2478,7 @@ vector<bool, _Allocator>::vector()
|
||||
template <class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY inline
|
||||
vector<bool, _Allocator>::vector(const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
@ -2498,7 +2486,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(size_type __n)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
@ -2511,7 +2499,7 @@ vector<bool, _Allocator>::vector(size_type __n)
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
@ -2524,7 +2512,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
@ -2540,7 +2528,7 @@ template <class _InputIterator>
|
||||
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
|
||||
typename enable_if<__is_input_iterator <_InputIterator>::value &&
|
||||
!__is_forward_iterator<_InputIterator>::value>::type*)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
@ -2554,7 +2542,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (__begin_ != 0)
|
||||
if (__begin_ != nullptr)
|
||||
__storage_traits::deallocate(__alloc(), __begin_, __cap());
|
||||
__invalidate_all_iterators();
|
||||
throw;
|
||||
@ -2567,7 +2555,7 @@ template <class _InputIterator>
|
||||
vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
|
||||
typename enable_if<__is_input_iterator <_InputIterator>::value &&
|
||||
!__is_forward_iterator<_InputIterator>::value>::type*)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
@ -2581,7 +2569,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (__begin_ != 0)
|
||||
if (__begin_ != nullptr)
|
||||
__storage_traits::deallocate(__alloc(), __begin_, __cap());
|
||||
__invalidate_all_iterators();
|
||||
throw;
|
||||
@ -2593,7 +2581,7 @@ template <class _Allocator>
|
||||
template <class _ForwardIterator>
|
||||
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
|
||||
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
@ -2609,7 +2597,7 @@ template <class _Allocator>
|
||||
template <class _ForwardIterator>
|
||||
vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
|
||||
typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
@ -2625,7 +2613,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0)
|
||||
{
|
||||
@ -2639,7 +2627,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
|
||||
{
|
||||
@ -2656,7 +2644,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::~vector()
|
||||
{
|
||||
if (__begin_ != 0)
|
||||
if (__begin_ != nullptr)
|
||||
__storage_traits::deallocate(__alloc(), __begin_, __cap());
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
__invalidate_all_iterators();
|
||||
@ -2665,7 +2653,7 @@ vector<bool, _Allocator>::~vector()
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(const vector& __v)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc()))
|
||||
{
|
||||
@ -2678,7 +2666,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, __a)
|
||||
{
|
||||
@ -2720,14 +2708,14 @@ vector<bool, _Allocator>::vector(vector&& __v)
|
||||
__size_(__v.__size_),
|
||||
__cap_alloc_(__v.__cap_alloc_)
|
||||
{
|
||||
__v.__begin_ = 0;
|
||||
__v.__begin_ = nullptr;
|
||||
__v.__size_ = 0;
|
||||
__v.__cap() = 0;
|
||||
}
|
||||
|
||||
template <class _Allocator>
|
||||
vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a)
|
||||
: __begin_(0),
|
||||
: __begin_(nullptr),
|
||||
__size_(0),
|
||||
__cap_alloc_(0, __a)
|
||||
{
|
||||
@ -3123,7 +3111,7 @@ template <class _Allocator>
|
||||
bool
|
||||
vector<bool, _Allocator>::__invariants() const
|
||||
{
|
||||
if (this->__begin_ == 0)
|
||||
if (this->__begin_ == nullptr)
|
||||
{
|
||||
if (this->__size_ != 0 || this->__cap() != 0)
|
||||
return false;
|
||||
|
@ -143,7 +143,7 @@ __libcpp_db::__insert_c(void* __c)
|
||||
if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_))
|
||||
{
|
||||
size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1);
|
||||
__c_node** cbeg = (__c_node**)calloc(nc, sizeof(void*));
|
||||
__c_node** cbeg = static_cast<__c_node**>(calloc(nc, sizeof(void*)));
|
||||
if (cbeg == nullptr)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_alloc();
|
||||
@ -168,7 +168,8 @@ __libcpp_db::__insert_c(void* __c)
|
||||
}
|
||||
size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
|
||||
__c_node* p = __cbeg_[hc];
|
||||
__c_node* r = __cbeg_[hc] = (__c_node*)malloc(sizeof(__c_node));
|
||||
__c_node* r = __cbeg_[hc] =
|
||||
static_cast<__c_node*>(malloc(sizeof(__c_node)));
|
||||
if (__cbeg_[hc] == nullptr)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_alloc();
|
||||
@ -407,7 +408,8 @@ __c_node::__add(__i_node* i)
|
||||
size_t nc = 2*static_cast<size_t>(cap_ - beg_);
|
||||
if (nc == 0)
|
||||
nc = 1;
|
||||
__i_node** beg = (__i_node**)malloc(nc * sizeof(__i_node*));
|
||||
__i_node** beg =
|
||||
static_cast<__i_node**>(malloc(nc * sizeof(__i_node*)));
|
||||
if (beg == nullptr)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_alloc();
|
||||
@ -433,7 +435,7 @@ __libcpp_db::__insert_iterator(void* __i)
|
||||
if (__isz_ + 1 > static_cast<size_t>(__iend_ - __ibeg_))
|
||||
{
|
||||
size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1);
|
||||
__i_node** ibeg = (__i_node**)calloc(nc, sizeof(void*));
|
||||
__i_node** ibeg = static_cast<__i_node**>(calloc(nc, sizeof(void*)));
|
||||
if (ibeg == nullptr)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_alloc();
|
||||
@ -458,7 +460,8 @@ __libcpp_db::__insert_iterator(void* __i)
|
||||
}
|
||||
size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
|
||||
__i_node* p = __ibeg_[hi];
|
||||
__i_node* r = __ibeg_[hi] = (__i_node*)malloc(sizeof(__i_node));
|
||||
__i_node* r = __ibeg_[hi] =
|
||||
static_cast<__i_node*>(malloc(sizeof(__i_node)));
|
||||
if (r == nullptr)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_alloc();
|
||||
|
@ -12,12 +12,9 @@
|
||||
#include "stdexcept"
|
||||
#include "type_traits"
|
||||
|
||||
// Don't silence a non-existent warning if clang doesn't yet have this warning.
|
||||
#ifdef __clang__
|
||||
#if (__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ >= 2))
|
||||
#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
|
@ -54,13 +54,13 @@ ios_base::Init::Init()
|
||||
|
||||
ios_base::Init::~Init()
|
||||
{
|
||||
ostream* cout_ptr = (ostream*)cout;
|
||||
ostream* clog_ptr = (ostream*)clog;
|
||||
ostream* cout_ptr = reinterpret_cast<ostream*>(cout);
|
||||
ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
|
||||
cout_ptr->flush();
|
||||
clog_ptr->flush();
|
||||
|
||||
wostream* wcout_ptr = (wostream*)wcout;
|
||||
wostream* wclog_ptr = (wostream*)wclog;
|
||||
wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);
|
||||
wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
|
||||
wcout_ptr->flush();
|
||||
wclog_ptr->flush();
|
||||
}
|
||||
|
@ -230,8 +230,10 @@ locale::__imp::__imp(const string& name, size_t refs)
|
||||
|
||||
// NOTE avoid the `base class should be explicitly initialized in the
|
||||
// copy constructor` warning emitted by GCC
|
||||
#if defined(__clang__) || _GNUC_VER >= 406
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wextra"
|
||||
#endif
|
||||
|
||||
locale::__imp::__imp(const __imp& other)
|
||||
: facets_(max<size_t>(N, other.facets_.size())),
|
||||
@ -243,7 +245,9 @@ locale::__imp::__imp(const __imp& other)
|
||||
facets_[i]->__add_shared();
|
||||
}
|
||||
|
||||
#if defined(__clang__) || _GNUC_VER >= 406
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
|
||||
: facets_(N),
|
||||
@ -786,7 +790,7 @@ ctype<wchar_t>::do_toupper(char_type c) const
|
||||
{
|
||||
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
|
||||
return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
|
||||
#else
|
||||
return (isascii(c) && iswlower_l(c, __cloc())) ? c-L'a'+L'A' : c;
|
||||
@ -799,7 +803,7 @@ ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const
|
||||
for (; low != high; ++low)
|
||||
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
|
||||
*low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
|
||||
: *low;
|
||||
#else
|
||||
@ -813,7 +817,7 @@ ctype<wchar_t>::do_tolower(char_type c) const
|
||||
{
|
||||
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
|
||||
return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
|
||||
#else
|
||||
return (isascii(c) && isupper_l(c, __cloc())) ? c-L'A'+'a' : c;
|
||||
@ -826,7 +830,7 @@ ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
|
||||
for (; low != high; ++low)
|
||||
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
|
||||
*low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
|
||||
: *low;
|
||||
#else
|
||||
@ -893,9 +897,11 @@ ctype<char>::do_toupper(char_type c) const
|
||||
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
return isascii(c) ?
|
||||
static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;
|
||||
#elif defined(__NetBSD__)
|
||||
return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
|
||||
return isascii(c) ?
|
||||
static_cast<char>(__classic_upper_table()[static_cast<size_t>(c)]) : c;
|
||||
static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
|
||||
#else
|
||||
return (isascii(c) && islower_l(c, __cloc())) ? c-'a'+'A' : c;
|
||||
#endif
|
||||
@ -908,6 +914,8 @@ ctype<char>::do_toupper(char_type* low, const char_type* high) const
|
||||
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
*low = isascii(*low) ?
|
||||
static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low;
|
||||
#elif defined(__NetBSD__)
|
||||
*low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
|
||||
*low = isascii(*low) ?
|
||||
static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
|
||||
@ -923,7 +931,9 @@ ctype<char>::do_tolower(char_type c) const
|
||||
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
return isascii(c) ?
|
||||
static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
|
||||
#elif defined(__NetBSD__)
|
||||
return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN) || defined(__NetBSD__)
|
||||
return isascii(c) ?
|
||||
static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
|
||||
#else
|
||||
@ -937,6 +947,8 @@ ctype<char>::do_tolower(char_type* low, const char_type* high) const
|
||||
for (; low != high; ++low)
|
||||
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
*low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low;
|
||||
#elif defined(__NetBSD__)
|
||||
*low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);
|
||||
#elif defined(__GLIBC__) || defined(EMSCRIPTEN)
|
||||
*low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
|
||||
#else
|
||||
@ -989,6 +1001,8 @@ ctype<char>::classic_table() _NOEXCEPT
|
||||
{
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
return _DefaultRuneLocale.__runetype;
|
||||
#elif defined(__NetBSD__)
|
||||
return _C_ctype_tab_ + 1;
|
||||
#elif defined(__GLIBC__)
|
||||
return __cloc()->__ctype_b;
|
||||
#elif __sun__
|
||||
@ -1020,9 +1034,20 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
|
||||
{
|
||||
return __cloc()->__ctype_toupper;
|
||||
}
|
||||
#endif // __GLIBC__
|
||||
#elif __NetBSD__
|
||||
const short*
|
||||
ctype<char>::__classic_lower_table() _NOEXCEPT
|
||||
{
|
||||
return _C_tolower_tab_ + 1;
|
||||
}
|
||||
|
||||
#if defined(EMSCRIPTEN)
|
||||
const short*
|
||||
ctype<char>::__classic_upper_table() _NOEXCEPT
|
||||
{
|
||||
return _C_toupper_tab_ + 1;
|
||||
}
|
||||
|
||||
#elif defined(EMSCRIPTEN)
|
||||
const int*
|
||||
ctype<char>::__classic_lower_table() _NOEXCEPT
|
||||
{
|
||||
@ -1034,7 +1059,7 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
|
||||
{
|
||||
return *__ctype_toupper_loc();
|
||||
}
|
||||
#endif // EMSCRIPTEN
|
||||
#endif // __GLIBC__ || EMSCRIPTEN || __NETBSD__
|
||||
|
||||
// template <> class ctype_byname<char>
|
||||
|
||||
@ -1068,28 +1093,28 @@ ctype_byname<char>::~ctype_byname()
|
||||
char
|
||||
ctype_byname<char>::do_toupper(char_type c) const
|
||||
{
|
||||
return static_cast<char>(toupper_l(c, __l));
|
||||
return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l));
|
||||
}
|
||||
|
||||
const char*
|
||||
ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const
|
||||
{
|
||||
for (; low != high; ++low)
|
||||
*low = static_cast<char>(toupper_l(*low, __l));
|
||||
*low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l));
|
||||
return low;
|
||||
}
|
||||
|
||||
char
|
||||
ctype_byname<char>::do_tolower(char_type c) const
|
||||
{
|
||||
return static_cast<char>(tolower_l(c, __l));
|
||||
return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l));
|
||||
}
|
||||
|
||||
const char*
|
||||
ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
|
||||
{
|
||||
for (; low != high; ++low)
|
||||
*low = static_cast<char>(tolower_l(*low, __l));
|
||||
*low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l));
|
||||
return low;
|
||||
}
|
||||
|
||||
@ -1372,7 +1397,7 @@ locale::id codecvt<wchar_t, char, mbstate_t>::id;
|
||||
|
||||
codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)
|
||||
: locale::facet(refs),
|
||||
__l(0)
|
||||
__l(_LIBCPP_GET_C_LOCALE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1389,7 +1414,7 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
|
||||
|
||||
codecvt<wchar_t, char, mbstate_t>::~codecvt()
|
||||
{
|
||||
if (__l != 0)
|
||||
if (__l != _LIBCPP_GET_C_LOCALE)
|
||||
freelocale(__l);
|
||||
}
|
||||
|
||||
@ -5315,7 +5340,7 @@ __time_put::__time_put(const string& nm)
|
||||
|
||||
__time_put::~__time_put()
|
||||
{
|
||||
if (__loc_)
|
||||
if (__loc_ != _LIBCPP_GET_C_LOCALE)
|
||||
freelocale(__loc_);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ __libcpp_nmstr::__libcpp_nmstr(const char* msg)
|
||||
c[0] = c[1] = len;
|
||||
str_ += offset;
|
||||
count() = 0;
|
||||
std::strcpy(const_cast<char*>(c_str()), msg);
|
||||
std::memcpy(const_cast<char*>(c_str()), msg, len + 1);
|
||||
}
|
||||
|
||||
inline
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,11 +16,17 @@
|
||||
#if !defined(_WIN32)
|
||||
#if !defined(__sun__) && !defined(__linux__)
|
||||
#include <sys/sysctl.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif // !__sun__ && !__linux__
|
||||
#include <unistd.h>
|
||||
#endif // !_WIN32
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#pragma weak pthread_create // Do not create libpthread dependency
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
thread::~thread()
|
||||
@ -67,7 +73,7 @@ thread::hardware_concurrency() _NOEXCEPT
|
||||
std::size_t s = sizeof(n);
|
||||
sysctl(mib, 2, &n, &s, 0, 0);
|
||||
return n;
|
||||
#elif (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && defined(_SC_NPROCESSORS_ONLN)) || defined(EMSCRIPTEN)
|
||||
#elif defined(_SC_NPROCESSORS_ONLN)
|
||||
long result = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
// sysconf returns -1 if the name is invalid, the option does not exist or
|
||||
// does not have a definite limit.
|
||||
@ -76,9 +82,14 @@ thread::hardware_concurrency() _NOEXCEPT
|
||||
if (result < 0)
|
||||
return 0;
|
||||
return static_cast<unsigned>(result);
|
||||
#elif defined(_WIN32)
|
||||
SYSTEM_INFO info;
|
||||
GetSystemInfo(&info);
|
||||
return info.dwNumberOfProcessors;
|
||||
#else // defined(CTL_HW) && defined(HW_NCPU)
|
||||
// TODO: grovel through /proc or check cpuid on x86 and similar
|
||||
// instructions on other architectures.
|
||||
#warning hardware_concurrency not yet implemented
|
||||
return 0; // Means not computable [thread.thread.static]
|
||||
#endif // defined(CTL_HW) && defined(HW_NCPU)
|
||||
}
|
||||
|
@ -27,3 +27,4 @@
|
||||
#define ATOMIC_LOAD(addr)\
|
||||
(__sync_synchronize(), *addr)
|
||||
#endif
|
||||
|
||||
|
@ -65,3 +65,13 @@ extern "C" void __cxa_pure_virtual()
|
||||
abort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compilers may (but are not required to) set any deleted-virtual function's
|
||||
* vtable entry to this function. This makes debugging slightly easier, as
|
||||
* users can add a breakpoint on this function to tell if they've accidentally
|
||||
* called a deleted-virtual function.
|
||||
*/
|
||||
extern "C" void __cxa_deleted_virtual()
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
@ -193,6 +193,8 @@ __cxa_eh_globals *__cxa_get_globals(void);
|
||||
*/
|
||||
__cxa_eh_globals *__cxa_get_globals_fast(void);
|
||||
|
||||
std::type_info * __cxa_current_exception_type();
|
||||
|
||||
/**
|
||||
* Throws an exception returned by __cxa_current_primary_exception(). This
|
||||
* exception may have been caught in another thread.
|
||||
|
@ -57,6 +57,8 @@ typedef unsigned char *dw_eh_ptr_t;
|
||||
/// DWARF data encoding types.
|
||||
enum dwarf_data_encoding
|
||||
{
|
||||
/// Absolute pointer value
|
||||
DW_EH_PE_absptr = 0x00,
|
||||
/// Unsigned, little-endian, base 128-encoded (variable length).
|
||||
DW_EH_PE_uleb128 = 0x01,
|
||||
/// Unsigned 16-bit integer.
|
||||
@ -95,8 +97,6 @@ enum dwarf_data_relative
|
||||
{
|
||||
/// Value is omitted
|
||||
DW_EH_PE_omit = 0xff,
|
||||
/// Absolute pointer value
|
||||
DW_EH_PE_absptr = 0x00,
|
||||
/// Value relative to program counter
|
||||
DW_EH_PE_pcrel = 0x10,
|
||||
/// Value relative to the text segment
|
||||
|
@ -39,6 +39,24 @@
|
||||
#pragma weak pthread_setspecific
|
||||
#pragma weak pthread_getspecific
|
||||
#pragma weak pthread_once
|
||||
#ifdef LIBCXXRT_WEAK_LOCKS
|
||||
#pragma weak pthread_mutex_lock
|
||||
#define pthread_mutex_lock(mtx) do {\
|
||||
if (pthread_mutex_lock) pthread_mutex_lock(mtx);\
|
||||
} while(0)
|
||||
#pragma weak pthread_mutex_unlock
|
||||
#define pthread_mutex_unlock(mtx) do {\
|
||||
if (pthread_mutex_unlock) pthread_mutex_unlock(mtx);\
|
||||
} while(0)
|
||||
#pragma weak pthread_cond_signal
|
||||
#define pthread_cond_signal(cv) do {\
|
||||
if (pthread_cond_signal) pthread_cond_signal(cv);\
|
||||
} while(0)
|
||||
#pragma weak pthread_cond_wait
|
||||
#define pthread_cond_wait(cv, mtx) do {\
|
||||
if (pthread_cond_wait) pthread_cond_wait(cv, mtx);\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
using namespace ABI_NAMESPACE;
|
||||
|
||||
@ -214,8 +232,6 @@ namespace std
|
||||
|
||||
}
|
||||
|
||||
extern "C" std::type_info *__cxa_current_exception_type();
|
||||
|
||||
/**
|
||||
* Class of exceptions to distinguish between this and other exception types.
|
||||
*
|
||||
|
@ -41,37 +41,90 @@
|
||||
* initialised.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <assert.h>
|
||||
#include "atomic.h"
|
||||
|
||||
// Older GCC doesn't define __LITTLE_ENDIAN__
|
||||
#ifndef __LITTLE_ENDIAN__
|
||||
// If __BYTE_ORDER__ is defined, use that instead
|
||||
# ifdef __BYTE_ORDER__
|
||||
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
# define __LITTLE_ENDIAN__
|
||||
# endif
|
||||
// x86 and ARM are the most common little-endian CPUs, so let's have a
|
||||
// special case for them (ARM is already special cased). Assume everything
|
||||
// else is big endian.
|
||||
# elif defined(__x86_64) || defined(__i386)
|
||||
# define __LITTLE_ENDIAN__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The least significant bit of the guard variable indicates that the object
|
||||
* has been initialised, the most significant bit is used for a spinlock.
|
||||
*/
|
||||
#ifdef __arm__
|
||||
// ARM ABI - 32-bit guards.
|
||||
typedef uint32_t guard_t;
|
||||
static const uint32_t LOCKED = ((guard_t)1) << 31;
|
||||
static const uint32_t INITIALISED = 1;
|
||||
#else
|
||||
typedef uint64_t guard_t;
|
||||
# if defined(__LITTLE_ENDIAN__)
|
||||
static const guard_t LOCKED = ((guard_t)1) << 63;
|
||||
static const guard_t INITIALISED = 1;
|
||||
# else
|
||||
static const guard_t LOCKED = 1;
|
||||
static const guard_t INITIALISED = ((guard_t)1) << 56;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Acquires a lock on a guard, returning 0 if the object has already been
|
||||
* initialised, and 1 if it has not. If the object is already constructed then
|
||||
* this function just needs to read a byte from memory and return.
|
||||
*/
|
||||
extern "C" int __cxa_guard_acquire(volatile int32_t *guard_object)
|
||||
extern "C" int __cxa_guard_acquire(volatile guard_t *guard_object)
|
||||
{
|
||||
if ((1<<31) == *guard_object) { return 0; }
|
||||
// If we can atomically move the value from 0 -> 1, then this is
|
||||
// uninitialised.
|
||||
if (__sync_bool_compare_and_swap(guard_object, 0, 1))
|
||||
// Not an atomic read, doesn't establish a happens-before relationship, but
|
||||
// if one is already established and we end up seeing an initialised state
|
||||
// then it's a fast path, otherwise we'll do something more expensive than
|
||||
// this test anyway...
|
||||
if ((INITIALISED == *guard_object)) { return 0; }
|
||||
// Spin trying to do the initialisation
|
||||
while (1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
// If the value is not 0, some other thread was initialising this. Spin
|
||||
// until it's finished.
|
||||
while (__sync_bool_compare_and_swap(guard_object, (1<<31), (1<<31)))
|
||||
{
|
||||
// If the other thread aborted, then we grab the lock
|
||||
if (__sync_bool_compare_and_swap(guard_object, 0, 1))
|
||||
// Loop trying to move the value of the guard from 0 (not
|
||||
// locked, not initialised) to the locked-uninitialised
|
||||
// position.
|
||||
switch (__sync_val_compare_and_swap(guard_object, 0, LOCKED))
|
||||
{
|
||||
return 1;
|
||||
// If the old value was 0, we succeeded, so continue
|
||||
// initialising
|
||||
case 0:
|
||||
return 1;
|
||||
// If this was already initialised, return and let the caller skip
|
||||
// initialising it again.
|
||||
case INITIALISED:
|
||||
return 0;
|
||||
// If it is locked by another thread, relinquish the CPU and try
|
||||
// again later.
|
||||
case LOCKED:
|
||||
case LOCKED | INITIALISED:
|
||||
sched_yield();
|
||||
break;
|
||||
// If it is some other value, then something has gone badly wrong.
|
||||
// Give up.
|
||||
default:
|
||||
fprintf(stderr, "Invalid state detected attempting to lock static initialiser.\n");
|
||||
abort();
|
||||
}
|
||||
sched_yield();
|
||||
}
|
||||
//__builtin_unreachable();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -79,86 +132,21 @@ extern "C" int __cxa_guard_acquire(volatile int32_t *guard_object)
|
||||
* Releases the lock without marking the object as initialised. This function
|
||||
* is called if initialising a static causes an exception to be thrown.
|
||||
*/
|
||||
extern "C" void __cxa_guard_abort(int32_t *guard_object)
|
||||
extern "C" void __cxa_guard_abort(volatile guard_t *guard_object)
|
||||
{
|
||||
assert(__sync_bool_compare_and_swap(guard_object, 1, 0));
|
||||
__attribute__((unused))
|
||||
bool reset = __sync_bool_compare_and_swap(guard_object, LOCKED, 0);
|
||||
assert(reset);
|
||||
}
|
||||
/**
|
||||
* Releases the guard and marks the object as initialised. This function is
|
||||
* called after successful initialisation of a static.
|
||||
*/
|
||||
extern "C" void __cxa_guard_release(int32_t *guard_object)
|
||||
extern "C" void __cxa_guard_release(volatile guard_t *guard_object)
|
||||
{
|
||||
assert(__sync_bool_compare_and_swap(guard_object, 1, (1<<31)));
|
||||
__attribute__((unused))
|
||||
bool reset = __sync_bool_compare_and_swap(guard_object, LOCKED, INITIALISED);
|
||||
assert(reset);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
// Itanium ABI: 64-bit guards
|
||||
|
||||
/**
|
||||
* Returns a pointer to the low 32 bits in a 64-bit value, respecting the
|
||||
* platform's byte order.
|
||||
*/
|
||||
static int32_t *low_32_bits(volatile int64_t *ptr)
|
||||
{
|
||||
int32_t *low= (int32_t*)ptr;
|
||||
// Test if the machine is big endian - constant propagation at compile time
|
||||
// should eliminate this completely.
|
||||
int one = 1;
|
||||
if (*(char*)&one != 1)
|
||||
{
|
||||
low++;
|
||||
}
|
||||
return low;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquires a lock on a guard, returning 0 if the object has already been
|
||||
* initialised, and 1 if it has not. If the object is already constructed then
|
||||
* this function just needs to read a byte from memory and return.
|
||||
*/
|
||||
extern "C" int __cxa_guard_acquire(volatile int64_t *guard_object)
|
||||
{
|
||||
char first_byte = (*guard_object) >> 56;
|
||||
if (1 == first_byte) { return 0; }
|
||||
int32_t *lock = low_32_bits(guard_object);
|
||||
// Simple spin lock using the low 32 bits. We assume that concurrent
|
||||
// attempts to initialize statics are very rare, so we don't need to
|
||||
// optimise for the case where we have lots of threads trying to acquire
|
||||
// the lock at the same time.
|
||||
while (!__sync_bool_compare_and_swap_4(lock, 0, 1))
|
||||
{
|
||||
if (1 == ((*guard_object) >> 56))
|
||||
{
|
||||
break;
|
||||
}
|
||||
sched_yield();
|
||||
}
|
||||
// We have to test the guard again, in case another thread has performed
|
||||
// the initialisation while we were trying to acquire the lock.
|
||||
first_byte = (*guard_object) >> 56;
|
||||
return (1 != first_byte);
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the lock without marking the object as initialised. This function
|
||||
* is called if initialising a static causes an exception to be thrown.
|
||||
*/
|
||||
extern "C" void __cxa_guard_abort(int64_t *guard_object)
|
||||
{
|
||||
int32_t *lock = low_32_bits(guard_object);
|
||||
*lock = 0;
|
||||
}
|
||||
/**
|
||||
* Releases the guard and marks the object as initialised. This function is
|
||||
* called after successful initialisation of a static.
|
||||
*/
|
||||
extern "C" void __cxa_guard_release(int64_t *guard_object)
|
||||
{
|
||||
// Set the first byte to 1
|
||||
*guard_object |= ((int64_t)1) << 56;
|
||||
__cxa_guard_abort(guard_object);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -99,40 +99,21 @@ void* operator new(size_t size)
|
||||
__attribute__((weak))
|
||||
void* operator new(size_t size, const std::nothrow_t &) throw()
|
||||
{
|
||||
if (0 == size)
|
||||
{
|
||||
size = 1;
|
||||
try {
|
||||
return :: operator new(size);
|
||||
} catch (...) {
|
||||
// nothrow operator new should return NULL in case of
|
||||
// std::bad_alloc exception in new handler
|
||||
return NULL;
|
||||
}
|
||||
void *mem = malloc(size);
|
||||
while (0 == mem)
|
||||
{
|
||||
new_handler h = std::get_new_handler();
|
||||
if (0 != h)
|
||||
{
|
||||
try
|
||||
{
|
||||
h();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// nothrow operator new should return NULL in case of
|
||||
// std::bad_alloc exception in new handler
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
mem = malloc(size);
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
||||
__attribute__((weak))
|
||||
void operator delete(void * ptr)
|
||||
#if __cplusplus < 201000L
|
||||
throw()
|
||||
#endif
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
@ -140,13 +121,32 @@ void operator delete(void * ptr)
|
||||
|
||||
__attribute__((weak))
|
||||
void * operator new[](size_t size)
|
||||
#if __cplusplus < 201000L
|
||||
throw(std::bad_alloc)
|
||||
#endif
|
||||
{
|
||||
return ::operator new(size);
|
||||
}
|
||||
|
||||
|
||||
__attribute__((weak))
|
||||
void operator delete[](void * ptr) throw()
|
||||
void * operator new[](size_t size, const std::nothrow_t &) throw()
|
||||
{
|
||||
try {
|
||||
return ::operator new[](size);
|
||||
} catch (...) {
|
||||
// nothrow operator new should return NULL in case of
|
||||
// std::bad_alloc exception in new handler
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__attribute__((weak))
|
||||
void operator delete[](void * ptr)
|
||||
#if __cplusplus < 201000L
|
||||
throw()
|
||||
#endif
|
||||
{
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
@ -75,15 +75,12 @@ STATISTIC(NumFastIselDead, "Number of dead insts removed on failure");
|
||||
void FastISel::startNewBlock() {
|
||||
LocalValueMap.clear();
|
||||
|
||||
// Instructions are appended to FuncInfo.MBB. If the basic block already
|
||||
// contains labels or copies, use the last instruction as the last local
|
||||
// value.
|
||||
EmitStartPt = 0;
|
||||
|
||||
// Advance the emit start point past any EH_LABEL instructions.
|
||||
MachineBasicBlock::iterator
|
||||
I = FuncInfo.MBB->begin(), E = FuncInfo.MBB->end();
|
||||
while (I != E && I->getOpcode() == TargetOpcode::EH_LABEL) {
|
||||
EmitStartPt = I;
|
||||
++I;
|
||||
}
|
||||
if (!FuncInfo.MBB->empty())
|
||||
EmitStartPt = &FuncInfo.MBB->back();
|
||||
LastLocalValue = EmitStartPt;
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,13 @@ extern int SIZE_BUF;
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/capability.h>
|
||||
#include <sys/ioccom.h>
|
||||
#include <net/bpf.h>
|
||||
#include <fcntl.h>
|
||||
#include <libgen.h>
|
||||
#endif /* __FreeBSD__ */
|
||||
#ifndef WIN32
|
||||
#include <sys/wait.h>
|
||||
#include <sys/resource.h>
|
||||
@ -384,6 +391,9 @@ struct dump_info {
|
||||
char *CurrentFileName;
|
||||
pcap_t *pd;
|
||||
pcap_dumper_t *p;
|
||||
#ifdef __FreeBSD__
|
||||
int dirfd;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
|
||||
@ -702,6 +712,10 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
int status;
|
||||
FILE *VFile;
|
||||
#ifdef __FreeBSD__
|
||||
int cansandbox;
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
if(wsockinit() != 0) return 1;
|
||||
#endif /* WIN32 */
|
||||
@ -1189,6 +1203,12 @@ main(int argc, char **argv)
|
||||
pd = pcap_open_offline(RFileName, ebuf);
|
||||
if (pd == NULL)
|
||||
error("%s", ebuf);
|
||||
#ifdef __FreeBSD__
|
||||
if (cap_rights_limit(fileno(pcap_file(pd)), CAP_READ) < 0 &&
|
||||
errno != ENOSYS) {
|
||||
error("unable to limit pcap descriptor");
|
||||
}
|
||||
#endif
|
||||
dlt = pcap_datalink(pd);
|
||||
dlt_name = pcap_datalink_val_to_name(dlt);
|
||||
if (dlt_name == NULL) {
|
||||
@ -1437,6 +1457,20 @@ main(int argc, char **argv)
|
||||
|
||||
if (pcap_setfilter(pd, &fcode) < 0)
|
||||
error("%s", pcap_geterr(pd));
|
||||
#ifdef __FreeBSD__
|
||||
if (RFileName == NULL && VFileName == NULL) {
|
||||
static const unsigned long cmds[] = { BIOCGSTATS };
|
||||
|
||||
if (cap_rights_limit(pcap_fileno(pd),
|
||||
CAP_IOCTL | CAP_READ) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit pcap descriptor");
|
||||
}
|
||||
if (cap_ioctls_limit(pcap_fileno(pd), cmds,
|
||||
sizeof(cmds) / sizeof(cmds[0])) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit ioctls on pcap descriptor");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (WFileName) {
|
||||
pcap_dumper_t *p;
|
||||
/* Do not exceed the default PATH_MAX for files. */
|
||||
@ -1458,9 +1492,30 @@ main(int argc, char **argv)
|
||||
#endif
|
||||
if (p == NULL)
|
||||
error("%s", pcap_geterr(pd));
|
||||
#ifdef __FreeBSD__
|
||||
if (cap_rights_limit(fileno(pcap_dump_file(p)),
|
||||
CAP_SEEK | CAP_WRITE) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit dump descriptor");
|
||||
}
|
||||
#endif
|
||||
if (Cflag != 0 || Gflag != 0) {
|
||||
callback = dump_packet_and_trunc;
|
||||
#ifdef __FreeBSD__
|
||||
dumpinfo.WFileName = strdup(basename(WFileName));
|
||||
dumpinfo.dirfd = open(dirname(WFileName),
|
||||
O_DIRECTORY | O_RDONLY);
|
||||
if (dumpinfo.dirfd < 0) {
|
||||
error("unable to open directory %s",
|
||||
dirname(WFileName));
|
||||
}
|
||||
if (cap_rights_limit(dumpinfo.dirfd, CAP_CREATE |
|
||||
CAP_FCNTL | CAP_FTRUNCATE | CAP_LOOKUP | CAP_SEEK |
|
||||
CAP_WRITE) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit directory rights");
|
||||
}
|
||||
#else /* !__FreeBSD__ */
|
||||
dumpinfo.WFileName = WFileName;
|
||||
#endif
|
||||
callback = dump_packet_and_trunc;
|
||||
dumpinfo.pd = pd;
|
||||
dumpinfo.p = p;
|
||||
pcap_userdata = (u_char *)&dumpinfo;
|
||||
@ -1530,6 +1585,15 @@ main(int argc, char **argv)
|
||||
(void)fflush(stderr);
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
cansandbox = (nflag && VFileName == NULL && zflag == NULL);
|
||||
if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
|
||||
error("unable to enter the capability mode");
|
||||
if (cap_sandboxed())
|
||||
fprintf(stderr, "capability mode sandbox enabled\n");
|
||||
#endif
|
||||
|
||||
do {
|
||||
status = pcap_loop(pd, cnt, callback, pcap_userdata);
|
||||
if (WFileName == NULL) {
|
||||
@ -1569,6 +1633,12 @@ main(int argc, char **argv)
|
||||
pd = pcap_open_offline(RFileName, ebuf);
|
||||
if (pd == NULL)
|
||||
error("%s", ebuf);
|
||||
#ifdef __FreeBSD__
|
||||
if (cap_rights_limit(fileno(pcap_file(pd)),
|
||||
CAP_READ) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit pcap descriptor");
|
||||
}
|
||||
#endif
|
||||
new_dlt = pcap_datalink(pd);
|
||||
if (WFileName && new_dlt != dlt)
|
||||
error("%s: new dlt does not match original", RFileName);
|
||||
@ -1765,6 +1835,11 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
|
||||
|
||||
/* If the time is greater than the specified window, rotate */
|
||||
if (t - Gflag_time >= Gflag) {
|
||||
#ifdef __FreeBSD__
|
||||
FILE *fp;
|
||||
int fd;
|
||||
#endif
|
||||
|
||||
/* Update the Gflag_time */
|
||||
Gflag_time = t;
|
||||
/* Update Gflag_count */
|
||||
@ -1811,13 +1886,35 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
|
||||
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
|
||||
capng_apply(CAPNG_EFFECTIVE);
|
||||
#endif /* HAVE_CAP_NG_H */
|
||||
#ifdef __FreeBSD__
|
||||
fd = openat(dump_info->dirfd,
|
||||
dump_info->CurrentFileName,
|
||||
O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
||||
if (fd < 0) {
|
||||
error("unable to open file %s",
|
||||
dump_info->CurrentFileName);
|
||||
}
|
||||
fp = fdopen(fd, "w");
|
||||
if (fp == NULL) {
|
||||
error("unable to fdopen file %s",
|
||||
dump_info->CurrentFileName);
|
||||
}
|
||||
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
|
||||
#else /* !__FreeBSD__ */
|
||||
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
|
||||
#endif
|
||||
#ifdef HAVE_CAP_NG_H
|
||||
capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
|
||||
capng_apply(CAPNG_EFFECTIVE);
|
||||
#endif /* HAVE_CAP_NG_H */
|
||||
if (dump_info->p == NULL)
|
||||
error("%s", pcap_geterr(pd));
|
||||
#ifdef __FreeBSD__
|
||||
if (cap_rights_limit(fileno(pcap_dump_file(dump_info->p)),
|
||||
CAP_SEEK | CAP_WRITE) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit dump descriptor");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1827,6 +1924,11 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
|
||||
* file could put it over Cflag.
|
||||
*/
|
||||
if (Cflag != 0 && pcap_dump_ftell(dump_info->p) > Cflag) {
|
||||
#ifdef __FreeBSD__
|
||||
FILE *fp;
|
||||
int fd;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Close the current file and open a new one.
|
||||
*/
|
||||
@ -1849,9 +1951,30 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
|
||||
if (dump_info->CurrentFileName == NULL)
|
||||
error("dump_packet_and_trunc: malloc");
|
||||
MakeFilename(dump_info->CurrentFileName, dump_info->WFileName, Cflag_count, WflagChars);
|
||||
#ifdef __FreeBSD__
|
||||
fd = openat(dump_info->dirfd, dump_info->CurrentFileName,
|
||||
O_CREAT | O_WRONLY | O_TRUNC, 0644);
|
||||
if (fd < 0) {
|
||||
error("unable to open file %s",
|
||||
dump_info->CurrentFileName);
|
||||
}
|
||||
fp = fdopen(fd, "w");
|
||||
if (fp == NULL) {
|
||||
error("unable to fdopen file %s",
|
||||
dump_info->CurrentFileName);
|
||||
}
|
||||
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
|
||||
#else /* !__FreeBSD__ */
|
||||
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
|
||||
#endif
|
||||
if (dump_info->p == NULL)
|
||||
error("%s", pcap_geterr(pd));
|
||||
#ifdef __FreeBSD__
|
||||
if (cap_rights_limit(fileno(pcap_dump_file(dump_info->p)),
|
||||
CAP_SEEK | CAP_WRITE) < 0 && errno != ENOSYS) {
|
||||
error("unable to limit dump descriptor");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
pcap_dump((u_char *)dump_info->p, h, sp);
|
||||
|
@ -852,12 +852,18 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou
|
||||
# announced that year's Ramadan daylight-saving transitions would be
|
||||
# 2012-07-20 and 2012-08-20; see
|
||||
# <http://www.mmsp.gov.ma/fr/actualites.aspx?id=288>.
|
||||
#
|
||||
|
||||
# From Andrew Paprocki (2013-07-02):
|
||||
# Morocco announced that the year's Ramadan daylight-savings
|
||||
# transitions would be 2013-07-07 and 2013-08-10; see:
|
||||
# http://www.maroc.ma/en/news/morocco-suspends-daylight-saving-time-july-7-aug10
|
||||
|
||||
# From Paul Eggert (2013-07-03):
|
||||
# To estimate what the Moroccan government will do in future years,
|
||||
# transition dates for 2013 through 2021 were determined by running
|
||||
# transition dates for 2014 through 2021 were determined by running
|
||||
# the following program under GNU Emacs 24.3:
|
||||
#
|
||||
# (let ((islamic-year 1434))
|
||||
# (let ((islamic-year 1435))
|
||||
# (while (< islamic-year 1444)
|
||||
# (let ((a
|
||||
# (calendar-gregorian-from-absolute
|
||||
@ -910,8 +916,8 @@ Rule Morocco 2012 2019 - Apr lastSun 2:00 1:00 S
|
||||
Rule Morocco 2012 max - Sep lastSun 3:00 0 -
|
||||
Rule Morocco 2012 only - Jul 20 3:00 0 -
|
||||
Rule Morocco 2012 only - Aug 20 2:00 1:00 S
|
||||
Rule Morocco 2013 only - Jul 9 3:00 0 -
|
||||
Rule Morocco 2013 only - Aug 8 2:00 1:00 S
|
||||
Rule Morocco 2013 only - Jul 7 3:00 0 -
|
||||
Rule Morocco 2013 only - Aug 10 2:00 1:00 S
|
||||
Rule Morocco 2014 only - Jun 29 3:00 0 -
|
||||
Rule Morocco 2014 only - Jul 29 2:00 1:00 S
|
||||
Rule Morocco 2015 only - Jun 18 3:00 0 -
|
||||
|
@ -1212,39 +1212,21 @@ Rule Zion 2011 only - Oct 2 2:00 0 S
|
||||
Rule Zion 2012 only - Mar Fri>=26 2:00 1:00 D
|
||||
Rule Zion 2012 only - Sep 23 2:00 0 S
|
||||
|
||||
# From Ephraim Silverberg (2012-10-18):
|
||||
# Yesterday, the Interior Ministry Committee, after more than a year
|
||||
# past, approved sending the proposed June 2011 changes to the Time
|
||||
# Decree Law back to the Knesset for second and third (final) votes
|
||||
# before the upcoming elections on Jan. 22, 2013. Hence, although the
|
||||
# changes are not yet law, they are expected to be so before February 2013.
|
||||
# From Ephraim Silverberg (2013-06-27):
|
||||
# On June 23, 2013, the Israeli government approved changes to the
|
||||
# Time Decree Law. The next day, the changes passed the First Reading
|
||||
# in the Knesset. The law is expected to pass the Second and Third
|
||||
# (final) Readings by the beginning of September 2013.
|
||||
#
|
||||
# As of 2013, DST starts at 02:00 on the Friday before the last Sunday in March.
|
||||
# DST ends at 02:00 on the first Sunday after October 1, unless it occurs on the
|
||||
# second day of the Jewish Rosh Hashana holiday, in which case DST ends a day
|
||||
# later (i.e. at 02:00 the first Monday after October 2).
|
||||
# [Rosh Hashana holidays are factored in until 2100.]
|
||||
|
||||
# From Ephraim Silverberg (2012-11-05):
|
||||
# The Knesset passed today (in second and final readings) the amendment to the
|
||||
# Time Decree Law making the changes ... law.
|
||||
# As of 2013, DST starts at 02:00 on the Friday before the last Sunday
|
||||
# in March. DST ends at 02:00 on the last Sunday of October.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Zion 2013 max - Mar Fri>=23 2:00 1:00 D
|
||||
Rule Zion 2013 2026 - Oct Sun>=2 2:00 0 S
|
||||
Rule Zion 2027 only - Oct Mon>=3 2:00 0 S
|
||||
Rule Zion 2028 max - Oct Sun>=2 2:00 0 S
|
||||
# The following rules are commented out for now, as they break older
|
||||
# versions of zic that support only signed 32-bit timestamps, i.e.,
|
||||
# through 2038-01-19 03:14:07 UTC.
|
||||
#Rule Zion 2028 2053 - Oct Sun>=2 2:00 0 S
|
||||
#Rule Zion 2054 only - Oct Mon>=3 2:00 0 S
|
||||
#Rule Zion 2055 2080 - Oct Sun>=2 2:00 0 S
|
||||
#Rule Zion 2081 only - Oct Mon>=3 2:00 0 S
|
||||
#Rule Zion 2082 max - Oct Sun>=2 2:00 0 S
|
||||
Rule Zion 2013 max - Oct lastSun 2:00 0 S
|
||||
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Asia/Jerusalem 2:20:56 - LMT 1880
|
||||
Zone Asia/Jerusalem 2:20:54 - LMT 1880
|
||||
2:20:40 - JMT 1918 # Jerusalem Mean Time?
|
||||
2:00 Zion I%sT
|
||||
|
||||
@ -2547,8 +2529,8 @@ Rule Syria 2006 only - Sep 22 0:00 0 -
|
||||
Rule Syria 2007 only - Mar lastFri 0:00 1:00 S
|
||||
# From Jesper Norgard (2007-10-27):
|
||||
# The sister center ICARDA of my work CIMMYT is confirming that Syria DST will
|
||||
# not take place 1.st November at 0:00 o'clock but 1.st November at 24:00 or
|
||||
# rather Midnight between Thursday and Friday. This does make more sence than
|
||||
# not take place 1st November at 0:00 o'clock but 1st November at 24:00 or
|
||||
# rather Midnight between Thursday and Friday. This does make more sense than
|
||||
# having it between Wednesday and Thursday (two workdays in Syria) since the
|
||||
# weekend in Syria is not Saturday and Sunday, but Friday and Saturday. So now
|
||||
# it is implemented at midnight of the last workday before weekend...
|
||||
|
@ -230,10 +230,16 @@ Zone Australia/Lord_Howe 10:36:20 - LMT 1895 Feb
|
||||
# - Macquarie Island will stay on UTC+11 for winter and therefore not
|
||||
# switch back from daylight savings time when other parts of Australia do
|
||||
# on 4 April.
|
||||
#
|
||||
# From Arthur David Olson (2013-05-23):
|
||||
# The 1919 transition is overspecified below so pre-2013 zics
|
||||
# will produce a binary file with an EST-type as the first 32-bit type;
|
||||
# this is required for correct handling of times before 1916 by
|
||||
# pre-2013 versions of localtime.
|
||||
Zone Antarctica/Macquarie 0 - zzz 1899 Nov
|
||||
10:00 - EST 1916 Oct 1 2:00
|
||||
10:00 1:00 EST 1917 Feb
|
||||
10:00 Aus EST 1919 Apr
|
||||
10:00 Aus EST 1919 Apr 1 0:00s
|
||||
0 - zzz 1948 Mar 25
|
||||
10:00 Aus EST 1967
|
||||
10:00 AT EST 2010 Apr 4 3:00
|
||||
@ -1475,12 +1481,12 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
|
||||
# From Paul Eggert (2000-01-08):
|
||||
# IATA SSIM (1999-09) says DST ends 0100 local time. Go with McDow.
|
||||
|
||||
# From the BBC World Service (1998-10-31 11:32 UTC):
|
||||
# From the BBC World Service in
|
||||
# http://news.bbc.co.uk/2/hi/asia-pacific/205226.stm (1998-10-31 16:03 UTC):
|
||||
# The Fijiian government says the main reasons for the time change is to
|
||||
# improve productivity and reduce road accidents. But correspondents say it
|
||||
# also hopes the move will boost Fiji's ability to compete with other pacific
|
||||
# islands in the effort to attract tourists to witness the dawning of the new
|
||||
# millenium.
|
||||
# improve productivity and reduce road accidents.... [T]he move is also
|
||||
# intended to boost Fiji's ability to attract tourists to witness the dawning
|
||||
# of the new millennium.
|
||||
|
||||
# http://www.fiji.gov.fj/press/2000_09/2000_09_13-05.shtml (2000-09-13)
|
||||
# reports that Fiji has discontinued DST.
|
||||
@ -1625,7 +1631,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
|
||||
# Shanks & Pottenger say the transition was on 1968-10-01; go with Mundell.
|
||||
|
||||
# From Eric Ulevik (1999-05-03):
|
||||
# Tonga's director of tourism, who is also secretary of the National Millenium
|
||||
# Tonga's director of tourism, who is also secretary of the National Millennium
|
||||
# Committee, has a plan to get Tonga back in front.
|
||||
# He has proposed a one-off move to tropical daylight saving for Tonga from
|
||||
# October to March, which has won approval in principle from the Tongan
|
||||
|
@ -523,7 +523,7 @@ Rule C-Eur 1944 only - Oct 2 2:00s 0 -
|
||||
# It seems that Paris, Monaco, Rule France, Rule Belgium all agree on
|
||||
# 2:00 standard time, e.g. 3:00 local time. However there are no
|
||||
# countries that use C-Eur rules in September 1945, so the only items
|
||||
# affected are apparently these ficticious zones that translates acronyms
|
||||
# affected are apparently these fictitious zones that translate acronyms
|
||||
# CET and MET:
|
||||
#
|
||||
# Zone CET 1:00 C-Eur CE%sT
|
||||
@ -2779,9 +2779,9 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents.
|
||||
|
||||
# Ukraine
|
||||
#
|
||||
# From Igor Karpov, who works for the Ukranian Ministry of Justice,
|
||||
# From Igor Karpov, who works for the Ukrainian Ministry of Justice,
|
||||
# via Garrett Wollman (2003-01-27):
|
||||
# BTW, I've found the official document on this matter. It's goverment
|
||||
# BTW, I've found the official document on this matter. It's government
|
||||
# regulations number 509, May 13, 1996. In my poor translation it says:
|
||||
# "Time in Ukraine is set to second timezone (Kiev time). Each last Sunday
|
||||
# of March at 3am the time is changing to 4am and each last Sunday of
|
||||
@ -2815,7 +2815,7 @@ Link Europe/Istanbul Asia/Istanbul # Istanbul is in both continents.
|
||||
# time this year after all.
|
||||
#
|
||||
# From Udo Schwedt (2011-10-18):
|
||||
# As far as I understand, the recent change to the Ukranian time zone
|
||||
# As far as I understand, the recent change to the Ukrainian time zone
|
||||
# (Europe/Kiev) to introduce permanent daylight saving time (similar
|
||||
# to Russia) was reverted today:
|
||||
#
|
||||
|
@ -971,7 +971,7 @@ Rule Brazil 2007 only - Feb 25 0:00 0 -
|
||||
# adopted by the same states as before.
|
||||
Rule Brazil 2007 only - Oct Sun>=8 0:00 1:00 S
|
||||
# From Frederico A. C. Neves (2008-09-10):
|
||||
# Acording to this decree
|
||||
# According to this decree
|
||||
# <a href="http://www.planalto.gov.br/ccivil_03/_Ato2007-2010/2008/Decreto/D6558.htm">
|
||||
# http://www.planalto.gov.br/ccivil_03/_Ato2007-2010/2008/Decreto/D6558.htm
|
||||
# </a>
|
||||
@ -1203,7 +1203,7 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914
|
||||
# http://www.emol.com/noticias/nacional/detalle/detallenoticias.asp?idnoticia=467651
|
||||
# </a>
|
||||
#
|
||||
# This is not yet reflected in the offical "cambio de hora" site, but
|
||||
# This is not yet reflected in the official "cambio de hora" site, but
|
||||
# probably will be soon:
|
||||
# <a href="http://www.horaoficial.cl/cambio.htm">
|
||||
# http://www.horaoficial.cl/cambio.htm
|
||||
|
@ -1,18 +1,21 @@
|
||||
# <pre>
|
||||
# TZ zone descriptions
|
||||
#
|
||||
# This file is in the public domain, so clarified as of
|
||||
# 2009-05-17 by Arthur David Olson.
|
||||
#
|
||||
# TZ zone descriptions
|
||||
#
|
||||
# From Paul Eggert (1996-08-05):
|
||||
# From Paul Eggert (2013-05-27):
|
||||
#
|
||||
# This file contains a table with the following columns:
|
||||
# 1. ISO 3166 2-character country code. See /usr/share/misc/iso3166.
|
||||
# This identifies a country that overlaps the zone. The country may
|
||||
# overlap other zones and the zone may overlap other countries.
|
||||
# 2. Latitude and longitude of the zone's principal location
|
||||
# in ISO 6709 sign-degrees-minutes-seconds format,
|
||||
# either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
|
||||
# first latitude (+ is north), then longitude (+ is east).
|
||||
# This location need not lie within the column-1 country.
|
||||
# 3. Zone name used in value of TZ environment variable.
|
||||
# Please see the 'Theory' file for how zone names are chosen.
|
||||
# 4. Comments; present if and only if the country has multiple rows.
|
||||
#
|
||||
# Columns are separated by a single tab.
|
||||
@ -22,6 +25,10 @@
|
||||
#
|
||||
# Lines beginning with `#' are comments.
|
||||
#
|
||||
# This table is intended as an aid for users, to help them select time
|
||||
# zone data appropriate for their practical needs. It is not intended
|
||||
# to take or endorse any position on legal or territorial claims.
|
||||
#
|
||||
#country-
|
||||
#code coordinates TZ comments
|
||||
AD +4230+00131 Europe/Andorra
|
||||
@ -216,7 +223,7 @@ ID -0002+10920 Asia/Pontianak west & central Borneo
|
||||
ID -0507+11924 Asia/Makassar east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor
|
||||
ID -0232+14042 Asia/Jayapura west New Guinea (Irian Jaya) & Malukus (Moluccas)
|
||||
IE +5320-00615 Europe/Dublin
|
||||
IL +3146+03514 Asia/Jerusalem
|
||||
IL +314650+0351326 Asia/Jerusalem
|
||||
IM +5409-00428 Europe/Isle_of_Man
|
||||
IN +2232+08822 Asia/Kolkata
|
||||
IO -0720+07225 Indian/Chagos
|
||||
|
@ -1348,7 +1348,7 @@ static void wpa_supplicant_process_1_of_2(struct wpa_sm *sm,
|
||||
goto failed;
|
||||
|
||||
if (rekey) {
|
||||
wpa_msg(sm->ctx->msg_ctx, MSG_INFO, "WPA: Group rekeying "
|
||||
wpa_msg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Group rekeying "
|
||||
"completed with " MACSTR " [GTK=%s]",
|
||||
MAC2STR(sm->bssid), wpa_cipher_txt(sm->group_cipher));
|
||||
wpa_sm_cancel_auth_timeout(sm);
|
||||
|
@ -1052,16 +1052,12 @@ ifalias_af_common()
|
||||
#
|
||||
ipv6_prefix_hostid_addr_common()
|
||||
{
|
||||
local _if _action prefix laddr hostid j address
|
||||
local _if _action prefix j
|
||||
_if=$1
|
||||
_action=$2
|
||||
prefix=`get_if_var ${_if} ipv6_prefix_IF`
|
||||
|
||||
if [ -n "${prefix}" ]; then
|
||||
laddr=`network6_getladdr ${_if}`
|
||||
hostid=${laddr#fe80::}
|
||||
hostid=${hostid%\%*}
|
||||
|
||||
for j in ${prefix}; do
|
||||
# The default prefixlen is 64.
|
||||
plen=${j#*/}
|
||||
@ -1071,18 +1067,10 @@ ipv6_prefix_hostid_addr_common()
|
||||
esac
|
||||
|
||||
# Normalize the last part by removing ":"
|
||||
j=${j%:*}
|
||||
j=${j%::*}
|
||||
j=${j%:}
|
||||
OIFS=$IFS; IFS=":"; set -- $j; nj=$#; IFS=$OIFS
|
||||
OIFS=$IFS; IFS=":"; set -- $hostid; nh=$#; IFS=$OIFS
|
||||
if [ $(($nj + $nh)) -eq 8 ]; then
|
||||
address=$j\:$hostid
|
||||
else
|
||||
address=$j\::$hostid
|
||||
fi
|
||||
|
||||
${IFCONFIG_CMD} ${_if} inet6 ${address} \
|
||||
prefixlen $plen ${_action}
|
||||
${IFCONFIG_CMD} ${_if} inet6 $j:: \
|
||||
prefixlen $plen eui64 ${_action}
|
||||
|
||||
# if I am a router, add subnet router
|
||||
# anycast address (RFC 2373).
|
||||
|
@ -42,7 +42,7 @@ pfsync_start()
|
||||
pfsync_stop()
|
||||
{
|
||||
echo "Disabling pfsync."
|
||||
ifconfig pfsync0 -syncdev down
|
||||
ifconfig pfsync0 -syncdev -syncpeer down
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
|
@ -23,7 +23,7 @@ zfs_start_jail()
|
||||
|
||||
zfs_start_main()
|
||||
{
|
||||
zfs mount -a
|
||||
zfs mount -va
|
||||
zfs share -a
|
||||
if [ ! -r /etc/zfs/exports ]; then
|
||||
touch /etc/zfs/exports
|
||||
|
@ -161,14 +161,16 @@ _Noreturn void
|
||||
quick_exit(int);
|
||||
#endif /* __ISO_C_VISIBLE >= 2011 */
|
||||
/*
|
||||
* Extensions made by POSIX relative to C. We don't know yet which edition
|
||||
* of POSIX made these extensions, so assume they've always been there until
|
||||
* research can be done.
|
||||
* Extensions made by POSIX relative to C.
|
||||
*/
|
||||
#if __POSIX_VISIBLE /* >= ??? */
|
||||
int posix_memalign(void **, size_t, size_t); /* (ADV) */
|
||||
int rand_r(unsigned *); /* (TSF) */
|
||||
#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
|
||||
char *realpath(const char * __restrict, char * __restrict);
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 199506
|
||||
int rand_r(unsigned *); /* (TSF) */
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200112
|
||||
int posix_memalign(void **, size_t, size_t); /* (ADV) */
|
||||
int setenv(const char *, const char *, int);
|
||||
int unsetenv(const char *);
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd February 11, 2012
|
||||
.Dd May 17, 2013
|
||||
.Dt SYSCTL 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -547,14 +547,14 @@ The length of each message is contained in the message header.
|
||||
The third level name is a protocol number, which is currently always 0.
|
||||
The fourth level name is an address family, which may be set to 0 to
|
||||
select all address families.
|
||||
The fifth and sixth level names are as follows:
|
||||
.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
|
||||
.It Sy "Fifth level name Sixth level is:"
|
||||
.It "NET_RT_FLAGS rtflags"
|
||||
.It "NET_RT_DUMP None"
|
||||
.It "NET_RT_IFLIST 0 or if_index"
|
||||
.It "NET_RT_IFMALIST 0 or if_index"
|
||||
.It "NET_RT_IFLISTL 0 or if_index"
|
||||
The fifth, sixth, and seventh level names are as follows:
|
||||
.Bl -column -offset indent "Fifth level Sixth level" "Seventh level"
|
||||
.It Sy "Fifth level Sixth level" Ta Sy "Seventh level"
|
||||
.It "NET_RT_FLAGS rtflags" Ta "None"
|
||||
.It "NET_RT_DUMP None" Ta "None or fib number"
|
||||
.It "NET_RT_IFLIST 0 or if_index" Ta None
|
||||
.It "NET_RT_IFMALIST 0 or if_index" Ta None
|
||||
.It "NET_RT_IFLISTL 0 or if_index" Ta None
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
|
@ -255,7 +255,7 @@ member points to a filled-in socket address structure of length
|
||||
This implementation of
|
||||
.Fn getaddrinfo
|
||||
allows numeric IPv6 address notation with scope identifier,
|
||||
as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt.
|
||||
as documented in chapter 11 of RFC 4007.
|
||||
By appending the percent character and scope identifier to addresses,
|
||||
one can fill the
|
||||
.Li sin6_scope_id
|
||||
@ -441,9 +441,8 @@ freeaddrinfo(res0);
|
||||
.%A E. Nordmark
|
||||
.%A B. Zill
|
||||
.%T "IPv6 Scoped Address Architecture"
|
||||
.%R internet draft
|
||||
.%N draft-ietf-ipv6-scoping-arch-02.txt
|
||||
.%O work in progress material
|
||||
.%R RFC 4007
|
||||
.%D March 2005
|
||||
.Re
|
||||
.Rs
|
||||
.%A Craig Metz
|
||||
|
@ -191,10 +191,11 @@ printf("host=%s\en", hbuf);
|
||||
.%A R. Gilligan
|
||||
.%A S. Thomson
|
||||
.%A J. Bound
|
||||
.%A J. McCann
|
||||
.%A W. Stevens
|
||||
.%T Basic Socket Interface Extensions for IPv6
|
||||
.%R RFC 2553
|
||||
.%D March 1999
|
||||
.%R RFC 3493
|
||||
.%D February 2003
|
||||
.Re
|
||||
.Rs
|
||||
.%A S. Deering
|
||||
@ -203,9 +204,8 @@ printf("host=%s\en", hbuf);
|
||||
.%A E. Nordmark
|
||||
.%A B. Zill
|
||||
.%T "IPv6 Scoped Address Architecture"
|
||||
.%R internet draft
|
||||
.%N draft-ietf-ipv6-scoping-arch-02.txt
|
||||
.%O work in progress material
|
||||
.%R RFC 4007
|
||||
.%D March 2005
|
||||
.Re
|
||||
.Rs
|
||||
.%A Craig Metz
|
||||
@ -217,9 +217,9 @@ printf("host=%s\en", hbuf);
|
||||
The
|
||||
.Fn getnameinfo
|
||||
function is defined by the
|
||||
.St -p1003.1g-2000
|
||||
draft specification and documented in
|
||||
.Tn "RFC 2553" ,
|
||||
.St -p1003.1-2004
|
||||
specification and documented in
|
||||
.Tn "RFC 3493" ,
|
||||
.Dq Basic Socket Interface Extensions for IPv6 .
|
||||
.Sh CAVEATS
|
||||
.Fn getnameinfo
|
||||
|
@ -274,6 +274,11 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size)
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
if ((id == SCTP_CURRENT_ASSOC) ||
|
||||
(id == SCTP_ALL_ASSOC)) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
switch (opt) {
|
||||
case SCTP_RTOINFO:
|
||||
((struct sctp_rtoinfo *)arg)->srto_assoc_id = id;
|
||||
@ -338,6 +343,9 @@ sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t * size)
|
||||
case SCTP_MAX_BURST:
|
||||
((struct sctp_assoc_value *)arg)->assoc_id = id;
|
||||
break;
|
||||
case SCTP_ENABLE_STREAM_RESET:
|
||||
((struct sctp_assoc_value *)arg)->assoc_id = id;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -54,12 +54,12 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
|
||||
|
||||
mc = &ucp->uc_mcontext;
|
||||
if (ucp == NULL ||
|
||||
(mc->mc_flags & ((1L << _MC_VERSION_BITS) - 1)) != _MC_VERSION)
|
||||
(mc->_mc_flags & ((1L << _MC_VERSION_BITS) - 1)) != _MC_VERSION)
|
||||
return;
|
||||
if ((argc < 0) || (argc > 6) ||
|
||||
(ucp->uc_stack.ss_sp == NULL) ||
|
||||
(ucp->uc_stack.ss_size < MINSIGSTKSZ)) {
|
||||
mc->mc_flags = 0;
|
||||
mc->_mc_flags = 0;
|
||||
return;
|
||||
}
|
||||
mc = &ucp->uc_mcontext;
|
||||
@ -71,8 +71,8 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
|
||||
mc->mc_global[1] = (uint64_t)start;
|
||||
mc->mc_global[2] = (uint64_t)ucp;
|
||||
mc->mc_out[6] = sp - SPOFF - sizeof(struct frame);
|
||||
mc->mc_tnpc = (uint64_t)_ctx_start + 4;
|
||||
mc->mc_tpc = (uint64_t)_ctx_start;
|
||||
mc->_mc_tnpc = (uint64_t)_ctx_start + 4;
|
||||
mc->_mc_tpc = (uint64_t)_ctx_start;
|
||||
}
|
||||
|
||||
void
|
||||
@ -82,7 +82,7 @@ _ctx_done(ucontext_t *ucp)
|
||||
if (ucp->uc_link == NULL)
|
||||
exit(0);
|
||||
else {
|
||||
ucp->uc_mcontext.mc_flags = 0;
|
||||
ucp->uc_mcontext._mc_flags = 0;
|
||||
setcontext((const ucontext_t *)ucp->uc_link);
|
||||
abort();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ __signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func)
|
||||
mcontext_t *mc;
|
||||
|
||||
mc = &ucp->uc_mcontext;
|
||||
sfp = (struct sigframe *)(mc->mc_sp + SPOFF) - 1;
|
||||
sfp = (struct sigframe *)(mc->_mc_sp + SPOFF) - 1;
|
||||
fp = (struct frame *)sfp - 1;
|
||||
|
||||
bzero(fp, sizeof(*fp));
|
||||
@ -67,8 +67,8 @@ __signalcontext(ucontext_t *ucp, int sig, __sighandler_t *func)
|
||||
mc->mc_out[1] = (uint64_t)&sfp->sf_si;
|
||||
mc->mc_out[2] = (uint64_t)&sfp->sf_uc;
|
||||
mc->mc_out[6] = (uint64_t)fp - SPOFF;
|
||||
mc->mc_tnpc = (uint64_t)_ctx_start + 4;
|
||||
mc->mc_tpc = (uint64_t)_ctx_start;
|
||||
mc->_mc_tnpc = (uint64_t)_ctx_start + 4;
|
||||
mc->_mc_tpc = (uint64_t)_ctx_start;
|
||||
|
||||
ucp->uc_link = &sfp->sf_uc;
|
||||
sigdelset(&ucp->uc_sigmask, sig);
|
||||
|
@ -65,7 +65,7 @@ fwrite(const void * __restrict buf, size_t size, size_t count, FILE * __restrict
|
||||
/*
|
||||
* Check for integer overflow. As an optimization, first check that
|
||||
* at least one of {count, size} is at least 2^16, since if both
|
||||
* values are less than that, their product can't possible overflow
|
||||
* values are less than that, their product can't possibly overflow
|
||||
* (size_t is always at least 32 bits on FreeBSD).
|
||||
*/
|
||||
if (((count | size) > 0xFFFF) &&
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" @(#)mktemp.3 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 4, 2012
|
||||
.Dd July 5, 2013
|
||||
.Dt MKTEMP 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -37,15 +37,16 @@
|
||||
.Sh LIBRARY
|
||||
.Lb libc
|
||||
.Sh SYNOPSIS
|
||||
.In unistd.h
|
||||
.In stdlib.h
|
||||
.Ft char *
|
||||
.Fn mktemp "char *template"
|
||||
.Ft int
|
||||
.Fn mkstemp "char *template"
|
||||
.Ft int
|
||||
.Fn mkstemps "char *template" "int suffixlen"
|
||||
.Ft char *
|
||||
.Fn mkdtemp "char *template"
|
||||
.In unistd.h
|
||||
.Ft int
|
||||
.Fn mkstemps "char *template" "int suffixlen"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn mktemp
|
||||
@ -180,12 +181,36 @@ with an argument of
|
||||
will result in a core dump due to
|
||||
.Fn mkstemp
|
||||
attempting to modify the string constant that was given.
|
||||
.Pp
|
||||
The
|
||||
.Fn mkdtemp ,
|
||||
.Fn mkstemp
|
||||
and
|
||||
.Fn mktemp
|
||||
function prototypes are also available from
|
||||
.In unistd.h .
|
||||
.Sh SEE ALSO
|
||||
.Xr chmod 2 ,
|
||||
.Xr getpid 2 ,
|
||||
.Xr mkdir 2 ,
|
||||
.Xr open 2 ,
|
||||
.Xr stat 2
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn mkstemp
|
||||
and
|
||||
.Fn mkdtemp
|
||||
functions are expected to conform to
|
||||
.St -p1003.1-2008 .
|
||||
The
|
||||
.Fn mktemp
|
||||
function is expected to conform to
|
||||
.St -p1003.1-2001
|
||||
and is not specified by
|
||||
.St -p1003.1-2008 .
|
||||
The
|
||||
.Fn mkstemps
|
||||
function does not conform to any standard.
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Fn mktemp
|
||||
|
@ -505,9 +505,8 @@ __setenv(const char *name, size_t nameLen, const char *value, int overwrite)
|
||||
envVars[envNdx].valueSize = valueLen;
|
||||
|
||||
/* Save name of name/value pair. */
|
||||
env = stpcpy(envVars[envNdx].name, name);
|
||||
if ((envVars[envNdx].name)[nameLen] != '=')
|
||||
env = stpcpy(env, "=");
|
||||
env = stpncpy(envVars[envNdx].name, name, nameLen);
|
||||
*env++ = '=';
|
||||
}
|
||||
else
|
||||
env = envVars[envNdx].value;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
LIB= kvm
|
||||
SHLIBDIR?= /lib
|
||||
SHLIB_MAJOR= 6
|
||||
CFLAGS+=-DLIBC_SCCS -I${.CURDIR}
|
||||
|
||||
.if exists(${.CURDIR}/kvm_${MACHINE_ARCH}.c)
|
||||
|
@ -89,8 +89,6 @@ kvm_t *kvm_openfiles
|
||||
(const char *, const char *, const char *, int, char *);
|
||||
ssize_t kvm_read(kvm_t *, unsigned long, void *, size_t);
|
||||
ssize_t kvm_read_zpcpu(kvm_t *, void *, u_long, size_t, int);
|
||||
ssize_t kvm_uread
|
||||
(kvm_t *, const struct kinfo_proc *, unsigned long, char *, size_t);
|
||||
ssize_t kvm_write(kvm_t *, unsigned long, const void *, size_t);
|
||||
__END_DECLS
|
||||
|
||||
|
@ -57,9 +57,9 @@ pt_fpreg_to_ucontext(const struct fpreg* r, ucontext_t *uc)
|
||||
|
||||
memcpy(mc->mc_fp, r->fr_regs, MIN(sizeof(mc->mc_fp),
|
||||
sizeof(r->fr_regs)));
|
||||
mc->mc_fsr = r->fr_fsr;
|
||||
mc->mc_gsr = r->fr_gsr;
|
||||
mc->mc_fprs |= FPRS_FEF;
|
||||
mc->_mc_fsr = r->fr_fsr;
|
||||
mc->_mc_gsr = r->fr_gsr;
|
||||
mc->_mc_fprs |= FPRS_FEF;
|
||||
}
|
||||
|
||||
void
|
||||
@ -67,11 +67,11 @@ pt_ucontext_to_fpreg(const ucontext_t *uc, struct fpreg *r)
|
||||
{
|
||||
const mcontext_t *mc = &uc->uc_mcontext;
|
||||
|
||||
if ((mc->mc_fprs & FPRS_FEF) != 0) {
|
||||
if ((mc->_mc_fprs & FPRS_FEF) != 0) {
|
||||
memcpy(r->fr_regs, mc->mc_fp, MIN(sizeof(mc->mc_fp),
|
||||
sizeof(r->fr_regs)));
|
||||
r->fr_fsr = mc->mc_fsr;
|
||||
r->fr_gsr = mc->mc_gsr;
|
||||
r->fr_fsr = mc->_mc_fsr;
|
||||
r->fr_gsr = mc->_mc_gsr;
|
||||
} else
|
||||
memset(r, 0, sizeof(*r));
|
||||
}
|
||||
|
@ -15,11 +15,12 @@ INCS+= libusb20_desc.h
|
||||
MAN= libusb.3 libusb20.3
|
||||
MKLINT= no
|
||||
NOGCCERROR=
|
||||
PTHREAD_LIBS?= -lpthread
|
||||
|
||||
WARNS?= 2
|
||||
|
||||
DPADD= ${LIBPTHREAD}
|
||||
LDADD= -lpthread
|
||||
LDADD= ${PTHREAD_LIBS}
|
||||
|
||||
MLINKS+= libusb.3 usb.3
|
||||
|
||||
@ -42,7 +43,17 @@ CFLAGS+= -DCOMPAT_32BIT
|
||||
#
|
||||
# Examples:
|
||||
# make LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h
|
||||
# make COMPAT_32BIT=YES LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h
|
||||
# make COMPAT_32BIT=YES \
|
||||
# LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \
|
||||
# DEBUG_FLAGS="-g"
|
||||
#
|
||||
# From Ubuntu 10.04:
|
||||
# freebsd-make LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \
|
||||
# PTHREAD_LIBS="-lpthread -lrt"
|
||||
# freebsd-make COMPAT32_BIT=YES \
|
||||
# LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h \
|
||||
# PTHREAD_LIBS="-lpthread -lrt"
|
||||
#
|
||||
#
|
||||
.if defined(LIBUSB_GLOBAL_INCLUDE_FILE)
|
||||
CFLAGS+= -DLIBUSB_GLOBAL_INCLUDE_FILE=\"${LIBUSB_GLOBAL_INCLUDE_FILE}\"
|
||||
|
@ -1202,27 +1202,13 @@ libusb20_be_alloc(const struct libusb20_backend_methods *methods)
|
||||
struct libusb20_backend *
|
||||
libusb20_be_alloc_linux(void)
|
||||
{
|
||||
struct libusb20_backend *pbe;
|
||||
|
||||
#ifdef __linux__
|
||||
pbe = libusb20_be_alloc(&libusb20_linux_backend);
|
||||
#else
|
||||
pbe = NULL;
|
||||
#endif
|
||||
return (pbe);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
struct libusb20_backend *
|
||||
libusb20_be_alloc_ugen20(void)
|
||||
{
|
||||
struct libusb20_backend *pbe;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
pbe = libusb20_be_alloc(&libusb20_ugen20_backend);
|
||||
#else
|
||||
pbe = NULL;
|
||||
#endif
|
||||
return (pbe);
|
||||
return (libusb20_be_alloc(&libusb20_ugen20_backend));
|
||||
}
|
||||
|
||||
struct libusb20_backend *
|
||||
@ -1230,10 +1216,12 @@ libusb20_be_alloc_default(void)
|
||||
{
|
||||
struct libusb20_backend *pbe;
|
||||
|
||||
#ifdef __linux__
|
||||
pbe = libusb20_be_alloc_linux();
|
||||
if (pbe) {
|
||||
return (pbe);
|
||||
}
|
||||
#endif
|
||||
pbe = libusb20_be_alloc_ugen20();
|
||||
if (pbe) {
|
||||
return (pbe);
|
||||
|
@ -46,6 +46,10 @@
|
||||
#include "libusb20_desc.h"
|
||||
#include "libusb20_int.h"
|
||||
|
||||
#ifndef IOUSB
|
||||
#define IOUSB(a) a
|
||||
#endif
|
||||
|
||||
static libusb20_init_backend_t ugen20_init_backend;
|
||||
static libusb20_open_device_t ugen20_open_device;
|
||||
static libusb20_close_device_t ugen20_close_device;
|
||||
@ -145,14 +149,14 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
|
||||
if (f < 0) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
if (ioctl(f, USB_GET_PLUGTIME, &plugtime)) {
|
||||
if (ioctl(f, IOUSB(USB_GET_PLUGTIME), &plugtime)) {
|
||||
error = LIBUSB20_ERROR_OTHER;
|
||||
goto done;
|
||||
}
|
||||
/* store when the device was plugged */
|
||||
pdev->session_data.plugtime = plugtime;
|
||||
|
||||
if (ioctl(f, USB_GET_DEVICE_DESC, &ddesc)) {
|
||||
if (ioctl(f, IOUSB(USB_GET_DEVICE_DESC), &ddesc)) {
|
||||
error = LIBUSB20_ERROR_OTHER;
|
||||
goto done;
|
||||
}
|
||||
@ -167,7 +171,7 @@ ugen20_enumerate(struct libusb20_device *pdev, const char *id)
|
||||
error = LIBUSB20_ERROR_OTHER;
|
||||
goto done;
|
||||
}
|
||||
if (ioctl(f, USB_GET_DEVICEINFO, &devinfo)) {
|
||||
if (ioctl(f, IOUSB(USB_GET_DEVICEINFO), &devinfo)) {
|
||||
error = LIBUSB20_ERROR_OTHER;
|
||||
goto done;
|
||||
}
|
||||
@ -241,7 +245,7 @@ repeat:
|
||||
st->urd.urd_maxlen = sizeof(st->buf);
|
||||
st->nparsed = 0;
|
||||
|
||||
if (ioctl(st->f, USB_READ_DIR, &st->urd)) {
|
||||
if (ioctl(st->f, IOUSB(USB_READ_DIR), &st->urd)) {
|
||||
return (EINVAL);
|
||||
}
|
||||
st->ptr = st->buf;
|
||||
@ -313,7 +317,7 @@ ugen20_tr_release(struct libusb20_device *pdev)
|
||||
/* release all pending USB transfers */
|
||||
if (pdev->privBeData != NULL) {
|
||||
memset(&fs_uninit, 0, sizeof(fs_uninit));
|
||||
if (ioctl(pdev->file, USB_FS_UNINIT, &fs_uninit)) {
|
||||
if (ioctl(pdev->file, IOUSB(USB_FS_UNINIT), &fs_uninit)) {
|
||||
/* ignore any errors of this kind */
|
||||
}
|
||||
}
|
||||
@ -353,7 +357,7 @@ ugen20_tr_renew(struct libusb20_device *pdev)
|
||||
fs_init.pEndpoints = libusb20_pass_ptr(pdev->privBeData);
|
||||
fs_init.ep_index_max = nMaxTransfer;
|
||||
|
||||
if (ioctl(pdev->file, USB_FS_INIT, &fs_init)) {
|
||||
if (ioctl(pdev->file, IOUSB(USB_FS_INIT), &fs_init)) {
|
||||
error = LIBUSB20_ERROR_OTHER;
|
||||
goto done;
|
||||
}
|
||||
@ -387,7 +391,7 @@ ugen20_open_device(struct libusb20_device *pdev, uint16_t nMaxTransfer)
|
||||
close(g);
|
||||
return (LIBUSB20_ERROR_NO_DEVICE);
|
||||
}
|
||||
if (ioctl(f, USB_GET_PLUGTIME, &plugtime)) {
|
||||
if (ioctl(f, IOUSB(USB_GET_PLUGTIME), &plugtime)) {
|
||||
error = LIBUSB20_ERROR_OTHER;
|
||||
goto done;
|
||||
}
|
||||
@ -430,7 +434,7 @@ ugen20_close_device(struct libusb20_device *pdev)
|
||||
|
||||
if (pdev->privBeData) {
|
||||
memset(&fs_uninit, 0, sizeof(fs_uninit));
|
||||
if (ioctl(pdev->file, USB_FS_UNINIT, &fs_uninit)) {
|
||||
if (ioctl(pdev->file, IOUSB(USB_FS_UNINIT), &fs_uninit)) {
|
||||
/* ignore this error */
|
||||
}
|
||||
free(pdev->privBeData);
|
||||
@ -468,7 +472,7 @@ ugen20_get_config_desc_full(struct libusb20_device *pdev,
|
||||
gen_desc.ugd_maxlen = sizeof(cdesc);
|
||||
gen_desc.ugd_config_index = cfg_index;
|
||||
|
||||
error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
|
||||
error = ioctl(pdev->file_ctrl, IOUSB(USB_GET_FULL_DESC), &gen_desc);
|
||||
if (error) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
@ -488,7 +492,7 @@ ugen20_get_config_desc_full(struct libusb20_device *pdev,
|
||||
gen_desc.ugd_data = libusb20_pass_ptr(ptr);
|
||||
gen_desc.ugd_maxlen = len;
|
||||
|
||||
error = ioctl(pdev->file_ctrl, USB_GET_FULL_DESC, &gen_desc);
|
||||
error = ioctl(pdev->file_ctrl, IOUSB(USB_GET_FULL_DESC), &gen_desc);
|
||||
if (error) {
|
||||
free(ptr);
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
@ -507,7 +511,7 @@ ugen20_get_config_index(struct libusb20_device *pdev, uint8_t *pindex)
|
||||
{
|
||||
int temp;
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_GET_CONFIG, &temp)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_CONFIG), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
*pindex = temp;
|
||||
@ -523,7 +527,7 @@ ugen20_set_config_index(struct libusb20_device *pdev, uint8_t cfg_index)
|
||||
/* release all active USB transfers */
|
||||
ugen20_tr_release(pdev);
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_SET_CONFIG, &temp)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_SET_CONFIG), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
return (ugen20_tr_renew(pdev));
|
||||
@ -543,7 +547,7 @@ ugen20_set_alt_index(struct libusb20_device *pdev,
|
||||
/* release all active USB transfers */
|
||||
ugen20_tr_release(pdev);
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_SET_ALTINTERFACE, &alt_iface)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_SET_ALTINTERFACE), &alt_iface)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
return (ugen20_tr_renew(pdev));
|
||||
@ -557,7 +561,7 @@ ugen20_reset_device(struct libusb20_device *pdev)
|
||||
/* release all active USB transfers */
|
||||
ugen20_tr_release(pdev);
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_DEVICEENUMERATE, &temp)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_DEVICEENUMERATE), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
return (ugen20_tr_renew(pdev));
|
||||
@ -569,7 +573,7 @@ ugen20_check_connected(struct libusb20_device *pdev)
|
||||
uint32_t plugtime;
|
||||
int error = 0;
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_GET_PLUGTIME, &plugtime)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_PLUGTIME), &plugtime)) {
|
||||
error = LIBUSB20_ERROR_NO_DEVICE;
|
||||
goto done;
|
||||
}
|
||||
@ -606,7 +610,7 @@ ugen20_set_power_mode(struct libusb20_device *pdev, uint8_t power_mode)
|
||||
default:
|
||||
return (LIBUSB20_ERROR_INVALID_PARAM);
|
||||
}
|
||||
if (ioctl(pdev->file_ctrl, USB_SET_POWER_MODE, &temp)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_SET_POWER_MODE), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
return (0);
|
||||
@ -617,7 +621,7 @@ ugen20_get_power_mode(struct libusb20_device *pdev, uint8_t *power_mode)
|
||||
{
|
||||
int temp;
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_GET_POWER_MODE, &temp)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_POWER_MODE), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
switch (temp) {
|
||||
@ -649,7 +653,7 @@ ugen20_get_port_path(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize
|
||||
{
|
||||
struct usb_device_port_path udpp;
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_GET_DEV_PORT_PATH, &udpp))
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_DEV_PORT_PATH), &udpp))
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
|
||||
if (udpp.udp_port_level > bufsize)
|
||||
@ -665,7 +669,7 @@ ugen20_get_power_usage(struct libusb20_device *pdev, uint16_t *power_usage)
|
||||
{
|
||||
int temp;
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_GET_POWER_USAGE, &temp)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_POWER_USAGE), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
*power_usage = temp;
|
||||
@ -678,7 +682,7 @@ ugen20_kernel_driver_active(struct libusb20_device *pdev,
|
||||
{
|
||||
int temp = iface_index;
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_IFACE_DRIVER_ACTIVE, &temp)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_IFACE_DRIVER_ACTIVE), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
return (0); /* kernel driver is active */
|
||||
@ -690,7 +694,7 @@ ugen20_detach_kernel_driver(struct libusb20_device *pdev,
|
||||
{
|
||||
int temp = iface_index;
|
||||
|
||||
if (ioctl(pdev->file_ctrl, USB_IFACE_DRIVER_DETACH, &temp)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_IFACE_DRIVER_DETACH), &temp)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
return (0); /* kernel driver is active */
|
||||
@ -713,7 +717,7 @@ ugen20_do_request_sync(struct libusb20_device *pdev,
|
||||
sizeof(req.ucr_request), setup)) {
|
||||
/* ignore */
|
||||
}
|
||||
if (ioctl(pdev->file_ctrl, USB_DO_REQUEST, &req)) {
|
||||
if (ioctl(pdev->file_ctrl, IOUSB(USB_DO_REQUEST), &req)) {
|
||||
return (LIBUSB20_ERROR_OTHER);
|
||||
}
|
||||
if (pactlen) {
|
||||
@ -732,7 +736,7 @@ ugen20_process(struct libusb20_device *pdev)
|
||||
|
||||
while (1) {
|
||||
|
||||
if (ioctl(pdev->file, USB_FS_COMPLETE, &temp)) {
|
||||
if (ioctl(pdev->file, IOUSB(USB_FS_COMPLETE), &temp)) {
|
||||
if (errno == EBUSY) {
|
||||
break;
|
||||
} else {
|
||||
@ -800,10 +804,10 @@ ugen20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
|
||||
if (stream_id != 0) {
|
||||
temp.fs_open_stream.stream_id = stream_id;
|
||||
|
||||
if (ioctl(xfer->pdev->file, USB_FS_OPEN_STREAM, &temp.fs_open_stream))
|
||||
if (ioctl(xfer->pdev->file, IOUSB(USB_FS_OPEN_STREAM), &temp.fs_open_stream))
|
||||
return (LIBUSB20_ERROR_INVALID_PARAM);
|
||||
} else {
|
||||
if (ioctl(xfer->pdev->file, USB_FS_OPEN, &temp.fs_open))
|
||||
if (ioctl(xfer->pdev->file, IOUSB(USB_FS_OPEN), &temp.fs_open))
|
||||
return (LIBUSB20_ERROR_INVALID_PARAM);
|
||||
}
|
||||
/* maximums might have changed - update */
|
||||
@ -829,7 +833,7 @@ ugen20_tr_close(struct libusb20_transfer *xfer)
|
||||
|
||||
temp.ep_index = xfer->trIndex;
|
||||
|
||||
if (ioctl(xfer->pdev->file, USB_FS_CLOSE, &temp)) {
|
||||
if (ioctl(xfer->pdev->file, IOUSB(USB_FS_CLOSE), &temp)) {
|
||||
return (LIBUSB20_ERROR_INVALID_PARAM);
|
||||
}
|
||||
return (0); /* success */
|
||||
@ -846,7 +850,7 @@ ugen20_tr_clear_stall_sync(struct libusb20_transfer *xfer)
|
||||
|
||||
temp.ep_index = xfer->trIndex;
|
||||
|
||||
if (ioctl(xfer->pdev->file, USB_FS_CLEAR_STALL_SYNC, &temp)) {
|
||||
if (ioctl(xfer->pdev->file, IOUSB(USB_FS_CLEAR_STALL_SYNC), &temp)) {
|
||||
return (LIBUSB20_ERROR_INVALID_PARAM);
|
||||
}
|
||||
return (0); /* success */
|
||||
@ -885,7 +889,7 @@ ugen20_tr_submit(struct libusb20_transfer *xfer)
|
||||
|
||||
temp.ep_index = xfer->trIndex;
|
||||
|
||||
if (ioctl(xfer->pdev->file, USB_FS_START, &temp)) {
|
||||
if (ioctl(xfer->pdev->file, IOUSB(USB_FS_START), &temp)) {
|
||||
/* ignore any errors - should never happen */
|
||||
}
|
||||
return; /* success */
|
||||
@ -900,7 +904,7 @@ ugen20_tr_cancel_async(struct libusb20_transfer *xfer)
|
||||
|
||||
temp.ep_index = xfer->trIndex;
|
||||
|
||||
if (ioctl(xfer->pdev->file, USB_FS_STOP, &temp)) {
|
||||
if (ioctl(xfer->pdev->file, IOUSB(USB_FS_STOP), &temp)) {
|
||||
/* ignore any errors - should never happen */
|
||||
}
|
||||
return;
|
||||
@ -939,7 +943,7 @@ ugen20_dev_get_iface_desc(struct libusb20_device *pdev,
|
||||
ugd.ugd_maxlen = len;
|
||||
ugd.ugd_iface_index = iface_index;
|
||||
|
||||
if (ioctl(pdev->file, USB_GET_IFACE_DRIVER, &ugd)) {
|
||||
if (ioctl(pdev->file, IOUSB(USB_GET_IFACE_DRIVER), &ugd)) {
|
||||
return (LIBUSB20_ERROR_INVALID_PARAM);
|
||||
}
|
||||
return (0);
|
||||
@ -949,7 +953,7 @@ static int
|
||||
ugen20_dev_get_info(struct libusb20_device *pdev,
|
||||
struct usb_device_info *pinfo)
|
||||
{
|
||||
if (ioctl(pdev->file, USB_GET_DEVICEINFO, pinfo)) {
|
||||
if (ioctl(pdev->file, IOUSB(USB_GET_DEVICEINFO), pinfo)) {
|
||||
return (LIBUSB20_ERROR_INVALID_PARAM);
|
||||
}
|
||||
return (0);
|
||||
@ -966,7 +970,7 @@ ugen20_root_get_dev_quirk(struct libusb20_backend *pbe,
|
||||
|
||||
q.index = quirk_index;
|
||||
|
||||
error = ugen20_be_ioctl(USB_DEV_QUIRK_GET, &q);
|
||||
error = ugen20_be_ioctl(IOUSB(USB_DEV_QUIRK_GET), &q);
|
||||
|
||||
if (error) {
|
||||
if (errno == EINVAL) {
|
||||
@ -993,7 +997,7 @@ ugen20_root_get_quirk_name(struct libusb20_backend *pbe, uint16_t quirk_index,
|
||||
|
||||
q.index = quirk_index;
|
||||
|
||||
error = ugen20_be_ioctl(USB_QUIRK_NAME_GET, &q);
|
||||
error = ugen20_be_ioctl(IOUSB(USB_QUIRK_NAME_GET), &q);
|
||||
|
||||
if (error) {
|
||||
if (errno == EINVAL) {
|
||||
@ -1020,7 +1024,7 @@ ugen20_root_add_dev_quirk(struct libusb20_backend *pbe,
|
||||
q.bcdDeviceHigh = pq->bcdDeviceHigh;
|
||||
strlcpy(q.quirkname, pq->quirkname, sizeof(q.quirkname));
|
||||
|
||||
error = ugen20_be_ioctl(USB_DEV_QUIRK_ADD, &q);
|
||||
error = ugen20_be_ioctl(IOUSB(USB_DEV_QUIRK_ADD), &q);
|
||||
if (error) {
|
||||
if (errno == ENOMEM) {
|
||||
return (LIBUSB20_ERROR_NO_MEM);
|
||||
@ -1044,7 +1048,7 @@ ugen20_root_remove_dev_quirk(struct libusb20_backend *pbe,
|
||||
q.bcdDeviceHigh = pq->bcdDeviceHigh;
|
||||
strlcpy(q.quirkname, pq->quirkname, sizeof(q.quirkname));
|
||||
|
||||
error = ugen20_be_ioctl(USB_DEV_QUIRK_REMOVE, &q);
|
||||
error = ugen20_be_ioctl(IOUSB(USB_DEV_QUIRK_REMOVE), &q);
|
||||
if (error) {
|
||||
if (errno == EINVAL) {
|
||||
return (LIBUSB20_ERROR_NOT_FOUND);
|
||||
@ -1056,11 +1060,11 @@ ugen20_root_remove_dev_quirk(struct libusb20_backend *pbe,
|
||||
static int
|
||||
ugen20_root_set_template(struct libusb20_backend *pbe, int temp)
|
||||
{
|
||||
return (ugen20_be_ioctl(USB_SET_TEMPLATE, &temp));
|
||||
return (ugen20_be_ioctl(IOUSB(USB_SET_TEMPLATE), &temp));
|
||||
}
|
||||
|
||||
static int
|
||||
ugen20_root_get_template(struct libusb20_backend *pbe, int *ptemp)
|
||||
{
|
||||
return (ugen20_be_ioctl(USB_GET_TEMPLATE, ptemp));
|
||||
return (ugen20_be_ioctl(IOUSB(USB_GET_TEMPLATE), ptemp));
|
||||
}
|
||||
|
@ -29,7 +29,9 @@
|
||||
|
||||
#define _XOPEN_SOURCE
|
||||
#define _BSD_SOURCE
|
||||
#ifdef __linux__
|
||||
#define _POSIX_SOURCE
|
||||
#endif
|
||||
#define _POSIX_C_SOURCE 200809
|
||||
|
||||
#include <ctype.h>
|
||||
@ -39,10 +41,13 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __linux__
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <setjmp.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/ioctl.h>
|
||||
@ -51,6 +56,10 @@
|
||||
#include <dev/usb/usb_endian.h>
|
||||
#include <dev/usb/usb_freebsd.h>
|
||||
|
||||
#include <compat/linux/linux_ioctl.h>
|
||||
|
||||
#define IOUSB(a) FBSD_L##a
|
||||
|
||||
#ifndef __aligned
|
||||
#define __aligned(x) __attribute__((__aligned__(x)))
|
||||
#endif
|
||||
|
@ -80,27 +80,34 @@ extern const union __nan_un {
|
||||
#define FP_NORMAL 0x04
|
||||
#define FP_SUBNORMAL 0x08
|
||||
#define FP_ZERO 0x10
|
||||
#define fpclassify(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
|
||||
: __fpclassifyl(x))
|
||||
|
||||
#define isfinite(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __isfinite(x) \
|
||||
: __isfinitel(x))
|
||||
#define isinf(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isinff(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? isinf(x) \
|
||||
: __isinfl(x))
|
||||
#define isnan(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isnanf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? isnan(x) \
|
||||
: __isnanl(x))
|
||||
#define isnormal(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __isnormal(x) \
|
||||
: __isnormall(x))
|
||||
#if (__STDC_VERSION__ >= 201112L && defined(__clang__)) || \
|
||||
__has_extension(c_generic_selections)
|
||||
#define __fp_type_select(x, f, d, ld) _Generic((0,(x)), \
|
||||
float: f(x), \
|
||||
double: d(x), \
|
||||
long double: ld(x))
|
||||
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
|
||||
#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(__typeof(x), long double), ld(x), \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(__typeof(x), double), d(x), \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
|
||||
#else
|
||||
#define __fp_type_select(x, f, d, ld) \
|
||||
((sizeof(x) == sizeof(float)) ? f(x) \
|
||||
: (sizeof(x) == sizeof(double)) ? d(x) \
|
||||
: ld(x))
|
||||
#endif
|
||||
|
||||
#define fpclassify(x) \
|
||||
__fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyl)
|
||||
#define isfinite(x) __fp_type_select(x, __isfinitef, __isfinite, __isfinitel)
|
||||
#define isinf(x) __fp_type_select(x, __isinff, __isinf, __isinfl)
|
||||
#define isnan(x) \
|
||||
__fp_type_select(x, __inline_isnanf, __inline_isnan, __inline_isnanl)
|
||||
#define isnormal(x) __fp_type_select(x, __isnormalf, __isnormal, __isnormall)
|
||||
|
||||
#ifdef __MATH_BUILTIN_RELOPS
|
||||
#define isgreater(x, y) __builtin_isgreater((x), (y))
|
||||
@ -119,10 +126,7 @@ extern const union __nan_un {
|
||||
#define isunordered(x, y) (isnan(x) || isnan(y))
|
||||
#endif /* __MATH_BUILTIN_RELOPS */
|
||||
|
||||
#define signbit(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __signbitf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __signbit(x) \
|
||||
: __signbitl(x))
|
||||
#define signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl)
|
||||
|
||||
typedef __double_t double_t;
|
||||
typedef __float_t float_t;
|
||||
@ -175,9 +179,8 @@ int __isfinitef(float) __pure2;
|
||||
int __isfinite(double) __pure2;
|
||||
int __isfinitel(long double) __pure2;
|
||||
int __isinff(float) __pure2;
|
||||
int __isinf(double) __pure2;
|
||||
int __isinfl(long double) __pure2;
|
||||
int __isnanf(float) __pure2;
|
||||
int __isnanl(long double) __pure2;
|
||||
int __isnormalf(float) __pure2;
|
||||
int __isnormal(double) __pure2;
|
||||
int __isnormall(long double) __pure2;
|
||||
@ -185,6 +188,27 @@ int __signbit(double) __pure2;
|
||||
int __signbitf(float) __pure2;
|
||||
int __signbitl(long double) __pure2;
|
||||
|
||||
static __inline int
|
||||
__inline_isnan(__const double __x)
|
||||
{
|
||||
|
||||
return (__x != __x);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
__inline_isnanf(__const float __x)
|
||||
{
|
||||
|
||||
return (__x != __x);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
__inline_isnanl(__const long double __x)
|
||||
{
|
||||
|
||||
return (__x != __x);
|
||||
}
|
||||
|
||||
double acos(double);
|
||||
double asin(double);
|
||||
double atan(double);
|
||||
@ -227,8 +251,6 @@ double expm1(double);
|
||||
double fma(double, double, double);
|
||||
double hypot(double, double);
|
||||
int ilogb(double) __pure2;
|
||||
int (isinf)(double) __pure2;
|
||||
int (isnan)(double) __pure2;
|
||||
double lgamma(double);
|
||||
long long llrint(double);
|
||||
long long llround(double);
|
||||
|
@ -14,6 +14,9 @@ SRCBRANCH="base/head"
|
||||
DOCBRANCH="doc/head"
|
||||
PORTBRANCH="ports/head"
|
||||
|
||||
## Run svn co --force for src checkout.
|
||||
#SRC_FORCE_CHECKOUT=yes
|
||||
|
||||
## Set the src/, ports/, and doc/ revisions.
|
||||
SRCREVISION="-rHEAD"
|
||||
DOCREVISION="-rHEAD"
|
||||
@ -23,6 +26,8 @@ PORTREVISION="-rHEAD"
|
||||
#TARGET="amd64"
|
||||
#TARGET_ARCH="amd64"
|
||||
#KERNEL="GENERIC"
|
||||
## Multiple kernels may be set.
|
||||
#KERNEL="GENERIC XENHVM"
|
||||
|
||||
## Set to specify a custom make.conf and/or src.conf
|
||||
#MAKE_CONF="/etc/local/make.conf"
|
||||
|
@ -45,6 +45,10 @@ SRCBRANCH="base/head"
|
||||
DOCBRANCH="doc/head"
|
||||
PORTBRANCH="ports/head"
|
||||
|
||||
# Sometimes one needs to checkout src with --force svn option.
|
||||
# If custom kernel configs copied to src tree before checkout, e.g.
|
||||
SRC_FORCE_CHECKOUT=
|
||||
|
||||
# The default src/, doc/, and ports/ revisions.
|
||||
SRCREVISION="-rHEAD"
|
||||
DOCREVISION="-rHEAD"
|
||||
@ -109,6 +113,25 @@ while getopts c: opt; do
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
# If PORTS is set and NODOC is unset, force NODOC=yes because the ports tree
|
||||
# is required to build the documentation set.
|
||||
if [ "x${NOPORTS}" != "x" ] && [ "x${NODOC}" = "x" ]; then
|
||||
echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
|
||||
echo " and NOPORTS is set."
|
||||
NODOC=yes
|
||||
fi
|
||||
|
||||
# If NOPORTS and/or NODOC are unset, they must not pass to make as variables.
|
||||
# The release makefile verifies definedness of NOPORTS/NODOC variables
|
||||
# instead of their values.
|
||||
DOCPORTS=
|
||||
if [ "x${NOPORTS}" != "x" ]; then
|
||||
DOCPORTS="NOPORTS=yes "
|
||||
fi
|
||||
if [ "x${NODOC}" != "x" ]; then
|
||||
DOCPORTS="${DOCPORTS}NODOC=yes"
|
||||
fi
|
||||
|
||||
# The aggregated build-time flags based upon variables defined within
|
||||
# this file, unless overridden by release.conf. In most cases, these
|
||||
# will not need to be changed.
|
||||
@ -118,16 +141,14 @@ CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
|
||||
CHROOT_IMAKEFLAGS="${CONF_FILES}"
|
||||
CHROOT_DMAKEFLAGS="${CONF_FILES}"
|
||||
RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}"
|
||||
RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=${KERNEL} ${ARCH_FLAGS} ${CONF_FILES}"
|
||||
RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=${KERNEL} ${CONF_FILES} \
|
||||
NODOC=${NODOC} NOPORTS=${NOPORTS}"
|
||||
RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
|
||||
RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \
|
||||
${DOCPORTS}"
|
||||
|
||||
# If PORTS is set and NODOC is unset, force NODOC=yes because the ports tree
|
||||
# is required to build the documentation set.
|
||||
if [ "x${NOPORTS}" != "x" ] && [ "x${NODOC}" = "x" ]; then
|
||||
echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
|
||||
echo " and NOPORTS is set."
|
||||
NODOC=1
|
||||
# Force src checkout if configured
|
||||
FORCE_SRC_KEY=
|
||||
if [ "x${SRC_FORCE_CHECKOUT}" != "x" ]; then
|
||||
FORCE_SRC_KEY="--force"
|
||||
fi
|
||||
|
||||
if [ ! ${CHROOTDIR} ]; then
|
||||
@ -144,7 +165,7 @@ set -e # Everything must succeed
|
||||
|
||||
mkdir -p ${CHROOTDIR}/usr
|
||||
|
||||
svn co ${SVNROOT}/${SRCBRANCH} ${CHROOTDIR}/usr/src $SRCREVISION
|
||||
svn co ${FORCE_SRC_KEY} ${SVNROOT}/${SRCBRANCH} ${CHROOTDIR}/usr/src $SRCREVISION
|
||||
if [ "x${NODOC}" = "x" ]; then
|
||||
svn co ${SVNROOT}/${DOCBRANCH} ${CHROOTDIR}/usr/doc $DOCREVISION
|
||||
fi
|
||||
@ -164,10 +185,10 @@ trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
|
||||
build_doc_ports() {
|
||||
## Trick the ports 'run-autotools-fixup' target to do the right thing.
|
||||
_OSVERSION=$(sysctl -n kern.osreldate)
|
||||
if [ -d ${CHROOTDIR}/usr/doc ] && [ "x${NODOC}" != "x" ]; then
|
||||
PBUILD_FLAGS="OSVERSION=${_OSVERSION} WITHOUT_JADETEX=yes BATCH=yes"
|
||||
if [ -d ${CHROOTDIR}/usr/doc ] && [ "x${NODOC}" = "x" ]; then
|
||||
PBUILD_FLAGS="OSVERSION=${_OSVERSION} WITHOUT_JADETEX=yes WITHOUT_X11=yes BATCH=yes"
|
||||
chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
|
||||
${PBUILD_FLAGS} install
|
||||
${PBUILD_FLAGS} install clean distclean
|
||||
fi
|
||||
}
|
||||
|
||||
@ -191,11 +212,11 @@ if [ "x${RELSTRING}" = "x" ]; then
|
||||
RELSTRING="$(chroot ${CHROOTDIR} uname -s)-${OSRELEASE}-${TARGET_ARCH}"
|
||||
fi
|
||||
|
||||
chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
|
||||
chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
|
||||
chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
|
||||
release RELSTRING=${RELSTRING}
|
||||
chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
|
||||
eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
|
||||
install DESTDIR=/R RELSTRING=${RELSTRING}
|
||||
|
||||
cd ${CHROOTDIR}/R
|
||||
|
@ -124,7 +124,8 @@ static volatile sig_atomic_t romeo_must_die = 0;
|
||||
|
||||
static const char *configfile = CF;
|
||||
|
||||
static void devdlog(int priority, const char* message, ...);
|
||||
static void devdlog(int priority, const char* message, ...)
|
||||
__printflike(2, 3);
|
||||
static void event_loop(void);
|
||||
static void usage(void);
|
||||
|
||||
@ -969,7 +970,7 @@ event_loop(void)
|
||||
}
|
||||
rv = select(max_fd, &fds, NULL, NULL, &tv);
|
||||
if (got_siginfo) {
|
||||
devdlog(LOG_INFO, "Events received so far=%ld\n",
|
||||
devdlog(LOG_INFO, "Events received so far=%u\n",
|
||||
total_events);
|
||||
got_siginfo = 0;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd April 21, 2013
|
||||
.Dd July 12, 2013
|
||||
.Dt DEVFS 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -190,6 +190,7 @@ Nodes may later be revived manually with
|
||||
or with the
|
||||
.Cm unhide
|
||||
action.
|
||||
Hiding a directory node effectively hides all of its child nodes.
|
||||
.It Cm include Ar ruleset
|
||||
Apply all the rules in ruleset number
|
||||
.Ar ruleset
|
||||
@ -213,6 +214,8 @@ which may be a user name
|
||||
or number.
|
||||
.It Cm unhide
|
||||
Unhide the node.
|
||||
If the node resides in a subdirectory,
|
||||
all parent directory nodes must be visible to be able to access the node.
|
||||
.El
|
||||
.Sh IMPLEMENTATION NOTES
|
||||
Rulesets are created by the kernel at the first reference
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
PROG= mount
|
||||
SRCS= mount.c mount_fs.c getmntopts.c vfslist.c
|
||||
MAN= mount.8
|
||||
MAN= mount.8 mount.conf.8
|
||||
# We do NOT install the getmntopts.3 man page.
|
||||
|
||||
DPADD= ${LIBUTIL}
|
||||
|
@ -118,6 +118,9 @@ When used in conjunction with the
|
||||
.Fl a
|
||||
option, also mount those file systems which are marked as
|
||||
.Dq Li late .
|
||||
.It Fl n
|
||||
For compatibility with some other implementations, this flag is
|
||||
currently a no-op.
|
||||
.It Fl o
|
||||
Options are specified with a
|
||||
.Fl o
|
||||
|
@ -253,7 +253,7 @@ main(int argc, char *argv[])
|
||||
options = NULL;
|
||||
vfslist = NULL;
|
||||
vfstype = "ufs";
|
||||
while ((ch = getopt(argc, argv, "adF:fLlo:prt:uvw")) != -1)
|
||||
while ((ch = getopt(argc, argv, "adF:fLlno:prt:uvw")) != -1)
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
all = 1;
|
||||
@ -274,6 +274,9 @@ main(int argc, char *argv[])
|
||||
case 'l':
|
||||
late = 1;
|
||||
break;
|
||||
case 'n':
|
||||
/* For compatibility with the Linux version of mount. */
|
||||
break;
|
||||
case 'o':
|
||||
if (*optarg) {
|
||||
options = catopt(options, optarg);
|
||||
|
252
sbin/mount/mount.conf.8
Normal file
252
sbin/mount/mount.conf.8
Normal file
@ -0,0 +1,252 @@
|
||||
.\" Copyright (c) 2013 Marcel Moolenaar
|
||||
.\" Copyright (c) 2013 Craig Rodrigues
|
||||
.\" 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 AUTHORS 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 AUTHORS 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$
|
||||
.\"
|
||||
.\"
|
||||
.Dd July 7, 2013
|
||||
.Dt MOUNT.CONF 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm mount.conf
|
||||
.Nd root file system mount configuration file
|
||||
.Sh SYNOPSIS
|
||||
.Pa /.mount.conf
|
||||
.Sh DESCRIPTION
|
||||
During the bootup process, the
|
||||
.Fx
|
||||
kernel will try to mount the root file system
|
||||
using the logic in the
|
||||
.Fn vfs_mountroot
|
||||
function in
|
||||
.Pa src/sys/kern/vfs_mountroot.c .
|
||||
The root mount logic can be described as follows:
|
||||
.Bl -enum
|
||||
.It
|
||||
The kernel will synthesize in memory a config file
|
||||
with default directives for mounting
|
||||
the root file system.
|
||||
The logic for this is in
|
||||
.Fn vfs_mountroot_conf0 .
|
||||
.It
|
||||
The kernel will first mount
|
||||
.Xr devfs 8
|
||||
as the root file system.
|
||||
.It
|
||||
Next, the kernel will parse the in-memory config file created in step 1
|
||||
and try to mount the actual root file system.
|
||||
See
|
||||
.Sx FILE FORMAT
|
||||
for the format of the config file.
|
||||
.It
|
||||
When the actual root file system is mounted,
|
||||
.Xr devfs
|
||||
will be re-mounted on the
|
||||
.Pa /dev
|
||||
directory.
|
||||
.It
|
||||
If a
|
||||
.Pa /.mount.conf
|
||||
file does not exist in the root file system which was
|
||||
just mounted, the root mount logic stops here.
|
||||
.It
|
||||
If a
|
||||
.Pa /.mount.conf
|
||||
file exists in the root file system which was just mounted,
|
||||
this file will be parsed, and the kernel will use this new config
|
||||
file to try to re-mount the root file system.
|
||||
See
|
||||
.Sx FILE FORMAT
|
||||
for the format of the config file.
|
||||
.It
|
||||
If the new root file system has a
|
||||
.Pa /.mount
|
||||
directory, the old root file system will be re-mounted
|
||||
on
|
||||
.Pa /.mount .
|
||||
.It
|
||||
The root mount logic will go back to step 4.
|
||||
.El
|
||||
.Pp
|
||||
The root mount logic is recursive, and step 8 will
|
||||
be repeated as long as each new root file system
|
||||
which is mounted has a
|
||||
.Pa /.mount.conf
|
||||
file.
|
||||
.Sh FILE FORMAT
|
||||
The kernel parses each line in
|
||||
.Pa .mount.conf
|
||||
and then tries to perform the action specified on that line as soon as it is parsed.
|
||||
.Bl -tag -width "XXXXXXXXXX"
|
||||
.It Ic #
|
||||
A line beginning with a # is a comment and is ignored.
|
||||
.It Ic {FS}:{MOUNTPOINT} {OPTIONS}
|
||||
The kernel will try to mount this in an
|
||||
operation equivalent to:
|
||||
.Bd -literal -offset indent
|
||||
mount -t {FS} -o {OPTIONS} {MOUNTPOINT} /
|
||||
.Ed
|
||||
.Pp
|
||||
If this is successfully mounted,
|
||||
further lines in
|
||||
.Pa .mount.conf
|
||||
are ignored.
|
||||
If all lines in
|
||||
.Pa .mount.conf
|
||||
have been processed and no root file system has been successfully
|
||||
mounted, then the action specified by
|
||||
.Ic .onfail
|
||||
is performed.
|
||||
.It Ic .ask
|
||||
When the kernel processes this line, a
|
||||
.Li mountroot>
|
||||
command-line prompt is displayed.
|
||||
At this prompt, the operator can enter the
|
||||
the root mount.
|
||||
.It Ic .md Ar file
|
||||
Create a memory backed
|
||||
.Xr md 4
|
||||
virtual disk, using
|
||||
.Ar file
|
||||
as the backing store.
|
||||
.It Ic .onfail Ar [panic|reboot|retry|continue]
|
||||
If after parsing all the lines in
|
||||
.Pa .mount.conf
|
||||
the kernel is unable to mount a root file system,
|
||||
the
|
||||
.Ic .onfail
|
||||
directive tells the kernel what action to perform.
|
||||
.It Ic .timeout Ar N
|
||||
Before trying to mount a root file system,
|
||||
if the root mount device does not exist, wait at most
|
||||
.Ar N
|
||||
seconds for the device to appear before trying to mount it.
|
||||
If
|
||||
.Ic .timeout
|
||||
is not specified, the default timeout is 3 seconds.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
The following example
|
||||
.Pa .mount.conf
|
||||
will direct the kernel to try mounting the root file system
|
||||
first as an ISO CD9660 file system on
|
||||
.Pa /dev/cd0 ,
|
||||
then if that does not work, as an ISO CD9660 file system on
|
||||
.Pa /dev/acd0 ,
|
||||
and then if that does not work, as a UFS file system on
|
||||
.Pa /dev/ada0s1a .
|
||||
If that does not work, a
|
||||
.Li mountroot>
|
||||
command-line prompt will be displayed where the operator
|
||||
can manually enter the root file system to mount.
|
||||
Finally if that does not work, the kernel will panic.
|
||||
.Bd -literal -offset indent
|
||||
.Li .onfail panic
|
||||
.Li .timeout 3
|
||||
cd9660:/dev/cd0 ro
|
||||
.Li .timeout 0
|
||||
cd9660:/dev/acd0 ro
|
||||
.Li .timeout 3
|
||||
ufs:/dev/ada0s1a
|
||||
.Li .ask
|
||||
.Ed
|
||||
.Pp
|
||||
The following example
|
||||
.Pa .mount.conf
|
||||
will direct the kernel to create a
|
||||
.Xr md 4
|
||||
memory disk attached to the file
|
||||
.Pa /data/OS-1.0.iso
|
||||
and then mount the ISO CD9660 file system
|
||||
on the md device which was just created.
|
||||
The last line is a comment which is ignored.
|
||||
.Bd -literal -offset indent
|
||||
.Li .timeout 3
|
||||
.Li .md /data/OS-1.0.iso
|
||||
.Li cd9600:/dev/md# ro
|
||||
.Li # Can also use cd9660:/dev/md0 ro
|
||||
.Ed
|
||||
.Pp
|
||||
The following example
|
||||
.Pa .mount.conf
|
||||
will direct the kernel to create a
|
||||
.Xr md 4
|
||||
memory disk attached to the file
|
||||
.Pa /data/base.ufs.uzip
|
||||
and then mount the UFS file system
|
||||
on the md uzip device which was just created
|
||||
by the
|
||||
.Xr geom_uzip 4
|
||||
driver.
|
||||
.Bd -literal -offset indent
|
||||
.Li .md /data/base.ufs.uzip
|
||||
.Li ufs:/dev/md#.uzip ro
|
||||
.Li # Can also use ufs:/dev/md0.uzip ro
|
||||
.Ed
|
||||
.Pp
|
||||
The following example
|
||||
.Pa .mount.conf
|
||||
will direct the kernel to do a unionfs
|
||||
mount on a directory
|
||||
.Pa /jail/freebsd-8-stable
|
||||
which has a
|
||||
.Xr chroot 2
|
||||
environment.
|
||||
.Bd -literal -offset indent
|
||||
.Li .timeout 3
|
||||
.Li unionfs:/jail/freebsd-8-stable
|
||||
.Ed
|
||||
.Sh NOTES
|
||||
For each root file system which is mounted, a
|
||||
.Pa /dev
|
||||
directory
|
||||
.Em must
|
||||
exist so that the root mount logic can properly re-mount
|
||||
.Xr devfs 8 .
|
||||
If this directory does not exist, the system
|
||||
may hang during the bootup process.
|
||||
.Sh SEE ALSO
|
||||
.Xr nmount 2 ,
|
||||
.Xr md 4 ,
|
||||
.Xr boot.config 5 ,
|
||||
.Xr fstab 5 ,
|
||||
.Xr boot 8 ,
|
||||
.Xr loader 8 ,
|
||||
.Xr mount 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
file first appeared in
|
||||
.Fx 9.0 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The root mount logic in the
|
||||
.Fx
|
||||
kernel which parses
|
||||
.Pa /.mount.conf
|
||||
was written by
|
||||
.An Marcel Moolenaar Aq marcel@FreeBSD.org .
|
||||
This man page was written by
|
||||
.An Craig Rodrigues Aq rodrigc@FreeBSD.org .
|
@ -28,7 +28,7 @@
|
||||
.\" @(#)mount_nfs.8 8.3 (Berkeley) 3/29/95
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 9, 2012
|
||||
.Dd July 8, 2013
|
||||
.Dt MOUNT_NFS 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -118,6 +118,13 @@ for regular files, and 30 -> 60 seconds for directories.
|
||||
The algorithm to calculate the timeout is based on the age of the file.
|
||||
The older the file,
|
||||
the longer the cache is considered valid, subject to the limits above.
|
||||
.It Cm allgssname
|
||||
This option can be used along with
|
||||
.Fl o Cm gssname
|
||||
to specify that all operations should use the host-based initiator
|
||||
credential.
|
||||
This may be used for clients that run system daemons that need to
|
||||
access files on the NFSv4 mounted volume.
|
||||
.It Cm bg
|
||||
If an initial attempt to contact the server fails, fork off a child to keep
|
||||
trying the mount in the background.
|
||||
@ -138,6 +145,23 @@ short.
|
||||
.It Cm fg
|
||||
Same as not specifying
|
||||
.Cm bg .
|
||||
.It Cm gssname Ns = Ns Aq Ar service-principal-name
|
||||
This option can be used with the KerberosV security flavors for NFSv4 mounts
|
||||
to specify the
|
||||
.Dq "service-principal-name"
|
||||
of a host-based entry in the default
|
||||
keytab file that is used for system operations.
|
||||
It allows the mount to be performed by
|
||||
.Dq "root"
|
||||
and avoids problems with
|
||||
cached credentials for the system operations expiring.
|
||||
The
|
||||
.Dq "service-prinicpal-name"
|
||||
should be specified without instance or domain and is typically
|
||||
.Dq "host" ,
|
||||
.Dq "nfs"
|
||||
or
|
||||
.Dq "root" .
|
||||
.It Cm hard
|
||||
Same as not specifying
|
||||
.Cm soft .
|
||||
|
@ -29,13 +29,14 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nvmecontrol.h"
|
||||
@ -45,7 +46,7 @@ devlist_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\n");
|
||||
fprintf(stderr, DEVLIST_USAGE);
|
||||
exit(EX_USAGE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
@ -62,9 +63,7 @@ devlist(int argc, char *argv[])
|
||||
struct nvme_namespace_data nsdata;
|
||||
char name[64];
|
||||
uint32_t i;
|
||||
int ch, ctrlr, exit_code, fd, found;
|
||||
|
||||
exit_code = EX_OK;
|
||||
int ch, ctrlr, fd, found, ret;
|
||||
|
||||
while ((ch = getopt(argc, argv, "")) != -1) {
|
||||
switch ((char)ch) {
|
||||
@ -80,19 +79,19 @@ devlist(int argc, char *argv[])
|
||||
ctrlr++;
|
||||
sprintf(name, "%s%d", NVME_CTRLR_PREFIX, ctrlr);
|
||||
|
||||
exit_code = open_dev(name, &fd, 0, 0);
|
||||
ret = open_dev(name, &fd, 0, 0);
|
||||
|
||||
if (exit_code == EX_NOINPUT)
|
||||
break;
|
||||
else if (exit_code == EX_NOPERM) {
|
||||
printf("Could not open /dev/%s, errno = %d (%s)\n",
|
||||
name, errno, strerror(errno));
|
||||
continue;
|
||||
if (ret != 0) {
|
||||
if (ret == EACCES) {
|
||||
warnx("could not open "_PATH_DEV"%s\n", name);
|
||||
continue;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
found++;
|
||||
read_controller_data(fd, &cdata);
|
||||
printf("%6s: %s\n", name, cdata.mn);
|
||||
printf("%6s: %.*s\n", name, NVME_MODEL_NUMBER_LENGTH, cdata.mn);
|
||||
|
||||
for (i = 0; i < cdata.nn; i++) {
|
||||
sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr,
|
||||
@ -111,5 +110,5 @@ devlist(int argc, char *argv[])
|
||||
if (found == 0)
|
||||
printf("No NVMe controllers found.\n");
|
||||
|
||||
exit(EX_OK);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -36,14 +36,14 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nvmecontrol.h"
|
||||
@ -64,60 +64,58 @@ slot_has_valid_firmware(int fd, int slot)
|
||||
}
|
||||
|
||||
static void
|
||||
read_image_file(char *path, void **buf, ssize_t *size)
|
||||
read_image_file(char *path, void **buf, int32_t *size)
|
||||
{
|
||||
struct stat sb;
|
||||
int32_t filesize;
|
||||
int fd;
|
||||
|
||||
*size = 0;
|
||||
*buf = NULL;
|
||||
|
||||
if ((fd = open(path, O_RDONLY)) < 0) {
|
||||
fprintf(stderr, "Unable to open '%s'.\n", path);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
fprintf(stderr, "Unable to stat '%s'.\n", path);
|
||||
close(fd);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if ((*buf = malloc(sb.st_size)) == NULL) {
|
||||
fprintf(stderr, "Unable to malloc %jd bytes.\n",
|
||||
sb.st_size);
|
||||
close(fd);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if ((*size = read(fd, *buf, sb.st_size)) < 0) {
|
||||
fprintf(stderr, "Error reading '%s', errno=%d (%s)\n",
|
||||
path, errno, strerror(errno));
|
||||
close(fd);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (*size != sb.st_size) {
|
||||
fprintf(stderr, "Error reading '%s', "
|
||||
"read %zd bytes, requested %jd bytes\n",
|
||||
path, *size, sb.st_size);
|
||||
close(fd);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if ((fd = open(path, O_RDONLY)) < 0)
|
||||
err(1, "unable to open '%s'", path);
|
||||
if (fstat(fd, &sb) < 0)
|
||||
err(1, "unable to stat '%s'", path);
|
||||
|
||||
/*
|
||||
* The NVMe spec does not explicitly state a maximum firmware image
|
||||
* size, although one can be inferred from the dword size limitation
|
||||
* for the size and offset fields in the Firmware Image Download
|
||||
* command.
|
||||
*
|
||||
* Technically, the max is UINT32_MAX * sizeof(uint32_t), since the
|
||||
* size and offsets are specified in terms of dwords (not bytes), but
|
||||
* realistically INT32_MAX is sufficient here and simplifies matters
|
||||
* a bit.
|
||||
*/
|
||||
if (sb.st_size > INT32_MAX)
|
||||
errx(1, "size of file '%s' is too large (%jd bytes)",
|
||||
path, (intmax_t)sb.st_size);
|
||||
filesize = (int32_t)sb.st_size;
|
||||
if ((*buf = malloc(filesize)) == NULL)
|
||||
errx(1, "unable to malloc %d bytes", filesize);
|
||||
if ((*size = read(fd, *buf, filesize)) < 0)
|
||||
err(1, "error reading '%s'", path);
|
||||
/* XXX assuming no short reads */
|
||||
if (*size != filesize)
|
||||
errx(1,
|
||||
"error reading '%s' (read %d bytes, requested %d bytes)",
|
||||
path, *size, filesize);
|
||||
}
|
||||
|
||||
static void
|
||||
update_firmware(int fd, uint8_t *payload, uint32_t payload_size)
|
||||
update_firmware(int fd, uint8_t *payload, int32_t payload_size)
|
||||
{
|
||||
struct nvme_pt_command pt;
|
||||
size_t size;
|
||||
int32_t off, resid, size;
|
||||
void *chunk;
|
||||
uint32_t off, resid;
|
||||
int exit_code = EX_OK;
|
||||
|
||||
off = 0;
|
||||
resid = payload_size;
|
||||
|
||||
if ((chunk = malloc((size_t)NVME_MAX_XFER_SIZE)) == NULL) {
|
||||
printf("Unable to malloc %d bytes.\n", NVME_MAX_XFER_SIZE);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if ((chunk = malloc(NVME_MAX_XFER_SIZE)) == NULL)
|
||||
errx(1, "unable to malloc %d bytes", NVME_MAX_XFER_SIZE);
|
||||
|
||||
while (resid > 0) {
|
||||
size = (resid >= NVME_MAX_XFER_SIZE) ?
|
||||
@ -132,26 +130,15 @@ update_firmware(int fd, uint8_t *payload, uint32_t payload_size)
|
||||
pt.len = size;
|
||||
pt.is_read = 0;
|
||||
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
|
||||
printf("Firmware image download request failed. "
|
||||
"errno=%d (%s)\n",
|
||||
errno, strerror(errno));
|
||||
exit_code = EX_IOERR;
|
||||
break;
|
||||
}
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
|
||||
err(1, "firmware download request failed");
|
||||
|
||||
if (nvme_completion_is_error(&pt.cpl)) {
|
||||
printf("Passthrough command returned error.\n");
|
||||
exit_code = EX_IOERR;
|
||||
break;
|
||||
}
|
||||
if (nvme_completion_is_error(&pt.cpl))
|
||||
errx(1, "firmware download request returned error");
|
||||
|
||||
resid -= size;
|
||||
off += size;
|
||||
}
|
||||
|
||||
if (exit_code != EX_OK)
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -164,16 +151,11 @@ activate_firmware(int fd, int slot, int activate_action)
|
||||
pt.cmd.cdw10 = (activate_action << 3) | slot;
|
||||
pt.is_read = 0;
|
||||
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
|
||||
printf("Firmware activate request failed. errno=%d (%s)\n",
|
||||
errno, strerror(errno));
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
|
||||
err(1, "firmware activate request failed");
|
||||
|
||||
if (nvme_completion_is_error(&pt.cpl)) {
|
||||
printf("Passthrough command returned error.\n");
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (nvme_completion_is_error(&pt.cpl))
|
||||
errx(1, "firmware activate request returned error");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -181,7 +163,7 @@ firmware_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\n");
|
||||
fprintf(stderr, FIRMWARE_USAGE);
|
||||
exit(EX_USAGE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
@ -192,7 +174,7 @@ firmware(int argc, char *argv[])
|
||||
char ch, *p, *image = NULL;
|
||||
char *controller = NULL, prompt[64];
|
||||
void *buf = NULL;
|
||||
ssize_t size;
|
||||
int32_t size = 0;
|
||||
struct nvme_controller_data cdata;
|
||||
|
||||
a_flag = s_flag = f_flag = false;
|
||||
@ -252,34 +234,27 @@ firmware(int argc, char *argv[])
|
||||
open_dev(controller, &fd, 1, 1);
|
||||
read_controller_data(fd, &cdata);
|
||||
|
||||
if (cdata.oacs.firmware == 0) {
|
||||
fprintf(stderr,
|
||||
"Controller does not support firmware "
|
||||
"activate/download.\n");
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (cdata.oacs.firmware == 0)
|
||||
errx(1,
|
||||
"controller does not support firmware activate/download");
|
||||
|
||||
if (f_flag && slot == 1 && cdata.frmw.slot1_ro) {
|
||||
fprintf(stderr, "Slot %d is marked as read only.\n", slot);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (f_flag && slot == 1 && cdata.frmw.slot1_ro)
|
||||
errx(1, "slot %d is marked as read only", slot);
|
||||
|
||||
if (slot > cdata.frmw.num_slots) {
|
||||
fprintf(stderr,
|
||||
"Slot %d was specified but controller only "
|
||||
"supports %d firmware slots.\n",
|
||||
if (slot > cdata.frmw.num_slots)
|
||||
errx(1,
|
||||
"slot %d specified but controller only supports %d slots",
|
||||
slot, cdata.frmw.num_slots);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
|
||||
if (!slot_has_valid_firmware(fd, slot)) {
|
||||
fprintf(stderr,
|
||||
"Slot %d does not contain valid firmware.\n"
|
||||
"Try 'nvmecontrol logpage -p 3 %s' to get a list "
|
||||
"of available firmware images.\n",
|
||||
if (a_flag && !f_flag && !slot_has_valid_firmware(fd, slot))
|
||||
errx(1,
|
||||
"slot %d does not contain valid firmware,\n"
|
||||
"try 'nvmecontrol logpage -p 3 %s' to get a list "
|
||||
"of available images\n",
|
||||
slot, controller);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
|
||||
if (f_flag)
|
||||
read_image_file(image, &buf, &size);
|
||||
|
||||
if (f_flag && a_flag)
|
||||
printf("You are about to download and activate "
|
||||
@ -305,12 +280,11 @@ firmware(int argc, char *argv[])
|
||||
if (strncasecmp(prompt, "yes", 3) == 0)
|
||||
break;
|
||||
if (strncasecmp(prompt, "no", 2) == 0)
|
||||
exit(EX_OK);
|
||||
exit(1);
|
||||
printf("Please answer \"yes\" or \"no\". ");
|
||||
}
|
||||
|
||||
if (f_flag) {
|
||||
read_image_file(image, &buf, &size);
|
||||
update_firmware(fd, buf, size);
|
||||
if (a_flag)
|
||||
activate_firmware(fd, slot,
|
||||
@ -331,5 +305,5 @@ firmware(int argc, char *argv[])
|
||||
}
|
||||
|
||||
close(fd);
|
||||
exit(EX_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
@ -30,13 +30,12 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nvmecontrol.h"
|
||||
@ -48,9 +47,12 @@ print_controller(struct nvme_controller_data *cdata)
|
||||
printf("================================\n");
|
||||
printf("Vendor ID: %04x\n", cdata->vid);
|
||||
printf("Subsystem Vendor ID: %04x\n", cdata->ssvid);
|
||||
printf("Serial Number: %s\n", cdata->sn);
|
||||
printf("Model Number: %s\n", cdata->mn);
|
||||
printf("Firmware Version: %s\n", cdata->fr);
|
||||
printf("Serial Number: %.*s\n",
|
||||
NVME_SERIAL_NUMBER_LENGTH, cdata->sn);
|
||||
printf("Model Number: %.*s\n",
|
||||
NVME_MODEL_NUMBER_LENGTH, cdata->mn);
|
||||
printf("Firmware Version: %.*s\n",
|
||||
NVME_FIRMWARE_REVISION_LENGTH, cdata->fr);
|
||||
printf("Recommended Arb Burst: %d\n", cdata->rab);
|
||||
printf("IEEE OUI Identifier: %02x %02x %02x\n",
|
||||
cdata->ieee[0], cdata->ieee[1], cdata->ieee[2]);
|
||||
@ -125,13 +127,11 @@ print_namespace(struct nvme_namespace_data *nsdata)
|
||||
printf("Thin Provisioning: %s\n",
|
||||
nsdata->nsfeat.thin_prov ? "Supported" : "Not Supported");
|
||||
printf("Number of LBA Formats: %d\n", nsdata->nlbaf+1);
|
||||
printf("Current LBA Format: LBA Format #%d\n",
|
||||
printf("Current LBA Format: LBA Format #%02d\n",
|
||||
nsdata->flbas.format);
|
||||
for (i = 0; i <= nsdata->nlbaf; i++) {
|
||||
printf("LBA Format #%d:\n", i);
|
||||
printf(" LBA Data Size: %d\n",
|
||||
1 << nsdata->lbaf[i].lbads);
|
||||
}
|
||||
for (i = 0; i <= nsdata->nlbaf; i++)
|
||||
printf("LBA Format #%02d: Data Size: %5d Metadata Size: %5d\n",
|
||||
i, 1 << nsdata->lbaf[i].lbads, nsdata->lbaf[i].ms);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -139,7 +139,7 @@ identify_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\n");
|
||||
fprintf(stderr, IDENTIFY_USAGE);
|
||||
exit(EX_USAGE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -177,16 +177,16 @@ identify_ctrlr(int argc, char *argv[])
|
||||
hexlength = offsetof(struct nvme_controller_data,
|
||||
reserved5);
|
||||
print_hex(&cdata, hexlength);
|
||||
exit(EX_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (verboseflag == 1) {
|
||||
printf("-v not currently supported without -x.\n");
|
||||
fprintf(stderr, "-v not currently supported without -x\n");
|
||||
identify_usage();
|
||||
}
|
||||
|
||||
print_controller(&cdata);
|
||||
exit(EX_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -194,7 +194,6 @@ identify_ns(int argc, char *argv[])
|
||||
{
|
||||
struct nvme_namespace_data nsdata;
|
||||
char path[64];
|
||||
char *nsloc;
|
||||
int ch, fd, hexflag = 0, hexlength, nsid;
|
||||
int verboseflag = 0;
|
||||
|
||||
@ -223,25 +222,13 @@ identify_ns(int argc, char *argv[])
|
||||
open_dev(argv[optind], &fd, 1, 1);
|
||||
close(fd);
|
||||
|
||||
/*
|
||||
* Pull the namespace id from the string. +2 skips past the "ns" part
|
||||
* of the string. Don't search past 10 characters into the string,
|
||||
* otherwise we know it is malformed.
|
||||
*/
|
||||
nsloc = strnstr(argv[optind], NVME_NS_PREFIX, 10);
|
||||
if (nsloc != NULL)
|
||||
nsid = strtol(nsloc + 2, NULL, 10);
|
||||
if (nsloc == NULL || (nsid == 0 && errno != 0)) {
|
||||
printf("Invalid namespace ID %s.\n", argv[optind]);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
|
||||
/*
|
||||
* We send IDENTIFY commands to the controller, not the namespace,
|
||||
* since it is an admin cmd. So the path should only include the
|
||||
* nvmeX part of the nvmeXnsY string.
|
||||
* since it is an admin cmd. The namespace ID will be specified in
|
||||
* the IDENTIFY command itself. So parse the namespace's device node
|
||||
* string to get the controller substring and namespace ID.
|
||||
*/
|
||||
snprintf(path, nsloc - argv[optind] + 1, "%s", argv[optind]);
|
||||
parse_ns_str(argv[optind], path, &nsid);
|
||||
open_dev(path, &fd, 1, 1);
|
||||
read_namespace_data(fd, nsid, &nsdata);
|
||||
close(fd);
|
||||
@ -253,16 +240,16 @@ identify_ns(int argc, char *argv[])
|
||||
hexlength = offsetof(struct nvme_namespace_data,
|
||||
reserved6);
|
||||
print_hex(&nsdata, hexlength);
|
||||
exit(EX_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (verboseflag == 1) {
|
||||
printf("-v not currently supported without -x.\n");
|
||||
fprintf(stderr, "-v not currently supported without -x\n");
|
||||
identify_usage();
|
||||
}
|
||||
|
||||
print_namespace(&nsdata);
|
||||
exit(EX_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -275,6 +262,10 @@ identify(int argc, char *argv[])
|
||||
|
||||
while (getopt(argc, argv, "vx") != -1) ;
|
||||
|
||||
/* Check that a controller or namespace was specified. */
|
||||
if (optind >= argc)
|
||||
identify_usage();
|
||||
|
||||
target = argv[optind];
|
||||
|
||||
optreset = 1;
|
||||
|
@ -34,14 +34,13 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nvmecontrol.h"
|
||||
@ -52,14 +51,13 @@ __FBSDID("$FreeBSD$");
|
||||
typedef void (*print_fn_t)(void *buf, uint32_t size);
|
||||
|
||||
static void *
|
||||
get_log_buffer(size_t size)
|
||||
get_log_buffer(uint32_t size)
|
||||
{
|
||||
void *buf;
|
||||
|
||||
if ((buf = malloc(size)) == NULL) {
|
||||
fprintf(stderr, "Unable to malloc %zd bytes\n", size);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if ((buf = malloc(size)) == NULL)
|
||||
errx(1, "unable to malloc %u bytes", size);
|
||||
|
||||
memset(buf, 0, size);
|
||||
return (buf);
|
||||
}
|
||||
@ -79,16 +77,11 @@ read_logpage(int fd, uint8_t log_page, int nsid, void *payload,
|
||||
pt.len = payload_size;
|
||||
pt.is_read = 1;
|
||||
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
|
||||
printf("Get log page request failed. errno=%d (%s)\n",
|
||||
errno, strerror(errno));
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
|
||||
err(1, "get log page request failed");
|
||||
|
||||
if (nvme_completion_is_error(&pt.cpl)) {
|
||||
printf("Passthrough command returned error.\n");
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (nvme_completion_is_error(&pt.cpl))
|
||||
errx(1, "get log page request returned error");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -242,19 +235,18 @@ logpage_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\n");
|
||||
fprintf(stderr, LOGPAGE_USAGE);
|
||||
exit(EX_USAGE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
logpage(int argc, char *argv[])
|
||||
{
|
||||
int fd, nsid, len;
|
||||
int fd, nsid;
|
||||
int log_page = 0, pageflag = false;
|
||||
int hexflag = false;
|
||||
int allow_ns = false;
|
||||
char ch, *p, *nsloc = NULL;
|
||||
char *cname = NULL;
|
||||
size_t size;
|
||||
int hexflag = false, ns_specified;
|
||||
char ch, *p;
|
||||
char cname[64];
|
||||
uint32_t size;
|
||||
void *buf;
|
||||
struct logpage_function *f;
|
||||
struct nvme_controller_data cdata;
|
||||
@ -296,54 +288,31 @@ logpage(int argc, char *argv[])
|
||||
if (optind >= argc)
|
||||
logpage_usage();
|
||||
|
||||
if (strstr(argv[optind], NVME_NS_PREFIX) != NULL) {
|
||||
ns_specified = true;
|
||||
parse_ns_str(argv[optind], cname, &nsid);
|
||||
open_dev(cname, &fd, 1, 1);
|
||||
} else {
|
||||
ns_specified = false;
|
||||
nsid = NVME_GLOBAL_NAMESPACE_TAG;
|
||||
open_dev(argv[optind], &fd, 1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* The log page attribtues indicate whether or not the controller
|
||||
* supports the SMART/Health information log page on a per
|
||||
* namespace basis.
|
||||
*/
|
||||
cname = malloc(strlen(NVME_CTRLR_PREFIX) + 2);
|
||||
len = strlen(NVME_CTRLR_PREFIX) + 1;
|
||||
cname = strncpy(cname, argv[optind], len);
|
||||
open_dev(cname, &fd, 1, 1);
|
||||
read_controller_data(fd, &cdata);
|
||||
|
||||
if (log_page == NVME_LOG_HEALTH_INFORMATION && cdata.lpa.ns_smart != 0)
|
||||
allow_ns = true;
|
||||
|
||||
/* If a namespace id was specified, validate it's use */
|
||||
if (strstr(argv[optind], NVME_NS_PREFIX) != NULL) {
|
||||
if (!allow_ns) {
|
||||
if (log_page != NVME_LOG_HEALTH_INFORMATION) {
|
||||
fprintf(stderr,
|
||||
"Namespace ID not valid for log page %d.\n",
|
||||
log_page);
|
||||
} else if (cdata.lpa.ns_smart == 0) {
|
||||
fprintf(stderr,
|
||||
"Controller does not support per "
|
||||
"namespace SMART/Health information.\n");
|
||||
}
|
||||
close(fd);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
nsloc = strnstr(argv[optind], NVME_NS_PREFIX, 10);
|
||||
if (nsloc != NULL)
|
||||
nsid = strtol(nsloc + 2, NULL, 10);
|
||||
if (nsloc == NULL || (nsid == 0 && errno != 0)) {
|
||||
fprintf(stderr,
|
||||
"Invalid namespace ID %s.\n",
|
||||
argv[optind]);
|
||||
close(fd);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
|
||||
/*
|
||||
* User is asking for per namespace log page information
|
||||
* so close the controller and open up the namespace.
|
||||
*/
|
||||
close(fd);
|
||||
open_dev(argv[optind], &fd, 1, 1);
|
||||
} else
|
||||
nsid = NVME_GLOBAL_NAMESPACE_TAG;
|
||||
if (ns_specified) {
|
||||
if (log_page != NVME_LOG_HEALTH_INFORMATION)
|
||||
errx(1, "log page %d valid only at controller level",
|
||||
log_page);
|
||||
read_controller_data(fd, &cdata);
|
||||
if (cdata.lpa.ns_smart == 0)
|
||||
errx(1,
|
||||
"controller does not support per namespace "
|
||||
"smart/health information");
|
||||
}
|
||||
|
||||
print_fn = print_hex;
|
||||
if (!hexflag) {
|
||||
@ -384,5 +353,5 @@ logpage(int argc, char *argv[])
|
||||
print_fn(buf, size);
|
||||
|
||||
close(fd);
|
||||
exit(EX_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
@ -32,14 +32,15 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nvmecontrol.h"
|
||||
@ -71,7 +72,7 @@ usage(void)
|
||||
fprintf(stderr, "%s", f->usage);
|
||||
f++;
|
||||
}
|
||||
exit(EX_USAGE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -134,16 +135,11 @@ read_controller_data(int fd, struct nvme_controller_data *cdata)
|
||||
pt.len = sizeof(*cdata);
|
||||
pt.is_read = 1;
|
||||
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
|
||||
printf("Identify request failed. errno=%d (%s)\n",
|
||||
errno, strerror(errno));
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
|
||||
err(1, "identify request failed");
|
||||
|
||||
if (nvme_completion_is_error(&pt.cpl)) {
|
||||
printf("Passthrough command returned error.\n");
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (nvme_completion_is_error(&pt.cpl))
|
||||
errx(1, "identify request returned error");
|
||||
}
|
||||
|
||||
void
|
||||
@ -158,58 +154,63 @@ read_namespace_data(int fd, int nsid, struct nvme_namespace_data *nsdata)
|
||||
pt.len = sizeof(*nsdata);
|
||||
pt.is_read = 1;
|
||||
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0) {
|
||||
printf("Identify request failed. errno=%d (%s)\n",
|
||||
errno, strerror(errno));
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
|
||||
err(1, "identify request failed");
|
||||
|
||||
if (nvme_completion_is_error(&pt.cpl)) {
|
||||
printf("Passthrough command returned error.\n");
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (nvme_completion_is_error(&pt.cpl))
|
||||
errx(1, "identify request returned error");
|
||||
}
|
||||
|
||||
int
|
||||
open_dev(const char *str, int *fd, int show_error, int exit_on_error)
|
||||
{
|
||||
struct stat devstat;
|
||||
char full_path[64];
|
||||
|
||||
if (!strnstr(str, NVME_CTRLR_PREFIX, strlen(NVME_CTRLR_PREFIX))) {
|
||||
if (show_error)
|
||||
fprintf(stderr,
|
||||
"Controller/namespace IDs must begin with '%s'.\n",
|
||||
warnx("controller/namespace ids must begin with '%s'",
|
||||
NVME_CTRLR_PREFIX);
|
||||
if (exit_on_error)
|
||||
exit(EX_USAGE);
|
||||
exit(1);
|
||||
else
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
||||
snprintf(full_path, sizeof(full_path), "/dev/%s", str);
|
||||
if (stat(full_path, &devstat) != 0) {
|
||||
if (show_error)
|
||||
fprintf(stderr, "Could not stat %s. errno=%d (%s)\n",
|
||||
full_path, errno, strerror(errno));
|
||||
if (exit_on_error)
|
||||
exit(EX_NOINPUT);
|
||||
else
|
||||
return (EX_NOINPUT);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
snprintf(full_path, sizeof(full_path), _PATH_DEV"%s", str);
|
||||
*fd = open(full_path, O_RDWR);
|
||||
if (*fd < 0) {
|
||||
if (show_error)
|
||||
fprintf(stderr, "Could not open %s. errno=%d (%s)\n",
|
||||
full_path, errno, strerror(errno));
|
||||
warn("could not open %s", full_path);
|
||||
if (exit_on_error)
|
||||
exit(EX_NOPERM);
|
||||
exit(1);
|
||||
else
|
||||
return (EX_NOPERM);
|
||||
return (errno);
|
||||
}
|
||||
|
||||
return (EX_OK);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
parse_ns_str(const char *ns_str, char *ctrlr_str, int *nsid)
|
||||
{
|
||||
char *nsloc;
|
||||
|
||||
/*
|
||||
* Pull the namespace id from the string. +2 skips past the "ns" part
|
||||
* of the string. Don't search past 10 characters into the string,
|
||||
* otherwise we know it is malformed.
|
||||
*/
|
||||
nsloc = strnstr(ns_str, NVME_NS_PREFIX, 10);
|
||||
if (nsloc != NULL)
|
||||
*nsid = strtol(nsloc + 2, NULL, 10);
|
||||
if (nsloc == NULL || (*nsid == 0 && errno != 0))
|
||||
errx(1, "invalid namespace ID '%s'", ns_str);
|
||||
|
||||
/*
|
||||
* The controller string will include only the nvmX part of the
|
||||
* nvmeXnsY string.
|
||||
*/
|
||||
snprintf(ctrlr_str, nsloc - ns_str + 1, "%s", ns_str);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -38,7 +38,7 @@
|
||||
" nvmecontrol devlist\n"
|
||||
|
||||
#define IDENTIFY_USAGE \
|
||||
" nvmecontrol identify <controller id|namespace id>\n"
|
||||
" nvmecontrol identify [-x [-v]] <controller id|namespace id>\n"
|
||||
|
||||
#define PERFTEST_USAGE \
|
||||
" nvmecontrol perftest <-n num_threads> <-o read|write>\n" \
|
||||
@ -63,6 +63,7 @@ void logpage(int argc, char *argv[]);
|
||||
void firmware(int argc, char *argv[]);
|
||||
|
||||
int open_dev(const char *str, int *fd, int show_error, int exit_on_error);
|
||||
void parse_ns_str(const char *ns_str, char *ctrlr_str, int *nsid);
|
||||
void read_controller_data(int fd, struct nvme_controller_data *cdata);
|
||||
void read_namespace_data(int fd, int nsid, struct nvme_namespace_data *nsdata);
|
||||
void print_hex(void *data, uint32_t length);
|
||||
|
@ -31,14 +31,13 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nvmecontrol.h"
|
||||
@ -72,7 +71,7 @@ perftest_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\n");
|
||||
fprintf(stderr, PERFTEST_USAGE);
|
||||
exit(EX_USAGE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
@ -168,14 +167,10 @@ perftest(int argc, char *argv[])
|
||||
perftest_usage();
|
||||
|
||||
open_dev(argv[optind], &fd, 1, 1);
|
||||
if (ioctl(fd, ioctl_cmd, &io_test) < 0) {
|
||||
fprintf(stderr, "NVME_IO_TEST failed. errno=%d (%s)\n", errno,
|
||||
strerror(errno));
|
||||
close(fd);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (ioctl(fd, ioctl_cmd, &io_test) < 0)
|
||||
err(1, "ioctl NVME_IO_TEST failed");
|
||||
|
||||
close(fd);
|
||||
print_perftest(&io_test, perthread);
|
||||
exit(EX_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
@ -30,12 +30,11 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioccom.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sysexits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nvmecontrol.h"
|
||||
@ -45,7 +44,7 @@ reset_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage:\n");
|
||||
fprintf(stderr, RESET_USAGE);
|
||||
exit(EX_USAGE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
@ -65,11 +64,8 @@ reset(int argc, char *argv[])
|
||||
reset_usage();
|
||||
|
||||
open_dev(argv[optind], &fd, 1, 1);
|
||||
if (ioctl(fd, NVME_RESET_CONTROLLER) < 0) {
|
||||
printf("Reset request to %s failed. errno=%d (%s)\n",
|
||||
argv[optind], errno, strerror(errno));
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
if (ioctl(fd, NVME_RESET_CONTROLLER) < 0)
|
||||
err(1, "reset request to %s failed", argv[optind]);
|
||||
|
||||
exit(EX_OK);
|
||||
exit(0);
|
||||
}
|
||||
|
@ -125,9 +125,9 @@ recoverdisk -b 0 /dev/ad3 /somewhere
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dd 1 ,
|
||||
.Xr ada 4,
|
||||
.Xr cam 4,
|
||||
.Xr cd 4,
|
||||
.Xr ada 4 ,
|
||||
.Xr cam 4 ,
|
||||
.Xr cd 4 ,
|
||||
.Xr da 4
|
||||
.Sh HISTORY
|
||||
The
|
||||
|
@ -7,24 +7,21 @@ PROG= route
|
||||
MAN= route.8
|
||||
SRCS= route.c keywords.h
|
||||
WARNS?= 3
|
||||
CLEANFILES+=keywords.h _keywords.tmp
|
||||
CLEANFILES+=keywords.h
|
||||
|
||||
CFLAGS+= -DNS
|
||||
|
||||
.if ${MK_INET_SUPPORT} != "no"
|
||||
CFLAGS+= -DINET
|
||||
.endif
|
||||
.if ${MK_INET6_SUPPORT} != "no"
|
||||
CFLAGS+= -DINET6
|
||||
.endif
|
||||
|
||||
CFLAGS+= -I.
|
||||
|
||||
keywords.h: keywords
|
||||
sed -e '/^#/d' -e '/^$$/d' ${.CURDIR}/keywords > _keywords.tmp
|
||||
LC_ALL=C tr 'a-z' 'A-Z' < _keywords.tmp | paste _keywords.tmp - | \
|
||||
awk '{ \
|
||||
if (NF > 1) \
|
||||
printf "#define\tK_%s\t%d\n\t{\"%s\", K_%s},\n", \
|
||||
$$2, NR, $$1, $$2 }' \
|
||||
> ${.TARGET}
|
||||
rm -f _keywords.tmp
|
||||
LC_ALL=C awk '!/^#|^$$/ { \
|
||||
printf "#define\tK_%s\t%d\n\t{\"%s\", K_%s},\n", \
|
||||
toupper($$1), ++L, $$1, toupper($$1); \
|
||||
}' < ${.CURDIR}/keywords > ${.TARGET} || (rm -f ${.TARGET}; false)
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@
|
||||
SUBDIR= intel_ipw \
|
||||
intel_iwi \
|
||||
intel_iwn \
|
||||
intel_wpi
|
||||
intel_wpi \
|
||||
realtek
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user