diff options
Diffstat (limited to 'ffi/src/core.rs')
-rw-r--r-- | ffi/src/core.rs | 77 |
1 files changed, 35 insertions, 42 deletions
diff --git a/ffi/src/core.rs b/ffi/src/core.rs index 8ad3a655..5b139fb4 100644 --- a/ffi/src/core.rs +++ b/ffi/src/core.rs @@ -64,9 +64,8 @@ impl Context { /// Returns the last error. /// /// Returns and removes the last error from the context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_last_error(ctx: *mut Context) - -> *mut ::error::Error { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_last_error(ctx: *mut Context) -> *mut ::error::Error { let ctx = ffi_param_ref_mut!(ctx); ::std::mem::replace(&mut ctx.e, ptr::null_mut()) } @@ -79,10 +78,10 @@ pub extern "system" fn sq_context_last_error(ctx: *mut Context) /// /// Returns `NULL` on errors. If `errp` is not `NULL`, the error is /// stored there. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_new(domain: *const c_char, - errp: Option<&mut *mut ::error::Error>) - -> *mut Context { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_new(domain: *const c_char, + errp: Option<&mut *mut ::error::Error>) + -> *mut Context { ffi_make_fry_from_errp!(errp); let domain = ffi_param_cstr!(domain).to_string_lossy(); @@ -90,8 +89,8 @@ pub extern "system" fn sq_context_new(domain: *const c_char, } /// Frees a context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_free(context: Option<&mut Context>) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_free(context: Option<&mut Context>) { ffi_free!(context) } @@ -104,52 +103,51 @@ pub extern "system" fn sq_context_free(context: Option<&mut Context>) { /// The configuration is seeded like in `sq_context_new`, but can be /// modified. A configuration has to be finalized using /// `sq_config_build()` in order to turn it into a Context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_configure(domain: *const c_char) - -> *mut Config { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_configure(domain: *const c_char) -> *mut Config { let domain = ffi_param_cstr!(domain).to_string_lossy(); Box::into_raw(Box::new(core::Context::configure(&domain))) } /// Returns the domain of the context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_domain(ctx: *const Context) -> *const c_char { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_domain(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.domain().as_bytes().as_ptr() as *const c_char } /// Returns the directory containing shared state. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_home(ctx: *const Context) -> *const c_char { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_home(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.home().to_string_lossy().as_ptr() as *const c_char } /// Returns the directory containing backend servers. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_lib(ctx: *const Context) -> *const c_char { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_lib(ctx: *const Context) -> *const c_char { let ctx = ffi_param_ref!(ctx); ctx.c.lib().to_string_lossy().as_bytes().as_ptr() as *const c_char } /// Returns the network policy. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_network_policy(ctx: *const Context) -> c_int { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_network_policy(ctx: *const Context) -> c_int { let ctx = ffi_param_ref!(ctx); u8::from(ctx.c.network_policy()) as c_int } /// Returns the IPC policy. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_ipc_policy(ctx: *const Context) -> c_int { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_ipc_policy(ctx: *const Context) -> c_int { let ctx = ffi_param_ref!(ctx); u8::from(ctx.c.ipc_policy()) as c_int } /// Returns whether or not this is an ephemeral context. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_context_ephemeral(ctx: *const Context) -> uint8_t { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_context_ephemeral(ctx: *const Context) -> uint8_t { let ctx = ffi_param_ref!(ctx); if ctx.c.ephemeral() { 1 } else { 0 } } @@ -161,10 +159,9 @@ pub extern "system" fn sq_context_ephemeral(ctx: *const Context) -> uint8_t { /// /// Consumes `cfg`. Returns `NULL` on errors. Returns `NULL` on /// errors. If `errp` is not `NULL`, the error is stored there. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_build(cfg: *mut Config, - errp: Option<&mut *mut ::error::Error>) - -> *mut Context { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_build(cfg: *mut Config, errp: Option<&mut *mut ::error::Error>) + -> *mut Context { ffi_make_fry_from_errp!(errp); let cfg = ffi_param_move!(cfg); @@ -172,27 +169,24 @@ pub extern "system" fn sq_config_build(cfg: *mut Config, } /// Sets the directory containing shared state. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_home(cfg: *mut Config, - home: *const c_char) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_home(cfg: *mut Config, home: *const c_char) { let cfg = ffi_param_ref_mut!(cfg); let home = ffi_param_cstr!(home).to_string_lossy(); cfg.set_home(home.as_ref()); } /// Set the directory containing backend servers. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_lib(cfg: *mut Config, - lib: *const c_char) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_lib(cfg: *mut Config, lib: *const c_char) { let cfg = ffi_param_ref_mut!(cfg); let lib = ffi_param_cstr!(lib).to_string_lossy(); cfg.set_lib(&lib.as_ref()); } /// Sets the network policy. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_network_policy(cfg: *mut Config, - policy: c_int) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_network_policy(cfg: *mut Config, policy: c_int) { let cfg = ffi_param_ref_mut!(cfg); if policy < 0 || policy > 3 { panic!("Bad network policy: {}", policy); @@ -201,9 +195,8 @@ pub extern "system" fn sq_config_network_policy(cfg: *mut Config, } /// Sets the IPC policy. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_ipc_policy(cfg: *mut Config, - policy: c_int) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_ipc_policy(cfg: *mut Config, policy: c_int) { let cfg = ffi_param_ref_mut!(cfg); if policy < 0 || policy > 2 { panic!("Bad ipc policy: {}", policy); @@ -212,8 +205,8 @@ pub extern "system" fn sq_config_ipc_policy(cfg: *mut Config, } /// Makes this context ephemeral. -#[::ffi_catch_abort] #[no_mangle] -pub extern "system" fn sq_config_ephemeral(cfg: *mut Config) { +#[::ffi_catch_abort] #[no_mangle] pub extern "C" +fn sq_config_ephemeral(cfg: *mut Config) { let cfg = ffi_param_ref_mut!(cfg); cfg.set_ephemeral(); } |