Files
roytam1 b383d6bc2f import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1161101 - Use JS_GetOwnPropertyDescriptor instead of GetPropertyDescriptor in dom/bindings. r=bz (918d7961c)
- Bug 1119387 part 5: Update docker images. (0d47fde65)
- Bug 1144463 - Add dolphin-512 and update docker. r=jlal,wcosta (aa6a55cab)
- Bug 1134226: Add lightsaber nightly builds. (7926eff96)
- Bug 1151981 - Properly check for MSVC (mingw fixup). (d95e17266)
- Bug 1154947 part 3: Add aries nightly user, userdebug and eng builds. (45e096ed6)
- Bug 1178932 - Implement Reflect.construct. r=Waldo. (4c5f0e72e)
- Bug 1131206 - Remove the less useful commands from taskcluster mach r=garndt (e4c8ed78a)
- Bug 1131206 - Select mozharness version from in tree r=garndt (fdab5140d)
- bug 1156816 - Fix scopes for aws-provisioner. Switch nightly builds to production balrog. r=garndt (561d5cd58)
- Bug 1166073 - change docker registry to hub r=garndt (17faea355)
- Bug 1166233: Bring taskcluster-build mach command back. (c0a719c6b)
- Bug 1142779 - Add buildbot steps for cloning and running tests r=lightsofapollo (304235375)
- Bug 1142779 - Update job tasks to include functional unit and dual sim r=lightsofapollo (09b320602)
- Bug 1147605 - Disable tests on phone builds r=me CLOSED TREE (0912de6ba)
- Bug 1142779 - Update job tasks to use new chunking logic r=lightsofapollo (70c531920)
- Bug 1144994 part 1: Update provisioner. (2447affa4)
- Bug 1144994 part 2: Switch aries nightlies from cypress to m-c. (3019a6878)
- Bug 1164939: Provide flame-kk user, userdebug and eng builds. (ab7ad22a7)
- goanna->gecko (70b49bb18)
- Bug 1166745: Reorganize tasks. (d3090e0a9)
- Bug 1170378: Create tasks timestamps in UTC. r=jonasfj a=jonasfj (60160f061)
- Bug 987902 - Add a "doctor" mach command; r=gps (be60e7df6)
- Bug 985857 - Automatically log mach output and add a command to display it. r=gps (90993b77f)
- Bug 991983 - Add a ContextDerivedTypedListWithItems type. r=gps (ad9482c7b)
- Bug 991983 - Don't pass template paths to contexts. r=gps (30a4f2038)
- Bug 991983 - Refactor SourcePath handling for moz.build, add new classes and extensive tests. r=gps (00aeb401b)
- Bug 1142494 - Only package the steeplechase tests if webrtc is enabled. r=ted, f=drno (760943034)
- Bug 1142494 - Fix OSX packaging mistake. r=glandium, a=bustage (03cd3ca35)
- Bug 1147029 - Land luciddream in-tree, r=ted (8a4d2651b)
- Bug 1147031 - Write mach command for luciddream. r=jgriffin (b913c4df4)
- Bug 1171446 - Add a description to the luciddream mach target r=ochameau (c807799b6)
- Bug 1176642 - Remove unused imports; r=glandium (b0e458f5d)
- Bug 1151080: Rewrite NR_async_timer_set(0) to use direct dispatch. r=mt (6c3dda54d)
- Bug 1152185 - Include port/generic/include also for mtransport/test and webrtc/signaling/test. r=ekr (969ce4205)
- Bug 1156621 - Don't assume --without-system-nspr. r=glandium (4cf9c3e76)
- Bug 1035468: A NAT simulator based on NrSocket, and integrate into ice_unittest. r=ekr (903d8f6c8)
- Bug 1162026 - move WrapRunnable &co over to variadic templates; r=ekr (6224de8e9)
- Bug 1163328 - Add a Tuple class to MFBT. r=froydnj (ba3276ef3)
- Bug 1163328 - Add an And<...> class to TemplateLib.h which performs logical and on a variadic number of booleans known at compile time. r=froydnj (ac3afcabd)
- Bug 1175621 - make WrapRunnable* more efficient by utilizing moves in wrapper functions; r=ekr (15cf9f55a)
2020-11-27 09:26:17 +08:00

134 lines
3.4 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Reusable template meta-functions on types and compile-time values. Meta-
* functions are placed inside the 'tl' namespace to avoid conflict with non-
* meta functions of the same name (e.g., mozilla::tl::FloorLog2 vs.
* mozilla::FloorLog2).
*
* When constexpr support becomes universal, we should probably use that instead
* of some of these templates, for simplicity.
*/
#ifndef mozilla_TemplateLib_h
#define mozilla_TemplateLib_h
#include <limits.h>
#include <stddef.h>
#include "mozilla/TypeTraits.h"
namespace mozilla {
namespace tl {
/** Compute min/max. */
template<size_t I, size_t J>
struct Min
{
static const size_t value = I < J ? I : J;
};
template<size_t I, size_t J>
struct Max
{
static const size_t value = I > J ? I : J;
};
/** Compute floor(log2(i)). */
template<size_t I>
struct FloorLog2
{
static const size_t value = 1 + FloorLog2<I / 2>::value;
};
template<> struct FloorLog2<0> { /* Error */ };
template<> struct FloorLog2<1> { static const size_t value = 0; };
/** Compute ceiling(log2(i)). */
template<size_t I>
struct CeilingLog2
{
static const size_t value = FloorLog2<2 * I - 1>::value;
};
/** Round up to the nearest power of 2. */
template<size_t I>
struct RoundUpPow2
{
static const size_t value = size_t(1) << CeilingLog2<I>::value;
};
template<>
struct RoundUpPow2<0>
{
static const size_t value = 1;
};
/** Compute the number of bits in the given unsigned type. */
template<typename T>
struct BitSize
{
static const size_t value = sizeof(T) * CHAR_BIT;
};
/**
* Produce an N-bit mask, where N <= BitSize<size_t>::value. Handle the
* language-undefined edge case when N = BitSize<size_t>::value.
*/
template<size_t N>
struct NBitMask
{
// Assert the precondition. On success this evaluates to 0. Otherwise it
// triggers divide-by-zero at compile time: a guaranteed compile error in
// C++11, and usually one in C++98. Add this value to |value| to assure
// its computation.
static const size_t checkPrecondition =
0 / size_t(N < BitSize<size_t>::value);
static const size_t value = (size_t(1) << N) - 1 + checkPrecondition;
};
template<>
struct NBitMask<BitSize<size_t>::value>
{
static const size_t value = size_t(-1);
};
/**
* For the unsigned integral type size_t, compute a mask M for N such that
* for all X, !(X & M) implies X * N will not overflow (w.r.t size_t)
*/
template<size_t N>
struct MulOverflowMask
{
static const size_t value =
~NBitMask<BitSize<size_t>::value - CeilingLog2<N>::value>::value;
};
template<> struct MulOverflowMask<0> { /* Error */ };
template<> struct MulOverflowMask<1> { static const size_t value = 0; };
/**
* And<bool...> computes the logical 'and' of its argument booleans.
*
* Examples:
* mozilla::t1::And<true, true>::value is true.
* mozilla::t1::And<true, false>::value is false.
* mozilla::t1::And<>::value is true.
*/
template<bool...>
struct And;
template<>
struct And<> : public TrueType { };
template<bool C1, bool... Cn>
struct And<C1, Cn...>
: public Conditional<C1, And<Cn...>, FalseType>::Type { };
} // namespace tl
} // namespace mozilla
#endif /* mozilla_TemplateLib_h */