Commit Graph

326 Commits

Author SHA1 Message Date
Jeff Walden
0eefeabe25 Bug 1445024 - Implement mozilla::WrappingSubtract. r=froydnj
--HG--
extra : rebase_source : 026268df1cb1cfc56873e61834ea90257645c508
2018-03-06 19:22:20 -08:00
Jeff Walden
52d9907ee0 Bug 1445024 - Implement mozilla::WrappingAdd. r=froydnj
--HG--
extra : rebase_source : 3514c6487305e64ce19060cb05d39bc6eb2fd912
2018-03-06 19:21:58 -08:00
Jeff Walden
15bf6fd876 Bug 1442967 - Boo, MSVC warns when a cast will truncate a numeric constant. Arguably a desirable warning generally, but here we specifically intend the cast to narrow, so disable the warning. r=me in a CLOSED TREE 2018-03-12 19:20:42 -07:00
Jeff Walden
fc7dc7e60e Bug 1442967 - When doing a comparison against a 64-bit constant in code run only in 64-bit builds, but compiled in 32-bit builds, cast it to uintptr_t so that the comparison isn't clearly false in 32-bit builds. rs=froydnj by suggestion on IRC
--HG--
extra : rebase_source : 2be98a1a0c436664ea0fa3ef8be55a9fb71541af
2018-03-12 13:36:44 -07:00
Jeff Walden
1b063823be Bug 1442967 - Futz with a uintptr_t (as uint32_t) == uint64_t comparison to evade constantly-false compiler warnings in 32-bit builds. r=jorendorff 2018-03-09 21:59:08 -08:00
Jason Orendorff
ef8693d6f2 Bug 1413049 - Part 1a: In a test, zero-pad hex integer constants to the width of their type. r=Waldo.
--HG--
extra : rebase_source : dfd3f1a00470856a177a526d385dd0f1b7d0ec38
2018-03-01 20:06:37 -06:00
Jason Orendorff
2418dfb4b3 Bug 1413049 - Part 1: Add methods to EndianUtils for pointer-sized integers. r=Waldo.
--HG--
extra : rebase_source : 115e40ecaee589b07e4ff9534694e56af7690e9b
2018-03-01 11:05:13 -06:00
Jeff Walden
25a7df6306 Bug 1441657 - Implement mozilla::WrappingMultiply. r=froydnj
--HG--
extra : rebase_source : 57d1796976a25597ee4dda90561d40debc6a9fc9
2018-02-15 17:36:55 -08:00
Jeff Walden
b0074d3a7d Bug 1441657 - Create a new mozilla/WrappingOperations.h header to contain implementations of common math operations with well-defined wraparound semantics. r=froydnj
--HG--
rename : mfbt/MathAlgorithms.h => mfbt/WrappingOperations.h
rename : mfbt/tests/TestMathAlgorithms.cpp => mfbt/tests/TestWrappingOperations.cpp
extra : rebase_source : 552a0f17d7ba2ad6229d45fd2945592aceabb354
2018-02-15 17:36:50 -08:00
Jeff Walden
1b16de9738 Bug 744965 - Implement mozilla::NumberEqualsInt32 in a way that doesn't depend on undefined behavior casting an out-of-range floating point number to int32_t. r=froydnj
--HG--
extra : rebase_source : dc4781e2a31ee0e75fc62951cbdc71eaa9fd7b1c
2018-02-15 17:22:14 -08:00
Cosmin Sabou
48de1e7807 Backed out changeset 1fcc972d445b (bug 744965) for assertion failures on TestFloatingPoint.cpp on a CLOSED TREE 2018-02-21 10:12:45 +02:00
Jeff Walden
e77ef331a3 Bug 744965 - Implement mozilla::NumberEqualsInt32 in a way that doesn't depend on undefined behavior casting an out-of-range floating point number to int32_t. r=froydnj
--HG--
extra : rebase_source : d6d890b7b20d93297f575abe838e8619418ea545
2018-02-15 17:22:14 -08:00
Jeff Walden
51f84c53a8 Bug 1432646 - Followup bustage fix for compilers that warn (error with -Werror-alike) when negating an unsigned expression. r=bustage in a CLOSED TREE 2018-01-27 00:25:40 -08:00
Jeff Walden
8314131139 Bug 1432646 - Implement mozilla::WrapToSigned. r=froydnj
--HG--
extra : rebase_source : 2c1a216830767da789eea59d00b55a45845f4d60
2018-01-25 14:48:01 -08:00
Chris Peterson
37efe4d0e6 Bug 1428535 - Add missing override specifiers to overridden virtual functions. r=froydnj
MozReview-Commit-ID: DCPTnyBooIe

--HG--
extra : rebase_source : cfec2d96faeb11656d86d760a34e0a04cacddb13
extra : intermediate-source : 6176724d63788b0fe8caa3f91607c2d93dbaa7ec
extra : source : eebbb0600447f9b64aae3bcd47b4be66c02a51ea
2017-11-05 19:37:28 -08:00
Sylvestre Ledru
c911c249ec Bug 1424866 - Update the comment for fix a warning: unnecessary parentheses in declaration of 'type name' r=gerald DONTBUILD 2018-01-04 11:59:13 +01:00
Sylvestre Ledru
530203c95e Bug 1424866 - Fix a warning: unnecessary parentheses in declaration of 'type name' r=gerald
MozReview-Commit-ID: CBOTKHgqDfV

--HG--
extra : rebase_source : cc9d339008e7024b5406153bad37e4d717c7ae59
2018-01-03 17:43:04 +01:00
Sylvestre Ledru
5de63ef061 Bug 1394734 - Replace CONFIG['MSVC'] by CONFIG['CC_TYPE'] r=glandium
MozReview-Commit-ID: 5orfnoude7h

--HG--
extra : rebase_source : 1ed9a6b56e1d27221a07624767a7fb0e6147117f
2017-12-08 13:46:13 +01:00
Sylvestre Ledru
9bfe27d903 Bug 1394734 - Replace CONFIG['GNU_C*'] by CONFIG['CC_TYPE'] r=glandium
MozReview-Commit-ID: 7duJk2gSd4m

--HG--
extra : rebase_source : 7312fe276e561e8c034a5f6749774ae812727f9c
2017-12-07 22:09:15 +01:00
Alfredo.Yang
0000c37a97 Bug 1419682 - add unwrap_or() for Result. r=Waldo
MozReview-Commit-ID: FmPvPzUmN9j

--HG--
extra : rebase_source : d5d3b3ca42b839b82886512ada8bc49551a60d8a
2017-11-22 17:14:28 +08:00
Gerald Squelart
5bea7c3a56 Bug 1410252 - MakeNotNull<PointerType, OptionalPointeeType>(Args...) - r=njn
MakeNotNull is similar to UniquePtr, in that it combines the infallible
allocation and construction of an object on the heap and wraps the (raw or
smart) pointer into a NotNull.
It skips the unnecessary null check from WrapNotNull, and removes the usual
naked 'new' used in many WrapNotNull calls.

MozReview-Commit-ID: UwCrhDnkUg

--HG--
extra : rebase_source : 5a027165fc17ed748783c7ffda03eb421865ad6e
2017-10-20 14:56:01 +11:00
Lee Salzman
70cd2a8499 Bug 1404742 - add test for ThreadSafeWeakPtr. r=nfroyd
MozReview-Commit-ID: GkNXsTLcN7m
2017-10-18 14:21:27 -04:00
Mike Hommey
9f2dd4775e Bug 1407468 - Replace multiple !JS_STANDALONE with MOZ_WIDGET_TOOLKIT. r=mshal
--HG--
extra : rebase_source : 4f9f9f583c3422ed0f8d1d65ea8e7575bd9baf2c
2017-10-05 14:50:01 +09:00
Chris Peterson
a48326552c Bug 1405582 - Span: delete implicit constructors for char* and char16_t*. r=froydnj,hsivonen
Delete Span's implicit constructors for char* and char16_t* pointers to avoid accidental construction in cases where a pointer does not point to a zero-terminated string. Use the MakeStringSpan() function instead.

I deleted both the const and non-const char* and char16_t* constructors, in the name of cross-compiler consistency. If we only delete the const char* and char16_t* constructors, for some reason, MSVC complains that `Span<char> s(charArray)` uses a deleted constructor while clang nor gcc permit it. I don't know if this is a compiler bug in MSVC or clang and gcc.

Also, do not permit MakeSpan() for string literals (const char and char16_t arrays) because the Span length would include the zero terminator, which may surprise callers. Use MakeStringSpan() to create a Span whose length that excludes the string literal's zero terminator or use the MakeSpan() overload that accepts a pointer and length and specify the string literal's full length.

The following Span usages are prevented:

  Span<const char> span("literal"); // error
  Span<char> span(charArray); // error

  Span<const char> span;
  span = "literal"; // error
  span = charArray; // error

  MakeSpan("literal"); // error

The following Span usages are still permitted:

  assert(MakeStringSpan("literal") == 8); // OK: span length is calculated with strlen() and excludes the zero terminator
  MakeStringSpan(charArray); // OK: span length is calculated with strlen() and excludes the zero terminator
  MakeSpan(charArray); // OK: span length is the char array size including any zero terminator

MozReview-Commit-ID: Et71CpjsiyI

--HG--
extra : rebase_source : f6f8bdb28726f0f2368fdfdd039fb1d7dcf2914e
extra : source : 0547d8924ffc7713d6cf32cc06eeeaf00e0d69a3
2017-09-20 00:38:07 -07:00
Luke Wagner
bb375a16d4 Bug 1329019 - Allow specifying capacity to Vector::replaceRawBuffer (r=froydnj)
MozReview-Commit-ID: 9Eq6PR53n4i
2017-09-22 10:34:24 -05:00
Luke Wagner
231c33a9fe Bug 1329019 - Vector::podResizeToFit should update reserved (r=froydnj)
MozReview-Commit-ID: CkoNRjxmjom
2017-09-22 10:33:36 -05:00
Matt Woodrow
a56e3551a2 Bug 1397056 - Add Contains and a return parameter to Remove for SmallPointerArray. r=froydnj
* * *
[mq]: fix

MozReview-Commit-ID: 5laM7PQLP7X
2017-09-12 14:11:47 -04:00
Wes Kocher
b1233c7d04 Backed out changeset 371a03aa9b24 (bug 1397056) for build errors in SmallPointerArray.h a=backout CLOSED TREE
MozReview-Commit-ID: FNVPjKmVCWB

--HG--
extra : rebase_source : 41e380e59d9eead945ba515d85c1b9195329bc74
2017-09-12 12:39:09 -07:00
Matt Woodrow
5675f29866 Bug 1397056 - Add Contains and a return parameter to Remove for SmallPointerArray. r=froydnj
* * *
[mq]: fix

MozReview-Commit-ID: 5laM7PQLP7X

--HG--
extra : rebase_source : f1baa7c1581fcc864d2b548989e967f57e24b921
2017-09-12 14:11:47 -04:00
Mike Hommey
0d8ed2b1a5 Bug 1396723 - Simplify the trait users of DoublyLinkedList need to define. r=froydnj
While the flexibility of the current trait is nice, it's actually not
used to its fullest anywhere, and is boilerplate-y. While it is useful
to be able to put the links anywhere, there's not much usefulness from
being able to split mNext and mPrev.

So instead of a trait that allows to get/set mNext and mPrev
independently, we just use a trait that tells how to get a reference to
a DoublyLinkedListElement from a list element itself.

--HG--
extra : rebase_source : 674277bac4fc979f2e483a77b5ef1495baccc7fe
2017-09-02 08:09:58 +09:00
Chris Manchester
c0a229d4c3 Bug 1386876 - Replace all uses of DISABLE_STL_WRAPPING with a template, remove DISABLE_STL_WRAPPING. r=glandium
MozReview-Commit-ID: FMEtb5PY7iP

