whitespace cleanup after rebase
This commit is contained in:
parent
b712e5e132
commit
625c518eec
@ -9,18 +9,18 @@
|
|||||||
|
|
||||||
// crust fn pointers
|
// crust fn pointers
|
||||||
typedef void (*crust_async_op_cb)(uv_loop_t* loop, void* data,
|
typedef void (*crust_async_op_cb)(uv_loop_t* loop, void* data,
|
||||||
uv_async_t* op_handle);
|
uv_async_t* op_handle);
|
||||||
typedef void (*crust_simple_cb)(uint8_t* id_buf, void* loop_data);
|
typedef void (*crust_simple_cb)(uint8_t* id_buf, void* loop_data);
|
||||||
typedef void (*crust_close_cb)(uint8_t* id_buf, void* handle,
|
typedef void (*crust_close_cb)(uint8_t* id_buf, void* handle,
|
||||||
void* data);
|
void* data);
|
||||||
|
|
||||||
// data types
|
// data types
|
||||||
#define RUST_UV_HANDLE_LEN 16
|
#define RUST_UV_HANDLE_LEN 16
|
||||||
|
|
||||||
struct handle_data {
|
struct handle_data {
|
||||||
uint8_t id_buf[RUST_UV_HANDLE_LEN];
|
uint8_t id_buf[RUST_UV_HANDLE_LEN];
|
||||||
crust_simple_cb cb;
|
crust_simple_cb cb;
|
||||||
crust_close_cb close_cb;
|
crust_close_cb close_cb;
|
||||||
};
|
};
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
@ -37,52 +37,52 @@ current_kernel_free(void* ptr) {
|
|||||||
|
|
||||||
static handle_data*
|
static handle_data*
|
||||||
new_handle_data_from(uint8_t* buf, crust_simple_cb cb) {
|
new_handle_data_from(uint8_t* buf, crust_simple_cb cb) {
|
||||||
handle_data* data = (handle_data*)current_kernel_malloc(
|
handle_data* data = (handle_data*)current_kernel_malloc(
|
||||||
sizeof(handle_data),
|
sizeof(handle_data),
|
||||||
"handle_data");
|
"handle_data");
|
||||||
memcpy(data->id_buf, buf, RUST_UV_HANDLE_LEN);
|
memcpy(data->id_buf, buf, RUST_UV_HANDLE_LEN);
|
||||||
data->cb = cb;
|
data->cb = cb;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// libuv callback impls
|
// libuv callback impls
|
||||||
static void
|
static void
|
||||||
native_crust_async_op_cb(uv_async_t* handle, int status) {
|
native_crust_async_op_cb(uv_async_t* handle, int status) {
|
||||||
crust_async_op_cb cb = (crust_async_op_cb)handle->data;
|
crust_async_op_cb cb = (crust_async_op_cb)handle->data;
|
||||||
void* loop_data = handle->loop->data;
|
void* loop_data = handle->loop->data;
|
||||||
cb(handle->loop, loop_data, handle);
|
cb(handle->loop, loop_data, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
native_async_cb(uv_async_t* handle, int status) {
|
native_async_cb(uv_async_t* handle, int status) {
|
||||||
handle_data* handle_d = (handle_data*)handle->data;
|
handle_data* handle_d = (handle_data*)handle->data;
|
||||||
void* loop_data = handle->loop->data;
|
void* loop_data = handle->loop->data;
|
||||||
handle_d->cb(handle_d->id_buf, loop_data);
|
handle_d->cb(handle_d->id_buf, loop_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
native_timer_cb(uv_timer_t* handle, int status) {
|
native_timer_cb(uv_timer_t* handle, int status) {
|
||||||
handle_data* handle_d = (handle_data*)handle->data;
|
handle_data* handle_d = (handle_data*)handle->data;
|
||||||
void* loop_data = handle->loop->data;
|
void* loop_data = handle->loop->data;
|
||||||
handle_d->cb(handle_d->id_buf, loop_data);
|
handle_d->cb(handle_d->id_buf, loop_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
native_close_cb(uv_handle_t* handle) {
|
native_close_cb(uv_handle_t* handle) {
|
||||||
handle_data* data = (handle_data*)handle->data;
|
handle_data* data = (handle_data*)handle->data;
|
||||||
data->close_cb(data->id_buf, handle, handle->loop->data);
|
data->close_cb(data->id_buf, handle, handle->loop->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
native_close_op_cb(uv_handle_t* op_handle) {
|
native_close_op_cb(uv_handle_t* op_handle) {
|
||||||
current_kernel_free(op_handle);
|
current_kernel_free(op_handle);
|
||||||
// uv_run() should return after this..
|
// uv_run() should return after this..
|
||||||
}
|
}
|
||||||
|
|
||||||
// native fns bound in rust
|
// native fns bound in rust
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_free(void* ptr) {
|
rust_uv_free(void* ptr) {
|
||||||
current_kernel_free(ptr);
|
current_kernel_free(ptr);
|
||||||
}
|
}
|
||||||
extern "C" void*
|
extern "C" void*
|
||||||
rust_uv_loop_new() {
|
rust_uv_loop_new() {
|
||||||
@ -117,49 +117,49 @@ rust_uv_loop_set_data(uv_loop_t* loop, void* data) {
|
|||||||
|
|
||||||
extern "C" void*
|
extern "C" void*
|
||||||
rust_uv_bind_op_cb(uv_loop_t* loop, crust_async_op_cb cb) {
|
rust_uv_bind_op_cb(uv_loop_t* loop, crust_async_op_cb cb) {
|
||||||
uv_async_t* async = (uv_async_t*)current_kernel_malloc(
|
uv_async_t* async = (uv_async_t*)current_kernel_malloc(
|
||||||
sizeof(uv_async_t),
|
sizeof(uv_async_t),
|
||||||
"uv_async_t");
|
"uv_async_t");
|
||||||
uv_async_init(loop, async, native_crust_async_op_cb);
|
uv_async_init(loop, async, native_crust_async_op_cb);
|
||||||
async->data = (void*)cb;
|
async->data = (void*)cb;
|
||||||
// decrement the ref count, so that our async bind
|
// decrement the ref count, so that our async bind
|
||||||
// doesn't count towards keeping the loop alive
|
// doesn't count towards keeping the loop alive
|
||||||
//uv_unref(loop);
|
//uv_unref(loop);
|
||||||
return async;
|
return async;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_stop_op_cb(uv_handle_t* op_handle) {
|
rust_uv_stop_op_cb(uv_handle_t* op_handle) {
|
||||||
uv_close(op_handle, native_close_op_cb);
|
uv_close(op_handle, native_close_op_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_run(uv_loop_t* loop) {
|
rust_uv_run(uv_loop_t* loop) {
|
||||||
uv_run(loop);
|
uv_run(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_close(uv_handle_t* handle, uv_close_cb cb) {
|
rust_uv_close(uv_handle_t* handle, uv_close_cb cb) {
|
||||||
uv_close(handle, cb);
|
uv_close(handle, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_hilvl_close(uv_handle_t* handle, crust_close_cb cb) {
|
rust_uv_hilvl_close(uv_handle_t* handle, crust_close_cb cb) {
|
||||||
handle_data* data = (handle_data*)handle->data;
|
handle_data* data = (handle_data*)handle->data;
|
||||||
data->close_cb = cb;
|
data->close_cb = cb;
|
||||||
uv_close(handle, native_close_cb);
|
uv_close(handle, native_close_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_hilvl_close_async(uv_async_t* handle) {
|
rust_uv_hilvl_close_async(uv_async_t* handle) {
|
||||||
current_kernel_free(handle->data);
|
current_kernel_free(handle->data);
|
||||||
current_kernel_free(handle);
|
current_kernel_free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_hilvl_close_timer(uv_async_t* handle) {
|
rust_uv_hilvl_close_timer(uv_async_t* handle) {
|
||||||
current_kernel_free(handle->data);
|
current_kernel_free(handle->data);
|
||||||
current_kernel_free(handle);
|
current_kernel_free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
@ -169,233 +169,226 @@ rust_uv_async_send(uv_async_t* handle) {
|
|||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_async_init(uv_loop_t* loop_handle,
|
rust_uv_async_init(uv_loop_t* loop_handle,
|
||||||
uv_async_t* async_handle,
|
uv_async_t* async_handle,
|
||||||
uv_async_cb cb) {
|
uv_async_cb cb) {
|
||||||
return uv_async_init(loop_handle, async_handle, cb);
|
return uv_async_init(loop_handle, async_handle, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void*
|
extern "C" void*
|
||||||
rust_uv_hilvl_async_init(uv_loop_t* loop, crust_simple_cb cb,
|
rust_uv_hilvl_async_init(uv_loop_t* loop, crust_simple_cb cb,
|
||||||
uint8_t* buf) {
|
uint8_t* buf) {
|
||||||
uv_async_t* async = (uv_async_t*)current_kernel_malloc(
|
uv_async_t* async = (uv_async_t*)current_kernel_malloc(
|
||||||
sizeof(uv_async_t),
|
sizeof(uv_async_t),
|
||||||
"uv_async_t");
|
"uv_async_t");
|
||||||
uv_async_init(loop, async, native_async_cb);
|
uv_async_init(loop, async, native_async_cb);
|
||||||
handle_data* data = new_handle_data_from(buf, cb);
|
handle_data* data = new_handle_data_from(buf, cb);
|
||||||
async->data = data;
|
async->data = data;
|
||||||
|
|
||||||
return async;
|
return async;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void*
|
extern "C" void*
|
||||||
rust_uv_timer_init(uv_loop_t* loop, crust_simple_cb cb,
|
rust_uv_timer_init(uv_loop_t* loop, crust_simple_cb cb,
|
||||||
uint8_t* buf) {
|
uint8_t* buf) {
|
||||||
uv_timer_t* new_timer = (uv_timer_t*)current_kernel_malloc(
|
uv_timer_t* new_timer = (uv_timer_t*)current_kernel_malloc(
|
||||||
sizeof(uv_timer_t),
|
sizeof(uv_timer_t),
|
||||||
"uv_timer_t");
|
"uv_timer_t");
|
||||||
uv_timer_init(loop, new_timer);
|
uv_timer_init(loop, new_timer);
|
||||||
handle_data* data = new_handle_data_from(buf, cb);
|
handle_data* data = new_handle_data_from(buf, cb);
|
||||||
new_timer->data = data;
|
new_timer->data = data;
|
||||||
|
|
||||||
return new_timer;
|
return new_timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_timer_start(uv_timer_t* the_timer, uint32_t timeout,
|
rust_uv_timer_start(uv_timer_t* the_timer, uint32_t timeout,
|
||||||
uint32_t repeat) {
|
uint32_t repeat) {
|
||||||
uv_timer_start(the_timer, native_timer_cb, timeout, repeat);
|
uv_timer_start(the_timer, native_timer_cb, timeout, repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_timer_stop(uv_timer_t* the_timer) {
|
rust_uv_timer_stop(uv_timer_t* the_timer) {
|
||||||
uv_timer_stop(the_timer);
|
uv_timer_stop(the_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_tcp_init(uv_loop_t* loop, uv_tcp_t* handle) {
|
rust_uv_tcp_init(uv_loop_t* loop, uv_tcp_t* handle) {
|
||||||
return uv_tcp_init(loop, handle);
|
return uv_tcp_init(loop, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_tcp_connect(uv_connect_t* connect_ptr,
|
rust_uv_tcp_connect(uv_connect_t* connect_ptr,
|
||||||
uv_tcp_t* tcp_ptr,
|
uv_tcp_t* tcp_ptr,
|
||||||
uv_connect_cb cb,
|
uv_connect_cb cb,
|
||||||
sockaddr_in* addr_ptr) {
|
sockaddr_in* addr_ptr) {
|
||||||
printf("inside rust_uv_tcp_connect\n");
|
printf("inside rust_uv_tcp_connect\n");
|
||||||
// FIXME ref #2064
|
// FIXME ref #2064
|
||||||
sockaddr_in addr = *addr_ptr;
|
sockaddr_in addr = *addr_ptr;
|
||||||
printf("before tcp_connect .. port: %d\n", addr.sin_port);
|
printf("before tcp_connect .. port: %d\n", addr.sin_port);
|
||||||
printf("before tcp_connect.. tcp stream: %lu cb ptr: %lu\n",
|
printf("before tcp_connect.. tcp stream: %lu cb ptr: %lu\n",
|
||||||
(unsigned long int)tcp_ptr, (unsigned long int)cb);
|
(unsigned long int)tcp_ptr, (unsigned long int)cb);
|
||||||
int result = uv_tcp_connect(connect_ptr, tcp_ptr, addr, cb);
|
int result = uv_tcp_connect(connect_ptr, tcp_ptr, addr, cb);
|
||||||
printf ("leaving rust_uv_tcp_connect.. and result: %d\n",
|
printf ("leaving rust_uv_tcp_connect.. and result: %d\n",
|
||||||
result);
|
result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_tcp_bind(uv_tcp_t* tcp_server, sockaddr_in* addr_ptr) {
|
rust_uv_tcp_bind(uv_tcp_t* tcp_server, sockaddr_in* addr_ptr) {
|
||||||
// FIXME ref #2064
|
// FIXME ref #2064
|
||||||
sockaddr_in addr = *addr_ptr;
|
sockaddr_in addr = *addr_ptr;
|
||||||
printf("before uv_tcp_bind .. tcp_server: %lu port: %d\n",
|
printf("before uv_tcp_bind .. tcp_server: %lu port: %d\n",
|
||||||
(unsigned long int)tcp_server, addr.sin_port);
|
(unsigned long int)tcp_server, addr.sin_port);
|
||||||
return uv_tcp_bind(tcp_server, addr);
|
return uv_tcp_bind(tcp_server, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_listen(uv_stream_t* stream, int backlog,
|
rust_uv_listen(uv_stream_t* stream, int backlog,
|
||||||
uv_connection_cb cb) {
|
uv_connection_cb cb) {
|
||||||
return uv_listen(stream, backlog, cb);
|
return uv_listen(stream, backlog, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_accept(uv_stream_t* server, uv_stream_t* client) {
|
rust_uv_accept(uv_stream_t* server, uv_stream_t* client) {
|
||||||
return uv_accept(server, client);
|
return uv_accept(server, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
rust_uv_helper_uv_tcp_t_size() {
|
rust_uv_helper_uv_tcp_t_size() {
|
||||||
return sizeof(uv_tcp_t);
|
return sizeof(uv_tcp_t);
|
||||||
}
|
}
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
rust_uv_helper_uv_connect_t_size() {
|
rust_uv_helper_uv_connect_t_size() {
|
||||||
return sizeof(uv_connect_t);
|
return sizeof(uv_connect_t);
|
||||||
}
|
}
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
rust_uv_helper_uv_buf_t_size() {
|
rust_uv_helper_uv_buf_t_size() {
|
||||||
return sizeof(uv_buf_t);
|
return sizeof(uv_buf_t);
|
||||||
}
|
}
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
rust_uv_helper_uv_write_t_size() {
|
rust_uv_helper_uv_write_t_size() {
|
||||||
return sizeof(uv_write_t);
|
return sizeof(uv_write_t);
|
||||||
}
|
}
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
rust_uv_helper_uv_err_t_size() {
|
rust_uv_helper_uv_err_t_size() {
|
||||||
return sizeof(uv_err_t);
|
return sizeof(uv_err_t);
|
||||||
}
|
}
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
rust_uv_helper_sockaddr_in_size() {
|
rust_uv_helper_sockaddr_in_size() {
|
||||||
return sizeof(sockaddr_in);
|
return sizeof(sockaddr_in);
|
||||||
}
|
}
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
rust_uv_helper_uv_async_t_size() {
|
rust_uv_helper_uv_async_t_size() {
|
||||||
return sizeof(uv_async_t);
|
return sizeof(uv_async_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uv_stream_t*
|
extern "C" uv_stream_t*
|
||||||
rust_uv_get_stream_handle_from_connect_req(uv_connect_t* connect) {
|
rust_uv_get_stream_handle_from_connect_req(uv_connect_t* connect) {
|
||||||
return connect->handle;
|
return connect->handle;
|
||||||
}
|
}
|
||||||
extern "C" uv_stream_t*
|
extern "C" uv_stream_t*
|
||||||
rust_uv_get_stream_handle_from_write_req(uv_write_t* write_req) {
|
rust_uv_get_stream_handle_from_write_req(uv_write_t* write_req) {
|
||||||
return write_req->handle;
|
return write_req->handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uv_buf_t
|
extern "C" uv_buf_t
|
||||||
current_kernel_malloc_alloc_cb(uv_handle_t* handle,
|
current_kernel_malloc_alloc_cb(uv_handle_t* handle,
|
||||||
size_t suggested_size) {
|
size_t suggested_size) {
|
||||||
char* base_ptr = (char*)current_kernel_malloc(sizeof(char)
|
char* base_ptr = (char*)current_kernel_malloc(sizeof(char)
|
||||||
* suggested_size,
|
* suggested_size,
|
||||||
"uv_buf_t_base_val");
|
"uv_buf_t_base_val");
|
||||||
return uv_buf_init(base_ptr, suggested_size);
|
return uv_buf_init(base_ptr, suggested_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uv_buf_t
|
extern "C" uv_buf_t
|
||||||
rust_uv_buf_init(char* base, size_t len) {
|
rust_uv_buf_init(char* base, size_t len) {
|
||||||
return uv_buf_init(base, len);
|
return uv_buf_init(base, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uv_loop_t*
|
extern "C" uv_loop_t*
|
||||||
rust_uv_get_loop_for_uv_handle(uv_handle_t* handle) {
|
rust_uv_get_loop_for_uv_handle(uv_handle_t* handle) {
|
||||||
return handle->loop;
|
return handle->loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void*
|
extern "C" void*
|
||||||
rust_uv_get_data_for_uv_handle(uv_handle_t* handle) {
|
rust_uv_get_data_for_uv_handle(uv_handle_t* handle) {
|
||||||
return handle->data;
|
return handle->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_set_data_for_uv_handle(uv_handle_t* handle,
|
rust_uv_set_data_for_uv_handle(uv_handle_t* handle,
|
||||||
void* data) {
|
void* data) {
|
||||||
handle->data = data;
|
handle->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void*
|
extern "C" void*
|
||||||
rust_uv_get_data_for_req(uv_req_t* req) {
|
rust_uv_get_data_for_req(uv_req_t* req) {
|
||||||
return req->data;
|
return req->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_set_data_for_req(uv_req_t* req, void* data) {
|
rust_uv_set_data_for_req(uv_req_t* req, void* data) {
|
||||||
req->data = data;
|
req->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" char*
|
extern "C" char*
|
||||||
rust_uv_get_base_from_buf(uv_buf_t buf) {
|
rust_uv_get_base_from_buf(uv_buf_t buf) {
|
||||||
return buf.base;
|
return buf.base;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" size_t
|
extern "C" size_t
|
||||||
rust_uv_get_len_from_buf(uv_buf_t buf) {
|
rust_uv_get_len_from_buf(uv_buf_t buf) {
|
||||||
return buf.len;
|
return buf.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uv_err_t
|
extern "C" uv_err_t
|
||||||
rust_uv_last_error(uv_loop_t* loop) {
|
rust_uv_last_error(uv_loop_t* loop) {
|
||||||
return uv_last_error(loop);
|
return uv_last_error(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" const char*
|
extern "C" const char*
|
||||||
rust_uv_strerror(uv_err_t* err_ptr) {
|
rust_uv_strerror(uv_err_t* err_ptr) {
|
||||||
uv_err_t err = *err_ptr;
|
uv_err_t err = *err_ptr;
|
||||||
return uv_strerror(err);
|
return uv_strerror(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" const char*
|
extern "C" const char*
|
||||||
rust_uv_err_name(uv_err_t* err_ptr) {
|
rust_uv_err_name(uv_err_t* err_ptr) {
|
||||||
uv_err_t err = *err_ptr;
|
uv_err_t err = *err_ptr;
|
||||||
return uv_err_name(err);
|
return uv_err_name(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_write(uv_write_t* req, uv_stream_t* handle,
|
rust_uv_write(uv_write_t* req, uv_stream_t* handle,
|
||||||
uv_buf_t* bufs, int buf_cnt,
|
uv_buf_t* bufs, int buf_cnt,
|
||||||
uv_write_cb cb) {
|
uv_write_cb cb) {
|
||||||
return uv_write(req, handle, bufs, buf_cnt, cb);
|
return uv_write(req, handle, bufs, buf_cnt, cb);
|
||||||
}
|
}
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_read_start(uv_stream_t* stream, uv_alloc_cb on_alloc,
|
rust_uv_read_start(uv_stream_t* stream, uv_alloc_cb on_alloc,
|
||||||
uv_read_cb on_read) {
|
uv_read_cb on_read) {
|
||||||
return uv_read_start(stream, on_alloc, on_read);
|
return uv_read_start(stream, on_alloc, on_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
rust_uv_read_stop(uv_stream_t* stream) {
|
rust_uv_read_stop(uv_stream_t* stream) {
|
||||||
return uv_read_stop(stream);
|
return uv_read_stop(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" char*
|
extern "C" char*
|
||||||
rust_uv_malloc_buf_base_of(size_t suggested_size) {
|
rust_uv_malloc_buf_base_of(size_t suggested_size) {
|
||||||
return (char*) current_kernel_malloc(sizeof(char)*suggested_size,
|
return (char*) current_kernel_malloc(sizeof(char)*suggested_size,
|
||||||
"uv_buf_t base");
|
"uv_buf_t base");
|
||||||
}
|
}
|
||||||
extern "C" void
|
extern "C" void
|
||||||
rust_uv_free_base_of_buf(uv_buf_t buf) {
|
rust_uv_free_base_of_buf(uv_buf_t buf) {
|
||||||
current_kernel_free(buf.base);
|
current_kernel_free(buf.base);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" struct sockaddr_in
|
extern "C" struct sockaddr_in
|
||||||
rust_uv_ip4_addr(const char* ip, int port) {
|
rust_uv_ip4_addr(const char* ip, int port) {
|
||||||
printf("before creating addr_ptr.. ip %s port %d\n", ip, port);
|
printf("before creating addr_ptr.. ip %s port %d\n", ip, port);
|
||||||
struct sockaddr_in addr = uv_ip4_addr(ip, port);
|
struct sockaddr_in addr = uv_ip4_addr(ip, port);
|
||||||
printf("after creating .. port: %d\n", addr.sin_port);
|
printf("after creating .. port: %d\n", addr.sin_port);
|
||||||
return addr;
|
return addr;
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" bool
|
|
||||||
rust_uv_ip4_test_verify_port_val(struct sockaddr_in addr,
|
|
||||||
unsigned int expected) {
|
|
||||||
printf("inside c++ ip4_test .. port: %u\n", addr.sin_port);
|
|
||||||
return addr.sin_port == expected;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user