From 4ea98362c39d63bbfaef28aa25a1e630e01c5611 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 10 Jun 2025 12:02:10 +0200 Subject: Added native example --- 03_threads/build-native.sh | 4 ++++ 03_threads/native.c | 10 ++++++++++ 03_threads/program.mjs | 6 ++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100755 03_threads/build-native.sh create mode 100644 03_threads/native.c (limited to '03_threads') diff --git a/03_threads/build-native.sh b/03_threads/build-native.sh new file mode 100755 index 0000000..251e0a0 --- /dev/null +++ b/03_threads/build-native.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +mkdir -p build +cc -o build/native primes.c native.c diff --git a/03_threads/native.c b/03_threads/native.c new file mode 100644 index 0000000..4a3d4fa --- /dev/null +++ b/03_threads/native.c @@ -0,0 +1,10 @@ +#include + +int primes_in_range(int, int); + +int main() { + int low = 1; + int high = 10000000; + int result = primes_in_range(low, high); + printf("There are %d primes between %d and %d\n", result, low, high); +} diff --git a/03_threads/program.mjs b/03_threads/program.mjs index db0a2c6..3bdb4ea 100644 --- a/03_threads/program.mjs +++ b/03_threads/program.mjs @@ -2,5 +2,7 @@ import Primes from "./build/primes.mjs" var primes = await Primes(); -const count = primes._primes_in_range(1, 100); -console.log("There are " + count + " primes between 1 and 100"); +var low = 1; +var high = 10000000; +const count = primes._primes_in_range(low, high); +console.log("There are " + count + " primes between " + low + " and " + high); -- cgit v1.3