Skip to content

Commit

Permalink
refactor: Rename system_{memory,...} to os_{memory,...}.
Browse files Browse the repository at this point in the history
This rename happens in the system PR, so I'm pulling it out to reduce
the size of that PR.
  • Loading branch information
iphydf committed Jan 25, 2024
1 parent 203e1af commit bdf460a
Show file tree
Hide file tree
Showing 35 changed files with 95 additions and 95 deletions.
36 changes: 18 additions & 18 deletions auto_tests/TCP_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ static uint16_t ports[NUM_PORTS] = {13215, 33445, 25643};

static void test_basic(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Expand Down Expand Up @@ -304,11 +304,11 @@ static int read_packet_sec_tcp(const Logger *logger, struct sec_TCP_con *con, ui

static void test_some(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Expand Down Expand Up @@ -499,11 +499,11 @@ static int oob_data_callback(void *object, const uint8_t *public_key, const uint

static void test_client(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);

Logger *logger = logger_new();
Expand Down Expand Up @@ -633,11 +633,11 @@ static void test_client(void)
// Test how the client handles servers that don't respond.
static void test_client_invalid(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Expand Down Expand Up @@ -712,11 +712,11 @@ static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t

static void test_tcp_connection(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Expand Down Expand Up @@ -825,11 +825,11 @@ static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigne

static void test_tcp_connection2(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
Expand Down
8 changes: 4 additions & 4 deletions auto_tests/announce_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

static void test_bucketnum(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
uint8_t key1[CRYPTO_PUBLIC_KEY_SIZE], key2[CRYPTO_PUBLIC_KEY_SIZE];
random_bytes(rng, key1, sizeof(key1));
Expand Down Expand Up @@ -50,11 +50,11 @@ static void test_announce_data(void *object, const uint8_t *data, uint16_t lengt

static void test_store_data(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);

Logger *log = logger_new();
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/conference_av_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ static void do_audio(AutoTox *autotoxes, uint32_t iterations)

static void run_conference_tests(AutoTox *autotoxes)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
bool disabled[NUM_AV_GROUP_TOX] = {0};

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/conference_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static uint32_t random_false_index(const Random *rng, bool *list, const uint32_t

static void run_conference_tests(AutoTox *autotoxes)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
/* disabling name change propagation check for now, as it occasionally
* fails due to disconnections too short to trigger freezing */
Expand Down
10 changes: 5 additions & 5 deletions auto_tests/crypto_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static void test_fast_known(void)

static void test_endtoend(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);

// Test 100 random messages and keypairs
Expand Down Expand Up @@ -192,7 +192,7 @@ static void test_endtoend(void)

static void test_large_data(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
uint8_t k[CRYPTO_SHARED_KEY_SIZE];
uint8_t n[CRYPTO_NONCE_SIZE];
Expand Down Expand Up @@ -236,7 +236,7 @@ static void test_large_data(void)

static void test_large_data_symmetric(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
uint8_t k[CRYPTO_SYMMETRIC_KEY_SIZE];

Expand Down Expand Up @@ -271,7 +271,7 @@ static void test_large_data_symmetric(void)

static void test_very_large_data(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);

uint8_t nonce[CRYPTO_NONCE_SIZE] = {0};
Expand Down Expand Up @@ -316,7 +316,7 @@ static void increment_nonce_number_cmp(uint8_t *nonce, uint32_t num)

static void test_increment_nonce(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);

uint8_t n[CRYPTO_NONCE_SIZE];
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/encryptsave_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static void test_keys(void)
ck_assert(encrypted2a != nullptr);
uint8_t *in_plaintext2a = (uint8_t *)malloc(plaintext_length2a);
ck_assert(in_plaintext2a != nullptr);
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
random_bytes(rng, in_plaintext2a, plaintext_length2a);
ret = tox_pass_encrypt(in_plaintext2a, plaintext_length2a, key_char, 12, encrypted2a, &encerr);
Expand Down
10 changes: 5 additions & 5 deletions auto_tests/forwarding_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ typedef struct Forwarding_Subtox {

static Forwarding_Subtox *new_forwarding_subtox(const Memory *mem, bool no_udp, uint32_t *index, uint16_t port)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);

Forwarding_Subtox *subtox = (Forwarding_Subtox *)calloc(1, sizeof(Forwarding_Subtox));
Expand Down Expand Up @@ -152,11 +152,11 @@ static void kill_forwarding_subtox(const Memory *mem, Forwarding_Subtox *subtox)

static void test_forwarding(void)
{
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);

uint32_t index[NUM_FORWARDER];
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/group_message_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static void group_message_test(AutoTox *autotoxes)
{
ck_assert_msg(NUM_GROUP_TOXES >= 2, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);

const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);

Tox *tox0 = autotoxes[0].tox;
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/group_sync_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static void topic_spam(const Random *rng, AutoTox *autotoxes, uint32_t num_peers
static void group_sync_test(AutoTox *autotoxes)
{
ck_assert(NUM_GROUP_TOXES >= 5);
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);

for (size_t i = 0; i < NUM_GROUP_TOXES; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/group_topic_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static void group_topic_test(AutoTox *autotoxes)
{
ck_assert_msg(NUM_GROUP_TOXES >= 3, "NUM_GROUP_TOXES is too small: %d", NUM_GROUP_TOXES);

const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);

Tox *tox0 = autotoxes[0].tox;
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/network_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void test_addr_resolv_localhost(void)
errno = 0;
#endif

const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);

const char localhost[] = "localhost";
Expand Down
12 changes: 6 additions & 6 deletions auto_tests/onion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ static Networking_Core *new_networking(const Logger *log, const Memory *mem, con
static void test_basic(void)
{
uint32_t index[] = { 1, 2, 3 };
const Network *ns = system_network();
const Network *ns = os_network();
ck_assert(ns != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);

Logger *log1 = logger_new();
Expand Down Expand Up @@ -407,7 +407,7 @@ static Onions *new_onions(const Memory *mem, const Random *rng, uint16_t port, u
{
IP ip = get_loopback();
ip.ip.v6.uint8[15] = 1;
const Network *ns = system_network();
const Network *ns = os_network();
Onions *on = (Onions *)malloc(sizeof(Onions));

if (!on) {
Expand Down Expand Up @@ -576,9 +576,9 @@ static void test_announce(void)
{
uint32_t index[NUM_ONIONS];
Onions *onions[NUM_ONIONS];
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const Memory *mem = system_memory();
const Memory *mem = os_memory();
ck_assert(mem != nullptr);

for (uint32_t i = 0; i < NUM_ONIONS; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/reconnect_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static bool all_disconnected_from(uint32_t tox_count, AutoTox *autotoxes, uint32

static void test_reconnect(AutoTox *autotoxes)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
const time_t test_start_time = time(nullptr);

Expand Down
2 changes: 1 addition & 1 deletion auto_tests/save_friend_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int main(void)
ck_assert(reference_name != nullptr);
ck_assert(reference_status != nullptr);

const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
set_random(tox1, rng, tox_self_set_name, tox_max_name_length());
set_random(tox2, rng, tox_self_set_name, tox_max_name_length());
Expand Down
4 changes: 2 additions & 2 deletions auto_tests/tox_many_tcp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static uint16_t tcp_relay_port = 33448;

static void test_many_clients_tcp(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
long long unsigned int cur_time = time(nullptr);
Tox *toxes[NUM_TOXES_TCP];
Expand Down Expand Up @@ -162,7 +162,7 @@ static void test_many_clients_tcp(void)

static void test_many_clients_tcp_b(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
long long unsigned int cur_time = time(nullptr);
Tox *toxes[NUM_TOXES_TCP];
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/tox_many_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void accept_friend_request(Tox *m, const Tox_Event_Friend_Request *event,

static void test_many_clients(void)
{
const Random *rng = system_random();
const Random *rng = os_random();
ck_assert(rng != nullptr);
time_t cur_time = time(nullptr);
Tox *toxes[TCP_TEST_NUM_TOXES];
Expand Down
6 changes: 3 additions & 3 deletions other/DHT_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ int main(int argc, char *argv[])
logger_callback_log(logger, print_log, nullptr, nullptr);
}

const Random *rng = system_random();
const Network *ns = system_network();
const Memory *mem = system_memory();
const Random *rng = os_random();
const Network *ns = os_network();
const Memory *mem = os_memory();

Mono_Time *mono_time = mono_time_new(mem, nullptr, nullptr);
const uint16_t start_port = PORT;
Expand Down
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8a2cc2e20ac0688b42c6e6211cb1bc5797c276ed52a2322d8b786f8ad562d535 /usr/local/bin/tox-bootstrapd
48ed699a0da0282b7e12142648a322198a2f2af791df3fb49bbe3f7e41afadc4 /usr/local/bin/tox-bootstrapd
6 changes: 3 additions & 3 deletions other/bootstrap_daemon/src/tox-bootstrapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ int main(int argc, char *argv[])
}

const uint16_t end_port = start_port + (TOX_PORTRANGE_TO - TOX_PORTRANGE_FROM);
const Memory *mem = system_memory();
const Random *rng = system_random();
const Network *ns = system_network();
const Memory *mem = os_memory();
const Random *rng = os_random();
const Network *ns = os_network();
Networking_Core *net = new_networking_ex(logger, mem, ns, &ip, start_port, end_port, nullptr);

if (net == nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions testing/Messenger_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int main(int argc, char *argv[])
exit(0);
}

const Memory *mem = system_memory();
const Memory *mem = os_memory();
Mono_Time *const mono_time = mono_time_new(mem, nullptr, nullptr);

if (mono_time == nullptr) {
Expand All @@ -103,7 +103,7 @@ int main(int argc, char *argv[])
Messenger_Options options = {0};
options.ipv6enabled = ipv6enabled;
Messenger_Error err;
m = new_messenger(mono_time, mem, system_random(), system_network(), &options, &err);
m = new_messenger(mono_time, mem, os_random(), os_network(), &options, &err);

if (!m) {
fprintf(stderr, "Failed to allocate messenger datastructure: %d\n", err);
Expand Down
2 changes: 1 addition & 1 deletion third_party/cmp
Submodule cmp updated 2 files
+1 −1 cmp.c
+1 −1 cmp.h
2 changes: 1 addition & 1 deletion toxav/rtp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RTPHeader random_header(const Random *rng)

TEST(Rtp, Deserialisation)
{
const Random *rng = system_random();
const Random *rng = os_random();
ASSERT_NE(rng, nullptr);
RTPHeader const header = random_header(rng);

Expand Down
Loading

0 comments on commit bdf460a

Please sign in to comment.