mirror of
https://github.com/data61/MP-SPDZ.git
synced 2026-01-10 05:57:57 -05:00
Fix compilation with clang 18.
This commit is contained in:
@@ -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;
|
||||
@@ -33,5 +33,6 @@ int AndJob::run()
|
||||
gate++;
|
||||
}
|
||||
}
|
||||
delete[] prf_output;
|
||||
return i_gate;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
@@ -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));
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -170,9 +170,10 @@ public:
|
||||
throw runtime_error("no human-readable input");
|
||||
else
|
||||
{
|
||||
char buf[size()];
|
||||
char* buf = new char[size()];
|
||||
is.read(buf, size());
|
||||
assign(buf);
|
||||
delete[] buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
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++)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
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++)
|
||||
{
|
||||
@@ -116,6 +116,8 @@ public:
|
||||
x.assign(bbuffer + i * bsize);
|
||||
b.push_back(x);
|
||||
}
|
||||
delete[] bbuffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
void output(int length, ofstream& s)
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user