Skip to content
Snippets Groups Projects
Commit 75bef808 authored by Florian Fischer's avatar Florian Fischer
Browse files

export async functions to C

parent f07625ec
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
#include "BinaryPrivateSemaphore.hpp" #include "BinaryPrivateSemaphore.hpp"
#include "CountingPrivateSemaphore.hpp" #include "CountingPrivateSemaphore.hpp"
#ifdef EMPER_ASYNC_LIB
#include "AsyncLibrary.hpp"
#endif
runtime* init_runtime(void) { runtime* init_runtime(void) {
Runtime* r = new Runtime(); Runtime* r = new Runtime();
return reinterpret_cast<runtime*>(r); return reinterpret_cast<runtime*>(r);
...@@ -96,3 +100,39 @@ void wait_cps(cps* sem) { ...@@ -96,3 +100,39 @@ void wait_cps(cps* sem) {
countingPrivateSemaphore->wait(); countingPrivateSemaphore->wait();
} }
#ifdef EMPER_ASYNC_NETWORK
int async_recv(int fd, unsigned char* buff, int buff_len, int flags) {
bool read_once = flags & READ_FULL_BUFFER == 0;
bool fd_serialized = flags & UNSERIALIZED == 0;
return io::async_recv(fd, buff, buff_len, read_once, fd_serialized);
}
int async_send(int fd, unsigned char* buff, int buff_len, int flags) {
bool fd_serialized = flags & UNSERIALIZED == 0;
return io::async_recv(fd, buff, buff_len, read_once, fd_serialized);
}
int async_connect(int fd, sockaddr* sockaddress, socklen_t len, int flags) {
bool fd_serialized = flags & UNSERIALIZED == 0;
return io::async_connect(fd, sockaddress, len, fd_serialized);
}
int async_accept(int fd, sockaddr* sockaddress, socklen_t len, int flags) {
bool fd_serialized = flags & UNSERIALIZED == 0;
return io::async_accept(fd, sockaddress, len, fd_serialized);
}
#endif
#ifdef EMPER_ASYNC_DISK_IO
int async_read_file(int fd, unsigned char* buff, size_t count, off_t offset) {
return io::async_read_file(fd, buff, count, offset);
}
int async_write_file(int fd, const unsigned char* buff, size_t count, off_t offset) {
return io::async_write_file(fd, buff, count, offset);
}
#endif
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
#include "emper-common.h" #include "emper-common.h"
#ifdef EMPER_ASYNC_NETWORK
#include "sys/socket.h"
#endif
typedef struct runtime runtime; typedef struct runtime runtime;
typedef struct fiber fiber; typedef struct fiber fiber;
...@@ -56,6 +60,27 @@ extern "C" { ...@@ -56,6 +60,27 @@ extern "C" {
void wait_cps(cps* sem); void wait_cps(cps* sem);
#ifdef EMPER_ASYNC_NETWORK
enum EMPER_ASYNC_NETWORK_FLAGS {
READ_FULL_BUFFER = 1,
UNSERIALIZED = 2,
};
int async_recv(int fd, unsigned char* buff, int buff_len, int flags);
int async_send(int fd, unsigned char* buff, int buff_len, int flags);
int async_connect(int fd, sockaddr* sockaddress, socklen_t len, int flags);
int async_accept(int fd, sockaddr* sockaddress, socklen_t len, int flags);
#endif
#ifdef EMPER_ASYNC_DISK_IO
int async_read_file(int fd, unsigned char* buff, size_t count, off_t offset);
int async_write_file(int fd, const unsigned char* buff, size_t count, off_t offset);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment