text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
//#UnixOnly: true
//#SkipEngine:V8:async functions are not supported yet
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <wasix/context.h>
// Test nested context switches with multiple visits to each context
wasix_context_id_t ctxA, ctxB, ctxC;
int visit_count_A = 0;
int visit_count_B = 0;
int vi... | fim | wasmerio/wasmer | c |
//#UnixOnly: true
//#SkipEngine:V8:async functions are not supported yet
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wasix/context.h>
// Test context switching while file operations are pending
wasix_context_id_t ctx1, ctx2, ctx3;
int pipe_fds[2];
voi... | fim | wasmerio/wasmer | c |
//#UnixOnly: true
//#SkipEngine:V8:async functions are not supported yet
// Test context switching during recursive system calls
// This tries to trigger the store context borrow error by doing
// complex syscalls that might borrow the store while switching
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#in... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#UnixOnly: true
//#SkipEngine:V8:async functions are not supported yet
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <wasix/context.h>
wasix_context_id_t context1;
wasix_context_id_t context2;
char* <|fim_suffix|>wasix_context_switch(context1);
stop = 1;
... | fim | wasmerio/wasmer | c |
<|fim_suffix|>f(stderr, "ctx2 switching to ctx3 (id=%llu)\n",
(unsigned long long)ctx3);
fflush(stderr);
wasix_context_switch(ctx3);
// Should not reach here in this test
fprintf(stderr, "ERROR: ctx2 resumed unexpectedly\n");
fflush(stderr);
execution_order[order_idx++] = 99;
wasix_context_swit... | fim | wasmerio/wasmer | c |
<|fim_suffix|>asix_context_create(&context1, test1);
wasix_context_create(&context2, test2);
wasix_context_switch(context1);
return NULL;
}
int main() {
pthread_t thread;
pthread_create(&thread, NULL, abort_in_thread, NULL);
pthread_join(thread, NULL);
if (counter != 4) {
printf("Error: expected co... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#UnixOnly: true
//#SkipEngine:V8:async functions are not supported yet
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdli<|fim_suffix|>s destroyed before the first
// switch works
wasix_context_destroy(context2);
wasix_context_switch(context2);
assert(counter == 1);
ex... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#UnixOnly: true
//#SkipEngine:V8:async functions are not supported yet
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <wasix/context.h>
wasix_context_id_t context1;
wasix_context_id_t context2;
int stop = 0;
int counter = 0;
void test1(void) {
<|fim_suffix|>e(... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#UnixOnly: true
//#SkipEngine:V8:async functions are not supported yet
// Minimal: 3 mutually recursive funcs, 3 contexts, circular pattern
#include <assert.h>
#include <stdio.h>
#include <wasix/context.h>
wasix_context_id_t ctx1, ctx2, ctx3;
void func_b(int d);
void func_c(int d);
void func_a(int d... | fim | wasmerio/wasmer | c |
<|fim_suffix|>d_sum,
full_arguments, sizeof(full_arguments),
oversized_result, sizeof(oversized_result), true);
assert(error == -1);
assert(errno == EINVAL);
memset(oversized_result, 0x7a, sizeof(oversized_result));
errno = 0;
error = wasix_call_dynam... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <wasix/call_dynamic.h>
#include <wasix/reflection.h>
typedef struct {
int x;
double y;
char z[32];
} TestStruct;
static TestStruct update_struct(TestStruct s) {
s.x += 1;
s.y *= 2.0;
strcat(s.z, "_updated... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <wasix/call_dynamic.h>
static int fib(int n) {
if (n <= 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
static void write_i32(uint8_t* buffer, int32_t value) {
memcpy(buffer, &value, sizeof(value... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <wasix/closure.h>
typedef struct {
int call_count;
} ClosureState;
static void write_i32(uint8_t* buffer, int32_t value) {
memcpy(buffer, &value, sizeof(value));
}
static int32_t read_i32(const uint8_t* buffer) ... | fim | wasmerio/wasmer | c |
#include <stdio.h>
extern "C" void cpp_function() { printf("Hello world from C++\n"); }
<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <assert.h>
#include <dlfcn.h>
#include <std<|fim_suffix|>() {
void* handle = dlopen("liblibrary.so", RTLD_NOW | RTLD_LOCAL);
assert(handle);
cpp_function_t cpp_function = dlsym(handle, "cpp_function");
assert(cpp_function);
cpp_function();
int result = dlclose(handle);
assert(res... | fim | wasmerio/wasmer | c |
<|fim_suffix|>);
dlclose(handle2);
return 1;
}
// side_func2 returns x * 2
res = side_func2(2);
if (res != 4) {
fprintf(stderr, "side_func returned unexpected value: %d\n", res);
dlclose(handle1);
dlclose(handle2);
return 1;
}
dlclose(handle1);
dlclose(handle2);
return 0;
}<|f... | fim | wasmerio/wasmer | c |
<|fim_prefix|>extern int side_needed_<|fim_suffix|> 42; }<|fim_middle|>func(int);
int side_func(int x) { return x +<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|> return x * 2; }<|fim_prefix|>extern int<|fim_middle|> side_needed_func(int);
int side_func(int x) {<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>) = (int (*)(int))dlsym(h, "side_func");
if (!f || f(5) != 10) abort();
dlclose(h);
usleep(40);
}
return NULL;
}
static void* spawn_loop(void* arg) {
(void)arg;
for (int i = 0; i < SPAWN_ITERATIONS; i++) {
pthread_t t;
if (pthread_create(&t, NULL, noop_thread, NULL) != 0) abor... | fim | wasmerio/wasmer | c |
<|fim_suffix|>return x * 2; }
<|fim_prefix|>int side<|fim_middle|>_func(int x) { <|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>[i], NULL, call_side_many, NULL) != 0) abort();
}
for (int i = 0; i < WORKER_THREADS; i++) pthread_join(workers[i], NULL);
if (dlclose(shared_handle) != 0) abort();
printf("topology dl-multi-thread-shared-side-calls ok\n");
fflush(stdout);
return 0;
}
<|fim_prefix|>#include <dlfcn.h>
#includ... | fim | wasmerio/wasmer | c |
<|fim_suffix|>func(int x) { return x * 2; }
<|fim_prefix|>in<|fim_middle|>t side_<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>int main_needed_func(in<|fim_suffix|>1; }<|fim_middle|>t x) { return x + <|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>or());
return 1;
}
pthread_kill(thread, SIGTERM);
// Print something to make sure printf and, by extension, data relocations
// work. Do *NOT* remote this.
printf(" All tests passed successfully!\n");
return 0;
}
<|fim_prefix|>#include <dlfcn.h>
#include <pthread.h>
#include <signal.h>... | fim | wasmerio/wasmer | c |
<|fim_suffix|>de_needed_func pointer mismatch\n");
return -1;
}
if (main_exported_ptr() != 85) {
printf("main_exported returned unexpected value\n");
return -1;
}
return x + 4;
}<|fim_prefix|>#include <stdio.h>
// This generates a GOT.func entry that gets resolved between
// loading this module a... | fim | wasmerio/wasmer | c |
<|fim_suffix|>) * 2;
}<|fim_prefix|>#include <stdio.h>
extern int side_needed_func(int);
// This generates a GOT.func entry that gets resolved between
// loading this module and side-needed.c, which caused an
// error in the past.
extern int main_exported();
int (*main_exported_ptr)() <|fim_middle|>= main_exported;
... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <dlfcn.h>
#include <pthread.h>
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h<|fim_suffix|>top_dlsym)) {
int (*fn)(int) = (int (*)(int))dlsym(handle, "side_func");
if (!fn) {
atomic_store(&worker_failed, 1);
atomic_store(&stop_dlsym, 1);
break;
}
if... | fim | wasmerio/wasmer | c |
<|fim_prefix|>int<|fim_suffix|>c(int x) { return x * 2; }
<|fim_middle|> side_fun<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
__attribute__((constructor)) static void init() { printf("a"); }
// The main module is loaded first, so its constructor runs before `main`.
__attribute__((destructor)) static void fini() { printf("f"); }
// The main module stays loaded until proc... | fim | wasmerio/wasmer | c |
<|fim_suffix|> void fini() { printf("d"); }
<|fim_prefix|>#include <stdio.h>
// The loader runs this during `dlopen`, before control returns to `main`.
__attribute__((constructor)) static void init() { printf("b"); }
//<|fim_middle|> The loader runs this during `dlclose`, before `dlclose` returns to `main`.
__attribu... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <dlfcn.h>
#include <stdio.h>
int main() {
void* handle = dlopen("./libside.so", RTLD_NOW | RTLD_GLOBAL);
if (!handle) {
fprintf(stderr, "dlopen failed: %s\n", dlerror());
ret<|fim_suffix|> dlclose(handle);
return 1;
}
if (dlclose(handle) != 0) {
fprintf(stderr, "dlclos... | fim | wasmerio/wasmer | c |
int side_func(int x) { return x * 2; }<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
void __attribute__((constructor)) main_ctor() { printf("Main loaded\n"); }
void __attribute__((destructor)) main_dtor() { printf("Main unloaded\n"); }
// TODO: the side module should run its destructors when it's unloaded
// via dlclose, but cur... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <stdio.h>
int data_export = 42;
extern int data_export2;
extern int func_export2();
void __attribute__((constructor)) side1_ctor() { printf("Side 1 loaded\n"); }
void __attribute__((destructor)) side1_dtor() { printf("Side 1 unloaded\n"); }
static void local_function(int* i) {
printf("loca... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <stdio.h>
int data_export2 = 10101;
int<|fim_suffix|><|fim_middle|> func_export2() {
printf("starting func_export2\n");
return 987;
}<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>char module<|fim_suffix|> return 'A'; }
<|fim_middle|>_name() {<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>e_name() { return 'B'; }
<|fim_prefix|>char modu<|fim_middle|>l<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
typedef char (*module_name_t)();
int main() {
void* handle_a = dlopen("a/libside.so", RTLD_NOW | RTLD_LOCAL);
assert(handle_a);
module_name_t module_name_a = dlsym(handle_a, "mod<|fim_suffix|>t_a == 0);
int result_b = dlclose(handle_b)... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <stdio.h>
#include <stdlib.h>
extern int data_export;
extern int func_export();
void __attribute__((constructor)) main_ctor() { printf("Main loaded\n"); }
void __attribute__((destructor)) main_dtor() { printf("Main unloaded\n"); }
int main() {
printf("Main started\n");
printf("data_expor... | fim | wasmerio/wasmer | c |
<|fim_suffix|> printf("Side 1 unloaded\n"); }
static void local_function(int* i) {
printf("local_function called with %d\n", *i);
}
int func_export() {
printf("func_export started\n");
int x = 123;
local_function(&x);
printf("calling func_export2\n");
printf("result: %d\n", func_export2());
printf("ca... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <stdio.h>
int da<|fim_suffix|> func_export2\n");
return 987;
}<|fim_middle|>ta_export2 = 10101;
int func_export2() {
printf("starting<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>uded for when the feature is supported.
int main() {
int side_value = get_value();
printf("The shared library returned: %i\n", side_value);
assert(side_value == 42);
return 0;
}
<|fim_prefix|>#include <assert.h>
#include <stdio.h>
extern int get_value();
// NOTE: Currently broken on wasix, becau... | fim | wasmerio/wasmer | c |
<|fim_prefix|>int get_value<|fim_suffix|>) { return 42; }
<|fim_middle|>(<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
typedef int (*get_value_t)();
int main() {
void* handle = dlopen("libside.so", RTLD_NOW | RTLD_LOCAL);
assert(handle);
get_value_<|fim_suffix|>et_value");
assert(get_value);
int side_value = get_value();
printf("The shared library r... | fim | wasmerio/wasmer | c |
<|fim_prefix|>int get_value() { retu<|fim_suffix|>2; }
<|fim_middle|>rn 4<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: topology spawn-under-nanosleep-worker ok
#include <pthread.h>
#include <stdatomic.h>
#include <stdio.h>
#include <time.h>
#define BUSY_THREADS 4
#define SPAWN_ROUNDS 24
#define THREADS_PER_ROUND 16
static atomic_int stop_busy = 0;
static void* nanosleep_busy(void* arg) {
(void)arg;... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: topology spawn-under-sched-yield-worker ok
#include <pthread.h>
#include <stdatomic.h>
#include <stdio.h>
#include <unistd.h>
#include <wasi/api.h>
#define BUSY_THREADS 4
#define SPAWN_ROUNDS 24
#define THREADS_PER_ROUND 16
static atomic_int stop_busy = 0;
st<|fim_suffix|>op_thread(v... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <dlfcn.h>
#include <pthread.h>
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef NUM_SIDES
#error "NUM_SIDES must be defined by build.sh"
#endif
#ifndef SPAWN_BATCH
#error "SPAWN_BATCH must be defined by build.sh"
#endif
#ifndef SPAWN_ROUNDS
#error "SPAW... | fim | wasmerio/wasmer | c |
<|fim_suffix|>(a, b) a##b
// Per-module TLS ensures __wasix_init_tls is exported and replayed on spawn.
_Thread_local int CAT(side_tls_, NAME_SUFFIX) = NAME_SUFFIX;
// Unique entry point per copy so main can dlopen/dlsym each module.
int CAT(side_touch_, NAME_SUFFIX)(void) {
CAT(side_tls_, NAME_SUFFIX) = 1;
retur... | fim | wasmerio/wasmer | c |
<|fim_suffix|>4;
<|fim_prefix|>int erryes <|fim_middle|>= 44<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <stdio.h>
extern in<|fim_suffix|>;
return 0;
}
<|fim_middle|>t erryes;
int main() {
printf("error number: %i\n", erryes)<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
type<|fim_suffix|>, RTLD_NOW);
if (!handle) {
printf("dlopen failed: %s\n", dlerror());
return 1;
}
side_type side = (side_type)dlsym(handle, "side");
if (!side) {
printf("dlsym failed: %s\n", dlerror());
... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <stdio.h>
#include <stdlib.h>
typedef void (*cool_fn_type)();
void cool_fn_impl() { printf("called\n"); }
volatile cool_fn_type* keep;
void repro() {
cool_fn_type<|fim_suffix|>side() {
repro();
return 0;
}
<|fim_middle|> cool_fn = cool_fn_impl;
int before = !!cool_fn;
// Take the a... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
typedef void (*side_type)();
int main() {
void* handle = dlopen("l<|fim_suffix|>(0);
}
<|fim_middle|>ibside.so", RTLD_NOW);
if (!handle) {
printf("dlopen failed: %s\n", dlerror());
return 1;
}
side_type side = ... | fim | wasmerio/wasmer | c |
#include <stdio.h>
#include <stdlib.h>
typedef void (*cool_fn_type)();
void cool_fn_impl() { printf("called\n"); }
void side() {
cool_fn_type cool_fn = cool_fn_impl;
cool_fn();
}
<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
void* handle = dlopen("libside.so", RTLD_NOW);
asse<|fim_suffix|>ert(get_value != NULL);
int value = get_value();
printf("The dynamic library returned: %d\n", value);
assert(value == 42);
}
<|fim_middle|>... | fim | wasmerio/wasmer | c |
<|fim_prefix|>int get_value() { r<|fim_suffix|>2; }
<|fim_middle|>eturn 4<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>e__((__weak__)) extern int other_func();
int main() {
if (!other_func) {
printf("other_func is not defined\n");
exit(1);
}
int result = other_func();
printf("other_func returned %i\n", result);
exit(0);
}
<|fim_prefix|>#include <assert.h>
#include <stdio.h>
#<|fim_middle|>include <stdli... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>int other_func(<|fim_suffix|>rn 42; }
<|fim_middle|>) { retu<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>her_func is not defined, but the program still compiled\n");
return 0;
}
int result = other_func();
printf("other_func returned %i\n", result);
return 1;
}
<|fim_prefix|>//#ExpectedStdout: other_func is not defined, but the program still compiled
#include <assert.h>
#include <|fim_middle|><std... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>t exception: %s\n", msg);
}
}<|fim_prefix|>#include <cstdio>
#include "thrower.hpp"
void catch_exception() {
<|fim_middle|>try {
throw_exception();
} catch (const char* msg) {
printf("Caugh<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>void cat<|fim_suffix|>h_exception();<|fim_middle|>c<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>
#else
#include "catcher.hpp"
#endif
int main() {
catch_exception();
return 0;
}
<|fim_prefix|>
#include <stdio.h><|fim_middle|>
#ifdef STATIC_THROWER
#include "thrower.cpp"
#else
#include "thrower.hpp"
#endif
#ifdef STATIC_CATCHER
#include "catcher.cpp"<|endoftext|> | fim | wasmerio/wasmer | cpp |
#include "thrower.hpp"
void throw_exception_proxy() {
// throw_exception();
}<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>void throw_exce<|fim_suffix|>_proxy();<|fim_middle|>ption<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>ception occurred!"; }<|fim_prefix|>void throw_exception() { th<|fim_middle|>row "An ex<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>xception();<|fim_prefix|>void t<|fim_middle|>hrow_e<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#inc<|fim_suffix|>tch (...) {
printf("Caught some exception\n");
}
return 42;
}<|fim_middle|>lude <stdio.h>
int try_catch_in_lib() {
try {
throw "An exception occurred!";
} ca<|endoftext|> | fim | wasmerio/wasmer | cpp |
int try_catch_in_lib();<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>ary.hpp"
int main() {
try_catch_in_lib();
return 0;
}<|fim_prefix|>#include <assert.h>
#inclu<|fim_middle|>de <stdio.h>
#include "libr<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>e exception\n");
}
return 42;
}<|fim_prefix|>#include <stdio.h>
int try_catch_in_lib() {
try {
throw "An exc<|fim_middle|>eption occurred!";
} catch (...) {
printf("Caught som<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>in<|fim_suffix|>atch_in_lib();<|fim_middle|>t try_c<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|> some exception\n");
}
return 42;
}
int main() {
try_catch_in_main();
try_catch_in_lib();
return 0;
}<|fim_prefix|>#include <assert.h>
#include <stdio.h>
#include "library.hpp"
int try_catch_in_main() {
try {
throw "An exception occurred!";
} catch (...) {
<|fim_middle|> printf("Ca... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>ght exception in main: " << myNum << std::endl;
return myNum;
}
return 1;
}
<|fim_prefix|>#include <iostream>
void bar() { throw 40; }
void foo() { bar(); }
void baz() {
try {
foo();
} catch (int& e) {
e += 2;
std::cout << "caught exception, will rethrow" << std::endl;
thro... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>// Originally reported: https://github.com/wasme<|fim_suffix|> {
try {
throw 1;
} catch (int e) {
std::cout << "inner " << e << std::endl;
throw 2;
}
} catch (int e) {
std::cout << "outer " << e << std::endl;
return 0;
}
return 1;
}
<|fim_middle|>rio/wasmer/iss... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>;
}
return 0;
}<|fim_prefix|>#include <stdio.h>
int main() {
try {
throw "An exception occurred!";
} catch (const <|fim_middle|>char* msg) {
printf("Caught exception: %s\n", msg)<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>{
printf("Caught exception: %s\n", msg);
}
return 0;
}<|fim_prefix|>#include <stdio.h>
int main() {
try {
throw "An exception occurred!";
} catch (const char*<|fim_middle|> msg) <|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>void throw_exception();
int get_number_fro<|fim_suffix|>42;
}<|fim_middle|>m_library() {
throw_exception();
return <|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>ibrary();<|fim_prefix|>int get_numb<|fim_middle|>er_from_l<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <assert.h>
#include <stdio.h>
#include "library.hpp"
void throw_exception() { throw "An exception occurred!"; }
int main() {
try {
// This function calls throw_<|fim_suffix|>tch (const char* msg) {
printf("Caught exception: %s\n", msg);
}
return 0;
}
<|fim_middle|>exception() fro... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|><|fim_suffix|>ibrary() { return 42; }<|fim_middle|>int get_number_from_l<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>int get_number_<|fim_suffix|>rom_library();<|fim_middle|>f<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>st char* msg) {
printf("Caught exception: %s\n", msg);
}
return 0;
}<|fim_prefix|>#incl<|fim_middle|>ude <assert.h>
#include <stdio.h>
#include "library.hpp"
int main() {
try {
// See if the presence of a shared library changes anything.
int number = get_number_from_library();
asse... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>ead_join(thread, NULL);
return 5;
}
<|fim_prefix|>//#Ignored: flaky test (#6538)
//#ExpectedExitCode: 134
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef NULL
#define NULL ((void*)0)
#endif
void* abort_in_thread(void* arg) {
abort();
return NULL;
}
int main(<|fim_middle|>) {
... | fim | wasmerio/wasmer | c |
<|fim_suffix|>#include <stdio.h>
#include <stdlib.h>
int main() {
exit(99);
return 1;
}
<|fim_prefix|>//#MustFail: true
//#ExpectedExitCode: 99
<|fim_middle|>#include <assert.h>
<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#includ<|fim_suffix|>d_ret;
if (pthread_join(thread, &thread_ret) != 0) {
perror("join");
return -1;
}
sleep(1);
return 1;
}
<|fim_middle|>e <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wasix/call_dynamic.h>
void dynamically_called()... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
<|fim_suffix|>_function_pointer_t closure_pointer = 0;
int exit_code = 99;
int error = wasix_closure_allocate(&closure_pointer);
assert(error == 0);
error = wasix_closure_prepare((wasix_function_pointer_t)exit_with_co... | fim | wasmerio/wasmer | c |
<|fim_suffix|>thread = {0};
if (pthread_create(&thread, &attr, &thread_func, (void*)stdout) != 0) {
perror("create thread");
return -1;
}
void* thread_ret;
if (pthread_join(thread, &thread_ret) != 0) {
perror("join");
return -1;
}
sleep(1);
return 1;
}
<|fim_prefix|>#include <assert.h>
#... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#Ignore<|fim_suffix|>>
#include <unistd.h>
void* print_and_exit(void* data) {
printf("Thread called!\n");
exit(99); // Exit the program with 0
}
int main() {
pthread_attr_t attr = {0};
if (pthread_attr_init(&attr) != 0) {
perror("init attr");
return -1;
}
pthread_t thread = {0};
... | fim | wasmerio/wasmer | c |
<|fim_suffix|>}<|fim_prefix|>#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
exit(0);
return 1;<|fim_middle|>
<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|> }
pthread_t thread = {0};
if (pthread_create(&thread, &attr, &thread_func, (void*)stdout) != 0) {
perror("create thread");
return -1;
}
void* thread_ret;
if (pthread_join(thread, &thread_ret) != 0) {
perror("join");
return -1;
}
sleep(1);
return 1;
}
<|fim_prefix|>#incl... | fim | wasmerio/wasmer | c |
<|fim_suffix|>= *(int*)user_data_ptr;
printf("Closure call\n");
exit(exit_code);
}
int main() {
wasix_function_pointer_t closure_pointer = 0;
int exit_code = 0;
int error = wasix_closure_allocate(&closure_pointer);
assert(error == 0);
error = wasix_closure_prepare((wasix_function_pointer_t)exit_with_co... | fim | wasmerio/wasmer | c |
<|fim_suffix|>closure_pointer, NULL, 0, NULL, 0, &exit_code);
assert(error == 0);
((void (*)(void))closure_pointer)();
return 0;
}
int main() {
pthread_attr_t attr = {0};
if (pthread_attr_init(&attr) != 0) {
perror("init attr");
return -1;
}
pthread_t thread = {0};
if (pthread_create(&thread,... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void* print_and_exit(void* dat<|fim_suffix|>
pthread_t thread = {0};
if (pthread_create(&thread, &attr, &print_and_exit, (void*)stdout) != 0) {
perror("create thread");
return -1;
}
void* thread_ret;
if (p... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#includ<|fim_suffix|>t main(void) {
const char* path = "fd_allocate_basic";
unlink(path);
int fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0644);
assert(fd >= 0);
assert(file_size(fd) == 0);
__wasi_errno_t err = __wasi_fd_allocate((__wasi_fd_t)fd, 0, 10);
assert(err == _... | fim | wasmerio/wasmer | c |
<|fim_suffix|>
assert(strcmp(b, "Z") == 0);
}
<|fim_prefix|>#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main(void) {
int fd = open("/tmp/x", O_CREAT | O_RDWR | O_APPEND, 0644);
assert(write(fd, "12345678901234567", 17) == 17);
assert(ftruncate(fd, 0) == 0);
assert<|fim_... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
int main(void) {
int fd = open("/tmp/append_seek", O_CREAT | O_RDWR | O_APPEND, 0644);
write(fd, "abc", 3);
lseek(fd, 0, SEEK_SET);
char b[4] = {0};
assert(read(fd, b, sizeof(b)) == 3);
assert(strcmp(b, "abc") == 0);
}
<|endoft... | fim | wasmerio/wasmer | c |
<|fim_suffix|> %d\n", errno);
return 1;
}
fd = open(".", O_RDONLY | O_DIRECTORY);
if (fd < 0) {
perror("open dir");
return 1;
}
if (close(fd) < 0) {
perror("dir close");
return 1;
}
return 0;
}
<|fim_prefix|>#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <err<|fim_suffix|>er_dup2(int stdio_fd) {
int fds[2];
assert(pipe(fds) == 0);
assert(dup2(fds[1], stdio_fd) == stdio_fd);
close(fds[1]);
errno = 0;
int ret = close(stdio_fd);
assert(ret == 0);
close(fds[0]);
}
int main(void) {
assert_close_ok_after_dup2(S... | fim | wasmerio/wasmer | c |
<|fim_suffix|>r this previously returning EIO
errno = 0;
assert(fdatasync(fds[0]) == -1);
assert(errno == EINVAL);
errno = 0;
assert(fdatasync(fds[1]) == -1);
assert(errno == EINVAL);
// Similarly, this should also fail with EINVAL
// Regression test for this previously returning success
// from spe... | fim | wasmerio/wasmer | c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.