Skip to content

Commit

Permalink
Fix compilation with clang 18.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed May 9, 2024
1 parent 59a4e83 commit 28f8664
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 20 deletions.
3 changes: 2 additions & 1 deletion BMR/AndJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int AndJob::run()
printf("thread %d: run and job from %d to %d with %d gates\n",
pthread_self(), start, end, gates.size());
#endif
__m128i prf_output[PAD_TO_8(ProgramParty::s().get_n_parties())];
__m128i* prf_output = new __m128i[PAD_TO_8(ProgramParty::s().get_n_parties())];
auto gate = gates.begin();
vector< GC::Secret<EvalRegister> >& S = *this->S;
const vector<int>& args = *this->args;
Expand All @@ -33,5 +33,6 @@ int AndJob::run()
gate++;
}
}
delete[] prf_output;
return i_gate;
}
3 changes: 2 additions & 1 deletion BMR/network/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void Node::Broadcast2(SendBuffer& msg) {
}

void Node::_identify() {
char msg[strlen(ID_HDR)+sizeof(_id)];
char* msg = new char[strlen(ID_HDR)+sizeof(_id)];
memcpy(msg, ID_HDR, strlen(ID_HDR));
memcpy(msg+strlen(ID_HDR), (const char *)&_id, sizeof(_id));
//printf("Node:: identifying myself:\n");
Expand All @@ -178,6 +178,7 @@ void Node::_identify() {
phex(buffer.data(), 4);
#endif
_client->Broadcast(buffer);
delete[] msg;
}

void Node::_parse_map(const char* netmap_file, int num_parties) {
Expand Down
10 changes: 6 additions & 4 deletions Math/Square.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "Math/Square.h"
#include "Math/BitVec.h"
#include "Math/Zp_Data.h"

template<class U>
Square<U>& Square<U>::sub(const Square<U>& other)
Expand Down Expand Up @@ -83,7 +84,8 @@ void Square<U>::to(U& result)
template<class U>
void Square<U>::to(U& result, true_type)
{
int L = U::get_ZpD().get_t();
int t = U::get_ZpD().get_t();
const int L = MAX_MOD_SZ;
mp_limb_t product[2 * L], sum[2 * L], tmp[L][2 * L];
memset(tmp, 0, sizeof(tmp));
memset(sum, 0, sizeof(sum));
Expand All @@ -93,10 +95,10 @@ void Square<U>::to(U& result, true_type)
if (i % 64 == 0)
memcpy(product, tmp[i/64], sizeof(product));
else
mpn_lshift(product, tmp[i/64], 2 * L, i % 64);
mpn_add_n(sum, product, sum, 2 * L);
mpn_lshift(product, tmp[i/64], 2 * t, i % 64);
mpn_add_n(sum, product, sum, 2 * t);
}
mp_limb_t q[2 * L], ans[2 * L];
mpn_tdiv_qr(q, ans, 0, sum, 2 * L, U::get_ZpD().get_prA(), L);
mpn_tdiv_qr(q, ans, 0, sum, 2 * t, U::get_ZpD().get_prA(), t);
result.assign((void*) ans);
}
2 changes: 1 addition & 1 deletion Math/Zp_Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Zp_Data::init(const bigint& p,bool mont)

void Zp_Data::Mont_Mult(mp_limb_t* z,const mp_limb_t* x,const mp_limb_t* y,int t) const
{
mp_limb_t ans[2 * MAX_MOD_SZ + 1], u, yy[t + 1];
mp_limb_t ans[2 * MAX_MOD_SZ + 1], u, yy[MAX_MOD_SZ + 1];
inline_mpn_copyi(yy, y, t);
yy[t] = 0;
// First loop
Expand Down
4 changes: 2 additions & 2 deletions Networking/sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ inline void send(int socket,octet *msg,size_t len)
template<class T>
inline void send(T& socket, size_t a, size_t len)
{
octet blen[len];
octet blen[8];
encode_length(blen, a, len);
send(socket, blen, len);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ inline void receive(int socket,octet *msg,size_t len)
template<class T>
inline void receive(T& socket, size_t& a, size_t len)
{
octet blen[len];
octet blen[8];
receive(socket, blen, len);
a = decode_length(blen, len);
}
Expand Down
2 changes: 1 addition & 1 deletion OT/OTVole.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void OTVoleBase<T>::hash_row(__m128i res[2], const U& row,
{
auto coeff_base = coefficients;
int num_blocks = DIV_CEIL(row.size() * T::size(), 16);
__m128i buffer[T::size()];
__m128i buffer[T::N_BYTES];
size_t next = 0;
while (next + 16 <= row.size())
{
Expand Down
4 changes: 3 additions & 1 deletion Processor/Binary_File_IO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Binary_File_IO::read_from_file(const string filename, vector< T >& buffer,

int size_in_bytes = T::size() * buffer.size();
int n_read = 0;
char read_buffer[size_in_bytes];
char* read_buffer = new char[size_in_bytes];
inf.seekg(start_posn * T::size(), iostream::cur);
do
{
Expand Down Expand Up @@ -90,4 +90,6 @@ void Binary_File_IO::read_from_file(const string filename, vector< T >& buffer,

for (unsigned int i = 0; i < buffer.size(); i++)
buffer[i].assign(&read_buffer[i*T::size()]);

delete[] read_buffer;
}
3 changes: 2 additions & 1 deletion Protocols/NoShare.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ class NoShare : public ShareInterface
throw runtime_error("no human-readable input");
else
{
char buf[size()];
char* buf = new char[size()];
is.read(buf, size());
assign(buf);
delete[] buf;
}
}

Expand Down
6 changes: 4 additions & 2 deletions Protocols/edabit.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class edabitvec

void input(int length, ifstream& s)
{
char buffer[MAX_SIZE * T::size()];
char* buffer = new char[MAX_SIZE * T::size()];
s.read(buffer, MAX_SIZE * T::size());
for (int i = 0; i < MAX_SIZE; i++)
{
Expand All @@ -108,14 +108,16 @@ class edabitvec
a.push_back(x);
}
size_t bsize = T::bit_type::part_type::size();
char bbuffer[length * bsize];
char* bbuffer = new char[length * bsize];
s.read(bbuffer, length * bsize);
for (int i = 0; i < length; i++)
{
typename T::bit_type::part_type x;
x.assign(bbuffer + i * bsize);
b.push_back(x);
}
delete[] bbuffer;
delete[] buffer;
}

void output(int length, ofstream& s)
Expand Down
2 changes: 1 addition & 1 deletion Protocols/fake-stuff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void make_vector_share(T* Sa,const U& a,int N,const V& key,PRNG& G)
Sa[i].resize_regs(length);
for (int j = 0; j < length; j++)
{
typename T::part_type shares[N];
vector<typename T::part_type> shares(N);
make_share(shares, typename T::part_type::clear(a.get_bit(j)), N, key, G);
for (int i = 0; i < N; i++)
Sa[i].get_reg(j) = shares[i];
Expand Down
3 changes: 2 additions & 1 deletion Tools/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void BufferBase::prune()
ofstream tmp(tmp_name.c_str());
size_t start = file->tellg();
start -= element_length() * (BUFFER_SIZE - next);
char buf[header_length];
char* buf = new char[header_length];
file->seekg(0);
file->read(buf, header_length);
tmp.write(buf, header_length);
Expand All @@ -118,6 +118,7 @@ void BufferBase::prune()
file->close();
rename(tmp_name.c_str(), filename.c_str());
file->open(filename.c_str(), ios::in | ios::binary);
delete[] buf;
}
#ifdef VERBOSE
else
Expand Down
3 changes: 2 additions & 1 deletion Tools/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,12 @@ inline void Buffer<T, U>::fill_buffer()
}
else
{
char read_buffer[BUFFER_SIZE * T::size()];
char* read_buffer = new char[BUFFER_SIZE * T::size()];
read(read_buffer);
//memset(buffer, 0, sizeof(buffer));
for (int i = 0; i < BUFFER_SIZE; i++)
buffer[i].assign(&read_buffer[i*T::size()]);
delete[] read_buffer;
}
}

Expand Down
3 changes: 2 additions & 1 deletion Tools/octetStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ octetStream octetStream::hash() const

bigint octetStream::check_sum(int req_bytes) const
{
unsigned char hash[req_bytes];
auto hash = new unsigned char[req_bytes];
crypto_generichash(hash, req_bytes, data, len, NULL, 0);

bigint ans;
bigintFromBytes(ans,hash,req_bytes);
// cout << ans << "\n";
delete[] hash;
return ans;
}

Expand Down
3 changes: 2 additions & 1 deletion Tools/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ inline void get_vector(int m, vector<int>& start, istream& s)
inline void get_string(string& res, istream& s)
{
unsigned size = get_int(s);
char buf[size];
char* buf = new char[size];
s.read(buf, size);
res.assign(buf, size);
delete[] buf;
}

#endif /* TOOLS_PARSE_H_ */
3 changes: 2 additions & 1 deletion Tools/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void PRNG::get(bigint& res, int n_bits, bool positive)
assert(n_bits > 0);
int n_bytes = (n_bits + 7) / 8;
int n_words = DIV_CEIL(n_bytes, sizeof(word));
word words[n_words];
auto words = new word[n_words];
octet* bytes = (octet*) words;
words[n_words - 1] = 0;
get_octets(bytes, n_bytes);
Expand All @@ -252,4 +252,5 @@ void PRNG::get(bigint& res, int n_bits, bool positive)
mpz_import(res.get_mpz_t(), n_words, -1, sizeof(word), -1, 0, bytes);
if (not positive and (get_bit()))
mpz_neg(res.get_mpz_t(), res.get_mpz_t());
delete[] words;
}

0 comments on commit 28f8664

Please sign in to comment.