Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/libstore/builtins/buildenv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@

namespace nix {

namespace {

struct State
{
std::map<Path, int> priorities;
unsigned long symlinks = 0;
};

} // namespace

/* For each activated package, create symlinks */
static void createLinks(State & state, const Path & srcDir, const Path & dstDir, int priority)
{
Expand Down
4 changes: 4 additions & 0 deletions src/libutil/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ std::optional<std::string> RootArgs::needsCompletion(std::string_view s)
return {};
}

namespace {

/**
* Basically this is `typedef std::optional<Parser> Parser(std::string_view s, Strings & r);`
*
Expand Down Expand Up @@ -246,6 +248,8 @@ void ParseQuoted::operator()(std::shared_ptr<Parser> & state, Strings & r)
assert(false);
}

} // namespace

Strings parseShebangContent(std::string_view s)
{
Strings result;
Expand Down
14 changes: 7 additions & 7 deletions src/libutil/hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Hash newHashAllowEmpty(std::string_view hashStr, std::optional<HashAlgorithm> ha
return Hash::parseAny(hashStr, ha);
}

union Ctx
union Hash::Ctx
{
blake3_hasher blake3;
MD5_CTX md5;
Expand All @@ -282,7 +282,7 @@ union Ctx
SHA512_CTX sha512;
};

static void start(HashAlgorithm ha, Ctx & ctx)
static void start(HashAlgorithm ha, Hash::Ctx & ctx)
{
if (ha == HashAlgorithm::BLAKE3)
blake3_hasher_init(&ctx.blake3);
Expand Down Expand Up @@ -317,7 +317,7 @@ void blake3_hasher_update_with_heuristics(blake3_hasher * blake3, std::string_vi
}
}

static void update(HashAlgorithm ha, Ctx & ctx, std::string_view data)
static void update(HashAlgorithm ha, Hash::Ctx & ctx, std::string_view data)
{
if (ha == HashAlgorithm::BLAKE3)
blake3_hasher_update_with_heuristics(&ctx.blake3, data);
Expand All @@ -331,7 +331,7 @@ static void update(HashAlgorithm ha, Ctx & ctx, std::string_view data)
SHA512_Update(&ctx.sha512, data.data(), data.size());
}

static void finish(HashAlgorithm ha, Ctx & ctx, unsigned char * hash)
static void finish(HashAlgorithm ha, Hash::Ctx & ctx, unsigned char * hash)
{
if (ha == HashAlgorithm::BLAKE3)
blake3_hasher_finalize(&ctx.blake3, hash, BLAKE3_OUT_LEN);
Expand All @@ -347,7 +347,7 @@ static void finish(HashAlgorithm ha, Ctx & ctx, unsigned char * hash)

Hash hashString(HashAlgorithm ha, std::string_view s, const ExperimentalFeatureSettings & xpSettings)
{
Ctx ctx;
Hash::Ctx ctx;
Hash hash(ha, xpSettings);
start(ha, ctx);
update(ha, ctx, s);
Expand All @@ -365,7 +365,7 @@ Hash hashFile(HashAlgorithm ha, const Path & path)
HashSink::HashSink(HashAlgorithm ha)
: ha(ha)
{
ctx = new Ctx;
ctx = new Hash::Ctx;
bytes = 0;
start(ha, *ctx);
}
Expand Down Expand Up @@ -393,7 +393,7 @@ HashResult HashSink::finish()
HashResult HashSink::currentHash()
{
flush();
Ctx ctx2 = *ctx;
Hash::Ctx ctx2 = *ctx;
Hash hash(ha);
nix::finish(ha, ctx2, hash.hash);
return HashResult(hash, bytes);
Expand Down
7 changes: 4 additions & 3 deletions src/libutil/include/nix/util/hash.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ extern const StringSet hashFormats;

struct Hash
{
/** Opaque handle type for the hash calculation state. */
union Ctx;

constexpr static size_t maxHashSize = 64;
size_t hashSize = 0;
uint8_t hash[maxHashSize] = {};
Expand Down Expand Up @@ -224,8 +227,6 @@ std::optional<HashAlgorithm> parseHashAlgoOpt(std::string_view s);
*/
std::string_view printHashAlgo(HashAlgorithm ha);

union Ctx;

struct AbstractHashSink : virtual Sink
{
virtual HashResult finish() = 0;
Expand All @@ -235,7 +236,7 @@ class HashSink : public BufferedSink, public AbstractHashSink
{
private:
HashAlgorithm ha;
Ctx * ctx;
Hash::Ctx * ctx;
uint64_t bytes;

public:
Expand Down
4 changes: 4 additions & 0 deletions src/nix/diff-closures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@

namespace nix {

namespace {

struct Info
{
std::string outputName;
};

} // namespace

// name -> version -> store paths
typedef std::map<std::string, std::map<std::string, std::map<StorePath, Info>>> GroupedPaths;

Expand Down
Loading