Implement sys/file.h
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "sys_file"
|
||||
version = "0.1.0"
|
||||
authors = ["jD91mZM2 <me@krake.one>"]
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
[dependencies]
|
||||
platform = { path = "../platform" }
|
||||
@@ -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/file.h");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
include_guard = "_SYS_FILE_H"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,21 @@
|
||||
//! sys/file.h implementation
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate platform;
|
||||
|
||||
use platform::types::*;
|
||||
|
||||
pub const LOCK_SH: usize = 1;
|
||||
pub const LOCK_EX: usize = 1 << 1;
|
||||
pub const LOCK_NB: usize = 1 << 2;
|
||||
pub const LOCK_UN: usize = 1 << 3;
|
||||
|
||||
pub const L_SET: usize = 0;
|
||||
pub const L_INCR: usize = 1;
|
||||
pub const L_XTND: usize = 2;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn flock(fd: c_int, operation: c_int) -> c_int {
|
||||
platform::flock(fd, operation)
|
||||
}
|
||||
Reference in New Issue
Block a user