Add structures and stub fns for sys/socket.h

Add some of the basic structures and stub functions for sys/socket.h
This commit is contained in:
Dan Robertson
2018-03-15 17:19:58 +00:00
parent a1baf1c92d
commit 01081729c8
7 changed files with 197 additions and 0 deletions
Generated
+9
View File
@@ -263,6 +263,7 @@ dependencies = [
"resource 0.1.0",
"semaphore 0.1.0",
"signal 0.1.0",
"socket 0.1.0",
"stat 0.1.0",
"stdio 0.1.0",
"stdlib 0.1.0",
@@ -351,6 +352,14 @@ dependencies = [
"platform 0.1.0",
]
[[package]]
name = "socket"
version = "0.1.0"
dependencies = [
"cbindgen 0.5.2",
"platform 0.1.0",
]
[[package]]
name = "standalone-quote"
version = "0.5.0"
+1
View File
@@ -23,6 +23,7 @@ platform = { path = "src/platform" }
resource = { path = "src/resource" }
semaphore = { path = "src/semaphore" }
signal = { path = "src/signal" }
socket = { path = "src/socket" }
stat = { path = "src/stat" }
stdio = { path = "src/stdio" }
stdlib = { path = "src/stdlib" }
+1
View File
@@ -13,6 +13,7 @@ extern crate grp;
extern crate mman;
extern crate resource;
extern crate semaphore;
extern crate socket;
extern crate stat;
extern crate stdio;
extern crate stdlib;
+11
View File
@@ -0,0 +1,11 @@
[package]
name = "socket"
version = "0.1.0"
authors = ["Dan Robertson <danlrobertson89@gmail.com>"]
build = "build.rs"
[build-dependencies]
cbindgen = { path = "../../cbindgen" }
[dependencies]
platform = { path = "../platform" }
+11
View File
@@ -0,0 +1,11 @@
extern crate cbindgen;
use std::{env, fs};
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
fs::create_dir_all("../../target/include").expect("failed to create include directory");
cbindgen::generate(crate_dir)
.expect("failed to generate bindings")
.write_to_file("../../target/include/sys/socket.h");
}
+11
View File
@@ -0,0 +1,11 @@
sys_includes = ["sys/types.h"]
include_guard = "_SYS_SOCKET_H"
style = "Tag"
language = "C"
[defines]
"target_os=linux" = "__linux__"
"target_os=redox" = "__redox__"
[enum]
prefix_with_name = true
+153
View File
@@ -0,0 +1,153 @@
//! socket implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html
#![no_std]
#![allow(non_camel_case_types)]
extern crate platform;
use platform::types::*;
pub type sa_family_t = u16;
pub type socklen_t = u32;
#[repr(C)]
pub struct sockaddr {
pub sa_family: sa_family_t,
pub sa_data: [c_char; 14],
}
#[no_mangle]
pub unsafe extern "C" fn accept(
socket: c_int,
address: *mut sockaddr,
address_len: *mut socklen_t,
) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn bind(
socket: c_int,
address: *const sockaddr,
address_len: socklen_t,
) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn connect(
socket: c_int,
address: *const sockaddr,
address_len: socklen_t,
) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn getpeername(
socket: c_int,
address: *const sockaddr,
address_len: socklen_t,
) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn getsockname(
socket: c_int,
address: *mut sockaddr,
address_len: *mut socklen_t,
) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn getsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *mut c_void,
option_len: *mut socklen_t,
) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn listen(socket: c_int, backlog: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn recv(
socket: c_int,
buffer: *mut c_void,
length: size_t,
flags: c_int,
) -> ssize_t {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn recvfrom(
socket: c_int,
buffer: *mut c_void,
length: size_t,
flags: c_int,
address: *mut sockaddr,
address_len: *mut socklen_t,
) -> ssize_t {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn send(
socket: c_int,
message: *const c_void,
length: size_t,
flags: c_int,
) -> ssize_t {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn sento(
socket: c_int,
message: *const c_void,
length: size_t,
flags: c_int,
dest_addr: *const sockaddr,
dest_len: socklen_t,
) -> ssize_t {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn setsockopt(
socket: c_int,
level: c_int,
option_name: c_int,
option_value: *const c_void,
option_len: socklen_t,
) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn shutdown(socket: c_int, how: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn socket(domain: c_int, _type: c_int, protocol: c_int) -> c_int {
unimplemented!();
}
#[no_mangle]
pub unsafe extern "C" fn socketpair(
domain: c_int,
_type: c_int,
protocol: c_int,
socket_vector: [c_int; 2],
) -> c_int {
unimplemented!();
}