Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions libc/benchmarks/LibcBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ template <typename T> class CircularArrayRef {
size_t Offset;

public:
explicit const_iterator(llvm::ArrayRef<T> Array, size_t Index = 0)
: Array(Array), Index(Index), Offset(Index % Array.size()) {}
explicit const_iterator(llvm::ArrayRef<T> Arr, size_t Idx = 0)
: Array(Arr), Index(Idx), Offset(Idx % Arr.size()) {}
const_iterator &operator++() {
++Index;
++Offset;
Expand All @@ -293,9 +293,8 @@ template <typename T> class CircularArrayRef {
const T &operator*() const { return Array[Offset]; }
};

CircularArrayRef(llvm::ArrayRef<T> Array, size_t Size)
: Array(Array), Size(Size) {
assert(Array.size() > 0);
CircularArrayRef(llvm::ArrayRef<T> Arr, size_t S) : Array(Arr), Size(S) {
assert(Arr.size() > 0);
}

const_iterator begin() const { return const_iterator(Array); }
Expand Down
6 changes: 3 additions & 3 deletions libc/benchmarks/LibcMemoryBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ OffsetDistribution::OffsetDistribution(size_t BufferSize, size_t MaxSizeValue,
// Precomputes offset where to insert mismatches between the two buffers.
MismatchOffsetDistribution::MismatchOffsetDistribution(size_t BufferSize,
size_t MaxSizeValue,
size_t MismatchAt)
: MismatchAt(MismatchAt) {
if (MismatchAt <= 1)
size_t MisAt)
: MismatchAt(MisAt) {
if (MisAt <= 1)
return;
for (size_t i = MaxSizeValue + 1; i < BufferSize; i += MaxSizeValue)
MismatchIndices.push_back(i);
Expand Down
6 changes: 3 additions & 3 deletions libc/benchmarks/LibcMemoryBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ class AlignedBuffer {
public:
static constexpr size_t Alignment = 512;

explicit AlignedBuffer(size_t Size)
explicit AlignedBuffer(size_t S)
: Buffer(static_cast<char *>(
aligned_alloc(Alignment, alignTo(Size, Alignment)))),
Size(Size) {}
aligned_alloc(Alignment, alignTo(S, Alignment)))),
Size(S) {}
~AlignedBuffer() { free(Buffer); }

inline char *operator+(size_t Index) { return Buffer + Index; }
Expand Down
4 changes: 2 additions & 2 deletions libc/benchmarks/LibcMemoryBenchmarkMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ struct MemfunctionBenchmarkSweep final : public MemfunctionBenchmarkBase {

struct MemfunctionBenchmarkDistribution final
: public MemfunctionBenchmarkBase {
MemfunctionBenchmarkDistribution(MemorySizeDistribution Distribution)
: Distribution(Distribution), Probabilities(Distribution.Probabilities),
MemfunctionBenchmarkDistribution(MemorySizeDistribution Dist)
: Distribution(Dist), Probabilities(Distribution.Probabilities),
SizeSampler(Probabilities.begin(), Probabilities.end()),
OffsetSampler(MemfunctionBenchmarkBase::BufferSize,
Probabilities.size() - 1, MaybeAlign(AlignedAccess)) {}
Expand Down
8 changes: 4 additions & 4 deletions libc/benchmarks/gpu/LibcGpuBenchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ class Benchmark {
add_benchmark(this);
}

Benchmark(uint64_t (*f)(uint32_t), char const *suite_name,
char const *test_name, uint32_t num_threads)
: target(BenchmarkTarget(f)), suite_name(suite_name),
test_name(test_name), num_threads(num_threads) {
Benchmark(uint64_t (*f)(uint32_t), char const *suite, char const *test,
uint32_t n_threads)
: target(BenchmarkTarget(f)), suite_name(suite), test_name(test),
num_threads(n_threads) {
add_benchmark(this);
}

Expand Down
6 changes: 3 additions & 3 deletions libc/benchmarks/gpu/Random.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ template <typename T> class UniformExponent {
public:
explicit UniformExponent(int min_exp = -FPBits::EXP_BIAS,
int max_exp = FPBits::EXP_BIAS,
cpp::optional<Sign> forced_sign = cpp::nullopt)
cpp::optional<Sign> sign = cpp::nullopt)
: min_exp(clamp_exponent(cpp::min(min_exp, max_exp))),
max_exp(clamp_exponent(cpp::max(min_exp, max_exp))),
forced_sign(forced_sign) {}
max_exp(clamp_exponent(cpp::max(min_exp, max_exp))), forced_sign(sign) {
}

LIBC_INLINE T operator()(RandomGenerator &rng) const noexcept {
// Sample unbiased exponent e uniformly in [min_exp, max_exp] without modulo
Expand Down
2 changes: 1 addition & 1 deletion libc/fuzzing/__support/hashtable_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class HashTable {
public:
HashTable(uint64_t size, uint64_t seed)
: table(internal::HashTable::allocate(size, seed)) {}
HashTable(internal::HashTable *table) : table(table) {}
HashTable(internal::HashTable *t) : table(t) {}
~HashTable() { internal::HashTable::deallocate(table); }
HashTable(HashTable &&other) : table(other.table) { other.table = nullptr; }
bool is_valid() const { return table != nullptr; }
Expand Down
20 changes: 10 additions & 10 deletions libc/shared/rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ template <bool Invert> struct Process {
static constexpr uint64_t NUM_BITS_IN_WORD = sizeof(uint32_t) * 8;
uint32_t lock[MAX_PORT_COUNT / NUM_BITS_IN_WORD] = {0};

RPC_ATTRS Process(uint32_t port_count, void *buffer)
: port_count(port_count), inbox(reinterpret_cast<uint32_t *>(
advance(buffer, inbox_offset(port_count)))),
RPC_ATTRS Process(uint32_t n_ports, void *buffer)
: port_count(n_ports), inbox(reinterpret_cast<uint32_t *>(
advance(buffer, inbox_offset(n_ports)))),
outbox(reinterpret_cast<uint32_t *>(
advance(buffer, outbox_offset(port_count)))),
advance(buffer, outbox_offset(n_ports)))),
header(reinterpret_cast<Header *>(
advance(buffer, header_offset(port_count)))),
advance(buffer, header_offset(n_ports)))),
packet(reinterpret_cast<Buffer *>(
advance(buffer, buffer_offset(port_count)))) {}
advance(buffer, buffer_offset(n_ports)))) {}

/// Allocate a memory buffer sufficient to store the following equivalent
/// representation in memory.
Expand Down Expand Up @@ -292,10 +292,10 @@ RPC_ATTRS static void invoke_rpc(F &&fn, uint32_t lane_size, uint64_t lane_mask,
/// processes. A port is conceptually an index into the memory provided by the
/// underlying process that is guarded by a lock bit.
template <bool T> struct Port {
RPC_ATTRS Port(Process<T> &process, uint64_t lane_mask, uint32_t lane_size,
uint32_t index, uint32_t out)
: process(process), lane_mask(lane_mask), lane_size(lane_size),
index(index), out(out), receive(false), owns_buffer(true) {}
RPC_ATTRS Port(Process<T> &proc, uint64_t l_mask, uint32_t l_size,
uint32_t idx, uint32_t o)
: process(proc), lane_mask(l_mask), lane_size(l_size), index(idx), out(o),
receive(false), owns_buffer(true) {}
RPC_ATTRS ~Port() = default;

private:
Expand Down
4 changes: 2 additions & 2 deletions libc/src/__support/CPP/expected.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ template <class T> class unexpected {
T value;

public:
LIBC_INLINE constexpr explicit unexpected(T value) : value(value) {}
LIBC_INLINE constexpr explicit unexpected(T val) : value(val) {}
LIBC_INLINE constexpr T error() { return value; }
};

Expand All @@ -35,7 +35,7 @@ template <class T, class E> class expected {
bool is_expected;

public:
LIBC_INLINE constexpr expected(T exp) : exp(exp), is_expected(true) {}
LIBC_INLINE constexpr expected(T e) : exp(e), is_expected(true) {}
LIBC_INLINE constexpr expected(unexpected<E> unexp)
: unexp(unexp.error()), is_expected(false) {}

Expand Down
6 changes: 3 additions & 3 deletions libc/src/__support/FPUtil/FPBits.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ template <FPType fp_type> struct FPStorage : public FPLayout<fp_type> {
// different semantics.
template <typename T> struct TypedInt {
using value_type = T;
LIBC_INLINE constexpr explicit TypedInt(T value) : value(value) {}
LIBC_INLINE constexpr TypedInt(const TypedInt &value) = default;
LIBC_INLINE constexpr TypedInt &operator=(const TypedInt &value) = default;
LIBC_INLINE constexpr explicit TypedInt(T v) : value(v) {}
LIBC_INLINE constexpr TypedInt(const TypedInt &v) = default;
LIBC_INLINE constexpr TypedInt &operator=(const TypedInt &v) = default;

LIBC_INLINE constexpr explicit operator T() const { return value; }

Expand Down
2 changes: 1 addition & 1 deletion libc/src/__support/File/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct FileIOResult {
int error;

constexpr FileIOResult(size_t val) : value(val), error(0) {}
constexpr FileIOResult(size_t val, int error) : value(val), error(error) {}
constexpr FileIOResult(size_t val, int err) : value(val), error(err) {}

constexpr bool has_error() { return error != 0; }

Expand Down
2 changes: 1 addition & 1 deletion libc/src/__support/OSUtil/linux/vdso.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Symbol {
public:
LIBC_INLINE_VAR static constexpr size_t COUNT =
static_cast<size_t>(VDSOSym::VDSOSymCount);
LIBC_INLINE constexpr explicit Symbol(VDSOSym sym) : sym(sym) {}
LIBC_INLINE constexpr explicit Symbol(VDSOSym s) : sym(s) {}
LIBC_INLINE constexpr Symbol(size_t idx) : sym(static_cast<VDSOSym>(idx)) {}
LIBC_INLINE constexpr cpp::string_view name() const {
return symbol_name(sym);
Expand Down
4 changes: 2 additions & 2 deletions libc/src/__support/arg_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ template <bool packed> class StructArgList {
void *end;

public:
LIBC_INLINE StructArgList(void *ptr, size_t size)
: ptr(ptr), end(reinterpret_cast<unsigned char *>(ptr) + size) {}
LIBC_INLINE StructArgList(void *p, size_t size)
: ptr(p), end(reinterpret_cast<unsigned char *>(p) + size) {}
LIBC_INLINE StructArgList(const StructArgList &other) {
ptr = other.ptr;
end = other.end;
Expand Down
7 changes: 3 additions & 4 deletions libc/src/__support/freetrie.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ class FreeTrie {
size_t min;
size_t width;

LIBC_INLINE constexpr SizeRange(size_t min, size_t width)
: min(min), width(width) {
LIBC_ASSERT(!(width & (width - 1)) && "width must be a power of two");
LIBC_INLINE constexpr SizeRange(size_t m, size_t w) : min(m), width(w) {
LIBC_ASSERT(!(w & (w - 1)) && "width must be a power of two");
}

/// @returns The lower half of the size range.
Expand All @@ -83,7 +82,7 @@ class FreeTrie {
};

LIBC_INLINE constexpr FreeTrie() : FreeTrie(SizeRange{0, 0}) {}
LIBC_INLINE constexpr FreeTrie(SizeRange range) : range(range) {}
LIBC_INLINE constexpr FreeTrie(SizeRange r) : range(r) {}

/// Sets the range of possible block sizes. This can only be called when the
/// trie is empty.
Expand Down
2 changes: 1 addition & 1 deletion libc/src/__support/integer_to_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ template <bool forward> class StringBufferWriterImpl {

public:
StringBufferWriterImpl(const StringBufferWriterImpl &) = delete;
StringBufferWriterImpl(cpp::span<char> buffer) : buffer(buffer) {}
StringBufferWriterImpl(cpp::span<char> buf) : buffer(buf) {}

LIBC_INLINE size_t size() const { return index; }
LIBC_INLINE size_t remainder_size() const { return buffer.size() - size(); }
Expand Down
2 changes: 1 addition & 1 deletion libc/src/__support/memory_size.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SafeMemSize {
private:
using type = cpp::make_signed_t<size_t>;
type value;
LIBC_INLINE explicit SafeMemSize(type value) : value(value) {}
LIBC_INLINE explicit SafeMemSize(type val) : value(val) {}

public:
LIBC_INLINE_VAR static constexpr size_t MAX_MEM_SIZE =
Expand Down
3 changes: 1 addition & 2 deletions libc/src/__support/sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ struct Sign {
LIBC_INLINE constexpr Sign negate() const { return Sign(!is_negative); }

private:
LIBC_INLINE constexpr explicit Sign(bool is_negative)
: is_negative(is_negative) {}
LIBC_INLINE constexpr explicit Sign(bool is_neg) : is_negative(is_neg) {}

bool is_negative;
};
Expand Down
12 changes: 6 additions & 6 deletions libc/src/__support/str_to_num_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ template <typename T> struct StrToNumResult {
int error;
ptrdiff_t parsed_len;

LIBC_INLINE constexpr StrToNumResult(T value)
: value(value), error(0), parsed_len(0) {}
LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len)
: value(value), error(0), parsed_len(parsed_len) {}
LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len, int error)
: value(value), error(error), parsed_len(parsed_len) {}
LIBC_INLINE constexpr StrToNumResult(T val)
: value(val), error(0), parsed_len(0) {}
LIBC_INLINE constexpr StrToNumResult(T val, ptrdiff_t parsed_length)
: value(val), error(0), parsed_len(parsed_length) {}
LIBC_INLINE constexpr StrToNumResult(T val, ptrdiff_t parsed_length, int err)
: value(val), error(err), parsed_len(parsed_length) {}

LIBC_INLINE constexpr bool has_error() { return error != 0; }

Expand Down
8 changes: 4 additions & 4 deletions libc/src/__support/threads/linux/rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class WaitingQueue final : private RawMutex {
WaitingQueue &queue;
bool is_pshared;

LIBC_INLINE Guard(WaitingQueue &queue, bool is_pshared)
: queue(queue), is_pshared(is_pshared) {
queue.lock(cpp::nullopt, is_pshared);
LIBC_INLINE Guard(WaitingQueue &q, bool pshared)
: queue(q), is_pshared(pshared) {
queue.lock(cpp::nullopt, pshared);
}

public:
Expand Down Expand Up @@ -154,7 +154,7 @@ class RwState {

public:
// Construction and conversion functions.
LIBC_INLINE constexpr RwState(int state = 0) : state(state) {}
LIBC_INLINE constexpr RwState(int s = 0) : state(s) {}
LIBC_INLINE constexpr operator int() const { return state; }

// Utilities to check the state of the RwLock.
Expand Down
2 changes: 1 addition & 1 deletion libc/src/stdio/generic/puts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace {

// Simple helper to unlock the file once destroyed.
struct ScopedLock {
ScopedLock(LIBC_NAMESPACE::File *stream) : stream(stream) { stream->lock(); }
ScopedLock(LIBC_NAMESPACE::File *s) : stream(s) { s->lock(); }
~ScopedLock() { stream->unlock(); }

private:
Expand Down
4 changes: 2 additions & 2 deletions libc/src/stdio/printf_core/float_dec_converter_limited.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ struct DigitsInput {
// and shifts it up to the top of the UInt128 so that a function consuming
// this struct afterwards doesn't have to remember which format it came from.
DigitsInput(int32_t fraction_len, StorageType mantissa_, int exponent_,
Sign sign)
Sign sign_)
: mantissa(UInt128(mantissa_) << (127 - fraction_len)),
exponent(exponent_), sign(sign) {
exponent(exponent_), sign(sign_) {
if (!(mantissa & (UInt128(1) << 127)) && mantissa != 0) {
// Normalize a denormalized input.
int shift = cpp::countl_zero(mantissa);
Expand Down
14 changes: 7 additions & 7 deletions libc/src/stdio/printf_core/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ template <WriteMode write_mode> struct WriteBuffer {
// stream writer with function pointers.
[[maybe_unused]] WriteMode write_mode_;

LIBC_INLINE WriteBuffer(char *buff, size_t buff_len, StreamWriter hook,
LIBC_INLINE WriteBuffer(char *buf, size_t buf_len, StreamWriter hook,
void *target)
: buff(buff), init_buff(buff), buff_len(buff_len), stream_writer(hook),
: buff(buf), init_buff(buf), buff_len(buf_len), stream_writer(hook),
output_target(target), write_mode_(WriteMode::FLUSH_TO_STREAM) {}

LIBC_INLINE WriteBuffer(char *buff, size_t buff_len)
: buff(buff), init_buff(buff), buff_len(buff_len), stream_writer(nullptr),
LIBC_INLINE WriteBuffer(char *buf, size_t buf_len)
: buff(buf), init_buff(buf), buff_len(buf_len), stream_writer(nullptr),
output_target(nullptr),
write_mode_(WriteMode::FILL_BUFF_AND_DROP_OVERFLOW) {}

LIBC_INLINE WriteBuffer(char *buff, size_t buff_len, StreamWriter hook)
: buff(buff), init_buff(buff), buff_len(buff_len), stream_writer(hook),
LIBC_INLINE WriteBuffer(char *buf, size_t buf_len, StreamWriter hook)
: buff(buf), init_buff(buf), buff_len(buf_len), stream_writer(hook),
output_target(this), write_mode_(WriteMode::RESIZE_AND_FILL_BUFF) {}

LIBC_INLINE int flush_to_stream(cpp::string_view new_str) {
Expand Down Expand Up @@ -156,7 +156,7 @@ template <WriteMode write_mode> class Writer final {
}

public:
LIBC_INLINE Writer(WriteBuffer<write_mode> &wb) : wb(wb) {}
LIBC_INLINE Writer(WriteBuffer<write_mode> &buf) : wb(buf) {}

// Takes a string, copies it into the buffer if there is space, else passes it
// to the overflow mechanism to be handled separately.
Expand Down
4 changes: 2 additions & 2 deletions libc/src/stdio/scanf_core/string_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class StringReader : public Reader<StringReader> {
size_t buff_cur = 0;

public:
LIBC_INLINE StringReader(const char *buffer, size_t buff_len)
: buffer(buffer), buff_len(buff_len) {}
LIBC_INLINE StringReader(const char *buf, size_t buf_len)
: buffer(buf), buff_len(buf_len) {}

LIBC_INLINE char getc() {
char output = buffer[buff_cur];
Expand Down
2 changes: 1 addition & 1 deletion libc/src/stdio/scanf_core/vfscanf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class StreamReader : public Reader<StreamReader> {
::FILE *stream;

public:
LIBC_INLINE StreamReader(::FILE *stream) : stream(stream) {}
LIBC_INLINE StreamReader(::FILE *s) : stream(s) {}

LIBC_INLINE char getc() {
return static_cast<char>(internal::getc(static_cast<FILE *>(stream)));
Expand Down
2 changes: 1 addition & 1 deletion libc/src/string/memory_utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ template <typename T> struct StrictIntegralType {

// Can only be constructed from a T.
template <typename U, cpp::enable_if_t<cpp::is_same_v<U, T>, bool> = 0>
LIBC_INLINE StrictIntegralType(U value) : value(value) {}
LIBC_INLINE StrictIntegralType(U val) : value(val) {}

// Allows using the type in an if statement.
LIBC_INLINE explicit operator bool() const { return value; }
Expand Down
4 changes: 2 additions & 2 deletions libc/test/UnitTest/LibcTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace internal {
// A simple location object to allow consistent passing of __FILE__ and
// __LINE__.
struct Location {
Location(const char *file, int line) : file(file), line(line) {}
Location(const char *f, int l) : file(f), line(l) {}
const char *file;
int line;
};
Expand Down Expand Up @@ -215,7 +215,7 @@ class Test {
template <typename Func> testutils::FunctionCaller *createCallable(Func f) {
struct Callable : public testutils::FunctionCaller {
Func f;
Callable(Func f) : f(f) {}
Callable(Func func) : f(func) {}
void operator()() override { f(); }
};

Expand Down
Loading
Loading