Skip to content

Commit

Permalink
Update cstdint / cstddef includes
Browse files Browse the repository at this point in the history
Update uses of std::-qualified integer types such as std::ptrdiff_t, etc. to non std::-qualified types.
Update some BUILD rules.

mingw headers export some types only in the std:: namespace, so be consistent.

PiperOrigin-RevId: 695094623
Change-Id: I61318569c0564d108de7b1ac9970f3628f7cd19b
  • Loading branch information
laramiel authored and copybara-github committed Nov 10, 2024
1 parent 6ee275b commit 059955b
Show file tree
Hide file tree
Showing 275 changed files with 1,023 additions and 832 deletions.
2 changes: 1 addition & 1 deletion examples/compute_percentiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// limitations under the License.

#include <math.h>
#include <stddef.h>

#include <algorithm>
#include <cstddef>
#include <iostream>
#include <list>
#include <string>
Expand Down
1 change: 1 addition & 0 deletions python/tensorstore/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ pybind11_cc_library(
"//tensorstore/util:future",
"//tensorstore/util:str_cat",
"//tensorstore/util/garbage_collection",
"@com_github_nlohmann_json//:json",
"@com_github_pybind_pybind11//:pybind11",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings:cord",
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/array_type_caster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
#include "python/tensorstore/array_type_caster.h"

// Other headers
#include <stddef.h>

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <exception>
#include <memory>
#include <optional>
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/data_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
#include "python/tensorstore/data_type.h"

// Other headers
#include <stddef.h>

#include <array>
#include <cassert>
#include <cstddef>
#include <string>
#include <string_view>
#include <utility>
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
// Other headers must be included after pybind11 to ensure header-order
// inclusion constraints are satisfied.

#include <stddef.h>

#include <array>
#include <complex>
#include <cstddef>
#include <string_view>

#include "tensorstore/data_type.h"
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/dim_expression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include "python/tensorstore/dim_expression.h"

// Other headers
#include <cstddef>
#include <stddef.h>

#include <iterator>
#include <memory>
#include <optional>
Expand Down
1 change: 0 additions & 1 deletion python/tensorstore/future.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <algorithm>
#include <cassert>
#include <cerrno>
#include <cstddef>
#include <optional>
#include <utility>

Expand Down
2 changes: 1 addition & 1 deletion python/tensorstore/homogeneous_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// Other headers must be included after pybind11 to ensure header-order
// inclusion constraints are satisfied.

#include <cstddef>
#include <stddef.h>

#include "python/tensorstore/type_name_override.h"
#include "tensorstore/util/span.h"
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#include "python/tensorstore/index.h"

// Other headers
#include <cstddef>
#include <stddef.h>

#include <string>
#include <variant>
#include <vector>
Expand Down
5 changes: 3 additions & 2 deletions python/tensorstore/index_space.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
// Other headers must be included after pybind11 to ensure header-order
// inclusion constraints are satisfied.

#include <cstddef>
#include <cstdint>
#include <stddef.h>
#include <stdint.h>

#include <optional>
#include <utility>

Expand Down
5 changes: 3 additions & 2 deletions python/tensorstore/json_type_caster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include "python/tensorstore/json_type_caster.h"

// Other headers
#include <cstdint>
#include <stdint.h>

#include <string>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -105,7 +106,7 @@ ::nlohmann::json PyObjectToJsonInteger(py::handle h) {
PyErr_Clear();
if (auto v = PyLong_AsLongLong(h.ptr());
v != static_cast<decltype(v)>(-1) || !PyErr_Occurred()) {
return static_cast<std::int64_t>(v);
return static_cast<int64_t>(v);
}
throw py::error_already_set();
}
Expand Down
4 changes: 3 additions & 1 deletion python/tensorstore/kvstore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include "python/tensorstore/kvstore.h"

// Other headers
#include <cstddef>
#include <stddef.h>

#include <limits>
#include <optional>
#include <string>
Expand All @@ -31,6 +32,7 @@

#include "absl/status/status.h"
#include "absl/strings/cord.h"
#include <nlohmann/json_fwd.hpp>
#include "python/tensorstore/batch.h"
#include "python/tensorstore/context.h"
#include "python/tensorstore/define_heap_type.h"
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/numpy_indexing_spec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
#include "python/tensorstore/numpy_indexing_spec.h"

// Other headers
#include <stddef.h>

#include <algorithm>
#include <cstddef>
#include <string>
#include <string_view>
#include <utility>
Expand Down
5 changes: 3 additions & 2 deletions python/tensorstore/sequence_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
// Other headers must be included after pybind11 to ensure header-order
// inclusion constraints are satisfied.

#include <cstddef>
#include <pybind11/stl.h>
#include <stddef.h>

#include <vector>

#include "python/tensorstore/type_name_override.h"
#include <pybind11/stl.h>

