From 182d350cf4328002180723ae3673e15dca8dce39 2020-06-26 11:40:07 From: Christopher Esterhuyse Date: 2020-06-26 11:40:07 Subject: [PATCH] streamlined example compilation --- diff --git a/examples/1_minimal/make.sh b/examples/1_minimal/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/1_minimal/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/2_runtime_pdl/make.sh b/examples/2_runtime_pdl/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/2_runtime_pdl/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/3_trivial_connect/make.sh b/examples/3_trivial_connect/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/3_trivial_connect/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/4_port_pair/make.sh b/examples/4_port_pair/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/4_port_pair/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/5_put_get/make.sh b/examples/5_put_get/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/5_put_get/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/6_atomic/make.sh b/examples/6_atomic/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/6_atomic/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/7_recovery/make.sh b/examples/7_recovery/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/7_recovery/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/8_net_ports/make.sh b/examples/8_net_ports/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/8_net_ports/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/9_net_self_putget/make.sh b/examples/9_net_self_putget/make.sh deleted file mode 100644 index bf036e6c666650f8a878ff5275c7b5b12ab38cc3..0000000000000000000000000000000000000000 --- a/examples/9_net_self_putget/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy diff --git a/examples/make.py b/examples/make.py new file mode 100644 index 0000000000000000000000000000000000000000..b7efdc620d00d7d68accc8473db228d315e0fc89 --- /dev/null +++ b/examples/make.py @@ -0,0 +1,15 @@ +import os, glob, subprocess +script_path = os.path.dirname(os.path.realpath(__file__)); +for c_file in glob.glob(script_path + "/*/*.c", recursive=False): + print("compiling", c_file) + args = [ + "gcc", + "-L", + "../target/release", + "-lreowolf_rs", + "-Wl,-R../target/release", + c_file, + "-o", + c_file[:-2] + ]; + subprocess.run(args); \ No newline at end of file diff --git a/examples/old/1_socketlike/amy.c b/examples/old/1_socketlike/amy.c deleted file mode 100644 index c03703226d87c2e461e965a0670c2dede7bed552..0000000000000000000000000000000000000000 --- a/examples/old/1_socketlike/amy.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { - - // Protocol is hard-coded. - char* pdl = - "primitive forward(in i, out o) {" - " while(true) synchronous { " - " put(o, get(i)); " - " } " - "} "; - - // create a connector with one outgoing network channel. - Connector* c = connector_new(); - printf("configuring...\n"); - check("config ", connector_configure(c, pdl, "forward")); - check("bind 0 ", connector_bind_native(c, 0)); - check("bind 1 ", connector_bind_passive(c, 1, "127.0.0.1:7000")); - printf("connecting...\n"); - check("connect", connector_connect(c, 5000)); - - // send "hello" message three times - int i; - for (i = 0; i < 3; i++) { - check("put ", connector_put(c, 0, "hello", 5)); - check("sync", connector_sync(c, 1000)); - printf("Sent one message!\n"); - } - - printf("cleaning up\n"); - connector_destroy(c); - return 0; -} \ No newline at end of file diff --git a/examples/old/1_socketlike/bob.c b/examples/old/1_socketlike/bob.c deleted file mode 100644 index 5457309363001adbd3038b6ec3c720b27958e6dc..0000000000000000000000000000000000000000 --- a/examples/old/1_socketlike/bob.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { - - // Protocol is hard-coded. - char* pdl = - "primitive forward(in i, out o) {" - " while(true) synchronous { " - " put(o, get(i)); " - " } " - "} "; - - // setup a connector with one incoming network channel. - Connector* c = connector_new(); - printf("configuring...\n"); - check("config ", connector_configure(c, pdl, "forward")); - check("bind 0 ", connector_bind_active(c, 0, "127.0.0.1:7000")); - check("bind 1 ", connector_bind_native(c, 1)); - check("connect ", connector_connect(c, 5000)); - - // receive a message and print it to stdout three times - int i, msg_len; - const unsigned char * msg; - for (i = 0; i < 3; i++) { - check("get ", connector_get(c, 0)); - check("sync", connector_sync(c, 1000)); - check("read", connector_gotten(c, 0, &msg, &msg_len)); - printf("Received one message `%.*s`!\n", msg_len, msg); - } - - printf("cleaning up\n"); - connector_destroy(c); - return 0; -} \ No newline at end of file diff --git a/examples/old/1_socketlike/make.sh b/examples/old/1_socketlike/make.sh deleted file mode 100644 index 2a55b236fc6ece4baf796ff607056fb115b806f3..0000000000000000000000000000000000000000 --- a/examples/old/1_socketlike/make.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o ./amy -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH bob.c -o ./bob diff --git a/examples/old/2_dynamic_pdl/amy.c b/examples/old/2_dynamic_pdl/amy.c deleted file mode 100644 index 489a6b4870a7c880f3ca3f970fd2773216eac768..0000000000000000000000000000000000000000 --- a/examples/old/2_dynamic_pdl/amy.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { - - // Protocol is loaded from file. - char * pdl = buffer_pdl("eg_protocols.pdl"); - - // create a connector with one outgoing network channel. - Connector* c = connector_new(); - printf("configuring...\n"); - check("config ", connector_configure(c, pdl, "dynamic")); - check("bind 0 ", connector_bind_native(c, 0)); - check("bind 1 ", connector_bind_passive(c, 1, "127.0.0.1:7000")); - printf("connecting...\n"); - check("connect", connector_connect(c, 5000)); - - // send "hello" message three times - int i; - for (i = 0; i < 3; i++) { - check("put ", connector_put(c, 0, "hello", 5)); - check("sync", connector_sync(c, 1000)); - printf("Sent one message!\n"); - } - - printf("cleaning up\n"); - connector_destroy(c); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/old/2_dynamic_pdl/make.sh b/examples/old/2_dynamic_pdl/make.sh deleted file mode 100644 index 090a17a3ea6d33867de7e7ec53414c23789ffaa0..0000000000000000000000000000000000000000 --- a/examples/old/2_dynamic_pdl/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../../target/release" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o amy \ No newline at end of file diff --git a/examples/old/3_atomicity/amy.c b/examples/old/3_atomicity/amy.c deleted file mode 100644 index 7b5d12685dc22c4815fd826300c18f84d869a413..0000000000000000000000000000000000000000 --- a/examples/old/3_atomicity/amy.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { // AMY - char * pdl = buffer_pdl("eg_protocols.pdl"); - - Connector* c = connector_new(); - printf("configuring...\n"); - - check("config ", connector_configure(c, pdl, "sync_two")); - check("bind 0 ", connector_bind_native(c, 0)); - check("bind 1 ", connector_bind_native(c, 1)); - check("bind 2 ", connector_bind_passive(c, 2, "127.0.0.1:7000")); - check("bind 3 ", connector_bind_passive(c, 3, "127.0.0.1:7001")); - printf("connecting...\n"); - check("connect", connector_connect(c, 5000)); - - int round, code; - for(round = 0; true; round++) { - printf("\nround %d\n", round); - - check("put ", connector_put(c, 0, "one", 3)); - check("put ", connector_put(c, 1, "two", 3)); - check("sync ", connector_sync(c, 10000)); - } - - printf("cleaning up...\n"); - connector_destroy(c); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/old/3_atomicity/bob.c b/examples/old/3_atomicity/bob.c deleted file mode 100644 index 60f4a020c4213a7aea0ef06ee8b6e789d2071ba2..0000000000000000000000000000000000000000 --- a/examples/old/3_atomicity/bob.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { - - Connector* c = connector_new(); - printf("configuring...\n"); - char * pdl = buffer_pdl("eg_protocols.pdl"); - check("config ", connector_configure(c, pdl, "sync_two")); - check("bind 0 ", connector_bind_active(c, 0, "127.0.0.1:7000")); - check("bind 1 ", connector_bind_active(c, 1, "127.0.0.1:7001")); - check("bind 2 ", connector_bind_native(c, 2)); - check("bind 3 ", connector_bind_native(c, 3)); - - printf("connecting...\n"); - check("connect", connector_connect(c, 5000)); - - const unsigned char * msg; - const char * nth[2] = {"first", "second"}; - int i, code, msg_len; - char yn[2]; - - while(true) { - printf("\nround %d...\n", i); - printf("Which of the two messages should we receive? (y/n)(y/n) (eg: yy): "); - scanf(" %c%c", &yn[0], &yn[1]); - for (i = 0; i < 2; i++) { - if (yn[i] != 'y' && yn[i] != 'n') { - printf("Expected (y/n) input!"); - continue; - } - } - printf("Receiving messages [%c, %c]\n", yn[0], yn[1]); - if (yn[0] == 'y') check("get first ", connector_get(c, 0)); - if (yn[1] == 'y') check("get second ", connector_get(c, 1)); - check("sync ", connector_sync(c, 1000)); - for (i = 0; i < 2; i++) { - if (yn[i] == 'y') { - check("read ", connector_gotten(c, i, &msg, &msg_len)); - printf("Got %s msg `%.*s`\n", nth[i], msg_len, msg); - } - } - } - - printf("cleaning up\n"); - connector_destroy(c); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/old/3_atomicity/make.sh b/examples/old/3_atomicity/make.sh deleted file mode 100644 index 29265a080aec2c404da4a511f2c78a513596c536..0000000000000000000000000000000000000000 --- a/examples/old/3_atomicity/make.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -LIB_PATH="../" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o amy -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH bob.c -o bob diff --git a/examples/old/4_nondeterminism/amy.c b/examples/old/4_nondeterminism/amy.c deleted file mode 100644 index 543ee8d69868c715837efa83db0725ffc6bbc59b..0000000000000000000000000000000000000000 --- a/examples/old/4_nondeterminism/amy.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { // AMY - char * pdl = buffer_pdl("eg_protocols.pdl"); - - Connector* c = connector_new(); - printf("configuring...\n"); - - check("config ", connector_configure(c, pdl, "sync_two")); - check("bind 0 ", connector_bind_native(c, 0)); - check("bind 1 ", connector_bind_native(c, 1)); - check("bind 2 ", connector_bind_passive(c, 2, "127.0.0.1:7000")); - check("bind 3 ", connector_bind_passive(c, 3, "127.0.0.1:7001")); - printf("connecting...\n"); - check("connect", connector_connect(c, 5000)); - - int round, code; - for(round = 0; true; round++) { - printf("\nround %d\n", round); - - check("next ", connector_next_batch(c)); - check("put ", connector_put(c, 0, "one", 3)); - check("put ", connector_put(c, 1, "two", 3)); - code = connector_sync(c, 3000); - check("sync ", code); - if(code == 0) printf("sent neither message!"); - else printf("sent both messages!"); - } - - printf("cleaning up...\n"); - connector_destroy(c); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/old/4_nondeterminism/make.sh b/examples/old/4_nondeterminism/make.sh deleted file mode 100644 index 47ee3dafa30728d73105d4d36dbd58ca09827fbb..0000000000000000000000000000000000000000 --- a/examples/old/4_nondeterminism/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o amy \ No newline at end of file diff --git a/examples/old/5_recovery/amy.c b/examples/old/5_recovery/amy.c deleted file mode 100644 index 717fba1351219e8ad69e991ca4cdc634b59ce804..0000000000000000000000000000000000000000 --- a/examples/old/5_recovery/amy.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { // AMY - char * pdl = buffer_pdl("eg_protocols.pdl"); - - Connector* c = connector_new(); - printf("configuring...\n"); - - check("config ", connector_configure(c, pdl, "sync_two")); - check("bind 0 ", connector_bind_native(c, 0)); - check("bind 1 ", connector_bind_native(c, 1)); - check("bind 2 ", connector_bind_passive(c, 2, "127.0.0.1:7000")); - check("bind 3 ", connector_bind_passive(c, 3, "127.0.0.1:7001")); - printf("connecting...\n"); - check("connect", connector_connect(c, 5000)); - - int round, code; - for(round = 0; true; round++) { - printf("\nround %d\n", round); - - check("next ", connector_next_batch(c)); - check("put ", connector_put(c, 0, "one", 3)); - check("put ", connector_put(c, 1, "two", 3)); - code = connector_sync(c, 3000); - if(code == 0) printf("sent neither message!"); - else if(code == 1 ) printf("sent both messages!"); - else if(code == -1) printf("No interaction! Recovered state.\n"); - else { - printf("Unrecoverable error!\n"); - connector_dump_log(c); - break; - } - } - - printf("cleaning up...\n"); - connector_destroy(c); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/old/5_recovery/bob.c b/examples/old/5_recovery/bob.c deleted file mode 100644 index 7a74479040060ade4aa184cd7ae04436f646ae45..0000000000000000000000000000000000000000 --- a/examples/old/5_recovery/bob.c +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include "../../reowolf.h" -#include "../utility.c" - -int main() { - - Connector* c = connector_new(); - printf("configuring...\n"); - char * pdl = buffer_pdl("eg_protocols.pdl"); - check("config ", connector_configure(c, pdl, "sync_two")); - check("bind 0 ", connector_bind_active(c, 0, "127.0.0.1:7000")); - check("bind 1 ", connector_bind_active(c, 1, "127.0.0.1:7001")); - check("bind 2 ", connector_bind_native(c, 2)); - check("bind 3 ", connector_bind_native(c, 3)); - - printf("connecting...\n"); - check("connect", connector_connect(c, 5000)); - - const unsigned char * msg; - const char * nth[2] = {"first", "second"}; - int i, code, msg_len; - char yn[2]; - - while(true) { - printf("\nround %d...\n", i); - printf("Which of the two messages should we receive? (y/n)(y/n) (eg: yy): "); - scanf(" %c%c", &yn[0], &yn[1]); - for (i = 0; i < 2; i++) { - if (yn[i] != 'y' && yn[i] != 'n') { - printf("Expected (y/n) input!"); - continue; - } - } - printf("Receiving messages [%c, %c]\n", yn[0], yn[1]); - if (yn[0] == 'y') check("get first ", connector_get(c, 0)); - if (yn[1] == 'y') check("get second ", connector_get(c, 1)); - code = connector_sync(c, 1000); - if(code >= 0) { - for (i = 0; i < 2; i++) { - if (yn[i] == 'y') { - check("read ", connector_gotten(c, i, &msg, &msg_len)); - printf("Got %s msg `%.*s`\n", nth[i], msg_len, msg); - } - } - } else if(code == -1) { - printf("No interaction! Recovered state.\n"); - } else { - printf("Unrecoverable error!\n"); - connector_dump_log(c); - break; - } - } - - printf("cleaning up\n"); - connector_destroy(c); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/old/5_recovery/make.sh b/examples/old/5_recovery/make.sh deleted file mode 100644 index 29265a080aec2c404da4a511f2c78a513596c536..0000000000000000000000000000000000000000 --- a/examples/old/5_recovery/make.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -LIB_PATH="../" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH amy.c -o amy -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH bob.c -o bob diff --git a/examples/old/6_constraint_solve/main.c b/examples/old/6_constraint_solve/main.c deleted file mode 100644 index 76e87d4f8b18648ed70f9a9884b8b6038a226e9b..0000000000000000000000000000000000000000 --- a/examples/old/6_constraint_solve/main.c +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -#include -#include -#include "../../reowolf.h" -#include "../utility.c" - -#define N 4 - -typedef struct PeerInfo { - int id; - bool puts; // true iff the channel to this peer is INCOMING. -} PeerInfo; - -// return the index of (i,j) in the lexicographic ordering of set {(i,j) : ij -int combination_index(unsigned int i, unsigned int j) { - if (i > j) { - // swap! - i ^= j; - j ^= i; - i ^= j; - } - assert(iputs = i < my_id; - pi->id = i < my_id ? i : i+1; - printf("info %d puts=%d id=%d\n", i, pi->puts, pi->id); - } -} - -const char* addrs[] = { - "127.0.0.1:7000", - "127.0.0.1:7001", - "127.0.0.1:7002", - "127.0.0.1:7003", - "127.0.0.1:7004", - "127.0.0.1:7005", -}; -int main(int arg_c, char * argv[]) { - int my_id, peer_id, i, code; - if (arg_c != 2) { - printf("Expected one arg: which peer I am in 0..4"); - return 1; - } - my_id = atoi(argv[1]); - assert(0 <= my_id && my_id < N); - printf("I have id %d\n", my_id); - - char * pdl = buffer_pdl("eg_protocols.pdl"); - - Connector* c = connector_new(); - printf("configuring...\n"); - check("config ", connector_configure(c, pdl, "xor_three")); - - PeerInfo peer_infos[3]; - init_peer_infos(peer_infos, my_id); - - // for every native port, bind native and protocol port. - for (i = 0; i < 3; i++) { - PeerInfo * pi = &peer_infos[i]; - int addr_idx = combination_index(my_id, pi->id); - if (pi->puts) { - check("bind to putter ", - connector_bind_passive(c, i*2, addrs[addr_idx])); - check("bind native ", connector_bind_native(c, i*2 + 1)); - } else { - check("bind native ", connector_bind_native(c, i*2)); - check("bind to putter ", - connector_bind_active(c, i*2 + 1, addrs[addr_idx])); - } - } - printf("connecting...\n"); - check("connect", connector_connect(c, 3000)); - - // for every native port, create a singleton batch - for (i = 0; i < 3; i++) { - if (i > 0) assert(connector_next_batch(c) >= 0); - PeerInfo * pi = &peer_infos[i]; - check("op ", pi->puts? - connector_get(c, i): - connector_put(c, i, NULL, 0)); - } - // solve! - printf("solving...\n"); - code = connector_sync(c, 3000); - if (code < 0) printf("Error code on sync! %d\n", code); - else printf("{ my_id: %d, peer_id: %d }\n", my_id, peer_infos[code].id); - - printf("cleanup...\n"); - connector_destroy(c); - free(pdl); - return 0; -} \ No newline at end of file diff --git a/examples/old/6_constraint_solve/make.sh b/examples/old/6_constraint_solve/make.sh deleted file mode 100644 index 0fc253d99f1b661b85f559df9687262c0c24c2e1..0000000000000000000000000000000000000000 --- a/examples/old/6_constraint_solve/make.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -LIB_PATH="../" -gcc -L $LIB_PATH -lreowolf_rs -Wl,-R$LIB_PATH main.c -o main diff --git a/examples/old/REMINDER dll is a symlink.txt b/examples/old/REMINDER dll is a symlink.txt deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/examples/old/eg_protocols.pdl b/examples/old/eg_protocols.pdl deleted file mode 100644 index 20d134b9ef3ab7725484093bb04a050455a75b0e..0000000000000000000000000000000000000000 --- a/examples/old/eg_protocols.pdl +++ /dev/null @@ -1,33 +0,0 @@ - -primitive forward(in i, out o) { - while(true) synchronous { - put(o, get(i)); - } -} -composite dynamic(in i, out o) { - new forward(i, o); -} -primitive sync(in i, out o) { - while(true) synchronous { - if(fires(i)) { - put(o, get(i)); - } - } -} - -primitive sync_two(in ia, in ib, out oa, out ob) { - while(true) synchronous { - if (fires(ia)) { - put(oa, get(ia)); - put(ob, get(ib)); - } - } -} - -primitive xor_three(in ai, out ao, in bi, out bo, in ci, out co) { - synchronous { - if (fires(ai)) put(ao, get(ai)); - else if (fires(bi)) put(bo, get(bi)); - else put(co, get(ci)); - } -} \ No newline at end of file diff --git a/examples/old/utility.c b/examples/old/utility.c deleted file mode 100644 index 321a3ab691a09ad6adca26d3ea50a873ebd26208..0000000000000000000000000000000000000000 --- a/examples/old/utility.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -void check(const char* phase, int code) { - if (code < 0) { - printf("ERR %d in phase `%s`. Err was `%s`\nEXITING!\n", - code, phase, connector_error_peek()); - exit(1); - } -} - -// allocates a buffer! -char * buffer_pdl(char * filename) { - FILE *f = fopen(filename, "rb"); - if (f == NULL) { - printf("Opening pdl file returned errno %d!\n", errno); - exit(1); - } - fseek(f, 0, SEEK_END); - long fsize = ftell(f); - fseek(f, 0, SEEK_SET); - char *pdl = malloc(fsize + 1); - fread(pdl, 1, fsize, f); - fclose(f); - pdl[fsize] = 0; - return pdl; -} \ No newline at end of file