Skip to content

Commit 390f7db

Browse files
committed
refactor: Move random and memory OS-specifics to os_* files.
1 parent 6f7f515 commit 390f7db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+771
-252
lines changed

.cirrus.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ freebsd_task:
2929
-DAUTOTEST=ON \
3030
-GNinja
3131
cmake --build . --target install
32-
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3 || ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3
32+
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:3 ||
33+
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6

.clusterfuzzlite/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ FROM gcr.io/oss-fuzz-base/base-builder:latest
66
RUN apt-get update \
77
&& apt-get -y install --no-install-suggests --no-install-recommends \
88
cmake \
9+
ninja-build \
910
pkg-config \
1011
&& apt-get clean \
1112
&& rm -rf /var/lib/apt/lists/*

.clusterfuzzlite/build.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ cd "$WORK"
1818
ls /usr/local/lib/
1919

2020
# Debug build for asserts
21-
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CC" \
21+
cmake -GNinja \
22+
-DCMAKE_BUILD_TYPE=Debug \
23+
-DCMAKE_C_COMPILER="$CC" \
2224
-DCMAKE_CXX_COMPILER="$CXX" \
2325
-DCMAKE_C_FLAGS="$CFLAGS" \
2426
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
25-
-DBUILD_TOXAV=OFF -DENABLE_SHARED=NO -DBUILD_FUZZ_TESTS=ON \
26-
-DDHT_BOOTSTRAP=OFF -DBOOTSTRAP_DAEMON=OFF "$SRC"/c-toxcore
27+
-DBUILD_TOXAV=OFF \
28+
-DENABLE_SHARED=OFF \
29+
-DBUILD_FUZZ_TESTS=ON \
30+
-DDHT_BOOTSTRAP=OFF \
31+
-DBOOTSTRAP_DAEMON=OFF \
32+
"$SRC"/c-toxcore
2733

2834
for TARGET in "${FUZZ_TARGETS[@]}"; do
2935
# build fuzzer target

.github/scripts/cmake-osx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ brew update
1010
brew install \
1111
libconfig \
1212
libvpx \
13+
ninja \
1314
opus
1415

1516
. ".github/scripts/flags-clang.sh"
@@ -25,7 +26,7 @@ add_flag -Werror
2526
add_c_flag -Wno-c11-extensions
2627
add_c_flag -Wno-pre-c11-compat
2728

28-
cmake -B_build -H. \
29+
cmake -GNinja -B_build -H. \
2930
-DCMAKE_C_FLAGS="$C_FLAGS" \
3031
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
3132
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
@@ -38,11 +39,10 @@ cmake -B_build -H. \
3839
-DUSE_IPV6=OFF \
3940
-DAUTOTEST=ON
4041

41-
cd _build # pushd
42-
make "-j$NPROC" -k install
42+
cmake --build _build
43+
cmake --install _build
4344

4445
# TODO(iphydf): Investigate if we can get lan discovery to work on macos CI.
4546
# It works, but CI doesn't let us press the "allow broadcast" button.
46-
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery ||
47-
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery
48-
cd - # popd
47+
ctest --test-dir _build -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery ||
48+
ctest --test-dir _build -j50 --output-on-failure --rerun-failed --repeat until-pass:6 -E lan_discovery

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ set(toxcore_SOURCES
319319
toxcore/onion_client.c
320320
toxcore/onion_client.h
321321
toxcore/onion.h
322+
toxcore/os_memory.c
323+
toxcore/os_memory.h
324+
toxcore/os_random.c
325+
toxcore/os_random.h
322326
toxcore/ping_array.c
323327
toxcore/ping_array.h
324328
toxcore/ping.c
@@ -340,6 +344,7 @@ set(toxcore_SOURCES
340344
toxcore/timed_auth.c
341345
toxcore/timed_auth.h
342346
toxcore/tox_api.c
347+
toxcore/tox_attributes.h
343348
toxcore/tox.c
344349
toxcore/tox.h
345350
toxcore/tox_dispatch.c
@@ -350,12 +355,18 @@ set(toxcore_SOURCES
350355
toxcore/tox_events.h
351356
toxcore/tox_log_level.c
352357
toxcore/tox_log_level.h
358+
toxcore/tox_memory.c
359+
toxcore/tox_memory.h
360+
toxcore/tox_memory_impl.h
353361
toxcore/tox_options.c
354362
toxcore/tox_options.h
355363
toxcore/tox_private.c
356364
toxcore/tox_private.h
357365
toxcore/tox_pack.c
358366
toxcore/tox_pack.h
367+
toxcore/tox_random.c
368+
toxcore/tox_random.h
369+
toxcore/tox_random_impl.h
359370
toxcore/tox_unpack.c
360371
toxcore/tox_unpack.h
361372
toxcore/util.c
@@ -379,7 +390,8 @@ if(EXPERIMENTAL_API)
379390
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
380391
${toxcore_SOURCE_DIR}/toxcore/tox_dispatch.h^tox
381392
${toxcore_SOURCE_DIR}/toxcore/tox_events.h^tox
382-
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox)
393+
${toxcore_SOURCE_DIR}/toxcore/tox_private.h^tox
394+
${toxcore_SOURCE_DIR}/toxcore/tox_random.h^tox)
383395
endif()
384396

385397
################################################################################

auto_tests/TCP_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "../toxcore/mono_time.h"
1111
#include "../toxcore/net_profile.h"
1212
#include "../toxcore/network.h"
13+
#include "../toxcore/os_memory.h"
14+
#include "../toxcore/os_random.h"
1315
#include "auto_test_support.h"
1416

1517
#define NUM_PORTS 3

auto_tests/announce_test.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
#include <string.h>
33

44
#include "../toxcore/announce.h"
5-
#include "../toxcore/tox.h"
6-
#include "../testing/misc_tools.h"
75
#include "../toxcore/mono_time.h"
86
#include "../toxcore/forwarding.h"
9-
#include "../toxcore/net_crypto.h"
10-
#include "../toxcore/util.h"
7+
#include "../toxcore/os_memory.h"
8+
#include "../toxcore/os_random.h"
119
#include "auto_test_support.h"
1210
#include "check_compat.h"
1311

auto_tests/conference_av_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <stdint.h>
88

99
#include "../toxav/toxav.h"
10+
#include "../toxcore/os_random.h"
1011
#include "check_compat.h"
1112

1213
#define NUM_AV_GROUP_TOX 16

auto_tests/conference_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <time.h>
77
#include <stdint.h>
88

9+
#include "../toxcore/os_random.h"
910
#include "../toxcore/util.h"
1011

1112
#include "check_compat.h"

auto_tests/crypto_test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
#include <stdlib.h>
33
#include <string.h>
44

5-
#include "../testing/misc_tools.h"
65
#include "../toxcore/crypto_core.h"
76
#include "../toxcore/net_crypto.h"
7+
#include "../toxcore/os_memory.h"
8+
#include "../toxcore/os_random.h"
89
#include "check_compat.h"
910

1011
static void rand_bytes(const Random *rng, uint8_t *b, size_t blen)

0 commit comments

Comments
 (0)