namespace tensorstore {
namespace internal_python {
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/serialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#include "python/tensorstore/serialization.h"

// Other headers
#include <cstddef>
#include <stddef.h>

#include <memory>
#include <string_view>
#include <typeinfo>
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
// Other headers must be included after pybind11 to ensure header-order
// inclusion constraints are satisfied.

#include <cstddef>
#include <stddef.h>

#include <optional>
#include <utility>
#include <vector>
Expand Down
3 changes: 2 additions & 1 deletion python/tensorstore/status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
#include "python/tensorstore/status.h"

// Other headers
#include <stddef.h>

#include <cassert>
#include <cstddef>
#include <string>
#include <string_view>

Expand Down
2 changes: 0 additions & 2 deletions tensorstore/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ tensorstore_cc_test(
"//tensorstore/util:span",
"//tensorstore/util:status_testutil",
"//tensorstore/util:str_cat",
"@com_github_nlohmann_json//:json",
"@com_google_absl//absl/random",
"@com_google_absl//absl/random:bit_gen_ref",
"@com_google_absl//absl/status",
"@com_google_googletest//:gtest_main",
Expand Down
5 changes: 2 additions & 3 deletions tensorstore/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@

#include "tensorstore/array.h"

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstddef> // for std::byte
#include <limits>
#include <memory>
#include <random>
Expand All @@ -31,9 +32,7 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "absl/random/bit_gen_ref.h"
#include "absl/random/random.h"
#include "absl/status/status.h"
#include <nlohmann/json.hpp>
#include "tensorstore/box.h"
#include "tensorstore/container_kind.h"
#include "tensorstore/contiguous_layout.h"
Expand Down
5 changes: 3 additions & 2 deletions tensorstore/array_testutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
/// \file
/// Define a GMock matcher for `tensorstore::Array`.

#include <cstddef>
#include <stddef.h>

#include <ostream>
#include <string>
#include <vector>
Expand Down Expand Up @@ -209,7 +210,7 @@ ArrayMatcher MatchesArray(
///
/// \param origin The expected origin vector of the array.
/// \param element_matchers The matchers for each element of the array.
template <typename Element, Index N0, std::ptrdiff_t OriginRank>
template <typename Element, Index N0, ptrdiff_t OriginRank>
ArrayMatcher MatchesArray(
const Index (&origin)[OriginRank],
const ::testing::Matcher<Element> (&element_matchers)[N0]) {
Expand Down
6 changes: 3 additions & 3 deletions tensorstore/array_testutil_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using ::tensorstore::MatchesScalarArray;

TEST(MatchesArrayTest, Describe) {
std::ostringstream ss;
MatchesArray<std::int32_t>({1, 2}).DescribeTo(&ss);
MatchesArray<int32_t>({1, 2}).DescribeTo(&ss);
EXPECT_EQ(
R"(has a data type of int32 and a domain of {origin={0}, shape={2}} where
element at {0} is equal to 1,
Expand All @@ -41,7 +41,7 @@ element at {1} is equal to 2)",

TEST(MatchesArrayTest, DescribeNegation) {
std::ostringstream ss;
MatchesArray<std::int32_t>({1, 2}).DescribeNegationTo(&ss);
MatchesArray<int32_t>({1, 2}).DescribeNegationTo(&ss);
EXPECT_EQ(R"(doesn't have a data type of int32, or
doesn't have a domain of {origin={0}, shape={2}}, or
element at {0} isn't equal to 1, or
Expand All @@ -51,7 +51,7 @@ element at {1} isn't equal to 2)",

TEST(MatchesArrayTest, ExplainDataTypeMismatch) {
::testing::StringMatchResultListener listener;
::testing::ExplainMatchResult(MatchesArray<std::int32_t>({1, 2, 3}),
::testing::ExplainMatchResult(MatchesArray<int32_t>({1, 2, 3}),
MakeArray<float>({1, 2}), &listener);
EXPECT_EQ("which has a data type of float32", listener.str());
}
Expand Down
3 changes: 2 additions & 1 deletion tensorstore/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

#include "tensorstore/context.h"

#include <stddef.h>

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <memory>
#include <string>
#include <string_view>
Expand Down
5 changes: 3 additions & 2 deletions tensorstore/context_impl_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

// IWYU pragma: private, include "third_party/tensorstore/context.h"

#include <cstdint>
#include <stdint.h>

#include <memory>
#include <string>
#include <string_view>
Expand Down Expand Up @@ -390,7 +391,7 @@ class ResourceProviderImpl : public ResourceProviderImplBase {
this->value_);
} else {
internal::EncodeCacheKey(out, ResourceSpecImplBase::kResource,
reinterpret_cast<std::uintptr_t>(this));
reinterpret_cast<uintptr_t>(this));
}
}
};
Expand Down
15 changes: 8 additions & 7 deletions tensorstore/context_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

#include "tensorstore/context.h"

#include <cstddef>
#include <cstdint>
#include <stddef.h>
#include <stdint.h>

#include <optional>
#include <string>
#include <tuple>
Expand Down Expand Up @@ -72,12 +73,12 @@ using ::tensorstore::serialization::SerializationRoundTrip;

struct IntResource : public ContextResourceTraits<IntResource> {
struct Spec {
std::int64_t value;
int64_t value;
constexpr static auto ApplyMembers = [](auto&& x, auto f) {
return f(x.value);
};
};
using Resource = std::int64_t;
using Resource = int64_t;
static constexpr char id[] = "int_resource";
static Spec Default() { return {42}; }
static constexpr auto JsonBinder() {
Expand All @@ -97,12 +98,12 @@ struct IntResource : public ContextResourceTraits<IntResource> {
struct IntConfigResource : public ContextResourceTraits<IntConfigResource> {
constexpr static bool config_only = true;
struct Spec {
std::int64_t value;
int64_t value;
constexpr static auto ApplyMembers = [](auto&& x, auto f) {
return f(x.value);
};
};
using Resource = std::int64_t;
using Resource = int64_t;
static constexpr char id[] = "int_config_resource";
static Spec Default() { return {42}; }
static constexpr auto JsonBinder() { return jb::Projection(&Spec::value); }
Expand All @@ -117,7 +118,7 @@ struct IntConfigResource : public ContextResourceTraits<IntConfigResource> {

struct StrongRefResource : public ContextResourceTraits<StrongRefResource> {
struct Spec {
std::int64_t value;
int64_t value;
constexpr static auto ApplyMembers = [](auto&& x, auto f) {
return f(x.value);
};
Expand Down
Loading

0 comments on commit 059955b

Please sign in to comment.