--HG--
extra : rebase_source : 3cdee7528846462c758e623d6bcd2e6e17dbabff
2017-09-11 11:33:26 -07:00
Phil Ringnalda
bc78097d88 Backed out 2 changesets (bug 1396723) for !ElementAccess::Get(mHead).mPrev assertion failures
Backed out changeset 4f17343164b6 (bug 1396723)
Backed out changeset b744eba9ca78 (bug 1396723)

MozReview-Commit-ID: JbvM6oMxEFl
2017-09-06 21:39:20 -07:00
Mike Hommey
b16f4035ba Bug 1396723 - Simplify the trait users of DoublyLinkedList need to define. r=froydnj
While the flexibility of the current trait is nice, it's actually not
used to its fullest anywhere, and is boilerplate-y. While it is useful
to be able to put the links anywhere, there's not much usefulness from
being able to split mNext and mPrev.

So instead of a trait that allows to get/set mNext and mPrev
independently, we just use a trait that tells how to get a reference to
a DoublyLinkedListElement from a list element itself.

--HG--
extra : rebase_source : f84c5799c305a4a3b7dc5deb727a05d4d537bb15
2017-09-02 08:09:58 +09:00
Wes Kocher
f66c96f2c8 Backed out 2 changesets (bug 1396723) for build failures in TestDoublyLinkedList.cpp a=backout
Backed out changeset 1c0f9d069ade (bug 1396723)
Backed out changeset 6ca94a450b81 (bug 1396723)

MozReview-Commit-ID: 2w3WTvhpg6J
2017-09-06 14:30:41 -07:00
Mike Hommey
9a3dd41f50 Bug 1396723 - Simplify the trait users of DoublyLinkedList need to define. r=froydnj
While the flexibility of the current trait is nice, it's actually not
used to its fullest anywhere, and is boilerplate-y. While it is useful
to be able to put the links anywhere, there's not much usefulness from
being able to split mNext and mPrev.

So instead of a trait that allows to get/set mNext and mPrev
independently, we just use a trait that tells how to get a reference to
a DoublyLinkedListElement from a list element itself.

--HG--
extra : rebase_source : b7d502754a764670e291acdd56726948db935497
2017-09-02 08:09:58 +09:00
Botond Ballo
2c2d3ded79 Bug 1371771 - Add a MOZ_DEFINE_ENUM macro and variants to MFBT. r=froydnj
The macro simultaneously declares an enumeration and a count of its
enumerators.

A few variants of the macro are also provided to handle things like
enum classes, underlying types, and enumerations declared at class
scope.

MozReview-Commit-ID: 3z6yHnfXbLj

--HG--
extra : rebase_source : 92c333693e4bbf85b89cd3d7ac5b31f4b5434367
2017-06-30 19:58:11 -04:00
Chris Peterson
0a377e9314 Bug 1373525 - mfbt: Use unused GetPrev() member function in DoublyLinkedList test. r=froydnj
mfbt/tests/TestDoublyLinkedList.cpp:138:24 [-Wunused-member-function] unused member function 'GetPrev'

MozReview-Commit-ID: HQuTw0vXRKV

--HG--
extra : source : 0db3bd8a40d67a81b2f224dc9e63012cb832d0b9
extra : intermediate-source : 948c43ff15b4ca1a3db335544494562ec28e67cc
2017-06-11 14:39:42 -07:00
Petr Sumbera
80944c40d8 Bug 1158445 - posix_madvise() should be used instead of madvise on Solaris. r=froydnj, r=jandem 2017-06-09 00:59:32 -07:00
Henri Sivonen
854d241f4f Bug 1359874 - Make Span::Elements() always return a non-null pointer. r=froydnj.
MozReview-Commit-ID: AGvNlHmonpi
2017-06-13 13:22:34 +03:00
Gerald Squelart
f5f8abf86a Bug 1338389 - Tests for Variant's detail::Nth and detail::SelectVariantType - r=froydnj
MozReview-Commit-ID: 4QXdctmhNze

--HG--
extra : rebase_source : ddbdf8c79f49ebb02c9e68dca0be4a6ee9ad11f4
2017-06-06 16:59:00 +12:00
Gerald Squelart
a7c6eed190 Bug 1338389 - VariantType<T> and VariantIndex<N> permit unambiguous and variadic Variant construction - r=froydnj
MozReview-Commit-ID: 3rDya9ZBG6Y

--HG--
extra : rebase_source : d59375a7c805d6d470f5074669f3db5a609eb518
2017-05-08 11:26:07 +12:00
Gerald Squelart
78bc93af40 Bug 1338389 - Allow repeated Variant types, but prevent is/as/extract<T> for them - r=froydnj
MozReview-Commit-ID: 1yEUuGsht8k

--HG--
extra : rebase_source : fed56f264821e87cc474e6686e6dc203c147ac9b
2017-05-10 15:49:38 +12:00
Gerald Squelart
6015fbb5ac Bug 1338389 - Index-based Variant::is<N>, as<N>, and extract<N> - r=froydnj
MozReview-Commit-ID: C5iga0Eb1tH

--HG--
extra : rebase_source : d88cf614318cc8544d7ab52315e015a7ca4e5efd
2017-05-08 11:09:21 +12:00
Mike Hommey
38a6de0fe3 Bug 1369622 - Fix MOZ_FOR_EACH with an empty list. r=froydnj
I'm not sure how I tested MOZ_FOR_EACH in bug 1368932, but it turns out
it doesn't work with an empty list, despite
MOZ_PASTE_PREFIX_AND_ARG_COUNT now supporting 0 arguments.

Macros can be tricky, and it ends up being easier to make things work
cross-compiler with a separate macro that does the counting, and
(re)building MOZ_PASTE_PREFIX_AND_ARG_COUNT on top of that. Then
MOZ_FOR_EACH ends up working as expected with an empty list.

So this adds a MOZ_ARG_COUNT macro that counts the number of variadic
arguments it's given, and derives MOZ_PASTE_PREFIX_AND_ARG_COUNT from
it.

And this adds a testcase validating that MOZ_FOR_EACH works properly
with an empty list as a result.

--HG--
extra : rebase_source : 309371d87bd1561fbd2153f44fc1256185045d23
2017-06-02 14:53:54 +09:00
Mike Hommey
c1becb4a54 Bug 1368932 - Allow MOZ_PASTE_PREFIX_AND_ARG_COUNT to work with 0 arguments. r=froydnj
At the same time, remove the MOZ_STATIC_ASSERT_VALID_ARG_COUNT, which
doesn't actually work for more than 50 arguments(*), and which is now not
useful to detect 0 arguments.

(*) the build fails, but not directly thanks to the static_assert it
expands to.

--HG--
extra : rebase_source : 8f0fe7b352c89b5a3ec87f42ef5464c370c362ef
2017-05-25 15:47:21 +09:00
Bas Schouten
5a025e5c1f Bug 1331718 - Part 2: Add unit tests for SmallPointerArray. r=froydnj
MozReview-Commit-ID: 7xdQfv7Dpph
2017-05-10 05:07:38 +02:00
Carsten "Tomcat" Book
157a9fcde2 Backed out changeset 4527bd35cc4e (bug 1331718) 2017-05-10 12:09:06 +02:00
Bas Schouten
e8f8394b4e Bug 1331718 - Part 2: Add unit tests for SmallPointerArray. r=froydnj
MozReview-Commit-ID: 7xdQfv7Dpph
2017-05-10 05:07:38 +02:00
Olli Pettay
a991315918 Bug 1358761 - dummy handling for return values in test, r=bustage 2017-05-05 10:43:37 +03:00
Olli Pettay
0096f25b51 Bug 1358761 - replace PurpleBlock with SegmentedVector to reduce indirect memory accesses when calling suspect, r=mccr8,nfroyd
--HG--
extra : rebase_source : e74be6bfb9efbba9361d2ce3c22518379a332200
2017-05-05 00:49:22 +03:00